' Question of QB64Forum
' Basically I want to write a program to input data, store the data, <-- this is DATABASE
' retrieve the data, add to it, etc.
' I would like the ability to have a new window/app, run concurrently <-- this is a graphic plotter
' with the main window/app, but be able to display/plot the data
' I retrieved from the main window/app.
' 2020 02 12 with the power of the second array we implement the feature
' of resizable of child window
' 2020 02 09 with the power of the second array we implement a different
' child windows' system:
' all child windows can be Closed to window's bar
' all child windows can be dragged on the screen
' 2020 02 08 using a second array we store windows information indipendently so
' now each window can be modified and restored
' 2020 02 06 after dragging or maximize a window, restoring it we gives
' to it the last value used in windows(0) so the info of the last
' window that is dragged or maximize when we use Minimize button on
' another child window
' the fix can be got using a shadow array that stores windows informations
' or windows(0) as the child window that takes the information of the
' child window that must be acted (Minimize, Maximize and Closed)
' and we use it as template to make graphic output
' 2020 02 05 fixed a minor bug on mouse click events
' activated events Maxim Minim and Closed
' 2020 02 03 increasing the windows managed and close initialization to SUB
' removed vMax SHARED variable
' added 3 buttons on the rightest site of the bar of the child window
' SUB wClosed, wMaxim, wMinim
' In this version the user can maximize one child window to the application window
' In the status of Maxim the child window has the focus and can be only
' reduced to status Minim, it cannot be dragging or Closed to bar of window
' 2020 01 30 fixed bug on focusing a child window
'
' 2020 01 25 A program with child windows into it
' we need a system to manage multiple windows
' and a system to manage input/output
' and a system to make graphic report
' settings-------------------------------------------------------
CONST Black
= _RGBA32(0, 0, 0, 255), White
= _RGBA32(255, 255, 255, 255), Red
= _RGBA32(200, 0, 0, 255) CONST Green
= _RGBA32(0, 200, 0, 255), Blu
= _RGBA32(0, 0, 200, 255), Yellow
= _RGBA32(200, 200, 20, 255) CONST Cyan
= _RGBA32(20, 140, 230, 255), Orange
= _RGBA32(200, 100, 20, 255), Pink
= _RGBA32(227, 80, 120, 255) CONST Minim
= 10, Maxim
= 20, Closed
= 100 CONST wMin
= 5, aNull
= 0, aQuit
= 9999 CONST mTrue
= 1, mFalse
= 0, mLeft
= 2, mRight
= 3, mMiddle
= 4, mLR
= 5 CONST Dragging
= 300, Focusing
= 200, cMinim
= 400, cMaxim
= 500, cClosed
= 600 CONST cResize
= 700, LResize
= 710, RResize
= 720, StopResize
= 730
'dataset -----------------------------------------------
InitWin
' main loop -----------------------------------------------
' set the main window
Action = aNull
DrawAllWin
GetInput Action
DoAction Action
' SUBs and FUNCTIONs --------------------------------------
Windows(1).X = 1
Windows(1).Y = 1
Windows(1).Height = 400
Windows(1).Zorder = 1
Windows(1).Status = Minim
Windows(2).X = 100
Windows(2).Y = 1
Windows(2).Height = 400
Windows(2).Zorder = 2
Windows(2).Status = Minim
Windows
(2).
Color = Yellow
Windows(3).X = 200
Windows(3).Y = 1
Windows(3).Height = 400
Windows(3).Zorder = 3
Windows(3).Status = Minim
Windows(4).X = 300
Windows(4).Y = 1
Windows(4).Height = 400
Windows(4).Zorder = 4
Windows(4).Status = Minim
Windows(5).X = 400
Windows(5).Y = 1
Windows(5).Height = 400
Windows(5).Zorder = 5
Windows(5).Status = Minim
AdjournWin a
Windows(a).X = OldW(a).X
Windows(a).Y = OldW(a).Y
Windows(a).Height = OldW(a).Height
Windows(a).Zorder = OldW(a).Zorder
OldW(a).X = Windows(a).X
OldW(a).Y = Windows(a).Y
OldW(a).Height = Windows(a).Height
OldW(a).Zorder = Windows(a).Zorder
Finished = wMin
IF Windows
(a
).Zorder
= Finished
THEN DrawWindow Windows(a)
Finished = Finished - 1
IF Index
<> b
THEN SWAP Windows
(Index
).Zorder
, Windows
(b
).Zorder
DrawAllWin
' search where and what mouse has touched by leftclick
OldA = 0
OldActio = 0
FOR a
= 1 TO wMin
' windows(0) is out of action Actio = IsInWindow(mX, mY, Windows(a))
OldA = a
OldActio = Actio
ELSEIF Windows
(a
).Zorder
< Windows
(OldA
).Zorder
THEN OldA = a
OldActio = Actio
a = OldA ' restore the last windows interacting
Actio = OldActio
Focus a 'set zorder on the (a) window that gets the input
' here restore to standard (bar + area of window) status of child window
IF Windows
(a
).Status
= Closed
+ Maxim
THEN ' if windows is a closed maximized window
' we restore its status of maximized
Windows(a).Status = Maxim
' if windows is a closed minimized window
' we restore its status of minimized
Windows(a).Status = Minim
' if is a window maximized it gets back all info setting
' we restore its status of minimized
RestoreWin a
Windows(a).Status = Minim
' here convert the window to full size of main window of the program
' OR gives 1 if both parameter are true or al last one is true
IF (Windows
(a
).Status
= Minim
OR Windows
(a
).Status
= Closed
+ Minim
) THEN ' it acts if windows if not still maximized
' it is minimized window opened or closed
' memorize window's data when it is not maximized
' IF Windows(a).Width < _WIDTH THEN
AdjournWin a
' it sets maximized status
Windows(a).X = 1
Windows(a).Y = 1
' change status
Windows(a).Status = Maxim
' here minimize the child window to its window bar
Windows(a).Status = Windows(a).Status + Closed
' dragging is possible for all status of windows
'
' if minimized or Closed and minimized window we save data info
IF Windows
(a
).Status
= Minim
OR Windows
(a
).Status
= Closed
+ Minim
THEN AdjournWin a
' it sets variables for dragging
OldW(0).X = Windows(a).X
OldW(0).Y = Windows(a).Y
OldW(0).Height = Windows(a).Height
DrawAllWin
dragWindow OldW(0)
' new position of window
Windows(a).X = OldW(0).X
Windows(a).Y = OldW(0).Y
OldW(a).X = Windows(a).X
OldW(a).Y = Windows(a).Y
Focus a
' resizing is possible only for minimized opened child windows
IF Windows
(a
).Status
= Minim
THEN Windows(a).Status = cResize
DO WHILE Windows
(a
).Status
= cResize
DrawAllWin
ShowDimension Windows(a)
Actio = 0
IF IsInTheRange%
(mY
, Win.Y
, Win.Y
+ Win.Height
) THEN ' do nothing if is in the range of window
' user click out of area of window to resize
Actio = StopResize
' user click out of area of window to resize
Actio = StopResize
IF IsInTheRange%
(mX
, Win.X
, Win.X
+ 10) THEN IF IsInTheRange%
(mY
, Win.Y
, Win.Y
+ 10) THEN ' user click on lefttop square to resize
Actio = LResize
IF IsInTheRange%
(mY
, Win.Y
+ Win.Height
- 10, Win.Y
+ Win.Height
) THEN ' user click on the rightbottom square to resize
Actio = RResize
' no action done
' choosen LeftTop buttom to resize
OldW(0).X = Win.X
OldW(0).Y = Win.Y
OldW(0).Height = Win.Height
IF (OldW
(0).Y
+ OldW
(0).Height
- OldmY
) >= 30 THEN OldW
(0).Height
= OldW
(0).Y
+ OldW
(0).Height
- OldmY
DrawAllWin
ShowDimension OldW(0)
OldW(0).X = OldmX
OldW(0).Y = OldmY
Win.X = OldW(0).X
Win.Y = OldW(0).Y
Win.Height = OldW(0).Height
' choosen bottomright square
OldW(0).X = Win.X
OldW(0).Y = Win.Y
OldW(0).Height = Win.Height
IF OldmX
- OldW
(0).X
>= 50 THEN OldW
(0).
Width = OldmX
- OldW
(0).X
IF OldmY
- OldW
(0).Y
>= 30 THEN OldW
(0).Height
= OldmY
- OldW
(0).Y
DrawAllWin
ShowDimension OldW(0)
Win.X = OldW(0).X
Win.Y = OldW(0).Y
Win.Height = OldW(0).Height
' click out of window to stop resize action
Win.Status = Minim
SUB ShowDimension
(win
AS wChild
) LINE (win.X
, win.Y
)-(win.X
+ win.
Width, win.Y
+ win.Height
), White
, B
' windows size LINE (win.X
, win.Y
)-(win.X
+ 10, win.Y
+ 10), White
, BF
'button for resizing window LINE (win.X
+ win.
Width - 10, win.Y
+ win.Height
- 10)-(win.X
+ win.
Width, win.Y
+ win.Height
), White
, BF
'button for resizing window
IsInWindow = mFalse
IF IsInTheRange%
(Y
, Win.Y
+ 11, Win.Y
+ Win.Height
) = mTrue
THEN ' if window is closed to its bar it cannot get focus on the window area
IF IsInTheRange%
(X
, Win.X
, Win.X
+ Win.
Width) AND (Win.Status
< Closed
) THEN IsInWindow
= Focusing
ELSEIF IsInTheRange%
(Y
, Win.Y
, Win.Y
+ 10) = mTrue
THEN ' if is the window bar area
IF IsInTheRange%
(X
, Win.X
+ 10, Win.X
+ Win.
Width - 31) THEN ' if it is to the left of buttons on the bar
IsInWindow = Dragging
' if it is on the leftest button on the bar
IsInWindow = cMinim ' icon minimize--> restore to child default
' if it is on the middle button on the bar
IsInWindow = cMaxim ' icon maximize--> expand to fullscreen
' if is on the rightest button on the bar
IsInWindow = cClosed ' icon close-->reduce to the bar of child window
IsInWindow = cResize
IF What
> Min
AND What
< Max
THEN IsInTheRange%
= mTrue
ELSE IsInTheRange%
= mFalse
SUB dragWindow
(Win
AS wChild
) LINE (Win.X
, Win.Y
)-(Win.X
+ Win.
Width, Win.Y
+ Win.Height
), White
, B
' windows size LINE (Win.X
, Win.Y
)-(Win.X
+ Win.
Width, Win.Y
+ 10), White
, BF
'title bar for dragging window
SUB wClosed
(Win
AS wChild
) LINE (Win.X
+ Win.
Width - 10, Win.Y
)-(Win.X
+ Win.
Width, Win.Y
+ 10), Pink
, BF
'title bar for restore to original dimensions LINE (Win.X
+ Win.
Width - 10, Win.Y
)-(Win.X
+ Win.
Width, Win.Y
+ 10), Black
, B
LINE (Win.X
+ Win.
Width - 7, Win.Y
+ 3)-(Win.X
+ Win.
Width - 3, Win.Y
+ 7), Black
LINE (Win.X
+ Win.
Width - 7, Win.Y
+ 7)-(Win.X
+ Win.
Width - 3, Win.Y
+ 3), Black
SUB wMaxim
(win
AS wChild
) LINE (win.X
+ win.
Width - 20, win.Y
)-(win.X
+ win.
Width - 10, win.Y
+ 10), Pink
, BF
'title bar for restore to original dimensions LINE (win.X
+ win.
Width - 20, win.Y
)-(win.X
+ win.
Width - 10, win.Y
+ 10), Black
, B
LINE (win.X
+ win.
Width - 17, win.Y
+ 3)-(win.X
+ win.
Width - 13, win.Y
+ 7), Black
, B
SUB wMinim
(Win
AS wChild
) LINE (Win.X
+ Win.
Width - 30, Win.Y
)-(Win.X
+ Win.
Width - 20, Win.Y
+ 10), Pink
, BF
'title bar for restore to original dimensions LINE (Win.X
+ Win.
Width - 30, Win.Y
)-(Win.X
+ Win.
Width - 20, Win.Y
+ 10), Black
, B
LINE (Win.X
+ Win.
Width - 27, Win.Y
+ 7)-(Win.X
+ Win.
Width - 23, Win.Y
+ 7), Black
SUB wResize
(Win
AS wChild
) LINE (Win.X
, Win.Y
)-(Win.X
+ 10, Win.Y
+ 10), Pink
, BF
'title bar for restore to original dimensions LINE (Win.X
, Win.Y
)-(Win.X
+ 10, Win.Y
+ 10), Black
, B
LINE (Win.X
+ 2, Win.Y
+ 2)-(Win.X
+ 7, Win.Y
+ 7), Black
, B
, &B1010101010101010
SUB DrawWindow
(Win
AS wChild
) ' the window
IF Win.Status
= Minim
OR Win.Status
= Maxim
THEN LINE (Win.X
, Win.Y
)-(Win.X
+ Win.
Width, Win.Y
+ Win.Height
), Win.
Color, BF
LINE (Win.X
, Win.Y
+ Win.Height
)-(Win.X
+ Win.
Width, Win.Y
+ Win.Height
), Black
LINE (Win.X
+ Win.
Width, Win.Y
)-(Win.X
+ Win.
Width, Win.Y
+ Win.Height
), Black
' the status bar
LINE (Win.X
, Win.Y
)-(Win.X
+ Win.
Width, Win.Y
+ 10), Pink
, BF
'title bar for dragging window LINE (Win.X
, Win.Y
+ 10)-(Win.X
+ Win.
Width, Win.Y
+ 10), Black
wMinim Win
wMaxim Win
wClosed Win
wResize Win
' keyboard input
'mouse input
mInput = mFalse
mInput = mLR
mInput = mLeft
mInput = mRight
mInput = mMiddle
Act = aQuit
Act = Minim
Act = Maxim
Act = mInput