'GUI 02/27/16
OnWindow
AS INTEGER ' current window pointer is hovering over X
AS INTEGER ' current desktop mouse x coordinate Y
AS INTEGER ' current desktop mouse y coordinate PX
AS INTEGER ' previous desktop mouse x coordinate PY
AS INTEGER ' previous desktop mouse y coordinate WindowX
AS INTEGER ' current window mouse x coordinate WindowY
AS INTEGER ' current window mouse y coordinate SurfaceX
AS INTEGER ' current work space mouse x coordinate SurfaceY
AS INTEGER ' current work space mouse y coordinate OnSurface
AS INTEGER ' [BOOL] mouse currently hovering over surface? OnTitlebar
AS INTEGER ' [BOOL] mouse currently hovering over title bar? OnBorder
AS INTEGER ' [BOOL] mouse currently hovering over a border? Border
AS INTEGER ' border(s) mouse hovering (1-top, 2-right, 4-bottom, 8-left ... i.e. 6 = bottom right corner) LeftClick
AS INTEGER ' [BOOL] mouse left button currently pressed? RightClick
AS INTEGER ' [BOOL] mouse right button currently pressed? Move
AS INTEGER ' window currently in the process of being moved Resize
AS INTEGER ' current window being resized LeftReleased
AS INTEGER ' [BOOL] left mouse button released? RightReleased
AS INTEGER ' [BOOL] right mouse button released?
OnButton
AS INTEGER ' current button pointer is hovering over ButtonPressed
AS INTEGER ' current button being held down ButtonClicked
AS INTEGER ' button that was clicked then released
Surface
AS LONG ' [IMG] window surface image SurfaceX
AS INTEGER ' x location of current work space SurfaceY
AS INTEGER ' y location of current workspace SHeight
AS INTEGER ' height of current surface HasFocus
AS INTEGER ' [BOOL] current window has focus?
Font
AS LONG ' [FONT] window font Surface
AS LONG ' [IMG] surface image BGImage
AS LONG ' [IMG] background image under window TBFImage
AS LONG ' [IMG] title bar image when window has focus TBNFImage
AS LONG ' [IMG] title bar image when window has lost focus Wred
AS INTEGER ' [CLR] red component of Wcolor Wgreen
AS INTEGER ' [CLR] green component of Wcolor Wblue
AS INTEGER ' [CLR] blue component of Wcolor Visible
AS INTEGER ' [BOOL] window on screen?
'ByMethod AS INTEGER ' [BOOL] -1 = window dimensions by surface, 0 = dimensions by window
Move
AS INTEGER ' [BOOL] window currently being moved? Resize
AS INTEGER ' [BOOL] window currently being resized Icon
AS LONG ' [IMG] window icon
CloseButton
AS INTEGER ' 0 = no button, >0 = button handle number
Maximized
AS INTEGER ' -1 window currently maximized, 0 = normal (use 'state' instead for max/min/normal?) Minimized
AS INTEGER ' -1 window currently minimized
Rwidth
AS INTEGER ' restore width (when max or min - values to restore window size)
State
AS INTEGER ' state of button: -1 = pressed, 0 = normal, 1 = disabled Normal
AS LONG ' [IMG] normal button Pressed
AS LONG ' [IMG] pressed button Disabled
AS LONG ' [IMG] disabled button WinButton
AS INTEGER ' [BOOL] indicates a button for window use only (scroll bar buttons, etc..)
Icon
AS LONG ' [IMG] mouse pointer image
DIM POINTER
(15) AS MOUSEPOINTERS
POINTERS
WINDOW_DESKTOP 1024, 768, 0, ""
'FOR i% = 1 TO 10
' untitled%(i%) = WINDOW_NEW(320, 240)
' WINDOW_SETTITLE untitled%(i%), "Untitled-" + LTRIM$(STR$(i%))
' WIN(untitled%(i%)).TBSolid = 0
' WINDOW_MAKE untitled%(i%)
' WINDOW_SHOW untitled%(i%)
' WINDOW_PUT untitled%(i%), 140 + i% * 25, 20 + i% * 25, BYWINDOW
' WIN(untitled%(i%)).Size = -1
'NEXT i%
untitled1% = WINDOW_NEW(640, 480)
untitled2% = WINDOW_NEW(320, 240)
untitled3% = WINDOW_NEW(160, 120)
WINDOW_SETTITLE untitled1%, "Untitled-1"
WINDOW_SETTITLE untitled2%, "Untitled-2"
WINDOW_SETTITLE untitled3%, "Untitled-3"
WIN(untitled2%).TBSolid = 0 ' need to create library command for this
WINDOW_MAKE untitled3%
WINDOW_MAKE untitled2%
WINDOW_MAKE untitled1%
WINDOW_SHOW untitled1%
WINDOW_SHOW untitled2%
WINDOW_SHOW untitled3%
WINDOW_PUT untitled3%, 150, 25, BYWINDOW
WINDOW_PUT untitled2%, 200, 100, BYWINDOW
WINDOW_PUT untitled1%, 300, 200, BYWINDOW
WIN(untitled1%).Size = -1 ' need to create library command for this
WIN(untitled2%).Size = -1 ' need to create library command for this
WIN(untitled3%).Size = -1 ' need to create library command for this
WINDOW_REFRESH
PRINT " Focus ------> "; WinOrder%
(1) PRINT " Mouse X ----> "; MOUSE.X
PRINT " Mouse Y ----> "; MOUSE.Y
PRINT " On Window --> "; MOUSE.OnWindow
PRINT " Window X ---> "; MOUSE.WindowX
PRINT " Window Y ---> "; MOUSE.WindowY
PRINT " On Surface -> "; MOUSE.OnSurface
PRINT " Surface X---> "; MOUSE.SurfaceX
PRINT " Surface Y --> "; MOUSE.SurfaceY
PRINT " On TitleBar > "; MOUSE.OnTitlebar
PRINT " On Border --> "; MOUSE.OnBorder
PRINT " Border -----> "; MOUSE.Border
PRINT " Left Click -> "; MOUSE.LeftClick
PRINT " Right Click > "; MOUSE.RightClick
PRINT " Moving -----> "; MOUSE.Move
PRINT " Resizing ---> "; MOUSE.Resize
PRINT " On Button --> "; MOUSE.OnButton
PRINT " Button Press> "; MOUSE.ButtonPressed
PRINT " Button Click> "; MOUSE.ButtonClicked
'--------------------------------------------------------------------------------------------------------------------------------
' TBIMAGE
' h% = window handle
' f% = focus 1, no focus 0
DIM Redinc!
, Greeninc!
, Blueinc!
_DEST WIN
(h%
).TBFImage
' draw on title bar focus image _FONT WIN
(h%
).Font
' set title bar font COLOR WIN
(h%
).TTColor
' set font color CLS , WIN
(h%
).TBColor
' yes, color title bar Red!
= _RED(WIN
(h%
).TBColor
) ' get title bar color components Green!
= _GREEN(WIN
(h%
).TBColor
) Blue!
= _BLUE(WIN
(h%
).TBColor
) Redinc! = (255 - Red!) / WIN(h%).SWidth / 2 ' calculate color fade values
Greeninc! = (255 - Green!) / WIN(h%).SWidth / 2
Blueinc! = (255 - Blue!) / WIN(h%).SWidth / 2
Red! = 128
Green! = 128
Blue! = 128
Redinc! = 63 / WIN(h%).SWidth
Greeninc! = 63 / WIN(h%).SWidth
Blueinc! = 63 / WIN(h%).SWidth
FOR c%
= 0 TO WIN
(h%
).SWidth
- 1 LINE (c%
, 0)-(c%
, WIN
(h%
).TBHeight
- 1), _RGB32(Red!
, Green!
, Blue!
) Red! = Red! + Redinc!
Green! = Green! + Greeninc!
Blue! = Blue! + Blueinc!
IF WIN
(h%
).CloseButton
THEN w%
= w%
+ BUT
(WIN
(h%
).CloseButton
).
Width IF WIN
(h%
).MaxButton
THEN w%
= w%
+ BUT
(WIN
(h%
).MaxButton
).
Width IF WIN
(h%
).MinButton
THEN w%
= w%
+ BUT
(WIN
(h%
).MinButton
).
Width
mw% = WIN(h%).SWidth - (WIN(h%).TBHeight + 2) - w%
WIN
(h%
).MinWidth
= _PRINTWIDTH(LEFT$(t$
, 3) + "...") + WIN
(h%
).TBHeight
+ 2 + w%
nt$ = t$
nt$ = t$ + "..."
_PRINTSTRING (WIN
(h%
).TBHeight
+ 2, 4), nt$
' print title on title bar _PUTIMAGE (2, 1)-(WIN
(h%
).TBHeight
- 1, WIN
(h%
).TBHeight
- 2), WIN
(h%
).Icon
' place icon on title bar
'--------------------------------------------------------------------------------------------------------------------------------
' WITHIN
'*
'* Returns true if mouse pointer within given coordinate pairs.
'*
IF MOUSE.X
>= x%
THEN ' mouse pointer inside given rectangle? WITHIN = -1 ' yes, return true
'--------------------------------------------------------------------------------------------------------------------------------
' BUTTON_PUT
SUB BUTTON_PUT
(b%
, x%
, y%
, state%
) ' state% needed?
IF BUT
(b%
).WinButton
THEN ' is button for window use only? SELECT CASE BUT
(b%
).State
' which state is title bar button in? _PUTIMAGE (BUT
(b%
).X
, BUT
(b%
).Y
), BUT
(b%
).Pressed
, WIN
(BUT
(b%
).
Window).
Window ' draw pressed button on window CASE 0 ' normal (depressed) state _PUTIMAGE (BUT
(b%
).X
, BUT
(b%
).Y
), BUT
(b%
).Normal
, WIN
(BUT
(b%
).
Window).
Window ' draw normal button on window _PUTIMAGE (BUT
(b%
).X
, BUT
(b%
).Y
), BUT
(b%
).Disabled
, WIN
(BUT
(b%
).
Window).
Window ' draw disabled button on window
'*
'* Custom made buttons here
'*
'--------------------------------------------------------------------------------------------------------------------------------
' BUTTON_NEW
FUNCTION BUTTON_NEW
(win%
, w%
, h%
, t$
, f&
, c~&
, t~&
) '*
'* win% - window button belongs to (negative value sent in means a title bar button is being created)
'* w% - width of button (ignored if title bar button is being created)
'* h% - height of button (ignored if title bar button is being created)
'* t$ - text to be placed on button (if title bar button then "CLOSE", "MAXIMIZE", "MINIMIZE', and "RESTORE")
'* f& - text font (ignored if title bar button is being created)
'* c~& - button color (if 0 then window color is used)
'* t~& - text color (if 0 then balck is used)
'*
DIM i%
' next available button array index
i%
= UBOUND(BUT
) ' get last button index i% = i% - 1 ' go to previous index
WEND ' leave when last button still being used i% = 0 ' start at beginning
c% = 1
DO ' cycle through button indexes i% = c% ' no, use this index
c% = c% + 1 ' increment index counter
i% = c% ' use this index
LOOP UNTIL i%
' leave when available index found IF win%
< 0 THEN ' button belong to a title bar? win% = -win% ' yes, correct window handle
BUT(i%).WinButton = -1 ' mark button as belonging to a title bar
BUT
(i%
).
Window = win%
' button belongs to window (0 for desktop)BUT(i%).InUse = -1 ' mark index as used
BUT(i%).State = 0 ' default to normal
BUT(i%).X = 0 ' reset x coordinate
BUT(i%).Y = 0 ' reset y coordinate
IF BUT
(i%
).WinButton
THEN ' creating a title bar button? BUT(i%).Height = WIN(win%).TBHeight - 4 ' calculate button height
BUT
(i%
).
Width = INT(BUT
(i%
).Height
* 1.14286) ' calculate button width IF w%
THEN BUT
(i%
).Height
= BUT
(i%
).
Width ' yes, height=width x2%
= BUT
(i%
).
Width - 1 ' calculate right bottom corner button X y2% = BUT(i%).Height - 1 ' calculate right bottom corner button Y
BUT(i%).State = 0 ' set button as normal (depressed)
BUT
(i%
).Normal
= _NEWIMAGE(BUT
(i%
).
Width, BUT
(i%
).Height
, 32) ' create normal image holder _DEST BUT
(i%
).Normal
' draw on image CLS , WIN
(win%
).Darkest
' create common button image LINE (0, 0)-(x2%
- 1, y2%
- 1), WIN
(win%
).Lighter
, B
' draw background LINE (1, 1)-(x2%
- 1, y2%
- 1), WIN
(win%
).Darker
, B
LINE (1, 1)-(x2%
- 2, y2%
- 2), WIN
(win%
).WColor
, BF
BUT
(i%
).Pressed
= _NEWIMAGE(BUT
(i%
).
Width, BUT
(i%
).Height
, 32) ' create pressed image holder _DEST BUT
(i%
).Pressed
' draw on image CLS , WIN
(win%
).Lighter
' create common button image LINE (0, 0)-(x2%
- 1, y2%
- 1), WIN
(win%
).Darkest
, B
' draw background LINE (1, 1)-(x2%
- 1, y2%
- 1), WIN
(win%
).WColor
, B
LINE (1, 1)-(x2%
- 2, y2%
- 2), WIN
(win%
).Darker
, B
LINE (2, 2)-(x2%
- 1, y2%
- 1), WIN
(win%
).WColor
, BF
BUT
(i%
).Disabled
= _NEWIMAGE(BUT
(i%
).
Width, BUT
(i%
).Height
, 32) ' create disabled image holder _DEST BUT
(i%
).Disabled
' yes, draw on image CLS , WIN
(win%
).Darkest
' create common button image LINE (0, 0)-(x2%
- 1, y2%
- 1), WIN
(win%
).Lighter
, B
' draw background LINE (1, 1)-(x2%
- 1, y2%
- 1), WIN
(win%
).Darker
, B
LINE (1, 1)-(x2%
- 2, y2%
- 2), WIN
(win%
).WColor
, BF
SELECT CASE t$
' yes, which window button being created? CASE "CLOSE" ' close button _DEST BUT
(i%
).Normal
' work on normal LINE (4, 3)-(x2%
- 5, y2%
- 4), _RGB32(0, 0, 0) ' draw depressed button _DEST BUT
(i%
).Pressed
' work on pressed LINE (5, 4)-(x2%
- 4, y2%
- 3), _RGB32(0, 0, 0) ' draw pressed button _DEST BUT
(i%
).Disabled
' work on disabled LINE (5, y2%
- 4)-(x2%
- 4, 4), _RGB32(255, 255, 255) ' draw disabled button LINE (6, y2%
- 4)-(x2%
- 3, 4), _RGB32(255, 255, 255) LINE (x2%
- 4, y2%
- 3)-(x2%
- 3, y2%
- 3), _RGB32(255, 255, 255) ' LINE (4, 3)-(x2%
- 5, y2%
- 4), _RGB32(128, 128, 128) LINE (5, 3)-(x2%
- 4, y2%
- 4), _RGB32(128, 128, 128) LINE (4, y2%
- 4)-(x2%
- 5, 3), _RGB32(128, 128, 128) LINE (5, y2%
- 4)-(x2%
- 4, 3), _RGB32(128, 128, 128) CASE "MAXIMIZE" ' maximize button _DEST BUT
(i%
).Normal
' work on normal LINE (3, 3)-(x2%
- 4, y2%
- 3), _RGB32(0, 0, 0), B
' draw depressed button _DEST BUT
(i%
).Pressed
' work on pressed LINE (4, 4)-(x2%
- 3, y2%
- 2), _RGB32(0, 0, 0), B
' draw pressed button _DEST BUT
(i%
).Disabled
' work on disabled LINE (4, 4)-(x2%
- 3, y2%
- 2), _RGB32(255, 255, 255), B
' draw disabled button LINE (3, 3)-(x2%
- 4, y2%
- 3), _RGB32(128, 128, 128), B
CASE "MINIMIZE" ' minimize button _DEST BUT
(i%
).Normal
' work on normal LINE (4, y2%
- 4)-(x2%
- 6, y2%
- 3), _RGB32(0, 0, 0), B
' draw depressed button _DEST BUT
(i%
).Pressed
' work on pressed LINE (5, y2%
- 3)-(x2%
- 5, y2%
- 2), _RGB32(0, 0, 0), B
' draw pressed button _DEST BUT
(i%
).Disabled
' work on disabled LINE (5, y2%
- 3)-(x2%
- 5, y2%
- 2), _RGB32(255, 255, 255), B
' draw disabled button LINE (4, y2%
- 4)-(x2%
- 6, y2%
- 3), _RGB32(128, 128, 128), B
CASE "RESTORE" ' restore button _DEST BUT
(i%
).Normal
' work on normal LINE (3, 6)-(x2%
- 7, y2%
- 3), _RGB32(0, 0, 0), B
' draw depressed button LINE (x2%
- 5, 4)-(x2%
- 5, y2%
- 6), _RGB32(0, 0, 0) _DEST BUT
(i%
).Pressed
' work on pressed LINE (4, 7)-(x2%
- 6, y2%
- 2), _RGB32(0, 0, 0), B
' draw pressed button LINE (x2%
- 4, 5)-(x2%
- 4, y2%
- 5), _RGB32(0, 0, 0) _DEST BUT
(i%
).Disabled
' work on disabled LINE (4, 7)-(x2%
- 6, y2%
- 2), _RGB32(255, 255, 255), B
' draw disabled button LINE (x2%
- 5, 3)-(x2%
- 4, y2%
- 5), _RGB32(255, 255, 255), B
LINE (3, 6)-(x2%
- 7, y2%
- 3), _RGB32(128, 128, 128), B
LINE (5, 2)-(x2%
- 5, 3), _RGB32(128, 128, 128), B
LINE (x2%
- 5, 4)-(x2%
- 5, y2%
- 6), _RGB32(128, 128, 128) LINE (5, BUT
(i%
).Height \
2)-(x2%
- 7, 4), _RGB32(0, 0, 0) LINE (6, BUT
(i%
).Height \
2 + 1)-(x2%
- 6, 5), _RGB32(0, 0, 0) LINE -(6, BUT
(i%
).Height \
2 + 1), _RGB32(0, 0, 0) LINE (x2%
- 6, BUT
(i%
).Height \
2)-(6, 4), _RGB32(0, 0, 0) LINE -(x2%
- 6, BUT
(i%
).Height \
2), _RGB32(0, 0, 0) LINE (x2%
- 5, BUT
(i%
).Height \
2 + 1)-(7, 5), _RGB32(0, 0, 0) LINE -(x2%
- 5, BUT
(i%
).Height \
2 + 1), _RGB32(0, 0, 0)
'*
'* custom made buttons here
'*
BUTTON_NEW = i%
'--------------------------------------------------------------------------------------------------------------------------------
' WINDOW_MOUSE
'
' work in progress (only called when there has been mouse activity)
'
DIM c%
' current window being checked for mouse hover DIM o%
' order of windows DIM x%
' x offset movement of mouse DIM y%
' y offset movement of mouse
MOUSE.PX = MOUSE.X ' save last mouse x position
MOUSE.PY = MOUSE.Y ' save last mouse y position
MOUSE.X
= _MOUSEX ' set desktop x coordinate flagMOUSE.Y
= _MOUSEY ' set desktop y coordinate flagMOUSE.LeftClick
= _MOUSEBUTTON(1) ' set left mouse button statusMOUSE.RightClick
= _MOUSEBUTTON(2) ' set right mouse button status MOUSE.LeftReleased = -1 ' left mouse button has been released?
WIN(MOUSE.Move).Move = 0 ' yes, window no longer being moved
MOUSE.Move = 0 ' end window movement
WIN(MOUSE.Resize).Resize = 0 ' window no longer being resized
MOUSE.Resize = 0 ' end window resizing
MOUSE.Icon = 0 ' mouse pointer to default
IF MOUSE.ButtonPressed
THEN ' was a button being held down? MOUSE.ButtonClicked = MOUSE.ButtonPressed ' yes, this button has now been clicked
MOUSE.ButtonPressed = 0 ' button no longer being held down
BUT(MOUSE.ButtonClicked).State = 0 ' set button state back to normal
IF MOUSE.Move
THEN ' window currently being moved? WINDOW_PUT MOUSE.move, WIN(MOUSE.move).X + MOUSEMOVEMENTX,_
WIN(MOUSE.move).Y + MOUSEMOVEMENTY,_
BYWINDOW ' yes, update window position
ELSEIF MOUSE.Resize
THEN ' window currently being resized? x% = MOUSEMOVEMENTX ' yes, get change in x position
y% = MOUSEMOVEMENTY ' get change in y position
IF MOUSE.Border
AND 1 THEN ' mouse on top border? ty% = WIN(MOUSE.Resize).Height - y% ' yes, calculate possible y value
IF ty%
>= WIN
(MOUSE.Resize
).MinHeight
AND ty%
<= WIN
(MOUSE.Resize
).MaxHeight
THEN ' outside limits? WIN(MOUSE.Resize).Y = WIN(MOUSE.Resize).Y + y% ' no, adjust window y location
WIN(MOUSE.Resize).Height = ty% ' adjust overall window height
WIN(MOUSE.Resize).SHeight = WIN(MOUSE.Resize).SHeight - y% ' adjust window screen height
ELSE ' yes, minimum reached _MOUSEMOVE MOUSE.X
, MOUSE.PY
' force pointer back (not working correctly in GL) MOUSE.Y = MOUSE.PY ' update mouse y position
MOUSE.PY = MOUSEMOVEMENTY ' seed new y offset position
ty% = WIN(MOUSE.Resize).Height + y% ' calculate possible y value
IF ty%
>= WIN
(MOUSE.Resize
).MinHeight
AND ty%
<= WIN
(MOUSE.Resize
).MaxHeight
THEN ' outside limits? WIN(MOUSE.Resize).Height = ty% ' no, adjust overall window height
WIN(MOUSE.Resize).SHeight = WIN(MOUSE.Resize).SHeight + y% ' adjust window screen height
ELSE ' yes, minimum reached _MOUSEMOVE MOUSE.X
, MOUSE.PY
' force pointer back (not working correclty in GL) MOUSE.Y = MOUSE.PY ' update mouse y position
MOUSE.PY = MOUSEMOVEMENTY ' seed new y offset position
IF MOUSE.Border
AND 2 THEN ' mouse on right border? tx%
= WIN
(MOUSE.Resize
).
Width + x%
' yes, calculate possible x value IF tx%
>= WIN
(MOUSE.Resize
).MinWidth
AND tx%
<= WIN
(MOUSE.Resize
).MaxWidth
THEN ' outside limits? WIN
(MOUSE.Resize
).
Width = tx%
' no, adjust overall window width
WIN(MOUSE.Resize).SWidth = WIN(MOUSE.Resize).SWidth + x% ' adjust window screen width
ELSE ' yes, minimum reached _MOUSEMOVE MOUSE.PX
, MOUSE.Y
' force pointer back (not working correclty in GL) MOUSE.X = MOUSE.PX ' update mouse x position
MOUSE.PX = MOUSEMOVEMENTX ' seed new x offset position
tx%
= WIN
(MOUSE.Resize
).
Width - x%
' calculate possible x value IF tx%
>= WIN
(MOUSE.Resize
).MinWidth
AND tx%
<= WIN
(MOUSE.Resize
).MaxWidth
THEN ' outside limits? WIN(MOUSE.Resize).X = WIN(MOUSE.Resize).X + x% ' no, adjust window x location
WIN
(MOUSE.Resize
).
Width = tx%
' adjust overall window width
WIN(MOUSE.Resize).SWidth = WIN(MOUSE.Resize).SWidth - x% ' adjust window screen width
ELSE ' yes, minimum reached _MOUSEMOVE MOUSE.PX
, MOUSE.Y
' force pointer back (not working correctly in GL) MOUSE.X = MOUSE.PX ' update mouse x position
MOUSE.PX = MOUSEMOVEMENTX ' seed new x offset position
WINDOW_MAKE MOUSE.Resize ' redraw window
MOUSE.WindowX = MOUSE.X - WIN(MOUSE.OnWindow).X ' set window x coordinate flag
MOUSE.WindowY = MOUSE.Y - WIN(MOUSE.OnWindow).Y ' set window y coordinate flag
MOUSE.SurfaceX = MOUSE.WindowX - WIN(MOUSE.OnWindow).SurfaceX ' yes, set work space x flag
MOUSE.SurfaceY = MOUSE.WindowY - WIN(MOUSE.OnWindow).SurfaceY ' set work space y flag
IF NOT MOUSE.LeftReleased
THEN EXIT SUB ' don't interact if left button being held down
WIN.X = 0 ' reset window flags
WIN.Y = 0
WIN.Height = 0
WIN.Surface = 0
WIN.SurfaceX = 0
WIN.SurfaceY = 0
WIN.SWidth = 0
WIN.SHeight = 0
WIN.HasFocus = 0
MOUSE.Icon = 0
MOUSE.OnWindow = 0 ' reset remaining mouse flags
MOUSE.WindowX = 0
MOUSE.WindowY = 0
MOUSE.OnSurface = 0
MOUSE.SurfaceX = 0
MOUSE.SurfaceY = 0
MOUSE.OnTitlebar = 0
MOUSE.OnBorder = 0
MOUSE.Border = 0
MOUSE.OnButton = 0
DO ' loop through window order array c% = c% + 1 ' increment array index
o% = WinOrder%(c%) ' next window to check
IF WIN
(o%
).Visible
THEN ' is window visible on screen? WIN(o%).Y,_
WIN
(o%
).X
+ WIN
(o%
).
Width - 1,_
WIN
(o%
).Y
+ WIN
(o%
).Height
- 1) THEN ' yes, mouse within window coordinates? MOUSE.OnWindow = o% ' yes, set pointer flag to hovered window
MOUSE.WindowX = MOUSE.X - WIN(o%).X ' set window x coordinate flag
MOUSE.WindowY = MOUSE.Y - WIN(o%).Y ' set window y coordinate flag
WIN.X = WIN(o%).X
WIN.Y = WIN(o%).Y
WIN.Height = WIN(o%).Height ' set window height flag
WIN.Surface = WIN(o%).Surface
WIN.SurfaceX = WIN(o%).SurfaceX
WIN.SurfaceY = WIN(o%).SurfaceY
WIN.SWidth = WIN(o%).SWidth ' set window work space width flag
WIN.SHeight = WIN(o%).SHeight ' set window work space height flag
WIN.HasFocus = WIN(o%).Focus
IF WITHIN
(WIN
(o%
).X
+ WIN
(o%
).SurfaceX
,_
WIN(o%).Y + WIN(o%).SurfaceY,_
WIN(o%).X + WIN(o%).SurfaceX + WIN(o%).SWidth - 1,_
WIN
(o%
).Y
+ WIN
(o%
).SurfaceY
+ WIN
(o%
).SHeight
- 1) THEN ' mouse within screen coordinates? MOUSE.SurfaceX = MOUSE.WindowX - WIN(o%).SurfaceX ' yes, set screen x flag
MOUSE.SurfaceY = MOUSE.WindowY - WIN(o%).SurfaceY ' set screen y flag
MOUSE.OnSurface = -1 ' set screen flag
ELSEIF WITHIN
(WIN
(o%
).X
+ WIN
(o%
).SurfaceX
,_
WIN(o%).Y + WIN(o%).BWidth,_
WIN(o%).X + WIN(o%).SurfaceX + WIN(o%).SWidth - 1,_
WIN
(o%
).Y
+ WIN
(o%
).BWidth
+ WIN
(o%
).TBHeight
- 1) THEN ' no, mouse within title bar? IF WIN
(o%
).CloseButton
THEN ' yes, does this window have a close button? IF WITHIN
(WIN
(o%
).X
+ BUT
(WIN
(o%
).CloseButton
).X
,_
WIN(o%).Y + BUT(WIN(o%).CloseButton).Y,_
WIN
(o%
).X
+ BUT
(WIN
(o%
).CloseButton
).X
+ BUT
(WIN
(o%
).CloseButton
).
Width - 1,_
WIN
(o%
).Y
+ BUT
(WIN
(o%
).CloseButton
).Y
+ BUT
(WIN
(o%
).CloseButton
).Height
- 1) THEN ' yes, on button? MOUSE.OnButton = WIN(o%).CloseButton ' yes, set flag
IF WIN
(o%
).MaxButton
THEN ' does this window have a maximize button? IF WITHIN
(WIN
(o%
).X
+ BUT
(WIN
(o%
).MaxButton
).X
,_
WIN(o%).Y + BUT(WIN(o%).MaxButton).Y,_
WIN
(o%
).X
+ BUT
(WIN
(o%
).MaxButton
).X
+ BUT
(WIN
(o%
).MaxButton
).
Width - 1,_
WIN
(o%
).Y
+ BUT
(WIN
(o%
).MaxButton
).Y
+ BUT
(WIN
(o%
).MaxButton
).Height
- 1) THEN ' yes, on button? MOUSE.OnButton = WIN(o%).MaxButton ' yes, set flag
IF WIN
(o%
).MinButton
THEN ' does this window have a minimize button? IF WITHIN
(WIN
(o%
).X
+ BUT
(WIN
(o%
).MinButton
).X
,_
WIN(o%).Y + BUT(WIN(o%).MinButton).Y,_
WIN
(o%
).X
+ BUT
(WIN
(o%
).MinButton
).X
+ BUT
(WIN
(o%
).MinButton
).
Width - 1,_
WIN
(o%
).Y
+ BUT
(WIN
(o%
).MinButton
).Y
+ BUT
(WIN
(o%
).MinButton
).Height
- 1) THEN ' yes, on button? MOUSE.OnButton = WIN(o%).MinButton ' yes, set flag
IF MOUSE.OnButton
= 0 THEN MOUSE.OnTitlebar
= -1 ' if not on button then must be on title bar IF WIN
(o%
).Size
THEN ' is window resizable? IF MOUSE.OnSurface
+ MOUSE.OnTitlebar
+ MOUSE.OnButton
= 0 THEN ' yes, mouse on anything? MOUSE.OnBorder = -1 ' no, mouse must be on a border
IF MOUSE.Y
<= WIN
(o%
).Y
+ WIN
(o%
).BWidth
- 1 THEN ' on top border? MOUSE.Border = 1 ' yes, set border value
ELSEIF MOUSE.Y
>= WIN
(o%
).Y
+ WIN
(o%
).Height
- WIN
(o%
).BWidth
- 1 THEN ' no, on bottom border? MOUSE.Border = MOUSE.Border + 4 ' yes, add border value
IF MOUSE.X
>= WIN
(o%
).X
+ WIN
(o%
).
Width - WIN
(o%
).BWidth
- 1 THEN ' on right border? MOUSE.Border = MOUSE.Border + 2 ' yes, add border value
ELSEIF MOUSE.X
<= WIN
(o%
).X
+ WIN
(o%
).BWidth
- 1 THEN ' no, on left border? MOUSE.Border = MOUSE.Border + 8 ' yes, add border value
MOUSE.Icon = MOUSE.Border ' mouse icon to resize
LOOP UNTIL MOUSE.OnWindow
OR c%
= UBOUND(WinOrder%
) ' leave when hovering or entire array scanned IF MOUSE.LeftClick
THEN MOUSE.LeftReleased
= 0 ' left mouse button currently held down IF MOUSE.OnWindow
AND MOUSE.LeftClick
THEN ' is pointer on a window and left button pressed? WINDOW_SETFOCUS MOUSE.OnWindow ' yes, this window now has focus
c% = MOUSEMOVEMENTX ' seed mouse x offset function
c% = MOUSEMOVEMENTY ' seed mouse y offset function
IF MOUSE.OnTitlebar
AND MOUSE.Move
= 0 THEN ' is pointer on title bar and window not moving? MOUSE.Move = MOUSE.OnWindow ' yes, this window can now be moved
WIN(MOUSE.Move).Move = -1 ' set window state to moving
ELSEIF MOUSE.OnBorder
AND MOUSE.Resize
= 0 THEN ' is mouse on border and not resizing? MOUSE.Resize = MOUSE.OnWindow ' yes, this window can now be resized
WIN(MOUSE.Resize).Resize = -1 ' set window state to resizing
MOUSE.ButtonPressed = MOUSE.OnButton ' yes, button is currently being pressed
BUT(MOUSE.ButtonPressed).State = -1 ' set button state to pressed
'--------------------------------------------------------------------------------------------------------------------------------
' WINDOW_SETFOCUS
'
' h% = handle of window to set focus ******************** NEEDS FIXED for only 1 window
'
IF WIN
(h%
).Focus
THEN EXIT SUB ' leave if window already in focus DO ' loop through window order array c% = c% + 1 ' increment array index
LOOP UNTIL h%
= WinOrder%
(c%
) OR c%
= UBOUND(WinOrder%
) ' leave if window found or end of array reached FOR o%
= c%
- 1 TO 1 STEP -1 ' cycle through array WinOrder%(o% + 1) = WinOrder%(o%) ' move windows above h% down one
WinOrder%(1) = h% ' make this window the new focus
c% = WinOrder%(2)
WIN(h%).Focus = -1 ' this window now has focus
_PUTIMAGE (WIN
(h%
).BWidth
, WIN
(h%
).BWidth
), WIN
(h%
).TBFImage
, WIN
(h%
).
Window ' place focused title bar image on window
WIN(WinOrder%(2)).Focus = 0 ' previous window lost focus
_PUTIMAGE (WIN
(c%
).BWidth
, WIN
(c%
).BWidth
), WIN
(c%
).TBNFImage
, WIN
(c%
).
Window ' unfocused
'--------------------------------------------------------------------------------------------------------------------------------
' WINDOW_DESKTOP
SUB WINDOW_DESKTOP
(w%
, h%
, c~&
, i$
) '
' w% = desktop width (0 for default 640 or to use optional desktop image width)
' h% = desktop height (0 for default 480 or to use optional desktop image height)
' c~& = desktop color (0 for none)
' i$ = desktop image (null for none)
'
' If width and height are supplied then desktop is created with those dimensions and optional desktop image stretched across
'
DIM Back&
' desktop background image
IF w%
<> 0 AND h%
<> 0 THEN ' dimensions supplied? DeskTop&
= _NEWIMAGE(w%
, h%
, 32) ' yes, create desktop screen with dimensions Back&
= _LOADIMAGE(i$
, 32) ' yes, load background image _PUTIMAGE , Back&
, DeskTop&
' put background image on desktop screen _FREEIMAGE Back&
' background image no longer needed ELSE ' no, background image does not exist _DEST DeskTop&
' draw on desktop screen ELSE ' no dimensions supplied DeskTop&
= _LOADIMAGE(i$
, 32) ' yes, use this as the desktop ELSE ' no, background image does not exist DeskTop&
= _NEWIMAGE(640, 480, 32) ' create default 640x480 desktop screen _DEST DeskTop&
' draw on desktop screen CLS ' clear screen (remove transparency)
'--------------------------------------------------------------------------------------------------------------------------------
' WINDOW_REFRESH
IF DeskTop&
THEN _PUTIMAGE (0, 0), DeskTop&
' place background image if exist FOR o%
= UBOUND(WinOrder%
) TO 1 STEP -1 ' cycle through window order eversed h% = WinOrder%(o%) ' get next window handle
IF WIN
(h%
).Visible
THEN ' is this window visible?
IF WIN
(h%
).CloseButton
THEN BUTTON_PUT WIN
(h%
).CloseButton
, 0, 0, 0 ' draw close button if exist IF WIN
(h%
).MaxButton
THEN BUTTON_PUT WIN
(h%
).MaxButton
, 0, 0, 0 ' draw maximize button if exist IF WIN
(h%
).MinButton
THEN BUTTON_PUT WIN
(h%
).MinButton
, 0, 0, 0 ' draw minimize button if exist
_PUTIMAGE (WIN
(h%
).X
, WIN
(h%
).Y
), WIN
(h%
).
Window ' place window onto desktop _PUTIMAGE (MOUSE.X
+ POINTER
(MOUSE.Icon
).X
, MOUSE.Y
+ POINTER
(MOUSE.Icon
).Y
), POINTER
(MOUSE.Icon
).Icon
' place mouse pointer
'--------------------------------------------------------------------------------------------------------------------------------
' WINDOW_PUT
SUB WINDOW_PUT
(h%
, x%
, y%
, m%
) '
' h% - handle of window to move
' x% - new window x coordinate
' y% - new window y coordinate
' m% - method of move (by work space origin coordinates (BYSCREEN) or by entire window origin coordinates (BYWINDOW))
'
WIN(h%).X = x% - WIN(h%).BWidth
WIN(h%).Y = y% - WIN(h%).BWidth - WIN(h%).TBHeight
WIN(h%).X = x%
WIN(h%).Y = y%
'IF WIN(h%).Visible THEN WINDOW_SETFOCUS h% ' *************************************** focus routine needs fixing for only 1 window
'--------------------------------------------------------------------------------------------------------------------------------
' WINDOW_MAKE
'
' h% - handle of window to create
'
DIM Redinc!
, Greeninc!
, Blueinc!
p&(0) = 43690 ' scroll bar background pattern 1
p&(1) = 21845 ' scroll bar background pattern 2
CurrentDest&
= _DEST ' remember calling destination
IF WIN
(h%
).Resize
THEN ' window being resized? IF (MOUSE.Border
AND 2) OR (MOUSE.Border
AND 8) THEN ' resizing right or left border? _FREEIMAGE WIN
(h%
).TBFImage
' yes, remove title bar focus image _FREEIMAGE WIN
(h%
).TBNFImage
' remove title bar no focus image ELSE ' no, window being created CALCULATECOLORS h% ' calculate window color shades
WIN
(h%
).TBHeight
= _FONTHEIGHT(WIN
(h%
).Font
) + 8 ' calculate title bar height WIN
(h%
).
Width = WIN
(h%
).SWidth
+ WIN
(h%
).BWidth
* 2 ' yes, calculate window width WIN(h%).Height = WIN(h%).SHeight + WIN(h%).BWidth * 2 + WIN(h%).TBHeight + 1 ' calculate window height
WIN
(h%
).OWidth
= WIN
(h%
).
Width WIN(h%).OHeight = WIN(h%).Height
WIN(h%).MaxWidth = WIN(h%).OWidth ' save maximim width of window
WIN(h%).MaxHeight = WIN(h%).OHeight ' save maximim height of window
WIN(h%).SurfaceX = WIN(h%).BWidth ' calculate screen x location
WIN(h%).SurfaceY = WIN(h%).BWidth + WIN(h%).TBHeight ' calculate screen y location
WIN(h%).CloseButton = BUTTON_NEW(-h%, 0, 0, "CLOSE", 0, 0, 0) ' create close title bar button
WIN(h%).MaxButton = BUTTON_NEW(-h%, 0, 0, "MAXIMIZE", 0, 0, 0) ' create maximize title bar button
WIN(h%).MinButton = BUTTON_NEW(-h%, 0, 0, "MINIMIZE", 0, 0, 0) ' create minimize title bar button
WIN(h%).RestoreButton = BUTTON_NEW(-h%, 0, 0, "RESTORE", 0, 0, 0) ' create restore title bar button
WIN(h%).SUButton = BUTTON_NEW(-h%, 1, 0, "SCROLLUP", 0, 0, 0) ' create scroll bar up button
WIN(h%).SDButton = BUTTON_NEW(-h%, 1, 0, "SCROLLDOWN", 0, 0, 0) ' create scroll bar down button
WIN(h%).SLButton = BUTTON_NEW(-h%, 1, 0, "SCROLLLEFT", 0, 0, 0) ' create scroll bar left button
WIN(h%).SRButton = BUTTON_NEW(-h%, 1, 0, "SCROLLRIGHT", 0, 0, 0) ' create scroll bar right button
WIN(h%).MinHeight = WIN(h%).TBHeight + WIN(h%).BWidth * 2 + BUT(WIN(h%).SUButton).Height * 4 ' calculate min window height
WIN
(h%
).TBFImage
= _NEWIMAGE(WIN
(h%
).SWidth
, WIN
(h%
).TBHeight
, 32) ' create title bar with focus WIN
(h%
).TBNFImage
= _COPYIMAGE(WIN
(h%
).TBFImage
) ' create title bar without focus WIN
(h%
).Surface
= _NEWIMAGE(WIN
(h%
).SWidth
, WIN
(h%
).SHeight
, 32) ' create screen image container
BUT(WIN(h%).CloseButton).Y = WIN(h%).BWidth + 2 ' close button Y location
BUT(WIN(h%).MaxButton).Y = WIN(h%).BWidth + 2 ' maximize buttun Y location
BUT(WIN(h%).MinButton).Y = WIN(h%).BWidth + 2 ' minimize button Y location
BUT(WIN(h%).RestoreButton).Y = WIN(h%).BWidth + 2 ' restore button Y location
BUT(WIN(h%).SUButton).Y = WIN(h%).BWidth + WIN(h%).TBHeight + 1 ' scroll up button Y location
BUT(WIN(h%).SLButton).X = WIN(h%).BWidth ' scroll left button X location
BUT
(WIN
(h%
).CloseButton
).X
= WIN
(h%
).
Width - WIN
(h%
).BWidth
- BUT
(WIN
(h%
).CloseButton
).
Width - 2 ' close button X locationBUT
(WIN
(h%
).MaxButton
).X
= BUT
(WIN
(h%
).CloseButton
).X
- BUT
(WIN
(h%
).MaxButton
).
Width - 2 ' maximize button X locationBUT
(WIN
(h%
).MinButton
).X
= BUT
(WIN
(h%
).MaxButton
).X
- BUT
(WIN
(h%
).MinButton
).
Width ' minimize button X locationBUT(WIN(h%).RestoreButton).X = BUT(WIN(h%).MaxButton).X ' restore button X location
BUT(WIN(h%).SUButton).X = BUT(WIN(h%).CloseButton).X ' scroll up buttom X location
BUT(WIN(h%).SDButton).X = BUT(WIN(h%).CloseButton).X ' scroll down button X location
BUT(WIN(h%).SRButton).X = BUT(WIN(h%).CloseButton).X ' scroll right button X location
BUT(WIN(h%).SDButton).Y = WIN(h%).Height - WIN(h%).BWidth - BUT(WIN(h%).SDButton).Height ' scroll down button Y location
BUT(WIN(h%).SLButton).Y = WIN(h%).Height - WIN(h%).BWidth - BUT(WIN(h%).SDButton).Height ' scroll left button Y location
BUT(WIN(h%).SRButton).Y = BUT(WIN(h%).SLButton).Y ' scroll left button X location
IF NOT (WIN
(h%
).Resize
AND ((MOUSE.Border
= 1) OR (MOUSE.Border
= 4))) THEN ' resizing right or left border? WIN
(h%
).TBFImage
= _NEWIMAGE(WIN
(h%
).SWidth
, WIN
(h%
).TBHeight
, 32) ' yes, create title bar with focus WIN
(h%
).TBNFImage
= _COPYIMAGE(WIN
(h%
).TBFImage
) ' create title bar without focus TBIMAGE h%, 0 ' draw focused image
TBIMAGE h%, 1 ' draw unfocused image
CLS , WIN
(h%
).Lighter
' clear window image IF WIN
(h%
).Focus
THEN ' does this window have focus? _PUTIMAGE (WIN
(h%
).BWidth
, WIN
(h%
).BWidth
), WIN
(h%
).TBFImage
, WIN
(h%
).
Window ' yes, draw focused title bar _PUTIMAGE (WIN
(h%
).BWidth
, WIN
(h%
).BWidth
), WIN
(h%
).TBNFImage
, WIN
(h%
).
Window ' draw unfocused title bar
IF WIN
(h%
).SWidth
< WIN
(h%
).SIWidth
THEN
BUT(WIN(h%).SDButton).Y = BUT(WIN(h%).SDButton).Y - BUT(WIN(h%).SDButton).Height ' yes, adjust scroll down button Y
LINE (BUT
(WIN
(h%
).SLButton
).X
+ BUT
(WIN
(h%
).SLButton
).
Width - 1, BUT
(WIN
(h%
).SLButton
).Y
)-(BUT
(WIN
(h%
).SRButton
).X
, BUT
(WIN
(h%
).SRButton
).Y
+ BUT
(WIN
(h%
).SRButton
).Height
- 1), _RGB32(255, 255, 255), BF
FOR y%
= BUT
(WIN
(h%
).SLButton
).Y
TO BUT
(WIN
(h%
).SLButton
).Y
+ BUT
(WIN
(h%
).SLButton
).Height
- 1 LINE (BUT
(WIN
(h%
).SLButton
).X
+ BUT
(WIN
(h%
).SLButton
).
Width - 1, y%
)-(BUT
(WIN
(h%
).SRButton
).X
, y%
), _RGB32(212, 208, 200), , p&
(y%
AND 1) ' alternate odd/even pattern BUTTON_PUT WIN(h%).SLButton, 0, 0, 0
BUTTON_PUT WIN(h%).SRButton, 0, 0, 0
IF WIN
(h%
).SHeight
< WIN
(h%
).SIHeight
THEN
BUT
(WIN
(h%
).SRButton
).X
= BUT
(WIN
(h%
).SRButton
).X
- BUT
(WIN
(h%
).SRButton
).
Width ' yes, adjust scroll right button X
LINE (BUT
(WIN
(h%
).SUButton
).X
, BUT
(WIN
(h%
).SUButton
).Y
+ BUT
(WIN
(h%
).SUButton
).Height
)-(BUT
(WIN
(h%
).SDButton
).X
+ BUT
(WIN
(h%
).SDButton
).
Width - 1, BUT
(WIN
(h%
).SDButton
).Y
), _RGB32(255, 255, 255), BF
FOR x%
= BUT
(WIN
(h%
).SUButton
).X
TO BUT
(WIN
(h%
).SUButton
).X
+ BUT
(WIN
(h%
).SUButton
).
Width - 1 LINE (x%
, BUT
(WIN
(h%
).SUButton
).Y
+ BUT
(WIN
(h%
).SUButton
).Height
)-(x%
, BUT
(WIN
(h%
).SDButton
).Y
), _RGB32(212, 208, 200), , p&
(x%
AND 1) BUTTON_PUT WIN(h%).SUButton, 0, 0, 0
BUTTON_PUT WIN(h%).SDButton, 0, 0, 0
'**
'** Calculate where screen needs to sit inside viewport
'**
'** place window at viewport
'**
IF WIN
(h%
).BWidth
THEN ' draw a border? IF WIN
(h%
).BWidth
= 1 THEN ' yes, 1 pixel border? LINE (WIN
(h%
).
Width - 1, 0)-(WIN
(h%
).
Width - 1, WIN
(h%
).Height
- 1), WIN
(h%
).Dark
' yes, draw border LINE -(0, WIN
(h%
).Height
- 1), WIN
(h%
).Dark
IF WIN
(h%
).BWidth
= 2 THEN ' 2 pixel border? LINE (0, 0)-(WIN
(h%
).
Width - 1, WIN
(h%
).Height
- 1), WIN
(h%
).Dark
, B
' yes, draw bottom and right border LINE (0, 0)-(WIN
(h%
).
Width - 2, WIN
(h%
).Height
- 2), WIN
(h%
).Light
, B
' draw top and left border IF WIN
(h%
).BWidth
> 2 THEN ' more than 2 pixel border? LINE (0, 0)-(WIN
(h%
).
Width - 1, WIN
(h%
).Height
- 1), WIN
(h%
).Darker
, B
' yes, draw bottom and right border LINE (0, 0)-(WIN
(h%
).
Width - 2, WIN
(h%
).Height
- 2), WIN
(h%
).Lighter
, B
' draw top and left border LINE (1, 1)-(WIN
(h%
).
Width - 2, WIN
(h%
).Height
- 2), WIN
(h%
).Dark
, B
' draw bottom and right middle border LINE (1, 1)-(WIN
(h%
).
Width - 3, WIN
(h%
).Height
- 3), WIN
(h%
).Light
, B
' draw top and left middle border LINE (2, 2)-(WIN
(h%
).
Width - 3, WIN
(h%
).Height
- 3), WIN
(h%
).WColor
, B
IF WIN
(h%
).BWidth
> 3 THEN ' more than 3 pixel border? LINE (WIN
(h%
).BWidth
- 1, WIN
(h%
).BWidth
- 1)-(WIN
(h%
).
Width - WIN
(h%
).BWidth
, WIN
(h%
).Height
- WIN
(h%
).BWidth
), WIN
(h%
).Light
, B
LINE (WIN
(h%
).BWidth
- 1, WIN
(h%
).BWidth
- 1)-(WIN
(h%
).
Width - WIN
(h%
).BWidth
- 1, WIN
(h%
).Height
- WIN
(h%
).BWidth
- 1), WIN
(h%
).Dark
, B
LINE (WIN
(h%
).BWidth
, WIN
(h%
).BWidth
+ WIN
(h%
).TBHeight
)-(WIN
(h%
).
Width - WIN
(h%
).BWidth
- 1, WIN
(h%
).BWidth
+ WIN
(h%
).TBHeight
), _RGB32(0, 0, 0)
'--------------------------------------------------------------------------------------------------------------------------------
' WINDOW_NEW
'
' w% = width of window work space
' h% = height of window work space
'
' returns = integer handle number to reference window with
'
DIM i%
' next available window array index
i%
= UBOUND(WIN
) ' get last window index i% = i% - 1 ' go to previous index
i% = 0 ' start at beginning
c% = 1
DO ' cycle through window indexes i% = c% ' no, use this index
c% = c% + 1 ' increment index counter
i% = c% ' use this index
LOOP UNTIL i%
' leave when available index found WIN(i%).InUse = -1 ' mark index as used
WIN(i%).Visible = 0 ' set window invisible
WIN(i%).SIWidth = w% ' set screen image width
WIN(i%).SIHeight = h% ' set screen image height
WIN(i%).SWidth = w% ' set window screen width
WIN(i%).SHeight = h% ' set window screen height
WIN(i%).X = 0 ' set window x location
WIN(i%).Y = 0 ' set window y location
WIN(i%).BWidth = 3 ' set border width
WIN(i%).Title = ""
WIN(i%).Icon = QB64Icon&
WIN
(i%
).WColor
= _RGB32(212, 208, 200) ' set window colorWIN
(i%
).TBColor
= _RGB32(10, 40, 100) ' set title bar colorWIN
(i%
).TTColor
= _RGB32(255, 255, 255) ' set title bar text colorWIN(i%).TBSolid = -1
WIN(i%).Shadow = 0 ' set window shadow (off)
WIN(i%).Focus = 0 ' set window without focus
WIN(i%).Move = 0
WIN(i%).Resize = 0
WIN(i%).Size = 0
WIN(i%).CloseButton = 0
WIN(i%).MaxButton = 0
WIN(i%).MinButton = 0
WIN(i%).RestoreButton = 0
WIN(i%).SUButton = 0
WIN(i%).SDButton = 0
WIN(i%).SLButton = 0
WIN(i%).SRButton = 0
WIN(i%).Maximized = 0
WIN(i%).Minimized = 0
WinOrder%
(UBOUND(WinOrder%
)) = i%
' add window to order arrayWINDOW_NEW = i% ' return window handle
'--------------------------------------------------------------------------------------------------------------------------------
' WINDOW_SETTITLE
SUB WINDOW_SETTITLE
(h%
, t$
)
WIN(h%).Title = t$ ' set title of window
'--------------------------------------------------------------------------------------------------------------------------------
' WINDOW_SETFONT
SUB WINDOW_SETFONT
(h%
, f&
)
WIN(h%).Font = f& ' set window font
'--------------------------------------------------------------------------------------------------------------------------------
' WINDOW_SETBORDER
SUB WINDOW_SETBORDER
(h%
, w%
)
WIN(h%).BWidth = w%
'--------------------------------------------------------------------------------------------------------------------------------
' WINDOW_SETCOLOR
SUB WINDOW_SETCOLOR
(h%
, c~&
)
WIN(h%).WColor = c~& ' set window color
'--------------------------------------------------------------------------------------------------------------------------------
' WINDOW_SETTITLEBARCOLOR
SUB WINDOW_SETTITLEBARCOLOR
(h%
, c~&
)
WIN(h%).TBColor = c~& ' set title bar color
'--------------------------------------------------------------------------------------------------------------------------------
' WINDOW_SHOW
WIN(h%).Visible = -1
'--------------------------------------------------------------------------------------------------------------------------------
' WINDOW_HIDE
WIN(h%).Visible = 0
'--------------------------------------------------------------------------------------------------------------------------------
' POINTERS
Icon$ = "b bb bwb bwwb bwwwb bwwwwb bwwwwwb bwwwwwwb "+_
"bwwwwwwwb bwwwwwwwwb bwwwwwwwwwb bwwwwwwbbbbbbwwwbwwb bwwbbwwb bwb bwwb bb bwwb "+_
"b bwwb bwwb bwwb bwwb bb "
MAKEICON 0, Icon$, 12, 21, 0, 0 ' default - 12x21 - offset 0,0
Icon$ = " w wbw wbbbw wbbbbbw wbbbbbbbwwwwwbwwww wbw wbw wbw wbw "+_
" wbw wbw wbw wbw wbw wwwwbwwwwwbbbbbbbw wbbbbbw wbbbw wbw w "
MAKEICON 1, Icon$, 9, 21, -4, -10 ' NS resize - 9x21 - offset 5,11
Icon$ = " ww ww wbw wbw wbbw wbbw wbbbwwwwwwwwwwwbbbw wbbbbbbbbbbbbbbbbbbbw"+_
" wbbbwwwwwwwwwwwbbbw wbbw wbbw wbw wbw ww ww "
MAKEICON 2, Icon$, 21, 9, -10, -4 ' EW resize - 21x9 - offset 11,5
Icon$ = " wwwwwww wbbbbbw wbbbbw wbbbw wbwbbw wbw wbw"+_
" wbw ww wbw ww wbw wbw wbw wbbwbw wbbbw "+_
"wbbbbw wbbbbbw wwwwwww "
MAKEICON 3, Icon$, 15, 15, -7, -7 ' NESW resize - 15x15 - offset 8,8
Icon$ = " bb bwwb bwwb bwwb bwwb bwwbbb "+_
" bwwbwwbbb bwwbwwbwwbb bwwbwwbwwbwb bbb bwwbwwbwwbwwbbwwbbwwwwwwwwbwwbbwwwbwwwwwwwwwwwb"+_
" bwwbwwwwwwwwwwwb bwbwwwwwwwwwwwb bwwwwwwwwwwwwwb bwwwwwwwwwwwwb bwwwwwwwwwwwb bwwwwwwwwwwb "+_
" bwwwwwwwwwwb bwwwwwwwwb bwwwwwwwwb bbbbbbbbbb "
MAKEICON 5, Icon$, 17, 22, -5, 0 ' pointer (hand) - 17x22 - offset 6,0
Icon$ = "wwwwwww wbbbbbw wbbbbw wbbbw wbbwbw wbw wbw "+_
"ww wbw wbw wbw ww wbw wbw wbwbbw wbbbw"+_
" wbbbbw wbbbbbw wwwwwww"
MAKEICON 6, Icon$, 15, 15, -7, -7 ' NWSE resize - 15x15 - offset 8,8
Icon$ = "bbbbbbbbbbbbbbbwwwwwwwwwbbbbbbbbbbbbbbb bwwwwwwwwwb bwwwwwwwwwb bwwbwbwbwwb bwwwbwbwwwb "+_
" bbwwwbwwwbb bbwwwwwbb bbwbwbb bbwbb bbwbb bbwwwbb bbwwbwwbb "+_
" bbwwwwwwwbb bwwwwbwwwwb bwwwbwbwwwb bwwbwbwbwwb bwbwbwbwbwb bbbbbbbbbbbbbbbwwwwwwwwwbbbbbbbbbbbbbbb"
MAKEICON 7, Icon$, 13, 22, -6, -10 ' wait - 13x22 - offset 7,11
Icon$ = " w wbw wbbbw wbbbbbw wbbbbbbbw "+_
" wwwwbwwww ww wbw ww wbw wbw wbw wbbw wbw wbbw wbbbwwwwwbwwwwwbbbw "+_
"wbbbbbbbbbbbbbbbbbbbw wbbbwwwwwbwwwwwbbbw wbbw wbw wbbw wbw wbw wbw ww wbw ww "+_
" wwwwbwwww wbbbbbbbw wbbbbbw wbbbw wbw "+_
" w "
MAKEICON 10, Icon$, 21, 21, -10, -10 ' move - 21x21 - offset 11,11
Icon$ = " www wbw wbw wbw wbw "+_
" wbw wbw wbw wwwwwwwwwbwwwwwwwwwwbbbbbbbbbbbbbbbbbw"+_
"wwwwwwwwwbwwwwwwwww wbw wbw wbw wbw "+_
" wbw wbw wbw www "
MAKEICON 11, Icon$, 19, 19, -9, -9 ' crosshair - 19x19 - offset 10,10
Icon$ = "wwww wwwwwbbbwbbbwwwwwbwwww wbw wbw wbw wbw wbw wbw wbw "+_
" wbw wbw wbw wbw wbw wwwwbwwwwwbbbwbbbwwwww wwww"
MAKEICON 13, Icon$, 9, 18, -4, -8 ' text - 9x18 - offset 5,9
Icon$ = " wwwwww wwbbbbbbww wbbbbbbbbbbw wbbbbwwwwbbbbw wbbbww wwbbbw "+_
" wbbbbbw wbbbw wbbwbbbw wbbw wbbbwwbbbw wbbbwwbbw wbbbw wbbwwbbw wbbbw wbbw"+_
"wbbw wbbbw wbbwwbbw wbbbw wbbwwbbbw wbbbwwbbbw wbbw wbbbwbbw wbbbw wbbbbbw "+_
" wbbbww wwbbbw wbbbbwwwwbbbbw wbbbbbbbbbbw wwbbbbbbww wwwwww "
MAKEICON 14, Icon$, 20, 20, -9, -9 ' not-allowed - 20x20 - offset 10,10
Icon$ = "11111111111111111111121133333331144444444112113355533114455554411211335553311445555441121133555331144444441112"+_
"11335553311444444411121133555331144555544112113355533114455554411211333333311444444441121133333331144444444112"+_
"11113331111111111111121111111111111111111112116666666117711117711211661111111771111771121166111111177111177112"+_
"11666666611777777771121166666661177777777112116655566111111117711211665556611111111771121166666661111111177112"+_
"11111111111111111111122222222222222222222222"
MAKEICON -1, Icon$, 22, 22, 0, 0 ' QB64 - 22x22
POINTER(4) = POINTER(1)
POINTER(8) = POINTER(2)
POINTER(9) = POINTER(6)
POINTER(12) = POINTER(3)
'--------------------------------------------------------------------------------------------------------------------------------
' MAKEICON
SUB MAKEICON
(n%
, i$
, w%
, h%
, xo%
, yo%
)
POINTER(n%).X = xo%
POINTER(n%).Y = yo%
c% = c% + 1
'--------------------------------------------------------------------------------------------------------------------------------
' CALCULATECOLORS
WIN
(h%
).Wred
= _RED(WIN
(h%
).WColor
) ' get RGB components of window colorWIN
(h%
).Wgreen
= _GREEN(WIN
(h%
).WColor
)WIN
(h%
).Wblue
= _BLUE(WIN
(h%
).WColor
)WIN
(h%
).Lighter
= _RGB32(WIN
(h%
).Wred
* 1.5, WIN
(h%
).Wgreen
* 1.5, WIN
(h%
).Wblue
* 1.5) ' calculate window/border color shadesWIN
(h%
).Light
= _RGB32(WIN
(h%
).Wred
* 1.25, WIN
(h%
).Wgreen
* 1.25, WIN
(h%
).Wblue
* 1.25)WIN
(h%
).Dark
= _RGB32(WIN
(h%
).Wred
/ 1.25, WIN
(h%
).Wgreen
/ 1.25, WIN
(h%
).Wblue
/ 1.25)WIN
(h%
).Darker
= _RGB32(WIN
(h%
).Wred
/ 1.5, WIN
(h%
).Wgreen
/ 1.5, WIN
(h%
).Wblue
/ 1.5)WIN
(h%
).Darkest
= _RGB32(WIN
(h%
).Wred
/ 2, WIN
(h%
).Wgreen
/ 2, WIN
(h%
).Wblue
/ 2)
'--------------------------------------------------------------------------------------------------------------------------------
' MOUSEMOVEMENTY
'
' returns the mouse y coordinate difference between calls
'
STATIC y%
' previous call's mouse y coordinate (saved between calls)
MOUSEMOVEMENTY = MOUSE.Y - y% ' calculate mouse y offset from previous call
y% = MOUSE.Y ' save current mouse y coordinate
'--------------------------------------------------------------------------------------------------------------------------------
' MOUSEMOVEMENTX
'
' returns the mouse x coordinate difference between calls
'
STATIC x%
' previous call's mouse x coordinate (saved between calls)
MOUSEMOVEMENTX = MOUSE.X - x% ' calculate mouse x offset from previous call
x% = MOUSE.X ' save current mouse x coordinate