· 5 years ago · Mar 12, 2020, 10:56 PM
1'InForm - GUI library for QB64
2'Fellippe Heitor, 2016-2019 - fellippe@qb64.org - @fellippeheitor
3'
4'VWATCH64:OFF
5
6DECLARE LIBRARY
7 FUNCTION __UI_GetPID ALIAS getpid ()
8END DECLARE
9
10DECLARE CUSTOMTYPE LIBRARY
11 SUB __UI_MemCopy ALIAS memcpy (BYVAL dest AS _OFFSET, BYVAL source AS _OFFSET, BYVAL bytes AS LONG)
12END DECLARE
13
14DECLARE LIBRARY "falcon"
15 SUB uprint_extra (BYVAL x&, BYVAL y&, BYVAL chars%&, BYVAL length%&, BYVAL kern&, BYVAL do_render&, txt_width&, BYVAL charpos%&, charcount&, BYVAL colour~&, BYVAL max_width&)
16 FUNCTION uprint (BYVAL x&, BYVAL y&, chars$, BYVAL txt_len&, BYVAL colour~&, BYVAL max_width&)
17 FUNCTION uprintwidth (chars$, BYVAL txt_len&, BYVAL max_width&)
18 FUNCTION uheight& ()
19 FUNCTION falcon_uspacing& ALIAS uspacing ()
20 FUNCTION uascension& ()
21END DECLARE
22
23$IF WIN THEN
24 DECLARE LIBRARY
25 FUNCTION __UI_MB& ALIAS MessageBox (BYVAL ignore&, message$, title$, BYVAL type&)
26 FUNCTION GetSystemMetrics& (BYVAL WhichMetric&)
27 END DECLARE
28
29 CONST __UI_SM_SWAPBUTTON = 23
30$ELSE
31 DECLARE LIBRARY ""
32 FUNCTION __UI_MB& ALIAS MessageBox (BYVAL ignore&, message$, title$, BYVAL type&)
33 END DECLARE
34$END IF
35
36$SCREENHIDE
37_CONTROLCHR OFF
38
39TYPE __UI_ControlTYPE
40 ID AS LONG
41 ParentID AS LONG
42 PreviousParentID AS LONG
43 ContextMenuID AS LONG
44 Type AS INTEGER
45 Name AS STRING * 40
46 ParentName AS STRING * 40
47 SubMenu AS _BYTE
48 MenuPanelID AS LONG
49 SourceControl AS LONG
50 Top AS INTEGER
51 Left AS INTEGER
52 Width AS INTEGER
53 Height AS INTEGER
54 Canvas AS LONG
55 HelperCanvas AS LONG
56 TransparentColor AS _UNSIGNED LONG
57 Stretch AS _BYTE
58 PreviousStretch AS _BYTE
59 Font AS INTEGER
60 PreviousFont AS INTEGER
61 BackColor AS _UNSIGNED LONG
62 ForeColor AS _UNSIGNED LONG
63 SelectedForeColor AS _UNSIGNED LONG
64 SelectedBackColor AS _UNSIGNED LONG
65 BackStyle AS _BYTE
66 HasBorder AS _BYTE
67 BorderSize AS INTEGER
68 Padding AS INTEGER
69 Encoding AS LONG
70 Align AS _BYTE
71 PrevAlign AS _BYTE
72 VAlign AS _BYTE
73 PrevVAlign AS _BYTE
74 BorderColor AS _UNSIGNED LONG
75 Value AS _FLOAT
76 PreviousValue AS _FLOAT
77 Min AS _FLOAT
78 PrevMin AS _FLOAT
79 Max AS _FLOAT
80 PrevMax AS _FLOAT
81 Interval AS _FLOAT
82 PrevInterval AS _FLOAT
83 MinInterval AS _FLOAT
84 PrevMinInterval AS _FLOAT
85 HotKey AS INTEGER
86 HotKeyOffset AS INTEGER
87 HotKeyPosition AS INTEGER
88 ShowPercentage AS _BYTE
89 AutoScroll AS _BYTE
90 AutoSize AS _BYTE
91 InputViewStart AS LONG
92 PreviousInputViewStart AS LONG
93 LastVisibleItem AS INTEGER
94 ItemHeight AS INTEGER
95 HasVScrollbar AS _BYTE
96 VScrollbarButton2Top AS INTEGER
97 HoveringVScrollbarButton AS _BYTE
98 ThumbHeight AS INTEGER
99 ThumbTop AS INTEGER
100 VScrollbarRatio AS SINGLE
101 Cursor AS LONG
102 PasswordField AS _BYTE
103 PrevCursor AS LONG
104 FieldArea AS LONG
105 PreviousFieldArea AS LONG
106 TextIsSelected AS _BYTE
107 BypassSelectOnFocus AS _BYTE
108 Multiline AS _BYTE
109 NumericOnly AS _BYTE
110 FirstVisibleLine AS LONG
111 PrevFirstVisibleLine AS LONG
112 CurrentLine AS LONG
113 PrevCurrentLine AS LONG
114 VisibleCursor AS LONG
115 PrevVisibleCursor AS LONG
116 ControlIsSelected AS _BYTE
117 LeftOffsetFromFirstSelected AS INTEGER
118 TopOffsetFromFirstSelected AS INTEGER
119 SelectionLength AS LONG
120 SelectionStart AS LONG
121 WordWrap AS _BYTE
122 CanResize AS _BYTE
123 CanHaveFocus AS _BYTE
124 Disabled AS _BYTE
125 Hidden AS _BYTE
126 PreviouslyHidden AS _BYTE
127 CenteredWindow AS _BYTE
128 ControlState AS _BYTE
129 ChildrenRedrawn AS _BYTE
130 FocusState AS LONG
131 LastChange AS SINGLE
132 Redraw AS _BYTE
133 BulletStyle AS _BYTE
134 MenuItemGroup AS INTEGER
135 KeyCombo AS LONG
136 BoundTo AS LONG
137 BoundProperty AS LONG
138END TYPE
139
140TYPE __UI_Types
141 Name AS STRING * 16
142 Count AS LONG
143 TurnsInto AS INTEGER
144 DefaultHeight AS INTEGER
145 MinimumHeight AS INTEGER
146 DefaultWidth AS INTEGER
147 MinimumWidth AS INTEGER
148 RestrictResize AS _BYTE
149END TYPE
150
151TYPE __UI_ThemeImagesType
152 FileName AS STRING * 32
153 Handle AS LONG
154END TYPE
155
156TYPE __UI_WordWrapHistoryType
157 StringSlot AS LONG
158 Width AS INTEGER
159 LongestLine AS INTEGER
160 Font AS LONG
161 TotalLines AS INTEGER
162END TYPE
163
164TYPE __UI_KeyCombos
165 Combo AS STRING * 14 ' "CTRL+SHIFT+F12"
166 FriendlyCombo AS STRING * 14 ' "Ctrl+Shift+F12"
167 ControlID AS LONG
168END TYPE
169
170REDIM SHARED Caption(0 TO 100) AS STRING
171REDIM SHARED __UI_TempCaptions(0 TO 100) AS STRING
172REDIM SHARED Text(0 TO 100) AS STRING
173REDIM SHARED __UI_TempTexts(0 TO 100) AS STRING
174REDIM SHARED Mask(0 TO 100) AS STRING
175REDIM SHARED __UI_TempMask(0 TO 100) AS STRING
176REDIM SHARED ToolTip(0 TO 100) AS STRING
177REDIM SHARED __UI_TempTips(0 TO 100) AS STRING
178REDIM SHARED Control(0 TO 100) AS __UI_ControlTYPE
179REDIM SHARED ControlDrawOrder(0) AS LONG
180REDIM SHARED __UI_ThemeImages(0 TO 100) AS __UI_ThemeImagesType
181REDIM SHARED __UI_WordWrapHistoryTexts(0 TO 100) AS STRING
182REDIM SHARED __UI_WordWrapHistoryResults(0 TO 100) AS STRING
183REDIM SHARED __UI_WordWrapHistory(0 TO 100) AS __UI_WordWrapHistoryType
184REDIM SHARED __UI_ThisLineChars(0) AS LONG, __UI_FocusedTextBoxChars(0) AS LONG
185REDIM SHARED __UI_ActiveMenu(0 TO 100) AS LONG, __UI_ParentMenu(0 TO 100) AS LONG
186REDIM SHARED __UI_KeyCombo(0 TO 100) AS __UI_KeyCombos
187
188DIM SHARED __UI_TotalKeyCombos AS LONG, __UI_BypassKeyCombos AS _BYTE
189DIM SHARED table1252$(0 TO 255), table437$(0 TO 255)
190DIM SHARED __UI_MouseLeft AS INTEGER, __UI_MouseTop AS INTEGER
191DIM SHARED __UI_MouseWheel AS INTEGER, __UI_MouseButtonsSwap AS _BYTE
192DIM SHARED __UI_PrevMouseLeft AS INTEGER, __UI_PrevMouseTop AS INTEGER
193DIM SHARED __UI_MouseButton1 AS _BYTE, __UI_MouseButton2 AS _BYTE
194DIM SHARED __UI_MouseIsDown AS _BYTE, __UI_MouseDownOnID AS LONG
195DIM SHARED __UI_Mouse2IsDown AS _BYTE, __UI_Mouse2DownOnID AS LONG
196DIM SHARED __UI_PreviousMouseDownOnID AS LONG
197DIM SHARED __UI_KeyIsDown AS _BYTE, __UI_KeyDownOnID AS LONG
198DIM SHARED __UI_ShiftIsDown AS _BYTE, __UI_CtrlIsDown AS _BYTE
199DIM SHARED __UI_AltIsDown AS _BYTE, __UI_ShowHotKeys AS _BYTE, __UI_AltCombo$
200DIM SHARED __UI_LastMouseClick AS SINGLE, __UI_MouseDownOnScrollbar AS SINGLE
201DIM SHARED __UI_DragX AS INTEGER, __UI_DragY AS INTEGER
202DIM SHARED __UI_DefaultButtonID AS LONG
203DIM SHARED __UI_KeyHit AS LONG, __UI_KeepFocus AS _BYTE
204DIM SHARED __UI_Focus AS LONG, __UI_PreviousFocus AS LONG, __UI_KeyboardFocus AS _BYTE
205DIM SHARED __UI_HoveringID AS LONG, __UI_LastHoveringID AS LONG, __UI_BelowHoveringID AS LONG
206DIM SHARED __UI_IsDragging AS _BYTE, __UI_DraggingID AS LONG
207DIM SHARED __UI_IsResizing AS _BYTE, __UI_ResizingID AS LONG
208DIM SHARED __UI_ResizeHandleHover AS _BYTE
209DIM SHARED __UI_IsSelectingText AS _BYTE, __UI_IsSelectingTextOnID AS LONG
210DIM SHARED __UI_SelectedText AS STRING, __UI_SelectionLength AS LONG
211DIM SHARED __UI_StateHasChanged AS _BYTE
212DIM SHARED __UI_DraggingThumb AS _BYTE, __UI_ThumbDragTop AS INTEGER
213DIM SHARED __UI_DraggingThumbOnID AS LONG
214DIM SHARED __UI_HasInput AS _BYTE, __UI_ProcessInputTimer AS SINGLE
215DIM SHARED __UI_UnloadSignal AS _BYTE, __UI_HasResized AS _BYTE
216DIM SHARED __UI_ExitTriggered AS _BYTE
217DIM SHARED __UI_Loaded AS _BYTE
218DIM SHARED __UI_EventsTimer AS INTEGER, __UI_RefreshTimer AS INTEGER
219DIM SHARED __UI_ActiveDropdownList AS LONG, __UI_ParentDropdownList AS LONG
220DIM SHARED __UI_TotalActiveMenus AS LONG, __UI_ActiveMenuIsContextMenu AS _BYTE
221DIM SHARED __UI_SubMenuDelay AS SINGLE, __UI_HoveringSubMenu AS _BYTE
222DIM SHARED __UI_TopMenuBarItem AS LONG
223DIM SHARED __UI_ActiveTipID AS LONG, __UI_TipTimer AS SINGLE, __UI_PreviousTipID AS LONG
224DIM SHARED __UI_ActiveTipTop AS INTEGER, __UI_ActiveTipLeft AS INTEGER
225DIM SHARED __UI_FormID AS LONG, __UI_HasMenuBar AS LONG
226DIM SHARED __UI_ScrollbarWidth AS INTEGER, __UI_ScrollbarButtonHeight AS INTEGER
227DIM SHARED __UI_MenuBarOffset AS INTEGER, __UI_MenuItemOffset AS INTEGER
228DIM SHARED __UI_NewMenuBarTextLeft AS INTEGER, __UI_DefaultCaptionIndent AS INTEGER
229DIM SHARED __UI_ForceRedraw AS _BYTE, __UI_AutoRefresh AS _BYTE
230DIM SHARED __UI_CurrentTitle AS STRING
231DIM SHARED __UI_DesignMode AS _BYTE, __UI_FirstSelectedID AS LONG
232DIM SHARED __UI_WaitMessage AS STRING, __UI_TotalSelectedControls AS LONG
233DIM SHARED __UI_WaitMessageHandle AS LONG, __UI_EditorMode AS _BYTE
234DIM SHARED __UI_LastRenderedLineWidth AS LONG, __UI_LastRenderedCharCount AS LONG
235DIM SHARED __UI_SelectionRectangleTop AS INTEGER, __UI_SelectionRectangleLeft AS INTEGER
236DIM SHARED __UI_SelectionRectangle AS _BYTE
237DIM SHARED __UI_CantShowContextMenu AS _BYTE, __UI_ShowPositionAndSize AS _BYTE
238DIM SHARED __UI_ShowInvisibleControls AS _BYTE, __UI_Snapped AS _BYTE
239DIM SHARED __UI_SnappedByProximityX AS _BYTE, __UI_SnappedByProximityY AS _BYTE
240DIM SHARED __UI_SnappedX AS INTEGER, __UI_SnappedY AS INTEGER
241DIM SHARED __UI_SnappedXID AS LONG, __UI_SnappedYID AS LONG
242DIM SHARED __UI_SnapLines AS _BYTE, __UI_SnapDistance AS INTEGER, __UI_SnapDistanceFromForm AS INTEGER
243DIM SHARED __UI_FrameRate AS SINGLE, __UI_Font8Offset AS INTEGER, __UI_Font16Offset AS INTEGER
244DIM SHARED __UI_ClipboardCheck$, __UI_MenuBarOffsetV AS INTEGER
245DIM SHARED __UI_KeepScreenHidden AS _BYTE, __UI_MaxBorderSize AS INTEGER
246DIM SHARED __UI_InternalContextMenus AS LONG, __UI_DidClick AS _BYTE
247DIM SHARED __UI_ContextMenuSourceID AS LONG
248DIM SHARED __UI_FKey(1 TO 12) AS LONG
249
250'Control types: -----------------------------------------------
251DIM SHARED __UI_Type(0 TO 18) AS __UI_Types
252__UI_Type(__UI_Type_Form).Name = "Form"
253
254__UI_Type(__UI_Type_Frame).Name = "Frame"
255__UI_Type(__UI_Type_Frame).DefaultWidth = 230
256__UI_Type(__UI_Type_Frame).DefaultHeight = 150
257
258__UI_Type(__UI_Type_Button).Name = "Button"
259__UI_Type(__UI_Type_Button).DefaultWidth = 80
260__UI_Type(__UI_Type_Button).DefaultHeight = 23
261
262__UI_Type(__UI_Type_Label).Name = "Label"
263__UI_Type(__UI_Type_Label).DefaultWidth = 150
264__UI_Type(__UI_Type_Label).DefaultHeight = 23
265
266__UI_Type(__UI_Type_CheckBox).Name = "CheckBox"
267__UI_Type(__UI_Type_CheckBox).DefaultWidth = 150
268__UI_Type(__UI_Type_CheckBox).DefaultHeight = 23
269__UI_Type(__UI_Type_CheckBox).TurnsInto = __UI_Type_ToggleSwitch
270
271__UI_Type(__UI_Type_RadioButton).Name = "RadioButton"
272__UI_Type(__UI_Type_RadioButton).DefaultWidth = 150
273__UI_Type(__UI_Type_RadioButton).DefaultHeight = 23
274
275__UI_Type(__UI_Type_TextBox).Name = "TextBox"
276__UI_Type(__UI_Type_TextBox).DefaultWidth = 120
277__UI_Type(__UI_Type_TextBox).DefaultHeight = 23
278
279__UI_Type(__UI_Type_ProgressBar).Name = "ProgressBar"
280__UI_Type(__UI_Type_ProgressBar).DefaultWidth = 300
281__UI_Type(__UI_Type_ProgressBar).DefaultHeight = 23
282
283__UI_Type(__UI_Type_ListBox).Name = "ListBox"
284__UI_Type(__UI_Type_ListBox).DefaultWidth = 200
285__UI_Type(__UI_Type_ListBox).DefaultHeight = 200
286__UI_Type(__UI_Type_ListBox).TurnsInto = __UI_Type_DropdownList
287
288__UI_Type(__UI_Type_DropdownList).Name = "DropdownList"
289__UI_Type(__UI_Type_DropdownList).DefaultWidth = 200
290__UI_Type(__UI_Type_DropdownList).DefaultHeight = 23
291__UI_Type(__UI_Type_DropdownList).TurnsInto = __UI_Type_ListBox
292
293__UI_Type(__UI_Type_MenuBar).Name = "MenuBar"
294__UI_Type(__UI_Type_MenuBar).TurnsInto = __UI_Type_ContextMenu
295__UI_Type(__UI_Type_MenuBar).RestrictResize = __UI_CantResizeV
296
297__UI_Type(__UI_Type_MenuItem).Name = "MenuItem"
298__UI_Type(__UI_Type_MenuItem).RestrictResize = __UI_CantResizeV
299
300__UI_Type(__UI_Type_MenuPanel).Name = "MenuPanel"
301
302__UI_Type(__UI_Type_PictureBox).Name = "PictureBox"
303__UI_Type(__UI_Type_PictureBox).DefaultWidth = 230
304__UI_Type(__UI_Type_PictureBox).DefaultHeight = 150
305
306__UI_Type(__UI_Type_TrackBar).Name = "TrackBar"
307__UI_Type(__UI_Type_TrackBar).DefaultWidth = 300
308__UI_Type(__UI_Type_TrackBar).DefaultHeight = 40
309__UI_Type(__UI_Type_TrackBar).MinimumHeight = 30
310__UI_Type(__UI_Type_TrackBar).RestrictResize = __UI_CantResizeV
311
312__UI_Type(__UI_Type_ContextMenu).Name = "ContextMenu"
313__UI_Type(__UI_Type_ContextMenu).TurnsInto = __UI_Type_MenuBar
314__UI_Type(__UI_Type_ContextMenu).RestrictResize = __UI_CantResize
315__UI_Type(__UI_Type_ContextMenu).DefaultWidth = 22
316__UI_Type(__UI_Type_ContextMenu).DefaultHeight = 22
317
318__UI_Type(__UI_Type_Font).Name = "Font"
319
320__UI_Type(__UI_Type_ToggleSwitch).Name = "ToggleSwitch"
321__UI_Type(__UI_Type_ToggleSwitch).DefaultWidth = 40
322__UI_Type(__UI_Type_ToggleSwitch).DefaultHeight = 17
323__UI_Type(__UI_Type_ToggleSwitch).TurnsInto = __UI_Type_CheckBox
324__UI_Type(__UI_Type_ToggleSwitch).RestrictResize = __UI_CantResize
325'--------------------------------------------------------------
326
327__UI_RestoreFKeys
328
329CONST True = -1, False = 0
330'$INCLUDE:'InFormVersion.bas'
331__UI_SubMenuDelay = .4
332__UI_SnapDistance = 5
333__UI_SnapDistanceFromForm = 10
334__UI_MaxBorderSize = 10
335__UI_Font8Offset = 5
336__UI_Font16Offset = 3
337__UI_ClipboardCheck$ = "InForm" + STRING$(2, 10) + "BEGIN CONTROL DATA" + CHR$(10) + STRING$(60, 45) + CHR$(10)
338
339__UI_ThemeSetup
340__UI_InternalMenus
341__UI_LoadForm
342
343__UI_Init
344
345'Main loop
346DO
347 _LIMIT 1
348LOOP
349
350SYSTEM
351__UI_ErrorHandler:
352RESUME NEXT
353
354'------------------------------------------------------------------------------
355'Control types:
356FUNCTION __UI_Type_Form%%:__UI_Type_Form%% = 1: END FUNCTION
357FUNCTION __UI_Type_Frame%%: __UI_Type_Frame%% = 2: END FUNCTION
358FUNCTION __UI_Type_Button%%: __UI_Type_Button%% = 3: END FUNCTION
359FUNCTION __UI_Type_Label%%: __UI_Type_Label%% = 4: END FUNCTION
360FUNCTION __UI_Type_CheckBox%%: __UI_Type_CheckBox%% = 5: END FUNCTION
361FUNCTION __UI_Type_RadioButton%%: __UI_Type_RadioButton%% = 6: END FUNCTION
362FUNCTION __UI_Type_TextBox%%: __UI_Type_TextBox%% = 7: END FUNCTION
363FUNCTION __UI_Type_ProgressBar%%: __UI_Type_ProgressBar%% = 8: END FUNCTION
364FUNCTION __UI_Type_ListBox%%: __UI_Type_ListBox%% = 9: END FUNCTION
365FUNCTION __UI_Type_DropdownList%%: __UI_Type_DropdownList%% = 10: END FUNCTION
366FUNCTION __UI_Type_MenuBar%%: __UI_Type_MenuBar%% = 11: END FUNCTION
367FUNCTION __UI_Type_MenuItem%%: __UI_Type_MenuItem%% = 12: END FUNCTION
368FUNCTION __UI_Type_MenuPanel%%: __UI_Type_MenuPanel%% = 13: END FUNCTION
369FUNCTION __UI_Type_PictureBox%%: __UI_Type_PictureBox%% = 14: END FUNCTION
370FUNCTION __UI_Type_TrackBar%%: __UI_Type_TrackBar%% = 15: END FUNCTION
371FUNCTION __UI_Type_ContextMenu%%: __UI_Type_ContextMenu%% = 16: END FUNCTION
372FUNCTION __UI_Type_Font%%: __UI_Type_Font%% = 17: END FUNCTION
373FUNCTION __UI_Type_ToggleSwitch%%: __UI_Type_ToggleSwitch%% = 18: END FUNCTION
374
375'Back styles:
376FUNCTION __UI_Opaque%%: __UI_Opaque%% = 0: END FUNCTION
377FUNCTION __UI_Transparent%%: __UI_Transparent%% = -1: END FUNCTION
378
379'Text alignment
380FUNCTION __UI_Left%%: __UI_Left%% = 0: END FUNCTION
381FUNCTION __UI_Center%%: __UI_Center%% = 1: END FUNCTION
382FUNCTION __UI_Right%%: __UI_Right%% = 2: END FUNCTION
383FUNCTION __UI_Top%%: __UI_Top%% = 0: END FUNCTION
384FUNCTION __UI_Middle%%: __UI_Middle%% = 1: END FUNCTION
385FUNCTION __UI_Bottom%%: __UI_Bottom%% = 2: END FUNCTION
386
387'Textbox controls
388FUNCTION __UI_NumericWithoutBounds%%: __UI_NumericWithoutBounds%% = True: END FUNCTION
389FUNCTION __UI_NumericWithBounds%%: __UI_NumericWithBounds%% = 2: END FUNCTION
390
391'BulletStyle
392FUNCTION __UI_CheckMark%%: __UI_CheckMark%% = 0: END FUNCTION
393FUNCTION __UI_Bullet%%: __UI_Bullet%% = 1: END FUNCTION
394
395
396'Messagebox constants
397FUNCTION MsgBox_OkOnly%%: MsgBox_OkOnly%% = 0: END FUNCTION
398FUNCTION MsgBox_OkCancel%%: MsgBox_OkCancel%% = 1: END FUNCTION
399FUNCTION MsgBox_AbortRetryIgnore%%: MsgBox_AbortRetryIgnore%% = 2: END FUNCTION
400FUNCTION MsgBox_YesNoCancel%%: MsgBox_YesNoCancel%% = 3: END FUNCTION
401FUNCTION MsgBox_YesNo%%: MsgBox_YesNo%% = 4: END FUNCTION
402FUNCTION MsgBox_RetryCancel%%: MsgBox_RetryCancel%% = 5: END FUNCTION
403FUNCTION MsgBox_CancelTryagainContinue%%: MsgBox_CancelTryagainContinue%% = 6: END FUNCTION
404
405FUNCTION MsgBox_Critical%: MsgBox_Critical% = 16: END FUNCTION
406FUNCTION MsgBox_Question%: MsgBox_Question% = 32: END FUNCTION
407FUNCTION MsgBox_Exclamation%: MsgBox_Exclamation% = 48: END FUNCTION
408FUNCTION MsgBox_Information%: MsgBox_Information% = 64: END FUNCTION
409
410FUNCTION MsgBox_DefaultButton1%: MsgBox_DefaultButton1% = 0: END FUNCTION
411FUNCTION MsgBox_DefaultButton2%: MsgBox_DefaultButton2% = 256: END FUNCTION
412FUNCTION MsgBox_DefaultButton3%: MsgBox_DefaultButton3% = 512: END FUNCTION
413FUNCTION MsgBox_Defaultbutton4%: MsgBox_Defaultbutton4% = 768: END FUNCTION
414
415FUNCTION MsgBox_AppModal%%: MsgBox_AppModal%% = 0: END FUNCTION
416FUNCTION MsgBox_SystemModal%: MsgBox_SystemModal% = 4096: END FUNCTION
417FUNCTION MsgBox_SetForeground&: MsgBox_SetForeground& = 65536: END FUNCTION
418
419FUNCTION MsgBox_Ok%%: MsgBox_Ok%% = 1: END FUNCTION
420FUNCTION MsgBox_Cancel%%: MsgBox_Cancel%% = 2: END FUNCTION
421FUNCTION MsgBox_Abort%%: MsgBox_Abort%% = 3: END FUNCTION
422FUNCTION MsgBox_Retry%%: MsgBox_Retry%% = 4: END FUNCTION
423FUNCTION MsgBox_Ignore%%: MsgBox_Ignore%% = 5: END FUNCTION
424FUNCTION MsgBox_Yes%%: MsgBox_Yes%% = 6: END FUNCTION
425FUNCTION MsgBox_No%%: MsgBox_No%% = 7: END FUNCTION
426FUNCTION MsgBox_Tryagain%%: MsgBox_Tryagain%% = 10: END FUNCTION
427FUNCTION MsgBox_Continue%%: MsgBox_Continue%% = 11: END FUNCTION
428
429'General constants
430FUNCTION __UI_ToolTipTimeOut!: __UI_ToolTipTimeOut! = .8: END FUNCTION
431FUNCTION __UI_CantResizeV%%: __UI_CantResizeV%% = 1: END FUNCTION
432FUNCTION __UI_CantResizeH%%: __UI_CantResizeH%% = 2: END FUNCTION
433FUNCTION __UI_CantResize%%: __UI_CantResize%% = 3: END FUNCTION
434
435'---------------------------------------------------------------------------------
436FUNCTION uspacing&
437 uspacing& = uheight + (((_FONT = 8) * -1) * __UI_Font8Offset + ((_FONT = 16) * -1) * __UI_Font16Offset)
438END FUNCTION
439
440'---------------------------------------------------------------------------------
441SUB __UI_InternalMenus
442 'Internal "design mode" context menu. -------------------------------------------
443 DIM __UI_NewID AS LONG
444 __UI_NewID = __UI_NewControl(__UI_Type_ContextMenu, "__UI_PreviewMenu", 0, 0, 0, 0, 0)
445 Control(__UI_NewID).Font = SetFont("segoeui.ttf?arial.ttf?/Library/Fonts/Arial.ttf?InForm/resources/NotoMono-Regular.ttf?cour.ttf", 12)
446
447 'Hotkeys available:
448 'F, J, K, Q
449 __UI_NewID = __UI_NewControl(__UI_Type_MenuItem, "__UI_PreviewMenuNewMenuBar", 0, 0, 0, 0, __UI_GetID("__UI_PreviewMenu"))
450 SetCaption __UI_GetID("__UI_PreviewMenuNewMenuBar"), "New &MenuBar control"
451
452 __UI_NewID = __UI_NewControl(__UI_Type_MenuItem, "__UI_PreviewMenuNewContextMenu", 0, 0, 0, 0, __UI_GetID("__UI_PreviewMenu"))
453 SetCaption __UI_GetID("__UI_PreviewMenuNewContextMenu"), "New ContextMen&u control-"
454
455 __UI_NewID = __UI_NewControl(__UI_Type_MenuItem, "__UI_PreviewMenuShowInvisibleControls", 0, 0, 0, 0, __UI_GetID("__UI_PreviewMenu"))
456 SetCaption __UI_GetID("__UI_PreviewMenuShowInvisibleControls"), "Sho&w invisible controls-"
457 ToolTip(__UI_NewID) = "Toogles the display of invisible items (e.g. ContextMenu controls)"
458
459 __UI_NewID = __UI_NewControl(__UI_Type_MenuItem, "__UI_PreviewMenuSetDefaultButton", 0, 0, 0, 0, __UI_GetID("__UI_PreviewMenu"))
460 SetCaption __UI_GetID("__UI_PreviewMenuSetDefaultButton"), "&Set as default button-"
461 ToolTip(__UI_NewID) = "The default button can be triggered with Enter even if it doesn't have focus at run time."
462
463 __UI_NewID = __UI_NewControl(__UI_Type_MenuItem, "__UI_PreviewMenuBindControls", 0, 0, 0, 0, __UI_GetID("__UI_PreviewMenu"))
464 SetCaption __UI_GetID("__UI_PreviewMenuBindControls"), "Bind selected controls...-"
465 ToolTip(__UI_NewID) = "Binds a control's property to another control's property."
466
467 __UI_NewID = __UI_NewControl(__UI_Type_MenuItem, "__UI_PreviewMenuConvertType", 0, 0, 0, 0, __UI_GetID("__UI_PreviewMenu"))
468 SetCaption __UI_GetID("__UI_PreviewMenuConvertType"), "Co&nvert to type-"
469
470 __UI_NewID = __UI_NewControl(__UI_Type_MenuItem, "__UI_PreviewMenuImageOriginalSize", 0, 0, 0, 0, __UI_GetID("__UI_PreviewMenu"))
471 SetCaption __UI_GetID("__UI_PreviewMenuImageOriginalSize"), "Restore &image dimensions-"
472
473 __UI_NewID = __UI_NewControl(__UI_Type_MenuItem, "__UI_PreviewMenuNumericOnly", 0, 0, 0, 0, __UI_GetID("__UI_PreviewMenu"))
474 SetCaption __UI_GetID("__UI_PreviewMenuNumericOnly"), "Validate .Min/.Ma&x bounds-"
475
476 __UI_NewID = __UI_NewControl(__UI_Type_MenuItem, "__UI_PreviewMenuAlignLeft", 0, 0, 0, 0, __UI_GetID("__UI_PreviewMenu"))
477 SetCaption __UI_GetID("__UI_PreviewMenuAlignLeft"), "Align &Left"
478
479 __UI_NewID = __UI_NewControl(__UI_Type_MenuItem, "__UI_PreviewMenuAlignRight", 0, 0, 0, 0, __UI_GetID("__UI_PreviewMenu"))
480 SetCaption __UI_GetID("__UI_PreviewMenuAlignRight"), "Align &Right"
481
482 __UI_NewID = __UI_NewControl(__UI_Type_MenuItem, "__UI_PreviewMenuAlignTops", 0, 0, 0, 0, __UI_GetID("__UI_PreviewMenu"))
483 SetCaption __UI_GetID("__UI_PreviewMenuAlignTops"), "Align T&op"
484
485 __UI_NewID = __UI_NewControl(__UI_Type_MenuItem, "__UI_PreviewMenuAlignBottoms", 0, 0, 0, 0, __UI_GetID("__UI_PreviewMenu"))
486 SetCaption __UI_GetID("__UI_PreviewMenuAlignBottoms"), "Align &Bottom-"
487
488 __UI_NewID = __UI_NewControl(__UI_Type_MenuItem, "__UI_PreviewMenuAlignCentersV", 0, 0, 0, 0, __UI_GetID("__UI_PreviewMenu"))
489 SetCaption __UI_GetID("__UI_PreviewMenuAlignCentersV"), "Align cent&ers Vertically"
490
491 __UI_NewID = __UI_NewControl(__UI_Type_MenuItem, "__UI_PreviewMenuAlignCentersH", 0, 0, 0, 0, __UI_GetID("__UI_PreviewMenu"))
492 SetCaption __UI_GetID("__UI_PreviewMenuAlignCentersH"), "Ali&gn centers Horizontally"
493
494 __UI_NewID = __UI_NewControl(__UI_Type_MenuItem, "__UI_PreviewMenuAlignCenterV", 0, 0, 0, 0, __UI_GetID("__UI_PreviewMenu"))
495 SetCaption __UI_GetID("__UI_PreviewMenuAlignCenterV"), "Center &Vertically (group)"
496
497 __UI_NewID = __UI_NewControl(__UI_Type_MenuItem, "__UI_PreviewMenuAlignCenterH", 0, 0, 0, 0, __UI_GetID("__UI_PreviewMenu"))
498 SetCaption __UI_GetID("__UI_PreviewMenuAlignCenterH"), "Center &Horizontally (group)-"
499
500 __UI_NewID = __UI_NewControl(__UI_Type_MenuItem, "__UI_PreviewMenuDistributeV", 0, 0, 0, 0, __UI_GetID("__UI_PreviewMenu"))
501 SetCaption __UI_GetID("__UI_PreviewMenuDistributeV"), "Distribute Verticall&y"
502
503 __UI_NewID = __UI_NewControl(__UI_Type_MenuItem, "__UI_PreviewMenuDistributeH", 0, 0, 0, 0, __UI_GetID("__UI_PreviewMenu"))
504 SetCaption __UI_GetID("__UI_PreviewMenuDistributeH"), "Distribute Hori&zontally-"
505
506 __UI_NewID = __UI_NewControl(__UI_Type_MenuItem, "__UI_PreviewMenuCut", 0, 0, 0, 0, __UI_GetID("__UI_PreviewMenu"))
507 SetCaption __UI_GetID("__UI_PreviewMenuCut"), "Cu&t"
508
509 __UI_NewID = __UI_NewControl(__UI_Type_MenuItem, "__UI_PreviewMenuCopy", 0, 0, 0, 0, __UI_GetID("__UI_PreviewMenu"))
510 SetCaption __UI_GetID("__UI_PreviewMenuCopy"), "&Copy"
511
512 __UI_NewID = __UI_NewControl(__UI_Type_MenuItem, "__UI_PreviewMenuPaste", 0, 0, 0, 0, __UI_GetID("__UI_PreviewMenu"))
513 SetCaption __UI_GetID("__UI_PreviewMenuPaste"), "&Paste"
514
515 __UI_NewID = __UI_NewControl(__UI_Type_MenuItem, "__UI_PreviewMenuDelete", 0, 0, 0, 0, __UI_GetID("__UI_PreviewMenu"))
516 SetCaption __UI_GetID("__UI_PreviewMenuDelete"), "&Delete-"
517
518 __UI_NewID = __UI_NewControl(__UI_Type_MenuItem, "__UI_PreviewMenuSelect", 0, 0, 0, 0, __UI_GetID("__UI_PreviewMenu"))
519 SetCaption __UI_GetID("__UI_PreviewMenuSelect"), "Select &All"
520
521 DIM prevDest AS LONG
522 prevDest = _DEST
523 'Draw Align menu icons
524 Control(__UI_GetID("__UI_PreviewMenuAlignLeft")).HelperCanvas = _NEWIMAGE(48, 16, 32)
525 _DEST Control(__UI_GetID("__UI_PreviewMenuAlignLeft")).HelperCanvas
526 'Normal state
527 LINE (0, 0)-(1, 16), _RGB32(105, 105, 105), BF
528 LINE (3, 2)-(14, 7), _RGB32(255, 255, 255), BF
529 LINE (3, 2)-(14, 7), _RGB32(105, 105, 105), B
530 LINE (3, 10)-(10, 14), _RGB32(105, 105, 105), BF
531 'Hovered
532 LINE (16, 0)-STEP(1, 16), _RGB32(255, 255, 255), BF
533 LINE (19, 2)-STEP(11, 5), _RGB32(105, 105, 105), BF
534 LINE (19, 2)-STEP(11, 5), _RGB32(255, 255, 255), B
535 LINE (19, 10)-STEP(7, 4), _RGB32(255, 255, 255), BF
536 'Disabled
537 LINE (32, 0)-STEP(1, 16), Darken(__UI_DefaultColor(__UI_Type_Form, 2), 80), BF
538 LINE (35, 2)-STEP(11, 5), Darken(__UI_DefaultColor(__UI_Type_Form, 2), 80), BF
539 LINE (35, 2)-STEP(11, 5), Darken(__UI_DefaultColor(__UI_Type_Form, 2), 80), B
540 LINE (35, 10)-STEP(7, 4), Darken(__UI_DefaultColor(__UI_Type_Form, 2), 80), BF
541
542 Control(__UI_GetID("__UI_PreviewMenuAlignRight")).HelperCanvas = _NEWIMAGE(48, 16, 32)
543 _DEST Control(__UI_GetID("__UI_PreviewMenuAlignRight")).HelperCanvas
544 'Normal state
545 LINE (14, 0)-STEP(1, 16), _RGB32(105, 105, 105), BF
546 LINE (1, 2)-STEP(11, 5), _RGB32(255, 255, 255), BF
547 LINE (1, 2)-STEP(11, 5), _RGB32(105, 105, 105), B
548 LINE (5, 10)-STEP(7, 4), _RGB32(105, 105, 105), BF
549 'Hovered
550 LINE (14 + 16, 0)-STEP(1, 16), _RGB32(255, 255, 255), BF
551 LINE (1 + 16, 2)-STEP(11, 5), _RGB32(105, 105, 105), BF
552 LINE (1 + 16, 2)-STEP(11, 5), _RGB32(255, 255, 255), B
553 LINE (5 + 16, 10)-STEP(7, 4), _RGB32(255, 255, 255), BF
554 'Disabled
555 LINE (14 + 32, 0)-STEP(1, 16), Darken(__UI_DefaultColor(__UI_Type_Form, 2), 80), BF
556 LINE (1 + 32, 2)-STEP(11, 5), Darken(__UI_DefaultColor(__UI_Type_Form, 2), 80), BF
557 LINE (1 + 32, 2)-STEP(11, 5), Darken(__UI_DefaultColor(__UI_Type_Form, 2), 80), B
558 LINE (5 + 32, 10)-STEP(7, 4), Darken(__UI_DefaultColor(__UI_Type_Form, 2), 80), BF
559
560 Control(__UI_GetID("__UI_PreviewMenuAlignTops")).HelperCanvas = _NEWIMAGE(48, 16, 32)
561 _DEST Control(__UI_GetID("__UI_PreviewMenuAlignTops")).HelperCanvas
562 'Normal
563 LINE (0, 0)-STEP(16, 1), _RGB32(105, 105, 105), BF
564 LINE (2, 3)-STEP(5, 11), _RGB32(255, 255, 255), BF
565 LINE (2, 3)-STEP(4, 11), _RGB32(105, 105, 105), B
566 LINE (9, 3)-STEP(4, 7), _RGB32(105, 105, 105), BF
567 'Hovered
568 LINE (0 + 16, 0)-STEP(16, 1), _RGB32(255, 255, 255), BF
569 LINE (2 + 16, 3)-STEP(5, 11), _RGB32(105, 105, 105), BF
570 LINE (2 + 16, 3)-STEP(4, 11), _RGB32(255, 255, 255), B
571 LINE (9 + 16, 3)-STEP(4, 7), _RGB32(255, 255, 255), BF
572 'Disabled
573 LINE (0 + 32, 0)-STEP(16, 1), Darken(__UI_DefaultColor(__UI_Type_Form, 2), 80), BF
574 LINE (2 + 32, 3)-STEP(5, 11), Darken(__UI_DefaultColor(__UI_Type_Form, 2), 80), BF
575 LINE (2 + 32, 3)-STEP(4, 11), Darken(__UI_DefaultColor(__UI_Type_Form, 2), 80), B
576 LINE (9 + 32, 3)-STEP(4, 7), Darken(__UI_DefaultColor(__UI_Type_Form, 2), 80), BF
577
578 Control(__UI_GetID("__UI_PreviewMenuAlignBottoms")).HelperCanvas = _NEWIMAGE(48, 16, 32)
579 _DEST Control(__UI_GetID("__UI_PreviewMenuAlignBottoms")).HelperCanvas
580 'Normal
581 LINE (0, 14)-STEP(16, 1), _RGB32(105, 105, 105), BF
582 LINE (2, 1)-STEP(5, 11), _RGB32(255, 255, 255), BF
583 LINE (2, 1)-STEP(5, 11), _RGB32(105, 105, 105), B
584 LINE (9, 5)-STEP(4, 7), _RGB32(105, 105, 105), BF
585 'Hovered
586 LINE (0 + 16, 14)-STEP(16, 1), _RGB32(255, 255, 255), BF
587 LINE (2 + 16, 1)-STEP(5, 11), _RGB32(105, 105, 105), BF
588 LINE (2 + 16, 1)-STEP(5, 11), _RGB32(255, 255, 255), B
589 LINE (9 + 16, 5)-STEP(4, 7), _RGB32(255, 255, 255), BF
590 'Disabled
591 LINE (0 + 32, 14)-STEP(16, 1), Darken(__UI_DefaultColor(__UI_Type_Form, 2), 80), BF
592 LINE (2 + 32, 1)-STEP(5, 11), Darken(__UI_DefaultColor(__UI_Type_Form, 2), 80), BF
593 LINE (2 + 32, 1)-STEP(5, 11), Darken(__UI_DefaultColor(__UI_Type_Form, 2), 80), B
594 LINE (9 + 32, 5)-STEP(4, 7), Darken(__UI_DefaultColor(__UI_Type_Form, 2), 80), BF
595
596 Control(__UI_GetID("__UI_PreviewMenuAlignCentersV")).HelperCanvas = _NEWIMAGE(48, 16, 32)
597 _DEST Control(__UI_GetID("__UI_PreviewMenuAlignCentersV")).HelperCanvas
598 'Normal
599 LINE (0, 7)-STEP(16, 1), _RGB32(105, 105, 105), BF
600 LINE (2, 2)-STEP(5, 11), _RGB32(255, 255, 255), BF
601 LINE (2, 2)-STEP(5, 11), _RGB32(105, 105, 105), B
602 LINE (9, 4)-STEP(4, 7), _RGB32(105, 105, 105), BF
603 'Hovered
604 LINE (0 + 16, 7)-STEP(16, 1), _RGB32(255, 255, 255), BF
605 LINE (2 + 16, 2)-STEP(5, 11), _RGB32(105, 105, 105), BF
606 LINE (2 + 16, 2)-STEP(5, 11), _RGB32(255, 255, 255), B
607 LINE (9 + 16, 4)-STEP(4, 7), _RGB32(255, 255, 255), BF
608 'Disabled
609 LINE (0 + 32, 7)-STEP(16, 1), Darken(__UI_DefaultColor(__UI_Type_Form, 2), 80), BF
610 LINE (2 + 32, 2)-STEP(5, 11), Darken(__UI_DefaultColor(__UI_Type_Form, 2), 80), BF
611 LINE (2 + 32, 2)-STEP(5, 11), Darken(__UI_DefaultColor(__UI_Type_Form, 2), 80), B
612 LINE (9 + 32, 4)-STEP(4, 7), Darken(__UI_DefaultColor(__UI_Type_Form, 2), 80), BF
613
614 Control(__UI_GetID("__UI_PreviewMenuAlignCentersH")).HelperCanvas = _NEWIMAGE(48, 16, 32)
615 _DEST Control(__UI_GetID("__UI_PreviewMenuAlignCentersH")).HelperCanvas
616 'Normal
617 LINE (7, 0)-STEP(1, 16), _RGB32(105, 105, 105), BF
618 LINE (2, 2)-STEP(11, 5), _RGB32(255, 255, 255), BF
619 LINE (2, 2)-STEP(11, 5), _RGB32(105, 105, 105), B
620 LINE (4, 9)-STEP(7, 4), _RGB32(105, 105, 105), BF
621 'Hovered
622 LINE (7 + 16, 0)-STEP(1, 16), _RGB32(255, 255, 255), BF
623 LINE (2 + 16, 2)-STEP(11, 5), _RGB32(105, 105, 105), BF
624 LINE (2 + 16, 2)-STEP(11, 5), _RGB32(255, 255, 255), B
625 LINE (4 + 16, 9)-STEP(7, 4), _RGB32(255, 255, 255), BF
626 'Disabled
627 LINE (7 + 32, 0)-STEP(1, 16), Darken(__UI_DefaultColor(__UI_Type_Form, 2), 80), BF
628 LINE (2 + 32, 2)-STEP(11, 5), Darken(__UI_DefaultColor(__UI_Type_Form, 2), 80), BF
629 LINE (2 + 32, 2)-STEP(11, 5), Darken(__UI_DefaultColor(__UI_Type_Form, 2), 80), B
630 LINE (4 + 32, 9)-STEP(7, 4), Darken(__UI_DefaultColor(__UI_Type_Form, 2), 80), BF
631
632 _DEST prevDest
633END SUB
634
635'---------------------------------------------------------------------------------
636SUB SetFrameRate(FPS AS _UNSIGNED INTEGER)
637 IF FPS >= 30 THEN
638 __UI_FrameRate = 1 / FPS
639 ELSE
640 __UI_FrameRate = 1 / 30
641 END IF
642
643 IF __UI_RefreshTimer = 0 THEN
644 __UI_RefreshTimer = _FREETIMER
645 ON TIMER(__UI_RefreshTimer, __UI_FrameRate) __UI_UpdateDisplay
646 ELSE
647 TIMER(__UI_RefreshTimer) OFF
648 TIMER(__UI_RefreshTimer) FREE
649 __UI_RefreshTimer = _FREETIMER
650 ON TIMER(__UI_RefreshTimer, __UI_FrameRate) __UI_UpdateDisplay
651 TIMER(__UI_RefreshTimer) ON
652 END IF
653END SUB
654
655'---------------------------------------------------------------------------------
656SUB SetFocus(id AS LONG)
657 IF __UI_Focus = id THEN EXIT SUB
658 IF Control(id).CanHaveFocus = False OR Control(id).Hidden = True OR Control(id).Disabled = True THEN EXIT SUB
659 __UI_Focus = id
660 IF Control(id).Type = __UI_Type_TextBox THEN
661 IF Control(id).BypassSelectOnFocus = False THEN
662 Control(id).TextIsSelected = True
663 Control(id).SelectionStart = 0
664 Control(id).Cursor = LEN(Text(id))
665 END IF
666 END IF
667END SUB
668
669'---------------------------------------------------------------------------------
670SUB __UI_Init
671 DIM i AS LONG, b$
672
673 SetFrameRate 30
674
675 __UI_BeforeInit
676
677 IF __UI_KeepScreenHidden = False THEN _SCREENSHOW
678
679 IF __UI_FormID = 0 THEN SYSTEM
680
681 SCREEN _NEWIMAGE(Control(__UI_FormID).Width, Control(__UI_FormID).Height, 32)
682 COLOR Control(__UI_FormID).ForeColor, Control(__UI_FormID).BackColor
683 IF Control(__UI_FormID).Font > 0 THEN _FONT Control(__UI_FormID).Font
684 b$ = "Initializing..."
685 GOSUB ShowMessage
686
687 _ICON
688 _TITLE "InForm"
689 IF Control(__UI_FormID).CenteredWindow THEN _SCREENMOVE _MIDDLE
690
691 IF Control(__UI_FormID).Font = 0 THEN Control(__UI_FormID).Font = SetFont("", 8)
692
693 IF Caption(__UI_FormID) = "" THEN Caption(__UI_FormID) = RTRIM$(Control(__UI_FormID).Name)
694
695 IF NOT __UI_DesignMode THEN
696 'Internal "text field" context menus. -------------------------------------------
697 DIM __UI_NewID AS LONG
698 __UI_NewID = __UI_NewControl(__UI_Type_ContextMenu, "__UI_TextFieldMenu", 0, 0, 0, 0, 0)
699
700 FOR i = 1 TO UBOUND(Control)
701 IF Control(i).Type = __UI_Type_TextBox AND Control(i).ContextMenuID = 0 THEN
702 Control(i).ContextMenuID = __UI_NewID
703 END IF
704 NEXT
705
706 __UI_NewID = __UI_NewControl(__UI_Type_MenuItem, "__UI_TextMenuCut", 0, 0, 0, 0, __UI_GetID("__UI_TextFieldMenu"))
707 SetCaption __UI_GetID("__UI_TextMenuCut"), "Cu&t"
708
709 __UI_NewID = __UI_NewControl(__UI_Type_MenuItem, "__UI_TextMenuCopy", 0, 0, 0, 0, __UI_GetID("__UI_TextFieldMenu"))
710 SetCaption __UI_GetID("__UI_TextMenuCopy"), "&Copy"
711
712 __UI_NewID = __UI_NewControl(__UI_Type_MenuItem, "__UI_TextMenuPaste", 0, 0, 0, 0, __UI_GetID("__UI_TextFieldMenu"))
713 SetCaption __UI_GetID("__UI_TextMenuPaste"), "&Paste"
714
715 __UI_NewID = __UI_NewControl(__UI_Type_MenuItem, "__UI_TextMenuDelete", 0, 0, 0, 0, __UI_GetID("__UI_TextFieldMenu"))
716 SetCaption __UI_GetID("__UI_TextMenuDelete"), "&Delete-"
717
718 __UI_NewID = __UI_NewControl(__UI_Type_MenuItem, "__UI_TextMenuSelect", 0, 0, 0, 0, __UI_GetID("__UI_TextFieldMenu"))
719 SetCaption __UI_GetID("__UI_TextMenuSelect"), "Select &all"
720 END IF
721
722 _DISPLAYORDER _SOFTWARE, _HARDWARE
723 _DISPLAY
724
725 __UI_AssignIDs
726 __UI_OnLoad
727
728 __UI_EventsTimer = _FREETIMER
729 ON TIMER(__UI_EventsTimer, .008) __UI_DoEvents
730 TIMER(__UI_EventsTimer) ON
731 TIMER(__UI_RefreshTimer) ON
732
733 __UI_AutoRefresh = True
734 __UI_Loaded = True
735 EXIT SUB
736
737 ShowMessage:
738 CLS
739 __UI_PrintString _WIDTH / 2 - _PRINTWIDTH(b$) / 2, _HEIGHT / 2 - _FONTHEIGHT / 2, b$
740 _DISPLAY
741 RETURN
742END SUB
743
744'---------------------------------------------------------------------------------
745'Internal procedures: ------------------------------------------------------------
746'---------------------------------------------------------------------------------
747FUNCTION __UI_GetProperMouseButton%%(Which%%)
748 $IF WIN THEN
749 IF GetSystemMetrics(__UI_SM_SWAPBUTTON) = 0 THEN
750 __UI_GetProperMouseButton%% = _MOUSEBUTTON(Which%%)
751 ELSE
752 IF Which%% = 1 THEN
753 __UI_GetProperMouseButton%% = _MOUSEBUTTON(2)
754 ELSEIF Which%% = 2 THEN
755 __UI_GetProperMouseButton%% = _MOUSEBUTTON(1)
756 END IF
757 END IF
758 __UI_MouseButtonsSwap = False
759 $ELSE
760 IF __UI_MouseButtonsSwap THEN
761 IF Which%% = 1 THEN
762 __UI_GetProperMouseButton%% = _MOUSEBUTTON(2)
763 ELSEIF Which%% = 2 THEN
764 __UI_GetProperMouseButton%% = _MOUSEBUTTON(1)
765 END IF
766 ELSE
767 __UI_GetProperMouseButton%% = _MOUSEBUTTON(Which%%)
768 END IF
769 $END IF
770END FUNCTION
771
772SUB __UI_ProcessInput
773 DIM OldScreen&, i AS LONG, j AS LONG
774 DIM ContainerOffsetTop AS INTEGER, ContainerOffsetLeft AS INTEGER
775 STATIC __UI_CurrentResizeStatus AS _BYTE, __UI_CurrentBackColor AS _UNSIGNED LONG
776
777 __UI_HasInput = False
778
779 __UI_ExitTriggered = _EXIT
780 IF __UI_ExitTriggered AND 1 THEN __UI_ExitTriggered = True: __UI_HasInput = True
781
782 IF _SCREENX = -32000 AND _SCREENY = -32000 THEN
783 'Window was minimized
784 EXIT SUB
785 END IF
786
787 'Mouse input (optimization kindly provided by Luke Ceddia):
788 __UI_MouseWheel = 0
789 IF __UI_MouseIsDown THEN __UI_HasInput = True
790 IF _MOUSEINPUT THEN
791 __UI_HasInput = True
792 __UI_MouseWheel = __UI_MouseWheel + _MOUSEWHEEL
793 IF __UI_GetProperMouseButton%%(1) = __UI_MouseButton1 AND __UI_GetProperMouseButton%%(2) = __UI_MouseButton2 THEN
794 DO WHILE _MOUSEINPUT
795 __UI_MouseWheel = __UI_MouseWheel + _MOUSEWHEEL
796 IF NOT (__UI_GetProperMouseButton%%(1) = __UI_MouseButton1 AND __UI_GetProperMouseButton%%(2) = __UI_MouseButton2) THEN EXIT DO
797 LOOP
798 END IF
799 __UI_MouseButton1 = __UI_GetProperMouseButton%%(1)
800 __UI_MouseButton2 = __UI_GetProperMouseButton%%(2)
801 __UI_MouseLeft = _MOUSEX
802 __UI_MouseTop = _MOUSEY
803 END IF
804
805 'Hover detection
806 IF __UI_PrevMouseLeft <> __UI_MouseLeft OR __UI_PrevMouseTop <> __UI_MouseTop OR __UI_DidClick OR __UI_HoveringSubMenu THEN
807 __UI_PrevMouseLeft = __UI_MouseLeft
808 __UI_PrevMouseTop = __UI_MouseTop
809 __UI_DidClick = False
810 DIM TempHover AS LONG
811 __UI_BelowHoveringID = 0
812 FOR i = 1 TO UBOUND(Control)
813 IF Control(i).ID > 0 AND Control(i).Type <> __UI_Type_MenuItem AND ((Control(i).Hidden = False AND __UI_DesignMode = False) OR (__UI_DesignMode = True)) THEN
814 IF Control(i).Type = __UI_Type_ContextMenu AND __UI_DesignMode AND __UI_ShowInvisibleControls = False THEN _CONTINUE
815 IF Control(i).Hidden = True AND __UI_ShowInvisibleControls = False THEN _CONTINUE
816 Control(i).HoveringVScrollbarButton = 0
817 IF Control(i).ParentID > 0 THEN
818 IF Control(Control(i).ParentID).Hidden = True THEN _CONTINUE
819 ContainerOffsetTop = Control(Control(i).ParentID).Top
820 ContainerOffsetLeft = Control(Control(i).ParentID).Left
821 'First make sure the mouse is inside the container:
822 IF __UI_MouseLeft >= ContainerOffsetLeft AND __UI_MouseLeft <= ContainerOffsetLeft + Control(Control(i).ParentID).Width - 1 AND __UI_MouseTop >= ContainerOffsetTop AND __UI_MouseTop <= ContainerOffsetTop + Control(Control(i).ParentID).Height - 1 THEN
823 'We're in. Now check for individual control:
824 IF __UI_MouseLeft >= ContainerOffsetLeft + Control(i).Left AND __UI_MouseLeft <= ContainerOffsetLeft + Control(i).Left + Control(i).Width - 1 AND __UI_MouseTop >= ContainerOffsetTop + Control(i).Top AND __UI_MouseTop <= ContainerOffsetTop + Control(i).Top + Control(i).Height - 1 THEN
825 __UI_BelowHoveringID = TempHover
826 TempHover = Control(i).ID
827 IF Control(i).HasVScrollbar AND __UI_IsDragging = False THEN
828 IF __UI_MouseLeft >= ContainerOffsetLeft + Control(i).Left + Control(i).Width - __UI_ScrollbarWidth THEN
829 IF __UI_MouseTop <= Control(i).Top + ContainerOffsetTop + __UI_ScrollbarButtonHeight AND __UI_DraggingThumb = False THEN
830 'Hovering "up" button
831 Control(i).HoveringVScrollbarButton = 1
832 Control(i).PreviousInputViewStart = 0
833 ELSEIF __UI_MouseTop >= Control(i).Top + ContainerOffsetTop + Control(i).Height - __UI_ScrollbarButtonHeight AND __UI_DraggingThumb = False THEN
834 'Hovering "down" button
835 Control(i).HoveringVScrollbarButton = 2
836 Control(i).PreviousInputViewStart = 0
837 ELSEIF __UI_MouseTop >= ContainerOffsetTop + Control(i).ThumbTop AND __UI_MouseTop <= ContainerOffsetTop + Control(i).ThumbTop + Control(i).ThumbHeight THEN
838 'Hovering the thumb
839 Control(i).HoveringVScrollbarButton = 3
840 Control(i).PreviousInputViewStart = 0
841 ELSE
842 'Hovering the track
843 IF __UI_MouseTop < ContainerOffsetTop + Control(i).ThumbTop THEN
844 'Above the thumb
845 Control(i).HoveringVScrollbarButton = 4
846 ELSE
847 'Below the thumb
848 Control(i).HoveringVScrollbarButton = 5
849 END IF
850 Control(i).PreviousInputViewStart = 0
851 END IF
852 END IF
853 END IF
854 END IF
855 END IF
856 ELSE
857 ContainerOffsetTop = 0
858 ContainerOffsetLeft = 0
859
860 IF __UI_MouseLeft >= Control(i).Left AND __UI_MouseLeft <= Control(i).Left + Control(i).Width - 1 AND __UI_MouseTop >= Control(i).Top AND __UI_MouseTop <= Control(i).Top + Control(i).Height - 1 THEN
861 __UI_BelowHoveringID = TempHover
862 TempHover = Control(i).ID
863
864 IF Control(i).Type = __UI_Type_ContextMenu AND __UI_DesignMode THEN
865 'In design mode, ContextMenu handles take precedence over
866 'any other controls
867 EXIT FOR
868 END IF
869
870 IF Control(i).HasVScrollbar AND __UI_IsDragging = False THEN
871 IF __UI_MouseLeft >= ContainerOffsetLeft + Control(i).Left + Control(i).Width - __UI_ScrollbarWidth THEN
872 IF __UI_MouseTop <= Control(i).Top + ContainerOffsetTop + __UI_ScrollbarButtonHeight AND __UI_DraggingThumb = False THEN
873 'Hovering "up" button
874 Control(i).HoveringVScrollbarButton = 1
875 Control(i).PreviousInputViewStart = 0
876 ELSEIF __UI_MouseTop >= Control(i).Top + ContainerOffsetTop + Control(i).Height - __UI_ScrollbarButtonHeight AND __UI_DraggingThumb = False THEN
877 'Hovering "down" button
878 Control(i).HoveringVScrollbarButton = 2
879 Control(i).PreviousInputViewStart = 0
880 ELSEIF __UI_MouseTop >= ContainerOffsetTop + Control(i).ThumbTop AND __UI_MouseTop <= ContainerOffsetTop + Control(i).ThumbTop + Control(i).ThumbHeight THEN
881 'Hovering the thumb
882 Control(i).HoveringVScrollbarButton = 3
883 Control(i).PreviousInputViewStart = 0
884 ELSE
885 'Hovering the track
886 IF __UI_MouseTop < ContainerOffsetTop + Control(i).ThumbTop THEN
887 'Above the thumb
888 Control(i).HoveringVScrollbarButton = 4
889 Control(i).PreviousInputViewStart = 0
890 ELSE
891 'Below the thumb
892 Control(i).HoveringVScrollbarButton = 5
893 Control(i).PreviousInputViewStart = 0
894 END IF
895 END IF
896 END IF
897 END IF
898 END IF
899 END IF
900 END IF
901 NEXT
902
903 IF Control(TempHover).Type = __UI_Type_MenuPanel THEN
904 DIM ParentMenu AS LONG
905
906 FOR i = __UI_TotalActiveMenus TO 1 STEP -1
907 IF __UI_ActiveMenu(i) = TempHover THEN
908 ParentMenu = __UI_ParentMenu(i)
909 EXIT FOR
910 END IF
911 NEXT
912
913 'For an active menu, we'll detect individual menu items being hovered
914 _FONT Control(TempHover).Font
915 FOR i = 1 TO UBOUND(Control)
916 IF Control(i).ParentID = ParentMenu AND Control(i).Hidden = False THEN
917 IF __UI_MouseTop >= Control(TempHover).Top + Control(i).Top AND __UI_MouseTop <= Control(TempHover).Top + Control(i).Top + Control(i).Height - 1 THEN
918 Control(TempHover).Value = __UI_Focus
919 TempHover = Control(i).ID
920 __UI_Focus = Control(i).ID
921
922 'Close any unrelated sub-menus:
923 FOR j = __UI_TotalActiveMenus TO 1 STEP -1
924 IF __UI_ParentMenu(j) = Control(i).ID OR __UI_ParentMenu(j) = ParentMenu THEN
925 EXIT FOR
926 ELSE
927 __UI_DestroyControl Control(__UI_ActiveMenu(j))
928 END IF
929 NEXT
930
931 EXIT FOR 'as no menu items will overlap in a panel
932 END IF
933 END IF
934 NEXT
935 END IF
936
937 __UI_HoveringID = TempHover
938
939 IF Control(__UI_HoveringID).Type = __UI_Type_Frame AND Control(__UI_BelowHoveringID).ParentID = Control(__UI_HoveringID).ID THEN
940 'If a control was created before its container, the following line
941 'will allow it to be properly hovered/focused/selected.
942 SWAP __UI_HoveringID, __UI_BelowHoveringID
943 END IF
944
945 'Design mode specific hover:
946 IF __UI_DesignMode AND __UI_IsResizing = False AND __UI_IsDragging = False THEN
947 __UI_ResizeHandleHover = 0
948 IF Control(__UI_HoveringID).ControlIsSelected AND Control(__UI_HoveringID).Type <> __UI_Type_MenuBar AND Control(__UI_HoveringID).Type <> __UI_Type_MenuItem THEN
949 IF __UI_MouseLeft >= Control(__UI_HoveringID).Left + Control(Control(__UI_HoveringID).ParentID).Left + Control(__UI_HoveringID).Width - 8 AND __UI_MouseTop >= Control(__UI_HoveringID).Top + Control(Control(__UI_HoveringID).ParentID).Top + Control(__UI_HoveringID).Height / 2 - 4 AND __UI_MouseTop <= Control(__UI_HoveringID).Top + Control(Control(__UI_HoveringID).ParentID).Top + Control(__UI_HoveringID).Height / 2 + 4 THEN
950 IF __UI_Type(Control(__UI_HoveringID).Type).RestrictResize <> __UI_CantResizeH AND __UI_Type(Control(__UI_HoveringID).Type).RestrictResize <> __UI_CantResize THEN
951 __UI_ResizeHandleHover = 1 'Right
952 END IF
953 ELSEIF __UI_MouseLeft >= Control(__UI_HoveringID).Left + Control(Control(__UI_HoveringID).ParentID).Left + Control(__UI_HoveringID).Width / 2 - 4 AND __UI_MouseLeft <= Control(__UI_HoveringID).Left + Control(Control(__UI_HoveringID).ParentID).Left + Control(__UI_HoveringID).Width / 2 + 4 AND __UI_MouseTop >= Control(__UI_HoveringID).Top + Control(Control(__UI_HoveringID).ParentID).Top + Control(__UI_HoveringID).Height / 2 - 4 AND __UI_MouseTop >= Control(__UI_HoveringID).Top + Control(Control(__UI_HoveringID).ParentID).Top + Control(__UI_HoveringID).Height - 8 THEN
954 IF __UI_Type(Control(__UI_HoveringID).Type).RestrictResize <> __UI_CantResizeV AND __UI_Type(Control(__UI_HoveringID).Type).RestrictResize <> __UI_CantResize THEN
955 __UI_ResizeHandleHover = 2 'Bottom
956 END IF
957 ELSEIF __UI_MouseLeft <= Control(__UI_HoveringID).Left + Control(Control(__UI_HoveringID).ParentID).Left + 8 AND __UI_MouseTop >= Control(__UI_HoveringID).Top + Control(Control(__UI_HoveringID).ParentID).Top + Control(__UI_HoveringID).Height / 2 - 4 AND __UI_MouseTop <= Control(__UI_HoveringID).Top + Control(Control(__UI_HoveringID).ParentID).Top + Control(__UI_HoveringID).Height / 2 + 4 THEN
958 IF __UI_Type(Control(__UI_HoveringID).Type).RestrictResize <> __UI_CantResizeH AND __UI_Type(Control(__UI_HoveringID).Type).RestrictResize <> __UI_CantResize THEN
959 __UI_ResizeHandleHover = 3 'Left
960 END IF
961 ELSEIF __UI_MouseLeft >= Control(__UI_HoveringID).Left + Control(Control(__UI_HoveringID).ParentID).Left + Control(__UI_HoveringID).Width / 2 - 4 AND __UI_MouseLeft <= Control(__UI_HoveringID).Left + Control(Control(__UI_HoveringID).ParentID).Left + Control(__UI_HoveringID).Width / 2 + 4 AND __UI_MouseTop <= Control(__UI_HoveringID).Top + Control(Control(__UI_HoveringID).ParentID).Top + 8 THEN
962 IF __UI_Type(Control(__UI_HoveringID).Type).RestrictResize <> __UI_CantResizeV AND __UI_Type(Control(__UI_HoveringID).Type).RestrictResize <> __UI_CantResize THEN
963 __UI_ResizeHandleHover = 4 'Top
964 END IF
965 ELSEIF __UI_MouseLeft >= Control(__UI_HoveringID).Left + Control(Control(__UI_HoveringID).ParentID).Left + Control(__UI_HoveringID).Width - 8 AND __UI_MouseTop <= Control(__UI_HoveringID).Top + Control(Control(__UI_HoveringID).ParentID).Top + 8 THEN
966 IF __UI_Type(Control(__UI_HoveringID).Type).RestrictResize = False THEN
967 __UI_ResizeHandleHover = 5 'Top-right
968 END IF
969 ELSEIF __UI_MouseLeft <= Control(__UI_HoveringID).Left + Control(Control(__UI_HoveringID).ParentID).Left + 8 AND __UI_MouseTop <= Control(__UI_HoveringID).Top + Control(Control(__UI_HoveringID).ParentID).Top + 8 THEN
970 IF __UI_Type(Control(__UI_HoveringID).Type).RestrictResize = False THEN
971 __UI_ResizeHandleHover = 6 'Top-left
972 END IF
973 ELSEIF __UI_MouseLeft >= Control(__UI_HoveringID).Left + Control(Control(__UI_HoveringID).ParentID).Left + Control(__UI_HoveringID).Width - 8 AND __UI_MouseTop >= Control(__UI_HoveringID).Top + Control(Control(__UI_HoveringID).ParentID).Top + Control(__UI_HoveringID).Height - 8 THEN
974 IF __UI_Type(Control(__UI_HoveringID).Type).RestrictResize = False THEN
975 __UI_ResizeHandleHover = 7 'Bottom-right
976 END IF
977 ELSEIF __UI_MouseLeft <= Control(__UI_HoveringID).Left + Control(Control(__UI_HoveringID).ParentID).Left + 8 AND __UI_MouseTop >= Control(__UI_HoveringID).Top + Control(Control(__UI_HoveringID).ParentID).Top + Control(__UI_HoveringID).Height - 8 THEN
978 IF __UI_Type(Control(__UI_HoveringID).Type).RestrictResize = False THEN
979 __UI_ResizeHandleHover = 8 'Bottom-left
980 END IF
981 END IF
982 END IF
983 END IF
984
985 IF Control(__UI_Focus).Type = __UI_Type_MenuBar AND Control(__UI_HoveringID).Type = __UI_Type_MenuBar THEN
986 IF __UI_TotalActiveMenus = 0 THEN
987 __UI_Focus = __UI_HoveringID
988 END IF
989 ELSEIF __UI_TotalActiveMenus > 0 AND Control(__UI_HoveringID).Type = __UI_Type_MenuBar AND __UI_ActiveMenuIsContextMenu = False AND __UI_DesignMode = False THEN
990 IF __UI_ParentMenu(__UI_TotalActiveMenus) <> __UI_HoveringID AND NOT Control(__UI_HoveringID).Disabled THEN
991 __UI_CloseAllMenus
992 __UI_ActivateMenu Control(__UI_HoveringID), False
993 __UI_ForceRedraw = True
994 ELSEIF Control(__UI_HoveringID).Disabled THEN
995 __UI_CloseAllMenus
996 __UI_Focus = __UI_HoveringID
997 END IF
998 ELSE
999 IF __UI_HoveringID <> __UI_LastHoveringID AND Control(__UI_HoveringID).Type = __UI_Type_MenuItem AND Control(__UI_HoveringID).SubMenu AND __UI_DesignMode = False THEN
1000 Control(__UI_HoveringID).LastChange = TIMER
1001 __UI_HoveringSubMenu = True
1002 ELSEIF __UI_HoveringID = __UI_LastHoveringID AND Control(__UI_HoveringID).Type = __UI_Type_MenuItem AND Control(__UI_HoveringID).SubMenu THEN
1003 IF TIMER - Control(__UI_HoveringID).LastChange >= __UI_SubMenuDelay THEN
1004 __UI_ActivateMenu Control(__UI_HoveringID), False
1005 __UI_HoveringSubMenu = False
1006 END IF
1007 END IF
1008 END IF
1009 END IF
1010
1011 'Check if a tooltip must be enabled
1012 IF __UI_HoveringID <> __UI_LastHoveringID OR __UI_MouseButton1 OR __UI_MouseButton2 THEN
1013 __UI_TipTimer = TIMER
1014 __UI_ActiveTipID = 0
1015 ELSE
1016 IF __UI_HoveringID <> __UI_ActiveTipID AND __UI_HoveringID > 0 AND NOT __UI_IsDragging THEN
1017 IF TIMER - __UI_TipTimer >= __UI_ToolTipTimeOut THEN
1018 IF LEN(ToolTip(__UI_HoveringID)) > 0 THEN
1019 __UI_ActiveTipID = __UI_HoveringID
1020 __UI_ActiveTipTop = __UI_MouseTop + 16
1021 __UI_ActiveTipLeft = __UI_MouseLeft
1022 END IF
1023 END IF
1024 END IF
1025 END IF
1026
1027 'Keyboard input:
1028 __UI_KeyHit = _KEYHIT
1029 IF __UI_KeyHit THEN __UI_HasInput = True
1030
1031 'Adjust the Resize Status of this form based on its CanResize property:
1032 IF __UI_DesignMode = False THEN
1033 IF Control(__UI_FormID).CanResize <> __UI_CurrentResizeStatus THEN
1034 __UI_CurrentResizeStatus = Control(__UI_FormID).CanResize
1035 IF __UI_CurrentResizeStatus THEN
1036 _RESIZE ON
1037 ELSE
1038 _RESIZE OFF
1039 END IF
1040 END IF
1041 END IF
1042
1043 'Resize event:
1044 '(Triggered either programatically or by directly resizing the form):
1045 DIM CheckResize AS _BYTE
1046 CheckResize = _RESIZE
1047 IF (CheckResize AND Control(__UI_FormID).CanResize) OR (CheckResize AND __UI_DesignMode) OR __UI_CurrentBackColor <> Control(__UI_FormID).BackColor OR Control(__UI_FormID).Width <> _WIDTH(0) OR Control(__UI_FormID).Height <> _HEIGHT(0) THEN
1048 _DELAY .1
1049 IF CheckResize THEN
1050 Control(__UI_FormID).Width = _RESIZEWIDTH
1051 Control(__UI_FormID).Height = _RESIZEHEIGHT
1052 END IF
1053 IF Control(__UI_FormID).Width > 0 AND Control(__UI_FormID).Height > 0 THEN
1054 __UI_CurrentBackColor = Control(__UI_FormID).BackColor
1055
1056 __UI_HasResized = 2 'Indicate this process is in the middle
1057
1058 OldScreen& = _DISPLAY
1059 SCREEN _NEWIMAGE(Control(__UI_FormID).Width, Control(__UI_FormID).Height, 32)
1060 _FREEIMAGE OldScreen&
1061 'Recreate the main form's canvas
1062 IF Control(__UI_FormID).Canvas <> 0 THEN _FREEIMAGE Control(__UI_FormID).Canvas
1063 Control(__UI_FormID).Canvas = _NEWIMAGE(Control(__UI_FormID).Width, Control(__UI_FormID).Height, 32)
1064 _DEST Control(__UI_FormID).Canvas
1065 COLOR Control(__UI_FormID).ForeColor, Control(__UI_FormID).BackColor
1066 CLS
1067 IF __UI_HasMenuBar = True THEN
1068 'Add menubar div to main form's canvas
1069 _FONT Control(__UI_FormID).Font
1070 __UI_MenuBarOffsetV = falcon_uspacing& + (((_FONT = 8) * -1) * __UI_Font8Offset + ((_FONT = 16) * -1) * __UI_Font16Offset) + 5 + 2
1071 LINE (0, __UI_MenuBarOffsetV - 1)-STEP(Control(__UI_FormID).Width - 1, 0), Darken(Control(__UI_FormID).BackColor, 80)
1072 LINE (0, __UI_MenuBarOffsetV)-STEP(Control(__UI_FormID).Width - 1, 0), Darken(Control(__UI_FormID).BackColor, 120)
1073 __UI_RefreshMenuBar
1074 ELSE
1075 __UI_MenuBarOffsetV = 0
1076 END IF
1077 _DEST 0
1078
1079 IF LEN(__UI_CurrentTitle) THEN _TITLE __UI_CurrentTitle
1080
1081 __UI_HasResized = True
1082 __UI_HasInput = True
1083 END IF
1084 END IF
1085
1086 'Update main window title if needed
1087 IF __UI_CurrentTitle <> Caption(__UI_FormID) THEN
1088 __UI_CurrentTitle = Caption(__UI_FormID)
1089 _TITLE __UI_CurrentTitle
1090 __UI_HasInput = True
1091 END IF
1092
1093 __UI_ProcessInputTimer = TIMER
1094END SUB
1095
1096'---------------------------------------------------------------------------------
1097SUB __UI_UpdateDisplay
1098 STATIC ActiveTipPanel AS LONG
1099 DIM i AS LONG, TempCaption$, PrevDest AS LONG, TempParentID AS LONG
1100 DIM OverlayisVisible AS _BYTE, OverlayReset AS _BYTE
1101 DIM ContainerOffsetLeft AS INTEGER, ContainerOffsetTop AS INTEGER
1102 DIM ControlState AS _BYTE '1 = Normal; 2 = Hover/focus; 3 = Mouse down; 4 = Disabled;
1103
1104 IF __UI_AutoRefresh = False THEN EXIT SUB
1105
1106 __UI_BeforeUpdateDisplay
1107
1108 IF _SCREENX = -32000 AND _SCREENY = -32000 THEN
1109 'Window was minimized
1110 EXIT SUB
1111 END IF
1112
1113 ON ERROR GOTO __UI_ErrorHandler
1114
1115 'Clear frames canvases and count its children;
1116 FOR i = 1 TO UBOUND(Control)
1117 IF Control(i).Type = __UI_Type_Frame THEN
1118 Control(i).ParentID = 0 'Enforce no frames inside frames
1119 Control(i).Value = 0 'Reset children counter
1120 IF _WIDTH(Control(i).Canvas) <> Control(i).Width OR _HEIGHT(Control(i).Canvas) <> Control(i).Height THEN
1121 _FREEIMAGE Control(i).Canvas
1122 Control(i).Canvas = _NEWIMAGE(Control(i).Width, Control(i).Height, 32)
1123 END IF
1124 _DEST Control(i).Canvas
1125 COLOR , Control(i).BackColor
1126 CLS
1127 ELSE
1128 IF Control(i).ParentID > 0 AND Control(i).Type <> __UI_Type_MenuItem THEN
1129 'Increase container's children controls counter
1130 Control(Control(i).ParentID).Value = Control(Control(i).ParentID).Value + 1
1131 END IF
1132 END IF
1133 NEXT
1134
1135 _DEST 0
1136
1137 IF __UI_ForceRedraw THEN 'Restore main window hardware bg
1138 'Free the hardware bg image:
1139 _FREEIMAGE Control(__UI_FormID).Canvas
1140 'Create a new software one:
1141 Control(__UI_FormID).Canvas = _NEWIMAGE(Control(__UI_FormID).Width, Control(__UI_FormID).Height, 32)
1142 'Draw on it:
1143 _DEST Control(__UI_FormID).Canvas
1144 COLOR Control(__UI_FormID).ForeColor, Control(__UI_FormID).BackColor
1145 CLS
1146 IF __UI_HasMenuBar THEN
1147 _FONT Control(__UI_FormID).Font
1148 __UI_MenuBarOffsetV = falcon_uspacing& + (((_FONT = 8) * -1) * __UI_Font8Offset + ((_FONT = 16) * -1) * __UI_Font16Offset) + 5 + 2
1149 LINE (0, falcon_uspacing& + (((_FONT = 8) * -1) * __UI_Font8Offset + ((_FONT = 16) * -1) * __UI_Font16Offset) + 5 + 1)-STEP(Control(__UI_FormID).Width - 1, 0), Darken(Control(__UI_FormID).BackColor, 80)
1150 LINE (0, falcon_uspacing& + (((_FONT = 8) * -1) * __UI_Font8Offset + ((_FONT = 16) * -1) * __UI_Font16Offset) + 5 + 2)-STEP(Control(__UI_FormID).Width - 1, 0), Darken(Control(__UI_FormID).BackColor, 120)
1151 ELSE
1152 __UI_MenuBarOffsetV = 0
1153 END IF
1154 _DEST 0
1155 END IF
1156
1157 'Control drawing
1158 DIM iCount AS LONG
1159 FOR iCount = 1 TO UBOUND(ControlDrawOrder)
1160 i = ControlDrawOrder(iCount)
1161 IF Control(i).ID > 0 THEN
1162 'Direct the drawing to the appropriate canvas (main or container)
1163 IF Control(i).ParentID > 0 AND Control(i).Type <> __UI_Type_MenuItem THEN
1164 _DEST Control(Control(i).ParentID).Canvas
1165 ELSE
1166 _DEST 0
1167 END IF
1168
1169 IF i = __UI_FirstSelectedID AND Control(i).BoundTo > 0 AND __UI_DesignMode = True AND __UI_ShowInvisibleControls = True THEN
1170 LINE (Control(i).Left - 5 + Control(Control(i).ParentID).Left, _
1171 Control(i).Top - 5 + Control(Control(i).ParentID).Top)- _
1172 STEP(Control(i).Width + 10, Control(i).Height + 10), _
1173 _RGB32(127, 105, 183, 50), BF
1174
1175 LINE (Control(Control(i).BoundTo).Left - 5 + Control(Control(Control(i).BoundTo).ParentID).Left, _
1176 Control(Control(i).BoundTo).Top - 5 + Control(Control(Control(i).BoundTo).ParentID).Top)- _
1177 STEP(Control(Control(i).BoundTo).Width + 10, Control(Control(i).BoundTo).Height + 10), _
1178 _RGB32(127, 105, 183, 50), BF
1179 END IF
1180
1181 IF Control(i).Hidden = True AND __UI_DesignMode = True AND __UI_ShowInvisibleControls = True THEN
1182 LINE (Control(i).Left, Control(i).Top)-STEP(Control(i).Width - 1, Control(i).Height - 1), _RGBA32(127, 127, 127, 80), BF
1183 _FONT 8
1184 _PRINTMODE _KEEPBACKGROUND
1185 COLOR _RGBA32(0, 0, 0, 150)
1186 _PRINTSTRING (Control(i).Left + 1, Control(i).Top + 1), RTRIM$(Control(i).Name)
1187 _PRINTSTRING (Control(i).Left + 1, Control(i).Top + 1 + falcon_uspacing&), "(hidden)"
1188 GOTO BypassDisplay
1189 ELSEIF Control(i).Hidden = True THEN
1190 GOTO BypassDisplay
1191 END IF
1192
1193 IF ((__UI_MouseIsDown AND i = __UI_MouseDownOnID) OR (__UI_KeyIsDown AND i = __UI_KeyDownOnID AND __UI_KeyDownOnID = __UI_Focus)) AND NOT Control(i).Disabled THEN
1194 ControlState = 3
1195 ELSEIF (i = __UI_HoveringID AND Control(i).Type = __UI_Type_MenuBar) THEN
1196 ControlState = 2
1197 ELSEIF (i = __UI_HoveringID AND Control(i).Type <> __UI_Type_MenuBar AND NOT Control(i).Disabled) THEN
1198 ControlState = 2
1199 ELSEIF Control(i).Disabled THEN
1200 ControlState = 4
1201 ELSE
1202 ControlState = 1
1203 END IF
1204
1205 SELECT CASE Control(i).Type
1206 CASE __UI_Type_Form
1207 'Main window:
1208 IF __UI_HasResized <> 2 THEN
1209 IF Control(i).Canvas < -1 THEN _PUTIMAGE (0, 0), Control(i).Canvas, 0
1210 ELSE
1211 PAINT (0, 0), Control(i).BackColor
1212 END IF
1213 CASE __UI_Type_Button
1214 'Buttons
1215 __UI_DrawButton Control(i), ControlState
1216 CASE __UI_Type_Label
1217 'Labels
1218 AutoSizeLabel Control(i)
1219 __UI_DrawLabel Control(i), ControlState
1220 CASE __UI_Type_RadioButton
1221 'Radio buttons
1222 __UI_DrawRadioButton Control(i), ControlState
1223 CASE __UI_Type_CheckBox
1224 'Check boxes
1225 __UI_StateHasChanged = False
1226 __UI_DrawCheckBox Control(i), ControlState
1227 IF __UI_StateHasChanged THEN __UI_ValueChanged i
1228 CASE __UI_Type_ProgressBar
1229 'Progress bars
1230 __UI_DrawProgressBar Control(i), ControlState
1231 CASE __UI_Type_TrackBar
1232 'Track bars
1233 Control(i).Value = _ROUND(Control(i).Value)
1234 Control(i).Interval = _ROUND(Control(i).Interval)
1235 Control(i).MinInterval = _ROUND(Control(i).MinInterval)
1236 __UI_StateHasChanged = False
1237 __UI_DrawTrackBar Control(i), ControlState
1238 IF __UI_StateHasChanged THEN
1239 __UI_ValueChanged i
1240 END IF
1241 CASE __UI_Type_TextBox
1242 'Text boxes
1243 'IF Control(i).InputViewStart = 0 THEN Control(i).InputViewStart = 1
1244
1245 IF __UI_EditorMode = False AND Control(i).NumericOnly = __UI_NumericWithBounds AND __UI_Focus <> i THEN
1246 __UI_ValidateBounds i
1247 IF Text(i) <> LTRIM$(STR$(Control(i).Value)) THEN
1248 Text(i) = LTRIM$(STR$(Control(i).Value))
1249 END IF
1250 END IF
1251
1252 DIM ss1 AS LONG, ss2 AS LONG
1253 __UI_FillSelectedText ss1, ss2
1254 __UI_StateHasChanged = False
1255 __UI_DrawTextBox Control(i), ControlState
1256 IF __UI_StateHasChanged THEN
1257 __UI_TextChanged i
1258 IF Control(i).NumericOnly THEN
1259 Control(i).Value = VAL(Text(i))
1260 __UI_ValidateBounds i
1261 END IF
1262 END IF
1263 CASE __UI_Type_ListBox
1264 'List boxes
1265 IF Control(i).InputViewStart <= 0 THEN Control(i).InputViewStart = 1
1266
1267 __UI_StateHasChanged = False
1268 __UI_DrawListBox Control(i), ControlState
1269 IF __UI_StateHasChanged THEN __UI_ValueChanged i
1270 CASE __UI_Type_DropdownList
1271 'Dropdown lists
1272
1273 __UI_StateHasChanged = False
1274 __UI_DrawDropdownList Control(i), ControlState
1275 IF __UI_StateHasChanged THEN __UI_ValueChanged i
1276 CASE __UI_Type_MenuBar
1277 __UI_DrawMenuBar Control(i), ControlState
1278 CASE __UI_Type_PictureBox
1279 __UI_DrawPictureBox Control(i), ControlState
1280 CASE __UI_Type_ToggleSwitch
1281 __UI_StateHasChanged = False
1282 __UI_DrawToggleSwitch Control(i), ControlState
1283 IF __UI_StateHasChanged THEN __UI_ValueChanged i
1284 END SELECT
1285 END IF
1286
1287 BypassDisplay:
1288 IF __UI_Snapped THEN
1289 IF OverlayReset = False THEN
1290 'Reset the helper canvas of the main form
1291 OverlayReset = True
1292 IF Control(__UI_FormID).HelperCanvas <> 0 THEN _FREEIMAGE Control(__UI_FormID).HelperCanvas
1293 Control(__UI_FormID).HelperCanvas = _NEWIMAGE(Control(__UI_FormID).Width, Control(__UI_FormID).Height, 32)
1294 _DEST Control(__UI_FormID).HelperCanvas
1295 CLS , _RGBA32(0, 0, 0, 0)
1296 ELSE
1297 _DEST Control(__UI_FormID).HelperCanvas
1298 END IF
1299 OverlayisVisible = True
1300
1301 IF __UI_Snapped THEN
1302 DIM X1 AS INTEGER, X2 AS INTEGER
1303 DIM Y1 AS INTEGER, Y2 AS INTEGER
1304
1305 ContainerOffsetLeft = Control(Control(__UI_DraggingID).ParentID).Left
1306 ContainerOffsetTop = Control(Control(__UI_DraggingID).ParentID).Top
1307
1308 IF __UI_SnappedY >= 0 AND __UI_SnappedByProximityY = 0 THEN
1309 X1 = 0
1310 X2 = _WIDTH
1311 LINE (X1, __UI_SnappedY)-STEP(X2, 0), Control(__UI_FormID).SelectedBackColor
1312 ELSEIF __UI_SnappedY >= 0 AND __UI_SnappedByProximityY > 0 THEN
1313 SELECT CASE __UI_SnappedByProximityY
1314 CASE 1 'bottom of dragged control to top of snapped control
1315 X1 = Control(__UI_DraggingID).Left + Control(__UI_DraggingID).Width / 2
1316 IF X1 < Control(__UI_SnappedXID).Left + 1 THEN X1 = Control(__UI_SnappedXID).Left + 1
1317 IF X1 > Control(__UI_SnappedXID).Left + Control(__UI_SnappedXID).Width - 1 THEN X1 = Control(__UI_SnappedXID).Left + Control(__UI_SnappedXID).Width - 1
1318 Y1 = Control(__UI_DraggingID).Top + Control(__UI_DraggingID).Height
1319 FOR X1 = X1 - 1 TO X1 + 1
1320 LINE (X1 + ContainerOffsetLeft, Y1 + ContainerOffsetTop)-STEP(0, __UI_SnapDistance), Control(__UI_FormID).SelectedBackColor
1321 NEXT
1322 CASE 2 'top of dragged control to bottom of snapped control
1323 X1 = Control(__UI_DraggingID).Left + Control(__UI_DraggingID).Width / 2
1324 IF X1 < Control(__UI_SnappedXID).Left + 1 THEN X1 = Control(__UI_SnappedXID).Left + 1
1325 IF X1 > Control(__UI_SnappedXID).Left + Control(__UI_SnappedXID).Width - 1 THEN X1 = Control(__UI_SnappedXID).Left + Control(__UI_SnappedXID).Width - 1
1326 Y1 = Control(__UI_DraggingID).Top
1327 FOR X1 = X1 - 1 TO X1 + 1
1328 LINE (X1 + ContainerOffsetLeft, Y1 + ContainerOffsetTop)-STEP(0, -__UI_SnapDistance), Control(__UI_FormID).SelectedBackColor
1329 NEXT
1330 CASE 3 'snapped to top of form
1331 X1 = Control(__UI_DraggingID).Left + Control(__UI_DraggingID).Width / 2
1332 IF X1 < 1 THEN X1 = 1
1333 IF X1 > Control(__UI_FormID).Width - 2 THEN X1 = Control(__UI_FormID).Width - 2
1334 Y1 = Control(__UI_DraggingID).Top
1335 FOR X1 = X1 - 1 TO X1 + 1
1336 LINE (X1 + ContainerOffsetLeft, Y1 + ContainerOffsetTop)-STEP(0, -__UI_SnapDistanceFromForm), Control(__UI_FormID).SelectedBackColor
1337 NEXT
1338 CASE 4 'snapped to bottom of form
1339 X1 = Control(__UI_DraggingID).Left + Control(__UI_DraggingID).Width / 2
1340 IF X1 < 1 THEN X1 = 1
1341 IF X1 > Control(__UI_FormID).Width - 2 THEN X1 = Control(__UI_FormID).Width - 2
1342 Y1 = Control(__UI_DraggingID).Top + Control(__UI_DraggingID).Height
1343 FOR X1 = X1 - 1 TO X1 + 1
1344 LINE (X1 + ContainerOffsetLeft, Y1 + ContainerOffsetTop)-STEP(0, __UI_SnapDistanceFromForm), Control(__UI_FormID).SelectedBackColor
1345 NEXT
1346 END SELECT
1347 END IF
1348
1349 IF __UI_SnappedX >= 0 AND __UI_SnappedByProximityX = 0 THEN
1350 Y1 = 0
1351 Y2 = _HEIGHT
1352 LINE (__UI_SnappedX, Y1)-STEP(0, Y2), Control(__UI_FormID).SelectedBackColor
1353 ELSEIF __UI_SnappedX >= 0 AND __UI_SnappedByProximityX > 0 THEN
1354 SELECT CASE __UI_SnappedByProximityX
1355 CASE 1 'left of dragged control to right of snapped control
1356 X1 = Control(__UI_SnappedXID).Left + Control(__UI_SnappedXID).Width
1357 Y1 = Control(__UI_DraggingID).Top + Control(__UI_DraggingID).Height / 2
1358 IF Y1 < Control(__UI_SnappedXID).Top + 1 THEN Y1 = Control(__UI_SnappedXID).Top + 1
1359 IF Y1 > Control(__UI_SnappedXID).Top + Control(__UI_SnappedXID).Height - 1 THEN Y1 = Control(__UI_SnappedXID).Top + Control(__UI_SnappedXID).Height - 1
1360 FOR Y1 = Y1 - 1 TO Y1 + 1
1361 LINE (X1 + ContainerOffsetLeft, Y1 + ContainerOffsetTop)-STEP(__UI_SnapDistance, 0), Control(__UI_FormID).SelectedBackColor
1362 NEXT
1363 CASE 2 'right of dragged control to left of snapped control
1364 X1 = Control(__UI_SnappedXID).Left
1365 Y1 = Control(__UI_DraggingID).Top + Control(__UI_DraggingID).Height / 2
1366 IF Y1 < Control(__UI_SnappedXID).Top + 1 THEN Y1 = Control(__UI_SnappedXID).Top + 1
1367 IF Y1 > Control(__UI_SnappedXID).Top + Control(__UI_SnappedXID).Height - 1 THEN Y1 = Control(__UI_SnappedXID).Top + Control(__UI_SnappedXID).Height - 1
1368 FOR Y1 = Y1 - 1 TO Y1 + 1
1369 LINE (X1 + ContainerOffsetLeft, Y1 + ContainerOffsetTop)-STEP(-__UI_SnapDistance, 0), Control(__UI_FormID).SelectedBackColor
1370 NEXT
1371 CASE 3 'snapped to left side of form
1372 X1 = Control(__UI_DraggingID).Left
1373 Y1 = Control(__UI_DraggingID).Top + Control(__UI_DraggingID).Height / 2
1374 IF Y1 < 1 THEN Y1 = 1
1375 IF Y1 > Control(__UI_FormID).Height - 2 THEN Y1 = Control(__UI_FormID).Height - 2
1376 FOR Y1 = Y1 - 1 TO Y1 + 1
1377 LINE (X1 + ContainerOffsetLeft, Y1 + ContainerOffsetTop)-STEP(-__UI_SnapDistanceFromForm, 0), Control(__UI_FormID).SelectedBackColor
1378 NEXT
1379 CASE 4 'snapped to right side of form
1380 X1 = Control(__UI_DraggingID).Left + Control(__UI_DraggingID).Width
1381 Y1 = Control(__UI_DraggingID).Top + Control(__UI_DraggingID).Height / 2
1382 IF Y1 < 1 THEN Y1 = 1
1383 IF Y1 > Control(__UI_FormID).Height - 2 THEN Y1 = Control(__UI_FormID).Height - 2
1384 FOR Y1 = Y1 - 1 TO Y1 + 1
1385 LINE (X1 + ContainerOffsetLeft, Y1 + ContainerOffsetTop)-STEP(__UI_SnapDistanceFromForm, 0), Control(__UI_FormID).SelectedBackColor
1386 NEXT
1387 END SELECT
1388 END IF
1389 END IF
1390 _DEST 0
1391 END IF
1392
1393 IF Control(i).ControlIsSelected THEN
1394 IF OverlayReset = False THEN
1395 'Reset the helper canvas of the main form
1396 OverlayReset = True
1397 IF Control(__UI_FormID).HelperCanvas <> 0 THEN _FREEIMAGE Control(__UI_FormID).HelperCanvas
1398 Control(__UI_FormID).HelperCanvas = _NEWIMAGE(Control(__UI_FormID).Width, Control(__UI_FormID).Height, 32)
1399 _DEST Control(__UI_FormID).HelperCanvas
1400 CLS , _RGBA32(0, 0, 0, 0)
1401 ELSE
1402 _DEST Control(__UI_FormID).HelperCanvas
1403 END IF
1404 OverlayisVisible = True
1405
1406 IF Control(i).Type = __UI_Type_MenuItem THEN
1407 TempParentID = Control(i).ParentID
1408 Control(i).ParentID = Control(i).MenuPanelID
1409 'Dotted outline:
1410 LINE (Control(i).Left + Control(Control(i).ParentID).Left - 2, Control(i).Top + Control(Control(i).ParentID).Top - 2)-STEP(Control(Control(i).ParentID).Width + 3, Control(i).Height + 3), _RGB32(0, 0, 0), B , 21845
1411 ELSE
1412 TempParentID = 0
1413 'Dotted outline:
1414 LINE (Control(i).Left + Control(Control(i).ParentID).Left - 2, Control(i).Top + Control(Control(i).ParentID).Top - 2)-STEP(Control(i).Width + 3, Control(i).Height + 3), _RGB32(0, 0, 0), B , 21845
1415 END IF
1416
1417 IF NOT __UI_IsDragging THEN
1418 IF __UI_Type(Control(i).Type).RestrictResize <> __UI_CantResizeH AND __UI_Type(Control(i).Type).RestrictResize <> __UI_CantResize THEN
1419 'Right resize handle:
1420 IF Control(i).Type = __UI_Type_MenuItem THEN
1421 LINE (Control(i).Left + Control(Control(i).ParentID).Left + Control(Control(i).ParentID).Width - 8, Control(i).Top + Control(Control(i).ParentID).Top + Control(i).Height / 2 - 4)-STEP(7, 7), _RGB32(255, 255, 255), BF
1422 LINE (Control(i).Left + Control(Control(i).ParentID).Left + Control(Control(i).ParentID).Width - 8, Control(i).Top + Control(Control(i).ParentID).Top + Control(i).Height / 2 - 4)-STEP(7, 7), _RGB32(0, 0, 0), B
1423 ELSE
1424 LINE (Control(i).Left + Control(Control(i).ParentID).Left + Control(i).Width - 8, Control(i).Top + Control(Control(i).ParentID).Top + Control(i).Height / 2 - 4)-STEP(7, 7), _RGB32(255, 255, 255), BF
1425 LINE (Control(i).Left + Control(Control(i).ParentID).Left + Control(i).Width - 8, Control(i).Top + Control(Control(i).ParentID).Top + Control(i).Height / 2 - 4)-STEP(7, 7), _RGB32(0, 0, 0), B
1426 END IF
1427
1428 'Left resize handle:
1429 LINE (Control(i).Left + Control(Control(i).ParentID).Left, Control(i).Top + Control(Control(i).ParentID).Top + Control(i).Height / 2 - 4)-STEP(7, 7), _RGB32(255, 255, 255), BF
1430 LINE (Control(i).Left + Control(Control(i).ParentID).Left, Control(i).Top + Control(Control(i).ParentID).Top + Control(i).Height / 2 - 4)-STEP(7, 7), _RGB32(0, 0, 0), B
1431 END IF
1432
1433 IF __UI_Type(Control(i).Type).RestrictResize <> __UI_CantResizeV AND __UI_Type(Control(i).Type).RestrictResize <> __UI_CantResize THEN
1434 'Bottom resize handle:
1435 LINE (Control(i).Left + Control(Control(i).ParentID).Left + Control(i).Width / 2 - 4, Control(i).Top + Control(Control(i).ParentID).Top + Control(i).Height - 8)-STEP(7, 7), _RGB32(255, 255, 255), BF
1436 LINE (Control(i).Left + Control(Control(i).ParentID).Left + Control(i).Width / 2 - 4, Control(i).Top + Control(Control(i).ParentID).Top + Control(i).Height - 8)-STEP(7, 7), _RGB32(0, 0, 0), B
1437
1438 'Top resize handle:
1439 LINE (Control(i).Left + Control(Control(i).ParentID).Left + Control(i).Width / 2 - 4, Control(i).Top + Control(Control(i).ParentID).Top)-STEP(7, 7), _RGB32(255, 255, 255), BF
1440 LINE (Control(i).Left + Control(Control(i).ParentID).Left + Control(i).Width / 2 - 4, Control(i).Top + Control(Control(i).ParentID).Top)-STEP(7, 7), _RGB32(0, 0, 0), B
1441 END IF
1442
1443 IF __UI_Type(Control(i).Type).RestrictResize = False THEN
1444 'Bottom-right resize handle:
1445 LINE (Control(i).Left + Control(Control(i).ParentID).Left + Control(i).Width - 8, Control(i).Top + Control(Control(i).ParentID).Top + Control(i).Height - 8)-STEP(7, 7), _RGB32(255, 255, 255), BF
1446 LINE (Control(i).Left + Control(Control(i).ParentID).Left + Control(i).Width - 8, Control(i).Top + Control(Control(i).ParentID).Top + Control(i).Height - 8)-STEP(7, 7), _RGB32(0, 0, 0), B
1447
1448 'Bottom-left resize handle:
1449 LINE (Control(i).Left + Control(Control(i).ParentID).Left, Control(i).Top + Control(Control(i).ParentID).Top + Control(i).Height - 8)-STEP(7, 7), _RGB32(255, 255, 255), BF
1450 LINE (Control(i).Left + Control(Control(i).ParentID).Left, Control(i).Top + Control(Control(i).ParentID).Top + Control(i).Height - 8)-STEP(7, 7), _RGB32(0, 0, 0), B
1451
1452 'Top-right resize handle:
1453 LINE (Control(i).Left + Control(Control(i).ParentID).Left + Control(i).Width - 8, Control(i).Top + Control(Control(i).ParentID).Top)-STEP(7, 7), _RGB32(255, 255, 255), BF
1454 LINE (Control(i).Left + Control(Control(i).ParentID).Left + Control(i).Width - 8, Control(i).Top + Control(Control(i).ParentID).Top)-STEP(7, 7), _RGB32(0, 0, 0), B
1455
1456 'Top-left resize handle:
1457 LINE (Control(i).Left + Control(Control(i).ParentID).Left, Control(i).Top + Control(Control(i).ParentID).Top)-STEP(7, 7), _RGB32(255, 255, 255), BF
1458 LINE (Control(i).Left + Control(Control(i).ParentID).Left, Control(i).Top + Control(Control(i).ParentID).Top)-STEP(7, 7), _RGB32(0, 0, 0), B
1459 END IF
1460 END IF
1461 IF TempParentID > 0 THEN Control(i).ParentID = TempParentID
1462 _DEST 0
1463 END IF
1464
1465 IF Control(i).ParentID > 0 AND Control(i).Type <> __UI_Type_MenuItem THEN
1466 'Check if no more controls will be drawn in this frame so it can be drawn too
1467 DIM CheckChildControls AS LONG, NoMoreChildren AS _BYTE, ThisParent AS LONG
1468
1469 ThisParent = Control(i).ParentID
1470 NoMoreChildren = True
1471 FOR CheckChildControls = i + 1 TO UBOUND(Control)
1472 IF Control(CheckChildControls).ParentID = ThisParent THEN
1473 NoMoreChildren = False
1474 EXIT FOR
1475 END IF
1476 NEXT
1477
1478 IF NoMoreChildren THEN
1479 'Draw frame
1480 __UI_DrawFrame Control(ThisParent)
1481 END IF
1482 END IF
1483
1484 IF i = __UI_Focus THEN __UI_CheckBinding i
1485 NEXT
1486
1487 FOR i = 1 TO UBOUND(Control)
1488 IF Control(i).Type = __UI_Type_Frame AND Control(i).Value = 0 THEN
1489 'Draw frame without any children controls
1490 __UI_DrawFrame Control(i)
1491 END IF
1492 NEXT
1493
1494 'Selection rectangle:
1495 IF __UI_DesignMode AND __UI_SelectionRectangle THEN
1496 IF OverlayReset = False THEN
1497 'Reset the helper canvas of the main form
1498 OverlayReset = True
1499 IF Control(__UI_FormID).HelperCanvas <> 0 THEN _FREEIMAGE Control(__UI_FormID).HelperCanvas
1500 Control(__UI_FormID).HelperCanvas = _NEWIMAGE(Control(__UI_FormID).Width, Control(__UI_FormID).Height, 32)
1501 _DEST Control(__UI_FormID).HelperCanvas
1502 CLS , _RGBA32(0, 0, 0, 0)
1503 ELSE
1504 _DEST Control(__UI_FormID).HelperCanvas
1505 END IF
1506 OverlayisVisible = True
1507
1508 LINE(__UI_SelectionRectangleLeft, __UI_SelectionRectangleTop)-(__UI_MouseLeft,__UI_MouseTop), _RGBA32(0, 177, 255, 150), BF
1509 LINE(__UI_SelectionRectangleLeft, __UI_SelectionRectangleTop)-(__UI_MouseLeft,__UI_MouseTop), _RGB32(39, 188, 244), B
1510 'LINE(__UI_SelectionRectangleLeft, __UI_SelectionRectangleTop)-(__UI_MouseLeft,__UI_MouseTop), Control(__UI_FormID).SelectedBackColor, B, 255 'Dotted line
1511 _DEST 0
1512 END IF
1513
1514 'Size and position indicator:
1515 IF __UI_TotalSelectedControls > 0 AND __UI_Snapped = False AND __UI_ShowPositionAndSize THEN
1516 IF Control(__UI_FormID).Width > 0 AND Control(__UI_FormID).Height > 0 THEN
1517 IF OverlayReset = False THEN
1518 'Reset the helper canvas of the main form
1519 OverlayReset = True
1520 IF Control(__UI_FormID).HelperCanvas <> 0 THEN _FREEIMAGE Control(__UI_FormID).HelperCanvas
1521 Control(__UI_FormID).HelperCanvas = _NEWIMAGE(Control(__UI_FormID).Width, Control(__UI_FormID).Height, 32)
1522 _DEST Control(__UI_FormID).HelperCanvas
1523 CLS , _RGBA32(0, 0, 0, 0)
1524 ELSE
1525 _DEST Control(__UI_FormID).HelperCanvas
1526 END IF
1527
1528 i = __UI_FirstSelectedID
1529 IF Control(__UI_HoveringID).ControlIsSelected THEN i = __UI_HoveringID
1530
1531 IF Control(i).Type <> __UI_Type_ContextMenu AND Control(i).Type <> __UI_Type_MenuBar AND Control(i).Type <> __UI_Type_MenuItem THEN
1532 OverlayisVisible = True
1533 DIM SizeAndPosition1$, SizeAndPosition2$, pw&
1534 DIM InfoLeft AS INTEGER, InfoTop AS INTEGER
1535 _FONT Control(__UI_FormID).Font
1536 'Calculate the info panel width
1537 SizeAndPosition1$ = LTRIM$(STR$(Control(i).Left)) + "," + LTRIM$(STR$(Control(i).Top))
1538 pw& = __UI_PrintWidth(SizeAndPosition1$)
1539 SizeAndPosition2$ = LTRIM$(STR$(Control(i).Width)) + "x" + LTRIM$(STR$(Control(i).Height))
1540 IF __UI_PrintWidth(SizeAndPosition2$) > pw& THEN pw& = __UI_PrintWidth(SizeAndPosition2$)
1541
1542 'Calculate the info panel position
1543 InfoLeft = Control(Control(i).ParentID).Left + Control(i).Left
1544 IF InfoLeft < 0 THEN InfoLeft = 0
1545 IF InfoLeft + pw& + 4 > Control(__UI_FormID).Width THEN InfoLeft = Control(__UI_FormID).Width - (pw& + 4)
1546
1547 InfoTop = Control(Control(i).ParentID).Top + Control(i).Top + Control(i).Height + 2
1548 IF InfoTop < 0 THEN InfoTop = 0
1549 IF InfoTop + uspacing& * 2 + 4 > Control(__UI_FormID).Height THEN InfoTop = Control(__UI_FormID).Height - (uspacing& * 2 + 4)
1550
1551 'Reposition the panel if it intersects with the controls
1552 IF InfoLeft < Control(Control(i).ParentID).Left + Control(i).Left + Control(i).Width AND _
1553 Control(Control(i).ParentID).Left + Control(i).Left < InfoLeft + pw& + 4 AND _
1554 InfoTop < Control(Control(i).ParentID).Top + Control(i).Top + Control(i).Height + 2 AND _
1555 Control(Control(i).ParentID).Top + Control(i).Top < InfoTop + uspacing& * 2 + 4 THEN
1556 InfoTop = Control(Control(i).ParentID).Top + Control(i).Top - (uspacing& * 2 + 4)
1557 END IF
1558
1559 'Reposition the panel if the mouse is where it'd be drawn
1560 IF __UI_MouseLeft >= InfoLeft AND __UI_MouseLeft <= InfoLeft + pw& + 4 AND _
1561 __UI_MouseTop >= InfoTop AND __UI_MouseTop <= InfoTop + uspacing& * 2 + 4 THEN
1562 InfoLeft = InfoLeft + Control(i).Width
1563 END IF
1564
1565 'Draw the info panel
1566 __UI_ShadowBox InfoLeft, InfoTop, pw& + 4, uspacing& * 2 + 4, __UI_DefaultColor(__UI_Type_Form, 6), 40, 5
1567
1568 'Print the info
1569 COLOR _RGB32(0, 0, 0)
1570 __UI_PrintString InfoLeft + 3, InfoTop + 3, SizeAndPosition1$
1571 __UI_PrintString InfoLeft + 3, InfoTop + 3 + uspacing&, SizeAndPosition2$
1572 END IF
1573
1574 _DEST 0
1575 END IF
1576 END IF
1577
1578 FOR i = 1 TO __UI_TotalActiveMenus
1579 IF LEFT$(Control(__UI_ActiveMenu(i)).Name, 5) <> "__UI_" THEN
1580 __UI_DrawMenuPanel Control(__UI_ActiveMenu(i)), __UI_ParentMenu(i)
1581 END IF
1582 NEXT
1583
1584 IF OverlayisVisible THEN
1585 IF Control(__UI_FormID).HelperCanvas < -1 THEN
1586 __UI_MakeHardwareImage Control(__UI_FormID).HelperCanvas
1587 _PUTIMAGE , Control(__UI_FormID).HelperCanvas
1588 END IF
1589 END IF
1590
1591 IF __UI_DesignMode = True AND __UI_ShowInvisibleControls = True THEN
1592 FOR i = 1 TO UBOUND(Control)
1593 IF Control(i).Type = __UI_Type_ContextMenu AND LEFT$(Control(i).Name, 5) <> "__UI_" THEN
1594 __UI_DrawContextMenuHandle Control(i), Control(i).ControlState
1595 END IF
1596 NEXT
1597 END IF
1598
1599 'Keep DesignMode context menus on top by drawing them last:
1600 FOR i = 1 TO __UI_TotalActiveMenus
1601 IF LEFT$(Control(__UI_ActiveMenu(i)).Name, 5) = "__UI_" THEN
1602 __UI_DrawMenuPanel Control(__UI_ActiveMenu(i)), __UI_ParentMenu(i)
1603 END IF
1604 NEXT
1605
1606 STATIC PanelWidth AS INTEGER, PanelHeight AS INTEGER
1607 IF __UI_ActiveTipID > 0 THEN
1608 IF __UI_ActiveTipID <> __UI_PreviousTipID OR ToolTip(__UI_ActiveTipID) <> __UI_TempTips(__UI_ActiveTipID) THEN
1609 __UI_PreviousTipID = __UI_ActiveTipID
1610 ToolTip(__UI_ActiveTipID) = RestoreCHR$(ToolTip(__UI_ActiveTipID))
1611 __UI_TempTips(__UI_ActiveTipID) = ToolTip(__UI_ActiveTipID)
1612
1613 DIM ThisLine%, TextTop%
1614 DIM FindLF AS LONG, TotalLines AS INTEGER, LongestLine AS INTEGER, TempLine$
1615 _FONT Control(__UI_FormID).Font
1616
1617 TempCaption$ = __UI_WordWrap(Replace(ToolTip(__UI_ActiveTipID), "\n", CHR$(10), False, 0), Control(__UI_FormID).Width / 2, LongestLine, TotalLines)
1618
1619 PanelWidth = LongestLine + 16
1620 IF TotalLines = 1 THEN
1621 PanelHeight = uspacing& + 8
1622 ELSE
1623 PanelHeight = (TotalLines * uspacing&) + 8
1624 END IF
1625
1626 IF ActiveTipPanel <> 0 THEN _FREEIMAGE ActiveTipPanel
1627 ActiveTipPanel = _NEWIMAGE(PanelWidth, PanelHeight, 32)
1628 _DEST ActiveTipPanel
1629 _FONT Control(__UI_FormID).Font
1630 __UI_ShadowBox 0, 0, PanelWidth - 6, PanelHeight - 6, __UI_DefaultColor(__UI_Type_Form, 6), 40, 5
1631 COLOR __UI_DefaultColor(__UI_Type_Form, 1)
1632
1633 IF TotalLines = 1 THEN
1634 __UI_PrintString _WIDTH \ 2 - __UI_PrintWidth(TempCaption$) \ 2 - 1.75, _HEIGHT \ 2 - uheight& \ 2 - 1.75, TempCaption$
1635 ELSE
1636 DO WHILE LEN(TempCaption$)
1637 ThisLine% = ThisLine% + 1
1638 TextTop% = 3 + ThisLine% * uspacing& - uspacing&
1639
1640 FindLF& = INSTR(TempCaption$, CHR$(1))
1641 IF FindLF& > 0 THEN
1642 TempLine$ = LEFT$(TempCaption$, FindLF& - 1)
1643 TempCaption$ = MID$(TempCaption$, FindLF& + 1)
1644 ELSE
1645 TempLine$ = TempCaption$
1646 TempCaption$ = ""
1647 IF ThisLine% = 1 THEN TextTop% = ((_HEIGHT \ 2) - uspacing& \ 2)
1648 END IF
1649
1650 __UI_PrintString 5, TextTop%, TempLine$
1651 LOOP
1652 END IF
1653
1654 LINE (0, 0)-(_WIDTH - 6, _HEIGHT - 6), __UI_DefaultColor(__UI_Type_Form, 5), B
1655 __UI_MakeHardwareImage ActiveTipPanel
1656 END IF
1657 _DEST 0
1658 IF __UI_ActiveTipTop + PanelHeight > Control(__UI_FormID).Height THEN
1659 __UI_ActiveTipTop = Control(__UI_FormID).Height - PanelHeight
1660 IF __UI_ActiveTipTop < 0 THEN __UI_ActiveTipTop = 0
1661 END IF
1662
1663 IF __UI_ActiveTipLeft + PanelWidth > Control(__UI_FormID).Width THEN
1664 __UI_ActiveTipLeft = Control(__UI_FormID).Width - PanelWidth
1665 IF __UI_ActiveTipLeft < 0 THEN __UI_ActiveTipLeft = 0
1666 END IF
1667 _PUTIMAGE (__UI_ActiveTipLeft, __UI_ActiveTipTop), ActiveTipPanel
1668 END IF
1669
1670 IF __UI_IsDragging AND __UI_DraggingID > 0 AND __UI_DraggingID <> __UI_FormID AND (_KEYDOWN(100305) = 0 AND _KEYDOWN(100306) = 0) AND __UI_SnapLines THEN
1671 STATIC DragTip AS LONG, TipPanelWidth AS INTEGER
1672
1673 IF DragTip = 0 THEN
1674 _FONT Control(__UI_FormID).Font
1675
1676 TempCaption$ = "Hold Ctrl to bypass snapping"
1677 TipPanelWidth = __UI_PrintWidth(TempCaption$) + 10
1678 PanelHeight = uspacing& + 5 + 5
1679
1680 DragTip = _NEWIMAGE(TipPanelWidth, PanelHeight, 32)
1681 _DEST DragTip
1682 _FONT Control(__UI_FormID).Font
1683 __UI_ShadowBox 0, 0, TipPanelWidth - 6, PanelHeight - 6, __UI_DefaultColor(__UI_Type_Form, 6), 40, 5
1684 COLOR __UI_DefaultColor(__UI_Type_Form, 1)
1685
1686 __UI_PrintString _WIDTH \ 2 - __UI_PrintWidth(TempCaption$) \ 2 - 1.75, _HEIGHT \ 2 - uspacing& \ 2 - 1.75, TempCaption$
1687
1688 LINE (0, 0)-(_WIDTH - 6, _HEIGHT - 6), __UI_DefaultColor(__UI_Type_Form, 5), B
1689 __UI_MakeHardwareImage DragTip
1690 END IF
1691 _DEST 0
1692
1693 IF __UI_Snapped THEN
1694 X1 = _WIDTH \ 2 - TipPanelWidth \ 2
1695 Y1 = 0
1696 IF Control(__UI_DraggingID).Top <= _HEIGHT(DragTip) THEN
1697 _PUTIMAGE (X1, Control(__UI_FormID).Height - _HEIGHT(DragTip)), DragTip
1698 ELSE
1699 _PUTIMAGE (X1, 0), DragTip
1700 END IF
1701 END IF
1702 ELSEIF __UI_IsResizing AND Control(__UI_ResizingID).Type = __UI_Type_Label AND Control(__UI_ResizingID).AutoSize = True THEN
1703 STATIC ResizeTip AS LONG, ResizeTipPanelWidth AS INTEGER
1704
1705 IF ResizeTip = 0 THEN
1706 _FONT Control(__UI_FormID).Font
1707
1708 TempCaption$ = "Can't resize a label when .AutoSize = True"
1709 ResizeTipPanelWidth = __UI_PrintWidth(TempCaption$) + 10
1710 PanelHeight = uspacing& + 5 + 5
1711
1712 ResizeTip = _NEWIMAGE(ResizeTipPanelWidth, PanelHeight, 32)
1713 _DEST ResizeTip
1714 _FONT Control(__UI_FormID).Font
1715 __UI_ShadowBox 0, 0, ResizeTipPanelWidth - 6, PanelHeight - 6, __UI_DefaultColor(__UI_Type_Form, 6), 40, 5
1716 COLOR __UI_DefaultColor(__UI_Type_Form, 1)
1717
1718 __UI_PrintString _WIDTH \ 2 - __UI_PrintWidth(TempCaption$) \ 2 - 1.75, _HEIGHT \ 2 - uspacing& \ 2 - 1.75, TempCaption$
1719
1720 LINE (0, 0)-(_WIDTH - 6, _HEIGHT - 6), __UI_DefaultColor(__UI_Type_Form, 5), B
1721 __UI_MakeHardwareImage ResizeTip
1722 END IF
1723 _DEST 0
1724
1725 X1 = _WIDTH \ 2 - ResizeTipPanelWidth \ 2
1726 Y1 = 0
1727 IF Control(__UI_ResizingID).Top <= _HEIGHT(ResizeTip) THEN
1728 _PUTIMAGE (X1, Control(__UI_FormID).Height - _HEIGHT(ResizeTip)), ResizeTip
1729 ELSE
1730 _PUTIMAGE (X1, 0), ResizeTip
1731 END IF
1732 END IF
1733
1734 __UI_ForceRedraw = False
1735
1736 STATIC WaitMessageSetup AS _BYTE, PrevWaitMessage AS STRING
1737 DIM NoInputMessage$
1738 IF TIMER - __UI_ProcessInputTimer > 2 THEN
1739 'Visually indicate that something is hogging the input routine
1740 IF __UI_WaitMessageHandle = 0 THEN
1741 __UI_WaitMessageHandle = _NEWIMAGE(_WIDTH(0), _HEIGHT(0), 32)
1742 ELSEIF _WIDTH(__UI_WaitMessageHandle) <> _WIDTH(0) OR _HEIGHT(__UI_WaitMessageHandle) <> _HEIGHT(0) THEN
1743 _FREEIMAGE __UI_WaitMessageHandle
1744 __UI_WaitMessageHandle = _NEWIMAGE(_WIDTH(0), _HEIGHT(0), 32)
1745 END IF
1746
1747 IF WaitMessageSetup = False OR PrevWaitMessage <> __UI_WaitMessage THEN
1748 PrevWaitMessage = __UI_WaitMessage
1749 WaitMessageSetup = True
1750 PrevDest = _DEST
1751 _DEST __UI_WaitMessageHandle
1752 LINE (0, 0)-STEP(_WIDTH, _HEIGHT), _RGBA32(0, 0, 0, 170), BF
1753 _FONT Control(__UI_FormID).Font
1754 _PRINTMODE _KEEPBACKGROUND
1755 NoInputMessage$ = "Please wait..."
1756 COLOR _RGB32(0, 0, 0)
1757 __UI_PrintString _WIDTH / 2 - __UI_PrintWidth(NoInputMessage$) / 2 + 1, _HEIGHT \ 2 - uspacing + 1, NoInputMessage$
1758 COLOR _RGB32(255, 255, 255)
1759 __UI_PrintString _WIDTH / 2 - __UI_PrintWidth(NoInputMessage$) / 2, _HEIGHT \ 2 - uspacing, NoInputMessage$
1760 IF LEN(__UI_WaitMessage) > 0 THEN
1761 IF LEFT$(__UI_WaitMessage, 1) <> "(" THEN __UI_WaitMessage = "(" + __UI_WaitMessage + ")"
1762 COLOR _RGB32(0, 0, 0)
1763 __UI_PrintString _WIDTH / 2 - __UI_PrintWidth(__UI_WaitMessage) / 2 + 1, _HEIGHT \ 2 + uspacing + 1, __UI_WaitMessage
1764 COLOR _RGB32(255, 255, 255)
1765 __UI_PrintString _WIDTH / 2 - __UI_PrintWidth(__UI_WaitMessage) / 2, _HEIGHT \ 2 + uspacing, __UI_WaitMessage
1766 END IF
1767 _DEST PrevDest
1768 __UI_MakeHardwareImage __UI_WaitMessageHandle
1769 END IF
1770 IF _EXIT THEN SYSTEM 'Can't force user to wait...
1771 _PUTIMAGE , __UI_WaitMessageHandle
1772 END IF
1773 FOR i = 1 TO 2
1774 IF ControlDrawOrder(UBOUND(ControlDrawOrder)) = 0 THEN __UI_ExpandControlDrawOrder -1
1775 NEXT i 'run that a couple times for good measure
1776 _DISPLAY
1777END SUB
1778
1779'---------------------------------------------------------------------------------
1780SUB __UI_EventDispatcher
1781 STATIC __UI_LastMouseIconSet AS _BYTE
1782 STATIC __UI_LastMouseDownEvent AS SINGLE
1783 STATIC __UI_MouseDownTop AS INTEGER, __UI_MouseDownLeft AS INTEGER
1784 STATIC __UI_JustOpenedMenu AS _BYTE
1785 STATIC OriginalDragX AS INTEGER, OriginalDragY AS INTEGER
1786 DIM i AS LONG, j AS LONG, ThisItem%, TempParent AS LONG
1787 DIM ContainerOffsetLeft AS INTEGER, ContainerOffsetTop AS INTEGER
1788
1789 IF __UI_HoveringID = 0 AND __UI_Focus = 0 THEN EXIT SUB
1790
1791 IF Control(__UI_HoveringID).ParentID > 0 AND Control(__UI_HoveringID).Type <> __UI_Type_MenuItem THEN
1792 ContainerOffsetLeft = Control(Control(__UI_HoveringID).ParentID).Left
1793 ContainerOffsetTop = Control(Control(__UI_HoveringID).ParentID).Top
1794 END IF
1795
1796 IF __UI_ExitTriggered THEN
1797 __UI_UnloadSignal = True
1798 __UI_BeforeUnload
1799 IF __UI_UnloadSignal THEN SYSTEM
1800 END IF
1801
1802 'Have we had a resize?
1803 IF __UI_HasResized THEN __UI_FormResized: __UI_HasResized = False
1804
1805 'Hover actions
1806 IF __UI_LastHoveringID <> __UI_HoveringID OR __UI_HoveringID = __UI_ActiveDropdownList THEN
1807 'MouseEnter, MouseLeave
1808 IF __UI_LastHoveringID THEN __UI_MouseLeave __UI_LastHoveringID
1809 __UI_MouseEnter __UI_HoveringID
1810
1811 STATIC LastMouseLeft AS INTEGER, LastMouseTop AS INTEGER
1812 IF NOT __UI_DraggingThumb AND __UI_HoveringID = __UI_ActiveDropdownList AND Control(__UI_HoveringID).HoveringVScrollbarButton = 0 AND LastMouseTop <> __UI_MouseTop THEN
1813 'Dropdown list items are preselected when hovered
1814 LastMouseTop = __UI_MouseTop
1815 IF Control(__UI_HoveringID).Max > 0 THEN
1816 IF Control(__UI_HoveringID).Font > 0 THEN _FONT Control(__UI_HoveringID).Font
1817 ThisItem% = ((__UI_MouseTop - (ContainerOffsetTop + Control(__UI_HoveringID).Top) - (ABS(Control(__UI_HoveringID).HasBorder) * __UI_DefaultCaptionIndent)) \ Control(__UI_HoveringID).ItemHeight) + Control(__UI_HoveringID).InputViewStart
1818 IF ThisItem% >= Control(__UI_HoveringID).Min AND ThisItem% <= Control(__UI_HoveringID).Max THEN
1819 Control(__UI_HoveringID).Value = ThisItem%
1820 IF Control(__UI_HoveringID).PreviousValue <> Control(__UI_HoveringID).Value THEN
1821 __UI_ValueChanged __UI_HoveringID
1822 Control(__UI_HoveringID).PreviousValue = Control(__UI_HoveringID).Value
1823 Control(__UI_HoveringID).Redraw = True
1824 END IF
1825 END IF
1826 END IF
1827 ELSEIF Control(__UI_HoveringID).Type = __UI_Type_MenuBar AND LastMouseLeft <> __UI_MouseLeft THEN
1828 LastMouseLeft = __UI_MouseLeft
1829 IF __UI_TotalActiveMenus > 0 AND __UI_ParentMenu(__UI_TotalActiveMenus) <> __UI_HoveringID THEN
1830 IF __UI_ActiveMenuIsContextMenu = False AND __UI_DesignMode = False THEN
1831 __UI_ActivateMenu Control(__UI_HoveringID), False
1832 __UI_ForceRedraw = True
1833 END IF
1834 END IF
1835 END IF
1836
1837 IF Control(__UI_Focus).Type = __UI_Type_MenuItem AND Control(__UI_HoveringID).Type <> __UI_Type_MenuItem THEN
1838 __UI_Focus = __UI_ActiveMenu(__UI_TotalActiveMenus)
1839 END IF
1840 END IF
1841
1842 $IF WIN OR MAC THEN
1843 IF __UI_ResizeHandleHover = 1 OR __UI_ResizeHandleHover = 3 THEN
1844 IF __UI_LastMouseIconSet <> 3 THEN
1845 __UI_LastMouseIconSet = 3
1846 _MOUSESHOW "horizontal"
1847 END IF
1848 ELSEIF __UI_ResizeHandleHover = 2 OR __UI_ResizeHandleHover = 4 THEN
1849 IF __UI_LastMouseIconSet <> 4 THEN
1850 __UI_LastMouseIconSet = 4
1851 _MOUSESHOW "vertical"
1852 END IF
1853 ELSEIF __UI_ResizeHandleHover = 5 OR __UI_ResizeHandleHover = 8 THEN
1854 IF __UI_LastMouseIconSet <> 5 THEN
1855 __UI_LastMouseIconSet = 5
1856 _MOUSESHOW "topright_bottomleft"
1857 END IF
1858 ELSEIF __UI_ResizeHandleHover = 6 OR __UI_ResizeHandleHover = 7 THEN
1859 IF __UI_LastMouseIconSet <> 6 THEN
1860 __UI_LastMouseIconSet = 6
1861 _MOUSESHOW "topleft_bottomright"
1862 END IF
1863 ELSEIF Control(__UI_HoveringID).Type = __UI_Type_TextBox AND NOT __UI_DesignMode THEN
1864 IF Control(__UI_HoveringID).HasVScrollbar AND __UI_MouseLeft >= Control(__UI_HoveringID).Left + Control(Control(__UI_HoveringID).ParentID).Left + Control(__UI_HoveringID).Width - __UI_ScrollbarWidth - 1 THEN
1865 IF __UI_LastMouseIconSet <> 0 THEN
1866 __UI_LastMouseIconSet = 0
1867 _MOUSESHOW "default"
1868 END IF
1869 ELSE
1870 IF __UI_LastMouseIconSet <> 2 THEN
1871 __UI_LastMouseIconSet = 2
1872 _MOUSESHOW "text"
1873 END IF
1874 END IF
1875 ELSE
1876 IF __UI_LastMouseIconSet <> 0 THEN
1877 __UI_LastMouseIconSet = 0
1878 _MOUSESHOW "default"
1879 END IF
1880 END IF
1881 $END IF
1882
1883 'FocusIn, FocusOut
1884 DIM __UI_FocusSearch AS LONG
1885 IF __UI_KeyHit = 9 AND __UI_IsDragging = False THEN 'TAB
1886 IF __UI_DesignMode THEN
1887
1888 __UI_FocusSearch = __UI_FirstSelectedID
1889
1890 FOR i = 1 TO UBOUND(Control)
1891 Control(i).ControlIsSelected = False
1892 NEXT
1893
1894 DO
1895 IF _KEYDOWN(100304) OR _KEYDOWN(100303) THEN
1896 __UI_FocusSearch = __UI_FocusSearch - 1
1897 IF __UI_FocusSearch < 1 THEN __UI_FocusSearch = UBOUND(Control)
1898 ELSE
1899 __UI_FocusSearch = __UI_FocusSearch + 1
1900 IF __UI_FocusSearch > UBOUND(Control) THEN __UI_FocusSearch = 0
1901 END IF
1902 IF __UI_FocusSearch = __UI_FirstSelectedID THEN
1903 'Full circle. No controls can be selected at the moment
1904 Control(__UI_FocusSearch).ControlIsSelected = True
1905 EXIT DO
1906 END IF
1907
1908 IF Control(__UI_FocusSearch).ID > 0 AND Control(__UI_FocusSearch).Type <> __UI_Type_Form AND Control(__UI_FocusSearch).Type <> __UI_Type_MenuPanel AND Control(__UI_FocusSearch).Type <> __UI_Type_Font AND UCASE$(LEFT$(Control(__UI_FocusSearch).Name, 5)) <> "__UI_" THEN
1909 IF Control(__UI_FocusSearch).Type <> __UI_Type_MenuItem THEN
1910 __UI_CloseAllMenus
1911 __UI_TotalSelectedControls = 1
1912 __UI_FirstSelectedID = __UI_FocusSearch
1913 Control(__UI_FocusSearch).ControlIsSelected = True
1914 IF Control(__UI_FocusSearch).Type = __UI_Type_MenuBar OR Control(__UI_FocusSearch).Type = __UI_Type_ContextMenu THEN
1915 __UI_ActivateMenu Control(__UI_FocusSearch), False
1916 END IF
1917 EXIT DO
1918 ELSE
1919 IF __UI_ParentMenu(__UI_TotalActiveMenus) = Control(__UI_FocusSearch).ParentID THEN
1920 __UI_TotalSelectedControls = 1
1921 __UI_FirstSelectedID = __UI_FocusSearch
1922 Control(__UI_FocusSearch).ControlIsSelected = True
1923 EXIT DO
1924 END IF
1925 END IF
1926 END IF
1927 LOOP
1928 ELSE
1929 __UI_KeyboardFocus = True
1930 __UI_FocusSearch = __UI_Focus
1931 DO
1932 IF _KEYDOWN(100304) OR _KEYDOWN(100303) THEN
1933 __UI_FocusSearch = __UI_FocusSearch - 1
1934 IF __UI_FocusSearch < 1 THEN __UI_FocusSearch = UBOUND(Control)
1935 ELSE
1936 __UI_FocusSearch = __UI_FocusSearch + 1
1937 IF __UI_FocusSearch > UBOUND(Control) THEN __UI_FocusSearch = 0
1938 END IF
1939 IF __UI_FocusSearch = __UI_Focus THEN
1940 'Full circle. No controls can have focus
1941 EXIT DO
1942 END IF
1943
1944 IF Control(__UI_FocusSearch).CanHaveFocus AND Control(__UI_FocusSearch).Disabled = False AND Control(__UI_FocusSearch).Hidden = False AND Control(Control(__UI_FocusSearch).ParentID).Disabled = False AND Control(Control(__UI_FocusSearch).ParentID).Hidden = False THEN
1945 IF __UI_Focus <> __UI_FocusSearch THEN __UI_KeepFocus = False: __UI_FocusOut __UI_Focus
1946 IF __UI_KeepFocus = False THEN
1947 __UI_Focus = __UI_FocusSearch
1948 IF Control(__UI_Focus).Type = __UI_Type_TextBox AND Control(__UI_Focus).Multiline = False THEN
1949 'Single-line textbox contents are selected when first focused.
1950 IF Control(__UI_Focus).BypassSelectOnFocus = False THEN
1951 Control(__UI_Focus).Cursor = LEN(Text(__UI_Focus))
1952 Control(__UI_Focus).SelectionStart = 0
1953 Control(__UI_Focus).TextIsSelected = True
1954 END IF
1955 END IF
1956 __UI_FocusIn __UI_Focus
1957 END IF
1958 EXIT DO
1959 END IF
1960 LOOP
1961 END IF
1962 END IF
1963
1964 'Any visible dropdown lists/menus will be destroyed when focus is lost
1965 IF __UI_DesignMode = False THEN
1966 IF __UI_ActiveDropdownList > 0 AND ((__UI_Focus <> __UI_ActiveDropdownList AND __UI_Focus <> __UI_ParentDropdownList) OR __UI_KeyHit = 27) THEN
1967 __UI_Focus = __UI_ParentDropdownList
1968 __UI_DestroyControl Control(__UI_ActiveDropdownList)
1969 __UI_KeyHit = 0
1970 ELSEIF __UI_TotalActiveMenus > 0 AND (__UI_Focus <> __UI_ActiveMenu(__UI_TotalActiveMenus) AND __UI_Focus <> __UI_ParentMenu(__UI_TotalActiveMenus)) THEN
1971 IF Control(__UI_Focus).Type <> __UI_Type_MenuItem THEN
1972 __UI_CloseAllMenus
1973 __UI_ForceRedraw = True
1974 END IF
1975 END IF
1976 END IF
1977
1978 'MouseWheel
1979 IF __UI_MouseWheel AND NOT __UI_DesignMode THEN
1980 IF (Control(__UI_HoveringID).Type = __UI_Type_ListBox AND NOT Control(__UI_HoveringID).Disabled) THEN
1981 Control(__UI_HoveringID).InputViewStart = Control(__UI_HoveringID).InputViewStart + __UI_MouseWheel
1982 IF Control(__UI_HoveringID).InputViewStart + Control(__UI_HoveringID).LastVisibleItem > Control(__UI_HoveringID).Max THEN
1983 Control(__UI_HoveringID).InputViewStart = Control(__UI_HoveringID).Max - Control(__UI_HoveringID).LastVisibleItem + 1
1984 END IF
1985 ELSEIF (__UI_ActiveDropdownList > 0 AND __UI_Focus = __UI_ActiveDropdownList AND __UI_ParentDropdownList = __UI_HoveringID) THEN
1986 Control(__UI_ActiveDropdownList).InputViewStart = Control(__UI_ActiveDropdownList).InputViewStart + __UI_MouseWheel
1987 IF Control(__UI_ActiveDropdownList).InputViewStart + Control(__UI_ActiveDropdownList).LastVisibleItem > Control(__UI_ActiveDropdownList).Max THEN
1988 Control(__UI_ActiveDropdownList).InputViewStart = Control(__UI_ActiveDropdownList).Max - Control(__UI_ActiveDropdownList).LastVisibleItem + 1
1989 END IF
1990 ELSEIF (Control(__UI_Focus).Type = __UI_Type_DropdownList AND NOT Control(__UI_Focus).Disabled) THEN
1991 Control(__UI_Focus).Value = Control(__UI_Focus).Value + __UI_MouseWheel
1992 IF Control(__UI_Focus).Value < 1 THEN Control(__UI_Focus).Value = 1
1993 IF Control(__UI_Focus).Value > Control(__UI_Focus).Max THEN Control(__UI_Focus).Value = Control(__UI_Focus).Max
1994 IF Control(__UI_Focus).PreviousValue <> Control(__UI_Focus).Value THEN
1995 __UI_ValueChanged __UI_Focus
1996 Control(__UI_Focus).PreviousValue = Control(__UI_Focus).Value
1997 Control(__UI_Focus).Redraw = True
1998 END IF
1999 ELSEIF Control(__UI_Focus).Type = __UI_Type_TextBox AND Control(__UI_Focus).MultiLine THEN
2000 DIM TotalLines AS LONG
2001 TotalLines = __UI_CountLines(__UI_Focus)
2002 _FONT Control(__UI_Focus).Font
2003 IF TotalLines > Control(__UI_Focus).Height \ uspacing& THEN
2004 Control(__UI_Focus).FirstVisibleLine = Control(__UI_Focus).FirstVisibleLine + __UI_MouseWheel
2005 IF Control(__UI_Focus).FirstVisibleLine < 1 THEN Control(__UI_Focus).FirstVisibleLine = 1
2006 IF Control(__UI_Focus).FirstVisibleLine > TotalLines - Control(__UI_Focus).Height \ uspacing& + 1 THEN
2007 Control(__UI_Focus).FirstVisibleLine = TotalLines - Control(__UI_Focus).Height \ uspacing& + 1
2008 END IF
2009 END IF
2010 END IF
2011 END IF
2012
2013 'MouseDown, MouseUp, BeginDrag
2014 IF __UI_MouseButton2 THEN
2015 'Second mouse button is first pressed
2016 IF __UI_Mouse2IsDown = False THEN
2017 __UI_Mouse2IsDown = True
2018 __UI_DidClick = True
2019 __UI_Mouse2DownOnID = __UI_HoveringID
2020 ELSE
2021 'Second mouse button is still pressed
2022 END IF
2023 ELSE
2024 'Second mousebutton is released
2025 IF __UI_Mouse2IsDown THEN
2026 __UI_Mouse2IsDown = False
2027 __UI_Mouse2DownOnID = 0
2028 'Click (second mouse button)
2029 IF __UI_DesignMode THEN
2030 DIM RightClickSelect AS _BYTE
2031 RightClickSelect = True
2032 GOSUB DesignModeClickToSelect
2033 RightClickSelect = False
2034 Control(__UI_GetID("__UI_PreviewMenuShowInvisibleControls")).Value = __UI_ShowInvisibleControls
2035 IF __UI_TotalSelectedControls = 0 THEN
2036 Control(__UI_GetID("__UI_PreviewMenuAlignLeft")).Hidden = True
2037 Control(__UI_GetID("__UI_PreviewMenuAlignRight")).Hidden = True
2038 Control(__UI_GetID("__UI_PreviewMenuAlignTops")).Hidden = True
2039 Control(__UI_GetID("__UI_PreviewMenuAlignBottoms")).Hidden = True
2040 Control(__UI_GetID("__UI_PreviewMenuAlignCenterV")).Hidden = True
2041 Control(__UI_GetID("__UI_PreviewMenuAlignCenterH")).Hidden = True
2042 Control(__UI_GetID("__UI_PreviewMenuAlignCentersV")).Hidden = True
2043 Control(__UI_GetID("__UI_PreviewMenuAlignCentersH")).Hidden = True
2044 Control(__UI_GetID("__UI_PreviewMenuDistributeV")).Hidden = True
2045 Control(__UI_GetID("__UI_PreviewMenuDistributeH")).Hidden = True
2046 Control(__UI_GetID("__UI_PreviewMenuCut")).Disabled = True
2047 Control(__UI_GetID("__UI_PreviewMenuCopy")).Disabled = True
2048 Control(__UI_GetID("__UI_PreviewMenuDelete")).Disabled = True
2049 Control(__UI_GetID("__UI_PreviewMenuImageOriginalSize")).Hidden = True
2050 Control(__UI_GetID("__UI_PreviewMenuNumericOnly")).Hidden = True
2051 Control(__UI_GetID("__UI_PreviewMenuSetDefaultButton")).Hidden = True
2052 Control(__UI_GetID("__UI_PreviewMenuBindControls")).Hidden = True
2053 Control(__UI_GetID("__UI_PreviewMenuShowInvisibleControls")).Hidden = False
2054 Control(__UI_GetID("__UI_PreviewMenuConvertType")).Hidden = True
2055 Control(__UI_GetID("__UI_PreviewMenuNewMenuBar")).Hidden = False
2056 Control(__UI_GetID("__UI_PreviewMenuNewContextMenu")).Hidden = False
2057 ELSEIF __UI_TotalSelectedControls = 1 THEN
2058 Control(__UI_GetID("__UI_PreviewMenuAlignLeft")).Hidden = True
2059 Control(__UI_GetID("__UI_PreviewMenuAlignRight")).Hidden = True
2060 Control(__UI_GetID("__UI_PreviewMenuAlignTops")).Hidden = True
2061 Control(__UI_GetID("__UI_PreviewMenuAlignBottoms")).Hidden = True
2062 IF Control(__UI_FirstSelectedID).Type <> __UI_Type_ContextMenu AND Control(__UI_FirstSelectedID).Type <> __UI_Type_MenuBar AND Control(__UI_FirstSelectedID).Type <> __UI_Type_MenuItem THEN
2063 Control(__UI_GetID("__UI_PreviewMenuAlignCenterV")).Hidden = False
2064 Control(__UI_GetID("__UI_PreviewMenuAlignCenterH")).Hidden = False
2065 SetCaption __UI_GetID("__UI_PreviewMenuAlignCenterV"), "Center &Vertically"
2066 SetCaption __UI_GetID("__UI_PreviewMenuAlignCenterH"), "Center &Horizontally-"
2067 Control(__UI_GetID("__UI_PreviewMenuNewMenuBar")).Hidden = True
2068 Control(__UI_GetID("__UI_PreviewMenuNewContextMenu")).Hidden = True
2069 Control(__UI_GetID("__UI_PreviewMenuShowInvisibleControls")).Hidden = True
2070 ELSE
2071 Control(__UI_GetID("__UI_PreviewMenuNewMenuBar")).Hidden = False
2072 Control(__UI_GetID("__UI_PreviewMenuNewContextMenu")).Hidden = False
2073 Control(__UI_GetID("__UI_PreviewMenuShowInvisibleControls")).Hidden = False
2074 Control(__UI_GetID("__UI_PreviewMenuAlignCenterV")).Hidden = True
2075 Control(__UI_GetID("__UI_PreviewMenuAlignCenterH")).Hidden = True
2076 END IF
2077 IF Control(__UI_FirstSelectedID).Type = __UI_Type_PictureBox AND LEN(Text(__UI_FirstSelectedID)) > 0 THEN
2078 IF Control(__UI_FirstSelectedID).Height - (Control(__UI_FirstSelectedID).BorderSize * ABS(Control(__UI_FirstSelectedID).HasBorder)) <> _HEIGHT(Control(__UI_FirstSelectedID).HelperCanvas) OR _
2079 Control(__UI_FirstSelectedID).Width - (Control(__UI_FirstSelectedID).BorderSize * ABS(Control(__UI_FirstSelectedID).HasBorder)) <> _WIDTH(Control(__UI_FirstSelectedID).HelperCanvas) THEN
2080 Control(__UI_GetID("__UI_PreviewMenuImageOriginalSize")).Hidden = False
2081 SetCaption __UI_GetID("__UI_PreviewMenuImageOriginalSize"), "Restore &image dimensions (" + LTRIM$(STR$(_WIDTH(Control(__UI_FirstSelectedID).HelperCanvas))) + "x" + LTRIM$(STR$(_HEIGHT(Control(__UI_FirstSelectedID).HelperCanvas))) + ")-"
2082 ELSE
2083 Control(__UI_GetID("__UI_PreviewMenuImageOriginalSize")).Hidden = True
2084 END IF
2085 ELSE
2086 Control(__UI_GetID("__UI_PreviewMenuImageOriginalSize")).Hidden = True
2087 END IF
2088 IF Control(__UI_FirstSelectedID).Type = __UI_Type_TextBox THEN
2089 IF Control(__UI_FirstSelectedID).NumericOnly = True THEN
2090 Control(__UI_GetID("__UI_PreviewMenuNumericOnly")).Hidden = False
2091 Control(__UI_GetID("__UI_PreviewMenuNumericOnly")).Value = False
2092 ELSEIF Control(__UI_FirstSelectedID).NumericOnly = __UI_NumericWithBounds THEN
2093 Control(__UI_GetID("__UI_PreviewMenuNumericOnly")).Hidden = False
2094 Control(__UI_GetID("__UI_PreviewMenuNumericOnly")).Value = True
2095 ELSE
2096 Control(__UI_GetID("__UI_PreviewMenuNumericOnly")).Hidden = True
2097 END IF
2098 ELSE
2099 Control(__UI_GetID("__UI_PreviewMenuNumericOnly")).Hidden = True
2100 Control(__UI_GetID("__UI_PreviewMenuNumericOnly")).Value = False
2101 END IF
2102 IF Control(__UI_FirstSelectedID).Type = __UI_Type_Button THEN
2103 IF __UI_FirstSelectedID <> __UI_DefaultButtonID THEN
2104 Control(__UI_GetID("__UI_PreviewMenuSetDefaultButton")).Hidden = False
2105 Control(__UI_GetID("__UI_PreviewMenuSetDefaultButton")).Value = False
2106 ELSE
2107 Control(__UI_GetID("__UI_PreviewMenuSetDefaultButton")).Hidden = False
2108 Control(__UI_GetID("__UI_PreviewMenuSetDefaultButton")).Value = True
2109 END IF
2110 ELSE
2111 Control(__UI_GetID("__UI_PreviewMenuSetDefaultButton")).Hidden = True
2112 END IF
2113 Control(__UI_GetID("__UI_PreviewMenuAlignCentersV")).Hidden = True
2114 Control(__UI_GetID("__UI_PreviewMenuAlignCentersH")).Hidden = True
2115 Control(__UI_GetID("__UI_PreviewMenuDistributeV")).Hidden = True
2116 Control(__UI_GetID("__UI_PreviewMenuDistributeH")).Hidden = True
2117 Control(__UI_GetID("__UI_PreviewMenuCut")).Disabled = False
2118 Control(__UI_GetID("__UI_PreviewMenuCopy")).Disabled = False
2119 Control(__UI_GetID("__UI_PreviewMenuDelete")).Disabled = False
2120 IF __UI_Type(Control(__UI_FirstSelectedID).Type).TurnsInto THEN
2121 Control(__UI_GetID("__UI_PreviewMenuConvertType")).Hidden = False
2122 SetCaption __UI_GetID("__UI_PreviewMenuConvertType"), "Co&nvert to " + RTRIM$(__UI_Type(__UI_Type(Control(__UI_FirstSelectedID).Type).TurnsInto).Name) + "-"
2123 ELSEIF Control(__UI_FirstSelectedID).Type = __UI_Type_TextBox THEN
2124 'Offer to turn text to numeric-only TextBox
2125 Control(__UI_GetID("__UI_PreviewMenuConvertType")).Hidden = False
2126 IF Control(__UI_FirstSelectedID).NumericOnly = False THEN
2127 SetCaption __UI_GetID("__UI_PreviewMenuConvertType"), "Co&nvert to NumericTextBox-"
2128 ELSE
2129 SetCaption __UI_GetID("__UI_PreviewMenuConvertType"), "Co&nvert to TextBox-"
2130 END IF
2131 ELSE
2132 Control(__UI_GetID("__UI_PreviewMenuConvertType")).Hidden = True
2133 END IF
2134
2135 IF Control(__UI_FirstSelectedID).BoundTo > 0 THEN
2136 Control(__UI_GetID("__UI_PreviewMenuBindControls")).Hidden = False
2137 SetCaption __UI_GetID("__UI_PreviewMenuBindControls"), "Edit binding...-"
2138 END IF
2139 ELSEIF __UI_TotalSelectedControls = 2 THEN
2140 Control(__UI_GetID("__UI_PreviewMenuBindControls")).Hidden = False
2141 IF Control(__UI_FirstSelectedID).BoundTo > 0 THEN
2142 SetCaption __UI_GetID("__UI_PreviewMenuBindControls"), "Edit binding...-"
2143 ELSE
2144 SetCaption __UI_GetID("__UI_PreviewMenuBindControls"), "Bind selected controls...-"
2145 END IF
2146
2147 Control(__UI_GetID("__UI_PreviewMenuNewMenuBar")).Hidden = True
2148 Control(__UI_GetID("__UI_PreviewMenuNewContextMenu")).Hidden = True
2149 Control(__UI_GetID("__UI_PreviewMenuShowInvisibleControls")).Hidden = True
2150 Control(__UI_GetID("__UI_PreviewMenuAlignLeft")).Hidden = False
2151 Control(__UI_GetID("__UI_PreviewMenuAlignRight")).Hidden = False
2152 Control(__UI_GetID("__UI_PreviewMenuAlignTops")).Hidden = False
2153 Control(__UI_GetID("__UI_PreviewMenuAlignBottoms")).Hidden = False
2154 Control(__UI_GetID("__UI_PreviewMenuAlignCenterV")).Hidden = False
2155 Control(__UI_GetID("__UI_PreviewMenuAlignCenterH")).Hidden = False
2156 SetCaption __UI_GetID("__UI_PreviewMenuAlignCenterV"), "Center &Vertically (group)"
2157 SetCaption __UI_GetID("__UI_PreviewMenuAlignCenterH"), "Center &Horizontally (group)-"
2158 Control(__UI_GetID("__UI_PreviewMenuAlignCentersV")).Hidden = False
2159 Control(__UI_GetID("__UI_PreviewMenuAlignCentersH")).Hidden = False
2160 Control(__UI_GetID("__UI_PreviewMenuDistributeV")).Hidden = True
2161 Control(__UI_GetID("__UI_PreviewMenuDistributeH")).Hidden = True
2162 Control(__UI_GetID("__UI_PreviewMenuCut")).Disabled = False
2163 Control(__UI_GetID("__UI_PreviewMenuCopy")).Disabled = False
2164 Control(__UI_GetID("__UI_PreviewMenuDelete")).Disabled = False
2165 Control(__UI_GetID("__UI_PreviewMenuImageOriginalSize")).Hidden = True
2166 Control(__UI_GetID("__UI_PreviewMenuSetDefaultButton")).Hidden = True
2167 Control(__UI_GetID("__UI_PreviewMenuNumericOnly")).Hidden = True
2168 GOTO AddConvertMenu
2169 ELSE
2170 Control(__UI_GetID("__UI_PreviewMenuNewMenuBar")).Hidden = True
2171 Control(__UI_GetID("__UI_PreviewMenuNewContextMenu")).Hidden = True
2172 Control(__UI_GetID("__UI_PreviewMenuShowInvisibleControls")).Hidden = True
2173 Control(__UI_GetID("__UI_PreviewMenuAlignLeft")).Hidden = False
2174 Control(__UI_GetID("__UI_PreviewMenuAlignRight")).Hidden = False
2175 Control(__UI_GetID("__UI_PreviewMenuAlignTops")).Hidden = False
2176 Control(__UI_GetID("__UI_PreviewMenuAlignBottoms")).Hidden = False
2177 Control(__UI_GetID("__UI_PreviewMenuAlignCenterV")).Hidden = False
2178 Control(__UI_GetID("__UI_PreviewMenuAlignCenterH")).Hidden = False
2179 SetCaption __UI_GetID("__UI_PreviewMenuAlignCenterV"), "Center &Vertically (group)"
2180 SetCaption __UI_GetID("__UI_PreviewMenuAlignCenterH"), "Center &Horizontally (group)-"
2181 Control(__UI_GetID("__UI_PreviewMenuAlignCentersV")).Hidden = False
2182 Control(__UI_GetID("__UI_PreviewMenuAlignCentersH")).Hidden = False
2183 Control(__UI_GetID("__UI_PreviewMenuDistributeV")).Hidden = False
2184 Control(__UI_GetID("__UI_PreviewMenuDistributeH")).Hidden = False
2185 Control(__UI_GetID("__UI_PreviewMenuCut")).Disabled = False
2186 Control(__UI_GetID("__UI_PreviewMenuCopy")).Disabled = False
2187 Control(__UI_GetID("__UI_PreviewMenuDelete")).Disabled = False
2188 Control(__UI_GetID("__UI_PreviewMenuImageOriginalSize")).Hidden = True
2189 Control(__UI_GetID("__UI_PreviewMenuSetDefaultButton")).Hidden = True
2190 Control(__UI_GetID("__UI_PreviewMenuNumericOnly")).Hidden = True
2191
2192 AddConvertMenu:
2193 IF __UI_Type(Control(__UI_FirstSelectedID).Type).TurnsInto OR Control(__UI_FirstSelectedID).Type = __UI_Type_TextBox THEN
2194 DIM SearchType AS INTEGER, AddConvertMenuCheck AS _BYTE
2195 SearchType = Control(__UI_FirstSelectedID).Type
2196 AddConvertMenuCheck = True
2197 FOR i = 1 TO UBOUND(Control)
2198 IF Control(i).ControlIsSelected THEN
2199 IF Control(i).Type <> SearchType THEN
2200 AddConvertMenuCheck = False
2201 EXIT FOR
2202 END IF
2203 END IF
2204 NEXT
2205 IF AddConvertMenuCheck THEN
2206 Control(__UI_GetID("__UI_PreviewMenuConvertType")).Hidden = False
2207 IF SearchType = __UI_Type_TextBox THEN
2208 IF Control(__UI_FirstSelectedID).NumericOnly = False THEN
2209 SetCaption __UI_GetID("__UI_PreviewMenuConvertType"), "Co&nvert to NumericTextBox-"
2210 ELSE
2211 SetCaption __UI_GetID("__UI_PreviewMenuConvertType"), "Co&nvert to TextBox-"
2212 END IF
2213 ELSE
2214 SetCaption __UI_GetID("__UI_PreviewMenuConvertType"), "Co&nvert to " + RTRIM$(__UI_Type(__UI_Type(Control(__UI_FirstSelectedID).Type).TurnsInto).Name) + "-"
2215 END IF
2216 ELSE
2217 Control(__UI_GetID("__UI_PreviewMenuConvertType")).Hidden = True
2218 END IF
2219 ELSE
2220 Control(__UI_GetID("__UI_PreviewMenuConvertType")).Hidden = True
2221 END IF
2222 END IF
2223
2224 IF LEFT$(_CLIPBOARD$, LEN(__UI_ClipboardCheck$)) = __UI_ClipboardCheck$ THEN
2225 Control(__UI_GetID("__UI_PreviewMenuPaste")).Disabled = False
2226 ELSE
2227 Control(__UI_GetID("__UI_PreviewMenuPaste")).Disabled = True
2228 END IF
2229
2230 IF Control(__UI_HoveringID).Type = __UI_Type_MenuBar THEN
2231 Control(__UI_GetID("__UI_PreviewMenuCut")).Disabled = True
2232 Control(__UI_GetID("__UI_PreviewMenuCopy")).Disabled = True
2233 END IF
2234
2235 IF __UI_HoveringID > 0 AND Control(__UI_HoveringID).Type <> __UI_Type_MenuItem AND Control(__UI_HoveringID).Type <> __UI_Type_MenuPanel THEN __UI_ActivateMenu Control(__UI_GetID("__UI_PreviewMenu")), False
2236 __UI_CantShowContextMenu = False
2237
2238 IF Control(__UI_ActiveMenu(__UI_TotalActiveMenus)).Height > Control(__UI_FormID).Height OR Control(__UI_ActiveMenu(__UI_TotalActiveMenus)).Width > Control(__UI_FormID).Width THEN
2239 __UI_CantShowContextMenu = True
2240 END IF
2241 ELSEIF Control(__UI_HoveringID).ContextMenuID > 0 AND Control(__UI_HoveringID).Disabled = False THEN
2242 __UI_Focus = __UI_HoveringID
2243 __UI_PreviousFocus = __UI_Focus
2244
2245 'Internal text field menu:
2246 IF Control(__UI_HoveringID).ContextMenuID = __UI_GetID("__UI_TextFieldMenu") THEN
2247 IF Control(__UI_HoveringID).TextIsSelected THEN
2248 Control(__UI_GetID("__UI_TextMenuCut")).Disabled = False
2249 Control(__UI_GetID("__UI_TextMenuCopy")).Disabled = False
2250 Control(__UI_GetID("__UI_TextMenuDelete")).Disabled = False
2251 ELSE
2252 Control(__UI_GetID("__UI_TextMenuCut")).Disabled = True
2253 Control(__UI_GetID("__UI_TextMenuCopy")).Disabled = True
2254 Control(__UI_GetID("__UI_TextMenuDelete")).Disabled = True
2255 END IF
2256
2257 IF LEN(_CLIPBOARD$) > 0 THEN
2258 Control(__UI_GetID("__UI_TextMenuPaste")).Disabled = False
2259 ELSE
2260 Control(__UI_GetID("__UI_TextMenuPaste")).Disabled = True
2261 END IF
2262 END IF
2263 __UI_ContextMenuSourceID = __UI_HoveringID
2264 __UI_ActivateMenu Control(Control(__UI_HoveringID).ContextMenuID), False
2265 END IF
2266 END IF
2267 END IF
2268
2269 IF __UI_MouseButton1 THEN
2270 'Mouse button is first pressed
2271 IF __UI_MouseIsDown = False THEN
2272 __UI_DidClick = True
2273 __UI_MouseDownTop = __UI_MouseTop
2274 __UI_MouseDownLeft = __UI_MouseLeft
2275 IF __UI_DesignMode THEN
2276 IF LEFT$(Control(__UI_HoveringID).Name, 5) = "__UI_" THEN GOTO ProcessClick
2277 DesignModeClickToSelect:
2278 IF RightClickSelect AND (Control(__UI_HoveringID).Type = __UI_Type_MenuPanel OR LEFT$(Control(__UI_HoveringID).Name, 5) = "__UI_") THEN RETURN
2279 IF __UI_TotalActiveMenus > 0 AND Control(__UI_HoveringID).Type <> __UI_Type_MenuPanel THEN
2280 IF Control(__UI_Focus).Type <> __UI_Type_MenuItem THEN
2281 __UI_CloseAllMenus
2282 __UI_ForceRedraw = True
2283 END IF
2284 END IF
2285
2286 IF _KEYDOWN(100305) OR _KEYDOWN(100306) THEN
2287 IF Control(__UI_HoveringID).Type <> __UI_Type_Frame AND Control(__UI_HoveringID).Type <> __UI_Type_Form AND Control(__UI_HoveringID).Type <> __UI_Type_Font AND Control(__UI_HoveringID).Type <> __UI_Type_MenuItem AND Control(__UI_HoveringID).Type <> __UI_Type_MenuPanel AND Control(__UI_HoveringID).Type <> __UI_Type_ContextMenu AND Control(__UI_HoveringID).Type <> __UI_Type_MenuBar THEN
2288 IF Control(__UI_HoveringID).ControlIsSelected = False AND Control(__UI_HoveringID).ParentID = Control(__UI_FirstSelectedID).ParentID AND Control(__UI_FirstSelectedID).Type <> __UI_Type_Frame THEN
2289 Control(__UI_HoveringID).ControlIsSelected = True
2290 __UI_TotalSelectedControls = __UI_TotalSelectedControls + 1
2291 ELSEIF Control(__UI_HoveringID).ControlIsSelected = True THEN
2292 Control(__UI_HoveringID).ControlIsSelected = False
2293 __UI_TotalSelectedControls = __UI_TotalSelectedControls - 1
2294 IF __UI_TotalSelectedControls = 1 THEN
2295 FOR i = 1 TO UBOUND(Control)
2296 IF Control(i).ControlIsSelected THEN __UI_FirstSelectedID = i: EXIT FOR
2297 NEXT
2298 ELSEIF __UI_TotalSelectedControls > 0 AND __UI_FirstSelectedID = __UI_HoveringID THEN
2299 FOR i = 1 TO UBOUND(Control)
2300 IF Control(i).ControlIsSelected THEN __UI_FirstSelectedID = i: EXIT FOR
2301 NEXT
2302 END IF
2303 END IF
2304 END IF
2305 ELSEIF _KEYDOWN(100303) OR _KEYDOWN(100304) THEN
2306 IF __UI_FirstSelectedID <> __UI_HoveringID AND Control(__UI_HoveringID).Type <> __UI_Type_Frame AND Control(__UI_HoveringID).Type <> __UI_Type_Form AND Control(__UI_HoveringID).Type <> __UI_Type_Font AND Control(__UI_HoveringID).Type <> __UI_Type_MenuItem AND Control(__UI_HoveringID).Type <> __UI_Type_MenuPanel AND Control(__UI_HoveringID).Type <> __UI_Type_ContextMenu AND Control(__UI_HoveringID).Type <> __UI_Type_MenuBar THEN
2307 'Select all controls in the range between the first
2308 'selected and the one being clicked, emulating the
2309 'selection rectangle.
2310 IF Control(__UI_FirstSelectedID).ParentID = Control(__UI_HoveringID).ParentID THEN
2311 __UI_SelectionRectangleLeft = Control(__UI_FirstSelectedID).Left + Control(__UI_FirstSelectedID).Width / 2
2312 __UI_SelectionRectangleTop = Control(__UI_FirstSelectedID).Top + Control(__UI_FirstSelectedID).Height / 2
2313 GOTO DoSelectionRectangle
2314 END IF
2315 END IF
2316 ELSE
2317 IF Control(__UI_HoveringID).Type = __UI_Type_MenuPanel AND LEFT$(Control(__UI_GetParentMenu(__UI_HoveringID)).Name, 5) <> "__UI_" THEN
2318 DIM TempValue AS LONG
2319 TempParent = __UI_GetParentMenu(__UI_HoveringID)
2320 TempValue = __UI_NewControl(__UI_Type_MenuItem, "", 0, 0, 0, 0, TempParent)
2321 SetCaption TempValue, RTRIM$(Control(TempValue).Name)
2322 FOR i = __UI_TotalActiveMenus TO __UI_GetActiveMenuIndex(__UI_HoveringID) STEP -1
2323 __UI_DestroyControl Control(__UI_ActiveMenu(i))
2324 NEXT
2325 __UI_ActivateMenu Control(TempParent), False
2326 FOR i = 1 TO UBOUND(Control)
2327 Control(i).ControlIsSelected = False
2328 NEXT
2329 Control(TempValue).ControlIsSelected = True
2330 __UI_ActivateMenu Control(TempValue), False
2331 __UI_ForceRedraw = True
2332 __UI_TotalSelectedControls = 1
2333 __UI_FirstSelectedID = TempValue
2334 ELSEIF Control(__UI_HoveringID).Type = __UI_Type_Form AND __UI_MouseTop <= (uspacing& + 5) THEN
2335 IF __UI_HasMenuBar THEN
2336 __UI_KeyPress 224
2337 END IF
2338 ELSE
2339 IF Control(__UI_HoveringID).ControlIsSelected = False THEN
2340 FOR i = 1 TO UBOUND(Control)
2341 Control(i).ControlIsSelected = False
2342 NEXT
2343 __UI_TotalSelectedControls = 0
2344 __UI_FirstSelectedID = 0
2345 IF Control(__UI_HoveringID).Type <> __UI_Type_Form AND Control(__UI_HoveringID).Type <> __UI_Type_Font AND Control(__UI_HoveringID).Type <> __UI_Type_MenuPanel THEN
2346 IF Control(__UI_HoveringID).Type = __UI_Type_ContextMenu AND __UI_ShowInvisibleControls = False THEN GOTO SkipInvisibleControl
2347 Control(__UI_HoveringID).ControlIsSelected = True
2348 __UI_TotalSelectedControls = 1
2349 __UI_FirstSelectedID = __UI_HoveringID
2350 IF Control(__UI_HoveringID).Type = __UI_Type_MenuItem OR Control(__UI_HoveringID).Type = __UI_Type_MenuBar OR (Control(__UI_HoveringID).Type = __UI_Type_ContextMenu AND __UI_ShowInvisibleControls) THEN
2351 __UI_ActivateMenu Control(__UI_HoveringID), False
2352 __UI_JustOpenedMenu = True
2353 END IF
2354 SkipInvisibleControl:
2355 END IF
2356 ELSE
2357 IF Control(__UI_FirstSelectedID).Type = __UI_Type_Frame AND (TIMER - __UI_LastMouseDownEvent < .5 AND (__UI_MouseTop = __UI_MouseDownTop AND __UI_MouseLeft = __UI_MouseDownLeft)) THEN
2358 'Select all controls inside a frame
2359 __UI_KeyPress 221
2360 END IF
2361 END IF
2362 END IF
2363 END IF
2364 IF RightClickSelect THEN RETURN
2365 ELSEIF Control(__UI_HoveringID).CanHaveFocus AND NOT Control(__UI_HoveringID).Disabled THEN
2366 STATIC JustEnteredTextBox AS SINGLE
2367 IF __UI_Focus <> __UI_HoveringID THEN
2368 __UI_KeepFocus = False: __UI_FocusOut __UI_Focus
2369 IF __UI_KeepFocus = False THEN
2370 __UI_Focus = __UI_HoveringID
2371 IF Control(__UI_Focus).Type = __UI_Type_TextBox THEN JustEnteredTextBox = TIMER
2372 __UI_FocusIn __UI_Focus
2373 END IF
2374 END IF
2375 ELSE
2376 IF Control(__UI_HoveringID).Type = __UI_Type_MenuBar AND __UI_TotalActiveMenus > 0 AND __UI_HoveringID = __UI_ParentMenu(__UI_TotalActiveMenus) THEN
2377 __UI_Focus = __UI_PreviousFocus
2378 ELSEIF Control(__UI_HoveringID).Type = __UI_Type_MenuBar AND (__UI_TotalActiveMenus = 0 OR __UI_ActiveMenuIsContextMenu) THEN
2379 __UI_CloseAllMenus
2380 __UI_ActivateMenu Control(__UI_HoveringID), False
2381 __UI_JustOpenedMenu = True
2382 ELSEIF Control(__UI_HoveringID).Type = __UI_Type_MenuItem THEN
2383 'Do nothing until mouseup (click)
2384 ELSE
2385 IF __UI_Focus > 0 THEN __UI_KeepFocus = False: __UI_FocusOut __UI_Focus
2386 IF __UI_KeepFocus = False THEN __UI_Focus = 0
2387 END IF
2388 END IF
2389 __UI_MouseIsDown = True
2390 __UI_MouseDownOnID = __UI_HoveringID
2391
2392 IF __UI_DesignMode AND __UI_MouseDownOnID = __UI_FormID THEN
2393 __UI_SelectionRectangle = True
2394 __UI_SelectionRectangleTop = __UI_MouseTop
2395 __UI_SelectionRectangleLeft = __UI_MouseLeft
2396 ELSE
2397 __UI_SelectionRectangle = False
2398 END IF
2399
2400 IF NOT __UI_DesignMode THEN
2401 IF Control(__UI_Focus).Type = __UI_Type_TextBox AND NOT Control(__UI_Focus).Disabled THEN
2402 _FONT Control(__UI_Focus).Font
2403 IF Control(__UI_HoveringID).HoveringVScrollbarButton = 1 OR Control(__UI_HoveringID).HoveringVScrollbarButton = 2 OR Control(__UI_HoveringID).HoveringVScrollbarButton = 4 OR Control(__UI_HoveringID).HoveringVScrollbarButton = 5 THEN
2404 __UI_MouseDownOnScrollbar = TIMER
2405 ELSEIF Control(__UI_HoveringID).HoveringVScrollbarButton = 3 THEN
2406 IF NOT __UI_DraggingThumb THEN
2407 __UI_DraggingThumb = True
2408 __UI_ThumbDragTop = __UI_MouseTop
2409 __UI_DraggingThumbOnID = __UI_HoveringID
2410 END IF
2411 ELSE
2412 IF TIMER - JustEnteredTextBox =< .3 THEN
2413 IF Control(__UI_Focus).Multiline THEN
2414 GOTO PositionCursorMultilineTB
2415 ELSE
2416 'Single-line textbox contents are selected when first focused.
2417 IF Control(__UI_Focus).BypassSelectOnFocus = False THEN
2418 Control(__UI_Focus).Cursor = LEN(Text(__UI_Focus))
2419 Control(__UI_Focus).SelectionStart = 0
2420 Control(__UI_Focus).TextIsSelected = True
2421 END IF
2422 END IF
2423 ELSE
2424 STATIC WholeWordSelection AS _BYTE, WholeWordCursor AS LONG, WholeWordSelStart AS LONG
2425 Control(__UI_Focus).TextIsSelected = False
2426 __UI_FillSelectedText 0, 0
2427 WholeWordSelection = False
2428 WholeWordCursor = 0
2429 WholeWordSelStart = 0
2430 IF Control(__UI_Focus).Multiline AND Control(__UI_Focus).HoveringVScrollbarButton = 0 THEN
2431 PositionCursorMultilineTB:
2432 'Multi-line textbox click (position cursor)
2433 'Calculate which line was clicked
2434 DIM ThisLine$, ThisLineLen AS LONG, ThisLineStart AS LONG
2435
2436 TotalLines = __UI_CountLines(__UI_Focus)
2437 Control(__UI_Focus).CurrentLine = Control(__UI_Focus).FirstVisibleLine - 1 + (__UI_MouseTop - Control(__UI_Focus).Top - Control(Control(__UI_Focus).ParentID).Top) / uspacing&
2438 IF Control(__UI_Focus).CurrentLine > TotalLines THEN Control(__UI_Focus).CurrentLine = TotalLines
2439 IF Control(__UI_Focus).CurrentLine = 0 THEN Control(__UI_Focus).CurrentLine = 1
2440 ThisLine$ = __UI_GetTextBoxLine(__UI_Focus, Control(__UI_Focus).CurrentLine, ThisLineStart)
2441 ThisLineLen = LEN(ThisLine$)
2442
2443 'Print the text offscreen just to fill the right variables
2444 __UI_PrintString _WIDTH + 10, _HEIGHT + 10, ThisLine$
2445
2446 'New cursor position:
2447 FOR i = 1 TO __UI_LastRenderedCharCount
2448 IF (__UI_MouseLeft - Control(__UI_Focus).Left - Control(Control(__UI_Focus).ParentID).Left) >= __UI_ThisLineChars(i - 1) AND (__UI_MouseLeft - Control(__UI_Focus).Left - Control(Control(__UI_Focus).ParentID).Left) <= __UI_ThisLineChars(i) THEN
2449 Control(__UI_Focus).Cursor = ThisLineStart + i - 2
2450 EXIT FOR
2451 END IF
2452 NEXT
2453
2454 IF i > __UI_LastRenderedCharCount THEN Control(__UI_Focus).Cursor = ThisLineStart + ThisLineLen - 1
2455 Control(__UI_Focus).SelectionStart = Control(__UI_Focus).Cursor
2456 ELSE
2457 'Position cursor in single-line textbox:
2458 STATIC LastCursorReposition#, LastCursorID AS LONG, LastCursor AS LONG
2459 STATIC JustSelectedAWord#, ContinuedSelection AS _BYTE
2460
2461 IF TIMER - LastCursorReposition# < .3 AND LastCursorID = __UI_Focus AND i <= __UI_LastRenderedCharCount AND LastCursor = Control(__UI_Focus).Cursor THEN
2462 'Double click on this textbox, same position.
2463 'Attempt to select this "word", with "word" being
2464 'any block of characters separated by a space, comma, or similar.
2465 CONST SEP$ = " ,.?!;:()=+-*/"
2466
2467 IF INSTR(SEP$, MID$(Text(__UI_Focus), Control(__UI_Focus).Cursor + 1, 1)) = 0 THEN
2468 RepositionCursorWholeWord:
2469 DO
2470 Control(__UI_Focus).Cursor = Control(__UI_Focus).Cursor - 1
2471 IF Control(__UI_Focus).Cursor = 0 THEN EXIT DO
2472 LOOP WHILE INSTR(SEP$, MID$(Text(__UI_Focus), Control(__UI_Focus).Cursor + 1, 1)) = 0
2473 Control(__UI_Focus).Cursor = Control(__UI_Focus).Cursor + 1
2474
2475 IF ContinuedSelection THEN RETURN
2476
2477 RepositionSelStartWholeWord:
2478 DO
2479 Control(__UI_Focus).SelectionStart = Control(__UI_Focus).SelectionStart + 1
2480 IF Control(__UI_Focus).SelectionStart = LEN(Text(__UI_Focus)) THEN EXIT DO
2481 LOOP WHILE INSTR(SEP$, MID$(Text(__UI_Focus), Control(__UI_Focus).SelectionStart + 1, 1)) = 0
2482
2483 DO
2484 'Select extra spaces to the right until another character is found,
2485 'for easy "whole word" replacement/deletion
2486 IF Control(__UI_Focus).SelectionStart = LEN(Text(__UI_Focus)) THEN EXIT DO
2487 IF MID$(Text(__UI_Focus), Control(__UI_Focus).SelectionStart + 1, 1) = " " THEN
2488 Control(__UI_Focus).SelectionStart = Control(__UI_Focus).SelectionStart + 1
2489 ELSE
2490 EXIT DO
2491 END IF
2492 LOOP
2493
2494 IF ContinuedSelection THEN RETURN
2495
2496 Control(__UI_Focus).TextIsSelected = True
2497 JustSelectedAWord# = TIMER
2498 WholeWordSelection = True
2499 WholeWordCursor = Control(__UI_Focus).Cursor
2500 WholeWordSelStart = Control(__UI_Focus).SelectionStart
2501 END IF
2502 ELSE
2503 IF TIMER - JustSelectedAWord# > .3 THEN
2504 Control(__UI_Focus).TextIsSelected = False
2505 __UI_FillSelectedText 0, 0
2506
2507 'Print the text offscreen just to fill the right variables
2508 __UI_PrintString _WIDTH + 10, _HEIGHT + 10, Text(__UI_Focus)
2509
2510 'Single-line textbox click
2511 FOR i = 1 TO __UI_LastRenderedCharCount
2512 IF (__UI_MouseLeft - Control(__UI_Focus).Left - Control(Control(__UI_Focus).ParentID).Left + Control(__UI_Focus).InputViewStart) >= __UI_ThisLineChars(i - 1) AND (__UI_MouseLeft - Control(__UI_Focus).Left - Control(Control(__UI_Focus).ParentID).Left) + Control(__UI_Focus).InputViewStart <= __UI_ThisLineChars(i) THEN
2513 Control(__UI_Focus).Cursor = i - 1
2514 EXIT FOR
2515 END IF
2516 NEXT
2517
2518 IF i > __UI_LastRenderedCharCount THEN Control(__UI_Focus).Cursor = LEN(Text(__UI_Focus))
2519 Control(__UI_Focus).SelectionStart = Control(__UI_Focus).Cursor
2520 END IF
2521 END IF
2522
2523 LastCursorReposition# = TIMER
2524 LastCursorID = __UI_Focus
2525 LastCursor = Control(__UI_Focus).Cursor
2526 END IF
2527 __UI_IsSelectingText = True
2528 __UI_IsSelectingTextOnID = __UI_Focus
2529 END IF
2530 END IF
2531 ELSEIF Control(__UI_HoveringID).Type = __UI_Type_ListBox AND NOT Control(__UI_HoveringID).Disabled THEN
2532 IF Control(__UI_HoveringID).HoveringVScrollbarButton = 1 OR Control(__UI_HoveringID).HoveringVScrollbarButton = 2 OR Control(__UI_HoveringID).HoveringVScrollbarButton = 4 OR Control(__UI_HoveringID).HoveringVScrollbarButton = 5 THEN
2533 __UI_MouseDownOnScrollbar = TIMER
2534 ELSEIF Control(__UI_HoveringID).HoveringVScrollbarButton = 3 THEN
2535 IF NOT __UI_DraggingThumb THEN
2536 __UI_DraggingThumb = True
2537 __UI_ThumbDragTop = __UI_MouseTop
2538 __UI_DraggingThumbOnID = __UI_HoveringID
2539 END IF
2540 END IF
2541 END IF
2542 END IF
2543 __UI_MouseDown __UI_HoveringID
2544 __UI_LastMouseDownEvent = TIMER
2545 ELSE
2546 'Mouse button is still pressed
2547 IF __UI_DesignMode THEN
2548 IF __UI_ResizeHandleHover = 0 AND (__UI_MouseTop <> __UI_MouseDownTop OR __UI_MouseLeft <> __UI_MouseDownLeft) THEN
2549 IF __UI_IsDragging = False AND __UI_SelectionRectangle = False THEN
2550 __UI_IsDragging = True
2551 __UI_DraggingID = __UI_HoveringID
2552 FOR i = 1 TO UBOUND(Control)
2553 IF Control(i).ControlIsSelected AND Control(i).Type = __UI_Type_Frame THEN
2554 'Frames can't be dragged with other controls
2555 __UI_DraggingID = i
2556 FOR i = 1 TO UBOUND(Control)
2557 IF i <> __UI_DraggingID THEN
2558 IF Control(i).ControlIsSelected THEN
2559 Control(i).ControlIsSelected = False
2560 __UI_TotalSelectedControls = __UI_TotalSelectedControls - 1
2561 END IF
2562 END IF
2563 NEXT
2564 EXIT FOR
2565 END IF
2566 NEXT
2567 IF Control(__UI_FirstSelectedID).Type = __UI_Type_ContextMenu OR Control(__UI_FirstSelectedID).Type = __UI_Type_MenuBar OR Control(__UI_FirstSelectedID).Type = __UI_Type_MenuItem THEN
2568 __UI_DraggingID = 0
2569 __UI_IsDragging = False
2570 __UI_MouseDownOnID = 0
2571 ELSE
2572 __UI_MouseDownOnID = 0
2573 __UI_DragY = __UI_MouseTop
2574 __UI_DragX = __UI_MouseLeft
2575 OriginalDragX = __UI_DragX - Control(__UI_DraggingID).Left - Control(Control(__UI_DraggingID).ParentID).Left
2576 OriginalDragY = __UI_DragY - Control(__UI_DraggingID).Top - Control(Control(__UI_DraggingID).ParentID).Top
2577 IF __UI_TotalSelectedControls > 1 THEN
2578 FOR i = 1 TO UBOUND(Control)
2579 IF i <> __UI_DraggingID THEN
2580 Control(i).LeftOffsetFromFirstSelected = Control(__UI_DraggingID).Left - Control(i).Left
2581 Control(i).TopOffsetFromFirstSelected = Control(__UI_DraggingID).Top - Control(i).Top
2582 END IF
2583 NEXT
2584 END IF
2585 END IF
2586 END IF
2587 ELSE
2588 IF __UI_IsResizing = False AND __UI_SelectionRectangle = False AND Control(__UI_FirstSelectedID).Type <> __UI_Type_MenuBar AND Control(__UI_FirstSelectedID).Type <> __UI_Type_MenuItem THEN
2589 __UI_IsResizing = True
2590 __UI_ResizingID = __UI_HoveringID
2591 __UI_MouseDownOnID = 0
2592 __UI_DragY = __UI_MouseTop
2593 __UI_DragX = __UI_MouseLeft
2594 END IF
2595 END IF
2596 END IF
2597
2598 IF TIMER - JustEnteredTextBox < .3 THEN JustEnteredTextBox = TIMER
2599
2600 IF __UI_IsSelectingText THEN
2601 _FONT (Control(__UI_IsSelectingTextOnID).Font)
2602 IF NOT Control(__UI_IsSelectingTextOnID).Multiline THEN
2603 'Print the text offscreen just to fill the right variables
2604 __UI_PrintString _WIDTH + 10, _HEIGHT + 10, Text(__UI_Focus)
2605 IF NOT WholeWordSelection THEN
2606 'Single line selection, char by char
2607
2608
2609 IF __UI_MouseLeft > Control(__UI_Focus).Left + Control(Control(__UI_Focus).ParentID).Left AND __UI_MouseLeft < Control(__UI_Focus).Left + Control(Control(__UI_Focus).ParentID).Left + Control(__UI_Focus).Width THEN
2610 FOR i = 1 TO __UI_LastRenderedCharCount
2611 IF (__UI_MouseLeft - Control(__UI_Focus).Left - Control(Control(__UI_Focus).ParentID).Left + Control(__UI_Focus).InputViewStart) >= __UI_ThisLineChars(i - 1) AND (__UI_MouseLeft - Control(__UI_Focus).Left - Control(Control(__UI_Focus).ParentID).Left) + Control(__UI_Focus).InputViewStart <= __UI_ThisLineChars(i) THEN
2612 Control(__UI_Focus).Cursor = i - 1
2613 EXIT FOR
2614 END IF
2615 NEXT
2616 IF i > __UI_LastRenderedCharCount THEN Control(__UI_Focus).Cursor = LEN(Text(__UI_Focus))
2617 ELSEIF __UI_MouseLeft < Control(__UI_Focus).Left + Control(Control(__UI_Focus).ParentID).Left THEN
2618 Control(__UI_Focus).Cursor = 0
2619 ELSEIF __UI_MouseLeft > Control(__UI_Focus).Left + Control(Control(__UI_Focus).ParentID).Left + Control(__UI_Focus).Width THEN
2620 Control(__UI_Focus).Cursor = LEN(Text(__UI_Focus))
2621 END IF
2622
2623 IF Control(__UI_IsSelectingTextOnID).Cursor <> Control(__UI_IsSelectingTextOnID).SelectionStart THEN
2624 Control(__UI_IsSelectingTextOnID).TextIsSelected = True
2625 ELSE
2626 Control(__UI_IsSelectingTextOnID).TextIsSelected = False
2627 END IF
2628 ELSE
2629 'Single line selection, word by word
2630 DIM TempCursor AS LONG
2631
2632 IF __UI_MouseLeft > Control(__UI_Focus).Left + Control(Control(__UI_Focus).ParentID).Left AND __UI_MouseLeft < Control(__UI_Focus).Left + Control(Control(__UI_Focus).ParentID).Left + Control(__UI_Focus).Width THEN
2633 FOR i = 1 TO __UI_LastRenderedCharCount
2634 IF (__UI_MouseLeft - Control(__UI_Focus).Left - Control(Control(__UI_Focus).ParentID).Left + Control(__UI_Focus).InputViewStart) >= __UI_ThisLineChars(i - 1) AND (__UI_MouseLeft - Control(__UI_Focus).Left - Control(Control(__UI_Focus).ParentID).Left) + Control(__UI_Focus).InputViewStart <= __UI_ThisLineChars(i) THEN
2635 TempCursor = i - 1
2636 EXIT FOR
2637 END IF
2638 NEXT
2639 ELSEIF __UI_MouseLeft < Control(__UI_Focus).Left + Control(Control(__UI_Focus).ParentID).Left THEN
2640 TempCursor = 0
2641 ELSEIF __UI_MouseLeft > Control(__UI_Focus).Left + Control(Control(__UI_Focus).ParentID).Left + Control(__UI_Focus).Width THEN
2642 TempCursor = LEN(Text(__UI_Focus))
2643 END IF
2644
2645 ContinuedSelection = True
2646 IF TempCursor < WholeWordCursor THEN Control(__UI_Focus).Cursor = TempCursor: GOSUB RepositionCursorWholeWord
2647 IF TempCursor > WholeWordSelStart THEN Control(__UI_Focus).SelectionStart = TempCursor: GOSUB RepositionSelStartWholeWord
2648 IF TempCursor > WholeWordCursor AND TempCursor < WholeWordSelStart THEN Control(__UI_Focus).Cursor = WholeWordCursor: Control(__UI_Focus).SelectionStart = WholeWordSelStart
2649
2650 ContinuedSelection = False
2651 END IF
2652 ELSE
2653 'Multi-line textbox click
2654 'Calculate current line
2655 TotalLines = __UI_CountLines(__UI_IsSelectingTextOnID)
2656 Control(__UI_IsSelectingTextOnID).CurrentLine = Control(__UI_IsSelectingTextOnID).FirstVisibleLine - 1 + (__UI_MouseTop - Control(__UI_IsSelectingTextOnID).Top - Control(Control(__UI_IsSelectingTextOnID).ParentID).Top) / uspacing&
2657 IF Control(__UI_IsSelectingTextOnID).CurrentLine > TotalLines THEN Control(__UI_IsSelectingTextOnID).CurrentLine = TotalLines
2658 IF Control(__UI_IsSelectingTextOnID).CurrentLine = 0 THEN Control(__UI_IsSelectingTextOnID).CurrentLine = 1
2659 ThisLine$ = __UI_GetTextBoxLine(__UI_IsSelectingTextOnID, Control(__UI_IsSelectingTextOnID).CurrentLine, ThisLineStart)
2660 ThisLineLen = LEN(ThisLine$)
2661 __UI_PrintString _WIDTH + 10, _HEIGHT + 10, ThisLine$
2662
2663 'New cursor position:
2664 FOR i = 1 TO __UI_LastRenderedCharCount
2665 IF (__UI_MouseLeft - Control(__UI_IsSelectingTextOnID).Left - Control(Control(__UI_IsSelectingTextOnID).ParentID).Left) >= __UI_ThisLineChars(i - 1) AND (__UI_MouseLeft - Control(__UI_IsSelectingTextOnID).Left - Control(Control(__UI_IsSelectingTextOnID).ParentID).Left) <= __UI_ThisLineChars(i) THEN
2666 Control(__UI_IsSelectingTextOnID).Cursor = ThisLineStart + i - 2
2667 EXIT FOR
2668 END IF
2669 NEXT
2670
2671 IF i > __UI_LastRenderedCharCount THEN Control(__UI_IsSelectingTextOnID).Cursor = ThisLineStart + ThisLineLen - 1
2672
2673 IF Control(__UI_IsSelectingTextOnID).Cursor <> Control(__UI_IsSelectingTextOnID).SelectionStart THEN
2674 Control(__UI_IsSelectingTextOnID).TextIsSelected = True
2675 END IF
2676 END IF
2677 END IF
2678
2679 IF NOT __UI_SelectionRectangle THEN
2680 IF __UI_MouseDownOnID <> __UI_HoveringID AND __UI_MouseDownOnID > 0 THEN
2681 IF Control(__UI_HoveringID).Type = __UI_Type_MenuItem OR Control(__UI_HoveringID).Type = __UI_Type_MenuPanel THEN
2682 __UI_MouseDownOnID = __UI_HoveringID
2683 ELSE
2684 __UI_PreviousMouseDownOnID = __UI_MouseDownOnID
2685 __UI_MouseDownOnID = 0
2686 END IF
2687 ELSEIF __UI_HoveringID = __UI_PreviousMouseDownOnID AND __UI_PreviousMouseDownOnID > 0 THEN
2688 __UI_MouseDownOnID = __UI_PreviousMouseDownOnID
2689 __UI_PreviousMouseDownOnID = 0
2690 ELSEIF __UI_MouseDownOnID = __UI_HoveringID THEN
2691 IF Control(__UI_MouseDownOnID).Type = __UI_Type_ListBox THEN
2692 IF NOT Control(__UI_MouseDownOnID).Disabled AND Control(__UI_MouseDownOnID).HoveringVScrollbarButton = 1 AND TIMER - __UI_MouseDownOnScrollbar > .3 THEN
2693 'Mousedown on "up" button
2694 Control(__UI_MouseDownOnID).InputViewStart = Control(__UI_MouseDownOnID).InputViewStart - 1
2695 __UI_MouseDownOnScrollbar = TIMER - .25
2696 ELSEIF NOT Control(__UI_MouseDownOnID).Disabled AND Control(__UI_MouseDownOnID).HoveringVScrollbarButton = 2 AND TIMER - __UI_MouseDownOnScrollbar > .3 THEN
2697 'Mousedown on "down" button
2698 IF Control(__UI_MouseDownOnID).InputViewStart + Control(__UI_MouseDownOnID).LastVisibleItem <= Control(__UI_MouseDownOnID).Max THEN
2699 Control(__UI_MouseDownOnID).InputViewStart = Control(__UI_MouseDownOnID).InputViewStart + 1
2700 END IF
2701 __UI_MouseDownOnScrollbar = TIMER - .25
2702 ELSEIF NOT Control(__UI_MouseDownOnID).Disabled AND Control(__UI_MouseDownOnID).HoveringVScrollbarButton = 4 AND TIMER - __UI_MouseDownOnScrollbar < .3 THEN
2703 'Mousedown on "track" area above the thumb
2704 Control(__UI_MouseDownOnID).InputViewStart = Control(__UI_MouseDownOnID).InputViewStart - (Control(__UI_MouseDownOnID).LastVisibleItem - 1)
2705 __UI_MouseDownOnScrollbar = TIMER - .25
2706 ELSEIF NOT Control(__UI_MouseDownOnID).Disabled AND Control(__UI_MouseDownOnID).HoveringVScrollbarButton = 5 AND TIMER - __UI_MouseDownOnScrollbar < .3 THEN
2707 'Mousedown on "track" area below the thumb
2708 Control(__UI_MouseDownOnID).InputViewStart = Control(__UI_MouseDownOnID).InputViewStart + (Control(__UI_MouseDownOnID).LastVisibleItem - 1)
2709 IF Control(__UI_MouseDownOnID).InputViewStart > Control(__UI_MouseDownOnID).Max - Control(__UI_MouseDownOnID).LastVisibleItem - 1 THEN
2710 Control(__UI_MouseDownOnID).InputViewStart = Control(__UI_MouseDownOnID).Max - Control(__UI_MouseDownOnID).LastVisibleItem - 1
2711 END IF
2712 __UI_MouseDownOnScrollbar = TIMER - .25
2713 END IF
2714 ELSEIF Control(__UI_MouseDownOnID).Type = __UI_Type_TextBox THEN
2715 _FONT Control(__UI_MouseDownOnID).Font
2716 IF NOT Control(__UI_MouseDownOnID).Disabled AND Control(__UI_MouseDownOnID).HoveringVScrollbarButton = 1 AND TIMER - __UI_MouseDownOnScrollbar > .3 THEN
2717 'Mousedown on "up" button
2718 Control(__UI_MouseDownOnID).FirstVisibleLine = Control(__UI_MouseDownOnID).FirstVisibleLine - 1
2719 IF Control(__UI_MouseDownOnID).FirstVisibleLine < 0 THEN Control(__UI_MouseDownOnID).FirstVisibleLine = 1
2720 ELSEIF NOT Control(__UI_MouseDownOnID).Disabled AND Control(__UI_MouseDownOnID).HoveringVScrollbarButton = 2 AND TIMER - __UI_MouseDownOnScrollbar > .3 THEN
2721 'Mousedown on "down" button
2722 IF Control(__UI_MouseDownOnID).FirstVisibleLine < __UI_CountLines(__UI_MouseDownOnID) - Control(__UI_MouseDownOnID).Height \ uspacing& + 1 THEN
2723 Control(__UI_MouseDownOnID).FirstVisibleLine = Control(__UI_MouseDownOnID).FirstVisibleLine + 1
2724 END IF
2725 ELSEIF NOT Control(__UI_MouseDownOnID).Disabled AND Control(__UI_MouseDownOnID).HoveringVScrollbarButton = 4 AND TIMER - __UI_MouseDownOnScrollbar < .3 THEN
2726 'Mousedown on "track" area above the thumb
2727 Control(__UI_MouseDownOnID).InputViewStart = Control(__UI_MouseDownOnID).InputViewStart - (Control(__UI_MouseDownOnID).LastVisibleItem - 1)
2728 ELSEIF NOT Control(__UI_MouseDownOnID).Disabled AND Control(__UI_MouseDownOnID).HoveringVScrollbarButton = 5 AND TIMER - __UI_MouseDownOnScrollbar < .3 THEN
2729 'Mousedown on "track" area below the thumb
2730 Control(__UI_MouseDownOnID).InputViewStart = Control(__UI_MouseDownOnID).InputViewStart + (Control(__UI_MouseDownOnID).LastVisibleItem - 1)
2731 IF Control(__UI_MouseDownOnID).InputViewStart > Control(__UI_MouseDownOnID).Max - Control(__UI_MouseDownOnID).LastVisibleItem - 1 THEN
2732 Control(__UI_MouseDownOnID).InputViewStart = Control(__UI_MouseDownOnID).Max - Control(__UI_MouseDownOnID).LastVisibleItem - 1
2733 END IF
2734 END IF
2735 END IF
2736
2737 IF Control(__UI_MouseDownOnID).Type = __UI_Type_TrackBar AND NOT Control(__UI_MouseDownOnID).Disabled THEN
2738 Control(__UI_HoveringID).Value = __UI_MAP((__UI_MouseLeft - (ContainerOffsetLeft + Control(__UI_HoveringID).Left)), 0, Control(__UI_HoveringID).Width, Control(__UI_HoveringID).Min, Control(__UI_HoveringID).Max)
2739 IF Control(__UI_HoveringID).Value < Control(__UI_HoveringID).Min THEN
2740 Control(__UI_HoveringID).Value = Control(__UI_HoveringID).Min
2741 END IF
2742 IF Control(__UI_HoveringID).Value > Control(__UI_HoveringID).Max THEN
2743 Control(__UI_HoveringID).Value = Control(__UI_HoveringID).Max
2744 END IF
2745 END IF
2746 END IF
2747 END IF
2748
2749 IF __UI_MouseDownOnID = 0 AND Control(__UI_PreviousMouseDownOnID).Type = __UI_Type_TrackBar AND NOT Control(__UI_PreviousMouseDownOnID).Disabled THEN
2750 Control(__UI_PreviousMouseDownOnID).Value = __UI_MAP((__UI_MouseLeft - (Control(Control(__UI_PreviousMouseDownOnID).ParentID).Left + Control(__UI_PreviousMouseDownOnID).Left)), 0, Control(__UI_PreviousMouseDownOnID).Width, Control(__UI_PreviousMouseDownOnID).Min, Control(__UI_PreviousMouseDownOnID).Max)
2751 IF Control(__UI_PreviousMouseDownOnID).Value > Control(__UI_PreviousMouseDownOnID).Max THEN Control(__UI_PreviousMouseDownOnID).Value = Control(__UI_PreviousMouseDownOnID).Max
2752 IF Control(__UI_PreviousMouseDownOnID).Value < Control(__UI_PreviousMouseDownOnID).Min THEN Control(__UI_PreviousMouseDownOnID).Value = Control(__UI_PreviousMouseDownOnID).Min
2753 'IF Control(__UI_PreviousMouseDownOnID).PreviousValue <> Control(__UI_PreviousMouseDownOnID).Value THEN __UI_ValueChanged __UI_PreviousMouseDownOnID
2754 END IF
2755
2756 END IF
2757 ELSE
2758 'Mouse button is released
2759 IF __UI_MouseIsDown THEN
2760 IF __UI_IsDragging THEN
2761 __UI_IsDragging = False
2762 __UI_DraggingID = 0
2763 __UI_Snapped = 0
2764 __UI_SnappedByProximityX = False
2765 __UI_SnappedByProximityY = False
2766 __UI_ForceRedraw = True
2767 END IF
2768 IF __UI_IsResizing THEN
2769 __UI_IsResizing = False
2770 __UI_ResizingID = 0
2771 END IF
2772 IF __UI_DraggingThumb THEN
2773 __UI_DraggingThumb = False
2774 __UI_DraggingThumbOnID = 0
2775 END IF
2776
2777 'Fire __UI_MouseUp
2778 IF __UI_PreviousMouseDownOnID > 0 THEN
2779 __UI_MouseUp __UI_PreviousMouseDownOnID
2780 ELSE
2781 IF __UI_MouseDownOnID > 0 THEN __UI_MouseUp __UI_MouseDownOnID
2782 END IF
2783
2784 'Click
2785 IF NOT __UI_DesignMode AND __UI_MouseDownOnID = __UI_HoveringID AND __UI_HoveringID > 0 THEN
2786 IF NOT Control(__UI_HoveringID).Disabled THEN
2787 SELECT CASE Control(__UI_HoveringID).Type
2788 CASE __UI_Type_RadioButton
2789 SetRadioButtonValue __UI_HoveringID
2790 CASE __UI_Type_CheckBox, __UI_Type_ToggleSwitch
2791 Control(__UI_HoveringID).Value = NOT Control(__UI_HoveringID).Value
2792 __UI_ValueChanged __UI_HoveringID
2793 Control(__UI_HoveringID).LastChange = TIMER
2794 CASE __UI_Type_TextBox
2795 'DIM TempNewCursor AS LONG
2796 'STATIC LastTextBoxClick AS SINGLE, LastTextBoxClickID AS LONG
2797
2798 IF Control(__UI_HoveringID).HasVScrollbar AND __UI_MouseLeft >= Control(__UI_HoveringID).Left + Control(__UI_HoveringID).Width - 25 + ContainerOffsetLeft THEN
2799 'Control has a vertical scrollbar and it's been clicked
2800 IF __UI_MouseTop >= Control(__UI_HoveringID).Top + ContainerOffsetTop AND NOT Control(__UI_HoveringID).Disabled AND __UI_MouseTop <= Control(__UI_HoveringID).Top + ContainerOffsetTop + __UI_ScrollbarButtonHeight THEN
2801 'Click on "up" button
2802 Control(__UI_MouseDownOnID).FirstVisibleLine = Control(__UI_MouseDownOnID).FirstVisibleLine - 1
2803 IF Control(__UI_MouseDownOnID).FirstVisibleLine < 0 THEN Control(__UI_MouseDownOnID).FirstVisibleLine = 1
2804 ELSEIF __UI_MouseTop >= Control(__UI_HoveringID).VScrollbarButton2Top + ContainerOffsetTop AND NOT Control(__UI_HoveringID).Disabled THEN
2805 'Click on "down" button
2806 IF Control(__UI_MouseDownOnID).FirstVisibleLine < __UI_CountLines(__UI_MouseDownOnID) - Control(__UI_MouseDownOnID).Height \ uspacing& + 1 THEN
2807 Control(__UI_MouseDownOnID).FirstVisibleLine = Control(__UI_MouseDownOnID).FirstVisibleLine + 1
2808 END IF
2809 END IF
2810 ELSE
2811 IF TIMER - JustEnteredTextBox > .3 THEN
2812 _FONT (Control(__UI_HoveringID).Font)
2813 'IF NOT Control(__UI_HoveringID).Multiline THEN
2814 ' 'Single-line textbox
2815 ' TempNewCursor = ((__UI_MouseLeft - (Control(__UI_HoveringID).Left + Control(Control(__UI_HoveringID).ParentID).Left)) / _FONTWIDTH) + (Control(__UI_HoveringID).InputViewStart - 1)
2816 ' IF __UI_HoveringID = LastTextBoxClickID AND TIMER - LastTextBoxClick < .3 AND TempNewCursor = Control(__UI_HoveringID).Cursor THEN
2817 ' 'Double click in a textbox to select it all
2818 ' IF LEN(Text(__UI_HoveringID)) > 0 THEN
2819 ' Control(__UI_HoveringID).Cursor = LEN(Text(__UI_HoveringID))
2820 ' Control(__UI_HoveringID).SelectionStart = 0
2821 ' Control(__UI_HoveringID).TextIsSelected = True
2822 ' END IF
2823 ' ELSE
2824 ' Control(__UI_HoveringID).Cursor = TempNewCursor
2825 ' IF Control(__UI_HoveringID).Cursor > LEN(Text(__UI_HoveringID)) THEN Control(__UI_HoveringID).Cursor = LEN(Text(__UI_HoveringID))
2826 ' END IF
2827 ' LastTextBoxClick = TIMER
2828 ' LastTextBoxClickID = __UI_HoveringID
2829 'ELSE
2830 ' 'Multiline textbox
2831 'END IF
2832 END IF
2833 END IF
2834 CASE __UI_Type_ListBox
2835 IF Control(__UI_HoveringID).HasVScrollbar AND __UI_MouseLeft >= Control(__UI_HoveringID).Left + Control(__UI_HoveringID).Width - 25 + ContainerOffsetLeft THEN
2836 'Control has a vertical scrollbar and it's been clicked
2837 IF __UI_MouseTop >= Control(__UI_HoveringID).Top + ContainerOffsetTop AND NOT Control(__UI_HoveringID).Disabled AND __UI_MouseTop <= Control(__UI_HoveringID).Top + ContainerOffsetTop + __UI_ScrollbarButtonHeight THEN
2838 'Click on "up" button
2839 Control(__UI_HoveringID).InputViewStart = Control(__UI_HoveringID).InputViewStart - 1
2840 ELSEIF __UI_MouseTop >= Control(__UI_HoveringID).VScrollbarButton2Top + ContainerOffsetTop AND NOT Control(__UI_HoveringID).Disabled THEN
2841 'Click on "down" button
2842 IF Control(__UI_HoveringID).InputViewStart + Control(__UI_HoveringID).LastVisibleItem <= Control(__UI_HoveringID).Max THEN
2843 Control(__UI_HoveringID).InputViewStart = Control(__UI_HoveringID).InputViewStart + 1
2844 END IF
2845 END IF
2846 ELSE
2847 IF Control(__UI_HoveringID).Max > 0 THEN
2848 _FONT Control(__UI_HoveringID).Font
2849 ThisItem% = ((__UI_MouseTop - (ContainerOffsetTop + Control(__UI_HoveringID).Top) - (ABS(Control(__UI_HoveringID).HasBorder) * __UI_DefaultCaptionIndent)) \ Control(__UI_HoveringID).ItemHeight) + Control(__UI_HoveringID).InputViewStart
2850 IF ThisItem% >= Control(__UI_HoveringID).Min AND ThisItem% <= Control(__UI_HoveringID).Max THEN
2851 Control(__UI_HoveringID).Value = ThisItem%
2852 ELSE
2853 Control(__UI_HoveringID).Value = 0
2854 END IF
2855 END IF
2856
2857 IF __UI_HoveringID = __UI_ActiveDropdownList THEN
2858 __UI_Focus = __UI_ParentDropdownList
2859 Control(__UI_ParentDropdownList).Value = Control(__UI_ActiveDropdownList).Value
2860 IF Control(__UI_ParentDropdownList).PreviousValue <> Control(__UI_ParentDropdownList).Value THEN
2861 __UI_ValueChanged __UI_ParentDropdownList
2862 Control(__UI_ParentDropdownList).PreviousValue = Control(__UI_ParentDropdownList).Value
2863 Control(__UI_ParentDropdownList).Redraw = True
2864 END IF
2865 __UI_DestroyControl Control(__UI_ActiveDropdownList)
2866 ELSE
2867 IF Control(__UI_HoveringID).PreviousValue <> Control(__UI_HoveringID).Value THEN
2868 __UI_ValueChanged __UI_HoveringID
2869 Control(__UI_HoveringID).PreviousValue = Control(__UI_HoveringID).Value
2870 Control(__UI_HoveringID).Redraw = True
2871 END IF
2872 END IF
2873 END IF
2874 CASE __UI_Type_DropdownList
2875 IF __UI_ActiveDropdownList = 0 THEN
2876 __UI_ActivateDropdownlist Control(__UI_HoveringID)
2877 ELSE
2878 __UI_DestroyControl Control(__UI_ActiveDropdownList)
2879 END IF
2880 CASE __UI_Type_MenuBar
2881 IF __UI_TotalActiveMenus > 0 AND NOT __UI_JustOpenedMenu THEN
2882 __UI_Focus = __UI_PreviousFocus
2883 END IF
2884 CASE __UI_Type_MenuItem
2885 IF Control(__UI_HoveringID).SubMenu THEN
2886 __UI_ActivateMenu Control(__UI_HoveringID), False
2887 ELSE
2888 __UI_Focus = __UI_PreviousFocus
2889 __UI_DestroyControl Control(__UI_ActiveMenu(__UI_TotalActiveMenus))
2890 __UI_ForceRedraw = True
2891 IF Control(__UI_HoveringID).BulletStyle = __UI_Bullet THEN SetRadioButtonValue __UI_HoveringID
2892 END IF
2893 END SELECT
2894 __UI_LastMouseClick = TIMER
2895 __UI_JustOpenedMenu = False
2896 __UI_MouseDownOnID = 0
2897
2898 ProcessClick:
2899 IF RTRIM$(Control(Control(__UI_HoveringID).ParentID).Name) = "__UI_TextFieldMenu" OR RTRIM$(Control(Control(__UI_HoveringID).ParentID).Name) = "__UI_PreviewMenu" THEN
2900 'Internal context menus - Text field/Design mode options
2901 IF RTRIM$(Control(Control(__UI_HoveringID).ParentID).Name) = "__UI_TextFieldMenu" THEN
2902 __UI_Focus = __UI_PreviousFocus
2903 ELSEIF RTRIM$(Control(Control(__UI_HoveringID).ParentID).Name) = "__UI_PreviewMenu" THEN
2904 __UI_DestroyControl Control(__UI_ActiveMenu(__UI_TotalActiveMenus))
2905 END IF
2906
2907 ProcessHotkey:
2908 __UI_FillSelectedText 0, 0
2909 IF UCASE$(LEFT$(Control(__UI_HoveringID).Name, 16)) = "__UI_PREVIEWMENU" THEN __UI_KeyPress 216
2910 SELECT CASE UCASE$(RTRIM$(Control(__UI_HoveringID).Name))
2911 CASE "__UI_TEXTMENUCUT"
2912 IF LEN(__UI_SelectedText) > 0 THEN
2913 _CLIPBOARD$ = __UI_SelectedText
2914 __UI_DeleteSelection
2915 END IF
2916 CASE "__UI_TEXTMENUCOPY"
2917 IF LEN(__UI_SelectedText) > 0 THEN _CLIPBOARD$ = __UI_SelectedText
2918 CASE "__UI_TEXTMENUPASTE"
2919 DIM ContextMenuPaste AS _BYTE
2920 ContextMenuPaste = True
2921 GOSUB PasteIntoTextBox
2922 CASE "__UI_TEXTMENUDELETE"
2923 __UI_DeleteSelection
2924 CASE "__UI_TEXTMENUSELECT"
2925 IF LEN(Text(__UI_Focus)) > 0 THEN
2926 Control(__UI_Focus).Cursor = LEN(Text(__UI_Focus))
2927 Control(__UI_Focus).SelectionStart = 0
2928 Control(__UI_Focus).TextIsSelected = True
2929 END IF
2930 CASE "__UI_PREVIEWMENUALIGNLEFT"
2931 __UI_KeyPress 201
2932 CASE "__UI_PREVIEWMENUALIGNRIGHT"
2933 __UI_KeyPress 202
2934 CASE "__UI_PREVIEWMENUALIGNTOPS"
2935 __UI_KeyPress 203
2936 CASE "__UI_PREVIEWMENUALIGNBOTTOMS"
2937 __UI_KeyPress 204
2938 CASE "__UI_PREVIEWMENUALIGNCENTERSV"
2939 __UI_KeyPress 205
2940 CASE "__UI_PREVIEWMENUALIGNCENTERSH"
2941 __UI_KeyPress 206
2942 CASE "__UI_PREVIEWMENUALIGNCENTERV"
2943 __UI_KeyPress 207
2944 CASE "__UI_PREVIEWMENUALIGNCENTERH"
2945 __UI_KeyPress 208
2946 CASE "__UI_PREVIEWMENUDISTRIBUTEV"
2947 __UI_KeyPress 209
2948 CASE "__UI_PREVIEWMENUDISTRIBUTEH"
2949 __UI_KeyPress 210
2950 CASE "__UI_PREVIEWMENUIMAGEORIGINALSIZE"
2951 IF LEN(Text(__UI_FirstSelectedID)) THEN
2952 __UI_RestoreImageOriginalSize
2953 END IF
2954 CASE UCASE$("__UI_PreviewMenuNumericOnly")
2955 __UI_KeyPress 223
2956 CASE UCASE$("__UI_PreviewMenuSetDefaultButton")
2957 IF __UI_DefaultButtonID = __UI_FirstSelectedID THEN
2958 __UI_DefaultButtonID = 0
2959 ELSE
2960 __UI_DefaultButtonID = __UI_FirstSelectedID
2961 END IF
2962 CASE UCASE$("__UI_PreviewMenuNewMenuBar")
2963 __UI_KeyPress 224
2964 CASE UCASE$("__UI_PreviewMenuConvertType")
2965 __UI_KeyPress 225
2966 CASE UCASE$("__UI_PreviewMenuNewContextMenu")
2967 __UI_KeyPress 226
2968 CASE UCASE$("__UI_PreviewMenuShowInvisibleControls")
2969 __UI_KeyPress 227
2970 CASE UCASE$("__UI_PreviewMenuBindControls")
2971 __UI_KeyPress 228
2972 CASE "__UI_PREVIEWMENUCUT": GOTO ControlCut
2973 CASE "__UI_PREVIEWMENUCOPY": GOTO ControlCopy
2974 CASE "__UI_PREVIEWMENUPASTE": GOTO ControlPaste
2975 CASE "__UI_PREVIEWMENUDELETE": GOTO ControlDelete
2976 CASE "__UI_PREVIEWMENUSELECT": GOTO ControlSelect
2977 END SELECT
2978 __UI_KeyPress __UI_Focus
2979 ELSE
2980 __UI_Click __UI_HoveringID
2981 __UI_KeyHit = 0
2982 END IF
2983 ELSE
2984 __UI_CloseAllMenus
2985 __UI_Focus = __UI_PreviousFocus
2986 __UI_ForceRedraw = True
2987 END IF
2988 END IF
2989 __UI_IsSelectingText = False
2990 __UI_IsSelectingTextOnID = 0
2991 __UI_MouseIsDown = False
2992 __UI_MouseDownOnID = 0
2993 __UI_PreviousMouseDownOnID = 0
2994 __UI_SelectionRectangle = False
2995 END IF
2996 END IF
2997
2998 'Drag update
2999 IF __UI_IsDragging AND __UI_DraggingID = __UI_FormID THEN __UI_IsDragging = False
3000
3001 __UI_Snapped = False
3002 __UI_SnappedByProximityX = False
3003 __UI_SnappedByProximityY = False
3004 __UI_SnappedX = -1
3005 __UI_SnappedY = -1
3006
3007 DIM SetNewParent AS _BYTE, LeftOffset AS INTEGER, TopOffset AS INTEGER
3008 IF __UI_IsDragging AND __UI_DraggingID > 0 THEN
3009 IF Control(__UI_DraggingID).Type <> __UI_Type_Frame THEN
3010 IF Control(__UI_BelowHoveringID).Type = __UI_Type_Frame OR Control(__UI_HoveringID).Type = __UI_Type_Frame THEN
3011 IF Control(__UI_HoveringID).Type = __UI_Type_Frame THEN __UI_BelowHoveringID = __UI_HoveringID
3012 IF Control(__UI_FirstSelectedID).ParentID <> __UI_BelowHoveringID THEN
3013 SetNewParent = True
3014 LeftOffset = Control(__UI_BelowHoveringID).Left
3015 TopOffset = Control(__UI_BelowHoveringID).Top
3016 END IF
3017 ELSEIF Control(__UI_BelowHoveringID).Type = __UI_Type_Form OR __UI_BelowHoveringID = 0 THEN
3018 IF Control(__UI_FirstSelectedID).ParentID > 0 THEN
3019 LeftOffset = Control(Control(__UI_FirstSelectedID).ParentID).Left
3020 TopOffset = Control(Control(__UI_FirstSelectedID).ParentID).Top
3021 __UI_BelowHoveringID = 0
3022 SetNewParent = True
3023 END IF
3024 END IF
3025 END IF
3026
3027 FOR i = 1 TO UBOUND(Control)
3028 IF Control(i).ControlIsSelected THEN
3029 Control(i).Top = Control(i).Top + (__UI_MouseTop - __UI_DragY)
3030 Control(i).Left = Control(i).Left + (__UI_MouseLeft - __UI_DragX)
3031
3032 IF SetNewParent THEN
3033 Control(i).ParentID = __UI_BelowHoveringID
3034 Control(i).ParentName = Control(__UI_BelowHoveringID).Name
3035 IF __UI_BelowHoveringID = 0 THEN
3036 Control(i).Top = Control(i).Top + TopOffset
3037 Control(i).Left = Control(i).Left + LeftOffset
3038 ELSE
3039 Control(i).Top = Control(i).Top - TopOffset
3040 Control(i).Left = Control(i).Left - LeftOffset
3041 END IF
3042 END IF
3043 END IF
3044 NEXT
3045
3046 IF (_KEYDOWN(100305) = 0 AND _KEYDOWN(100306) = 0) AND __UI_SnapLines THEN
3047 'How far the mouse is from the currently being dragged control:
3048 DIM MouseXOffset AS INTEGER, MouseYOffset AS INTEGER
3049 'How distant from the neighboring snapped control's edge we are:
3050 DIM XSnapOffset AS INTEGER, YSnapOffset AS INTEGER
3051 'Last snap coordinates, for priority comparison:
3052 DIM PrevXSnapOffset AS INTEGER, PrevYSnapOffset AS INTEGER
3053
3054 'Look for a control nearby to which this one may be aligned automatically
3055 PrevXSnapOffset = 10
3056 PrevYSnapOffset = 10
3057
3058 MouseYOffset = ABS(__UI_MouseTop - (Control(__UI_DraggingID).Top + Control(Control(__UI_DraggingID).ParentID).Top + OriginalDragY))
3059 MouseXOffset = ABS(__UI_MouseLeft - (Control(__UI_DraggingID).Left + Control(Control(__UI_DraggingID).ParentID).Left + OriginalDragX))
3060
3061 'Snap to form borders first: -------------------------------
3062 IF Control(__UI_DraggingID).ParentID = 0 THEN
3063 'Right to left of form snap when close:
3064 XSnapOffset = Control(__UI_DraggingID).Left
3065 IF XSnapOffSet >= __UI_SnapDistanceFromForm / 2 AND XSnapOffset =< __UI_SnapDistanceFromForm AND MouseXOffset < 10 THEN
3066 Control(__UI_DraggingID).Left = __UI_SnapDistanceFromForm
3067 __UI_Snapped = True
3068 __UI_SnappedX = __UI_SnapDistanceFromForm
3069 __UI_SnappedByProximityX = 3
3070 END IF
3071
3072 'Left to right of form snap when close:
3073 XSnapOffset = ABS((Control(__UI_DraggingID).Left + Control(__UI_DraggingID).Width + __UI_SnapDistanceFromForm) - Control(__UI_FormID).Width)
3074 IF XSnapOffSet < __UI_SnapDistanceFromForm AND MouseXOffset < 10 THEN
3075 Control(__UI_DraggingID).Left = Control(__UI_FormID).Width - (Control(__UI_DraggingID).Width + __UI_SnapDistanceFromForm)
3076 __UI_Snapped = True
3077 __UI_SnappedX = Control(__UI_DraggingID).Left
3078 __UI_SnappedByProximityX = 4
3079 END IF
3080
3081 'Top to top of form snap when close:
3082 YSnapOffset = Control(__UI_DraggingID).Top
3083 IF YSnapOffSet >= __UI_SnapDistanceFromForm / 2 AND YSnapOffset =< __UI_SnapDistanceFromForm AND MouseYOffset < 10 THEN
3084 Control(__UI_DraggingID).Top = __UI_SnapDistanceFromForm
3085 __UI_Snapped = True
3086 __UI_SnappedY = __UI_SnapDistanceFromForm
3087 __UI_SnappedByProximityY = 3
3088 END IF
3089
3090 'Bottom to bottom of form snap when close:
3091 YSnapOffset = ABS((Control(__UI_DraggingID).Top + Control(__UI_DraggingID).Height + __UI_SnapDistanceFromForm) - Control(__UI_FormID).Height)
3092 IF YSnapOffSet < __UI_SnapDistanceFromForm AND MouseYOffset < 10 THEN
3093 Control(__UI_DraggingID).Top = Control(__UI_FormID).Height - (Control(__UI_DraggingID).Height + __UI_SnapDistanceFromForm)
3094 __UI_Snapped = True
3095 __UI_SnappedY = Control(__UI_DraggingID).Top
3096 __UI_SnappedByProximityY = 4
3097 END IF
3098
3099 'Middle of form:
3100 YSnapOffset = ABS(((Control(__UI_FormID).Height - __UI_MenuBarOffsetV) / 2 + __UI_MenuBarOffsetV) - (Control(__UI_DraggingID).Top + Control(__UI_DraggingID).Height / 2))
3101 IF YSnapOffset < 5 AND MouseYOffset < 10 THEN
3102 Control(__UI_DraggingID).Top = (Control(__UI_FormID).Height - __UI_MenuBarOffsetV) / 2 + __UI_MenuBarOffsetV - Control(__UI_DraggingID).Height / 2
3103 __UI_Snapped = True
3104 __UI_SnappedY = (Control(__UI_FormID).Height - __UI_MenuBarOffsetV) / 2 + __UI_MenuBarOffsetV
3105 END IF
3106
3107 'Center of form:
3108 XSnapOffset = ABS((Control(__UI_FormID).Width / 2) - (Control(__UI_DraggingID).Left + Control(__UI_DraggingID).Width / 2))
3109 IF XSnapOffset < 5 AND MouseXOffset < 10 THEN
3110 Control(__UI_DraggingID).Left = Control(__UI_FormID).Width / 2 - Control(__UI_DraggingID).Width / 2
3111 __UI_Snapped = True
3112 __UI_SnappedX = Control(__UI_FormID).Width / 2
3113 END IF
3114 END IF
3115
3116
3117 'Snap to other controls: -----------------------------------
3118 FOR i = 1 TO UBOUND(Control)
3119 IF Control(i).ParentID = Control(__UI_DraggingID).ParentID AND Control(i).Type > 0 AND _
3120 i <> __UI_DraggingID AND Control(i).Type <> __UI_Type_ContextMenu AND Control(i).Type <> __UI_Type_Form AND Control(i).Type <> __UI_Type_Font AND Control(i).Type <> __UI_Type_MenuItem AND Control(i).Type <> __UI_Type_MenuBar AND Control(i).Type <> __UI_Type_MenuPanel AND _
3121 Control(i).ControlIsSelected = False THEN
3122
3123 'Tops:
3124 YSnapOffset = ABS((Control(i).Top + Control(Control(i).ParentID).Top) - (Control(__UI_DraggingID).Top + Control(Control(__UI_DraggingID).ParentID).Top))
3125 IF YSnapOffset < 5 AND YSnapOffset < PrevYSnapOffset AND MouseYOffset < 10 THEN
3126 PrevYSnapOffset = YSnapOffset
3127 Control(__UI_DraggingID).Top = Control(i).Top + Control(Control(i).ParentID).Top
3128 __UI_Snapped = True
3129 __UI_SnappedY = Control(i).Top + Control(Control(i).ParentID).Top
3130 __UI_SnappedYID = i
3131 END IF
3132
3133 'Middles:
3134 YSnapOffset = ABS((Control(i).Top + Control(i).Height / 2 + Control(Control(i).ParentID).Top) - (Control(__UI_DraggingID).Top + Control(__UI_DraggingID).Height / 2 + Control(Control(__UI_DraggingID).ParentID).Top))
3135 IF YSnapOffset < 5 AND YSnapOffset < PrevYSnapOffset AND MouseYOffset < 10 THEN
3136 PrevYSnapOffset = YSnapOffset
3137 Control(__UI_DraggingID).Top = Control(i).Top + Control(i).Height / 2 - Control(__UI_DraggingID).Height / 2 + Control(Control(i).ParentID).Top
3138 __UI_Snapped = True
3139 __UI_SnappedY = Control(i).Top + Control(i).Height / 2 + Control(Control(i).ParentID).Top
3140 __UI_SnappedYID = i
3141 END IF
3142
3143 'Bases:
3144 YSnapOffset = ABS((Control(i).Top + Control(i).Height + Control(Control(i).ParentID).Top) - (Control(__UI_DraggingID).Top + Control(__UI_DraggingID).Height + Control(Control(__UI_DraggingID).ParentID).Top))
3145 IF YSnapOffset < 5 AND YSnapOffset < PrevYSnapOffset AND MouseYOffset < 10 THEN
3146 PrevYSnapOffset = YSnapOffset
3147 Control(__UI_DraggingID).Top = Control(i).Top + Control(i).Height - Control(__UI_DraggingID).Height + Control(Control(i).ParentID).Top
3148 __UI_Snapped = True
3149 __UI_SnappedY = Control(i).Top + Control(i).Height + Control(Control(i).ParentID).Top
3150 __UI_SnappedYID = i
3151 END IF
3152
3153 'Lefts:
3154 XSnapOffset = ABS((Control(i).Left + Control(Control(i).ParentID).Left) - (Control(__UI_DraggingID).Left + Control(Control(__UI_DraggingID).ParentID).Left))
3155 IF XSnapOffset < 5 AND XSnapOffset < PrevXSnapOffset AND MouseXOffset < 10 THEN
3156 PrevXSnapOffset = XSnapOffset
3157 Control(__UI_DraggingID).Left = Control(i).Left + Control(Control(i).ParentID).Left
3158 __UI_Snapped = True
3159 __UI_SnappedX = Control(i).Left + Control(Control(i).ParentID).Left
3160 __UI_SnappedXID = i
3161 END IF
3162
3163 'Centers:
3164 XSnapOffset = ABS((Control(i).Left + Control(i).Width / 2 + Control(Control(i).ParentID).Left) - (Control(__UI_DraggingID).Left + Control(__UI_DraggingID).Width / 2 + Control(Control(__UI_DraggingID).ParentID).Left))
3165 IF XSnapOffset < 5 AND XSnapOffset < PrevXSnapOffset AND MouseXOffset < 10 THEN
3166 PrevXSnapOffset = XSnapOffset
3167 Control(__UI_DraggingID).Left = Control(i).Left + Control(i).Width / 2 - Control(__UI_DraggingID).Width / 2 + Control(Control(i).ParentID).Left
3168 __UI_Snapped = True
3169 __UI_SnappedX = Control(i).Left + Control(i).Width / 2 + Control(Control(i).ParentID).Left
3170 __UI_SnappedXID = i
3171 END IF
3172
3173 'Rights:
3174 XSnapOffset = ABS((Control(i).Left + Control(i).Width + Control(Control(i).ParentID).Left) - (Control(__UI_DraggingID).Left + Control(__UI_DraggingID).Width + Control(Control(__UI_DraggingID).ParentID).Left))
3175 IF XSnapOffset < 5 AND XSnapOffset < PrevXSnapOffset AND MouseXOffset < 10 THEN
3176 PrevXSnapOffset = XSnapOffset
3177 Control(__UI_DraggingID).Left = Control(i).Left + Control(i).Width - Control(__UI_DraggingID).Width + Control(Control(i).ParentID).Left
3178 __UI_Snapped = True
3179 __UI_SnappedX = Control(i).Left + Control(i).Width + Control(Control(i).ParentID).Left
3180 __UI_SnappedXID = i
3181 END IF
3182
3183 'Right to left snap when close:
3184 XSnapOffset = ABS((Control(i).Left + Control(i).Width + Control(Control(i).ParentID).Left + __UI_SnapDistance) - (Control(__UI_DraggingID).Left + Control(Control(__UI_DraggingID).ParentID).Left))
3185 IF XSnapOffset < 5 AND XSnapOffset < PrevXSnapOffset AND MouseXOffset < 10 THEN
3186 IF (Control(__UI_DraggingID).Top <= Control(i).Top + Control(i).Height AND _
3187 Control(__UI_DraggingID).Top >= Control(i).Top) OR _
3188 (Control(__UI_DraggingID).Top + Control(__UI_DraggingID).Height >= Control(i).Top AND _
3189 Control(__UI_DraggingID).Top + Control(__UI_DraggingID).Height <= Control(i).Top + Control(i).Height) THEN
3190 PrevXSnapOffset = XSnapOffset
3191 Control(__UI_DraggingID).Left = Control(i).Left + Control(i).Width + Control(Control(i).ParentID).Left + __UI_SnapDistance
3192 __UI_Snapped = True
3193 __UI_SnappedX = Control(i).Left + Control(i).Width + Control(Control(i).ParentID).Left + __UI_SnapDistance
3194 __UI_SnappedXID = i
3195 __UI_SnappedByProximityX = 1
3196 END IF
3197 END IF
3198
3199 'Left to right snap when close:
3200 XSnapOffset = ABS((Control(i).Left - __UI_SnapDistance) - (Control(__UI_DraggingID).Left + Control(__UI_DraggingID).Width + Control(Control(__UI_DraggingID).ParentID).Left))
3201 IF XSnapOffset < 5 AND XSnapOffset < PrevXSnapOffset AND MouseXOffset < 10 THEN
3202 IF (Control(__UI_DraggingID).Top <= Control(i).Top + Control(i).Height AND _
3203 Control(__UI_DraggingID).Top >= Control(i).Top) OR _
3204 (Control(__UI_DraggingID).Top + Control(__UI_DraggingID).Height >= Control(i).Top AND _
3205 Control(__UI_DraggingID).Top + Control(__UI_DraggingID).Height <= Control(i).Top + Control(i).Height) THEN
3206 PrevXSnapOffset = XSnapOffset
3207 Control(__UI_DraggingID).Left = Control(i).Left - Control(__UI_DraggingID).Width - __UI_SnapDistance
3208 __UI_Snapped = True
3209 __UI_SnappedX = Control(i).Left - Control(__UI_DraggingID).Width - __UI_SnapDistance
3210 __UI_SnappedXID = i
3211 __UI_SnappedByProximityX = 2
3212 END IF
3213 END IF
3214
3215 'Bottom to top snap when close:
3216 YSnapOffset = ABS((Control(i).Top + Control(Control(i).ParentID).Top - __UI_SnapDistance) - (Control(__UI_DraggingID).Top + Control(__UI_DraggingID).Height + Control(Control(__UI_DraggingID).ParentID).Top))
3217 IF YSnapOffset < 5 AND YSnapOffset < PrevYSnapOffset AND MouseYOffset < 10 THEN
3218 IF (Control(__UI_DraggingID).Left <= Control(i).Left + Control(i).Width AND _
3219 Control(__UI_DraggingID).Left >= Control(i).Left) OR _
3220 (Control(__UI_DraggingID).Left + Control(__UI_DraggingID).Width >= Control(i).Left AND _
3221 Control(__UI_DraggingID).Left + Control(__UI_DraggingID).Width <= Control(i).Left + Control(i).Width) THEN
3222 PrevYSnapOffset = YSnapOffset
3223 Control(__UI_DraggingID).Top = Control(i).Top + Control(Control(i).ParentID).Top - Control(__UI_DraggingID).Height - __UI_SnapDistance
3224 __UI_Snapped = True
3225 __UI_SnappedY = Control(i).Top + Control(Control(i).ParentID).Top - Control(__UI_DraggingID).Height - __UI_SnapDistance
3226 __UI_SnappedYID = i
3227 __UI_SnappedByProximityY = 1
3228 END IF
3229 END IF
3230
3231 'Top to bottom snap when close:
3232 YSnapOffset = ABS((Control(i).Top + Control(i).Height + Control(Control(i).ParentID).Top + __UI_SnapDistance) - (Control(__UI_DraggingID).Top + Control(Control(__UI_DraggingID).ParentID).Top))
3233 IF YSnapOffset < 5 AND YSnapOffset < PrevYSnapOffset AND MouseYOffset < 10 THEN
3234 IF (Control(__UI_DraggingID).Left <= Control(i).Left + Control(i).Width AND _
3235 Control(__UI_DraggingID).Left >= Control(i).Left) OR _
3236 (Control(__UI_DraggingID).Left + Control(__UI_DraggingID).Width >= Control(i).Left AND _
3237 Control(__UI_DraggingID).Left + Control(__UI_DraggingID).Width <= Control(i).Left + Control(i).Width) THEN
3238 PrevYSnapOffset = YSnapOffset
3239 Control(__UI_DraggingID).Top = Control(i).Top + Control(Control(i).ParentID).Top + Control(i).Height + __UI_SnapDistance
3240 __UI_Snapped = True
3241 __UI_SnappedY = Control(i).Top + Control(Control(i).ParentID).Top + Control(i).Height + __UI_SnapDistance
3242 __UI_SnappedYID = i
3243 __UI_SnappedByProximityY = 2
3244 END IF
3245 END IF
3246 END IF
3247 NEXT
3248 END IF
3249
3250 IF (_KEYDOWN(100305) OR _KEYDOWN(100306)) THEN __UI_Snapped = False: __UI_SnappedX = -1: __UI_SnappedY=-1
3251
3252 IF __UI_SnappedX = -1 THEN Control(__UI_DraggingID).Left = __UI_MouseLeft - OriginalDragX
3253 IF __UI_SnappedY = -1 THEN Control(__UI_DraggingID).Top = __UI_MouseTop - OriginalDragY
3254
3255 Control(__UI_DraggingID).Left = Control(__UI_DraggingID).Left - Control(Control(__UI_DraggingID).ParentID).Left
3256 Control(__UI_DraggingID).Top = Control(__UI_DraggingID).Top - Control(Control(__UI_DraggingID).ParentID).Top
3257
3258 IF __UI_TotalSelectedControls > 1 THEN
3259 FOR i = 1 TO UBOUND(Control)
3260 IF Control(i).ControlIsSelected AND i <> __UI_DraggingID THEN
3261 Control(i).Left = Control(__UI_DraggingID).Left - Control(i).LeftOffsetFromFirstSelected
3262 Control(i).Top = Control(__UI_DraggingID).Top - Control(i).TopOffsetFromFirstSelected
3263 END IF
3264 NEXT
3265 END IF
3266
3267 __UI_DragY = __UI_MouseTop
3268 __UI_DragX = __UI_MouseLeft
3269 END IF
3270
3271 IF __UI_IsResizing AND __UI_ResizingID > 0 THEN
3272 __UI_ForceRedraw = True
3273 FOR i = 1 TO UBOUND(Control)
3274 IF Control(i).ControlIsSelected THEN
3275 'Right
3276 IF __UI_ResizeHandleHover = 1 THEN
3277 IF __UI_Type(Control(i).Type).RestrictResize = __UI_CantResizeH OR __UI_Type(Control(__UI_HoveringID).Type).RestrictResize = __UI_CantResize THEN _CONTINUE
3278 IF __UI_ShiftIsDown THEN
3279 Control(i).Width = Control(i).Width + (2 * (__UI_MouseLeft - __UI_DragX)): IF Control(i).Width < 4 THEN Control(i).Width = 4
3280 IF Control(i).Width > 4 THEN Control(i).Left = Control(i).Left - (__UI_MouseLeft - __UI_DragX)
3281 ELSE
3282 Control(i).Width = Control(i).Width + (__UI_MouseLeft - __UI_DragX): IF Control(i).Width < 4 THEN Control(i).Width = 4
3283 END IF
3284 END IF
3285 'Bottom
3286 IF __UI_ResizeHandleHover = 2 THEN
3287 IF __UI_Type(Control(i).Type).RestrictResize = __UI_CantResizeV OR __UI_Type(Control(__UI_HoveringID).Type).RestrictResize = __UI_CantResize THEN _CONTINUE
3288 IF __UI_ShiftIsDown THEN
3289 Control(i).Height = Control(i).Height + (2 * (__UI_MouseTop - __UI_DragY)): IF Control(i).Height < 4 THEN Control(i).Height = 4
3290 IF Control(i).Height > 4 THEN Control(i).Top = Control(i).Top - (__UI_MouseTop - __UI_DragY)
3291 ELSE
3292 Control(i).Height = Control(i).Height + (__UI_MouseTop - __UI_DragY): IF Control(i).Height < 4 THEN Control(i).Height = 4
3293 END IF
3294 END IF
3295 'Left
3296 IF __UI_ResizeHandleHover = 3 THEN
3297 IF __UI_Type(Control(i).Type).RestrictResize = __UI_CantResizeH OR __UI_Type(Control(__UI_HoveringID).Type).RestrictResize = __UI_CantResize THEN _CONTINUE
3298 IF __UI_ShiftIsDown THEN
3299 Control(i).Width = Control(i).Width - (2 * (__UI_MouseLeft - __UI_DragX)): IF Control(i).Width < 4 THEN Control(i).Width = 4
3300 IF Control(i).Width > 4 THEN Control(i).Left = Control(i).Left + (__UI_MouseLeft - __UI_DragX)
3301 ELSE
3302 Control(i).Width = Control(i).Width - (__UI_MouseLeft - __UI_DragX): IF Control(i).Width < 4 THEN Control(i).Width = 4 ELSE Control(i).Left = Control(i).Left + (__UI_MouseLeft - __UI_DragX)
3303 END IF
3304 END IF
3305 'Top
3306 IF __UI_ResizeHandleHover = 4 THEN
3307 IF __UI_Type(Control(i).Type).RestrictResize = __UI_CantResizeV OR __UI_Type(Control(__UI_HoveringID).Type).RestrictResize = __UI_CantResize THEN _CONTINUE
3308 IF __UI_ShiftIsDown THEN
3309 Control(i).Height = Control(i).Height - (2 * (__UI_MouseTop - __UI_DragY)): IF Control(i).Height < 4 THEN Control(i).Height = 4
3310 IF Control(i).Height > 4 THEN Control(i).Top = Control(i).Top + (__UI_MouseTop - __UI_DragY)
3311 ELSE
3312 Control(i).Height = Control(i).Height - (__UI_MouseTop - __UI_DragY): IF Control(i).Height < 4 THEN Control(i).Height = 4 ELSE Control(i).Top = Control(i).Top + (__UI_MouseTop - __UI_DragY)
3313 END IF
3314 END IF
3315 DIM OldAlignmentY AS INTEGER
3316 'Resizing by corners keeps original aspect ratio for PictureBox controls
3317 'Top-right
3318 IF __UI_ResizeHandleHover = 5 THEN
3319 IF __UI_ShiftIsDown THEN
3320 IF __UI_Type(Control(i).Type).RestrictResize <> __UI_CantResizeH AND __UI_Type(Control(__UI_HoveringID).Type).RestrictResize <> __UI_CantResize THEN
3321 Control(i).Width = Control(i).Width + (2 * (__UI_MouseLeft - __UI_DragX)): IF Control(i).Width < 4 THEN Control(i).Width = 4
3322 IF Control(i).Width > 4 THEN Control(i).Left = Control(i).Left - (__UI_MouseLeft - __UI_DragX)
3323 END IF
3324
3325 IF __UI_Type(Control(i).Type).RestrictResize = __UI_CantResizeV OR __UI_Type(Control(__UI_HoveringID).Type).RestrictResize = __UI_CantResize THEN _CONTINUE
3326 Control(i).Height = Control(i).Height - (2 * (__UI_MouseTop - __UI_DragY)): IF Control(i).Height < 4 THEN Control(i).Height = 4
3327 IF Control(i).Height > 4 THEN Control(i).Top = Control(i).Top + (__UI_MouseTop - __UI_DragY)
3328
3329 IF Control(i).Type = __UI_Type_PictureBox AND LEN(Text(i)) > 0 THEN
3330 OldAlignmentY = Control(i).Top + Control(i).Height / 2
3331 Control(i).Height = (_HEIGHT(Control(i).HelperCanvas) / _WIDTH(Control(i).HelperCanvas)) * Control(i).Width
3332 Control(i).Top = OldAlignmentY - Control(i).Height / 2
3333 END IF
3334 ELSE
3335 IF __UI_Type(Control(i).Type).RestrictResize <> __UI_CantResizeV AND __UI_Type(Control(__UI_HoveringID).Type).RestrictResize <> __UI_CantResize THEN
3336 Control(i).Height = Control(i).Height - (__UI_MouseTop - __UI_DragY): IF Control(i).Height < 4 THEN Control(i).Height = 4 ELSE Control(i).Top = Control(i).Top + (__UI_MouseTop - __UI_DragY)
3337 END IF
3338
3339 IF __UI_Type(Control(i).Type).RestrictResize = __UI_CantResizeH OR __UI_Type(Control(__UI_HoveringID).Type).RestrictResize = __UI_CantResize THEN _CONTINUE
3340 Control(i).Width = Control(i).Width + (__UI_MouseLeft - __UI_DragX): IF Control(i).Width < 4 THEN Control(i).Width = 4
3341
3342 IF Control(i).Type = __UI_Type_PictureBox AND LEN(Text(i)) > 0 THEN
3343 OldAlignmentY = Control(i).Top + Control(i).Height
3344 Control(i).Height = (_HEIGHT(Control(i).HelperCanvas) / _WIDTH(Control(i).HelperCanvas)) * Control(i).Width
3345 Control(i).Top = OldAlignmentY - Control(i).Height
3346 END IF
3347 END IF
3348 END IF
3349 'Top-left
3350 IF __UI_ResizeHandleHover = 6 THEN
3351 IF __UI_ShiftIsDown THEN
3352 IF __UI_Type(Control(i).Type).RestrictResize <> __UI_CantResizeH AND __UI_Type(Control(__UI_HoveringID).Type).RestrictResize <> __UI_CantResize THEN
3353 Control(i).Width = Control(i).Width - (2 * (__UI_MouseLeft - __UI_DragX)): IF Control(i).Width < 4 THEN Control(i).Width = 4
3354 IF Control(i).Width > 4 THEN Control(i).Left = Control(i).Left + (__UI_MouseLeft - __UI_DragX)
3355 END IF
3356
3357 IF __UI_Type(Control(i).Type).RestrictResize = __UI_CantResizeV OR __UI_Type(Control(__UI_HoveringID).Type).RestrictResize = __UI_CantResize THEN _CONTINUE
3358 Control(i).Height = Control(i).Height - (2 * (__UI_MouseTop - __UI_DragY)): IF Control(i).Height < 4 THEN Control(i).Height = 4
3359 IF Control(i).Height > 4 THEN Control(i).Top = Control(i).Top + (__UI_MouseTop - __UI_DragY)
3360
3361 IF Control(i).Type = __UI_Type_PictureBox AND LEN(Text(i)) > 0 THEN
3362 OldAlignmentY = Control(i).Top + Control(i).Height / 2
3363 Control(i).Height = (_HEIGHT(Control(i).HelperCanvas) / _WIDTH(Control(i).HelperCanvas)) * Control(i).Width
3364 Control(i).Top = OldAlignmentY - Control(i).Height / 2
3365 END IF
3366 ELSE
3367 IF __UI_Type(Control(i).Type).RestrictResize <> __UI_CantResizeV AND __UI_Type(Control(__UI_HoveringID).Type).RestrictResize <> __UI_CantResize THEN
3368 Control(i).Height = Control(i).Height - (__UI_MouseTop - __UI_DragY): IF Control(i).Height < 4 THEN Control(i).Height = 4 ELSE Control(i).Top = Control(i).Top + (__UI_MouseTop - __UI_DragY)
3369 END IF
3370
3371 IF __UI_Type(Control(i).Type).RestrictResize = __UI_CantResizeH OR __UI_Type(Control(__UI_HoveringID).Type).RestrictResize = __UI_CantResize THEN _CONTINUE
3372 Control(i).Width = Control(i).Width - (__UI_MouseLeft - __UI_DragX): IF Control(i).Width < 4 THEN Control(i).Width = 4 ELSE Control(i).Left = Control(i).Left + (__UI_MouseLeft - __UI_DragX)
3373
3374 IF Control(i).Type = __UI_Type_PictureBox AND LEN(Text(i)) > 0 THEN
3375 OldAlignmentY = Control(i).Top + Control(i).Height
3376 Control(i).Height = (_HEIGHT(Control(i).HelperCanvas) / _WIDTH(Control(i).HelperCanvas)) * Control(i).Width
3377 Control(i).Top = OldAlignmentY - Control(i).Height
3378 END IF
3379 END IF
3380 END IF
3381 'Bottom-right
3382 IF __UI_ResizeHandleHover = 7 THEN
3383 IF __UI_ShiftIsDown THEN
3384 IF __UI_Type(Control(i).Type).RestrictResize <> __UI_CantResizeH AND __UI_Type(Control(__UI_HoveringID).Type).RestrictResize <> __UI_CantResize THEN
3385 Control(i).Width = Control(i).Width + (2 * (__UI_MouseLeft - __UI_DragX)): IF Control(i).Width < 4 THEN Control(i).Width = 4
3386 IF Control(i).Width > 4 THEN Control(i).Left = Control(i).Left - (__UI_MouseLeft - __UI_DragX)
3387 END IF
3388
3389 IF __UI_Type(Control(i).Type).RestrictResize = __UI_CantResizeV OR __UI_Type(Control(__UI_HoveringID).Type).RestrictResize = __UI_CantResize THEN _CONTINUE
3390 Control(i).Height = Control(i).Height + (2 * (__UI_MouseTop - __UI_DragY)): IF Control(i).Height < 4 THEN Control(i).Height = 4
3391 IF Control(i).Height > 4 THEN Control(i).Top = Control(i).Top - (__UI_MouseTop - __UI_DragY)
3392
3393 IF Control(i).Type = __UI_Type_PictureBox AND LEN(Text(i)) > 0 THEN
3394 OldAlignmentY = Control(i).Top + Control(i).Height / 2
3395 Control(i).Height = (_HEIGHT(Control(i).HelperCanvas) / _WIDTH(Control(i).HelperCanvas)) * Control(i).Width
3396 Control(i).Top = OldAlignmentY - Control(i).Height / 2
3397 END IF
3398 ELSE
3399 IF __UI_Type(Control(i).Type).RestrictResize <> __UI_CantResizeV AND __UI_Type(Control(__UI_HoveringID).Type).RestrictResize <> __UI_CantResize THEN
3400 Control(i).Height = Control(i).Height + (__UI_MouseTop - __UI_DragY): IF Control(i).Height < 4 THEN Control(i).Height = 4
3401 END IF
3402
3403 IF __UI_Type(Control(i).Type).RestrictResize = __UI_CantResizeH OR __UI_Type(Control(__UI_HoveringID).Type).RestrictResize = __UI_CantResize THEN _CONTINUE
3404 Control(i).Width = Control(i).Width + (__UI_MouseLeft - __UI_DragX): IF Control(i).Width < 4 THEN Control(i).Width = 4
3405
3406 IF Control(i).Type = __UI_Type_PictureBox AND LEN(Text(i)) > 0 THEN
3407 Control(i).Height = (_HEIGHT(Control(i).HelperCanvas) / _WIDTH(Control(i).HelperCanvas)) * Control(i).Width
3408 END IF
3409 END IF
3410 END IF
3411 'Bottom-left
3412 IF __UI_ResizeHandleHover = 8 THEN
3413 IF __UI_ShiftIsDown THEN
3414 IF __UI_Type(Control(i).Type).RestrictResize <> __UI_CantResizeH AND __UI_Type(Control(__UI_HoveringID).Type).RestrictResize <> __UI_CantResize THEN
3415 Control(i).Width = Control(i).Width - (2 * (__UI_MouseLeft - __UI_DragX)): IF Control(i).Width < 4 THEN Control(i).Width = 4
3416 IF Control(i).Width > 4 THEN Control(i).Left = Control(i).Left + (__UI_MouseLeft - __UI_DragX)
3417 END IF
3418
3419 IF __UI_Type(Control(i).Type).RestrictResize = __UI_CantResizeV OR __UI_Type(Control(__UI_HoveringID).Type).RestrictResize = __UI_CantResize THEN _CONTINUE
3420 Control(i).Height = Control(i).Height + (2 * (__UI_MouseTop - __UI_DragY)): IF Control(i).Height < 4 THEN Control(i).Height = 4
3421 IF Control(i).Height > 4 THEN Control(i).Top = Control(i).Top - (__UI_MouseTop - __UI_DragY)
3422
3423 IF Control(i).Type = __UI_Type_PictureBox AND LEN(Text(i)) > 0 THEN
3424 OldAlignmentY = Control(i).Top + Control(i).Height / 2
3425 Control(i).Height = (_HEIGHT(Control(i).HelperCanvas) / _WIDTH(Control(i).HelperCanvas)) * Control(i).Width
3426 Control(i).Top = OldAlignmentY - Control(i).Height / 2
3427 END IF
3428 ELSE
3429 IF __UI_Type(Control(i).Type).RestrictResize <> __UI_CantResizeV AND __UI_Type(Control(__UI_HoveringID).Type).RestrictResize <> __UI_CantResize THEN
3430 Control(i).Height = Control(i).Height + (__UI_MouseTop - __UI_DragY): IF Control(i).Height < 4 THEN Control(i).Height = 4
3431 END IF
3432
3433 IF __UI_Type(Control(i).Type).RestrictResize = __UI_CantResizeH OR __UI_Type(Control(__UI_HoveringID).Type).RestrictResize = __UI_CantResize THEN _CONTINUE
3434 Control(i).Width = Control(i).Width - (__UI_MouseLeft - __UI_DragX): IF Control(i).Width < 4 THEN Control(i).Width = 4 ELSE Control(i).Left = Control(i).Left + (__UI_MouseLeft - __UI_DragX)
3435
3436 IF Control(i).Type = __UI_Type_PictureBox AND LEN(Text(i)) > 0 THEN
3437 Control(i).Height = (_HEIGHT(Control(i).HelperCanvas) / _WIDTH(Control(i).HelperCanvas)) * Control(i).Width
3438 END IF
3439 END IF
3440 END IF
3441 END IF
3442 NEXT
3443 __UI_DragY = __UI_MouseTop
3444 __UI_DragX = __UI_MouseLeft
3445 END IF
3446 IF __UI_DraggingThumb = True THEN
3447 IF Control(__UI_DraggingThumbOnID).Type = __UI_Type_ListBox THEN
3448 IF __UI_MouseTop >= Control(__UI_DraggingThumbOnID).Top + Control(Control(__UI_DraggingThumbOnID).ParentID).Top + __UI_ScrollbarButtonHeight AND __UI_MouseTop <= Control(__UI_DraggingThumbOnID).Top + Control(Control(__UI_DraggingThumbOnID).ParentID).Top + Control(__UI_DraggingThumbOnID).Height - __UI_ScrollbarButtonHeight THEN
3449 'Dragging in the track area
3450 Control(__UI_DraggingThumbOnID).InputViewStart = Control(__UI_DraggingThumbOnID).InputViewStart + ((__UI_MouseTop - __UI_ThumbDragTop) * Control(__UI_DraggingThumbOnID).VScrollbarRatio)
3451 IF Control(__UI_DraggingThumbOnID).InputViewStart + Control(__UI_DraggingThumbOnID).LastVisibleItem - 1 > Control(__UI_DraggingThumbOnID).Max THEN Control(__UI_DraggingThumbOnID).InputViewStart = Control(__UI_DraggingThumbOnID).Max - Control(__UI_DraggingThumbOnID).LastVisibleItem + 1
3452 __UI_ThumbDragTop = __UI_MouseTop
3453 ELSEIF __UI_MouseTop < Control(__UI_DraggingThumbOnID).Top + Control(Control(__UI_DraggingThumbOnID).ParentID).Top + __UI_ScrollbarButtonHeight THEN
3454 'Dragging above the track area
3455 Control(__UI_DraggingThumbOnID).InputViewStart = 1
3456 ELSEIF __UI_MouseTop > Control(__UI_DraggingThumbOnID).Top + Control(Control(__UI_DraggingThumbOnID).ParentID).Top + Control(__UI_DraggingThumbOnID).Height - __UI_ScrollbarButtonHeight THEN
3457 'Dragging below the track area
3458 Control(__UI_DraggingThumbOnID).InputViewStart = Control(__UI_DraggingThumbOnID).Max - Control(__UI_DraggingThumbOnID).LastVisibleItem + 1
3459 END IF
3460 ELSEIF Control(__UI_DraggingThumbOnID).Type = __UI_Type_TextBox THEN
3461 _FONT Control(__UI_DraggingThumbOnID).Font
3462 IF __UI_MouseTop >= Control(__UI_DraggingThumbOnID).Top + Control(Control(__UI_DraggingThumbOnID).ParentID).Top + __UI_ScrollbarButtonHeight AND __UI_MouseTop <= Control(__UI_DraggingThumbOnID).Top + Control(Control(__UI_DraggingThumbOnID).ParentID).Top + Control(__UI_DraggingThumbOnID).Height - __UI_ScrollbarButtonHeight THEN
3463 'Dragging in the track area
3464 Control(__UI_DraggingThumbOnID).FirstVisibleLine = Control(__UI_DraggingThumbOnID).FirstVisibleLine + ((__UI_MouseTop - __UI_ThumbDragTop) * Control(__UI_DraggingThumbOnID).VScrollbarRatio)
3465 __UI_ThumbDragTop = __UI_MouseTop
3466 ELSEIF __UI_MouseTop < Control(__UI_DraggingThumbOnID).Top + Control(Control(__UI_DraggingThumbOnID).ParentID).Top + __UI_ScrollbarButtonHeight THEN
3467 'Dragging above the track area
3468 Control(__UI_DraggingThumbOnID).FirstVisibleLine = 1
3469 ELSEIF __UI_MouseTop > Control(__UI_DraggingThumbOnID).Top + Control(Control(__UI_DraggingThumbOnID).ParentID).Top + Control(__UI_DraggingThumbOnID).Height - __UI_ScrollbarButtonHeight THEN
3470 'Dragging below the track area
3471 Control(__UI_DraggingThumbOnID).FirstVisibleLine = __UI_CountLines(__UI_DraggingThumbOnID) - Control(__UI_DraggingThumbOnID).Height \ uspacing&
3472 END IF
3473 END IF
3474 END IF
3475
3476 IF __UI_SelectionRectangle THEN
3477 DoSelectionRectangle:
3478 DIM tsmx AS INTEGER, tmx AS INTEGER
3479 DIM tsmy AS INTEGER, tmy AS INTEGER
3480 DIM parentOffsetX AS INTEGER, parentOffsetY AS INTEGER
3481 DIM selectingInFrame AS _BYTE, thisParent AS LONG
3482
3483 tsmx = __UI_SelectionRectangleLeft: tmx = __UI_MouseLeft
3484 tsmy = __UI_SelectionRectangleTop: tmy = __UI_MouseTop
3485 parentOffsetX = 0: parentOffsetY = 0
3486 selectingInFrame = False
3487
3488 IF tsmx > tmx THEN SWAP tsmx, tmx
3489 IF tsmy > tmy THEN SWAP tsmy, tmy
3490 'Check if the selection rectangle intersects with any control
3491 IF (_KEYDOWN(100303) OR _KEYDOWN(100304)) AND __UI_FirstSelectedID > 0 AND __UI_SelectionRectangle = False THEN
3492 IF Control(__UI_FirstSelectedID).ParentID = Control(__UI_HoveringID).ParentID THEN
3493 thisParent = Control(__UI_FirstSelectedID).ParentID
3494 parentOffsetX = Control(thisParent).Left
3495 parentOffsetY = Control(thisParent).Top
3496 selectingInFrame = True
3497 END IF
3498 END IF
3499 __UI_TotalSelectedControls = 0
3500 FOR i = 1 TO UBOUND(Control)
3501 Control(i).ControlIsSelected = False
3502 IF Control(i).Type <> __UI_Type_Form AND Control(i).Type <> __UI_Type_Font AND Control(i).Type <> __UI_Type_MenuBar AND Control(i).Type <> __UI_Type_MenuItem AND Control(i).Type <> __UI_Type_MenuPanel AND Control(i).Type <> __UI_Type_ContextMenu THEN
3503 IF selectingInFrame THEN
3504 IF Control(i).ParentID = thisParent THEN
3505 IF tsmx < Control(i).Left + Control(i).Width + Control(thisParent).Left AND _
3506 Control(i).Left + Control(thisParent).Left < tmx AND _
3507 tsmy < Control(i).Top + Control(i).Height + Control(thisParent).Top AND _
3508 Control(i).Top + Control(thisParent).Top < tmy THEN
3509 Control(i).ControlIsSelected = True
3510 __UI_TotalSelectedControls = __UI_TotalSelectedControls + 1
3511 IF __UI_TotalSelectedControls = 1 THEN __UI_FirstSelectedID = i
3512 END IF
3513 END IF
3514 ELSE
3515 IF Control(i).ParentID = 0 THEN
3516 IF tsmx < Control(i).Left + Control(i).Width AND _
3517 Control(i).Left < tmx AND _
3518 tsmy < Control(i).Top + Control(i).Height AND _
3519 Control(i).Top < tmy THEN
3520 Control(i).ControlIsSelected = True
3521 __UI_TotalSelectedControls = __UI_TotalSelectedControls + 1
3522 IF __UI_TotalSelectedControls = 1 THEN __UI_FirstSelectedID = i
3523 END IF
3524 END IF
3525 END IF
3526 END IF
3527 NEXT
3528 END IF
3529
3530 'Keyboard handler
3531 'Modifiers (Ctrl, Alt, Shift):
3532 IF __UI_KeyHit = 100303 OR __UI_KeyHit = 100304 THEN __UI_ShiftIsDown = True
3533 IF __UI_KeyHit = -100303 OR __UI_KeyHit = -100304 THEN __UI_ShiftIsDown = False
3534 IF __UI_KeyHit = 100305 OR __UI_KeyHit = 100306 THEN __UI_CtrlIsDown = True
3535 IF __UI_KeyHit = -100305 OR __UI_KeyHit = -100306 THEN __UI_CtrlIsDown = False
3536 IF __UI_KeyHit = 100307 OR __UI_KeyHit = 100308 THEN __UI_AltIsDown = True
3537 IF __UI_KeyHit = -100307 OR __UI_KeyHit = -100308 THEN __UI_AltIsDown = False
3538
3539 'Key combos can be associated with controls using the RegisterKeyCombo method;
3540 'Key combos take precedence over other keyboard events:
3541 DIM DoCombo AS _BYTE
3542 DoCombo = False
3543 IF __UI_BypassKeyCombos = False AND __UI_DesignMode = False AND __UI_AltIsDown = False AND __UI_KeyHit > 0 AND __UI_TotalActiveMenus = 0 THEN
3544 DIM ComboKey AS STRING
3545 DIM tempCombo$
3546
3547 FOR i = 1 TO __UI_TotalKeyCombos
3548 IF __UI_KeyCombo(i).ControlID <= 0 THEN _CONTINUE 'handled internally
3549
3550 ComboKey = ""
3551 tempCombo$ = RTRIM$(UCASE$(__UI_KeyCombo(i).Combo))
3552 FOR j = LEN(tempCombo$) TO 1 STEP -1
3553 IF MID$(tempCombo$, j, 1) = "+" THEN
3554 ComboKey = MID$(tempCombo$, j + 1)
3555 EXIT FOR
3556 END IF
3557 NEXT
3558
3559 IF ComboKey = "" THEN ComboKey = tempCombo$
3560
3561 IF (INSTR(tempCombo$, "SHIFT+") > 0) <> __UI_ShiftIsDown THEN _CONTINUE
3562 IF (INSTR(tempCombo$, "CTRL+") > 0) <> __UI_CtrlIsDown THEN _CONTINUE
3563
3564 IF LEFT$(ComboKey, 1) = "F" THEN
3565 IF VAL(MID$(ComboKey, 2)) >= 1 AND VAL(MID$(ComboKey, 2)) <= 12 THEN
3566 'Function key
3567 IF __UI_KeyHit = __UI_FKey(VAL(MID$(ComboKey, 2))) THEN
3568 DoCombo = True
3569 EXIT FOR
3570 END IF
3571 ELSE
3572 IF __UI_KeyHit = ASC("F") OR __UI_KeyHit = ASC("f") THEN
3573 'Combo match
3574 DoCombo = True
3575 EXIT FOR
3576 END IF
3577 END IF
3578 ELSE
3579 IF __UI_KeyHit = ASC(ComboKey) OR __UI_KeyHit = ASC(LCASE$(ComboKey)) THEN
3580 'Combo match
3581 DoCombo = True
3582 EXIT FOR
3583 END IF
3584 END IF
3585 NEXT
3586
3587 IF DoCombo THEN
3588 IF Control(__UI_KeyCombo(i).ControlID).Disabled = False AND Control(__UI_KeyCombo(i).ControlID).Hidden = False THEN
3589 IF Control(__UI_KeyCombo(i).ControlID).Type = __UI_Type_RadioButton THEN
3590 SetRadioButtonValue __UI_KeyCombo(i).ControlID
3591 ELSEIF Control(__UI_KeyCombo(i).ControlID).Type = __UI_Type_CheckBox OR Control(__UI_KeyCombo(i).ControlID).Type = __UI_Type_ToggleSwitch THEN
3592 Control(__UI_KeyCombo(i).ControlID).Value = NOT Control(__UI_KeyCombo(i).ControlID).Value
3593 __UI_ValueChanged __UI_KeyCombo(i).ControlID
3594 Control(__UI_KeyCombo(i).ControlID).LastChange = TIMER
3595 ELSEIF Control(__UI_KeyCombo(i).ControlID).Type = __UI_Type_MenuItem THEN
3596 IF Control(__UI_KeyCombo(i).ControlID).BulletStyle = __UI_Bullet THEN SetRadioButtonValue __UI_KeyCombo(i).ControlID
3597 END IF
3598 __UI_Click __UI_KeyCombo(i).ControlID
3599 END IF
3600 EXIT SUB
3601 END IF
3602 END IF
3603
3604 'Alt:
3605 IF NOT __UI_DesignMode THEN
3606 IF __UI_AltIsDown AND Control(__UI_Focus).Type = __UI_Type_MenuBar THEN
3607 __UI_Focus = __UI_PreviousFocus
3608 __UI_AltIsDown = False
3609 __UI_ForceRedraw = True 'Trigger a global redraw
3610 ELSEIF __UI_AltIsDown AND __UI_TotalActiveMenus > 0 THEN
3611 __UI_Focus = __UI_PreviousFocus
3612 __UI_CloseAllMenus
3613 __UI_ForceRedraw = True
3614 __UI_KeyHit = 0
3615 __UI_AltIsDown = False
3616 ELSEIF __UI_AltIsDown THEN
3617 IF NOT __UI_ShowHotKeys THEN
3618 __UI_ShowHotKeys = True
3619 __UI_ForceRedraw = True 'Trigger a global redraw
3620 END IF
3621
3622 SELECT CASE __UI_KeyHit
3623 CASE 48 TO 57, 65 TO 90, 97 TO 122 'Alphanumeric
3624 __UI_AltCombo$ = __UI_AltCombo$ + CHR$(__UI_KeyHit)
3625
3626 IF __UI_KeyHit >= 97 THEN __UI_KeyHit = __UI_KeyHit - 32 'Turn to capitals
3627
3628 IF __UI_KeyHit > 0 THEN
3629 'Search for a matching hot key in controls
3630 FOR i = 1 TO UBOUND(Control)
3631 IF Control(i).HotKey = __UI_KeyHit AND NOT Control(i).Disabled AND Control(i).Type <> __UI_Type_MenuItem THEN
3632 SELECT CASE Control(i).Type
3633 CASE __UI_Type_Button
3634 IF Control(i).CanHaveFocus THEN __UI_Focus = Control(i).ID
3635 __UI_Click Control(i).ID
3636 CASE __UI_Type_RadioButton
3637 IF Control(i).CanHaveFocus THEN __UI_Focus = Control(i).ID
3638 SetRadioButtonValue Control(i).ID
3639 __UI_Click Control(i).ID
3640 CASE __UI_Type_CheckBox
3641 IF Control(i).CanHaveFocus THEN __UI_Focus = Control(i).ID
3642 Control(i).Value = NOT Control(i).Value
3643 __UI_Click Control(i).ID
3644 __UI_ValueChanged Control(i).ID
3645 CASE __UI_Type_Frame
3646 'Find the first children in this frame that can have focus
3647 FOR j = i + 1 TO UBOUND(Control)
3648 IF Control(j).ParentID = Control(i).ID AND Control(j).CanHaveFocus AND NOT Control(j).Disabled THEN
3649 __UI_Focus = Control(j).ID
3650 EXIT FOR
3651 END IF
3652 NEXT
3653 CASE __UI_Type_Label
3654 'Find the next control in the same container that can have focus
3655 FOR j = i + 1 TO UBOUND(Control)
3656 IF Control(j).ParentID = Control(i).ParentID AND Control(j).CanHaveFocus AND NOT Control(j).Disabled THEN
3657 __UI_Focus = Control(j).ID
3658 EXIT FOR
3659 END IF
3660 NEXT
3661 CASE __UI_Type_MenuBar
3662 IF __UI_TotalActiveMenus = 0 THEN
3663 __UI_PreviousFocus = __UI_Focus
3664 __UI_ActivateMenu Control(i), True
3665 __UI_ForceRedraw = True
3666 Control(__UI_ActiveMenu(__UI_TotalActiveMenus)).Value = __UI_Focus
3667 __UI_KeyHit = 0
3668 __UI_AltIsDown = False
3669 END IF
3670 END SELECT
3671 EXIT FOR
3672 END IF
3673 NEXT
3674 END IF
3675 __UI_KeyHit = 0
3676 END SELECT
3677 ELSE
3678 IF __UI_ShowHotKeys THEN
3679 __UI_ShowHotKeys = False
3680 __UI_ForceRedraw = True 'Trigger a global redraw
3681
3682 IF LEN(__UI_AltCombo$) THEN
3683 'Numeric keypresses with alt pressed are converted into the proper ASCII character
3684 'and inserted into the active textbox, if any.
3685 IF VAL(__UI_AltCombo$) >= 32 AND VAL(__UI_AltCombo$) <= 254 THEN
3686 __UI_KeyHit = VAL(__UI_AltCombo$)
3687 END IF
3688 __UI_AltCombo$ = ""
3689 ELSE
3690 'Alt was released with no key having been pressed in the meantime,
3691 'so the menubar will be activated, if it exists (unless a dropdown
3692 'list was activated
3693 IF __UI_HasMenuBar AND __UI_ActiveDropdownList = 0 THEN
3694 __UI_PreviousFocus = __UI_Focus
3695 __UI_Focus = __UI_FirstMenuBarControl
3696 END IF
3697 END IF
3698 END IF
3699 END IF
3700 END IF
3701
3702 'Control-specific keyboard handler:
3703 IF __UI_DesignMode THEN
3704 IF __UI_KeyHit = 27 THEN
3705 FOR i = 1 TO UBOUND(Control)
3706 Control(i).ControlIsSelected = False
3707 NEXT
3708 __UI_TotalSelectedControls = 0
3709 __UI_FirstSelectedID = 0
3710 END IF
3711 END IF
3712
3713 IF __UI_Focus > 0 AND __UI_KeyHit <> 0 AND __UI_DesignMode = False THEN
3714 __UI_KeyPress __UI_Focus
3715 __UI_KeyboardFocus = True
3716
3717 'Enter activates the selected/default button, if any
3718 IF __UI_IsDragging = False AND __UI_KeyHit = -13 AND NOT Control(__UI_Focus).Disabled THEN
3719 IF Control(__UI_Focus).Type = __UI_Type_Button OR Control(__UI_Focus).Type = __UI_Type_MenuItem THEN
3720 i = __UI_Focus
3721 IF Control(__UI_Focus).Type = __UI_Type_MenuItem THEN
3722 IF Control(__UI_Focus).SubMenu THEN
3723 __UI_ActivateMenu Control(__UI_Focus), True
3724 ELSE
3725 __UI_Focus = __UI_PreviousFocus
3726 __UI_CloseAllMenus
3727 __UI_ForceRedraw = True
3728 __UI_KeyHit = 0
3729 END IF
3730 END IF
3731 __UI_HoveringID = i
3732 GOTO ProcessClick
3733 ELSEIF Control(__UI_Focus).Type = __UI_Type_ListBox AND __UI_Focus = __UI_ActiveDropdownList THEN
3734 __UI_Focus = __UI_ParentDropdownList
3735 Control(__UI_ParentDropdownList).Value = Control(__UI_ActiveDropdownList).Value
3736 __UI_DestroyControl Control(__UI_ActiveDropdownList)
3737 IF Control(__UI_Focus).PreviousValue <> Control(__UI_Focus).Value THEN
3738 __UI_ValueChanged __UI_Focus
3739 Control(__UI_Focus).PreviousValue = Control(__UI_Focus).Value
3740 Control(__UI_Focus).Redraw = True
3741 END IF
3742 ELSEIF Control(__UI_Focus).Type = __UI_Type_MenuBar THEN
3743 __UI_ActivateMenu Control(__UI_Focus), True
3744 ELSEIF Control(__UI_Focus).Type = __UI_Type_TextBox AND Control(__UI_Focus).Multiline THEN
3745 'Do nothing. Enter will add a new line to a multiline textbox (below).
3746 ELSEIF __UI_Focus <> __UI_DefaultButtonID AND __UI_DefaultButtonID > 0 THEN
3747 __UI_Click __UI_DefaultButtonID
3748 END IF
3749 ELSE
3750 SELECT CASE Control(__UI_Focus).Type
3751 CASE __UI_Type_TrackBar
3752 SELECT CASE __UI_KeyHit
3753 CASE 19200 'Left
3754 IF Control(__UI_Focus).Value > Control(__UI_Focus).Min THEN
3755 IF __UI_CtrlIsDown THEN
3756 IF Control(__UI_Focus).MinInterval > 0 AND Control(__UI_Focus).MinInterval < Control(__UI_Focus).Interval THEN
3757 Control(__UI_Focus).Value = Control(__UI_Focus).Value - Control(__UI_Focus).MinInterval
3758 ELSE
3759 Control(__UI_Focus).Value = Control(__UI_Focus).Value - Control(__UI_Focus).Interval
3760 END IF
3761 ELSE
3762 Control(__UI_Focus).Value = Control(__UI_Focus).Value - Control(__UI_Focus).Interval
3763 END IF
3764 IF Control(__UI_Focus).Value < Control(__UI_Focus).Min THEN _
3765 Control(__UI_Focus).Value = Control(__UI_Focus).Min
3766 'IF Control(__UI_Focus).PreviousValue <> Control(__UI_Focus).Value THEN __UI_ValueChanged __UI_Focus
3767 END IF
3768 CASE 19712 'Right
3769 IF Control(__UI_Focus).Value < Control(__UI_Focus).Max THEN
3770 IF __UI_CtrlIsDown THEN
3771 Control(__UI_Focus).Value = Control(__UI_Focus).Value + Control(__UI_Focus).MinInterval
3772 ELSE
3773 Control(__UI_Focus).Value = Control(__UI_Focus).Value + Control(__UI_Focus).Interval
3774 END IF
3775 IF Control(__UI_Focus).Value > Control(__UI_Focus).Max THEN _
3776 Control(__UI_Focus).Value = Control(__UI_Focus).Max
3777 'IF Control(__UI_Focus).PreviousValue <> Control(__UI_Focus).Value THEN __UI_ValueChanged __UI_Focus
3778 END IF
3779 CASE 18176 'Home
3780 Control(__UI_Focus).Value = Control(__UI_Focus).Min
3781 'IF Control(__UI_Focus).PreviousValue <> Control(__UI_Focus).Value THEN __UI_ValueChanged __UI_Focus
3782 CASE 20224 'End
3783 Control(__UI_Focus).Value = Control(__UI_Focus).Max
3784 'IF Control(__UI_Focus).PreviousValue <> Control(__UI_Focus).Value THEN __UI_ValueChanged __UI_Focus
3785 END SELECT
3786 CASE __UI_Type_MenuBar
3787 SELECT CASE __UI_KeyHit
3788 CASE 48 TO 57, 65 TO 90, 97 TO 122 'Alphanumeric
3789 IF __UI_KeyHit >= 97 THEN __UI_KeyHit = __UI_KeyHit - 32 'Turn to capitals
3790 'Search for a matching hot key in menu bar items
3791 IF __UI_CtrlIsDown = False THEN
3792 FOR i = 1 TO UBOUND(Control)
3793 IF Control(i).HotKey = __UI_KeyHit AND NOT Control(i).Disabled AND Control(i).Type = __UI_Type_MenuBar THEN
3794 IF __UI_TotalActiveMenus = 0 THEN
3795 __UI_ActivateMenu Control(i), True
3796 Control(__UI_ActiveMenu(__UI_TotalActiveMenus)).Value = __UI_Focus
3797 __UI_ForceRedraw = True
3798 __UI_KeyHit = 0
3799 END IF
3800 EXIT FOR
3801 END IF
3802 NEXT
3803 END IF
3804 CASE 27 'Esc
3805 __UI_Focus = __UI_PreviousFocus
3806 __UI_KeyHit = 0
3807 CASE 19200 'Left
3808 __UI_Focus = __UI_PreviousMenuBarControl(__UI_Focus)
3809 CASE 19712 'Right
3810 __UI_Focus = __UI_NextMenuBarControl(__UI_Focus)
3811 CASE 18432, 20480 'Up, down
3812 __UI_ActivateMenu Control(__UI_Focus), True
3813 __UI_KeyHit = 0
3814 END SELECT
3815 CASE __UI_Type_MenuPanel, __UI_Type_MenuItem
3816 HandleDesignMenu:
3817 SELECT CASE __UI_KeyHit
3818 CASE 48 TO 57, 65 TO 90, 97 TO 122 'Alphanumeric
3819 IF __UI_CtrlIsDown = False THEN
3820 IF __UI_KeyHit >= 97 THEN __UI_KeyHit = __UI_KeyHit - 32 'Turn to capitals
3821 'Search for a matching hot key in menu bar items
3822 FOR i = 1 TO UBOUND(Control)
3823 IF Control(i).HotKey = __UI_KeyHit AND NOT Control(i).Disabled AND Control(i).Type = __UI_Type_MenuItem AND Control(i).ParentID = __UI_ParentMenu(__UI_TotalActiveMenus) THEN
3824 IF LEFT$(Control(i).Name, 5) = "__UI_" THEN
3825 __UI_HoveringID = i
3826 GOTO ProcessHotkey
3827 ELSE
3828 IF Control(i).SubMenu THEN
3829 __UI_KeyHit = 0
3830 __UI_Focus = Control(i).ID
3831 __UI_ForceRedraw = True
3832 _DELAY .1
3833 __UI_ActivateMenu Control(i), True
3834 ELSE
3835 __UI_Focus = __UI_PreviousFocus
3836 __UI_CloseAllMenus
3837 __UI_ForceRedraw = True
3838 __UI_KeyHit = 0
3839 __UI_Click i
3840 END IF
3841 END IF
3842 EXIT FOR
3843 END IF
3844 NEXT
3845 END IF
3846 CASE 27 'Esc
3847 IF __UI_TotalActiveMenus > 1 THEN
3848 __UI_Focus = __UI_ParentMenu(__UI_TotalActiveMenus)
3849 __UI_DestroyControl Control(__UI_ActiveMenu(__UI_TotalActiveMenus))
3850 ELSEIF __UI_TotalActiveMenus = 1 THEN
3851 __UI_Focus = __UI_ParentMenu(__UI_TotalActiveMenus)
3852 __UI_CloseAllMenus
3853 ELSEIF __UI_TotalActiveMenus > 0 AND __UI_ActiveMenuIsContextMenu THEN
3854 __UI_CloseAllMenus
3855 __UI_Focus = __UI_PreviousFocus
3856 END IF
3857 __UI_KeyHit = 0
3858 CASE 19200 'Left
3859 IF __UI_TotalActiveMenus > 1 THEN
3860 'close sub-menu
3861 __UI_Focus = __UI_ParentMenu(__UI_TotalActiveMenus)
3862 __UI_DestroyControl Control(__UI_ActiveMenu(__UI_TotalActiveMenus))
3863 ELSEIF __UI_TotalActiveMenus = 1 THEN
3864 IF __UI_ActiveMenuIsContextMenu = False THEN
3865 'activate left neighbor menubar item
3866 __UI_CloseAllMenus
3867 __UI_ActivateMenu Control(__UI_PreviousMenuBarControl(__UI_TopMenuBarItem)), True
3868 __UI_ForceRedraw = True
3869 END IF
3870 END IF
3871 __UI_KeyHit = 0
3872 CASE 19712 'Right
3873 IF Control(__UI_Focus).SubMenu THEN
3874 __UI_ActivateMenu Control(__UI_Focus), True
3875 ELSE
3876 IF __UI_ActiveMenuIsContextMenu = False THEN
3877 __UI_CloseAllMenus
3878 __UI_ActivateMenu Control(__UI_NextMenuBarControl(__UI_TopMenuBarItem)), True
3879 __UI_ForceRedraw = True
3880 END IF
3881 END IF
3882 __UI_KeyHit = 0
3883 CASE 18432 'Up
3884 __UI_Focus = __UI_PreviousMenuItem(__UI_Focus)
3885 Control(__UI_ActiveMenu(__UI_TotalActiveMenus)).Value = Control(__UI_Focus).ID
3886 CASE 20480 'Down
3887 __UI_Focus = __UI_NextMenuItem(__UI_Focus)
3888 Control(__UI_ActiveMenu(__UI_TotalActiveMenus)).Value = Control(__UI_Focus).ID
3889 END SELECT
3890 CASE __UI_Type_Button, __UI_Type_RadioButton, __UI_Type_CheckBox, __UI_Type_ToggleSwitch
3891 SELECT CASE __UI_KeyHit
3892 CASE 32
3893 'Emulate mouse down/click
3894 IF __UI_IsDragging = False AND NOT Control(__UI_Focus).Disabled THEN
3895 'Space bar down on a button
3896 IF __UI_KeyIsDown = False AND __UI_KeyDownOnID = 0 THEN
3897 __UI_KeyDownOnID = __UI_Focus
3898 __UI_KeyIsDown = True
3899 END IF
3900 END IF
3901 CASE -32
3902 IF __UI_IsDragging = False AND NOT Control(__UI_Focus).Disabled THEN
3903 'Space bar released and a button has focus
3904 IF __UI_KeyIsDown AND __UI_Focus = __UI_KeyDownOnID THEN
3905 IF Control(__UI_KeyDownOnID).Type = __UI_Type_RadioButton THEN
3906 SetRadioButtonValue __UI_KeyDownOnID
3907 ELSEIF Control(__UI_KeyDownOnID).Type = __UI_Type_CheckBox OR _
3908 Control(__UI_KeyDownOnID).Type = __UI_Type_ToggleSwitch THEN
3909 Control(__UI_KeyDownOnID).Value = NOT Control(__UI_KeyDownOnID).Value
3910 __UI_ValueChanged __UI_KeyDownOnID
3911 Control(__UI_KeyDownOnID).LastChange = TIMER
3912 END IF
3913 __UI_KeyDownOnID = 0
3914 __UI_KeyIsDown = False
3915 __UI_Click __UI_Focus
3916 END IF
3917 END IF
3918 CASE 18432, 20480 'Up, down
3919 IF (Control(__UI_Focus).Type = __UI_Type_RadioButton OR Control(__UI_Focus).Type = __UI_Type_CheckBox) THEN
3920 __UI_FocusSearch = __UI_Focus
3921 DO
3922 IF _KEYDOWN(100304) OR _KEYDOWN(100303) THEN
3923 __UI_FocusSearch = (__UI_FocusSearch + UBOUND(Control) - 2) MOD UBOUND(Control) + 1
3924 ELSE
3925 __UI_FocusSearch = __UI_FocusSearch MOD UBOUND(Control) + 1
3926 END IF
3927
3928 IF __UI_FocusSearch = __UI_Focus THEN
3929 'Full circle. No similar control can have focus
3930 EXIT DO
3931 END IF
3932
3933 IF Control(__UI_FocusSearch).CanHaveFocus AND NOT Control(__UI_FocusSearch).Disabled AND Control(__UI_Focus).Type = Control(__UI_FocusSearch).Type THEN
3934 __UI_KeepFocus = False: __UI_FocusOut __UI_Focus
3935 IF __UI_KeepFocus = False THEN
3936 __UI_Focus = __UI_FocusSearch
3937 __UI_FocusIn __UI_Focus
3938 IF Control(__UI_FocusSearch).Type = __UI_Type_RadioButton THEN SetRadioButtonValue __UI_Focus
3939 END IF
3940 EXIT DO
3941 END IF
3942 LOOP
3943 END IF
3944 END SELECT
3945 CASE __UI_Type_ListBox, __UI_Type_DropdownList
3946 IF NOT Control(__UI_Focus).Disabled AND Control(__UI_Focus).Max > 0 THEN
3947 _FONT (Control(__UI_Focus).Font)
3948 SELECT EVERYCASE __UI_KeyHit
3949 CASE 32 TO 254 'Printable ASCII characters
3950 DIM CurrentItem%
3951 CurrentItem% = Control(__UI_Focus).Value
3952 __UI_ListBoxSearchItem Control(__UI_Focus)
3953 IF CurrentItem% <> Control(__UI_Focus).Value THEN
3954 'Adjust view:
3955 IF Control(__UI_Focus).Value < Control(__UI_Focus).InputViewStart THEN
3956 Control(__UI_Focus).InputViewStart = Control(__UI_Focus).Value
3957 ELSEIF Control(__UI_Focus).Value > Control(__UI_Focus).InputViewStart + Control(__UI_Focus).LastVisibleItem - 1 THEN
3958 Control(__UI_Focus).InputViewStart = Control(__UI_Focus).Value - Control(__UI_Focus).LastVisibleItem + 1
3959 END IF
3960 END IF
3961 CASE 18432 'Up
3962 IF Control(__UI_Focus).Value > 1 THEN
3963 Control(__UI_Focus).Value = Control(__UI_Focus).Value - 1
3964 IF Control(__UI_Focus).PreviousValue <> Control(__UI_Focus).Value THEN
3965 __UI_ValueChanged __UI_Focus
3966 Control(__UI_Focus).PreviousValue = Control(__UI_Focus).Value
3967 Control(__UI_Focus).Redraw = True
3968 END IF
3969 END IF
3970 CASE 20480 'Down
3971 IF __UI_AltIsDown THEN
3972 IF Control(__UI_Focus).Type = __UI_Type_DropdownList THEN
3973 __UI_ActivateDropdownlist Control(__UI_Focus)
3974 END IF
3975 ELSE
3976 IF Control(__UI_Focus).Value < Control(__UI_Focus).Max THEN
3977 Control(__UI_Focus).Value = Control(__UI_Focus).Value + 1
3978 IF Control(__UI_Focus).PreviousValue <> Control(__UI_Focus).Value THEN
3979 __UI_ValueChanged __UI_Focus
3980 Control(__UI_Focus).PreviousValue = Control(__UI_Focus).Value
3981 Control(__UI_Focus).Redraw = True
3982 END IF
3983 END IF
3984 END IF
3985 CASE 18688 'Page up
3986 Control(__UI_Focus).Value = Control(__UI_Focus).Value - Control(__UI_Focus).LastVisibleItem
3987 IF Control(__UI_Focus).Value < 1 THEN Control(__UI_Focus).Value = 1
3988 IF Control(__UI_Focus).PreviousValue <> Control(__UI_Focus).Value THEN
3989 __UI_ValueChanged __UI_Focus
3990 Control(__UI_Focus).PreviousValue = Control(__UI_Focus).Value
3991 Control(__UI_Focus).Redraw = True
3992 END IF
3993 CASE 20736 'Page down
3994 IF Control(__UI_Focus).Value < Control(__UI_Focus).Max - Control(__UI_Focus).LastVisibleItem THEN
3995 Control(__UI_Focus).Value = Control(__UI_Focus).Value + Control(__UI_Focus).LastVisibleItem - 1
3996 ELSE
3997 Control(__UI_Focus).Value = Control(__UI_Focus).Max
3998 END IF
3999 IF Control(__UI_Focus).PreviousValue <> Control(__UI_Focus).Value THEN
4000 __UI_ValueChanged __UI_Focus
4001 Control(__UI_Focus).PreviousValue = Control(__UI_Focus).Value
4002 Control(__UI_Focus).Redraw = True
4003 END IF
4004 CASE 18176 'Home
4005 Control(__UI_Focus).Value = 1
4006 IF Control(__UI_Focus).PreviousValue <> Control(__UI_Focus).Value THEN
4007 __UI_ValueChanged __UI_Focus
4008 Control(__UI_Focus).PreviousValue = Control(__UI_Focus).Value
4009 Control(__UI_Focus).Redraw = True
4010 END IF
4011 CASE 20224 'End
4012 Control(__UI_Focus).Value = Control(__UI_Focus).Max
4013 IF Control(__UI_Focus).PreviousValue <> Control(__UI_Focus).Value THEN
4014 __UI_ValueChanged __UI_Focus
4015 Control(__UI_Focus).PreviousValue = Control(__UI_Focus).Value
4016 Control(__UI_Focus).Redraw = True
4017 END IF
4018 CASE 18432, 20480, 18688, 20736, 18176, 20224
4019 'Adjust view:
4020 IF Control(__UI_Focus).Value < Control(__UI_Focus).InputViewStart THEN
4021 Control(__UI_Focus).InputViewStart = Control(__UI_Focus).Value
4022 ELSEIF Control(__UI_Focus).Value > Control(__UI_Focus).InputViewStart + Control(__UI_Focus).LastVisibleItem - 1 THEN
4023 Control(__UI_Focus).InputViewStart = Control(__UI_Focus).Value - Control(__UI_Focus).LastVisibleItem + 1
4024 END IF
4025 END SELECT
4026 END IF
4027 CASE __UI_Type_TextBox
4028 DIM Clip$, FindLF&
4029 DIM s1 AS LONG, s2 AS LONG
4030 IF NOT Control(__UI_Focus).Disabled THEN
4031 SELECT EVERYCASE __UI_KeyHit
4032 CASE 32 TO 254 'Printable ASCII characters
4033 IF __UI_KeyHit = ASC("v") OR __UI_KeyHit = ASC("V") THEN 'Paste from clipboard (Ctrl+V)
4034 IF __UI_CtrlIsDown THEN
4035 PasteIntoTextBox:
4036 IF Control(__UI_Focus).Multiline THEN
4037 Clip$ = Replace(_CLIPBOARD$, CHR$(13) + CHR$(10), CHR$(10), False, 0)
4038 IF LEN(Clip$) > 0 THEN
4039 IF NOT Control(__UI_Focus).TextIsSelected THEN
4040 IF Control(__UI_Focus).Cursor = LEN(Text(__UI_Focus)) THEN
4041 Text(__UI_Focus) = Text(__UI_Focus) + Clip$
4042 Control(__UI_Focus).Cursor = LEN(Text(__UI_Focus))
4043 ELSE
4044 Text(__UI_Focus) = LEFT$(Text(__UI_Focus), Control(__UI_Focus).Cursor) + Clip$ + MID$(Text(__UI_Focus), Control(__UI_Focus).Cursor + 1)
4045 Control(__UI_Focus).Cursor = Control(__UI_Focus).Cursor + LEN(Clip$)
4046 END IF
4047 ELSE
4048 's1 = Control(__UI_Focus).SelectionStart
4049 's2 = Control(__UI_Focus).Cursor
4050 'IF s1 > s2 THEN SWAP s1, s2
4051 'Text(__UI_Focus) = LEFT$(Text(__UI_Focus), s1) + Clip$ + MID$(Text(__UI_Focus), s2 + 1)
4052 'Control(__UI_Focus).Cursor = s1 + LEN(Clip$)
4053 'Control(__UI_Focus).TextIsSelected = False
4054 '__UI_SelectedText = ""
4055 '__UI_SelectionLength = 0
4056 END IF
4057 __UI_TextChanged __UI_Focus
4058 IF Control(__UI_Focus).NumericOnly THEN
4059 Control(__UI_Focus).Value = VAL(Text(__UI_Focus))
4060
4061 __UI_ValidateBounds __UI_Focus
4062 END IF
4063 END IF
4064 IF ContextMenuPaste THEN
4065 ContextMenuPaste = False
4066 RETURN
4067 END IF
4068 __UI_KeyHit = 0
4069 ELSE
4070 Clip$ = _CLIPBOARD$
4071 FindLF& = INSTR(Clip$, CHR$(13))
4072 IF FindLF& > 0 THEN Clip$ = LEFT$(Clip$, FindLF& - 1)
4073 FindLF& = INSTR(Clip$, CHR$(10))
4074 IF FindLF& > 0 THEN Clip$ = LEFT$(Clip$, FindLF& - 1)
4075 IF LEN(Clip$) > 0 THEN
4076 IF LEN(Mask(__UI_Focus)) > 0 THEN
4077 'Paste only numbers and only up until the limit of
4078 'numeric placeholders:
4079 DIM NumericClip$
4080 NumericClip$ = ""
4081 FOR i = 1 TO LEN(Clip$)
4082 IF ASC(Clip$, i) >= 48 AND ASC(Clip$, i) <= 57 THEN
4083 NumericClip$ = NumericClip$ + CHR$(ASC(Clip$, i))
4084 END IF
4085 NEXT
4086 IF LEN(NumericClip$) THEN
4087 Text(__UI_Focus) = ""
4088 FOR i = 1 TO LEN(Mask(__UI_Focus))
4089 SELECT CASE MID$(Mask(__UI_Focus), i, 1)
4090 CASE "0", "9", "#"
4091 IF LEN(NumericClip$) THEN
4092 Text(__UI_Focus) = Text(__UI_Focus) + LEFT$(NumericClip$, 1)
4093 NumericClip$ = MID$(NumericClip$, 2)
4094 ELSE
4095 Text(__UI_Focus) = Text(__UI_Focus) + "_"
4096 END IF
4097 CASE ELSE
4098 Text(__UI_Focus) = Text(__UI_Focus) + MID$(Mask(__UI_Focus), i, 1)
4099 END SELECT
4100 NEXT
4101 END IF
4102 ELSE
4103 IF Control(__UI_Focus).NumericOnly THEN
4104 'Paste only if clipboard$ contains a number
4105 IF NOT isNumber(Clip$) THEN Clip$ = ""
4106 END IF
4107
4108 IF LEN(Clip$) THEN
4109 IF NOT Control(__UI_Focus).TextIsSelected THEN
4110 IF Control(__UI_Focus).Cursor = LEN(Text(__UI_Focus)) THEN
4111 Text(__UI_Focus) = Text(__UI_Focus) + Clip$
4112 Control(__UI_Focus).Cursor = LEN(Text(__UI_Focus))
4113 ELSE
4114 Text(__UI_Focus) = LEFT$(Text(__UI_Focus), Control(__UI_Focus).Cursor) + Clip$ + MID$(Text(__UI_Focus), Control(__UI_Focus).Cursor + 1)
4115 Control(__UI_Focus).Cursor = Control(__UI_Focus).Cursor + LEN(Clip$)
4116 END IF
4117 ELSE
4118 s1 = Control(__UI_Focus).SelectionStart
4119 s2 = Control(__UI_Focus).Cursor
4120 IF s1 > s2 THEN SWAP s1, s2
4121 Text(__UI_Focus) = LEFT$(Text(__UI_Focus), s1) + Clip$ + MID$(Text(__UI_Focus), s2 + 1)
4122 Control(__UI_Focus).Cursor = s1 + LEN(Clip$)
4123 Control(__UI_Focus).TextIsSelected = False
4124 __UI_FillSelectedText 0, 0
4125 END IF
4126 END IF
4127 END IF
4128 __UI_TextChanged __UI_Focus
4129 IF Control(__UI_Focus).NumericOnly THEN
4130 Control(__UI_Focus).Value = VAL(Text(__UI_Focus))
4131
4132 __UI_ValidateBounds __UI_Focus
4133 END IF
4134 END IF
4135 IF ContextMenuPaste THEN
4136 ContextMenuPaste = False
4137 RETURN
4138 END IF
4139 __UI_KeyHit = 0
4140 END IF
4141 END IF
4142 ELSEIF __UI_KeyHit = ASC("c") OR __UI_KeyHit = ASC("C") THEN 'Copy selection to clipboard (Ctrl+C)
4143 IF __UI_CtrlIsDown THEN
4144 __UI_FillSelectedText 0, 0
4145 IF LEN(__UI_SelectedText) > 0 THEN _CLIPBOARD$ = __UI_SelectedText
4146 __UI_KeyHit = 0
4147 END IF
4148 ELSEIF __UI_KeyHit = ASC("x") OR __UI_KeyHit = ASC("X") THEN 'Cut selection to clipboard (Ctrl+X)
4149 IF __UI_CtrlIsDown THEN
4150 __UI_FillSelectedText 0, 0
4151 IF LEN(__UI_SelectedText) > 0 THEN
4152 _CLIPBOARD$ = __UI_SelectedText
4153 __UI_DeleteSelection
4154 __UI_TextChanged __UI_Focus
4155 IF Control(__UI_Focus).NumericOnly THEN
4156 Control(__UI_Focus).Value = VAL(Text(__UI_Focus))
4157
4158 __UI_ValidateBounds __UI_Focus
4159 END IF
4160 END IF
4161 __UI_KeyHit = 0
4162 END IF
4163 ELSEIF __UI_KeyHit = ASC("a") OR __UI_KeyHit = ASC("A") THEN 'Select all text (Ctrl+A)
4164 IF __UI_CtrlIsDown THEN
4165 Control(__UI_Focus).Cursor = LEN(Text(__UI_Focus))
4166 Control(__UI_Focus).SelectionStart = 0
4167 Control(__UI_Focus).TextIsSelected = True
4168 __UI_KeyHit = 0
4169 END IF
4170 END IF
4171
4172 IF Control(__UI_Focus).NumericOnly THEN
4173 IF __UI_KeyHit = 45 THEN
4174 IF INSTR(Text(__UI_Focus), "-") > 0 THEN
4175 IF INSTR(__UI_SelectedText, "-") = 0 THEN
4176 __UI_KeyHit = 0
4177 END IF
4178 ELSE
4179 IF (Control(__UI_Focus).Cursor > 0 AND Control(__UI_Focus).TextIsSelected = False) THEN
4180 __UI_KeyHit = 0
4181 END IF
4182 END IF
4183 ELSEIF __UI_KeyHit = 46 THEN
4184 IF INSTR(Text(__UI_Focus), ".") > 0 THEN
4185 IF INSTR(__UI_SelectedText, ".") = 0 THEN
4186 __UI_KeyHit = 0
4187 END IF
4188 ELSE
4189 IF Control(__UI_Focus).Cursor = 0 AND LEFT$(Text(__UI_Focus), 1) = "-" THEN
4190 __UI_KeyHit = 0
4191 END IF
4192 END IF
4193 ELSEIF __UI_KeyHit < 48 OR __UI_KeyHit > 57 THEN
4194 __UI_KeyHit = 0
4195 END IF
4196 END IF
4197
4198 IF __UI_KeyHit THEN
4199 IF __UI_KeyHit = 13 THEN __UI_KeyHit = 10
4200 IF Mask(__UI_Focus) = "" OR Control(__UI_Focus).Multiline THEN
4201 IF NOT Control(__UI_Focus).TextIsSelected THEN
4202 IF Control(__UI_Focus).Cursor = LEN(Text(__UI_Focus)) THEN
4203 IF (Control(__UI_Focus).Max > 0 AND LEN(Text(__UI_Focus)) < Control(__UI_Focus).Max) OR Control(__UI_Focus).Max = 0 THEN
4204 Text(__UI_Focus) = Text(__UI_Focus) + CHR$(__UI_KeyHit)
4205 Control(__UI_Focus).Cursor = Control(__UI_Focus).Cursor + LEN(CHR$(__UI_KeyHit))
4206 END IF
4207 ELSE
4208 IF (Control(__UI_Focus).Max > 0 AND LEN(Text(__UI_Focus)) < Control(__UI_Focus).Max) OR Control(__UI_Focus).Max = 0 THEN
4209 Text(__UI_Focus) = LEFT$(Text(__UI_Focus), Control(__UI_Focus).Cursor) + CHR$(__UI_KeyHit) + MID$(Text(__UI_Focus), Control(__UI_Focus).Cursor + 1)
4210 Control(__UI_Focus).Cursor = Control(__UI_Focus).Cursor + 1
4211 END IF
4212 END IF
4213 ELSE
4214 s1 = Control(__UI_Focus).SelectionStart
4215 s2 = Control(__UI_Focus).Cursor
4216 IF s1 > s2 THEN SWAP s1, s2
4217 Text(__UI_Focus) = LEFT$(Text(__UI_Focus), s1) + CHR$(__UI_KeyHit) + MID$(Text(__UI_Focus), s2 + 1)
4218 Control(__UI_Focus).TextIsSelected = False
4219 __UI_SelectedText = ""
4220 __UI_SelectionLength = 0
4221 Control(__UI_Focus).Cursor = s1 + 1
4222 END IF
4223 ELSE
4224 'Masked input KeyHit:
4225 IF Control(__UI_Focus).TextIsSelected THEN
4226 __UI_DeleteSelectionMasked
4227 END IF
4228 IF __UI_KeyHit >= 48 AND __UI_KeyHit <= 57 THEN
4229 DO
4230 SELECT CASE MID$(Mask(__UI_Focus), Control(__UI_Focus).Cursor + 1, 1)
4231 CASE "0", "9", "#"
4232 MID$(Text(__UI_Focus), Control(__UI_Focus).Cursor + 1, 1) = CHR$(__UI_KeyHit)
4233 Control(__UI_Focus).Cursor = Control(__UI_Focus).Cursor + 1
4234 EXIT DO
4235 CASE ELSE
4236 IF Control(__UI_Focus).Cursor < LEN(Mask(__UI_Focus)) THEN
4237 Control(__UI_Focus).Cursor = Control(__UI_Focus).Cursor + 1
4238 ELSE
4239 EXIT DO
4240 END IF
4241 END SELECT
4242 LOOP
4243 END IF
4244 END IF
4245
4246 __UI_TextChanged __UI_Focus
4247
4248 IF Control(__UI_Focus).NumericOnly THEN
4249 Control(__UI_Focus).Value = VAL(Text(__UI_Focus))
4250
4251 __UI_ValidateBounds __UI_Focus
4252 END IF
4253 END IF
4254 CASE 8 'Backspace
4255 IF Mask(__UI_Focus) = "" OR Control(__UI_Focus).Multiline THEN
4256 IF LEN(Text(__UI_Focus)) > 0 THEN
4257 IF NOT Control(__UI_Focus).TextIsSelected THEN
4258 IF Control(__UI_Focus).Cursor = LEN(Text(__UI_Focus)) THEN
4259 IF Control(__UI_Focus).Multiline AND RIGHT$(Text(__UI_Focus), 1) = CHR$(10) THEN
4260 Control(__UI_Focus).CurrentLine = Control(__UI_Focus).CurrentLine - 1
4261 END IF
4262 Text(__UI_Focus) = LEFT$(Text(__UI_Focus), LEN(Text(__UI_Focus)) - 1)
4263 Control(__UI_Focus).Cursor = Control(__UI_Focus).Cursor - 1
4264 ELSEIF Control(__UI_Focus).Cursor >= 1 THEN
4265 IF Control(__UI_Focus).Multiline AND MID$(Text(__UI_Focus), Control(__UI_Focus).Cursor, 1) = CHR$(10) THEN
4266 Control(__UI_Focus).CurrentLine = Control(__UI_Focus).CurrentLine - 1
4267 END IF
4268 Text(__UI_Focus) = LEFT$(Text(__UI_Focus), Control(__UI_Focus).Cursor - 1) + MID$(Text(__UI_Focus), Control(__UI_Focus).Cursor + 1)
4269 Control(__UI_Focus).Cursor = Control(__UI_Focus).Cursor - 1
4270 END IF
4271 ELSE
4272 __UI_DeleteSelection
4273 END IF
4274 __UI_TextChanged __UI_Focus
4275 IF Control(__UI_Focus).NumericOnly THEN
4276 Control(__UI_Focus).Value = VAL(Text(__UI_Focus))
4277
4278 __UI_ValidateBounds __UI_Focus
4279 END IF
4280 END IF
4281 ELSE
4282 'Masked input Backspace:
4283 IF NOT Control(__UI_Focus).TextIsSelected THEN
4284 IF Control(__UI_Focus).Cursor = LEN(Text(__UI_Focus)) THEN
4285 Text(__UI_Focus) = LEFT$(Text(__UI_Focus), LEN(Text(__UI_Focus)) - 1)
4286 Control(__UI_Focus).Cursor = Control(__UI_Focus).Cursor - 1
4287 ELSEIF Control(__UI_Focus).Cursor >= 1 THEN
4288 IF Control(__UI_Focus).Multiline AND MID$(Text(__UI_Focus), Control(__UI_Focus).Cursor, 1) = CHR$(10) THEN
4289 Control(__UI_Focus).CurrentLine = Control(__UI_Focus).CurrentLine - 1
4290 END IF
4291 Text(__UI_Focus) = LEFT$(Text(__UI_Focus), Control(__UI_Focus).Cursor - 1) + MID$(Text(__UI_Focus), Control(__UI_Focus).Cursor + 1)
4292 Control(__UI_Focus).Cursor = Control(__UI_Focus).Cursor - 1
4293 END IF
4294
4295 Text(__UI_Focus) = __UI_MaskToText$(__UI_Focus)
4296 ELSE
4297 __UI_DeleteSelectionMasked
4298 END IF
4299 __UI_TextChanged __UI_Focus
4300 IF Control(__UI_Focus).NumericOnly THEN
4301 Control(__UI_Focus).Value = VAL(Text(__UI_Focus))
4302
4303 __UI_ValidateBounds __UI_Focus
4304 END IF
4305 END IF
4306 CASE 21248 'Delete
4307 IF LEN(Mask(__UI_Focus)) = 0 THEN
4308 IF NOT Control(__UI_Focus).TextIsSelected THEN
4309 IF LEN(Text(__UI_Focus)) > 0 THEN
4310 IF Control(__UI_Focus).Cursor = 0 THEN
4311 Text(__UI_Focus) = RIGHT$(Text(__UI_Focus), LEN(Text(__UI_Focus)) - 1)
4312 ELSEIF Control(__UI_Focus).Cursor > 0 AND Control(__UI_Focus).Cursor <= LEN(Text(__UI_Focus)) - 1 THEN
4313 Text(__UI_Focus) = LEFT$(Text(__UI_Focus), Control(__UI_Focus).Cursor) + MID$(Text(__UI_Focus), Control(__UI_Focus).Cursor + 2)
4314 END IF
4315 __UI_TextChanged __UI_Focus
4316 IF Control(__UI_Focus).NumericOnly THEN
4317 Control(__UI_Focus).Value = VAL(Text(__UI_Focus))
4318
4319 __UI_ValidateBounds __UI_Focus
4320 END IF
4321 END IF
4322 ELSE
4323 __UI_DeleteSelection
4324 __UI_TextChanged __UI_Focus
4325 IF Control(__UI_Focus).NumericOnly THEN
4326 Control(__UI_Focus).Value = VAL(Text(__UI_Focus))
4327
4328 __UI_ValidateBounds __UI_Focus
4329 END IF
4330 END IF
4331 ELSE
4332 'Masked input Delete:
4333 IF NOT Control(__UI_Focus).TextIsSelected THEN
4334 IF LEN(Text(__UI_Focus)) > 0 THEN
4335 IF Control(__UI_Focus).Cursor < LEN(Text(__UI_Focus)) THEN
4336 MID$(Text(__UI_Focus), Control(__UI_Focus).Cursor + 1, 1) = MID$(__UI_EmptyMask$(__UI_Focus), Control(__UI_Focus).Cursor + 1, 1)
4337 __UI_TextChanged __UI_Focus
4338 IF Control(__UI_Focus).NumericOnly THEN
4339 Control(__UI_Focus).Value = VAL(Text(__UI_Focus))
4340
4341 __UI_ValidateBounds __UI_Focus
4342 END IF
4343 END IF
4344 END IF
4345 ELSE
4346 __UI_DeleteSelectionMasked
4347 __UI_TextChanged __UI_Focus
4348 IF Control(__UI_Focus).NumericOnly THEN
4349 Control(__UI_Focus).Value = VAL(Text(__UI_Focus))
4350
4351 __UI_ValidateBounds __UI_Focus
4352 END IF
4353 END IF
4354 END IF
4355 CASE 19200 'Left arrow key
4356 __UI_CheckSelection __UI_Focus
4357 IF __UI_CtrlIsDown THEN
4358 IF Control(__UI_Focus).Cursor > 0 THEN
4359 'Go back until we hit a nonseparator character
4360 DO
4361 Control(__UI_Focus).Cursor = Control(__UI_Focus).Cursor - 1
4362 IF Control(__UI_Focus).Cursor = 0 THEN EXIT DO
4363 LOOP UNTIL INSTR(SEP$, MID$(Text(__UI_Focus), Control(__UI_Focus).Cursor + 1, 1)) = 0
4364
4365 'Find the beginning of a word
4366 DO
4367 Control(__UI_Focus).Cursor = Control(__UI_Focus).Cursor - 1
4368 IF Control(__UI_Focus).Cursor = 0 THEN EXIT DO
4369 LOOP WHILE INSTR(SEP$, MID$(Text(__UI_Focus), Control(__UI_Focus).Cursor + 1, 1)) = 0
4370
4371 Control(__UI_Focus).Cursor = Control(__UI_Focus).Cursor + 1
4372 END IF
4373 ELSE
4374 IF Control(__UI_Focus).Cursor > 0 THEN Control(__UI_Focus).Cursor = Control(__UI_Focus).Cursor - 1
4375 END IF
4376 IF MID$(Text(__UI_Focus), Control(__UI_Focus).Cursor + 1, 1) = CHR$(10) THEN Control(__UI_Focus).CurrentLine = Control(__UI_Focus).CurrentLine - 1
4377 CASE 19712 'Right arrow key
4378 __UI_CheckSelection __UI_Focus
4379 IF __UI_CtrlIsDown THEN
4380 IF Control(__UI_Focus).Cursor < LEN(Text(__UI_Focus)) THEN
4381 DO
4382 Control(__UI_Focus).Cursor = Control(__UI_Focus).Cursor + 1
4383 IF Control(__UI_Focus).Cursor > LEN(Text(__UI_Focus)) THEN EXIT DO
4384 LOOP WHILE INSTR(SEP$, MID$(Text(__UI_Focus), Control(__UI_Focus).Cursor + 1, 1)) = 0
4385 Control(__UI_Focus).Cursor = Control(__UI_Focus).Cursor + 1
4386 END IF
4387 ELSE
4388 IF Control(__UI_Focus).Cursor < LEN(Text(__UI_Focus)) THEN Control(__UI_Focus).Cursor = Control(__UI_Focus).Cursor + 1
4389 END IF
4390 IF MID$(Text(__UI_Focus), Control(__UI_Focus).Cursor, 1) = CHR$(10) THEN Control(__UI_Focus).CurrentLine = Control(__UI_Focus).CurrentLine + 1
4391 CASE 18432 'Up arrow key
4392 IF Control(__UI_Focus).Multiline THEN
4393 IF Control(__UI_Focus).CurrentLine > 1 THEN
4394 Control(__UI_Focus).CurrentLine = Control(__UI_Focus).CurrentLine - 1
4395 END IF
4396 END IF
4397 CASE 20480 'Down arrow key
4398 IF Control(__UI_Focus).Multiline THEN
4399 IF Control(__UI_Focus).CurrentLine < __UI_CountLines(__UI_Focus) THEN
4400 Control(__UI_Focus).CurrentLine = Control(__UI_Focus).CurrentLine + 1
4401 END IF
4402 END IF
4403 CASE 18432, 20480 'For both up and down keys
4404 IF Control(__UI_Focus).Multiline THEN
4405 ThisLineLen = LEN(__UI_GetTextBoxLine(__UI_Focus, Control(__UI_Focus).CurrentLine, ThisLineStart))
4406 Control(__UI_Focus).Cursor = ThisLineStart + Control(__UI_Focus).VisibleCursor - 1
4407 IF Control(__UI_Focus).Cursor > ThisLineStart + ThisLineLen - 1 THEN
4408 Control(__UI_Focus).Cursor = ThisLineStart + ThisLineLen - 1
4409 END IF
4410 END IF
4411 CASE 18176 'Home
4412 __UI_CheckSelection __UI_Focus
4413 IF Control(__UI_Focus).Multiline THEN
4414 IF __UI_CtrlIsDown THEN
4415 Control(__UI_Focus).Cursor = 0
4416 Control(__UI_Focus).CurrentLine = 1
4417 ELSE
4418 Control(__UI_Focus).Cursor = Control(__UI_Focus).Cursor - Control(__UI_Focus).VisibleCursor
4419 END IF
4420 ELSE
4421 Control(__UI_Focus).Cursor = 0
4422 END IF
4423 CASE 20224 'End
4424 __UI_CheckSelection __UI_Focus
4425 IF Control(__UI_Focus).Multiline THEN
4426 IF __UI_CtrlIsDown THEN
4427 Control(__UI_Focus).Cursor = LEN(Text(__UI_Focus))
4428 Control(__UI_Focus).CurrentLine = __UI_CountLines(__UI_Focus)
4429 ELSE
4430 ThisLineLen = LEN(__UI_GetTextBoxLine(__UI_Focus, Control(__UI_Focus).CurrentLine, ThisLineStart))
4431 Control(__UI_Focus).Cursor = ThisLineStart + ThisLineLen - 1
4432 END IF
4433 ELSE
4434 Control(__UI_Focus).Cursor = LEN(Text(__UI_Focus))
4435 END IF
4436 END SELECT
4437 IF Control(__UI_Focus).Multiline THEN
4438 _FONT Control(__UI_Focus).Font
4439 IF Control(__UI_Focus).CurrentLine < Control(__UI_Focus).FirstVisibleLine THEN
4440 Control(__UI_Focus).FirstVisibleLine = Control(__UI_Focus).CurrentLine
4441 ELSEIF Control(__UI_Focus).CurrentLine + 1 > Control(__UI_Focus).FirstVisibleLine + Control(__UI_Focus).Height \ uspacing& THEN
4442 Control(__UI_Focus).FirstVisibleLine = Control(__UI_Focus).CurrentLine - Control(__UI_Focus).Height \ uspacing& + 1
4443 END IF
4444 END IF
4445 END IF
4446 END SELECT
4447 END IF
4448 ELSEIF __UI_DesignMode AND __UI_KeyHit <> 0 THEN 'No buttons will respond while in design mode
4449 'But the design menu must respond:
4450 IF __UI_TotalActiveMenus > 0 AND LEFT$(Control(__UI_ParentMenu(__UI_TotalActiveMenus)).Name, 5) = "__UI_" THEN GOTO HandleDesignMenu
4451
4452 SELECT CASE __UI_Keyhit
4453 CASE ASC("Z"), ASC("z")
4454 IF __UI_CtrlIsDown THEN
4455 __UI_KeyPress 214
4456 END IF
4457 CASE ASC("Y"), ASC("y")
4458 IF __UI_CtrlIsDown THEN
4459 __UI_KeyPress 215
4460 END IF
4461 CASE ASC("A"), ASC("a")
4462 IF __UI_CtrlIsDown THEN
4463 ControlSelect:
4464 __UI_KeyPress 221
4465 END IF
4466 CASE ASC("X"), ASC("x")
4467 IF __UI_CtrlIsDown AND __UI_TotalSelectedControls > 0 THEN
4468 ControlCut:
4469 __UI_KeyPress 216
4470 __UI_KeyPress 219
4471 END IF
4472 CASE ASC("C"), ASC("c")
4473 IF __UI_CtrlIsDown AND __UI_TotalSelectedControls > 0 THEN
4474 ControlCopy:
4475 __UI_KeyPress 217
4476 END IF
4477 CASE ASC("V"), ASC("v")
4478 IF __UI_CtrlIsDown THEN
4479 ControlPaste:
4480 Clip$ = _CLIPBOARD$
4481 IF LEFT$(Clip$, LEN(__UI_ClipboardCheck$)) = __UI_ClipboardCheck$ THEN
4482 __UI_KeyPress 218
4483 END IF
4484 END IF
4485 CASE 21248 'Delete
4486 ControlDelete:
4487 __UI_KeyPress 216
4488 __UI_KeyPress 220
4489 CASE 19200 'Left arrow key
4490 __UI_KeyPress 216
4491 FOR i = 1 TO UBOUND(Control)
4492 IF Control(i).ControlIsSelected AND Control(i).Type <> __UI_Type_MenuBar AND Control(i).Type <> __UI_Type_MenuItem THEN
4493 IF __UI_ShiftIsDown THEN
4494 Control(i).Width = Control(i).Width - 1
4495 __UI_IsResizing = True
4496 __UI_ResizingID = i
4497 ELSE
4498 Control(i).Left = Control(i).Left - 1
4499 END IF
4500 END IF
4501 NEXT
4502 CASE 19712 'Right arrow key
4503 __UI_KeyPress 216
4504 FOR i = 1 TO UBOUND(Control)
4505 IF Control(i).ControlIsSelected AND Control(i).Type <> __UI_Type_MenuBar AND Control(i).Type <> __UI_Type_MenuItem THEN
4506 IF __UI_ShiftIsDown THEN
4507 Control(i).Width = Control(i).Width + 1
4508 __UI_IsResizing = True
4509 __UI_ResizingID = i
4510 ELSE
4511 Control(i).Left = Control(i).Left + 1
4512 END IF
4513 END IF
4514 NEXT
4515 CASE 18432 'Up arrow key
4516 __UI_KeyPress 216
4517 FOR i = 1 TO UBOUND(Control)
4518 IF Control(i).ControlIsSelected AND Control(i).Type <> __UI_Type_MenuBar AND Control(i).Type <> __UI_Type_MenuItem THEN
4519 IF __UI_ShiftIsDown THEN
4520 __UI_IsResizing = True
4521 __UI_ResizingID = i
4522 Control(i).Height = Control(i).Height - 1
4523 ELSE
4524 Control(i).Top = Control(i).Top - 1
4525 END IF
4526 END IF
4527 NEXT
4528 CASE 20480 'Down arrow key
4529 __UI_KeyPress 216
4530 FOR i = 1 TO UBOUND(Control)
4531 IF Control(i).ControlIsSelected AND Control(i).Type <> __UI_Type_MenuBar AND Control(i).Type <> __UI_Type_MenuItem THEN
4532 IF __UI_ShiftIsDown THEN
4533 Control(i).Height = Control(i).Height + 1
4534 __UI_IsResizing = True
4535 __UI_ResizingID = i
4536 ELSE
4537 Control(i).Top = Control(i).Top + 1
4538 END IF
4539 END IF
4540 NEXT
4541 END SELECT
4542 IF __UI_TotalActiveMenus > 0 THEN __UI_ActivateMenu Control(__UI_ParentMenu(__UI_TotalActiveMenus)), False
4543 ELSEIF __UI_KeyHit <> 0 THEN 'No control has focus
4544 'Enter activates the default button, if any
4545 IF __UI_IsDragging = False AND __UI_KeyHit = -13 AND __UI_DefaultButtonID > 0 THEN
4546 'Enter released and there is a default button
4547 __UI_Click __UI_DefaultButtonID
4548 __UI_KeyHit = 0
4549 END IF
4550 END IF
4551
4552 __UI_LastHoveringID = __UI_HoveringID
4553END SUB
4554
4555SUB __UI_ValidateBounds(this AS LONG)
4556 IF Control(this).NumericOnly = __UI_NumericWithBounds THEN
4557 'Max and Min properties can be used for NumericOnly textboxes
4558 'set as .NumericOnly = __UI_NumericWithBounds
4559 IF Control(this).Value < Control(this).Min THEN
4560 Control(this).Value = Control(this).Min
4561 END IF
4562
4563 IF Control(this).Value > Control(this).Max THEN
4564 Control(this).Value = Control(this).Max
4565 END IF
4566 END IF
4567END SUB
4568
4569'---------------------------------------------------------------------------------
4570SUB AutoSizeLabel (this AS __UI_ControlTYPE)
4571 DIM tempFont AS LONG, tempCenter AS INTEGER
4572 DIM autoWidth AS INTEGER, autoHeight AS INTEGER
4573 IF this.AutoSize = False THEN EXIT SUB
4574 IF this.WordWrap = False THEN
4575 tempFont = _FONT
4576 _FONT this.Font
4577 autoWidth = __UI_PrintWidth(Caption(this.ID))
4578 IF this.Padding THEN autoWidth = autoWidth + this.Padding * 2
4579 IF this.HasBorder THEN autoWidth = autoWidth + (__UI_DefaultCaptionIndent + this.BorderSize) * 2
4580 IF this.Width <> autoWidth OR this.Height <> uspacing + 6 THEN
4581 this.Width = autoWidth
4582 autoHeight = uspacing + 6
4583 IF this.HasBorder THEN autoHeight = autoHeight + this.BorderSize * 2
4584 IF this.Height <> autoHeight THEN
4585 tempCenter = this.Top + this.Height / 2
4586 this.Height = autoHeight
4587 this.Top = tempCenter - this.Height / 2
4588 END IF
4589 this.Redraw = True
4590 END IF
4591 _FONT tempFont
4592 END IF
4593END SUB
4594
4595'---------------------------------------------------------------------------------
4596FUNCTION Darken~& (WhichColor~&, ByHowMuch%)
4597 Darken~& = _RGB32(_RED32(WhichColor~&) * (ByHowMuch% / 100), _GREEN32(WhichColor~&) * (ByHowMuch% / 100), _BLUE32(WhichColor~&) * (ByHowMuch% / 100))
4598END FUNCTION
4599
4600'---------------------------------------------------------------------------------
4601FUNCTION isNumber%% (__a$)
4602 'This function adapted from qb64.bas
4603 DIM i AS LONG, a AS INTEGER, dp AS _BYTE, a$
4604
4605 a$ = LTRIM$(RTRIM$(__a$))
4606
4607 IF LEN(a$) = 0 THEN EXIT FUNCTION
4608 FOR i = 1 TO LEN(a$)
4609 a = ASC(MID$(a$, i, 1))
4610 IF a = 45 THEN
4611 IF i <> 1 THEN EXIT FUNCTION
4612 _CONTINUE
4613 END IF
4614 IF a = 46 THEN
4615 IF dp = 1 THEN EXIT FUNCTION
4616 dp = 1
4617 _CONTINUE
4618 END IF
4619 IF a >= 48 AND a <= 57 THEN _CONTINUE
4620 EXIT FUNCTION
4621 NEXT
4622 isNumber%% = True
4623END FUNCTION
4624
4625'---------------------------------------------------------------------------------
4626FUNCTION RegisterKeyCombo (__Combo$, id AS LONG)
4627 DIM i AS LONG, j AS LONG, Combo$
4628
4629 IF Control(id).ID = 0 THEN EXIT FUNCTION
4630
4631 IF LEN(LTRIM$(RTRIM$(__Combo$))) = 0 THEN
4632 IF id > 0 THEN
4633 'delete assignment
4634 FOR i = 1 TO __UI_TotalKeyCombos
4635 IF __UI_KeyCombo(i).ControlID = id THEN
4636 Control(__UI_KeyCombo(i).ControlID).KeyCombo = 0
4637 __UI_KeyCombo(i).ControlID = 0
4638 EXIT FOR
4639 END IF
4640 NEXT
4641 END IF
4642 EXIT FUNCTION
4643 END IF
4644
4645 Combo$ = UCASE$(LTRIM$(RTRIM$(__Combo$)))
4646 IF INSTR(Combo$, "CTRL+") = 0 THEN
4647 IF LEFT$(Combo$, 1) = "F" AND (VAL(MID$(Combo$, 2)) >= 1 AND VAL(MID$(Combo$, 2)) <= 12) THEN
4648 'valid
4649 ELSEIF LEFT$(Combo$, 7) = "SHIFT+F" AND (VAL(MID$(Combo$, 8)) >= 1 AND VAL(MID$(Combo$, 8)) <= 12) THEN
4650 'valid
4651 ELSE
4652 EXIT FUNCTION
4653 END IF
4654 END IF
4655
4656 FOR i = 1 TO __UI_TotalKeyCombos
4657 IF RTRIM$(__UI_KeyCombo(i).Combo) = Combo$ THEN
4658 IF __UI_KeyCombo(i).ControlID >= 0 THEN
4659 'Check if this id is already assigned to a combo
4660 FOR j = 1 TO __UI_TotalKeyCombos
4661 IF __UI_KeyCombo(j).ControlID = id THEN
4662 Control(__UI_KeyCombo(j).ControlID).KeyCombo = 0
4663 __UI_KeyCombo(j).ControlID = 0
4664 END IF
4665 NEXT
4666
4667 'Reassign combo to different control
4668 Control(__UI_KeyCombo(i).ControlID).KeyCombo = 0
4669 __UI_KeyCombo(i).ControlID = id
4670 Control(id).KeyCombo = i
4671 RegisterKeyCombo = True
4672 EXIT FUNCTION
4673 ELSE
4674 EXIT FUNCTION
4675 END IF
4676 END IF
4677 NEXT
4678
4679 IF __UI_TotalKeyCombos + 1 > UBOUND(__UI_KeyCombo) THEN
4680 REDIM _PRESERVE __UI_KeyCombo(0 TO UBOUND(__UI_KeyCombo) + 100) AS __UI_KeyCombos
4681 END IF
4682
4683 __UI_TotalKeyCombos = __UI_TotalKeyCombos + 1
4684 __UI_KeyCombo(__UI_TotalKeyCombos).Combo = Combo$
4685 __UI_KeyCombo(__UI_TotalKeyCombos).FriendlyCombo = __UI_FriendlyCombo(Combo$)
4686
4687 FOR i = 1 TO __UI_TotalKeyCombos
4688 IF __UI_KeyCombo(i).ControlID = id THEN
4689 __UI_KeyCombo(i).ControlID = 0
4690 END IF
4691 NEXT
4692
4693 __UI_KeyCombo(__UI_TotalKeyCombos).ControlID = id
4694 Control(id).KeyCombo = __UI_TotalKeyCombos
4695 RegisterKeyCombo = True
4696END FUNCTION
4697
4698'---------------------------------------------------------------------------------
4699FUNCTION __UI_FriendlyCombo$ (__Combo$)
4700 DIM i AS LONG, isCapital AS _BYTE
4701 DIM Combo$
4702
4703 isCapital = True
4704 FOR i = 1 TO LEN(__Combo$)
4705 IF isCapital THEN
4706 Combo$ = Combo$ + UCASE$(MID$(__Combo$, i, 1))
4707 isCapital = False
4708 ELSE
4709 Combo$ = Combo$ + LCASE$(MID$(__Combo$, i, 1))
4710 END IF
4711 IF RIGHT$(Combo$, 1) = "+" THEN isCapital = True
4712 NEXT
4713 __UI_FriendlyCombo$ = Combo$
4714END FUNCTION
4715
4716'---------------------------------------------------------------------------------
4717SUB __UI_RestoreFKeys
4718 RESTORE __UI_FKeysData
4719 DIM i AS LONG
4720 FOR i = 1 TO 12
4721 READ __UI_FKey(i)
4722 NEXT
4723
4724 __UI_FKeysData:
4725 DATA 15104,15360,15616,15872,16128,16384
4726 DATA 16640,16896,17152,17408,34048,34304
4727END SUB
4728
4729'---------------------------------------------------------------------------------
4730SUB __UI_RestoreImageOriginalSize
4731 DIM KeepCenterX AS INTEGER, KeepCenterY AS INTEGER
4732 KeepCenterY = Control(__UI_FirstSelectedID).Top + Control(__UI_FirstSelectedID).Height / 2
4733 KeepCenterX = Control(__UI_FirstSelectedID).Left + Control(__UI_FirstSelectedID).Width / 2
4734
4735 Control(__UI_FirstSelectedID).Height = _HEIGHT(Control(__UI_FirstSelectedID).HelperCanvas) + Control(__UI_FirstSelectedID).BorderSize * ABS(Control(__UI_FirstSelectedID).HasBorder)
4736 Control(__UI_FirstSelectedID).Width = _WIDTH(Control(__UI_FirstSelectedID).HelperCanvas) + Control(__UI_FirstSelectedID).BorderSize * ABS(Control(__UI_FirstSelectedID).HasBorder)
4737
4738 Control(__UI_FirstSelectedID).Top = KeepCenterY - Control(__UI_FirstSelectedID).Height / 2
4739 Control(__UI_FirstSelectedID).Left = KeepCenterX - Control(__UI_FirstSelectedID).Width / 2
4740
4741 Control(__UI_FirstSelectedID).Redraw = True
4742END SUB
4743
4744'---------------------------------------------------------------------------------
4745FUNCTION __UI_MaskToText$(id AS LONG)
4746 DIM i AS LONG
4747 DIM Text$
4748
4749 Text$ = Text(id)
4750 IF LEN(Text$) < LEN(Mask(id)) THEN Text$ = Text$ + SPACE$(LEN(Mask(id)) - LEN(Text$))
4751
4752 FOR i = 1 TO LEN(Mask(id))
4753 SELECT CASE MID$(Mask(id), i, 1)
4754 CASE "0", "9", "#"
4755 IF MID$(Text$, i, 1) <> MID$(Mask(id), i, 1) AND ASC(Text$, i) >= 48 AND ASC(Text$, i) <= 57 THEN
4756 'Do nothing
4757 ELSEIF MID$(Text$, i, 1) <> MID$(Mask(id), i, 1) THEN
4758 MID$(Text$, i, 1) = "_"
4759 END IF
4760 CASE ELSE
4761 MID$(Text$, i, 1) = MID$(Mask(id), i, 1)
4762 END SELECT
4763 NEXT
4764
4765 __UI_MaskToText$ = Text$
4766END FUNCTION
4767
4768'---------------------------------------------------------------------------------
4769FUNCTION RawText$(id AS LONG)
4770 DIM t$, c$, i AS INTEGER
4771
4772 IF Mask(id) = "" THEN
4773 RawText$ = Text(id)
4774 ELSE
4775 FOR i = 1 TO LEN(Mask(id))
4776 c$ = MID$(Text(id), i, 1)
4777 SELECT CASE MID$(Mask(id), i, 1)
4778 CASE "0", "9", "#"
4779 IF c$ <> "_" THEN
4780 t$ = t$ + c$
4781 ELSE
4782 t$ = t$ + " "
4783 END IF
4784 END SELECT
4785 NEXT
4786 RawText$ = t$
4787 END IF
4788END FUNCTION
4789
4790'---------------------------------------------------------------------------------
4791FUNCTION __UI_EmptyMask$(id AS LONG)
4792 DIM i AS LONG
4793 DIM Text$
4794
4795 FOR i = 1 TO LEN(Mask(id))
4796 SELECT CASE MID$(Mask(id), i, 1)
4797 CASE "0", "9", "#"
4798 Text$ = Text$ + "_"
4799 CASE ELSE
4800 Text$ = Text$ + MID$(Mask(id), i, 1)
4801 END SELECT
4802 NEXT
4803
4804 __UI_EmptyMask$ = Text$
4805END FUNCTION
4806
4807'---------------------------------------------------------------------------------
4808FUNCTION __UI_GetID (ControlName$)
4809 DIM i AS LONG, ControlSearch$
4810
4811 ControlSearch$ = UCASE$(RTRIM$(ControlName$))
4812 IF LEN(ControlSearch$) = 0 THEN EXIT FUNCTION
4813 FOR i = 1 TO UBOUND(Control)
4814 IF Control(i).ID > 0 AND UCASE$(RTRIM$(Control(i).Name)) = ControlSearch$ THEN
4815 __UI_GetID = i
4816 EXIT FUNCTION
4817 END IF
4818 NEXT
4819END FUNCTION
4820
4821'---------------------------------------------------------------------------------
4822FUNCTION __UI_GetFontID (FontHandle&)
4823 DIM i AS LONG
4824
4825 FOR i = 1 TO UBOUND(Control)
4826 IF Control(i).Type = __UI_Type_Font AND Control(i).Value = FontHandle& THEN
4827 __UI_GetFontID = i
4828 EXIT FUNCTION
4829 END IF
4830 NEXT
4831END FUNCTION
4832
4833'---------------------------------------------------------------------------------
4834FUNCTION SetFont& (__NewFontFile AS STRING, NewFontSize AS INTEGER)
4835 DIM NextSlot AS LONG, i AS LONG
4836 DIM NewFontFile AS STRING, PassedFontFile AS STRING, FindSep AS LONG
4837 DIM TotalPassedFonts AS LONG
4838 REDIM PassedFonts(0 TO 10) AS STRING
4839
4840 'common sense is not to use question marks for file names, so
4841 'we'll use it as a separator for multiple font assignments.
4842 '"arial.ttf?cour.ttf?lucon.ttf" - First font that is found is used.
4843 PassedFontFile = __NewFontFile
4844 DO
4845 FindSep = INSTR(PassedFontFile, "?")
4846 IF FindSep > 0 THEN
4847 NewFontFile = LEFT$(PassedFontFile, FindSep - 1)
4848 PassedFontFile = RTRIM$(LTRIM$(MID$(PassedFontFile, FindSep + 1)))
4849 ELSE
4850 NewFontFile = RTRIM$(LTRIM$(PassedFontFile))
4851 END IF
4852
4853 TotalPassedFonts = TotalPassedFonts + 1
4854 IF TotalPassedFonts > UBOUND(PassedFonts) THEN REDIM _PRESERVE PassedFonts(0 TO UBOUND(PassedFonts) + 9) AS STRING
4855 PassedFonts(TotalPassedFonts) = NewFontFile
4856
4857 'If the passed font is already loaded, we'll just return its handle
4858 FOR NextSlot = 1 TO UBOUND(Control)
4859 IF Control(NextSlot).Type = __UI_Type_Font THEN
4860 IF (UCASE$(ToolTip(NextSlot)) = UCASE$(__NewFontFile)) AND Control(NextSlot).Max = NewFontSize THEN
4861 SetFont& = Control(NextSlot).Value
4862 EXIT FUNCTION
4863 END IF
4864 END IF
4865 NEXT
4866 LOOP WHILE FindSep > 0
4867
4868 '-------------------------------------------------
4869 'The font isn't loaded, so we'll attempt to do so.
4870
4871 'Increase the global count of fonts
4872 __UI_Type(__UI_Type_Font).Count = __UI_Type(__UI_Type_Font).Count + 1
4873
4874 'Find an empty slot for the new font control
4875 FOR NextSlot = UBOUND(Control) TO 1 STEP -1
4876 IF Control(NextSlot).ID <> 0 THEN
4877 NextSlot = NextSlot + 1
4878 EXIT FOR
4879 ELSE
4880 IF NextSlot = 1 THEN NextSlot = UBOUND(Control) + 1: EXIT FOR
4881 END IF
4882 NEXT
4883
4884 IF NextSlot = UBOUND(Control) + 1 THEN
4885 'No empty slots. We must increase Control() and its helper arrays
4886 REDIM _PRESERVE Control(0 TO NextSlot + 99) AS __UI_ControlTYPE
4887 REDIM _PRESERVE Caption(0 TO NextSlot + 99) AS STRING
4888 REDIM _PRESERVE __UI_TempCaptions(0 TO NextSlot + 99) AS STRING
4889 REDIM _PRESERVE Text(0 TO NextSlot + 99) AS STRING
4890 REDIM _PRESERVE __UI_TempTexts(0 TO NextSlot + 99) AS STRING
4891 REDIM _PRESERVE Mask(0 TO NextSlot + 99) AS STRING
4892 REDIM _PRESERVE __UI_TempMask(0 TO NextSlot + 99) AS STRING
4893 REDIM _PRESERVE ToolTip(0 TO NextSlot + 99) AS STRING
4894 REDIM _PRESERVE __UI_TempTips(0 TO NextSlot + 99) AS STRING
4895 END IF
4896
4897 'Initialize new control
4898 Control(NextSlot).ID = NextSlot
4899 Control(NextSlot).Type = __UI_Type_Font
4900 Control(NextSlot).Name = "Font" + LTRIM$(STR$(__UI_Type(__UI_Type_Font).Count))
4901
4902 NewFontFile = ""
4903 FOR i = 1 TO TotalPassedFonts
4904 IF _FILEEXISTS(PassedFonts(i)) OR _FILEEXISTS("C:\Windows\Fonts\" + PassedFonts(i)) THEN
4905 NewFontFile = PassedFonts(i)
4906 EXIT FOR
4907 END IF
4908 NEXT
4909
4910 IF NewFontFile = "" THEN
4911 'Internal emulated fonts
4912 IF NewFontSize <> 8 AND NewFontSize <> 16 THEN
4913 Control(NextSlot).Value = 16
4914 Control(NextSlot).Max = 16
4915 ELSE
4916 Control(NextSlot).Value = NewFontSize
4917 Control(NextSlot).Max = NewFontSize
4918 END IF
4919 SetFont& = Control(NextSlot).Value
4920 ELSE
4921 Control(NextSlot).Value = _LOADFONT(NewFontFile, NewFontSize)
4922 Control(NextSlot).Max = NewFontSize
4923 Text(NextSlot) = NewFontFile
4924 ToolTip(NextSlot) = __NewFontFile 'save the original string passed
4925
4926 SetFont& = Control(NextSlot).Value
4927
4928 'If loading the requested font fails, we default to _FONT 16
4929 IF Control(NextSlot).Value <= 0 THEN
4930 __UI_DestroyControl Control(NextSlot)
4931 SetFont& = 16
4932 END IF
4933 END IF
4934END FUNCTION
4935
4936'---------------------------------------------------------------------------------
4937SUB __UI_AdjustNewMenuBarTopHeight (NextSlot AS LONG)
4938 DIM TempCanvas AS LONG, PrevDest AS LONG
4939
4940 IF _PIXELSIZE = 0 THEN
4941 'Temporarily create a 32bit screen for proper font handling, in case
4942 'we're still at form setup (SCREEN 0)
4943 TempCanvas = _NEWIMAGE(10, 10, 32)
4944 PrevDest = _DEST
4945 _DEST TempCanvas
4946 END IF
4947
4948 IF Control(__UI_FormID).Font THEN _FONT Control(__UI_FormID).Font
4949 Control(NextSlot).Height = falcon_uspacing& + (((_FONT = 8) * -1) * __UI_Font8Offset + ((_FONT = 16) * -1) * __UI_Font16Offset) + 5
4950 Control(NextSlot).Top = 0
4951
4952 IF TempCanvas <> 0 THEN
4953 _DEST PrevDest
4954 _FREEIMAGE TempCanvas
4955 END IF
4956
4957 IF __UI_HasMenuBar = False THEN
4958 __UI_HasMenuBar = True
4959 'Add menubar div to main form's canvas
4960 IF Control(__UI_FormID).Canvas <> 0 THEN _FREEIMAGE Control(__UI_FormID).Canvas
4961 Control(__UI_FormID).Canvas = _NEWIMAGE(Control(__UI_FormID).Width, Control(__UI_FormID).Height, 32)
4962 _DEST Control(__UI_FormID).Canvas
4963 COLOR Control(__UI_FormID).ForeColor, Control(__UI_FormID).BackColor
4964 CLS
4965 IF Control(__UI_FormID).Font THEN _FONT Control(__UI_FormID).Font
4966 __UI_MenuBarOffsetV = falcon_uspacing& + (((_FONT = 8) * -1) * __UI_Font8Offset + ((_FONT = 16) * -1) * __UI_Font16Offset) + 5 + 2
4967 LINE (0, falcon_uspacing& + (((_FONT = 8) * -1) * __UI_Font8Offset + ((_FONT = 16) * -1) * __UI_Font16Offset) + 5 + 1)-STEP(Control(__UI_FormID).Width - 1, 0), Darken(Control(__UI_FormID).BackColor, 80)
4968 LINE (0, falcon_uspacing& + (((_FONT = 8) * -1) * __UI_Font8Offset + ((_FONT = 16) * -1) * __UI_Font16Offset) + 5 + 2)-STEP(Control(__UI_FormID).Width - 1, 0), Darken(Control(__UI_FormID).BackColor, 120)
4969 _DEST 0
4970 END IF
4971END SUB
4972
4973'---------------------------------------------------------------------------------
4974FUNCTION __UI_NewControl (ControlType AS INTEGER, ControlName AS STRING, NewWidth AS INTEGER, NewHeight AS INTEGER, NewLeft AS INTEGER, NewTop AS INTEGER, ParentID AS LONG)
4975 DIM NextSlot AS LONG, i AS LONG
4976 STATIC InternalMenus AS LONG, FirstControl AS _BYTE
4977
4978 IF ControlType = 0 THEN EXIT SUB
4979
4980 __UI_ExpandControlDrawOrder 1
4981 'Increase the global count of controls of this type
4982 __UI_Type(ControlType).Count = __UI_Type(ControlType).Count + 1
4983
4984 'Give control a generic name, if none is provided
4985 IF ControlType = __UI_Type_MenuItem AND LEFT$(ControlName, 5) = "__UI_" THEN InternalMenus = InternalMenus + 1
4986 IF ControlType = __UI_Type_ContextMenu AND LEFT$(ControlName, 5) = "__UI_" THEN __UI_InternalContextMenus = __UI_InternalContextMenus + 1
4987
4988 IF ControlName = "" THEN
4989 IF ControlType = __UI_Type_MenuItem THEN
4990 ControlName = RTRIM$(__UI_Type(ControlType).Name) + LTRIM$(STR$(__UI_Type(ControlType).Count - InternalMenus))
4991 ELSEIF ControlType = __UI_Type_ContextMenu THEN
4992 ControlName = RTRIM$(__UI_Type(ControlType).Name) + LTRIM$(STR$(__UI_Type(ControlType).Count - __UI_InternalContextMenus))
4993 ELSE
4994 ControlName = RTRIM$(__UI_Type(ControlType).Name) + LTRIM$(STR$(__UI_Type(ControlType).Count))
4995 END IF
4996 END IF
4997
4998 'Make sure this ControlName is unique:
4999 IF ControlType <> __UI_Type_Font THEN
5000 i = 1
5001 DO
5002 IF __UI_GetID(ControlName) = 0 THEN EXIT DO
5003 i = i + 1
5004 ControlName = ControlName + "_" + LTRIM$(STR$(i))
5005 LOOP
5006 END IF
5007
5008 'Find an empty slot for the new control
5009 IF FirstControl = False THEN
5010 NextSlot = 1
5011 FirstControl = True
5012 ELSE
5013 FOR NextSlot = UBOUND(Control) TO 1 STEP -1
5014 IF Control(NextSlot).ID <> 0 THEN
5015 NextSlot = NextSlot + 1
5016 EXIT FOR
5017 ELSE
5018 IF NextSlot = 1 THEN NextSlot = UBOUND(Control) + 1: EXIT FOR
5019 END IF
5020 NEXT
5021 END IF
5022
5023 ControlDrawOrder(UBOUND(ControlDrawOrder)) = NextSlot
5024 IF NextSlot = UBOUND(Control) + 1 THEN
5025 'No empty slots. We must increase Control() and its helper arrays
5026 REDIM _PRESERVE Control(0 TO NextSlot + 99) AS __UI_ControlTYPE
5027 REDIM _PRESERVE Caption(0 TO NextSlot + 99) AS STRING
5028 REDIM _PRESERVE __UI_TempCaptions(0 TO NextSlot + 99) AS STRING
5029 REDIM _PRESERVE Text(0 TO NextSlot + 99) AS STRING
5030 REDIM _PRESERVE __UI_TempTexts(0 TO NextSlot + 99) AS STRING
5031 REDIM _PRESERVE Mask(0 TO NextSlot + 99) AS STRING
5032 REDIM _PRESERVE __UI_TempMask(0 TO NextSlot + 99) AS STRING
5033 REDIM _PRESERVE ToolTip(0 TO NextSlot + 99) AS STRING
5034 REDIM _PRESERVE __UI_TempTips(0 TO NextSlot + 99) AS STRING
5035 END IF
5036
5037 'Initialize new control
5038 Control(NextSlot).ID = NextSlot
5039 Control(NextSlot).Type = ControlType
5040 Control(NextSlot).Name = ControlName
5041
5042 IF ControlType = __UI_Type_Form AND __UI_FormID = 0 THEN __UI_FormID = NextSlot
5043
5044 Control(NextSlot).ParentID = ParentID
5045 Control(NextSlot).ParentName = Control(ParentID).Name
5046 IF ControlType = __UI_Type_MenuItem THEN
5047 IF Control(ParentID).Type = __UI_Type_MenuItem THEN
5048 Control(ParentID).SubMenu = True
5049 END IF
5050 END IF
5051
5052 IF (ControlType <> __UI_Type_Form AND ParentID = 0) THEN
5053 'Inherit main form's font
5054 Control(NextSlot).Font = Control(__UI_FormID).Font
5055 ELSEIF (ControlType <> __UI_Type_Frame AND ParentID > 0) THEN
5056 'Inherit container's font
5057 Control(NextSlot).Font = Control(ParentID).Font
5058 END IF
5059
5060 Control(NextSlot).Width = NewWidth
5061 Control(NextSlot).Height = NewHeight
5062 Control(NextSlot).Left = NewLeft
5063 Control(NextSlot).Top = NewTop
5064 Control(NextSlot).ForeColor = __UI_DefaultColor(ControlType, 1)
5065 Control(NextSlot).BackColor = __UI_DefaultColor(ControlType, 2)
5066 Control(NextSlot).SelectedForeColor = __UI_DefaultColor(ControlType, 3)
5067 Control(NextSlot).SelectedBackColor = __UI_DefaultColor(ControlType, 4)
5068 Control(NextSlot).BorderColor = __UI_DefaultColor(ControlType, 5)
5069
5070 IF ControlType = __UI_Type_MenuBar THEN
5071 __UI_AdjustNewMenuBarTopHeight NextSlot
5072 END IF
5073
5074 IF ControlType = __UI_Type_ToggleSwitch OR ControlType = __UI_Type_TrackBar OR ControlType = __UI_Type_TextBox OR ControlType = __UI_Type_Button OR ControlType = __UI_Type_CheckBox OR ControlType = __UI_Type_RadioButton OR ControlType = __UI_Type_ListBox OR ControlType = __UI_Type_DropdownList THEN
5075 Control(NextSlot).CanHaveFocus = True
5076 END IF
5077
5078 IF ControlType = __UI_Type_Frame THEN
5079 IF NewWidth = 0 THEN NewWidth = 10
5080 IF NewHeight = 0 THEN NewHeight = 10
5081 Control(NextSlot).Canvas = _NEWIMAGE(NewWidth, NewHeight, 32)
5082 END IF
5083
5084 IF __UI_DesignMode THEN
5085 'Control(NextSlot).ContextMenuID = __UI_GetID("__UI_PreviewMenu")
5086 ELSE
5087 IF ControlType = __UI_Type_TextBox THEN
5088 'Programmer can assign any custom menus to his controls, later
5089 'but by default textboxes and other textfields will be
5090 'assigned the internal __UI_TextFieldMenu.
5091 Control(NextSlot).ContextMenuID = __UI_GetID("__UI_TextFieldMenu")
5092 END IF
5093 END IF
5094
5095 IF ControlType = __UI_Type_ProgressBar THEN
5096 Control(NextSlot).Max = 100
5097 Caption(NextSlot) = "\#"
5098 END IF
5099
5100 IF ControlType = __UI_Type_TrackBar THEN
5101 Control(NextSlot).Max = 10
5102 Control(NextSlot).Interval = 1
5103 END IF
5104
5105 IF ControlType = __UI_Type_Form THEN
5106 'Create main window bg:
5107 Control(__UI_FormID).Canvas = _NEWIMAGE(NewWidth, NewHeight, 32)
5108 _DEST Control(__UI_FormID).Canvas
5109 COLOR Control(__UI_FormID).ForeColor, Control(__UI_FormID).BackColor
5110 CLS
5111 _DEST 0
5112 END IF
5113
5114 IF (ControlType = __UI_Type_PictureBox AND __UI_DesignMode) OR ControlType = __UI_Type_TextBox OR ControlType = __UI_Type_Frame OR ControlType = __UI_Type_ListBox OR ControlType = __UI_Type_DropdownList THEN
5115 Control(NextSlot).HasBorder = True
5116 Control(NextSlot).BorderSize = 1
5117 END IF
5118
5119 IF ControlType = __UI_Type_PictureBox THEN
5120 Control(NextSlot).HelperCanvas = _NEWIMAGE(NewWIdth, NewHeight, 32)
5121 IF __UI_DesignMode THEN Control(NextSlot).Stretch = True
5122 Control(NextSlot).Align = __UI_Center
5123 Control(NextSlot).VAlign = __UI_Middle
5124 END IF
5125
5126 IF ControlType = __UI_Type_Label AND __UI_DesignMode THEN Control(NextSlot).VAlign = __UI_Middle
5127
5128 __UI_NewControl = NextSlot
5129END FUNCTION
5130
5131'---------------------------------------------------------------------------------
5132SUB __UI_DestroyControl (This AS __UI_ControlTYPE)
5133 DIM i AS LONG, uw AS LONG
5134
5135 __UI_AutoRefresh = False
5136
5137 IF This.ID > 0 THEN
5138 Caption(This.ID) = ""
5139 __UI_TempCaptions(This.ID) = ""
5140 Text(This.ID) = ""
5141 __UI_TempTexts(This.ID) = ""
5142 ToolTip(This.ID) = ""
5143 __UI_TempTips(This.ID) = ""
5144 Mask(This.ID) = ""
5145
5146 IF This.Type = __UI_Type_ListBox THEN
5147 IF __UI_ActiveDropdownList = This.ID THEN
5148 __UI_ActiveDropdownList = 0
5149 __UI_ParentDropdownList = 0
5150 END IF
5151 ELSEIF This.Type = __UI_Type_MenuPanel THEN
5152 FOR i = 1 TO UBOUND(Control)
5153 IF Control(i).MenuPanelID = This.ID THEN
5154 IF Control(i).ControlIsSelected THEN
5155 Control(i).ControlIsSelected = False
5156 END IF
5157 END IF
5158 NEXT
5159 IF Control(This.SourceControl).Type = __UI_Type_ContextMenu THEN
5160 __UI_ActiveMenuIsContextMenu = False
5161 END IF
5162 __UI_TotalActiveMenus = __UI_TotalActiveMenus - 1
5163 IF __UI_TotalActiveMenus < 0 THEN __UI_TotalActiveMenus = 0
5164 END IF
5165
5166 __UI_Type(This.Type).Count = __UI_Type(This.Type).Count - 1
5167
5168 'Check if this was the last control using this font
5169 IF This.Font > 0 AND This.Font <> 8 AND This.Font <> 16 THEN
5170 FOR i = 1 TO UBOUND(Control)
5171 IF Control(i).Type <> __UI_Type_Font THEN
5172 IF This.ID <> i AND This.Font = Control(i).Font THEN EXIT FOR
5173 END IF
5174 NEXT
5175 IF i > UBOUND(Control) THEN
5176 __UI_DestroyControl Control(__UI_GetFontID(This.Font))
5177 This.Font = 0
5178 END IF
5179 ELSE
5180 This.Font = 0
5181 END IF
5182 END IF
5183
5184 DIM EmptyControl AS __UI_ControlTYPE
5185
5186 IF This.Canvas <> 0 THEN _FREEIMAGE This.Canvas: This.Canvas = 0
5187 IF This.HelperCanvas <> 0 THEN _FREEIMAGE This.HelperCanvas: This.HelperCanvas = 0
5188 IF This.ControlIsSelected THEN This.ControlIsSelected = False: __UI_TotalSelectedControls = __UI_TotalSelectedControls - 1
5189
5190 uw& = GetControlDrawOrder(This.ID)
5191 ControlDrawOrder(uw&) = 0
5192 This = EmptyControl
5193
5194 __UI_HasMenuBar = (__UI_FirstMenuBarControl > 0)
5195
5196 __UI_AutoRefresh = True
5197END SUB
5198
5199'---------------------------------------------------------------------------------
5200SUB SetCaption (ThisID AS LONG, TempCaption$)
5201 DIM FindSep%, NewCaption$, FindEscape%
5202 DIM PrevFont AS LONG, TempCanvas AS LONG, PrevDest AS LONG
5203
5204 IF ThisID = 0 THEN EXIT SUB
5205
5206 NewCaption$ = RestoreCHR$(TempCaption$)
5207
5208 'Parse for hotkey markers
5209 StartSearchForSep:
5210 FindSep% = INSTR(FindSep% + 1, NewCaption$, "&")
5211 IF FindSep% > 0 AND FindSep% < LEN(NewCaption$) THEN
5212 IF FindSep% > 1 THEN
5213 IF ASC(NewCaption$, FindSep% - 1) = 92 THEN
5214 '\& doesnt count as a hot key marker as the backslash
5215 'serves as an escape character
5216 GOTO StartSearchForSep
5217 END IF
5218 END IF
5219 NewCaption$ = LEFT$(NewCaption$, FindSep% - 1) + MID$(NewCaption$, FindSep% + 1)
5220 Control(ThisID).HotKey = ASC(UCASE$(NewCaption$), FindSep%)
5221 Control(ThisID).HotKeyPosition = FindSep%
5222
5223 FindEscape% = INSTR(NewCaption$, "\&")
5224 DO WHILE FindEscape% > 0
5225 IF FindEscape% < FindSep% THEN
5226 FindSep% = FindSep% - 1
5227 END IF
5228 NewCaption$ = LEFT$(NewCaption$, FindEscape% - 1) + MID$(NewCaption$, FindEscape% + 1)
5229 FindEscape% = INSTR(NewCaption$, "\&")
5230 LOOP
5231
5232 PrevFont = _FONT
5233
5234 IF _PIXELSIZE = 0 THEN
5235 'Temporarily create a 32bit screen for proper font handling, in case
5236 'we're still at form setup (SCREEN 0)
5237 TempCanvas = _NEWIMAGE(10, 10, 32)
5238 PrevDest = _DEST
5239 _DEST TempCanvas
5240 END IF
5241
5242 _FONT (Control(ThisID).Font)
5243 IF Control(ThisID).HotKeyPosition = 1 THEN
5244 Control(ThisID).HotKeyOffset = 0
5245 ELSE
5246 Control(ThisID).HotKeyOffset = __UI_PrintWidth(LEFT$(NewCaption$, Control(ThisID).HotKeyPosition - 1))
5247 END IF
5248
5249 IF TempCanvas <> 0 THEN
5250 _DEST PrevDest
5251 _FREEIMAGE TempCanvas
5252 END IF
5253 _FONT PrevFont
5254 ELSE
5255 Control(ThisID).HotKey = 0
5256 END IF
5257
5258 'Replace \n for line breaks:
5259 NewCaption$ = Replace$(NewCaption$, "\n", CHR$(10), False, 0)
5260
5261 Caption(ThisID) = NewCaption$
5262END SUB
5263
5264'---------------------------------------------------------------------------------
5265SUB BeginDraw(ThisID AS LONG)
5266 IF Control(ThisID).Type <> __UI_Type_PictureBox THEN EXIT SUB
5267 _DEST Control(ThisID).HelperCanvas
5268END SUB
5269
5270'---------------------------------------------------------------------------------
5271SUB EndDraw(ThisID AS LONG)
5272 IF Control(ThisID).Type <> __UI_Type_PictureBox THEN EXIT SUB
5273 _DEST 0
5274 Control(ThisID).Redraw = True
5275END SUB
5276
5277'---------------------------------------------------------------------------------
5278SUB LoadImage (This AS __UI_ControlTYPE, File$)
5279 DIM PrevDest AS LONG, ErrorMessage$
5280 STATIC NotFoundImage AS LONG
5281
5282 IF This.HelperCanvas <> 0 THEN _FREEIMAGE This.HelperCanvas
5283
5284 IF _FILEEXISTS(File$) THEN
5285 This.HelperCanvas = _LOADIMAGE(File$, 32)
5286 IF This.HelperCanvas >= -1 THEN
5287 'Maybe it's an .ICO file
5288 This.HelperCanvas = IconPreview(File$)
5289 IF This.HelperCanvas >= -1 THEN ErrorMessage$ = "Unable to load file:"
5290 END IF
5291 ELSE
5292 IF File$ = "" THEN
5293 'Passing an empty file name can be used to clean the canvas
5294 IF This.Type = __UI_Type_PictureBox THEN
5295 This.HelperCanvas = _NEWIMAGE(This.Width, This.Height, 32)
5296 END IF
5297 ELSE
5298 ErrorMessage$ = "Missing image file:"
5299 END IF
5300 END IF
5301
5302 IF LEN(ErrorMessage$) THEN
5303 IF NotFoundImage = 0 THEN NotFoundImage = __UI_LoadThemeImage("notfound.png")
5304
5305 PrevDest = _DEST
5306 This.HelperCanvas = _NEWIMAGE(This.Width, This.Height, 32)
5307 _DEST This.HelperCanvas
5308 _PRINTMODE _KEEPBACKGROUND
5309 _FONT (This.Font)
5310 CLS , _RGBA32(0, 0, 0, 0)
5311 'Place the "missing" icon
5312 _PUTIMAGE (This.Width / 2 - _WIDTH(NotFoundImage) / 2, This.Height / 2 - _HEIGHT(NotFoundImage) / 2), NotFoundImage
5313
5314 COLOR This.ForeColor
5315 __UI_PrintString 5, 5, ErrorMessage$
5316 __UI_PrintString 5, 5 + uspacing&, File$
5317 _DEST PrevDest
5318 Text(This.ID) = ""
5319 ELSE
5320 IF This.Type = __UI_Type_PictureBox OR This.Type = __UI_Type_Button OR This.Type = __UI_Type_MenuItem THEN
5321 Text(This.ID) = File$
5322 END IF
5323 END IF
5324 This.Redraw = True
5325END SUB
5326
5327'---------------------------------------------------------------------------------
5328SUB __UI_ClearColor (Image&, Left AS _UNSIGNED LONG, Top AS INTEGER)
5329 'This SUB may be invoked with two syntaxes:
5330 ' __UI_ClearColor Image&, Left, Top
5331 ' In which case the color at the (left,top) coordinate will be read and then cleared
5332 'OR
5333 ' __UI_ClearColor Image&, Color, -1
5334 ' In which case the 32bit color provided will be cleared
5335
5336 DIM PrevSource AS LONG
5337
5338 IF NOT Image& < -1 THEN EXIT SUB
5339
5340 IF Top = -1 THEN
5341 _CLEARCOLOR Left, Image&
5342 ELSE
5343 PrevSource = _SOURCE
5344 _SOURCE Image&
5345 _CLEARCOLOR POINT(Left, Top), Image&
5346 _SOURCE PrevSource
5347 END IF
5348END SUB
5349
5350'---------------------------------------------------------------------------------
5351SUB __UI_ClearHelperCanvasColor (This AS __UI_ControlTYPE, Left AS INTEGER, Top AS INTEGER)
5352 DIM PrevSource AS LONG
5353
5354 IF NOT This.HelperCanvas < -1 THEN EXIT SUB
5355
5356 PrevSource = _SOURCE
5357 _SOURCE This.HelperCanvas
5358 This.TransparentColor = POINT(Left, Top)
5359 _CLEARCOLOR This.TransparentColor, This.HelperCanvas
5360 _SOURCE PrevSource
5361END SUB
5362
5363'---------------------------------------------------------------------------------
5364FUNCTION __UI_LoadThemeImage& (FileName$)
5365 'Contains portions of Dav's BIN2BAS
5366 'http://www.qbasicnews.com/dav/qb64.php
5367
5368 DIM A$, i&, B$, C%, F$, C$, t%, B&, X$, btemp$, BASFILE$
5369 DIM MemoryBlock AS _MEM, TempImage AS LONG, NextSlot AS LONG
5370 DIM NewWidth AS INTEGER, NewHeight AS INTEGER
5371
5372 'Check if this FileName$ has already been loaded
5373 FOR NextSlot = 1 TO UBOUND(__UI_ThemeImages)
5374 IF UCASE$(RTRIM$(__UI_ThemeImages(NextSlot).FileName)) = UCASE$(FileName$) THEN
5375 __UI_LoadThemeImage& = __UI_ThemeImages(NextSlot).Handle
5376 EXIT FUNCTION
5377 ELSEIF RTRIM$(__UI_ThemeImages(NextSlot).FileName) = "" THEN
5378 'Found an empty slot
5379 END IF
5380 NEXT
5381
5382 A$ = __UI_ImageData$(FileName$)
5383 IF LEN(A$) = 0 THEN EXIT FUNCTION
5384
5385 NewWidth = CVI(LEFT$(A$, 2))
5386 NewHeight = CVI(MID$(A$, 3, 2))
5387 A$ = MID$(A$, 5)
5388
5389 FOR i& = 1 TO LEN(A$) STEP 4: B$ = MID$(A$, i&, 4)
5390 IF INSTR(1, B$, "%") THEN
5391 FOR C% = 1 TO LEN(B$): F$ = MID$(B$, C%, 1)
5392 IF F$ <> "%" THEN C$ = C$ + F$
5393 NEXT: B$ = C$
5394 END IF: FOR t% = LEN(B$) TO 1 STEP -1
5395 B& = B& * 64 + ASC(MID$(B$, t%)) - 48
5396 NEXT: X$ = "": FOR t% = 1 TO LEN(B$) - 1
5397 X$ = X$ + CHR$(B& AND 255): B& = B& \ 256
5398 NEXT: btemp$ = btemp$ + X$: NEXT
5399 BASFILE$ = btemp$
5400
5401 TempImage = _NEWIMAGE(NewWidth, NewHeight, 32)
5402 MemoryBlock = _MEMIMAGE(TempImage)
5403
5404 __UI_MemCopy MemoryBlock.OFFSET, _OFFSET(BASFILE$), LEN(BASFILE$)
5405 _MEMFREE MemoryBlock
5406
5407 IF NextSlot > UBOUND(__UI_ThemeImages) THEN
5408 'No empty slots. We must increase __UI_ThemeImages()
5409 REDIM _PRESERVE __UI_ThemeImages(0 TO NextSlot + 99) AS __UI_ThemeImagesType
5410 END IF
5411 __UI_ThemeImages(NextSlot).FileName = FileName$
5412 __UI_ThemeImages(NextSlot).Handle = TempImage
5413
5414 __UI_LoadThemeImage& = TempImage
5415END FUNCTION
5416
5417'---------------------------------------------------------------------------------
5418SUB SetRadioButtonValue (id AS LONG)
5419 'Radio buttons will change value of others in the same group
5420 'Also works for menus with the .BulletStyle set to __UI_Bullet
5421 DIM i AS LONG
5422
5423 IF Control(id).Type = __UI_Type_MenuItem AND Control(id).BulletStyle <> __UI_Bullet THEN
5424 Control(id).Value = NOT Control(id).Value
5425 EXIT SUB
5426 END IF
5427
5428 IF Control(id).Type = __UI_Type_MenuItem OR Control(id).Type = __UI_Type_RadioButton THEN
5429 FOR i = 1 TO UBOUND(Control)
5430 SELECT CASE Control(id).Type
5431 CASE __UI_Type_RadioButton
5432 IF Control(i).Type = __UI_Type_RadioButton AND Control(i).ParentID = Control(id).ParentID THEN
5433 IF Control(i).Value THEN
5434 Control(i).Value = False
5435 __UI_ValueChanged i
5436 END IF
5437 END IF
5438 CASE __UI_Type_MenuItem
5439 IF (Control(i).Type = __UI_Type_MenuItem AND Control(i).BulletStyle = __UI_Bullet) AND Control(i).ParentID = Control(id).ParentID THEN
5440 IF Control(i).MenuItemGroup = Control(id).MenuItemGroup THEN
5441 Control(i).Value = False
5442 END IF
5443 END IF
5444 END SELECT
5445 NEXT
5446 Control(id).Value = True
5447 IF Control(id).Type = __UI_Type_RadioButton THEN __UI_ValueChanged id
5448 Control(id).Redraw = True
5449 END IF
5450END SUB
5451
5452'---------------------------------------------------------------------------------
5453SUB __UI_CheckSelection (id)
5454 IF NOT Control(id).Multiline THEN
5455 IF __UI_ShiftIsDown THEN
5456 IF NOT Control(id).TextIsSelected THEN
5457 Control(id).TextIsSelected = True
5458 Control(id).SelectionStart = Control(id).Cursor
5459 END IF
5460 ELSE
5461 Control(id).TextIsSelected = False
5462 __UI_FillSelectedText 0, 0
5463 END IF
5464 END IF
5465END SUB
5466
5467SUB __UI_FillSelectedText(__ss1 AS LONG, __ss2 AS LONG)
5468 DIM i AS LONG
5469 i = __UI_Focus
5470 __UI_SelectedText = ""
5471 __UI_SelectionLength = 0
5472 IF Control(i).Type = __UI_Type_TextBox AND Control(i).TextIsSelected THEN
5473 DIM s1 AS LONG, s2 AS LONG
5474 DIM ss1 AS LONG, ss2 AS LONG
5475
5476 s1 = Control(i).SelectionStart
5477 s2 = Control(i).Cursor
5478 IF s1 > s2 THEN
5479 SWAP s1, s2
5480 IF Control(i).InputViewStart > 1 THEN
5481 ss1 = s1 - Control(i).InputViewStart + 1
5482 ELSE
5483 ss1 = s1
5484 END IF
5485 ss2 = s2 - s1
5486 IF ss1 + ss2 > Control(i).FieldArea THEN ss2 = Control(i).FieldArea - ss1
5487 ELSE
5488 ss1 = s1
5489 ss2 = s2 - s1
5490 IF ss1 < Control(i).InputViewStart THEN ss1 = 0: ss2 = s2 - Control(i).InputViewStart + 1
5491 IF ss1 > Control(i).InputViewStart THEN ss1 = ss1 - Control(i).InputViewStart + 1: ss2 = s2 - s1
5492 END IF
5493
5494 __UI_SelectedText = MID$(Text(i), s1 + 1, s2 - s1)
5495 __UI_SelectionLength = LEN(__UI_SelectedText)
5496 __ss1 = ss1
5497 __ss2 = ss2
5498 END IF
5499END SUB
5500
5501'---------------------------------------------------------------------------------
5502SUB __UI_DeleteSelection
5503 DIM s1 AS LONG, s2 AS LONG
5504
5505 IF NOT Control(__UI_Focus).Multiline THEN
5506 s1 = Control(__UI_Focus).SelectionStart
5507 s2 = Control(__UI_Focus).Cursor
5508 IF s1 > s2 THEN SWAP s1, s2
5509 Text(__UI_Focus) = LEFT$(Text(__UI_Focus), s1) + MID$(Text(__UI_Focus), s2 + 1)
5510 Control(__UI_Focus).TextIsSelected = False
5511 __UI_FillSelectedText 0, 0
5512 Control(__UI_Focus).Cursor = s1
5513 END IF
5514END SUB
5515
5516'---------------------------------------------------------------------------------
5517SUB __UI_DeleteSelectionMasked
5518 DIM s1 AS LONG, s2 AS LONG
5519
5520 s1 = Control(__UI_Focus).SelectionStart
5521 s2 = Control(__UI_Focus).Cursor
5522 IF s1 > s2 THEN SWAP s1, s2
5523 MID$(Text(__UI_Focus), s1 + 1, s2 - s1) = MID$(__UI_EmptyMask$(__UI_Focus), s1 + 1, s2 - s1)
5524 Control(__UI_Focus).TextIsSelected = False
5525 __UI_FillSelectedText 0, 0
5526 Control(__UI_Focus).Cursor = s1
5527END SUB
5528
5529'---------------------------------------------------------------------------------
5530SUB __UI_CursorAdjustments(This AS LONG)
5531 IF NOT Control(This).Multiline AND Control(This).Type = __UI_Type_TextBox THEN
5532 IF Control(This).VisibleCursor >= (Control(This).Width - ((Control(This).BorderSize + __UI_DefaultCaptionIndent) * ABS(Control(This).HasBorder))) THEN
5533 Control(This).InputViewStart = __UI_FocusedTextBoxChars(Control(This).Cursor) - Control(This).Width / 2 'Control(This).InputViewStart + Control(This).Width / 4
5534 ELSEIF Control(This).VisibleCursor <= 0 THEN
5535 Control(This).InputViewStart = __UI_FocusedTextBoxChars(Control(This).Cursor) - Control(This).Width / 2 'Control(This).InputViewStart - Control(This).Width / 4
5536 END IF
5537 IF Control(This).InputViewStart < 0 THEN Control(This).InputViewStart = 0
5538 ELSEIF Control(This).Multiline AND Control(This).Type = __UI_Type_TextBox THEN
5539 'DIM ThisLineStart AS LONG, ThisLineLen AS LONG
5540 'ThisLineLen = LEN(__UI_GetTextBoxLine(This, Control(This).CurrentLine, ThisLineStart))
5541 'IF Control(This).VisibleCursor > ThisLineLen THEN Control(This).VisibleCursor = ThisLineLen
5542 'IF Control(This).VisibleCursor > Control(This).PrevVisibleCursor THEN
5543 ' IF Control(This).VisibleCursor - Control(This).InputViewStart + 2 > Control(This).FieldArea THEN Control(This).InputViewStart = (Control(This).VisibleCursor - Control(This).FieldArea) + 2
5544 'ELSEIF Control(This).VisibleCursor < Control(This).PrevVisibleCursor THEN
5545 ' IF Control(This).VisibleCursor < Control(This).InputViewStart - 1 THEN Control(This).InputViewStart = Control(This).VisibleCursor
5546 'END IF
5547 'IF Control(This).InputViewStart < 1 THEN Control(This).InputViewStart = 1
5548 END IF
5549END SUB
5550
5551'---------------------------------------------------------------------------------
5552FUNCTION Replace$ (TempText$, SubString$, NewString$, CaseSensitive AS _BYTE, TotalReplacements AS LONG)
5553 DIM FindSubString AS LONG, Text$
5554
5555 IF LEN(TempText$) = 0 THEN EXIT SUB
5556
5557 Text$ = TempText$
5558 TotalReplacements = 0
5559 DO
5560 IF CaseSensitive THEN
5561 FindSubString = INSTR(FindSubString + 1, Text$, SubString$)
5562 ELSE
5563 FindSubString = INSTR(FindSubString + 1, UCASE$(Text$), UCASE$(SubString$))
5564 END IF
5565 IF FindSubString = 0 THEN EXIT DO
5566 IF LEFT$(SubString$, 1) = "\" THEN 'Escape sequence
5567 'Replace the Substring if it's not preceeded by another backslash
5568 IF MID$(Text$, FindSubstring - 1, 1) <> "\" THEN
5569 Text$ = LEFT$(Text$, FindSubString - 1) + NewString$ + MID$(Text$, FindSubString + LEN(SubString$))
5570 TotalReplacements = TotalReplacements + 1
5571 END IF
5572 ELSE
5573 Text$ = LEFT$(Text$, FindSubString - 1) + NewString$ + MID$(Text$, FindSubString + LEN(SubString$))
5574 TotalReplacements = TotalReplacements + 1
5575 END IF
5576 LOOP
5577
5578 Replace$ = Text$
5579END FUNCTION
5580
5581'---------------------------------------------------------------------------------
5582FUNCTION __UI_CountLines&(id AS LONG)
5583 DIM FindLF AS LONG, TotalLines AS LONG
5584
5585 IF LEN(Text(id)) = 0 THEN EXIT FUNCTION
5586
5587 FindLF = INSTR(Text(id), CHR$(10))
5588 IF FindLF = 0 THEN
5589 __UI_CountLines& = 1
5590 EXIT FUNCTION
5591 END IF
5592
5593 'There are at least two lines, as one line break was found.
5594 'The search continues from there
5595 TotalLines = 2
5596 DO
5597 FindLF = INSTR(FindLF + 1, Text(id), CHR$(10))
5598 IF FindLF = 0 THEN
5599 __UI_CountLines& = TotalLines
5600 EXIT FUNCTION
5601 END IF
5602 TotalLines = TotalLines + 1
5603 LOOP
5604END FUNCTION
5605
5606'---------------------------------------------------------------------------------
5607FUNCTION __UI_GetTextBoxLine$ (id AS LONG, LineNumber AS LONG, StartPosition AS LONG)
5608 'StartPosition is a return parameter
5609
5610 DIM This AS __UI_ControlTYPE, ThisLine AS LONG, FindLF AS LONG, LastLF AS LONG
5611
5612 This = Control(id)
5613
5614 StartPosition = 1
5615
5616 IF NOT This.MultiLine THEN
5617 __UI_GetTextBoxLine$ = Text(id)
5618 EXIT FUNCTION
5619 END IF
5620
5621 FindLF = INSTR(Text(id), CHR$(10))
5622 IF LineNumber = 1 THEN
5623 IF FindLF = 0 THEN
5624 __UI_GetTextBoxLine$ = Text(id)
5625 EXIT FUNCTION
5626 ELSE
5627 __UI_GetTextBoxLine$ = LEFT$(Text(id), FindLF - 1)
5628
5629 EXIT FUNCTION
5630 END IF
5631 END IF
5632
5633 'Scan forward until the desired line is reached or
5634 'until the end of the text is found:
5635 ThisLine = 2
5636 DO
5637 LastLF = FindLF
5638 FindLF = INSTR(LastLF + 1, Text(id), CHR$(10))
5639 IF FindLF > 0 THEN
5640 IF ThisLine = LineNumber THEN
5641 __UI_GetTextBoxLine$ = MID$(Text(id), LastLF + 1, FindLF - LastLF - 1)
5642 StartPosition = LastLF + 1
5643 EXIT FUNCTION
5644 END IF
5645 ELSE
5646 IF ThisLine = LineNumber THEN
5647 __UI_GetTextBoxLine$ = MID$(Text(id), LastLF + 1)
5648 StartPosition = LastLF + 1
5649 END IF
5650 EXIT FUNCTION
5651 END IF
5652 ThisLine = ThisLine + 1
5653 LOOP
5654 'We reached the end of the text. LineNumber seems to not exist.
5655 StartPosition = 0
5656END FUNCTION
5657
5658'---------------------------------------------------------------------------------
5659SUB AddItem (WhichListBox AS LONG, TempItem$)
5660 DIM ThisID AS LONG, prevFont AS LONG
5661 DIM BorderOffset AS INTEGER, Item$
5662
5663 ThisID = WhichListBox
5664 IF Control(ThisID).Type <> __UI_Type_ListBox AND Control(ThisID).Type <> __UI_Type_DropdownList THEN EXIT SUB
5665
5666 Item$ = Replace$(RestoreCHR$(TempItem$), CHR$(10), CHR$(13), False, 0)
5667
5668 IF LEN(Text(ThisID)) > 0 AND RIGHT$(Text(ThisID), 1) <> CHR$(10) THEN Text(ThisID) = Text(ThisID) + CHR$(10)
5669
5670 Text(ThisID) = Text(ThisID) + Item$ + CHR$(10)
5671 Control(ThisID).Max = Control(ThisID).Max + 1
5672
5673 IF Control(ThisID).AutoScroll THEN
5674 prevFont = _FONT
5675 BorderOffset = ABS(Control(ThisID).HasBorder) * 5
5676
5677 _FONT Control(ThisID).Font
5678 IF Control(ThisID).Max > FIX((Control(ThisID).Height - BorderOffset) / Control(ThisID).ItemHeight) THEN
5679 Control(ThisID).InputViewStart = Control(ThisID).Max - FIX((Control(ThisID).Height - BorderOffset) / Control(ThisID).ItemHeight) + 1
5680 END IF
5681 _FONT prevFont
5682 END IF
5683 Control(ThisID).LastVisibleItem = 0 'Reset this var so it'll be recalculated
5684 Control(ThisID).Redraw = True
5685END SUB
5686
5687'---------------------------------------------------------------------------------
5688SUB RemoveItem (WhichListBox AS LONG, ItemToRemove AS INTEGER)
5689 DIM This AS __UI_ControlTYPE, TempText$, ThisItem%, FindLF&, TempCaption$
5690
5691 This = Control(WhichListBox)
5692 IF This.Type <> __UI_Type_ListBox AND This.Type <> __UI_Type_DropdownList THEN EXIT SUB
5693
5694 IF ItemToRemove > This.Max THEN EXIT SUB
5695
5696 TempText$ = Text(This.ID)
5697 Text(This.ID) = ""
5698
5699 ThisItem% = 0
5700 DO WHILE LEN(TempText$)
5701 ThisItem% = ThisItem% + 1
5702 FindLF& = INSTR(TempText$, CHR$(10))
5703 IF FindLF& THEN
5704 TempCaption$ = LEFT$(TempText$, FindLF& - 1)
5705 TempText$ = MID$(TempText$, FindLF& + 1)
5706 ELSE
5707 TempCaption$ = TempText$
5708 TempText$ = ""
5709 END IF
5710
5711 IF ThisItem% <> ItemToRemove THEN Text(This.ID) = Text(This.ID) + TempCaption$ + CHR$(13)
5712 LOOP
5713
5714 This.Max = This.Max - 1
5715 This.LastVisibleItem = 0 'Reset this var so it'll be recalculated
5716 IF This.Value = ItemToRemove THEN
5717 This.Value = 0
5718 ELSEIF This.Value > ItemToRemove THEN
5719 This.Value = This.Value - 1
5720 END IF
5721
5722 Control(This.ID) = This
5723 Control(This.ID).Redraw = True
5724END SUB
5725
5726'---------------------------------------------------------------------------------
5727SUB ResetList (WhichListBox AS LONG)
5728 DIM This AS __UI_ControlTYPE
5729
5730 This = Control(WhichListBox)
5731 IF This.Type <> __UI_Type_ListBox AND This.Type <> __UI_Type_DropdownList THEN EXIT SUB
5732
5733 Text(This.ID) = ""
5734
5735 This.Max = 0
5736 This.LastVisibleItem = 0 'Reset this var so it'll be recalculated
5737 This.InputViewStart = 1
5738 This.Value = 0
5739
5740 Control(This.ID) = This
5741 Control(This.ID).Redraw = True
5742END SUB
5743
5744'---------------------------------------------------------------------------------
5745SUB ReplaceItem (WhichListBox AS LONG, ItemToReplace AS INTEGER, NewText$)
5746 DIM This AS __UI_ControlTYPE, TempText$, ThisItem%, FindLF&, TempCaption$
5747
5748 This = Control(WhichListBox)
5749 IF This.Type <> __UI_Type_ListBox AND This.Type <> __UI_Type_DropdownList THEN EXIT SUB
5750
5751 IF ItemToReplace > This.Max THEN EXIT SUB
5752
5753 TempText$ = Text(This.ID)
5754 Text(This.ID) = ""
5755
5756 ThisItem% = 0
5757 DO WHILE LEN(TempText$)
5758 ThisItem% = ThisItem% + 1
5759 FindLF& = INSTR(TempText$, CHR$(10))
5760 IF FindLF& THEN
5761 TempCaption$ = LEFT$(TempText$, FindLF& - 1)
5762 TempText$ = MID$(TempText$, FindLF& + 1)
5763 ELSE
5764 TempCaption$ = TempText$
5765 TempText$ = ""
5766 END IF
5767
5768 IF ThisItem% <> ItemToReplace THEN
5769 Text(This.ID) = Text(This.ID) + TempCaption$ + CHR$(10)
5770 ELSE
5771 Text(This.ID) = Text(This.ID) + NewText$ + CHR$(10)
5772 END IF
5773 LOOP
5774 Control(This.ID).Redraw = True
5775END SUB
5776
5777'---------------------------------------------------------------------------------
5778FUNCTION SelectItem%% (id AS LONG, __Item$)
5779 'Locates first item in ListBox 'id' that matches Item$;
5780 'Sets .Value; returns True when found;
5781 DIM b$, Item$, i AS LONG
5782
5783 IF Control(id).Type <> __UI_Type_ListBox AND Control(id).Type <> __UI_Type_DropdownList THEN
5784 EXIT FUNCTION
5785 END IF
5786
5787 Item$ = RTRIM$(LTRIM$(__Item$))
5788 IF LEN(Item$) = 0 THEN EXIT FUNCTION
5789
5790 FOR i = 1 TO Control(id).Max
5791 b$ = GetItem$(id, i)
5792 IF b$ = Item$ THEN
5793 Control(id).Value = i
5794 Control(id).Redraw = True
5795 SelectItem%% = True
5796 EXIT FUNCTION
5797 END IF
5798 NEXT
5799END FUNCTION
5800
5801'---------------------------------------------------------------------------------
5802FUNCTION GetItem$ (id AS LONG, Item AS LONG)
5803 DIM This AS __UI_ControlTYPE, ThisItem AS LONG, FindLF AS LONG, LastLF AS LONG
5804
5805 This = Control(id)
5806
5807 FindLF = INSTR(Text(id), CHR$(10))
5808 IF Item = 1 THEN
5809 IF FindLF = 0 THEN
5810 GetItem$ = Text(id)
5811 EXIT FUNCTION
5812 ELSE
5813 GetItem$ = LEFT$(Text(id), FindLF - 1)
5814 EXIT FUNCTION
5815 END IF
5816 END IF
5817
5818 'Scan forward until the desired item is reached or
5819 'until the end of the text is found:
5820 ThisItem = 2
5821 DO
5822 LastLF = FindLF
5823 FindLF = INSTR(LastLF + 1, Text(id), CHR$(10))
5824 IF FindLF > 0 THEN
5825 IF ThisItem = Item THEN
5826 GetItem$ = MID$(Text(id), LastLF + 1, FindLF - LastLF - 1)
5827 EXIT FUNCTION
5828 END IF
5829 ELSE
5830 IF ThisItem = Item THEN
5831 GetItem$ = MID$(Text(id), LastLF + 1)
5832 END IF
5833 EXIT FUNCTION
5834 END IF
5835 ThisItem = ThisItem + 1
5836 LOOP
5837 'We reached the end of the text. Item seems to not exist.
5838END FUNCTION
5839
5840'---------------------------------------------------------------------------------
5841SUB __UI_ListBoxSearchItem (This AS __UI_ControlTYPE)
5842 STATIC SearchPattern$, LastListKeyHit AS SINGLE
5843 DIM ThisItem%, FindLF&, TempCaption$, TempText$
5844 DIM ListItems$(1 TO This.Max)
5845
5846 TempText$ = Text(This.ID)
5847 DO WHILE LEN(TempText$)
5848 ThisItem% = ThisItem% + 1
5849 FindLF& = INSTR(TempText$, CHR$(10))
5850 IF FindLF& THEN
5851 TempCaption$ = LEFT$(TempText$, FindLF& - 1)
5852 TempText$ = MID$(TempText$, FindLF& + 1)
5853 ELSE
5854 TempCaption$ = TempText$
5855 TempText$ = ""
5856 END IF
5857
5858 ListItems$(ThisItem%) = TempCaption$
5859 LOOP
5860
5861 IF TIMER - LastListKeyHit < 1 THEN
5862 SearchPattern$ = SearchPattern$ + UCASE$(CHR$(__UI_KeyHit))
5863 ThisItem% = This.Value
5864 ELSE
5865 SearchPattern$ = UCASE$(CHR$(__UI_KeyHit))
5866 ThisItem% = This.Value + 1
5867 IF ThisItem% > This.Max THEN ThisItem% = 1
5868 END IF
5869
5870 DO
5871 IF UCASE$(LEFT$(ListItems$(ThisItem%), LEN(SearchPattern$))) = SearchPattern$ THEN
5872 This.Value = ThisItem%
5873 __UI_ValueChanged This.ID
5874 EXIT DO
5875 END IF
5876 ThisItem% = ThisItem% + 1
5877 IF ThisItem% > This.Max THEN ThisItem% = 1
5878 IF ThisItem% = This.Value THEN EXIT DO
5879 LOOP
5880
5881 LastListKeyHit = TIMER
5882END SUB
5883
5884'---------------------------------------------------------------------------------
5885SUB __UI_PrintString(Left AS INTEGER, Top AS INTEGER, Text$)
5886 DIM Utf$
5887
5888 IF LEFT$(Text$, 1) = CHR$(7) AND (_FONT = 8 OR _FONT = 16) THEN
5889 Utf$ = Text$
5890 ELSE
5891 IF Control(__UI_FormID).Encoding = 1252 THEN
5892 Utf$ = FromCP1252$(Text$)
5893 ELSE 'Default to 437
5894 Utf$ = FromCP437$(Text$)
5895 END IF
5896 END IF
5897
5898 REDIM __UI_ThisLineChars(0 TO LEN(Utf$)) AS LONG
5899 uprint_extra Left, Top, _OFFSET(Utf$), LEN(Utf$), True, True, __UI_LastRenderedLineWidth, _OFFSET(__UI_ThisLineChars()), __UI_LastRenderedCharCount, _DEFAULTCOLOR, 0
5900 REDIM _PRESERVE __UI_ThisLineChars(__UI_LastRenderedCharCount) AS LONG
5901END SUB
5902
5903'---------------------------------------------------------------------------------
5904FUNCTION __UI_PrintWidth&(Text$)
5905 __UI_PrintWidth& = uprintwidth(Text$, LEN(Text$), 0)
5906END FUNCTION
5907
5908'---------------------------------------------------------------------------------
5909FUNCTION __UI_WordWrap$ (PassedText AS STRING, Width AS INTEGER, LongestLine AS INTEGER, Lines AS INTEGER)
5910 DIM Temp$, TempCaption$, FindSep AS LONG, PrevSep AS LONG
5911 DIM NextSlot AS LONG, TempLine$, i AS LONG, Text AS STRING
5912 DIM ThisLineWidth AS INTEGER
5913
5914 Text = RTRIM$(PassedText)
5915 IF Text = "" THEN Lines = 1: EXIT FUNCTION
5916
5917 FOR i = 1 TO UBOUND(__UI_WordWrapHistoryTexts)
5918 IF __UI_WordWrapHistoryTexts(i) = "" THEN EXIT FOR
5919 IF __UI_WordWrapHistoryTexts(i) = Text THEN
5920 'Text has been processed before. If it was under the same Width and Font,
5921 'the previously stored result is returned
5922 IF __UI_WordWrapHistory(i).Width = Width AND __UI_WordWrapHistory(i).Font = _FONT THEN
5923 __UI_WordWrap$ = __UI_WordWrapHistoryResults(i)
5924 Lines = __UI_WordWrapHistory(i).TotalLines
5925 LongestLine = __UI_WordWrapHistory(i).LongestLine
5926 EXIT FUNCTION
5927 ELSE
5928 'Otherwise, it'll be reprocessed
5929 EXIT FOR
5930 ENDIF
5931 END IF
5932 NEXT
5933
5934 NextSlot = i
5935 IF NextSlot > UBOUND(__UI_WordWrapHistory) THEN
5936 REDIM _PRESERVE __UI_WordWrapHistory(1 TO NextSlot + 99) AS __UI_WordWrapHistoryType
5937 REDIM _PRESERVE __UI_WordWrapHistoryTexts(1 TO NextSlot + 99) AS STRING
5938 REDIM _PRESERVE __UI_WordWrapHistoryResults(1 TO NextSlot + 99) AS STRING
5939 END IF
5940
5941 __UI_WordWrapHistoryTexts(NextSlot) = Text
5942 __UI_WordWrapHistory(NextSlot).Width = Width
5943 __UI_WordWrapHistory(NextSlot).Font = _FONT
5944 Lines = 0
5945 LongestLine = 0
5946 TempCaption$ = Text
5947 IF __UI_PrintWidth&(TempCaption$) > Width THEN
5948 'Word wrap is faster for fixed-width fonts.
5949 'CHR$(10) is a line break. CHR$(1) is a soft break (word wrap)
5950 DO WHILE LEN(TempCaption$)
5951 FindSep = INSTR(TempCaption$, CHR$(10)) 'process the passed text line by line
5952 IF FindSep > 0 THEN
5953 TempLine$ = LEFT$(TempCaption$, FindSep - 1)
5954 TempCaption$ = MID$(TempCaption$, FindSep + 1)
5955 ELSE
5956 TempLine$ = TempCaption$
5957 TempCaption$ = ""
5958 END IF
5959
5960 DO WHILE LEN(TempLine$)
5961 IF __UI_PrintWidth&(TempLine$) < Width THEN
5962 IF LEN(Temp$) > 0 THEN Temp$ = Temp$ + CHR$(1)
5963 ThisLineWidth = __UI_PrintWidth(Templine$)
5964 IF LongestLine < ThisLineWidth THEN LongestLine = ThisLineWidth
5965 Temp$ = Temp$ + TempLine$
5966 TempLine$ = ""
5967 Lines = Lines + 1
5968 ELSE
5969 PrevSep = 0
5970 DO
5971 FindSep = INSTR(PrevSep + 1, TempLine$, " ")
5972 IF FindSep > 0 THEN
5973 IF __UI_PrintWidth(LEFT$(TempLine$, FindSep - 1)) > Width THEN
5974 IF PrevSep = 0 THEN
5975 'This word alone is > than the width, can't fight that.
5976 IF LEN(Temp$) > 0 THEN Temp$ = Temp$ + CHR$(1)
5977 Temp$ = Temp$ + LEFT$(TempLine$, FindSep - 1)
5978 TempLine$ = MID$(TempLine$, FindSep + 1)
5979 Lines = Lines + 1
5980 EXIT DO
5981 ELSE
5982 IF LEN(Temp$) > 0 THEN Temp$ = Temp$ + CHR$(1)
5983 Temp$ = Temp$ + LEFT$(TempLine$, PrevSep - 1)
5984 ThisLineWidth = __UI_PrintWidth(LEFT$(TempLine$, PrevSep - 1))
5985 IF LongestLine < ThisLineWidth THEN LongestLine = ThisLineWidth
5986 TempLine$ = MID$(TempLine$, PrevSep + 1)
5987 Lines = Lines + 1
5988 EXIT DO
5989 END IF
5990 END IF
5991 PrevSep = FindSep
5992 ELSE
5993 IF PrevSep > 0 THEN
5994 IF LEN(Temp$) > 0 THEN Temp$ = Temp$ + CHR$(1)
5995 Temp$ = Temp$ + LEFT$(TempLine$, PrevSep - 1)
5996 ThisLineWidth = __UI_PrintWidth(LEFT$(TempLine$, PrevSep - 1))
5997 IF LongestLine < ThisLineWidth THEN LongestLine = ThisLineWidth
5998 TempLine$ = MID$(TempLine$, PrevSep + 1)
5999 Lines = Lines + 1
6000 EXIT DO
6001 ELSE
6002 IF LEN(Temp$) > 0 THEN Temp$ = Temp$ + CHR$(1)
6003 Temp$ = Temp$ + Templine$
6004 ThisLineWidth = __UI_PrintWidth(Templine$)
6005 IF LongestLine < ThisLineWidth THEN LongestLine = ThisLineWidth
6006 TempLine$ = ""
6007 Lines = Lines + 1
6008 EXIT DO
6009 END IF
6010 END IF
6011 LOOP
6012 END IF
6013 LOOP
6014 LOOP
6015 __UI_WordWrap$ = Temp$
6016 __UI_WordWrapHistoryResults(NextSlot) = Temp$
6017 __UI_WordWrapHistory(NextSlot).TotalLines = Lines
6018 __UI_WordWrapHistory(NextSlot).LongestLine = LongestLine
6019 ELSE
6020 'Count line breaks
6021 Lines = 1
6022 LongestLine = 0
6023 Temp$ = TempCaption$
6024 FindSep = INSTR(TempCaption$, CHR$(10))
6025 IF FindSep > 0 THEN
6026 Temp$ = ""
6027 Lines = 0
6028 DO WHILE LEN(TempCaption$)
6029 FindSep = INSTR(TempCaption$, CHR$(10))
6030 IF FindSep > 0 THEN
6031 Lines = Lines + 1
6032 IF LEN(Temp$) > 0 THEN Temp$ = Temp$ + CHR$(1)
6033 Temp$ = Temp$ + LEFT$(TempCaption$, FindSep - 1)
6034 ThisLineWidth = __UI_PrintWidth(LEFT$(TempCaption$, FindSep - 1))
6035 IF LongestLine < ThisLineWidth THEN LongestLine = ThisLineWidth
6036 TempCaption$ = MID$(TempCaption$, FindSep + 1)
6037 ELSE
6038 Lines = Lines + 1
6039 Temp$ = Temp$ + CHR$(1) + TempCaption$
6040 EXIT DO
6041 END IF
6042 LOOP
6043 ELSE
6044 LongestLine = __UI_PrintWidth(TempCaption$)
6045 END IF
6046
6047 __UI_WordWrap$ = Temp$
6048 __UI_WordWrapHistoryResults(NextSlot) = Temp$
6049 __UI_WordWrapHistory(NextSlot).TotalLines = Lines
6050 __UI_WordWrapHistory(NextSlot).LongestLine = LongestLine
6051 END IF
6052END FUNCTION
6053
6054'---------------------------------------------------------------------------------
6055FUNCTION MessageBox& (Message$, Title$, Setup AS LONG)
6056 _DELAY .1 'So the interface can redraw before the messagebox kicks in
6057
6058 IF Title$ = "" THEN Title$ = __UI_CurrentTitle
6059
6060 $IF WIN THEN
6061 MessageBox& = __UI_MB(0, Replace(Message$, "\n", CHR$(10), False, 0) + CHR$(0), Title$ + CHR$(0), Setup + MsgBox_SystemModal + MsgBox_SetForeground)
6062 $ELSE
6063 IF (Setup AND 4) THEN
6064 MessageBox& = __UI_MB(0, Replace(Message$, "\n", CHR$(10), False, 0) + CHR$(0), Title$ + CHR$(0), 4)
6065 ELSE
6066 MessageBox& = __UI_MB(0, Replace(Message$, "\n", CHR$(10), False, 0) + CHR$(0), Title$ + CHR$(0), 0)
6067 END IF
6068 $END IF
6069END FUNCTION
6070
6071'---------------------------------------------------------------------------------
6072FUNCTION __UI_MAP! (value!, minRange!, maxRange!, newMinRange!, newMaxRange!)
6073 __UI_MAP! = ((value! - minRange!) / (maxRange! - minRange!)) * (newMaxRange! - newMinRange!) + newMinRange!
6074END FUNCTION
6075
6076'---------------------------------------------------------------------------------
6077SUB __UI_ActivateDropdownlist (This AS __UI_ControlTYPE)
6078 IF NOT This.Disabled THEN
6079 __UI_ParentDropdownList = This.ID
6080 __UI_ActiveDropdownList = __UI_NewControl(__UI_Type_ListBox, RTRIM$(This.Name) + CHR$(254) + "DropdownList", 0, 0, 0, 0, 0)
6081 Text(__UI_ActiveDropdownList) = Text(This.ID)
6082 Control(__UI_ActiveDropdownList).Left = This.Left + Control(This.ParentID).Left
6083 Control(__UI_ActiveDropdownList).Width = This.Width
6084 Control(__UI_ActiveDropdownList).Top = This.Top + This.Height + Control(This.ParentID).Top
6085
6086 'Make up to 14 items visible:
6087 DIM MaxVisible AS INTEGER
6088 IF This.Max > 14 THEN MaxVisible = 14 ELSE MaxVisible = This.Max
6089
6090 _FONT This.Font
6091 Control(__UI_ActiveDropdownList).Height = (uspacing& + (((_FONT = 8) * -1) * __UI_Font8Offset + ((_FONT = 16) * -1) * __UI_Font16Offset) + 3) * (MaxVisible + .5)
6092
6093 IF Control(__UI_ActiveDropdownList).Top + Control(__UI_ActiveDropdownList).Height > Control(__UI_FormID).Height THEN
6094 Control(__UI_ActiveDropdownList).Top = Control(__UI_FormID).Height - Control(__UI_ActiveDropdownList).Height
6095 END IF
6096 Control(__UI_ActiveDropdownList).Max = This.Max
6097 Control(__UI_ActiveDropdownList).Value = This.Value
6098 Control(__UI_ActiveDropdownList).ForeColor = This.ForeColor
6099 Control(__UI_ActiveDropdownList).BackColor = This.BackColor
6100 Control(__UI_ActiveDropdownList).SelectedForeColor = This.SelectedForeColor
6101 Control(__UI_ActiveDropdownList).SelectedBackColor = This.SelectedBackColor
6102 Control(__UI_ActiveDropdownList).Font = This.Font
6103 Control(__UI_ActiveDropdownList).HasBorder = True
6104 Control(__UI_ActiveDropdownList).BorderSize = 1
6105 Control(__UI_ActiveDropdownList).BorderColor = _RGB32(0, 0, 0)
6106 Control(__UI_ActiveDropdownList).CanHaveFocus = True
6107 Control(__UI_ActiveDropdownList).InputViewStart = 1
6108 Control(__UI_ActiveDropdownList).LastVisibleItem = MaxVisible
6109 __UI_Focus = __UI_ActiveDropdownList
6110
6111 'Adjust view:
6112 IF Control(__UI_Focus).Value < Control(__UI_Focus).InputViewStart THEN
6113 Control(__UI_Focus).InputViewStart = Control(__UI_Focus).Value
6114 ELSEIF Control(__UI_Focus).Value > Control(__UI_Focus).InputViewStart + Control(__UI_Focus).LastVisibleItem - 1 THEN
6115 Control(__UI_Focus).InputViewStart = Control(__UI_Focus).Value - Control(__UI_Focus).LastVisibleItem + 1
6116 END IF
6117 END IF
6118END SUB
6119
6120'---------------------------------------------------------------------------------
6121SUB __UI_CloseAllMenus
6122 DIM i AS LONG
6123 FOR i = 1 TO UBOUND(Control)
6124 IF Control(i).Type = __UI_Type_MenuPanel THEN
6125 __UI_DestroyControl Control(i)
6126 END IF
6127 NEXT
6128END SUB
6129
6130'---------------------------------------------------------------------------------
6131FUNCTION __UI_GetActiveMenuIndex(id AS LONG)
6132 DIM i AS LONG
6133 FOR i = 1 TO __UI_TotalActiveMenus
6134 IF __UI_ActiveMenu(i) = id THEN
6135 __UI_GetActiveMenuIndex = i
6136 EXIT FUNCTION
6137 END IF
6138 NEXT
6139END FUNCTION
6140
6141'---------------------------------------------------------------------------------
6142FUNCTION __UI_GetParentMenu(id AS LONG)
6143 DIM i AS LONG
6144 FOR i = 1 TO __UI_TotalActiveMenus
6145 IF __UI_ActiveMenu(i) = id THEN
6146 __UI_GetParentMenu = __UI_ParentMenu(i)
6147 EXIT FUNCTION
6148 END IF
6149 NEXT
6150END FUNCTION
6151
6152'---------------------------------------------------------------------------------
6153SUB __UI_ActivateMenu (This AS __UI_ControlTYPE, SelectFirstItem AS _BYTE)
6154 DIM i AS LONG, ItemHeight AS SINGLE, TotalItems AS INTEGER
6155 DIM CurrentGroup AS INTEGER, ComboSpacing AS INTEGER
6156
6157 IF NOT This.Disabled THEN
6158 IF This.Type = __UI_Type_ContextMenu THEN __UI_CloseAllMenus: __UI_ForceRedraw = True
6159
6160 IF __UI_GetID(RTRIM$(This.Name) + CHR$(254) + "Panel") > 0 THEN
6161 __UI_ActiveMenu(__UI_TotalActiveMenus) = __UI_GetID(RTRIM$(This.Name) + CHR$(254) + "Panel")
6162 IF NOT __UI_DesignMode THEN EXIT SUB
6163 ELSE
6164 IF __UI_TotalActiveMenus + 1 > UBOUND(__UI_ActiveMenu) THEN
6165 EXIT SUB
6166 END IF
6167 __UI_ActiveMenu(__UI_TotalActiveMenus + 1) = __UI_NewControl(__UI_Type_MenuPanel, RTRIM$(This.Name) + CHR$(254) + "Panel", 0, 0, 0, 0, 0)
6168 __UI_TotalActiveMenus = __UI_TotalActiveMenus + 1
6169 IF __UI_ActiveMenu(__UI_TotalActiveMenus) = 0 THEN
6170 __UI_TotalActiveMenus = __UI_TotalActiveMenus - 1
6171 EXIT SUB
6172 END IF
6173 END IF
6174
6175 Control(__UI_ActiveMenu(__UI_TotalActiveMenus)).SourceControl = This.ID
6176 __UI_ParentMenu(__UI_TotalActiveMenus) = This.ID
6177 Control(__UI_ActiveMenu(__UI_TotalActiveMenus)).Font = This.Font
6178 _FONT (This.Font)
6179
6180 IF This.Type = __UI_Type_MenuBar THEN
6181 Control(__UI_ActiveMenu(__UI_TotalActiveMenus)).Left = This.Left
6182 Control(__UI_ActiveMenu(__UI_TotalActiveMenus)).Top = falcon_uspacing& + (((_FONT = 8) * -1) * __UI_Font8Offset + ((_FONT = 16) * -1) * __UI_Font16Offset) + 3
6183 __UI_TopMenuBarItem = This.ID
6184 ELSEIF This.Type = __UI_Type_MenuItem THEN
6185 Control(__UI_ActiveMenu(__UI_TotalActiveMenus)).Left = Control(This.MenuPanelID).Left + Control(This.MenuPanelID).Width - __UI_MenuItemOffset / 4
6186 Control(__UI_ActiveMenu(__UI_TotalActiveMenus)).Top = Control(This.MenuPanelID).Top + This.Top
6187 ELSEIF This.Type = __UI_Type_ContextMenu THEN
6188 IF __UI_DesignMode AND LEFT$(This.Name, 5) <> "__UI_" THEN
6189 Control(__UI_ActiveMenu(__UI_TotalActiveMenus)).Left = This.Left + This.Width
6190 Control(__UI_ActiveMenu(__UI_TotalActiveMenus)).Top = Control(__UI_FormID).Height
6191 ELSE
6192 Control(__UI_ActiveMenu(__UI_TotalActiveMenus)).Left = __UI_MouseLeft
6193 Control(__UI_ActiveMenu(__UI_TotalActiveMenus)).Top = __UI_MouseTop
6194 END IF
6195 __UI_ActiveMenuIsContextMenu = True
6196 END IF
6197
6198 'Calculate panel's width and position the menu items
6199 ItemHeight = falcon_uspacing& + (((_FONT = 8) * -1) * __UI_Font8Offset + ((_FONT = 16) * -1) * __UI_Font16Offset) + 3
6200 Control(__UI_ActiveMenu(__UI_TotalActiveMenus)).Height = (((_FONT = 8) * -1) * 3 + falcon_uspacing&) / 4
6201 Control(__UI_ActiveMenu(__UI_TotalActiveMenus)).Width = 0
6202 CurrentGroup = 1
6203 ComboSpacing = 0
6204 FOR i = 1 TO UBOUND(Control)
6205 IF Control(i).ParentID = This.ID AND NOT Control(i).Hidden THEN
6206 TotalItems = TotalItems + 1
6207 Control(i).Width = __UI_MenuItemOffset * 2 + __UI_PrintWidth(Caption(i))
6208
6209 IF Control(i).KeyCombo > 0 THEN
6210 IF __UI_MenuItemOffset + __UI_PrintWidth(RTRIM$(__UI_KeyCombo(Control(i).KeyCombo).FriendlyCombo)) > ComboSpacing THEN
6211 ComboSpacing = __UI_MenuItemOffset + __UI_PrintWidth(RTRIM$(__UI_KeyCombo(Control(i).KeyCombo).FriendlyCombo))
6212 END IF
6213 END IF
6214
6215 IF Control(__UI_ActiveMenu(__UI_TotalActiveMenus)).Width < Control(i).Width THEN
6216 Control(__UI_ActiveMenu(__UI_TotalActiveMenus)).Width = Control(i).Width
6217 END IF
6218
6219 'Reposition menu items:
6220 Control(i).Top = Control(__UI_ActiveMenu(__UI_TotalActiveMenus)).Height
6221 Control(i).Height = ItemHeight
6222
6223 'Link menu item to this panel
6224 Control(i).MenuPanelID = Control(__UI_ActiveMenu(__UI_TotalActiveMenus)).ID
6225
6226 'Grow the panel:
6227 Control(__UI_ActiveMenu(__UI_TotalActiveMenus)).Height = Control(__UI_ActiveMenu(__UI_TotalActiveMenus)).Height + ItemHeight
6228
6229 'Assign MenuItemGroup to properly handle Bullet items
6230 Control(i).MenuItemGroup = CurrentGroup
6231
6232 IF RIGHT$(Caption(i), 1) = "-" THEN 'Separator
6233 Control(__UI_ActiveMenu(__UI_TotalActiveMenus)).Height = Control(__UI_ActiveMenu(__UI_TotalActiveMenus)).Height + ItemHeight / 3
6234 CurrentGroup = CurrentGroup + 1
6235 END IF
6236 END IF
6237 NEXT
6238
6239 Control(__UI_ActiveMenu(__UI_TotalActiveMenus)).Height = Control(__UI_ActiveMenu(__UI_TotalActiveMenus)).Height + (((((_FONT = 8) * -1) * __UI_Font8Offset + ((_FONT = 16) * -1) * __UI_Font16Offset) + falcon_uspacing&) / 4)
6240
6241 IF Control(__UI_ActiveMenu(__UI_TotalActiveMenus)).Width = 0 THEN Control(__UI_ActiveMenu(__UI_TotalActiveMenus)).Width = Control(__UI_FormID).Width / 4
6242
6243 Control(__UI_ActiveMenu(__UI_TotalActiveMenus)).Width = Control(__UI_ActiveMenu(__UI_TotalActiveMenus)).Width + ComboSpacing
6244
6245 IF __UI_DesignMode AND LEFT$(This.Name, 5) <> "__UI_" THEN Control(__UI_ActiveMenu(__UI_TotalActiveMenus)).Height = Control(__UI_ActiveMenu(__UI_TotalActiveMenus)).Height + ItemHeight
6246
6247 IF Control(__UI_ActiveMenu(__UI_TotalActiveMenus)).Left + Control(__UI_ActiveMenu(__UI_TotalActiveMenus)).Width > Control(__UI_FormID).Width THEN
6248 Control(__UI_ActiveMenu(__UI_TotalActiveMenus)).Left = Control(__UI_FormID).Width - Control(__UI_ActiveMenu(__UI_TotalActiveMenus)).Width - 5
6249 IF This.Type = __UI_Type_MenuItem THEN
6250 'Sub-menus must not overlap their parent menu panel
6251 Control(__UI_ActiveMenu(__UI_TotalActiveMenus)).Left = Control(This.MenuPanelID).Left - Control(__UI_ActiveMenu(__UI_TotalActiveMenus)).Width + __UI_MenuItemOffset / 4
6252 END IF
6253 END IF
6254
6255 IF Control(__UI_ActiveMenu(__UI_TotalActiveMenus)).Top + Control(__UI_ActiveMenu(__UI_TotalActiveMenus)).Height > Control(__UI_FormID).Height THEN
6256 Control(__UI_ActiveMenu(__UI_TotalActiveMenus)).Top = Control(__UI_FormID).Height - Control(__UI_ActiveMenu(__UI_TotalActiveMenus)).Height - 5
6257 IF __UI_DesignMode AND LEFT$(This.Name, 5) <> "__UI_" THEN Control(__UI_ActiveMenu(__UI_TotalActiveMenus)).Top = Control(__UI_ActiveMenu(__UI_TotalActiveMenus)).Top - This.Height
6258 END IF
6259
6260 IF SelectFirstItem AND NOT __UI_DesignMode AND TotalItems > 0 THEN
6261 __UI_Focus = __UI_NextMenuItem(0)
6262 ELSE
6263 IF TotalItems = 0 THEN
6264 Control(__UI_ActiveMenu(__UI_TotalActiveMenus)).Width = __UI_MenuItemOffset * 2 + __UI_PrintWidth("Add new")
6265 END IF
6266 __UI_Focus = __UI_ActiveMenu(__UI_TotalActiveMenus)
6267 END IF
6268 END IF
6269END SUB
6270
6271'---------------------------------------------------------------------------------
6272SUB __UI_DoEvents
6273 __UI_ProcessInput
6274 IF __UI_HasInput THEN
6275 __UI_EventDispatcher
6276 END IF
6277END SUB
6278
6279'---------------------------------------------------------------------------------
6280FUNCTION __UI_TrimAt0$(Text$)
6281 IF INSTR(Text$, CHR$(0)) > 0 THEN
6282 __UI_TrimAt0$ = LEFT$(Text$, INSTR(Text$, CHR$(0)) - 1)
6283 ELSE
6284 __UI_TrimAt0$ = Text$
6285 END IF
6286END FUNCTION
6287
6288'---------------------------------------------------------------------------------
6289SUB __UI_MakeHardwareImageFromCanvas (This AS __UI_ControlTYPE)
6290 DIM TempCanvas AS LONG
6291
6292 IF This.ID = 0 OR This.Canvas = 0 OR __UI_DesignMode = True THEN EXIT SUB
6293
6294 'Convert to hardware images only those that aren't contained in a frame
6295 IF This.ParentID = 0 THEN
6296 TempCanvas = _COPYIMAGE(This.Canvas, 33)
6297 IF This.Canvas <> 0 THEN _FREEIMAGE This.Canvas
6298 This.Canvas = TempCanvas
6299 END IF
6300END SUB
6301
6302'---------------------------------------------------------------------------------
6303SUB __UI_MakeHardwareImage (This AS LONG)
6304 DIM TempCanvas AS LONG
6305
6306 IF __UI_DesignMode = True THEN EXIT SUB
6307
6308 TempCanvas = _COPYIMAGE(This, 33)
6309 _FREEIMAGE This
6310 This = TempCanvas
6311END SUB
6312
6313'---------------------------------------------------------------------------------
6314FUNCTION __UI_FirstMenuBarControl
6315 DIM i AS LONG
6316 FOR i = 1 TO UBOUND(Control)
6317 IF Control(i).ID > 0 AND Control(i).Type = __UI_Type_MenuBar AND NOT Control(i).Hidden THEN
6318 __UI_FirstMenuBarControl = i
6319 EXIT FUNCTION
6320 END IF
6321 NEXT
6322END FUNCTION
6323
6324'---------------------------------------------------------------------------------
6325FUNCTION __UI_NextMenuBarControl (CurrentMenuBarControl)
6326 DIM i AS LONG
6327 i = CurrentMenuBarControl
6328 DO
6329 i = i + 1
6330 IF i > UBOUND(Control) THEN i = 1
6331 IF i = CurrentMenuBarControl THEN EXIT DO
6332 IF Control(i).Type = __UI_Type_MenuBar AND NOT Control(i).Hidden AND NOT Control(i).Disabled THEN
6333 EXIT DO
6334 END IF
6335 LOOP
6336 __UI_NextMenuBarControl = i
6337END FUNCTION
6338
6339'---------------------------------------------------------------------------------
6340FUNCTION __UI_PreviousMenuBarControl (CurrentMenuBarControl)
6341 DIM i AS LONG
6342 i = CurrentMenuBarControl
6343 DO
6344 i = i - 1
6345 IF i < 1 THEN i = UBOUND(Control)
6346 IF i = CurrentMenuBarControl THEN EXIT DO
6347 IF Control(i).Type = __UI_Type_MenuBar AND NOT Control(i).Hidden AND NOT Control(i).Disabled THEN
6348 EXIT DO
6349 END IF
6350 LOOP
6351 __UI_PreviousMenuBarControl = i
6352END FUNCTION
6353
6354'---------------------------------------------------------------------------------
6355FUNCTION __UI_NextMenuItem (CurrentMenuItemControl)
6356 DIM i AS LONG
6357 i = CurrentMenuItemControl
6358 DO
6359 i = i + 1
6360 IF i > UBOUND(Control) THEN i = 1
6361 IF i = CurrentMenuItemControl THEN EXIT DO
6362 IF Control(i).Type = __UI_Type_MenuItem AND NOT Control(i).Hidden AND Control(i).ParentID = __UI_ParentMenu(__UI_TotalActiveMenus) THEN
6363 EXIT DO
6364 END IF
6365 LOOP
6366 __UI_NextMenuItem = i
6367END FUNCTION
6368
6369'---------------------------------------------------------------------------------
6370FUNCTION __UI_PreviousMenuItem (CurrentMenuItemControl)
6371 DIM i AS LONG
6372 i = CurrentMenuItemControl
6373 DO
6374 i = i - 1
6375 IF i < 1 THEN i = UBOUND(Control)
6376 IF i = CurrentMenuItemControl THEN EXIT DO
6377 IF Control(i).Type = __UI_Type_MenuItem AND NOT Control(i).Hidden AND Control(i).ParentID = __UI_ParentMenu(__UI_TotalActiveMenus) THEN
6378 EXIT DO
6379 END IF
6380 LOOP
6381 __UI_PreviousMenuItem = i
6382END FUNCTION
6383
6384'---------------------------------------------------------------------------------
6385SUB __UI_RefreshMenuBar
6386 'Calculate menu items' .Left and .Width
6387 DIM LeftOffset AS INTEGER, i AS LONG
6388 DIM TotalItems AS INTEGER, LastMenuItem AS LONG
6389
6390 _FONT (Control(__UI_FormID).Font)
6391
6392 FOR i = 1 TO UBOUND(Control)
6393 IF Control(i).ID > 0 THEN
6394 IF Control(i).Type = __UI_Type_MenuBar AND NOT Control(i).Hidden THEN
6395 TotalItems = TotalItems + 1
6396 IF TotalItems = 1 THEN
6397 LeftOffset = __UI_MenuBarOffset
6398 ELSE
6399 LeftOffset = LeftOffset + Control(LastMenuItem).Width
6400 END IF
6401 Control(i).Width = __UI_MenuBarOffset + __UI_PrintWidth(Caption(i)) + __UI_MenuBarOffset
6402 IF Control(i).Align = __UI_Left THEN
6403 Control(i).Left = LeftOffset
6404 ELSE
6405 Control(i).Left = Control(__UI_FormID).Width - 1 - __UI_MenuBarOffset - Control(i).Width
6406 END IF
6407 LastMenuItem = i
6408 __UI_NewMenuBarTextLeft = Control(i).Left + Control(i).Width
6409 END IF
6410 END IF
6411 NEXT
6412END SUB
6413
6414'---------------------------------------------------------------------------------
6415'UTF conversion functions courtesy of Luke Ceddia.
6416'http://www.qb64.net/forum/index.php?topic=13981.msg121324#msg121324
6417FUNCTION FromCP437$ (source$)
6418 STATIC init&
6419 IF init& = 0 THEN
6420 DIM i&
6421 FOR i& = 0 TO 127
6422 table437$(i&) = CHR$(i&)
6423 NEXT i&
6424 table437$(7) = CHR$(226) + CHR$(151) + CHR$(143) 'UTF-8 e2978f
6425 table437$(128) = CHR$(&HE2) + CHR$(&H82) + CHR$(&HAC)
6426 table437$(128) = CHR$(&HC3) + CHR$(&H87)
6427 table437$(129) = CHR$(&HC3) + CHR$(&HBC)
6428 table437$(130) = CHR$(&HC3) + CHR$(&HA9)
6429 table437$(131) = CHR$(&HC3) + CHR$(&HA2)
6430 table437$(132) = CHR$(&HC3) + CHR$(&HA4)
6431 table437$(133) = CHR$(&HC3) + CHR$(&HA0)
6432 table437$(134) = CHR$(&HC3) + CHR$(&HA5)
6433 table437$(135) = CHR$(&HC3) + CHR$(&HA7)
6434 table437$(136) = CHR$(&HC3) + CHR$(&HAA)
6435 table437$(137) = CHR$(&HC3) + CHR$(&HAB)
6436 table437$(138) = CHR$(&HC3) + CHR$(&HA8)
6437 table437$(139) = CHR$(&HC3) + CHR$(&HAF)
6438 table437$(140) = CHR$(&HC3) + CHR$(&HAE)
6439 table437$(141) = CHR$(&HC3) + CHR$(&HAC)
6440 table437$(142) = CHR$(&HC3) + CHR$(&H84)
6441 table437$(143) = CHR$(&HC3) + CHR$(&H85)
6442 table437$(144) = CHR$(&HC3) + CHR$(&H89)
6443 table437$(145) = CHR$(&HC3) + CHR$(&HA6)
6444 table437$(146) = CHR$(&HC3) + CHR$(&H86)
6445 table437$(147) = CHR$(&HC3) + CHR$(&HB4)
6446 table437$(148) = CHR$(&HC3) + CHR$(&HB6)
6447 table437$(149) = CHR$(&HC3) + CHR$(&HB2)
6448 table437$(150) = CHR$(&HC3) + CHR$(&HBB)
6449 table437$(151) = CHR$(&HC3) + CHR$(&HB9)
6450 table437$(152) = CHR$(&HC3) + CHR$(&HBF)
6451 table437$(153) = CHR$(&HC3) + CHR$(&H96)
6452 table437$(154) = CHR$(&HC3) + CHR$(&H9C)
6453 table437$(155) = CHR$(&HC2) + CHR$(&HA2)
6454 table437$(156) = CHR$(&HC2) + CHR$(&HA3)
6455 table437$(157) = CHR$(&HC2) + CHR$(&HA5)
6456 table437$(158) = CHR$(&HE2) + CHR$(&H82) + CHR$(&HA7)
6457 table437$(159) = CHR$(&HC6) + CHR$(&H92)
6458 table437$(160) = CHR$(&HC3) + CHR$(&HA1)
6459 table437$(161) = CHR$(&HC3) + CHR$(&HAD)
6460 table437$(162) = CHR$(&HC3) + CHR$(&HB3)
6461 table437$(163) = CHR$(&HC3) + CHR$(&HBA)
6462 table437$(164) = CHR$(&HC3) + CHR$(&HB1)
6463 table437$(165) = CHR$(&HC3) + CHR$(&H91)
6464 table437$(166) = CHR$(&HC2) + CHR$(&HAA)
6465 table437$(167) = CHR$(&HC2) + CHR$(&HBA)
6466 table437$(168) = CHR$(&HC2) + CHR$(&HBF)
6467 table437$(169) = CHR$(&HE2) + CHR$(&H8C) + CHR$(&H90)
6468 table437$(170) = CHR$(&HC2) + CHR$(&HAC)
6469 table437$(171) = CHR$(&HC2) + CHR$(&HBD)
6470 table437$(172) = CHR$(&HC2) + CHR$(&HBC)
6471 table437$(173) = CHR$(&HC2) + CHR$(&HA1)
6472 table437$(174) = CHR$(&HC2) + CHR$(&HAB)
6473 table437$(175) = CHR$(&HC2) + CHR$(&HBB)
6474 table437$(176) = CHR$(&HE2) + CHR$(&H96) + CHR$(&H91)
6475 table437$(177) = CHR$(&HE2) + CHR$(&H96) + CHR$(&H92)
6476 table437$(178) = CHR$(&HE2) + CHR$(&H96) + CHR$(&H93)
6477 table437$(179) = CHR$(&HE2) + CHR$(&H94) + CHR$(&H82)
6478 table437$(180) = CHR$(&HE2) + CHR$(&H94) + CHR$(&HA4)
6479 table437$(181) = CHR$(&HE2) + CHR$(&H95) + CHR$(&HA1)
6480 table437$(182) = CHR$(&HE2) + CHR$(&H95) + CHR$(&HA2)
6481 table437$(183) = CHR$(&HE2) + CHR$(&H95) + CHR$(&H96)
6482 table437$(184) = CHR$(&HE2) + CHR$(&H95) + CHR$(&H95)
6483 table437$(185) = CHR$(&HE2) + CHR$(&H95) + CHR$(&HA3)
6484 table437$(186) = CHR$(&HE2) + CHR$(&H95) + CHR$(&H91)
6485 table437$(187) = CHR$(&HE2) + CHR$(&H95) + CHR$(&H97)
6486 table437$(188) = CHR$(&HE2) + CHR$(&H95) + CHR$(&H9D)
6487 table437$(189) = CHR$(&HE2) + CHR$(&H95) + CHR$(&H9C)
6488 table437$(190) = CHR$(&HE2) + CHR$(&H95) + CHR$(&H9B)
6489 table437$(191) = CHR$(&HE2) + CHR$(&H94) + CHR$(&H90)
6490 table437$(192) = CHR$(&HE2) + CHR$(&H94) + CHR$(&H94)
6491 table437$(193) = CHR$(&HE2) + CHR$(&H94) + CHR$(&HB4)
6492 table437$(194) = CHR$(&HE2) + CHR$(&H94) + CHR$(&HAC)
6493 table437$(195) = CHR$(&HE2) + CHR$(&H94) + CHR$(&H9C)
6494 table437$(196) = CHR$(&HE2) + CHR$(&H94) + CHR$(&H80)
6495 table437$(197) = CHR$(&HE2) + CHR$(&H94) + CHR$(&HBC)
6496 table437$(198) = CHR$(&HE2) + CHR$(&H95) + CHR$(&H9E)
6497 table437$(199) = CHR$(&HE2) + CHR$(&H95) + CHR$(&H9F)
6498 table437$(200) = CHR$(&HE2) + CHR$(&H95) + CHR$(&H9A)
6499 table437$(201) = CHR$(&HE2) + CHR$(&H95) + CHR$(&H94)
6500 table437$(202) = CHR$(&HE2) + CHR$(&H95) + CHR$(&HA9)
6501 table437$(203) = CHR$(&HE2) + CHR$(&H95) + CHR$(&HA6)
6502 table437$(204) = CHR$(&HE2) + CHR$(&H95) + CHR$(&HA0)
6503 table437$(205) = CHR$(&HE2) + CHR$(&H95) + CHR$(&H90)
6504 table437$(206) = CHR$(&HE2) + CHR$(&H95) + CHR$(&HAC)
6505 table437$(207) = CHR$(&HE2) + CHR$(&H95) + CHR$(&HA7)
6506 table437$(208) = CHR$(&HE2) + CHR$(&H95) + CHR$(&HA8)
6507 table437$(209) = CHR$(&HE2) + CHR$(&H95) + CHR$(&HA4)
6508 table437$(210) = CHR$(&HE2) + CHR$(&H95) + CHR$(&HA5)
6509 table437$(211) = CHR$(&HE2) + CHR$(&H95) + CHR$(&H99)
6510 table437$(212) = CHR$(&HE2) + CHR$(&H95) + CHR$(&H98)
6511 table437$(213) = CHR$(&HE2) + CHR$(&H95) + CHR$(&H92)
6512 table437$(214) = CHR$(&HE2) + CHR$(&H95) + CHR$(&H93)
6513 table437$(215) = CHR$(&HE2) + CHR$(&H95) + CHR$(&HAB)
6514 table437$(216) = CHR$(&HE2) + CHR$(&H95) + CHR$(&HAA)
6515 table437$(217) = CHR$(&HE2) + CHR$(&H94) + CHR$(&H98)
6516 table437$(218) = CHR$(&HE2) + CHR$(&H94) + CHR$(&H8C)
6517 table437$(219) = CHR$(&HE2) + CHR$(&H96) + CHR$(&H88)
6518 table437$(220) = CHR$(&HE2) + CHR$(&H96) + CHR$(&H84)
6519 table437$(221) = CHR$(&HE2) + CHR$(&H96) + CHR$(&H8C)
6520 table437$(222) = CHR$(&HE2) + CHR$(&H96) + CHR$(&H90)
6521 table437$(223) = CHR$(&HE2) + CHR$(&H96) + CHR$(&H80)
6522 table437$(224) = CHR$(&HCE) + CHR$(&HB1)
6523 table437$(225) = CHR$(&HC3) + CHR$(&H9F)
6524 table437$(226) = CHR$(&HCE) + CHR$(&H93)
6525 table437$(227) = CHR$(&HCF) + CHR$(&H80)
6526 table437$(228) = CHR$(&HCE) + CHR$(&HA3)
6527 table437$(229) = CHR$(&HCF) + CHR$(&H83)
6528 table437$(230) = CHR$(&HC2) + CHR$(&HB5)
6529 table437$(231) = CHR$(&HCF) + CHR$(&H84)
6530 table437$(232) = CHR$(&HCE) + CHR$(&HA6)
6531 table437$(233) = CHR$(&HCE) + CHR$(&H98)
6532 table437$(234) = CHR$(&HCE) + CHR$(&HA9)
6533 table437$(235) = CHR$(&HCE) + CHR$(&HB4)
6534 table437$(236) = CHR$(&HE2) + CHR$(&H88) + CHR$(&H9E)
6535 table437$(237) = CHR$(&HCF) + CHR$(&H86)
6536 table437$(238) = CHR$(&HCE) + CHR$(&HB5)
6537 table437$(239) = CHR$(&HE2) + CHR$(&H88) + CHR$(&HA9)
6538 table437$(240) = CHR$(&HE2) + CHR$(&H89) + CHR$(&HA1)
6539 table437$(241) = CHR$(&HC2) + CHR$(&HB1)
6540 table437$(242) = CHR$(&HE2) + CHR$(&H89) + CHR$(&HA5)
6541 table437$(243) = CHR$(&HE2) + CHR$(&H89) + CHR$(&HA4)
6542 table437$(244) = CHR$(&HE2) + CHR$(&H8C) + CHR$(&HA0)
6543 table437$(245) = CHR$(&HE2) + CHR$(&H8C) + CHR$(&HA1)
6544 table437$(246) = CHR$(&HC3) + CHR$(&HB7)
6545 table437$(247) = CHR$(&HE2) + CHR$(&H89) + CHR$(&H88)
6546 table437$(248) = CHR$(&HC2) + CHR$(&HB0)
6547 table437$(249) = CHR$(&HE2) + CHR$(&H88) + CHR$(&H99)
6548 table437$(250) = CHR$(&HC2) + CHR$(&HB7)
6549 table437$(251) = CHR$(&HE2) + CHR$(&H88) + CHR$(&H9A)
6550 table437$(252) = CHR$(&HE2) + CHR$(&H81) + CHR$(&HBF)
6551 table437$(253) = CHR$(&HC2) + CHR$(&HB2)
6552 table437$(254) = CHR$(&HE2) + CHR$(&H96) + CHR$(&HA0)
6553 table437$(255) = CHR$(&HC2) + CHR$(&HA0)
6554 init& = -1
6555 END IF
6556 FromCP437$ = UTF8$(source$, table437$())
6557END FUNCTION
6558
6559FUNCTION FromCP1252$ (source$)
6560 STATIC init&
6561 IF init& = 0 THEN
6562 DIM i&
6563 FOR i& = 0 TO 127
6564 table1252$(i&) = CHR$(i&)
6565 NEXT i&
6566 table1252$(7) = CHR$(226) + CHR$(151) + CHR$(143) 'UTF-8 e2978f
6567 table1252$(128) = CHR$(&HE2) + CHR$(&H82) + CHR$(&HAC)
6568 table1252$(130) = CHR$(&HE2) + CHR$(&H80) + CHR$(&H9A)
6569 table1252$(131) = CHR$(&HC6) + CHR$(&H92)
6570 table1252$(132) = CHR$(&HE2) + CHR$(&H80) + CHR$(&H9E)
6571 table1252$(133) = CHR$(&HE2) + CHR$(&H80) + CHR$(&HA6)
6572 table1252$(134) = CHR$(&HE2) + CHR$(&H80) + CHR$(&HA0)
6573 table1252$(135) = CHR$(&HE2) + CHR$(&H80) + CHR$(&HA1)
6574 table1252$(136) = CHR$(&HCB) + CHR$(&H86)
6575 table1252$(137) = CHR$(&HE2) + CHR$(&H80) + CHR$(&HB0)
6576 table1252$(138) = CHR$(&HC5) + CHR$(&HA0)
6577 table1252$(139) = CHR$(&HE2) + CHR$(&H80) + CHR$(&HB9)
6578 table1252$(140) = CHR$(&HC5) + CHR$(&H92)
6579 table1252$(142) = CHR$(&HC5) + CHR$(&HBD)
6580 table1252$(145) = CHR$(&HE2) + CHR$(&H80) + CHR$(&H98)
6581 table1252$(146) = CHR$(&HE2) + CHR$(&H80) + CHR$(&H99)
6582 table1252$(147) = CHR$(&HE2) + CHR$(&H80) + CHR$(&H9C)
6583 table1252$(148) = CHR$(&HE2) + CHR$(&H80) + CHR$(&H9D)
6584 table1252$(149) = CHR$(&HE2) + CHR$(&H80) + CHR$(&HA2)
6585 table1252$(150) = CHR$(&HE2) + CHR$(&H80) + CHR$(&H93)
6586 table1252$(151) = CHR$(&HE2) + CHR$(&H80) + CHR$(&H94)
6587 table1252$(152) = CHR$(&HCB) + CHR$(&H9C)
6588 table1252$(153) = CHR$(&HE2) + CHR$(&H84) + CHR$(&HA2)
6589 table1252$(154) = CHR$(&HC5) + CHR$(&HA1)
6590 table1252$(155) = CHR$(&HE2) + CHR$(&H80) + CHR$(&HBA)
6591 table1252$(156) = CHR$(&HC5) + CHR$(&H93)
6592 table1252$(158) = CHR$(&HC5) + CHR$(&HBE)
6593 table1252$(159) = CHR$(&HC5) + CHR$(&HB8)
6594 table1252$(160) = CHR$(&HC2) + CHR$(&HA0)
6595 table1252$(161) = CHR$(&HC2) + CHR$(&HA1)
6596 table1252$(162) = CHR$(&HC2) + CHR$(&HA2)
6597 table1252$(163) = CHR$(&HC2) + CHR$(&HA3)
6598 table1252$(164) = CHR$(&HC2) + CHR$(&HA4)
6599 table1252$(165) = CHR$(&HC2) + CHR$(&HA5)
6600 table1252$(166) = CHR$(&HC2) + CHR$(&HA6)
6601 table1252$(167) = CHR$(&HC2) + CHR$(&HA7)
6602 table1252$(168) = CHR$(&HC2) + CHR$(&HA8)
6603 table1252$(169) = CHR$(&HC2) + CHR$(&HA9)
6604 table1252$(170) = CHR$(&HC2) + CHR$(&HAA)
6605 table1252$(171) = CHR$(&HC2) + CHR$(&HAB)
6606 table1252$(172) = CHR$(&HC2) + CHR$(&HAC)
6607 table1252$(173) = CHR$(&HC2) + CHR$(&HAD)
6608 table1252$(174) = CHR$(&HC2) + CHR$(&HAE)
6609 table1252$(175) = CHR$(&HC2) + CHR$(&HAF)
6610 table1252$(176) = CHR$(&HC2) + CHR$(&HB0)
6611 table1252$(177) = CHR$(&HC2) + CHR$(&HB1)
6612 table1252$(178) = CHR$(&HC2) + CHR$(&HB2)
6613 table1252$(179) = CHR$(&HC2) + CHR$(&HB3)
6614 table1252$(180) = CHR$(&HC2) + CHR$(&HB4)
6615 table1252$(181) = CHR$(&HC2) + CHR$(&HB5)
6616 table1252$(182) = CHR$(&HC2) + CHR$(&HB6)
6617 table1252$(183) = CHR$(&HC2) + CHR$(&HB7)
6618 table1252$(184) = CHR$(&HC2) + CHR$(&HB8)
6619 table1252$(185) = CHR$(&HC2) + CHR$(&HB9)
6620 table1252$(186) = CHR$(&HC2) + CHR$(&HBA)
6621 table1252$(187) = CHR$(&HC2) + CHR$(&HBB)
6622 table1252$(188) = CHR$(&HC2) + CHR$(&HBC)
6623 table1252$(189) = CHR$(&HC2) + CHR$(&HBD)
6624 table1252$(190) = CHR$(&HC2) + CHR$(&HBE)
6625 table1252$(191) = CHR$(&HC2) + CHR$(&HBF)
6626 table1252$(192) = CHR$(&HC3) + CHR$(&H80)
6627 table1252$(193) = CHR$(&HC3) + CHR$(&H81)
6628 table1252$(194) = CHR$(&HC3) + CHR$(&H82)
6629 table1252$(195) = CHR$(&HC3) + CHR$(&H83)
6630 table1252$(196) = CHR$(&HC3) + CHR$(&H84)
6631 table1252$(197) = CHR$(&HC3) + CHR$(&H85)
6632 table1252$(198) = CHR$(&HC3) + CHR$(&H86)
6633 table1252$(199) = CHR$(&HC3) + CHR$(&H87)
6634 table1252$(200) = CHR$(&HC3) + CHR$(&H88)
6635 table1252$(201) = CHR$(&HC3) + CHR$(&H89)
6636 table1252$(202) = CHR$(&HC3) + CHR$(&H8A)
6637 table1252$(203) = CHR$(&HC3) + CHR$(&H8B)
6638 table1252$(204) = CHR$(&HC3) + CHR$(&H8C)
6639 table1252$(205) = CHR$(&HC3) + CHR$(&H8D)
6640 table1252$(206) = CHR$(&HC3) + CHR$(&H8E)
6641 table1252$(207) = CHR$(&HC3) + CHR$(&H8F)
6642 table1252$(208) = CHR$(&HC3) + CHR$(&H90)
6643 table1252$(209) = CHR$(&HC3) + CHR$(&H91)
6644 table1252$(210) = CHR$(&HC3) + CHR$(&H92)
6645 table1252$(211) = CHR$(&HC3) + CHR$(&H93)
6646 table1252$(212) = CHR$(&HC3) + CHR$(&H94)
6647 table1252$(213) = CHR$(&HC3) + CHR$(&H95)
6648 table1252$(214) = CHR$(&HC3) + CHR$(&H96)
6649 table1252$(215) = CHR$(&HC3) + CHR$(&H97)
6650 table1252$(216) = CHR$(&HC3) + CHR$(&H98)
6651 table1252$(217) = CHR$(&HC3) + CHR$(&H99)
6652 table1252$(218) = CHR$(&HC3) + CHR$(&H9A)
6653 table1252$(219) = CHR$(&HC3) + CHR$(&H9B)
6654 table1252$(220) = CHR$(&HC3) + CHR$(&H9C)
6655 table1252$(221) = CHR$(&HC3) + CHR$(&H9D)
6656 table1252$(222) = CHR$(&HC3) + CHR$(&H9E)
6657 table1252$(223) = CHR$(&HC3) + CHR$(&H9F)
6658 table1252$(224) = CHR$(&HC3) + CHR$(&HA0)
6659 table1252$(225) = CHR$(&HC3) + CHR$(&HA1)
6660 table1252$(226) = CHR$(&HC3) + CHR$(&HA2)
6661 table1252$(227) = CHR$(&HC3) + CHR$(&HA3)
6662 table1252$(228) = CHR$(&HC3) + CHR$(&HA4)
6663 table1252$(229) = CHR$(&HC3) + CHR$(&HA5)
6664 table1252$(230) = CHR$(&HC3) + CHR$(&HA6)
6665 table1252$(231) = CHR$(&HC3) + CHR$(&HA7)
6666 table1252$(232) = CHR$(&HC3) + CHR$(&HA8)
6667 table1252$(233) = CHR$(&HC3) + CHR$(&HA9)
6668 table1252$(234) = CHR$(&HC3) + CHR$(&HAA)
6669 table1252$(235) = CHR$(&HC3) + CHR$(&HAB)
6670 table1252$(236) = CHR$(&HC3) + CHR$(&HAC)
6671 table1252$(237) = CHR$(&HC3) + CHR$(&HAD)
6672 table1252$(238) = CHR$(&HC3) + CHR$(&HAE)
6673 table1252$(239) = CHR$(&HC3) + CHR$(&HAF)
6674 table1252$(240) = CHR$(&HC3) + CHR$(&HB0)
6675 table1252$(241) = CHR$(&HC3) + CHR$(&HB1)
6676 table1252$(242) = CHR$(&HC3) + CHR$(&HB2)
6677 table1252$(243) = CHR$(&HC3) + CHR$(&HB3)
6678 table1252$(244) = CHR$(&HC3) + CHR$(&HB4)
6679 table1252$(245) = CHR$(&HC3) + CHR$(&HB5)
6680 table1252$(246) = CHR$(&HC3) + CHR$(&HB6)
6681 table1252$(247) = CHR$(&HC3) + CHR$(&HB7)
6682 table1252$(248) = CHR$(&HC3) + CHR$(&HB8)
6683 table1252$(249) = CHR$(&HC3) + CHR$(&HB9)
6684 table1252$(250) = CHR$(&HC3) + CHR$(&HBA)
6685 table1252$(251) = CHR$(&HC3) + CHR$(&HBB)
6686 table1252$(252) = CHR$(&HC3) + CHR$(&HBC)
6687 table1252$(253) = CHR$(&HC3) + CHR$(&HBD)
6688 table1252$(254) = CHR$(&HC3) + CHR$(&HBE)
6689 table1252$(255) = CHR$(&HC3) + CHR$(&HBF)
6690 init& = -1
6691 END IF
6692 FromCP1252$ = UTF8$(source$, table1252$())
6693END FUNCTION
6694
6695FUNCTION UTF8$ (source$, table$())
6696 DIM i AS LONG, dest$
6697 FOR i = 1 TO LEN(source$)
6698 dest$ = dest$ + table$(ASC(source$, i))
6699 NEXT i
6700 UTF8$ = dest$
6701END FUNCTION
6702
6703FUNCTION GetControlDrawOrder&(ctrlRef AS LONG)
6704 DIM i AS LONG
6705 FOR i& = 1 to UBOUND(ControlDrawOrder)
6706 IF ControlDrawOrder(i&) = ctrlRef THEN GetControlDrawOrder& = i&: EXIT FUNCTION
6707 NEXT i&
6708END FUNCTION
6709
6710SUB __UI_ExpandControlDrawOrder (size&)
6711 REDIM _PRESERVE ControlDrawOrder(0 TO UBOUND(ControlDrawOrder) + size&) AS LONG
6712END SUB
6713
6714FUNCTION IconPreview& (IconFile$)
6715 DIM IconFileNum AS INTEGER
6716 DIM Preferred AS INTEGER, Largest AS INTEGER
6717 DIM i AS LONG, a$
6718
6719 TYPE ICONTYPE
6720 Reserved AS INTEGER: ID AS INTEGER: Count AS INTEGER
6721 END TYPE
6722
6723 TYPE ICONENTRY
6724 PWidth AS _UNSIGNED _BYTE: PDepth AS _UNSIGNED _BYTE
6725 NumColors AS _BYTE: RES2 AS _BYTE
6726 NumberPlanes AS INTEGER: BitsPerPixel AS INTEGER
6727 DataSize AS LONG: DataOffset AS LONG
6728 END TYPE
6729
6730 TYPE BMPENTRY
6731 ID AS STRING * 2: Size AS LONG: Res1 AS INTEGER: Res2 AS INTEGER: Offset AS LONG
6732 END TYPE
6733
6734 TYPE BMPHeader
6735 Hsize AS LONG: PWidth AS LONG: PDepth AS LONG
6736 Planes AS INTEGER: BPP AS INTEGER
6737 Compression AS LONG: ImageBytes AS LONG
6738 Xres AS LONG: Yres AS LONG: NumColors AS LONG: SigColors AS LONG
6739 END TYPE
6740
6741 DIM ICO AS ICONTYPE
6742 DIM BMP AS BMPENTRY
6743 DIM BMPHeader AS BMPHeader
6744
6745 IF _FILEEXISTS(IconFile$) = 0 THEN EXIT FUNCTION
6746
6747 IconFileNum = FREEFILE
6748 OPEN IconFile$ FOR BINARY AS #IconFileNum
6749 GET #IconFileNum, 1, ICO
6750 IF ICO.ID <> 1 THEN CLOSE #IconFileNum: EXIT FUNCTION
6751
6752 DIM Entry(ICO.Count) AS ICONENTRY
6753 Preferred = 0
6754 Largest = 0
6755
6756 FOR i = 1 TO ICO.Count
6757 GET #IconFileNum, , Entry(i)
6758 IF Entry(i).BitsPerPixel = 32 THEN
6759 IF Entry(i).PWidth = 0 THEN Entry(i).PWidth = 256
6760 IF Entry(i).PWidth > Largest THEN Largest = Entry(i).PWidth: Preferred = i
6761 END IF
6762 NEXT
6763
6764 IF Preferred = 0 THEN EXIT FUNCTION
6765
6766 a$ = SPACE$(Entry(Preferred).DataSize)
6767 GET #IconFileNum, Entry(Preferred).DataOffset + 1, a$
6768 CLOSE #IconFileNum
6769
6770 IF LEFT$(a$, 4) = CHR$(137) + "PNG" THEN
6771 'PNG data can be dumped to the disk directly
6772 OPEN IconFile$ + ".preview.png" FOR BINARY AS #IconFileNum
6773 PUT #IconFileNum, 1, a$
6774 CLOSE #IconFileNum
6775 i = _LOADIMAGE(IconFile$ + ".preview.png", 32)
6776 IF i = -1 THEN i = 0
6777 IconPreview& = i
6778 KILL IconFile$ + ".preview.png"
6779 EXIT FUNCTION
6780 ELSE
6781 'BMP data requires a header to be added
6782 BMP.ID = "BM"
6783 BMP.Size = LEN(BMP) + LEN(BMPHeader) + LEN(a$)
6784 BMP.Offset = LEN(BMP) + LEN(BMPHeader)
6785 BMPHeader.Hsize = 40
6786 BMPHeader.PWidth = Entry(Preferred).PWidth
6787 BMPHeader.PDepth = Entry(Preferred).PDepth: IF BMPHeader.PDepth = 0 THEN BMPHeader.PDepth = 256
6788 BMPHeader.Planes = 1
6789 BMPHeader.BPP = 32
6790 OPEN IconFile$ + ".preview.bmp" FOR BINARY AS #IconFileNum
6791 PUT #IconFileNum, 1, BMP
6792 PUT #IconFileNum, , BMPHeader
6793 a$ = MID$(a$, 41)
6794 PUT #IconFileNum, , a$
6795 CLOSE #IconFileNum
6796 i = _LOADIMAGE(IconFile$ + ".preview.bmp", 32)
6797 IF i < -1 THEN 'Loaded properly
6798 _SOURCE i
6799 IF POINT(0, 0) = _RGB32(0, 0, 0) THEN _CLEARCOLOR _RGB32(0, 0, 0), i
6800 _SOURCE 0
6801 ELSE
6802 i = 0
6803 END IF
6804 IconPreview& = i
6805 KILL IconFile$ + ".preview.bmp"
6806 EXIT FUNCTION
6807 END IF
6808END FUNCTION
6809
6810FUNCTION RestoreCHR$ (__Text$)
6811 DIM Text$, BackSlash AS LONG, SemiColon AS LONG
6812 DIM j AS LONG, tempNum$
6813
6814 Text$ = __Text$
6815
6816 IF INSTR(Text$, "\") = 0 THEN
6817 RestoreCHR$ = Text$
6818 EXIT FUNCTION
6819 END IF
6820
6821 DO
6822 BackSlash = INSTR(BackSlash + 1, Text$, "\")
6823 IF BackSlash = 0 THEN EXIT DO
6824
6825 SemiColon = INSTR(BackSlash + 1, Text$, ";")
6826 IF SemiColon = 0 THEN _CONTINUE
6827
6828 IF MID$(Text$, BackSlash + 1, 1) = "\" THEN
6829 'Skip this code as the backslash is doubled \\
6830 Text$ = LEFT$(Text$, BackSlash) + MID$(Text$, BackSlash + 2)
6831 _CONTINUE
6832 END IF
6833
6834 tempNum$ = ""
6835 FOR j = BackSlash + 1 TO SemiColon - 1
6836 IF ASC(Text$, j) < 48 OR ASC(Text$, j) > 57 THEN tempNum$ = "": EXIT FOR
6837 tempNum$ = tempNum$ + MID$(Text$, j, 1)
6838 NEXT
6839
6840 IF LEN(tempNum$) THEN
6841 Text$ = LEFT$(Text$, BackSlash - 1) + CHR$(VAL(tempNum$)) + MID$(Text$, SemiColon + 1)
6842 END IF
6843 LOOP
6844
6845 RestoreCHR$ = Text$
6846END FUNCTION
6847
6848FUNCTION __UI_StrUsing$ (format$, value##)
6849 DIM prevDest AS LONG, prevSource AS LONG
6850 DIM tempScreen AS LONG
6851 DIM i AS LONG, temp$
6852 DIM length AS LONG
6853
6854 prevDest = _DEST
6855 prevSource = _SOURCE
6856
6857 tempScreen = _NEWIMAGE(LEN(format$) * 2, 2, 0)
6858 _DEST tempScreen
6859 _SOURCE tempScreen
6860
6861 PRINT USING format$; value##;
6862
6863 length = POS(0) - 1
6864 temp$ = SPACE$(length)
6865 FOR i = 1 TO length
6866 ASC(temp$, i) = SCREEN(1, i)
6867 NEXT
6868
6869 _DEST prevDest
6870 _SOURCE prevSource
6871 _FREEIMAGE tempScreen
6872
6873 __UI_StrUsing$ = temp$
6874END FUNCTION
6875
6876SUB __UI_Bind(id AS LONG, targetID AS LONG, __PropertyID$, __PropertyTargetID$)
6877 DIM PropertyID$, PropertyTargetID$
6878
6879 PropertyID$ = UCASE$(__PropertyID$)
6880 PropertyTargetID$ = UCASE$(__PropertyTargetID$)
6881
6882 'Clear eventual previous bindings
6883 IF Control(id).BoundTo > 0 THEN
6884 Control(Control(id).BoundTo).BoundTo = 0
6885 END IF
6886
6887 IF Control(targetID).BoundTo > 0 THEN
6888 Control(Control(targetID).BoundTo).BoundTo = 0
6889 END IF
6890
6891
6892 Control(id).BoundTo = targetID
6893 Control(id).BoundProperty = __UI_PropertyEnum(PropertyID$, 0)
6894 IF Control(id).BoundProperty = 0 THEN Control(id).BoundTo = 0: EXIT SUB
6895 Control(targetID).BoundTo = id
6896 Control(targetID).BoundProperty = __UI_PropertyEnum(PropertyTargetID$, 0)
6897 IF Control(targetID).BoundProperty = 0 THEN
6898 Control(id).BoundTo = 0
6899 Control(targetID).BoundTo = 0
6900 END IF
6901 __UI_CheckBinding targetID 'acquire current value of targetID
6902END SUB
6903
6904FUNCTION __UI_PropertyEnum& (__property$, index AS LONG)
6905 'If __property$ is passed:
6906 ' - __UI_PropertyEnum& returns the index/hash value;
6907 'If index is passed:
6908 ' - __property$ returns the property name found and
6909 ' - __UI_PropertyEnum& returns True (-1)
6910
6911 DIM property$, NextAt AS LONG
6912 STATIC EnumInitialized AS _BYTE, Enum$
6913
6914 IF LEN(_TRIM$(__property$)) = 0 AND index = 0 THEN EXIT FUNCTION
6915
6916 IF NOT EnumInitialized THEN
6917 RESTORE EnumNames
6918 DO
6919 READ property$
6920 IF property$ = "*" THEN EXIT DO
6921 Enum$ = Enum$ + "@" + property$
6922 LOOP
6923 Enum$ = Enum$ + "@"
6924 EnumInitialized = True
6925 END IF
6926
6927 IF index > 0 THEN
6928 'return property name
6929 IF index > LEN(Enum$) THEN EXIT FUNCTION
6930 IF ASC(Enum$, index) <> 64 THEN EXIT FUNCTION
6931 NextAt = INSTR(index + 1, Enum$, "@")
6932 __property$ = MID$(Enum$, index + 1, NextAt - index - 1)
6933 __UI_PropertyEnum& = -1
6934 ELSE
6935 'return index
6936 property$ = "@" + _TRIM$(UCASE$(__property$)) + "@"
6937 __UI_PropertyEnum& = INSTR(UCASE$(Enum$), property$)
6938 END IF
6939 EXIT FUNCTION
6940
6941 EnumNames:
6942 DATA Top,Left,Width,Height,Bordersize,Padding,Value
6943 DATA Min,Max,Interval,MinInterval,Stretch,HasBorder,ShowPercentage
6944 DATA AutoScroll,AutoSize,PasswordMask,Disabled,Hidden
6945 DATA *
6946END FUNCTION
6947
6948SUB __UI_UnBind(id AS LONG)
6949 IF Control(id).BoundTo > 0 THEN
6950 Control(Control(id).BoundTo).Redraw = True
6951 Control(Control(id).BoundTo).BoundTo = 0
6952 Control(id).BoundTo = 0
6953 Control(id).Redraw = True
6954 END IF
6955END SUB
6956
6957SUB __UI_CheckBinding(id AS LONG)
6958 DIM BindTarget AS LONG, Temp AS _FLOAT
6959
6960 BindTarget = Control(id).BoundTo
6961 IF BindTarget = 0 THEN EXIT SUB
6962
6963 'IF Control(id).BoundProperty = Control(BindTarget).BoundProperty AND _
6964 ' Control(id).BoundProperty = __UI_PropertyEnum&("Value", 0) THEN
6965 ' Control(id).Min = Control(BindTarget).Min
6966 ' Control(id).Max = Control(BindTarget).Max
6967 'END IF
6968
6969 SELECT CASE Control(id).BoundProperty
6970 CASE __UI_PropertyEnum&("Top", 0)
6971 Temp = Control(id).Top
6972 CASE __UI_PropertyEnum&("Left", 0)
6973 Temp = Control(id).Left
6974 CASE __UI_PropertyEnum&("Width", 0)
6975 Temp = Control(id).Width
6976 CASE __UI_PropertyEnum&("Height", 0)
6977 Temp = Control(id).Height
6978 CASE __UI_PropertyEnum&("BorderSize", 0)
6979 Temp = Control(id).BorderSize
6980 CASE __UI_PropertyEnum&("Padding", 0)
6981 Temp = Control(id).Padding
6982 CASE __UI_PropertyEnum&("Value", 0)
6983 Temp = Control(id).Value
6984 CASE __UI_PropertyEnum&("Min", 0)
6985 Temp = Control(id).Min
6986 CASE __UI_PropertyEnum&("Max", 0)
6987 Temp = Control(id).Max
6988 CASE __UI_PropertyEnum&("Interval", 0)
6989 Temp = Control(id).Interval
6990 CASE __UI_PropertyEnum&("Mininterval", 0)
6991 Temp = Control(id).Mininterval
6992 CASE __UI_PropertyEnum&("Stretch", 0)
6993 Temp = Control(id).Stretch
6994 CASE __UI_PropertyEnum&("HasBorder", 0)
6995 Temp = Control(id).HasBorder
6996 CASE __UI_PropertyEnum&("ShowPercentage", 0)
6997 Temp = Control(id).ShowPercentage
6998 CASE __UI_PropertyEnum&("AutoScroll", 0)
6999 Temp = Control(id).AutoScroll
7000 CASE __UI_PropertyEnum&("AutoSize", 0)
7001 Temp = Control(id).AutoSize
7002 CASE __UI_PropertyEnum&("PasswordField", 0)
7003 Temp = Control(id).PasswordField
7004 CASE __UI_PropertyEnum&("Disabled", 0)
7005 Temp = Control(id).Disabled
7006 CASE __UI_PropertyEnum&("Hidden", 0)
7007 Temp = Control(id).Hidden
7008 END SELECT
7009
7010 SELECT CASE Control(BindTarget).BoundProperty
7011 CASE __UI_PropertyEnum&("Top", 0)
7012 Control(BindTarget).Top = Temp
7013 CASE __UI_PropertyEnum&("Left", 0)
7014 Control(BindTarget).Left = Temp
7015 CASE __UI_PropertyEnum&("Width", 0)
7016 Control(BindTarget).Width = Temp
7017 CASE __UI_PropertyEnum&("Height", 0)
7018 Control(BindTarget).Height = Temp
7019 CASE __UI_PropertyEnum&("BorderSize", 0)
7020 Control(BindTarget).BorderSize = Temp
7021 CASE __UI_PropertyEnum&("Padding", 0)
7022 Control(BindTarget).Padding = Temp
7023 CASE __UI_PropertyEnum&("Value", 0)
7024 Control(BindTarget).Value = Temp
7025 CASE __UI_PropertyEnum&("Min", 0)
7026 Control(BindTarget).Min = Temp
7027 CASE __UI_PropertyEnum&("Max", 0)
7028 Control(BindTarget).Max = Temp
7029 CASE __UI_PropertyEnum&("Interval", 0)
7030 Control(BindTarget).Interval = Temp
7031 CASE __UI_PropertyEnum&("MinInterval", 0)
7032 Control(BindTarget).MinInterval = Temp
7033 CASE __UI_PropertyEnum&("Stretch", 0)
7034 Control(BindTarget).Stretch = Temp
7035 CASE __UI_PropertyEnum&("HasBorder", 0)
7036 Control(BindTarget).HasBorder = Temp
7037 CASE __UI_PropertyEnum&("ShowPercentage", 0)
7038 Control(BindTarget).ShowPercentage = Temp
7039 CASE __UI_PropertyEnum&("AutoScroll", 0)
7040 Control(BindTarget).AutoScroll = Temp
7041 CASE __UI_PropertyEnum&("AutoSize", 0)
7042 Control(BindTarget).AutoSize = Temp
7043 CASE __UI_PropertyEnum&("PasswordField", 0)
7044 Control(BindTarget).PasswordField = Temp
7045 CASE __UI_PropertyEnum&("Disabled", 0)
7046 Control(BindTarget).Disabled = Temp
7047 CASE __UI_PropertyEnum&("Hidden", 0)
7048 Control(BindTarget).Hidden = Temp
7049 END SELECT
7050
7051 Control(id).Redraw = True
7052 Control(BindTarget).Redraw = True
7053END SUB
7054
7055'Control drawing: -------------------------------------------------------------
7056'---------------------------------------------------------------------------------
7057SUB __UI_DrawButton (This AS __UI_ControlTYPE, ControlState AS _BYTE)
7058 'ControlState: 1 = Normal; 2 = Hover/focus; 3 = Mouse down; 4 = Disabled
7059 DIM TempCaption$
7060 DIM PrevDest AS LONG, TempControlState AS _BYTE
7061
7062 STATIC ControlImage AS LONG
7063 CONST ButtonHeight = 21
7064 CONST ButtonWidth = 18
7065
7066 IF ControlImage = 0 THEN ControlImage = __UI_LoadThemeImage("button.png")
7067
7068 TempControlState = ControlState
7069 IF TempControlState = 1 THEN
7070 IF (This.ID = __UI_DefaultButtonID AND This.ID <> __UI_Focus AND Control(__UI_Focus).Type <> __UI_Type_Button) OR This.ID = __UI_Focus THEN
7071 TempControlState = 5
7072 END IF
7073 END IF
7074
7075 IF This.Redraw OR This.ControlState <> TempControlState OR This.FocusState <> (__UI_Focus = This.ID) OR Caption(This.ID) <> __UI_TempCaptions(This.ID) OR This.PreviousParentID <> This.ParentID OR __UI_ForceRedraw _
7076 OR This.Font <> This.PreviousFont THEN
7077 'Last time this control was drawn it had a different state/caption, so it'll be redrawn
7078 This.Redraw = False
7079 This.ControlState = TempControlState
7080 This.PreviousFont = This.Font
7081 This.FocusState = __UI_Focus = This.ID
7082 __UI_TempCaptions(This.ID) = Caption(This.ID)
7083 This.PreviousParentID = This.ParentID
7084 IF This.ParentID THEN Control(This.ParentID).ChildrenRedrawn = True
7085
7086 IF This.Canvas <> 0 THEN
7087 _FREEIMAGE This.Canvas
7088 END IF
7089
7090 This.Canvas = _NEWIMAGE(This.Width, This.Height, 32)
7091
7092 PrevDest = _DEST
7093 _DEST This.Canvas
7094 _FONT (This.Font)
7095 CLS , _RGBA32(0, 0, 0, 0)
7096 TempCaption$ = __UI_TrimAt0$(Caption(This.ID))
7097
7098 'Back surface
7099 _PUTIMAGE (0, 3)-(This.Width - 1, This.Height - 4), ControlImage, , (3, TempControlState * ButtonHeight - ButtonHeight + 3)-STEP(11, ButtonHeight - 7)
7100
7101 'Does this button have a helper canvas (icon)?
7102 DIM IconWidth AS INTEGER, IconHeight AS INTEGER
7103 IF This.HelperCanvas < -1 THEN
7104 IF LEN(TempCaption$) THEN
7105 'Icon will be to the left of caption
7106 IconHeight = This.Height - 6
7107 IconWidth = _WIDTH(This.HelperCanvas) * IconHeight / _HEIGHT(This.HelperCanvas)
7108 _PUTIMAGE ((This.Width \ 2 - __UI_PrintWidth&(TempCaption$) \ 2) - ((IconWidth / 2) + 5), This.Height / 2 - ((This.Height - 4) / 2) + 1)-STEP(IconWidth - 1, IconHeight - 1), This.HelperCanvas
7109 ELSE
7110 'Icon will be centered
7111 DIM PictureOffsetX AS INTEGER, PictureOffsetY AS INTEGER
7112 IF This.ControlState = 3 THEN
7113 PictureOffsetX = 1
7114 PictureOffsetY = 1
7115 END IF
7116 IconHeight = This.Height - 6
7117 IconWidth = _WIDTH(This.HelperCanvas) * (IconHeight / _HEIGHT(This.HelperCanvas))
7118 _PUTIMAGE (This.Width \ 2 - ((IconWidth \ 2)) + PictureOffsetX, This.Height / 2 - ((This.Height - 4) / 2) + 1 + PictureOffsetY)-STEP(IconWidth - 1, IconHeight - 1), This.HelperCanvas
7119 END IF
7120 END IF
7121
7122 'Top and bottom edges
7123 _PUTIMAGE (3, 0)-STEP(This.Width - 6, 3), ControlImage, , (3, TempControlState * ButtonHeight - ButtonHeight)-STEP(11, 3)
7124 _PUTIMAGE (3, This.Height - 3)-STEP(This.Width - 6, 3), ControlImage, , (3, TempControlState * ButtonHeight - ButtonHeight + 18)-STEP(11, 3)
7125
7126 'Left edges and corners:
7127 _PUTIMAGE (0, 2)-STEP(2, This.Height - 4), ControlImage, , (0, TempControlState * ButtonHeight - ButtonHeight + 2)-STEP(2, ButtonHeight - 6)
7128 _PUTIMAGE (0, 0), ControlImage, , (0, TempControlState * ButtonHeight - ButtonHeight)-STEP(2, 2)
7129 _PUTIMAGE (0, This.Height - 3), ControlImage, , (0, TempControlState * ButtonHeight - 3)-STEP(2, 2)
7130
7131 'Right edges and corners:
7132 _PUTIMAGE (This.Width - 3, 2)-STEP(2, This.Height - 4), ControlImage, , (ButtonWidth - 3, TempControlState * ButtonHeight - ButtonHeight + 2)-STEP(2, ButtonHeight - 6)
7133 _PUTIMAGE (This.Width - 2, 0), ControlImage, , (ButtonWidth - 2, TempControlState * ButtonHeight - ButtonHeight)-STEP(2, 2)
7134 _PUTIMAGE (This.Width - 3, This.Height - 3), ControlImage, , (ButtonWidth - 3, TempControlState * ButtonHeight - 3)-STEP(2, 2)
7135
7136 'Caption:
7137 IF NOT This.Disabled THEN
7138 COLOR This.ForeColor
7139 ELSE
7140 COLOR Darken(Control(__UI_FormID).BackColor, 80)
7141 END IF
7142 __UI_PrintString (IconWidth / 2) + (This.Width \ 2 - __UI_PrintWidth&(TempCaption$) \ 2), ((This.Height \ 2) - uheight& \ 2), TempCaption$
7143
7144 'Hot key:
7145 IF (This.HotKey > 0 AND (__UI_ShowHotKeys AND NOT This.Disabled)) OR (This.HotKey > 0 AND __UI_DesignMode) THEN
7146 LINE ((This.Width \ 2 - __UI_PrintWidth&(TempCaption$) \ 2) + This.HotKeyOffset, ((This.Height \ 2) + uheight& \ 2))-STEP(__UI_PrintWidth&(CHR$(This.HotKey)) - 1, 0), This.ForeColor
7147 END IF
7148
7149 'Focus outline:
7150 IF __UI_Focus = This.ID AND __UI_KeyboardFocus THEN
7151 LINE (2, 2)-STEP(This.Width - 5, This.Height - 5), _RGB32(0, 0, 0), B , 21845
7152 END IF
7153
7154 __UI_MakeHardwareImageFromCanvas This
7155 _DEST PrevDest
7156 END IF
7157
7158 IF This.Canvas THEN _PUTIMAGE (This.Left, This.Top), This.Canvas
7159END SUB
7160
7161'---------------------------------------------------------------------------------
7162SUB __UI_DrawLabel (This AS __UI_ControlTYPE, ControlState AS _BYTE)
7163 DIM PrevDest AS LONG, i AS LONG
7164 DIM CaptionIndent AS INTEGER, TempCaption$, TempLine$
7165
7166 IF This.Redraw OR This.ControlState <> ControlState OR Caption(This.ID) <> __UI_TempCaptions(This.ID) OR This.PreviousParentID <> This.ParentID OR __UI_ForceRedraw _
7167 OR This.PreviousFont <> This.Font _
7168 OR Mask(This.ID) <> __UI_TempMask(This.ID) _
7169 OR This.Value <> This.PreviousValue _
7170 OR This.PrevAlign <> This.Align _
7171 OR This.PrevVAlign <> This.VAlign THEN
7172 'Last time this control was drawn it had a different state/caption, so it'll be redrawn
7173 This.Redraw = False
7174 This.ControlState = ControlState
7175 This.PreviousFont = This.Font
7176 __UI_TempCaptions(This.ID) = Caption(This.ID)
7177 __UI_TempMask(This.ID) = Mask(This.ID)
7178 This.PrevAlign = This.Align
7179 This.PrevVAlign = This.VAlign
7180 This.PreviousValue = This.Value
7181 IF This.ParentID THEN Control(This.ParentID).ChildrenRedrawn = True
7182 This.PreviousParentID = This.ParentID
7183
7184 IF This.Canvas <> 0 THEN
7185 _FREEIMAGE This.Canvas
7186 END IF
7187
7188 This.Canvas = _NEWIMAGE(This.Width, This.Height, 32)
7189
7190 PrevDest = _DEST
7191 _DEST This.Canvas
7192 _FONT This.Font
7193
7194 IF This.HasBorder THEN
7195 IF This.BorderSize > __UI_MaxBorderSize THEN
7196 This.BorderSize = __UI_MaxBorderSize
7197 ELSEIF This.BorderSize < 1 THEN
7198 This.BorderSize = 1
7199 END IF
7200 CaptionIndent = __UI_DefaultCaptionIndent + This.BorderSize
7201 END IF
7202
7203 IF This.BackStyle = __UI_Opaque THEN
7204 CLS , This.BackColor
7205 ELSE
7206 CLS , _RGBA32(0, 0, 0, 0)
7207 END IF
7208
7209 IF NOT This.Disabled THEN
7210 COLOR This.ForeColor
7211 ELSE
7212 COLOR Darken(Control(__UI_FormID).BackColor, 80)
7213 END IF
7214
7215 'Caption:
7216 DIM CaptionLeft AS INTEGER, FindLF&, FindSep&, ThisLine%
7217 DIM CaptionLeftFirstLine AS INTEGER, CaptionTopFirstLine AS INTEGER, TextTop%
7218 DIM TotalLines AS INTEGER
7219 IF This.WordWrap THEN
7220 TempCaption$ = __UI_TrimAt0$(__UI_WordWrap(Caption(This.ID), This.Width - ((CaptionIndent + This.Padding) * 2), 0, TotalLines))
7221 DO WHILE LEN(TempCaption$)
7222 ThisLine% = ThisLine% + 1
7223
7224 IF This.VAlign = __UI_Top THEN
7225 TextTop% = CaptionIndent + ThisLine% * uspacing& - uspacing&
7226 ELSEIF This.VAlign = __UI_Middle THEN
7227 IF TotalLines < This.Height \ uspacing& THEN
7228 'Center vertically if less lines than fits the box
7229 TextTop% = (This.Height \ 2) - ((TotalLines * uspacing& - uspacing&) \ 2) - uspacing& \ 2 + (((ThisLine%) * uspacing& - uspacing&))
7230 ELSE
7231 'Snap to top of the label's boundaries
7232 'if there are more lines than meet the eye
7233 TextTop% = CaptionIndent + ThisLine% * uspacing& - uspacing&
7234 END IF
7235 ELSEIF This.VAlign = __UI_Bottom THEN
7236 TextTop% = This.Height - CaptionIndent - (TotalLines * uspacing&) + (ThisLine% * uspacing& - uspacing&)
7237 END IF
7238
7239 FindSep& = INSTR(TempCaption$, CHR$(1)) 'Search for soft breaks
7240 FindLF& = INSTR(TempCaption$, CHR$(10)) 'Search for hard breaks
7241 IF (FindSep& > 0 AND FindLF& > 0 AND FindSep& < FindLF&) OR (FindSep& > 0 AND FindLF& = 0) THEN
7242 TempLine$ = LEFT$(TempCaption$, FindSep& - 1)
7243 TempCaption$ = MID$(TempCaption$, FindSep& + 1)
7244 ELSEIF FindSep& = 0 THEN
7245 IF FindLF& > 0 THEN
7246 TempLine$ = LEFT$(TempCaption$, FindLF& - 1)
7247 TempCaption$ = MID$(TempCaption$, FindLF& + 1)
7248 ELSE
7249 TempLine$ = TempCaption$
7250 TempCaption$ = ""
7251 END IF
7252 END IF
7253
7254 SELECT CASE This.Align
7255 CASE __UI_Left
7256 CaptionLeft = CaptionIndent + This.Padding
7257 CASE __UI_Center
7258 CaptionLeft = (This.Width \ 2 - __UI_PrintWidth&(TempLine$) \ 2)
7259 CASE __UI_Right
7260 CaptionLeft = (This.Width - __UI_PrintWidth&(TempLine$)) - (CaptionIndent + This.Padding)
7261 END SELECT
7262
7263 __UI_PrintString CaptionLeft, TextTop%, TempLine$
7264
7265 IF ThisLine% = 1 THEN CaptionLeftFirstLine = CaptionLeft: CaptionTopFirstLine = TextTop%
7266 LOOP
7267
7268 'Hot key:
7269 IF (This.HotKey > 0 AND (__UI_ShowHotKeys AND NOT This.Disabled)) OR (This.HotKey > 0 AND __UI_DesignMode) THEN
7270 LINE (CaptionLeftFirstLine + This.HotKeyOffset, CaptionTopFirstLine + uspacing&)-STEP(__UI_PrintWidth&(CHR$(This.HotKey)) - 1, 0), This.ForeColor
7271 END IF
7272 ELSE
7273 IF LEN(Mask(This.ID)) THEN
7274 TempCaption$ = __UI_StrUsing$(Mask(This.ID), This.Value)
7275 ELSE
7276 TempCaption$ = __UI_TrimAt0$(Caption(This.ID))
7277 END IF
7278 SELECT CASE This.Align
7279 CASE __UI_Left
7280 CaptionLeft = CaptionIndent + This.Padding
7281 CASE __UI_Center
7282 CaptionLeft = (This.Width \ 2 - __UI_PrintWidth&(TempCaption$) \ 2)
7283 CASE __UI_Right
7284 CaptionLeft = This.Width - __UI_PrintWidth&(TempCaption$) - (CaptionIndent + This.Padding)
7285 END SELECT
7286
7287 IF This.VAlign = __UI_Top THEN
7288 TextTop% = CaptionIndent
7289 ELSEIF This.VAlign = __UI_Middle THEN
7290 TextTop% = (This.Height \ 2) - uspacing& \ 2
7291 ELSEIF This.VAlign = __UI_Bottom THEN
7292 TextTop% = This.Height - CaptionIndent - uspacing&
7293 END IF
7294
7295 CaptionLeftFirstLine = CaptionLeft
7296 __UI_PrintString CaptionLeft, TextTop%, TempCaption$
7297
7298 'Hot key:
7299 IF (This.HotKey > 0 AND (__UI_ShowHotKeys AND NOT This.Disabled)) OR (This.HotKey > 0 AND __UI_DesignMode) THEN
7300 LINE (CaptionLeftFirstLine + This.HotKeyOffset, (TextTop% + uspacing&))-STEP(__UI_PrintWidth&(CHR$(This.HotKey)) - 1, 0), This.ForeColor
7301 END IF
7302 END IF
7303
7304 IF This.HasBorder THEN
7305 FOR i = 0 TO This.BorderSize - 1
7306 LINE (i, i)-STEP(This.Width - 1 - i * 2, This.Height - 1 - i * 2), This.BorderColor, B
7307 NEXT
7308 END IF
7309
7310 __UI_MakeHardwareImageFromCanvas This
7311 _DEST PrevDest
7312 END IF
7313
7314 IF This.Canvas THEN _PUTIMAGE (This.Left, This.Top), This.Canvas
7315END SUB
7316
7317'---------------------------------------------------------------------------------
7318SUB __UI_DrawToggleSwitch (This AS __UI_ControlTYPE, ControlState AS _BYTE)
7319 DIM PrevDest AS LONG
7320 DIM CaptionIndent AS INTEGER
7321
7322 'STATIC ControlImage AS LONG
7323 CONST ImageHeight = 15
7324 CONST ImageWidth = 30
7325
7326 'IF ControlImage = 0 THEN ControlImage = __UI_LoadThemeImage("radiobutton.png")
7327
7328 IF This.Redraw OR This.ControlState <> ControlState OR TIMER - This.LastChange < .5 OR This.FocusState <> (__UI_Focus = This.ID) OR Caption(This.ID) <> __UI_TempCaptions(This.ID) OR This.Value <> This.PreviousValue OR This.PreviousParentID <> This.ParentID _
7329 OR __UI_ForceRedraw OR This.PreviousFont <> This.Font THEN
7330 'Last time this control was drawn it had a different state/caption, so it'll be redrawn
7331 This.Redraw = False
7332 This.ControlState = ControlState
7333 This.PreviousFont = This.Font
7334 This.FocusState = __UI_Focus = This.ID
7335 IF This.PreviousValue <> This.Value THEN
7336 __UI_StateHasChanged = True
7337 This.PreviousValue = This.Value
7338 END IF
7339 __UI_TempCaptions(This.ID) = Caption(This.ID)
7340 IF This.ParentID THEN Control(This.ParentID).ChildrenRedrawn = True
7341 This.PreviousParentID = This.ParentID
7342
7343 IF This.Canvas <> 0 THEN
7344 _FREEIMAGE This.Canvas
7345 END IF
7346
7347 IF This.Height < ImageHeight THEN This.Height = ImageHeight
7348 IF This.Width < ImageWidth THEN This.Width = ImageWidth
7349 This.Canvas = _NEWIMAGE(This.Width + 1, This.Height + 1, 32)
7350
7351 PrevDest = _DEST
7352 _DEST This.Canvas
7353 _FONT This.Font
7354 '------
7355 IF This.BackStyle = __UI_Opaque THEN
7356 CLS , This.BackColor
7357 ELSE
7358 CLS , _RGBA32(0, 0, 0, 0)
7359 END IF
7360
7361 CaptionIndent = 0
7362
7363 DIM AnimationOffset AS SINGLE
7364 AnimationOffset = __UI_MAP(TIMER - This.LastChange, 0, .2, This.Width / 2, 0)
7365 IF AnimationOffset < 0 THEN AnimationOffset = 0
7366 IF AnimationOffset > This.Width / 2 THEN AnimationOffset = This.Width / 2
7367
7368 IF This.Value THEN
7369 IF NOT This.Disabled THEN
7370 LINE (0, 0)-(This.Width, This.Height), This.SelectedBackColor, BF
7371 ELSE
7372 LINE (0, 0)-(This.Width, This.Height), Darken(This.SelectedBackColor, 150), BF
7373 END IF
7374
7375 LINE (This.Width / 2 + 4 - AnimationOffset, 4)-STEP(This.Width / 2 - 8, This.Height - 8), This.SelectedForeColor, BF
7376 LINE (0, 0)-(This.Width, This.Height), This.BorderColor, B
7377 ELSE
7378 IF NOT This.Disabled THEN
7379 LINE (0, 0)-(This.Width, This.Height), This.BackColor, BF
7380 ELSE
7381 LINE (0, 0)-(This.Width, This.Height), Darken(This.BackColor, 80), BF
7382 END IF
7383 LINE (4 + AnimationOffset, 4)-STEP(This.Width / 2 - 8, This.Height - 8), This.ForeColor, BF
7384 LINE (0, 0)-(This.Width, This.Height), This.BorderColor, B
7385 END IF
7386
7387 'Focus outline
7388 IF __UI_Focus = This.ID AND __UI_KeyboardFocus THEN
7389 LINE (1, 1)-STEP(This.Width - 2, This.Height - 2), _RGB32(0, 0, 0), B , 21845
7390 END IF
7391 '------
7392
7393 __UI_MakeHardwareImageFromCanvas This
7394 _DEST PrevDest
7395 END IF
7396
7397 IF This.Canvas THEN _PUTIMAGE (This.Left, This.Top), This.Canvas
7398END SUB
7399
7400'---------------------------------------------------------------------------------
7401SUB __UI_DrawRadioButton (This AS __UI_ControlTYPE, ControlState AS _BYTE)
7402 DIM PrevDest AS LONG
7403 DIM CaptionIndent AS INTEGER, TempCaption$
7404
7405 STATIC ControlImage AS LONG
7406 CONST ImageHeight = 13
7407 CONST ImageWidth = 13
7408
7409 IF ControlImage = 0 THEN ControlImage = __UI_LoadThemeImage("radiobutton.png")
7410
7411 IF This.Redraw OR This.ControlState <> ControlState OR This.FocusState <> (__UI_Focus = This.ID) OR Caption(This.ID) <> __UI_TempCaptions(This.ID) OR This.Value <> This.PreviousValue OR This.PreviousParentID <> This.ParentID _
7412 OR __UI_ForceRedraw OR This.PreviousFont <> This.Font THEN
7413 'Last time this control was drawn it had a different state/caption, so it'll be redrawn
7414 This.Redraw = False
7415 This.PreviousFont = This.Font
7416 This.ControlState = ControlState
7417 This.FocusState = __UI_Focus = This.ID
7418 This.PreviousValue = This.Value
7419 __UI_TempCaptions(This.ID) = Caption(This.ID)
7420 IF This.ParentID THEN Control(This.ParentID).ChildrenRedrawn = True
7421 This.PreviousParentID = This.ParentID
7422
7423 IF This.Canvas <> 0 THEN
7424 _FREEIMAGE This.Canvas
7425 END IF
7426
7427 IF This.Height < ImageHeight THEN This.Height = ImageHeight
7428 This.Canvas = _NEWIMAGE(This.Width + 1, This.Height + 1, 32)
7429
7430 PrevDest = _DEST
7431 _DEST This.Canvas
7432 _FONT This.Font
7433 '------
7434 IF This.BackStyle = __UI_Opaque THEN
7435 CLS , This.BackColor
7436 ELSE
7437 CLS , _RGBA32(0, 0, 0, 0)
7438 END IF
7439
7440 CaptionIndent = 0
7441 IF This.HasBorder THEN
7442 CaptionIndent = 5
7443 LINE (0, 0)-STEP(This.Width - 1, This.Height - 1), This.BorderColor, B
7444 END IF
7445
7446 IF This.Value THEN ControlState = ControlState + 4
7447 _PUTIMAGE (0, This.Height \ 2 - (ImageHeight \ 2))-STEP(ImageWidth - 1, ImageHeight - 1), ControlImage, , (0, ControlState * ImageHeight - ImageHeight)-STEP(12, 12)
7448
7449 CaptionIndent = CaptionIndent + ImageWidth * 1.5
7450 TempCaption$ = __UI_TrimAt0$(Caption(This.ID))
7451
7452 IF NOT This.Disabled THEN
7453 COLOR This.ForeColor
7454 ELSE
7455 COLOR Darken(Control(__UI_FormID).BackColor, 80)
7456 END IF
7457
7458 __UI_PrintString CaptionIndent, ((This.Height \ 2) - uspacing& \ 2) + 1, TempCaption$
7459
7460 'Hot key:
7461 IF (This.HotKey > 0 AND (__UI_ShowHotKeys AND NOT This.Disabled)) OR (This.HotKey > 0 AND __UI_DesignMode) THEN
7462 LINE (CaptionIndent + This.HotKeyOffset, ((This.Height \ 2) + uspacing& \ 2))-STEP(__UI_PrintWidth(CHR$(This.HotKey)) - 1, 0), This.ForeColor
7463 END IF
7464
7465 'Focus outline
7466 IF __UI_Focus = This.ID AND __UI_KeyboardFocus THEN
7467 LINE (CaptionIndent - 1, 0)-STEP(This.Width - CaptionIndent - 1, This.Height - 1), _RGB32(0, 0, 0), B , 21845
7468 END IF
7469
7470 '------
7471
7472 __UI_MakeHardwareImageFromCanvas This
7473 _DEST PrevDest
7474 END IF
7475
7476 IF This.Canvas THEN _PUTIMAGE (This.Left, This.Top), This.Canvas
7477END SUB
7478
7479'---------------------------------------------------------------------------------
7480SUB __UI_DrawCheckBox (This AS __UI_ControlTYPE, ControlState AS _BYTE)
7481 DIM PrevDest AS LONG
7482 DIM CaptionIndent AS INTEGER, TempCaption$
7483
7484 STATIC ControlImage AS LONG
7485 CONST ImageHeight = 13
7486 CONST ImageWidth = 13
7487
7488 IF ControlImage = 0 THEN ControlImage = __UI_LoadThemeImage("checkbox.png")
7489
7490 IF This.Redraw OR This.ControlState <> ControlState OR This.FocusState <> (__UI_Focus = This.ID) OR Caption(This.ID) <> __UI_TempCaptions(This.ID) OR This.Value <> This.PreviousValue OR This.PreviousParentID <> This.ParentID _
7491 OR __UI_ForceRedraw OR This.PreviousFont <> This.Font THEN
7492 'Last time this control was drawn it had a different state/caption, so it'll be redrawn
7493 This.Redraw = False
7494 This.ControlState = ControlState
7495 This.PreviousFont = This.Font
7496 This.FocusState = __UI_Focus = This.ID
7497 IF This.PreviousValue <> This.Value THEN
7498 __UI_StateHasChanged = True
7499 This.PreviousValue = This.Value
7500 END IF
7501 __UI_TempCaptions(This.ID) = Caption(This.ID)
7502 IF This.ParentID THEN Control(This.ParentID).ChildrenRedrawn = True
7503 This.PreviousParentID = This.ParentID
7504
7505 IF This.Canvas <> 0 THEN
7506 _FREEIMAGE This.Canvas
7507 END IF
7508
7509 IF This.Height < ImageHeight THEN This.Height = ImageHeight
7510 This.Canvas = _NEWIMAGE(This.Width + 2, This.Height + 2, 32)
7511
7512 PrevDest = _DEST
7513 _DEST This.Canvas
7514 _FONT This.Font
7515
7516 '------
7517 IF This.BackStyle = __UI_Opaque THEN
7518 CLS , This.BackColor
7519 ELSE
7520 CLS , _RGBA32(0, 0, 0, 0)
7521 END IF
7522
7523 CaptionIndent = 0
7524
7525 IF This.Value THEN ControlState = ControlState + 4
7526 _PUTIMAGE (0, This.Height \ 2 - (ImageHeight \ 2))-STEP(ImageWidth - 1, ImageHeight - 1), ControlImage, , (0, ControlState * ImageHeight - ImageHeight)-STEP(ImageWidth - 1, ImageHeight - 1)
7527
7528 CaptionIndent = CaptionIndent + ImageWidth * 1.5
7529 TempCaption$ = __UI_TrimAt0$(Caption(This.ID))
7530
7531 IF NOT This.Disabled THEN
7532 COLOR This.ForeColor
7533 ELSE
7534 COLOR Darken(Control(__UI_FormID).BackColor, 80)
7535 END IF
7536
7537 __UI_PrintString CaptionIndent, ((This.Height \ 2) - uspacing& \ 2) + 1, TempCaption$
7538
7539 'Hot key:
7540 IF (This.HotKey > 0 AND (__UI_ShowHotKeys AND NOT This.Disabled)) OR (This.HotKey > 0 AND __UI_DesignMode) THEN
7541 LINE (CaptionIndent + This.HotKeyOffset, ((This.Height \ 2) + uspacing& \ 2))-STEP(__UI_PrintWidth(CHR$(This.HotKey)) - 1, 0), This.ForeColor
7542 END IF
7543
7544 'Focus outline
7545 IF __UI_Focus = This.ID AND __UI_KeyboardFocus THEN
7546 LINE (CaptionIndent - 1, 0)-STEP(This.Width - CaptionIndent - 1, This.Height - 1), _RGB32(0, 0, 0), B , 21845
7547 END IF
7548 '------
7549
7550 __UI_MakeHardwareImageFromCanvas This
7551 _DEST PrevDest
7552 END IF
7553
7554 IF This.Canvas THEN _PUTIMAGE (This.Left, This.Top), This.Canvas
7555END SUB
7556
7557'---------------------------------------------------------------------------------
7558SUB __UI_DrawProgressBar (This AS __UI_ControlTYPE, ControlState)
7559 DIM PrevDest AS LONG, Temp&
7560 DIM TempCaption$, TempLine$
7561
7562 STATIC ControlImage_Track AS LONG, ControlImage_Chunk AS LONG
7563
7564 IF ControlImage_Chunk = 0 THEN ControlImage_Chunk = __UI_LoadThemeImage("progresschunk.png")
7565 IF ControlImage_Track = 0 THEN ControlImage_Track = __UI_LoadThemeImage("progresstrack.png")
7566
7567 IF This.Redraw OR This.ControlState <> ControlState OR This.FocusState <> (__UI_Focus = This.ID) OR Caption(This.ID) <> __UI_TempCaptions(This.ID) OR This.Value <> This.PreviousValue OR This.PreviousParentID <> This.ParentID _
7568 OR __UI_ForceRedraw OR This.PreviousFont <> This.Font THEN
7569 'Last time this control was drawn it had a different state/caption, so it'll be redrawn
7570 This.Redraw = False
7571 This.PreviousFont = This.Font
7572 This.ControlState = ControlState
7573 This.FocusState = __UI_Focus = This.ID
7574 This.PreviousValue = This.Value
7575 __UI_TempCaptions(This.ID) = Caption(This.ID)
7576 IF This.ParentID THEN Control(This.ParentID).ChildrenRedrawn = True
7577 This.PreviousParentID = This.ParentID
7578
7579 IF This.Canvas <> 0 THEN
7580 _FREEIMAGE This.Canvas
7581 END IF
7582
7583 This.Canvas = _NEWIMAGE(This.Width, This.Height, 32)
7584
7585 PrevDest = _DEST
7586 _DEST This.Canvas
7587 _FONT (This.Font)
7588 CLS , _RGBA32(0, 0, 0, 0)
7589
7590 '------
7591 'Draw track
7592 'Back
7593 _PUTIMAGE (5, 4)-STEP(This.Width - 9, This.Height - 8), ControlImage_Track, , (5, 4)-STEP(0, 11)
7594
7595 'Left side
7596 _PUTIMAGE (0, 0), ControlImage_Track, , (0, 0)-(4, 4) 'top corner
7597 _PUTIMAGE (0, This.Height - 3), ControlImage_Track, , (0, 16)-STEP(3, 2) 'bottom corner
7598 _PUTIMAGE (0, 4)-(4, This.Height - 4), ControlImage_Track, , (0, 4)-STEP(4, 11) 'vertical stretch
7599
7600 'Right side
7601 _PUTIMAGE (This.Width - 4, 0), ControlImage_Track, , (6, 0)-STEP(2, 3) 'top corner
7602 _PUTIMAGE (This.Width - 4, This.Height - 3), ControlImage_Track, , (6, 16)-STEP(2, 3) 'bottom corner
7603 _PUTIMAGE (This.Width - 4, 4)-STEP(2, This.Height - 8), ControlImage_Track, , (6, 4)-STEP(2, 11) 'vertical stretch
7604
7605 'Top
7606 _PUTIMAGE (4, 0)-STEP(This.Width - 9, 3), ControlImage_Track, , (4, 0)-STEP(1, 3)
7607
7608 'Bottom
7609 _PUTIMAGE (4, This.Height - 3)-STEP(This.Width - 9, 2), ControlImage_Track, , (4, 16)-STEP(1, 2)
7610
7611 'Draw progress
7612 IF This.Value THEN
7613 _PUTIMAGE (4, 3)-STEP(((This.Width - 9) / This.Max) * This.Value, This.Height - 7), ControlImage_Chunk
7614 END IF
7615
7616 IF This.ShowPercentage THEN
7617 DIM ProgressString$, ReplaceCode%
7618 ProgressString$ = LTRIM$(STR$(FIX((This.Value / This.Max) * 100))) + "%"
7619 IF LEN(Caption(This.ID)) THEN
7620 TempCaption$ = Replace$(Caption(This.ID), "\#", ProgressString$, 0, 0)
7621 ELSE
7622 TempCaption$ = ProgressString$
7623 END IF
7624
7625 IF NOT This.Disabled THEN
7626 COLOR This.ForeColor
7627 ELSE
7628 COLOR Darken(Control(__UI_FormID).BackColor, 70)
7629 END IF
7630
7631 'Caption:
7632 DIM CaptionLeft AS INTEGER, FindLF&, FindSep&, ThisLine%
7633 DIM CaptionLeftFirstLine AS INTEGER, CaptionTopFirstLine AS INTEGER, TextTop%
7634 DIM TotalLines AS INTEGER
7635 IF INSTR(TempCaption$, CHR$(10)) > 0 THEN
7636 TempCaption$ = __UI_TrimAt0$(__UI_WordWrap(TempCaption$, This.Width - ((__UI_DefaultCaptionIndent) * 2), 0, TotalLines))
7637 DO WHILE LEN(TempCaption$)
7638 ThisLine% = ThisLine% + 1
7639
7640 IF TotalLines < This.Height \ uspacing& THEN
7641 'Center vertically if less lines than fits the box
7642 TextTop% = (This.Height \ 2) - ((TotalLines * uspacing& - uspacing&) \ 2) - uspacing& \ 2 + (((ThisLine%) * uspacing& - uspacing&))
7643 ELSE
7644 'Snap to top of the label's boundaries
7645 'if there are more lines than meet the eye
7646 TextTop% = __UI_DefaultCaptionIndent + ThisLine% * uspacing& - uspacing&
7647 END IF
7648
7649 FindSep& = INSTR(TempCaption$, CHR$(1)) 'Search for soft breaks
7650 FindLF& = INSTR(TempCaption$, CHR$(10)) 'Search for hard breaks
7651 IF (FindSep& > 0 AND FindLF& > 0 AND FindSep& < FindLF&) OR (FindSep& > 0 AND FindLF& = 0) THEN
7652 TempLine$ = LEFT$(TempCaption$, FindSep& - 1)
7653 TempCaption$ = MID$(TempCaption$, FindSep& + 1)
7654 ELSEIF FindSep& = 0 THEN
7655 IF FindLF& > 0 THEN
7656 TempLine$ = LEFT$(TempCaption$, FindLF& - 1)
7657 TempCaption$ = MID$(TempCaption$, FindLF& + 1)
7658 ELSE
7659 TempLine$ = TempCaption$
7660 TempCaption$ = ""
7661 END IF
7662 END IF
7663
7664 CaptionLeft = (This.Width \ 2 - __UI_PrintWidth&(TempLine$) \ 2)
7665 __UI_PrintString CaptionLeft, TextTop%, TempLine$
7666
7667 IF ThisLine% = 1 THEN CaptionLeftFirstLine = CaptionLeft: CaptionTopFirstLine = TextTop%
7668 LOOP
7669 ELSE
7670 Temp& = __UI_PrintWidth(TempCaption$)
7671 __UI_PrintString This.Width \ 2 - Temp& \ 2, This.Height \ 2 - uspacing& \ 2 + 1, TempCaption$
7672 END IF
7673 END IF
7674 '------
7675
7676 __UI_MakeHardwareImageFromCanvas This
7677 _DEST PrevDest
7678 END IF
7679
7680 IF This.Canvas THEN _PUTIMAGE (This.Left, This.Top), This.Canvas
7681END SUB
7682
7683'---------------------------------------------------------------------------------
7684SUB __UI_DrawTrackBar (This AS __UI_ControlTYPE, ControlState)
7685 DIM PrevDest AS LONG, i AS LONG, TempControlState AS _BYTE
7686
7687 STATIC ControlImage_Track AS LONG, ControlImage_Slider AS LONG
7688
7689 CONST SliderHeight = 21
7690 CONST SliderWidth = 11
7691
7692 IF ControlImage_Track = 0 THEN ControlImage_Track = __UI_LoadThemeImage("slidertrack.png")
7693 IF ControlImage_Slider = 0 THEN
7694 ControlImage_Slider = __UI_LoadThemeImage("sliderdown.png")
7695 __UI_ClearColor ControlImage_Slider, 0, 0
7696 END IF
7697
7698 TempControlState = ControlState
7699 IF This.Disabled THEN TempControlState = 5
7700
7701 IF This.Redraw OR This.ControlState <> TempControlState OR This.FocusState <> (__UI_Focus = This.ID) OR This.Value <> This.PreviousValue OR This.PreviousParentID <> This.ParentID _
7702 OR __UI_ForceRedraw OR This.PreviousFont <> This.Font OR _
7703 This.PrevMin <> This.Min OR This.PrevMax <> This.Max OR _
7704 This.PrevInterval <> This.Interval OR This.PrevMinInterval <> This.MinInterval THEN
7705 'Last time this control was drawn it had a different state/caption, so it'll be redrawn
7706 This.Redraw = False
7707 This.ControlState = TempControlState
7708 This.PreviousFont = This.Font
7709 This.FocusState = __UI_Focus = This.ID
7710 IF This.PreviousValue <> This.Value THEN
7711 __UI_StateHasChanged = True
7712 This.PreviousValue = This.Value
7713 END IF
7714 This.PrevMin = This.Min
7715 This.PrevMax = This.Max
7716 This.PrevInterval = This.Interval
7717 This.PrevMinInterval = This.MinInterval
7718 IF This.ParentID THEN Control(This.ParentID).ChildrenRedrawn = True
7719 This.PreviousParentID = This.ParentID
7720
7721 IF This.Canvas <> 0 THEN
7722 _FREEIMAGE This.Canvas
7723 END IF
7724
7725 This.Canvas = _NEWIMAGE(This.Width, This.Height, 32)
7726
7727 PrevDest = _DEST
7728 _DEST This.Canvas
7729 _FONT (This.Font)
7730 CLS , _RGBA32(0, 0, 0, 0)
7731
7732 '------
7733 'Draw track
7734 _PUTIMAGE (3, 10), ControlImage_Track, , (0, 0)-STEP(1, 4)
7735 _PUTIMAGE (5, 10)-STEP(This.Width - 10, 5), ControlImage_Track, , (2, 0)-STEP(0, 4)
7736 _PUTIMAGE (This.Width - 4, 10), ControlImage_Track, , (3, 0)-STEP(1, 4)
7737
7738 'Interval ticks
7739 DIM IntervalSize AS INTEGER, MinIntervalSize AS INTEGER
7740 MinIntervalSize = 2
7741
7742 LINE (5, 30)-STEP(0, 3), This.BorderColor
7743 IF This.Interval = 0 THEN This.Interval = 1
7744
7745 IF This.MinInterval > This.Interval THEN
7746 This.MinInterval = 0
7747 ELSEIF This.MinInterval < This.Interval AND This.MinInterval > 0 THEN
7748 FOR i = This.Min TO This.Max STEP This.MinInterval
7749 LINE (__UI_MAP(i, This.Min, This.Max, 5, This.Width - 6), 30)-STEP(0, MinIntervalSize), This.BorderColor
7750 NEXT i
7751 ENDIF
7752
7753 IF This.MinInterval > 0 THEN IntervalSize = 5 ELSE IntervalSize = 2
7754
7755 FOR i = This.Min TO This.Max STEP This.Interval
7756 LINE (__UI_MAP(i, This.Min, This.Max, 5, This.Width - 6), 30)-STEP(0, IntervalSize), This.BorderColor
7757 NEXT i
7758
7759 LINE (5 + (This.Width - SliderWidth), 30)-STEP(0, 3), This.BorderColor
7760
7761 'Draw slider
7762 _PUTIMAGE (__UI_MAP(This.Value, This.Min, This.Max, 0, This.Width - SliderWidth), 2), ControlImage_Slider, , (0, TempControlState * SliderHeight - SliderHeight)-STEP(SliderWidth - 1, SliderHeight - 1)
7763
7764 'Focus outline
7765 IF __UI_Focus = This.ID AND __UI_KeyboardFocus THEN
7766 LINE (0, 0)-STEP(This.Width - 1, This.Height - 1), _RGB32(0, 0, 0), B , 21845
7767 END IF
7768 '------
7769
7770 __UI_MakeHardwareImageFromCanvas This
7771 _DEST PrevDest
7772 END IF
7773
7774 IF This.Canvas THEN _PUTIMAGE (This.Left, This.Top), This.Canvas
7775END SUB
7776
7777'---------------------------------------------------------------------------------
7778SUB __UI_DrawTextBox (This AS __UI_ControlTYPE, ControlState)
7779 DIM PrevDest AS LONG
7780 DIM CaptionIndent AS INTEGER, i AS LONG, TempCaption$
7781 STATIC SetCursor#, cursorBlink%%
7782
7783 IF This.FirstVisibleLine = 0 THEN This.FirstVisibleLine = 1
7784 IF This.CurrentLine = 0 THEN This.CurrentLine = 1
7785
7786 __UI_CursorAdjustments This.ID
7787
7788 IF This.Redraw OR This.ControlState <> ControlState OR _
7789 This.FocusState <> (__UI_Focus = This.ID) OR _
7790 Caption(This.ID) <> __UI_TempCaptions(This.ID) OR _
7791 Text(This.ID) <> __UI_TempTexts(This.ID) OR _
7792 (TIMER - SetCursor# > .3 AND __UI_Focus = This.ID) OR _
7793 (__UI_SelectionLength <> This.SelectionLength AND __UI_Focus = This.ID) OR _
7794 This.Cursor <> This.PrevCursor OR This.PreviousParentID <> This.ParentID OR _
7795 This.VisibleCursor <> This.PrevVisibleCursor OR _
7796 This.FirstVisibleLine <> This.PrevFirstVisibleLine OR _
7797 This.CurrentLine <> This.PrevCurrentLine OR _
7798 Mask(This.ID) <> __UI_TempMask(This.ID) OR _
7799 This.PreviousFont <> This.Font OR _
7800 __UI_ForceRedraw THEN
7801
7802 'Last time this control was drawn it had a different state/caption, so it'll be redrawn
7803 This.Redraw = False
7804 This.ControlState = ControlState
7805 This.PreviousFont = This.Font
7806 This.FocusState = __UI_Focus = This.ID
7807 __UI_TempCaptions(This.ID) = Caption(This.ID)
7808 IF Mask(This.ID) <> __UI_TempMask(This.ID) THEN
7809 IF NOT __UI_EditorMode THEN Mask(This.ID) = RestoreCHR$(Mask(This.ID))
7810 __UI_TempMask(This.ID) = Mask(This.ID)
7811 Text(This.ID) = __UI_EmptyMask(This.ID)
7812 END IF
7813 IF __UI_TempTexts(This.ID) <> Text(This.ID) THEN
7814 __UI_StateHasChanged = True
7815 IF NOT __UI_EditorMode THEN Text(This.ID) = RestoreCHR$(Text(This.ID))
7816 __UI_TempTexts(This.ID) = Text(This.ID)
7817 END IF
7818 This.SelectionLength = __UI_SelectionLength
7819 This.PrevCursor = This.Cursor
7820 This.PrevVisibleCursor = This.VisibleCursor
7821 IF This.ParentID THEN Control(This.ParentID).ChildrenRedrawn = True
7822 This.PreviousParentID = This.ParentID
7823 This.PrevFirstVisibleLine = This.FirstVisibleLine
7824 This.PrevCurrentLine = This.CurrentLine
7825
7826 IF This.Canvas <> 0 THEN
7827 _FREEIMAGE This.Canvas
7828 END IF
7829
7830 This.Canvas = _NEWIMAGE(This.Width, This.Height, 32)
7831
7832 PrevDest = _DEST
7833 _DEST This.Canvas
7834 _FONT (This.Font)
7835
7836 '------
7837 _PRINTMODE _KEEPBACKGROUND
7838 CLS , This.BackColor
7839
7840 TempCaption$ = __UI_TrimAt0$(Caption(This.ID))
7841 CaptionIndent = 0
7842
7843 IF This.HasBorder THEN
7844 IF This.BorderSize > __UI_MaxBorderSize THEN
7845 This.BorderSize = __UI_MaxBorderSize
7846 ELSEIF This.BorderSize < 1 THEN
7847 This.BorderSize = 1
7848 END IF
7849 CaptionIndent = __UI_DefaultCaptionIndent + This.BorderSize
7850 END IF
7851
7852 IF NOT This.Disabled AND (LEN(Text(This.ID)) OR This.Multiline) THEN
7853 COLOR This.ForeColor, This.BackColor
7854 ELSE
7855 COLOR Darken(Control(__UI_FormID).BackColor, 80), This.BackColor
7856 END IF
7857
7858 STATIC c AS _UNSIGNED LONG
7859 IF c = 0 THEN
7860 c = _RGBA32(_RED32(This.SelectedBackColor), _GREEN32(This.SelectedBackColor), _BLUE32(This.SelectedBackColor), 70)
7861 END IF
7862
7863 IF NOT This.Multiline THEN
7864 'Single line textbox
7865 DIM ThisTempText$
7866 ThisTempText$ = __UI_TrimAt0$(Text(This.ID))
7867
7868 IF LEN(ThisTempText$) > 0 AND This.PasswordField = True THEN
7869 ThisTempText$ = STRING$(LEN(ThisTempText$), 7)
7870 END IF
7871
7872 IF ((__UI_Focus = This.ID) OR (This.ID = __UI_PreviousFocus AND __UI_ParentMenu(__UI_TotalActiveMenus) = This.ContextMenuID)) AND NOT This.Disabled THEN
7873 IF LEN(Text(This.ID)) THEN
7874 __UI_PrintString CaptionIndent - This.InputViewStart, ((This.Height \ 2) - uspacing& \ 2), ThisTempText$
7875 ELSE
7876 __UI_PrintString CaptionIndent, ((This.Height \ 2) - uspacing& \ 2), TempCaption$
7877 END IF
7878
7879 IF This.TextIsSelected THEN
7880 LINE (Captionindent - This.InputViewStart + __UI_ThisLineChars(This.SelectionStart), ((This.Height \ 2) - uspacing& \ 2))-(Captionindent - This.InputViewStart + __UI_ThisLineChars(This.Cursor), ((This.Height \ 2) - uspacing& \ 2) + uspacing&), c, BF
7881 END IF
7882
7883 IF TIMER - SetCursor# > .3 THEN
7884 SetCursor# = TIMER
7885 cursorBlink%% = NOT cursorBlink%%
7886 END IF
7887 IF _WINDOWHASFOCUS = False THEN cursorBlink%% = False
7888
7889 IF This.Cursor > UBOUND(__UI_ThisLineChars) THEN This.Cursor = UBOUND(__UI_ThisLineChars)
7890 This.VisibleCursor = CaptionIndent + __UI_ThisLineChars(This.Cursor) - This.InputViewStart
7891
7892 STATIC PrevFocusedText$
7893 IF PrevFocusedText$ <> ThisTempText$ THEN
7894 PrevFocusedText$ = ThisTempText$
7895 REDIM __UI_FocusedTextBoxChars(0 TO UBOUND(__UI_ThisLineChars)) AS LONG
7896 DIM M1 AS _MEM, M2 AS _MEM
7897 M1 = _MEM(__UI_ThisLineChars())
7898 M2 = _MEM(__UI_FocusedTextBoxChars())
7899 _MEMCOPY M1, M1.OFFSET, M1.SIZE TO M2, M2.OFFSET
7900 _MEMFREE M1
7901 _MEMFREE M2
7902 END IF
7903
7904 SELECT CASE MID$(Mask(This.ID), This.Cursor + 1, 1)
7905 CASE "0", "9", "#" 'Digit placeholders
7906 LINE (This.VisibleCursor, ((This.Height \ 2) - uspacing& \ 2))-STEP(__UI_ThisLineChars(This.Cursor + 1) - __UI_ThisLineChars(This.Cursor), uspacing&), c, BF
7907 CASE ELSE
7908 IF cursorBlink%% THEN
7909 LINE (This.VisibleCursor, ((This.Height \ 2) - uspacing& \ 2))-STEP(0, uspacing&), _RGB32(0, 0, 0)
7910 END IF
7911 END SELECT
7912 ELSE
7913 IF LEN(Text(This.ID)) THEN
7914 __UI_PrintString CaptionIndent, ((This.Height \ 2) - uspacing& \ 2), ThisTempText$
7915 ELSE
7916 IF LEN(Mask(This.ID)) = 0 THEN
7917 __UI_PrintString CaptionIndent, ((This.Height \ 2) - uspacing& \ 2), TempCaption$
7918 ELSE
7919 Text(This.ID) = __UI_EmptyMask$(This.ID)
7920 END IF
7921 END IF
7922 END IF
7923 ELSE
7924 'Multi line textbox
7925 DIM ThisTop AS INTEGER, TempLine AS STRING
7926 DIM TotalLines AS INTEGER
7927 'DIM ThisLine AS LONG, ThisLineStart AS LONG
7928 DIM s1 AS LONG, s2 AS LONG
7929 STATIC PrevTotalLines AS LONG
7930
7931 IF This.TextIsSelected THEN
7932 s1 = This.SelectionStart + 1
7933 s2 = This.Cursor + 1
7934
7935 IF s1 > s2 THEN SWAP s1, s2
7936 END IF
7937
7938 ThisTop = CaptionIndent - uspacing&
7939 TempCaption$ = __UI_TrimAt0$(__UI_WordWrap(Text(This.ID), This.Width - __UI_ScrollbarWidth - 5, 0, TotalLines))
7940
7941 IF This.HelperCanvas = 0 OR PrevTotalLines <> TotalLines THEN
7942 PrevTotalLines = TotalLines
7943 IF This.HelperCanvas < -1 THEN _FREEIMAGE This.HelperCanvas
7944 This.HelperCanvas = _NEWIMAGE(This.Width - __UI_ScrollbarWidth, TotalLines * uspacing& + uspacing& / 2)
7945 END IF
7946
7947 _DEST This.HelperCanvas
7948 _FONT This.Font
7949 CLS , This.BackColor
7950
7951 IF TIMER - SetCursor# > .3 THEN
7952 SetCursor# = TIMER
7953 cursorBlink%% = NOT cursorBlink%%
7954 END IF
7955
7956 'FOR ThisLine = 1 TO TotalLines
7957 ' ThisTop = ThisTop + uspacing&
7958 ' TempLine = __UI_GetTextBoxLine$(This.ID, ThisLine, ThisLineStart)
7959
7960 ' IF LEN(TempLine) THEN
7961 ' __UI_PrintString CaptionIndent, ThisTop, MID$(TempLine, This.InputViewStart)
7962 ' END IF
7963
7964 ' IF This.TextIsSelected THEN
7965 ' IF s1 >= ThisLineStart AND s2 < ThisLineStart + LEN(TempLine) THEN
7966 ' 'Only a portion of this line is selected
7967 ' LINE (CaptionIndent + __UI_ThisLineChars(s1 - ThisLineStart), ThisTop)-(__UI_ThisLineChars(s2 - ThisLineStart + 1), ThisTop + uspacing& - 1), c, BF
7968 ' ELSEIF s1 >= ThisLineStart AND s1 <= ThisLineStart + LEN(TempLine) THEN
7969 ' 'The beginning of the selection is in this line waiting to be highlighted.
7970 ' LINE (CaptionIndent + __UI_ThisLineChars(s1 - ThisLineStart), ThisTop)-STEP(This.Width, uspacing& - 1), c, BF
7971 ' ELSEIF s1 < ThisLineStart AND s2 > ThisLineStart + LEN(TempLine) THEN
7972 ' 'This whole line is selected
7973 ' LINE (CaptionIndent, ThisTop)-STEP(This.Width, uspacing& - 1), c, BF
7974 ' ELSEIF s1< ThisLineStart AND s2 <= ThisLineStart + LEN(TempLine) THEN
7975 ' 'Selection ends in this line
7976 ' LINE (CaptionIndent, ThisTop)-STEP(__UI_ThisLineChars(s2 - ThisLineStart), uspacing& - 1), c, BF
7977 ' END IF
7978 ' END IF
7979
7980 ' 'IF ThisLine = This.CurrentLine THEN
7981 ' ' IF cursorBlink%% AND __UI_Focus = This.ID AND This.CurrentLine >= This.FirstVisibleLine AND This.CurrentLine <= This.FirstVisibleLine + This.Height \ uspacing& THEN
7982 ' ' LINE (CaptionIndent + __UI_ThisLineChars(This.VisibleCursor - (This.InputViewStart - 1)), ThisTop)-STEP(0, uspacing&), _RGB32(0, 0, 0)
7983 ' ' END IF
7984 ' 'END IF
7985 'NEXT
7986 DO WHILE LEN(TempCaption$)
7987 DIM ThisLine%, TextTop%, FindSep&, FindLF&, CaptionLeft AS INTEGER
7988 ThisLine% = ThisLine% + 1
7989
7990 TextTop% = CaptionIndent + ThisLine% * uspacing& - uspacing&
7991
7992 FindSep& = INSTR(TempCaption$, CHR$(1)) 'Search for soft breaks
7993 FindLF& = INSTR(TempCaption$, CHR$(10)) 'Search for hard breaks
7994 IF (FindSep& > 0 AND FindLF& > 0 AND FindSep& < FindLF&) OR (FindSep& > 0 AND FindLF& = 0) THEN
7995 TempLine$ = LEFT$(TempCaption$, FindSep& - 1)
7996 TempCaption$ = MID$(TempCaption$, FindSep& + 1)
7997 ELSEIF FindSep& = 0 THEN
7998 IF FindLF& > 0 THEN
7999 TempLine$ = LEFT$(TempCaption$, FindLF& - 1)
8000 TempCaption$ = MID$(TempCaption$, FindLF& + 1)
8001 ELSE
8002 TempLine$ = TempCaption$
8003 TempCaption$ = ""
8004 END IF
8005 END IF
8006
8007 CaptionLeft = CaptionIndent
8008
8009 __UI_PrintString CaptionLeft, TextTop%, TempLine$
8010 LOOP
8011
8012 IF This.ID = __UI_Focus THEN
8013 FOR i = Control(__UI_Focus).Cursor TO 0 STEP -1
8014 IF MID$(Text(__UI_Focus), i, 1) = CHR$(10) OR i = 0 THEN
8015 Control(__UI_Focus).VisibleCursor = Control(__UI_Focus).Cursor - i
8016 EXIT FOR
8017 END IF
8018 NEXT
8019 END IF
8020
8021 _DEST This.Canvas
8022 _PUTIMAGE (0,0),This.HelperCanvas
8023
8024 IF TotalLines > This.Height \ uspacing& THEN
8025 This.HasVScrollbar = True
8026 __UI_DrawVScrollBar This, ControlState
8027 ELSE
8028 This.HasVScrollbar = False
8029 __UI_DrawVScrollBar This, 4 'ControlState = 4 (Disabled)
8030 END IF
8031 END IF
8032
8033 IF This.HasBorder THEN
8034 FOR i = 0 TO This.BorderSize - 1
8035 LINE (i, i)-STEP(This.Width - 1 - i * 2, This.Height - 1 - i * 2), This.BorderColor, B
8036 NEXT
8037 END IF
8038 '------
8039
8040 __UI_MakeHardwareImageFromCanvas This
8041 _DEST PrevDest
8042 END IF
8043
8044 IF This.Canvas THEN _PUTIMAGE (This.Left, This.Top), This.Canvas
8045END SUB
8046
8047'---------------------------------------------------------------------------------
8048SUB __UI_DrawListBox (This AS __UI_ControlTYPE, ControlState)
8049 DIM PrevDest AS LONG, i AS LONG
8050 DIM CaptionIndent AS INTEGER, TempCaption$
8051
8052 IF This.Redraw OR This.ControlState <> ControlState OR This.FocusState <> (__UI_Focus = This.ID) OR This.PreviousValue <> This.Value OR Text(This.ID) <> __UI_TempTexts(This.ID) OR This.PreviousInputViewStart <> This.InputViewStart OR This.PreviousParentID <> This.ParentID _
8053 OR __UI_ForceRedraw OR This.PreviousFont <> This.Font THEN
8054 'Last time this control was drawn it had a different state/caption, so it'll be redrawn
8055 This.Redraw = False
8056 This.PreviousFont = This.Font
8057 This.ControlState = ControlState
8058 This.FocusState = __UI_Focus = This.ID
8059 IF This.PreviousValue <> This.Value THEN
8060 __UI_StateHasChanged = True
8061 This.PreviousValue = This.Value
8062 END IF
8063 This.PreviousInputViewStart = This.InputViewStart
8064 IF INSTR(Text(This.ID), CHR$(13) + CHR$(10)) > 0 THEN
8065 Text(This.ID) = Replace(Text(This.ID), CHR$(13) + CHR$(10), CHR$(10), 0, 0)
8066 END IF
8067
8068 __UI_TempTexts(This.ID) = Text(This.ID)
8069 IF This.ParentID THEN Control(This.ParentID).ChildrenRedrawn = True
8070 This.PreviousParentID = This.ParentID
8071
8072 IF This.Canvas <> 0 THEN
8073 _FREEIMAGE This.Canvas
8074 END IF
8075
8076 IF This.Width + This.Height > 0 THEN
8077 This.Canvas = _NEWIMAGE(This.Width, This.Height, 32)
8078 ELSE
8079 EXIT SUB
8080 END IF
8081
8082 PrevDest = _DEST
8083 _DEST This.Canvas
8084 _FONT (This.Font)
8085
8086 '------
8087 IF This.BackStyle = __UI_Opaque THEN
8088 CLS , This.BackColor
8089 ELSE
8090 CLS , _RGBA32(0, 0, 0, 0)
8091 END IF
8092
8093 IF This.HasBorder THEN
8094 IF This.BorderSize > __UI_MaxBorderSize THEN
8095 This.BorderSize = __UI_MaxBorderSize
8096 ELSEIF This.BorderSize < 1 THEN
8097 This.BorderSize = 1
8098 END IF
8099 CaptionIndent = __UI_DefaultCaptionIndent + This.BorderSize
8100 END IF
8101
8102 IF LEN(Text(This.ID)) THEN
8103 DIM TempText$, FindLF&, ThisItem%, ThisItemTop%
8104 DIM ItemHeight AS INTEGER, LastVisibleItem AS INTEGER
8105
8106 ItemHeight = uspacing + (((_FONT = 8) * -1) * __UI_Font8Offset + ((_FONT = 16) * -1) * __UI_Font16Offset) + 3
8107 This.ItemHeight = ItemHeight
8108 TempText$ = __UI_TrimAt0$(Text(This.ID))
8109 ThisItem% = 0
8110 DO WHILE LEN(TempText$)
8111 ThisItem% = ThisItem% + 1
8112 FindLF& = INSTR(TempText$, CHR$(10))
8113 IF FindLF& THEN
8114 TempCaption$ = LEFT$(TempText$, FindLF& - 1)
8115 TempText$ = MID$(TempText$, FindLF& + 1)
8116 ELSE
8117 TempCaption$ = TempText$
8118 TempText$ = ""
8119 END IF
8120 IF ThisItem% >= This.InputViewStart THEN
8121 ThisItemTop% = ((ThisItem% - This.InputViewStart + 1) * ItemHeight - ItemHeight) + CaptionIndent
8122 IF ThisItemTop% + ItemHeight > This.Height THEN _CONTINUE
8123 LastVisibleItem = LastVisibleItem + 1
8124
8125 IF ThisItem% = This.Value AND __UI_Focus = This.ID THEN Caption(This.ID) = TempCaption$
8126
8127 IF NOT This.Disabled THEN
8128 COLOR This.ForeColor
8129 ELSE
8130 COLOR Darken(Control(__UI_FormID).BackColor, 80)
8131 END IF
8132
8133 IF ThisItem% = This.Value THEN
8134 IF __UI_Focus = This.ID THEN
8135 COLOR This.SelectedForeColor, This.SelectedBackColor
8136 LINE (CaptionIndent, ThisItemTop% - 1)-STEP(This.Width - CaptionIndent * 2, ItemHeight), This.SelectedBackColor, BF
8137 ELSE
8138 LINE (CaptionIndent, ThisItemTop% - 1)-STEP(This.Width - CaptionIndent * 2, ItemHeight), _RGBA32(0, 0, 0, 50), BF
8139 END IF
8140 END IF
8141
8142 SELECT CASE This.Align
8143 CASE __UI_Left
8144 __UI_PrintString CaptionIndent * 2, ThisItemTop% + ((ItemHeight - uspacing&) / 2), TempCaption$
8145 CASE __UI_Center
8146 __UI_PrintString (This.Width \ 2 - __UI_PrintWidth(TempCaption$) \ 2), ThisItemTop% + ((ItemHeight - uspacing&) / 2), TempCaption$
8147 CASE __UI_Right
8148 __UI_PrintString (This.Width - __UI_PrintWidth(TempCaption$)) - CaptionIndent, ThisItemTop% + ((ItemHeight - uspacing&) / 2), TempCaption$
8149 END SELECT
8150 END IF
8151 LOOP
8152
8153 This.Max = ThisItem%
8154
8155 IF This.LastVisibleItem < LastVisibleItem THEN This.LastVisibleItem = LastVisibleItem
8156 IF This.InputViewStart > This.Max THEN This.InputViewStart = 0
8157 IF This.Value > This.Max THEN This.Value = 0
8158
8159 IF This.Max > This.LastVisibleItem THEN
8160 This.HasVScrollbar = True
8161 __UI_DrawVScrollBar This, ControlState
8162 ELSE
8163 This.HasVScrollbar = False
8164 END IF
8165 END IF
8166
8167 IF This.HasBorder THEN
8168 FOR i = 0 TO This.BorderSize - 1
8169 LINE (i, i)-STEP(This.Width - 1 - i * 2, This.Height - 1 - i * 2), This.BorderColor, B
8170 NEXT
8171 END IF
8172 '------
8173
8174 __UI_MakeHardwareImageFromCanvas This
8175 _DEST PrevDest
8176 END IF
8177
8178 IF This.Canvas THEN _PUTIMAGE (This.Left, This.Top), This.Canvas
8179END SUB
8180
8181'---------------------------------------------------------------------------------
8182SUB __UI_DrawVScrollBar (TempThis AS __UI_ControlTYPE, ControlState AS _BYTE)
8183 DIM TrackHeight AS INTEGER, ThumbHeight AS INTEGER, ThumbTop AS INTEGER
8184 DIM Ratio AS SINGLE
8185 DIM This AS __UI_ControlTYPE
8186
8187 STATIC ControlImage_Button AS LONG, ControlImage_Track AS LONG
8188 STATIC ControlImage_Thumb AS LONG
8189 CONST ImageHeight_Button = 17
8190 CONST ImageWidth_Button = 17
8191 CONST ImageHeight_Thumb = 22
8192 CONST ImageWidth_Thumb = 15
8193
8194 IF ControlImage_Button = 0 THEN ControlImage_Button = __UI_LoadThemeImage("scrollbuttons.png")
8195 IF ControlImage_Track = 0 THEN ControlImage_Track = __UI_LoadThemeImage("scrolltrack.png")
8196 IF ControlImage_Thumb = 0 THEN ControlImage_Thumb = __UI_LoadThemeImage("scrollthumb.png")
8197
8198 This = TempThis
8199
8200 _FONT This.Font
8201
8202 IF This.Type = __UI_Type_ListBox THEN
8203 This.Min = 0
8204 This.Max = This.Max - This.LastVisibleItem
8205 This.Value = This.InputViewStart - 1
8206 This.Left = This.Width - __UI_ScrollbarWidth - 1
8207 This.Top = 1
8208 This.Height = This.Height - 1
8209 This.Width = __UI_ScrollbarWidth
8210 ELSEIF This.Type = __UI_Type_TextBox THEN
8211 This.Min = 0
8212 This.Max = __UI_CountLines(This.ID) - This.Height \ uspacing&
8213 'IF This.HasHScrollbar THEN This.Height = This.Height - __UI_ScrollbarWidth
8214 This.Value = This.FirstVisibleLine - 1
8215 This.Left = This.Width - __UI_ScrollbarWidth - 1
8216 This.Top = 1
8217 This.Height = This.Height - 1
8218 This.Width = __UI_ScrollbarWidth
8219 END IF
8220
8221 'Scrollbar measurements:
8222 TrackHeight = This.Height - __UI_ScrollbarButtonHeight * 2 - 1
8223 Ratio = (This.Max) / TrackHeight
8224 ThumbHeight = TrackHeight - This.Height * Ratio
8225 IF ThumbHeight < 22 THEN ThumbHeight = 22
8226 IF ThumbHeight > TrackHeight THEN ThumbHeight = TrackHeight
8227 ThumbTop = This.Top + (TrackHeight - ThumbHeight) * (This.Value / This.Max)
8228 TempThis.ThumbTop = TempThis.Top + ThumbTop + __UI_ScrollbarButtonHeight
8229
8230 'Draw the bar
8231 IF ControlState <> 4 THEN
8232 _PUTIMAGE (This.Left, This.Top)-STEP(ImageWidth_Button - 1, This.Height - 1), ControlImage_Track, , (0, 1 * ImageHeight_Button - ImageHeight_Button)-STEP(ImageWidth_Button - 1, ImageHeight_Button - 1)
8233 ELSE
8234 _PUTIMAGE (This.Left, This.Top)-STEP(ImageWidth_Button - 1, This.Height - 1), ControlImage_Track, , (0, 4 * ImageHeight_Button - ImageHeight_Button)-STEP(ImageWidth_Button - 1, ImageHeight_Button - 1)
8235 END IF
8236
8237 'Mousedown on the track:
8238 IF __UI_MouseDownOnID = This.ID AND This.HoveringVScrollbarButton = 4 AND __UI_DraggingThumb = False THEN
8239 'Above the thumb
8240 _PUTIMAGE (This.Left, This.Top)-STEP(ImageWidth_Button - 1, ThumbTop + ThumbHeight + __UI_ScrollbarButtonHeight - 1), ControlImage_Track, , (0, 3 * ImageHeight_Button - ImageHeight_Button)-STEP(ImageWidth_Button - 1, ImageHeight_Button - 1)
8241 ELSEIF __UI_MouseDownOnID = This.ID AND This.HoveringVScrollbarButton = 5 AND __UI_DraggingThumb = False THEN
8242 'Below the thumb
8243 _PUTIMAGE (This.Left, This.Top + ThumbTop + __UI_ScrollbarButtonHeight)-STEP(ImageWidth_Button - 1, This.Height - (This.Top + ThumbTop + __UI_ScrollbarButtonHeight) - 1), ControlImage_Track, , (0, 3 * ImageHeight_Button - ImageHeight_Button)-STEP(ImageWidth_Button - 1, ImageHeight_Button - 1)
8244 END IF
8245
8246 'Draw buttons
8247 IF ControlState = 4 THEN
8248 _PUTIMAGE (This.Left, This.Top)-STEP(ImageWidth_Button - 1, ImageHeight_Button - 1), ControlImage_Button, , (0, 4 * ImageHeight_Button - ImageHeight_Button)-STEP(ImageWidth_Button - 1, ImageHeight_Button - 1)
8249 ELSEIF This.HoveringVScrollbarButton = 1 AND __UI_MouseDownOnID = This.ID THEN
8250 _PUTIMAGE (This.Left, This.Top)-STEP(ImageWidth_Button - 1, ImageHeight_Button - 1), ControlImage_Button, , (0, 3 * ImageHeight_Button - ImageHeight_Button)-STEP(ImageWidth_Button - 1, ImageHeight_Button - 1)
8251 ELSEIF This.HoveringVScrollbarButton = 1 THEN
8252 _PUTIMAGE (This.Left, This.Top)-STEP(ImageWidth_Button - 1, ImageHeight_Button - 1), ControlImage_Button, , (0, 2 * ImageHeight_Button - ImageHeight_Button)-STEP(ImageWidth_Button - 1, ImageHeight_Button - 1)
8253 ELSE
8254 _PUTIMAGE (This.Left, This.Top)-STEP(ImageWidth_Button - 1, ImageHeight_Button - 1), ControlImage_Button, , (0, 1 * ImageHeight_Button - ImageHeight_Button)-STEP(ImageWidth_Button - 1, ImageHeight_Button - 1)
8255 END IF
8256
8257 IF ControlState = 4 THEN
8258 _PUTIMAGE (This.Left, This.Top + This.Height - ImageHeight_Button - 1)-STEP(ImageWidth_Button - 1, ImageHeight_Button - 1), ControlImage_Button, , (0, 8 * ImageHeight_Button - ImageHeight_Button)-STEP(ImageWidth_Button - 1, ImageHeight_Button - 1)
8259 ELSEIF This.HoveringVScrollbarButton = 2 AND __UI_MouseDownOnID = This.ID THEN
8260 _PUTIMAGE (This.Left, This.Top + This.Height - ImageHeight_Button - 1)-STEP(ImageWidth_Button - 1, ImageHeight_Button - 1), ControlImage_Button, , (0, 7 * ImageHeight_Button - ImageHeight_Button)-STEP(ImageWidth_Button - 1, ImageHeight_Button - 1)
8261 ELSEIF This.HoveringVScrollbarButton = 2 THEN
8262 _PUTIMAGE (This.Left, This.Top + This.Height - ImageHeight_Button - 1)-STEP(ImageWidth_Button - 1, ImageHeight_Button - 1), ControlImage_Button, , (0, 6 * ImageHeight_Button - ImageHeight_Button)-STEP(ImageWidth_Button - 1, ImageHeight_Button - 1)
8263 ELSE
8264 _PUTIMAGE (This.Left, This.Top + This.Height - ImageHeight_Button - 1)-STEP(ImageWidth_Button - 1, ImageHeight_Button - 1), ControlImage_Button, , (0, 5 * ImageHeight_Button - ImageHeight_Button)-STEP(ImageWidth_Button - 1, ImageHeight_Button - 1)
8265 END IF
8266
8267 'Draw thumb
8268 IF ControlState = 4 THEN
8269 'No thumb is shown for disabled scrollbar
8270 ELSEIF __UI_DraggingThumb = True THEN
8271 _PUTIMAGE (This.Left + 1, ThumbTop + __UI_ScrollbarButtonHeight)-STEP(ImageWidth_Thumb - 2, ThumbHeight - 1), ControlImage_Thumb, , (0, 3 * ImageHeight_Thumb - ImageHeight_Thumb + 2)-STEP(ImageWidth_Thumb - 1, ImageHeight_Thumb - 5)
8272 _PUTIMAGE (This.Left + 1, ThumbTop + __UI_ScrollbarButtonHeight)-STEP(ImageWidth_Thumb - 2, 1), ControlImage_Thumb, , (0, 3 * ImageHeight_Thumb - ImageHeight_Thumb)-STEP(ImageWidth_Thumb - 1, 1)
8273 _PUTIMAGE (This.Left + 1, ThumbTop + __UI_ScrollbarButtonHeight + ThumbHeight - 2)-STEP(ImageWidth_Thumb - 2, 1), ControlImage_Thumb, , (0, 3 * ImageHeight_Thumb - 4)-STEP(ImageWidth_Thumb - 1, 3)
8274 ELSEIF This.HoveringVScrollbarButton = 3 AND __UI_DraggingThumb = False THEN
8275 _PUTIMAGE (This.Left + 1, ThumbTop + __UI_ScrollbarButtonHeight)-STEP(ImageWidth_Thumb - 2, ThumbHeight - 1), ControlImage_Thumb, , (0, 2 * ImageHeight_Thumb - ImageHeight_Thumb + 2)-STEP(ImageWidth_Thumb - 1, ImageHeight_Thumb - 5)
8276 _PUTIMAGE (This.Left + 1, ThumbTop + __UI_ScrollbarButtonHeight)-STEP(ImageWidth_Thumb - 2, 1), ControlImage_Thumb, , (0, 2 * ImageHeight_Thumb - ImageHeight_Thumb)-STEP(ImageWidth_Thumb - 1, 1)
8277 _PUTIMAGE (This.Left + 1, ThumbTop + __UI_ScrollbarButtonHeight + ThumbHeight - 2)-STEP(ImageWidth_Thumb - 2, 1), ControlImage_Thumb, , (0, 2 * ImageHeight_Thumb - 4)-STEP(ImageWidth_Thumb - 1, 3)
8278 ELSE
8279 _PUTIMAGE (This.Left + 1, ThumbTop + __UI_ScrollbarButtonHeight)-STEP(ImageWidth_Thumb - 2, ThumbHeight - 1), ControlImage_Thumb, , (0, 1 * ImageHeight_Thumb - ImageHeight_Thumb + 2)-STEP(ImageWidth_Thumb - 1, ImageHeight_Thumb - 5)
8280 _PUTIMAGE (This.Left + 1, ThumbTop + __UI_ScrollbarButtonHeight)-STEP(ImageWidth_Thumb - 2, 1), ControlImage_Thumb, , (0, 1 * ImageHeight_Thumb - ImageHeight_Thumb)-STEP(ImageWidth_Thumb - 1, 1)
8281 _PUTIMAGE (This.Left + 1, ThumbTop + __UI_ScrollbarButtonHeight + ThumbHeight - 2)-STEP(ImageWidth_Thumb - 2, 1), ControlImage_Thumb, , (0, 1 * ImageHeight_Thumb - 4)-STEP(ImageWidth_Thumb - 1, 3)
8282 END IF
8283
8284 'Pass scrollbar parameters back to caller ID
8285 TempThis.VScrollbarButton2Top = This.Top + This.Height - ImageHeight_Button - 1
8286 TempThis.ThumbHeight = ThumbHeight
8287 TempThis.VScrollbarRatio = Ratio
8288END SUB
8289
8290'---------------------------------------------------------------------------------
8291SUB __UI_DrawDropdownList (This AS __UI_ControlTYPE, ControlState)
8292 DIM PrevDest AS LONG, i AS LONG
8293 DIM CaptionIndent AS INTEGER, TempCaption$
8294
8295 STATIC ControlImage AS LONG
8296 STATIC ControlImage_Arrow AS LONG
8297 CONST ButtonHeight = 21
8298 CONST ButtonWidth = 18
8299 CONST ArrowWidth = 9
8300 CONST ArrowHeight = 9
8301
8302 IF ControlImage = 0 THEN ControlImage = __UI_LoadThemeImage("button.png")
8303 IF ControlImage_Arrow = 0 THEN
8304 ControlImage_Arrow = __UI_LoadThemeImage("arrows.png")
8305 __UI_ClearColor ControlImage_Arrow, 0, 0
8306 END IF
8307
8308 IF This.Redraw OR This.ControlState <> ControlState OR _
8309 This.FocusState <> (__UI_Focus = This.ID) OR _
8310 This.PreviousValue <> This.Value OR _
8311 Text(This.ID) <> __UI_TempTexts(This.ID) OR _
8312 This.PreviousInputViewStart <> This.InputViewStart OR _
8313 This.PreviousParentID <> This.ParentID OR _
8314 This.PreviousFont <> This.Font OR _
8315 __UI_ForceRedraw THEN
8316 'Last time this control was drawn it had a different state/caption, so it'll be redrawn
8317 This.Redraw = False
8318 This.ControlState = ControlState
8319 This.PreviousFont = This.Font
8320 This.FocusState = __UI_Focus = This.ID
8321 IF This.PreviousValue <> This.Value THEN
8322 __UI_StateHasChanged = True
8323 This.PreviousValue = This.Value
8324 END IF
8325 This.PreviousInputViewStart = This.InputViewStart
8326 __UI_TempTexts(This.ID) = Text(This.ID)
8327 IF This.ParentID THEN Control(This.ParentID).ChildrenRedrawn = True
8328 This.PreviousParentID = This.ParentID
8329
8330 IF This.Canvas <> 0 THEN
8331 _FREEIMAGE This.Canvas
8332 END IF
8333
8334 This.Canvas = _NEWIMAGE(This.Width, This.Height, 32)
8335
8336 PrevDest = _DEST
8337 _DEST This.Canvas
8338 _FONT This.Font
8339
8340 '------
8341 IF This.BackStyle = __UI_Opaque THEN
8342 CLS , This.BackColor
8343 ELSE
8344 CLS , _RGBA32(0, 0, 0, 0)
8345 END IF
8346
8347 IF This.HasBorder THEN
8348 IF This.BorderSize > __UI_MaxBorderSize THEN
8349 This.BorderSize = __UI_MaxBorderSize
8350 ELSEIF This.BorderSize < 1 THEN
8351 This.BorderSize = 1
8352 END IF
8353 CaptionIndent = __UI_DefaultCaptionIndent + This.BorderSize
8354
8355 FOR i = 0 TO This.BorderSize - 1
8356 LINE (i, i)-STEP(This.Width - 1 - i * 2, This.Height - 1 - i * 2), This.BorderColor, B
8357 NEXT
8358 END IF
8359
8360 DIM TempText$, ThisItem%, FindLF&, ThisItemTop%
8361
8362 IF This.Value > 0 THEN
8363 IF LEN(Text(This.ID)) THEN
8364 TempText$ = Text(This.ID)
8365 ThisItem% = 0
8366 DO WHILE LEN(TempText$)
8367 ThisItem% = ThisItem% + 1
8368 FindLF& = INSTR(TempText$, CHR$(10))
8369 IF FindLF& THEN
8370 TempCaption$ = LEFT$(TempText$, FindLF& - 1)
8371 TempText$ = MID$(TempText$, FindLF& + 1)
8372 ELSE
8373 TempCaption$ = TempText$
8374 TempText$ = ""
8375 END IF
8376 IF ThisItem% = This.Value THEN
8377 ThisItemTop% = This.Height \ 2 - uspacing& \ 2 + 1
8378
8379 IF ThisItem% = This.Value AND __UI_Focus = This.ID THEN Caption(This.ID) = TempCaption$
8380
8381 IF NOT This.Disabled THEN
8382 COLOR This.ForeColor
8383 ELSE
8384 COLOR Darken(Control(__UI_FormID).BackColor, 80)
8385 END IF
8386
8387 IF __UI_Focus = This.ID THEN
8388 COLOR This.SelectedForeColor
8389 LINE (CaptionIndent, 3)-STEP(This.Width - CaptionIndent * 2, This.Height - 7), This.SelectedBackColor, BF
8390 END IF
8391
8392 SELECT CASE This.Align
8393 CASE __UI_Left
8394 __UI_PrintString CaptionIndent * 2, ThisItemTop%, TempCaption$
8395 CASE __UI_Center
8396 __UI_PrintString (This.Width \ 2 - __UI_PrintWidth(TempCaption$) \ 2), ThisItemTop%, TempCaption$
8397 CASE __UI_Right
8398 __UI_PrintString (This.Width - __UI_PrintWidth(TempCaption$)) - CaptionIndent, ThisItemTop%, TempCaption$
8399 END SELECT
8400 EXIT DO
8401 END IF
8402 LOOP
8403 END IF
8404 END IF
8405
8406 'Draw "dropdown" button
8407 DIM DropdownState AS _BYTE
8408 IF __UI_TotalActiveMenus > 0 AND __UI_ParentDropdownList = This.ID THEN
8409 DropdownState = 3
8410 ELSEIF (This.ID = __UI_HoveringID OR This.ID = __UI_ParentDropdownList) AND NOT This.Disabled THEN
8411 DropdownState = 2
8412 ELSEIF This.Disabled = True THEN
8413 DropdownState = 4
8414 ELSE
8415 DropdownState = 1
8416 END IF
8417
8418 'Back surface
8419 _PUTIMAGE (This.Width - (__UI_ScrollbarWidth + 2), 3)-(This.Width - 1, This.Height - 4), ControlImage, , (3, DropdownState * ButtonHeight - ButtonHeight + 3)-STEP(11, ButtonHeight - 7)
8420
8421 'Top and bottom edges
8422 _PUTIMAGE (This.Width - (__UI_ScrollbarWidth + 1), 0)-STEP(__UI_ScrollbarWidth - 2, 3), ControlImage, , (3, DropdownState * ButtonHeight - ButtonHeight)-STEP(11, 3)
8423 _PUTIMAGE (This.Width - (__UI_ScrollbarWidth + 1), This.Height - 3)-STEP(__UI_ScrollbarWidth - 2, 3), ControlImage, , (3, DropdownState * ButtonHeight - ButtonHeight + 18)-STEP(11, 3)
8424
8425 'Left edges and corners:
8426 _PUTIMAGE (This.Width - (__UI_ScrollbarWidth + 2), 2)-STEP(2, This.Height - 4), ControlImage, , (0, DropdownState * ButtonHeight - ButtonHeight + 2)-STEP(2, ButtonHeight - 6)
8427 _PUTIMAGE (This.Width - (__UI_ScrollbarWidth + 2), 0), ControlImage, , (0, DropdownState * ButtonHeight - ButtonHeight)-STEP(2, 2)
8428 _PUTIMAGE (This.Width - (__UI_ScrollbarWidth + 2), This.Height - 3), ControlImage, , (0, DropdownState * ButtonHeight - 3)-STEP(2, 2)
8429
8430 'Right edges and corners:
8431 _PUTIMAGE (This.Width - 3, 2)-STEP(2, This.Height - 4), ControlImage, , (ButtonWidth - 3, DropdownState * ButtonHeight - ButtonHeight + 2)-STEP(2, ButtonHeight - 6)
8432 _PUTIMAGE (This.Width - 2, 0), ControlImage, , (ButtonWidth - 2, DropdownState * ButtonHeight - ButtonHeight)-STEP(2, 2)
8433 _PUTIMAGE (This.Width - 3, This.Height - 3), ControlImage, , (ButtonWidth - 3, DropdownState * ButtonHeight - 3)-STEP(2, 2)
8434
8435 'Arrow
8436 _PUTIMAGE (This.Width - 1 - (__UI_ScrollbarWidth / 2) - ArrowWidth / 2, This.Height / 2 - ArrowHeight / 2), ControlImage_Arrow, , (0, (DropdownState + 4) * ArrowHeight - ArrowHeight)-STEP(ArrowWidth - 1, ArrowHeight - 1)
8437 '------
8438
8439 __UI_MakeHardwareImageFromCanvas This
8440 _DEST PrevDest
8441 END IF
8442
8443 IF This.Canvas THEN _PUTIMAGE (This.Left, This.Top), This.Canvas
8444END SUB
8445
8446'---------------------------------------------------------------------------------
8447SUB __UI_DrawFrame (This AS __UI_ControlTYPE)
8448 DIM TempCaption$, CaptionIndent AS INTEGER, Temp&
8449 DIM TempCanvas AS LONG
8450
8451 STATIC ControlImage AS LONG
8452
8453 IF ControlImage = 0 THEN
8454 ControlImage = __UI_LoadThemeImage("frame.png")
8455 __UI_ClearColor ControlImage, 0, 0
8456 END IF
8457
8458 IF This.Redraw OR This.PreviouslyHidden <> This.Hidden OR This.ChildrenRedrawn OR Caption(This.ID) <> __UI_TempCaptions(This.ID) OR This.HelperCanvas = 0 OR (__UI_IsDragging AND Control(__UI_DraggingID).ParentID = This.ID) OR This.Value <> This.PreviousValue OR __UI_ForceRedraw _
8459 OR __UI_DesignMode OR This.PreviousFont <> This.Font THEN
8460 'Last time we drew this frame its children had different images
8461 This.Redraw = False
8462 This.ChildrenRedrawn = False
8463 This.PreviousFont = This.Font
8464 This.PreviousValue = This.Value
8465 This.PreviouslyHidden = This.Hidden
8466 __UI_TempCaptions(This.ID) = Caption(This.ID)
8467
8468 _FONT This.Font
8469 TempCanvas = _NEWIMAGE(This.Width, This.Height + uspacing& \ 2, 32)
8470
8471 _DEST TempCanvas
8472 _FONT This.Font
8473
8474 '------
8475 IF LEN(Caption(This.ID)) > 0 THEN TempCaption$ = " " + __UI_TrimAt0$(Caption(This.ID)) + " "
8476
8477 _FONT This.Font
8478
8479 IF This.Hidden = False THEN
8480 IF This.BackStyle = __UI_Opaque THEN
8481 CLS , This.BackColor
8482 ELSE
8483 CLS , _RGBA32(0, 0, 0, 0)
8484 END IF
8485
8486 CaptionIndent = 0
8487 IF This.HasBorder THEN CaptionIndent = 5
8488
8489 IF NOT This.Disabled THEN
8490 COLOR This.ForeColor
8491 ELSE
8492 COLOR Darken(Control(__UI_FormID).BackColor, 80)
8493 END IF
8494
8495 'This.Canvas holds the children controls' images
8496 _PUTIMAGE (CaptionIndent, CaptionIndent + uspacing& \ 2), This.Canvas, TempCanvas, (CaptionIndent, CaptionIndent)-(This.Width, This.Height)
8497
8498 IF This.HasBorder THEN
8499 'Four corners;
8500 _PUTIMAGE (0, uspacing& \ 2), ControlImage, , (0, 0)-STEP(2, 2)
8501 _PUTIMAGE (This.Width - 3, uspacing& \ 2), ControlImage, , (19, 0)-STEP(2, 2)
8502 _PUTIMAGE (0, This.Height + uspacing& \ 2 - 3), ControlImage, , (0, 17)-STEP(2, 2)
8503 _PUTIMAGE (This.Width - 3, This.Height + uspacing& \ 2 - 3), ControlImage, , (19, 17)-STEP(2, 2)
8504
8505 'Two vertical lines
8506 _PUTIMAGE (0, uspacing& \ 2 + 2)-(0, This.Height + uspacing& \ 2 - 4), ControlImage, , (0, 3)-(0, 16)
8507 _PUTIMAGE (This.Width - 1, uspacing& \ 2 + 2)-(This.Width - 1, This.Height + uspacing& \ 2 - 4), ControlImage, , (0, 3)-(0, 16)
8508
8509 'Two horizontal lines
8510 _PUTIMAGE (3, uspacing& \ 2)-STEP(This.Width - 6, 0), ControlImage, , (3, 0)-STEP(15, 0)
8511 _PUTIMAGE (3, This.Height + uspacing& \ 2 - 1)-STEP(This.Width - 6, 0), ControlImage, , (3, 0)-STEP(15, 0)
8512 END IF
8513
8514 DIM CaptionLeft AS INTEGER
8515
8516 IF LEN(TempCaption$) > 0 THEN
8517 SELECT CASE This.Align
8518 CASE __UI_Left
8519 CaptionLeft = CaptionIndent
8520 CASE __UI_Center
8521 CaptionLeft = (This.Width \ 2 - __UI_PrintWidth(TempCaption$) \ 2)
8522 CASE __UI_Right
8523 CaptionLeft = (This.Width - __UI_PrintWidth(TempCaption$)) - CaptionIndent
8524 END SELECT
8525
8526 LINE (CaptionLeft, 0)-STEP(__UI_PrintWidth(TempCaption$), uspacing&), This.BackColor, BF
8527 __UI_PrintString CaptionLeft, 0, TempCaption$
8528
8529 'Hot key:
8530 IF (This.HotKey > 0 AND (__UI_ShowHotKeys AND NOT This.Disabled)) OR (This.HotKey > 0 AND __UI_DesignMode) THEN
8531 Temp& = __UI_PrintWidth(CHR$(This.HotKey))
8532 LINE (CaptionLeft + Temp& + This.HotKeyOffset, uheight&)-STEP(Temp& - 1, 0), This.ForeColor
8533 END IF
8534 END IF
8535 END IF
8536 '------
8537
8538 __UI_MakeHardwareImage TempCanvas
8539 IF This.HelperCanvas <> 0 THEN _FREEIMAGE This.HelperCanvas
8540 This.HelperCanvas = TempCanvas
8541 _DEST 0
8542 END IF
8543
8544 _FONT This.Font
8545 IF This.HelperCanvas < -1 THEN _PUTIMAGE (This.Left, This.Top - uspacing& \ 2), This.HelperCanvas
8546END SUB
8547
8548'---------------------------------------------------------------------------------
8549SUB __UI_DrawMenuBar (This AS __UI_ControlTYPE, ControlState AS _BYTE)
8550 DIM PrevDest AS LONG, TempCaption$
8551 DIM Temp&
8552
8553 IF This.Redraw OR This.FocusState <> (__UI_Focus = This.ID) OR This.Value <> This.PreviousValue OR This.ControlState <> ControlState OR Caption(This.ID) <> __UI_TempCaptions(This.ID) _
8554 OR __UI_ForceRedraw OR This.PreviousFont <> This.Font THEN
8555 'Last time this control was drawn it had a different state/caption, so it'll be redrawn
8556 This.Redraw = False
8557 This.ControlState = ControlState
8558 This.PreviousFont = This.Font
8559 This.PreviousValue = This.Value
8560
8561 IF Caption(This.ID) <> __UI_TempCaptions(This.ID) THEN
8562 __UI_RefreshMenuBar
8563 END IF
8564
8565 __UI_TempCaptions(This.ID) = Caption(This.ID)
8566 This.FocusState = (__UI_Focus = This.ID)
8567
8568 IF This.Canvas <> 0 THEN
8569 _FREEIMAGE This.Canvas
8570 END IF
8571
8572 This.Canvas = _NEWIMAGE(This.Width, This.Height, 32)
8573
8574 PrevDest = _DEST
8575 _DEST This.Canvas
8576 _FONT (This.Font)
8577
8578 '---
8579 CLS , This.BackColor
8580
8581 TempCaption$ = __UI_TrimAt0$(Caption(This.ID))
8582
8583 IF __UI_Focus = This.ID OR _
8584 (__UI_ParentMenu(__UI_TotalActiveMenus) = This.ID AND (Control(__UI_Focus).Type = __UI_Type_MenuPanel OR Control(__UI_Focus).Type = __UI_Type_MenuItem)) OR _
8585 (__UI_HoveringID = This.ID AND (Control(__UI_Focus).Type <> __UI_Type_MenuPanel AND Control(__UI_Focus).Type <> __UI_Type_MenuBar AND Control(__UI_Focus).Type <> __UI_Type_MenuItem)) THEN
8586 LINE (0, 0)-STEP(This.Width - 1, This.Height - 1), This.SelectedBackColor, BF
8587 COLOR This.SelectedForeColor
8588 ELSE
8589 COLOR This.ForeColor
8590 END IF
8591
8592 IF This.Disabled THEN
8593 COLOR Darken(Control(__UI_FormID).BackColor, 80)
8594 END IF
8595
8596 __UI_PrintString __UI_MenuBarOffset, ((This.Height \ 2) - (falcon_uspacing& + (((_FONT = 8) * -1) * __UI_Font8Offset + ((_FONT = 16) * -1) * __UI_Font16Offset)) \ 2), TempCaption$
8597 IF This.HotKey > 0 AND (__UI_AltIsDown OR Control(__UI_Focus).Type = __UI_Type_MenuBar OR __UI_DesignMode) THEN
8598 'Has "hot-key"
8599 Temp& = __UI_PrintWidth(CHR$(This.HotKey))
8600 LINE (__UI_MenuBarOffset + This.HotKeyOffset, ((This.Height \ 2) + (falcon_uspacing& + (((_FONT = 8) * -1) * __UI_Font8Offset + ((_FONT = 16) * -1) * __UI_Font16Offset)) \ 2) - 1)-STEP(Temp& - 1, 0), _DEFAULTCOLOR
8601 END IF
8602
8603 IF __UI_DesignMode THEN
8604 IF This.Left + This.Width = __UI_NewMenuBarTextLeft THEN
8605 'Last menu bar item. Next is "Add new"
8606 _DEST Control(__UI_FormID).Canvas
8607 COLOR Darken(Control(__UI_FormID).BackColor, 80)
8608 _FONT (This.Font)
8609 LINE (__UI_NewMenuBarTextLeft + __UI_MenuBarOffset, ((This.Height \ 2) - (falcon_uspacing& + (((_FONT = 8) * -1) * __UI_Font8Offset + ((_FONT = 16) * -1) * __UI_Font16Offset)) \ 2))-STEP(__UI_PrintWidth("Add new"),(falcon_uspacing& + (((_FONT = 8) * -1) * __UI_Font8Offset + ((_FONT = 16) * -1) * __UI_Font16Offset))), Control(__UI_FormID).BackColor, BF
8610 __UI_PrintString __UI_NewMenuBarTextLeft + __UI_MenuBarOffset, ((This.Height \ 2) - (falcon_uspacing& + (((_FONT = 8) * -1) * __UI_Font8Offset + ((_FONT = 16) * -1) * __UI_Font16Offset)) \ 2), "Add new"
8611 END IF
8612 END IF
8613 '---
8614
8615 __UI_MakeHardwareImageFromCanvas This
8616 _DEST PrevDest
8617 END IF
8618
8619 IF This.Canvas THEN _PUTIMAGE (This.Left, This.Top), This.Canvas
8620END SUB
8621
8622'---------------------------------------------------------------------------------
8623SUB __UI_DrawMenuPanel (This AS __UI_ControlTYPE, Parent AS LONG)
8624 DIM PrevDest AS LONG, TempCaption$
8625 DIM Temp&
8626
8627 DIM CheckMarkIndex AS _BYTE
8628 STATIC ControlImage AS LONG, SubMenuArrow AS LONG
8629 CONST CheckMarkWidth = 7
8630 CONST CheckMarkHeight = 7
8631 IF ControlImage = 0 THEN
8632 ControlImage = __UI_LoadThemeImage("menucheckmark.bmp")
8633 __UI_ClearColor ControlImage, 0, 0
8634 END IF
8635 IF SubMenuArrow = 0 THEN
8636 SubMenuArrow = _NEWIMAGE(4, 7, 32)
8637 PrevDest = _DEST
8638 _DEST SubMenuArrow
8639 LINE (0, 0)-(3, 3), _RGB32(0, 0, 0)
8640 LINE -(0, 6), _RGB32(0, 0, 0)
8641 LINE -(0, 0), _RGB32(0, 0, 0)
8642 PAINT (2, 3), _RGB32(0, 0, 0)
8643 _DEST PrevDest
8644 END IF
8645
8646 IF This.Redraw OR This.Value <> This.PreviousValue OR This.FocusState <> (__UI_Focus = This.ID) _
8647 OR __UI_ForceRedraw OR This.PreviousFont <> This.Font THEN
8648 'Last time this control was drawn it had a different state/caption, so it'll be redrawn
8649 This.Redraw = False
8650 This.FocusState = (__UI_Focus = This.ID)
8651 This.PreviousFont = This.Font
8652 This.PreviousValue = This.Value
8653
8654 IF This.Canvas <> 0 THEN
8655 _FREEIMAGE This.Canvas
8656 END IF
8657
8658 This.Canvas = _NEWIMAGE(This.Width + 5, This.Height + 5, 32)
8659
8660 PrevDest = _DEST
8661 _DEST This.Canvas
8662 _FONT (This.Font)
8663
8664 '---
8665 COLOR , _RGBA32(0, 0, 0, 0)
8666 CLS
8667
8668 'White panel:
8669 __UI_ShadowBox 0, 0, This.Width - 1, This.Height - 1, _RGB32(255, 255, 255), 40, 5
8670 LINE (0, 0)-STEP(This.Width - 1, This.Height - 1), This.BorderColor, B
8671
8672 DIM i AS LONG, HasSeparator as _BYTE
8673 FOR i = 1 TO UBOUND(Control)
8674 IF Control(i).Type = __UI_Type_MenuItem AND NOT Control(i).Hidden AND Control(i).ParentID = Parent THEN
8675 TempCaption$ = __UI_TrimAt0$(Caption(i))
8676
8677 IF RIGHT$(TempCaption$, 1) = "-" THEN
8678 HasSeparator = True
8679 TempCaption$ = LEFT$(TempCaption$, LEN(TempCaption$) - 1)
8680 ELSE
8681 HasSeparator = False
8682 END IF
8683
8684 IF __UI_Focus = i OR (__UI_HoveringID = i AND __UI_Focus = i) THEN
8685 LINE (3, Control(i).Top)-STEP(This.Width - 7, Control(i).Height - 1), This.SelectedBackColor, BF
8686 COLOR This.SelectedForeColor
8687 CheckMarkIndex = 2
8688 ELSE
8689 COLOR This.ForeColor
8690 CheckMarkIndex = 1
8691 END IF
8692
8693 IF Control(i).Disabled THEN
8694 COLOR Darken(Control(__UI_FormID).BackColor, 80)
8695 CheckMarkIndex = 3
8696 END IF
8697
8698 __UI_PrintString Control(i).Left + __UI_MenuItemOffset, Control(i).Top + Control(i).Height \ 2 - uheight& \ 2, TempCaption$
8699 IF Control(i).KeyCombo > 0 THEN
8700 __UI_PrintString Control(i).Left + This.Width - __UI_MenuItemOffset - __UI_PrintWidth(RTRIM$(__UI_KeyCombo(Control(i).KeyCombo).FriendlyCombo)), Control(i).Top + Control(i).Height \ 2 - uheight& \ 2, RTRIM$(__UI_KeyCombo(Control(i).KeyCombo).FriendlyCombo)
8701 END IF
8702
8703 IF Control(i).SubMenu THEN
8704 _PUTIMAGE (This.Width - __UI_MenuItemOffset / 2, Control(i).Top + Control(i).Height / 2 - 3), SubMenuArrow
8705 END IF
8706
8707 IF Control(i).HotKey > 0 THEN
8708 'Has "hot-key"
8709 Temp& = __UI_PrintWidth(CHR$(Control(i).HotKey))
8710 LINE (Control(i).Left + __UI_MenuItemOffset + Control(i).HotKeyOffset, Control(i).Top + Control(i).Height \ 2 + uheight& \ 2 - 1)-STEP(Temp& - 1, 0), _DEFAULTCOLOR
8711 END IF
8712
8713 IF Control(i).Value = True THEN
8714 'Checked menu item
8715 IF Control(i).BulletStyle = __UI_Bullet%% THEN
8716 __UI_PrintString __UI_MenuItemOffset \ 2 - __UI_PrintWidth(CHR$(7)) \ 2, Control(i).Top + Control(i).Height \ 2 - uheight \ 2, CHR$(7)
8717 ELSE
8718 _PUTIMAGE (__UI_MenuItemOffset \ 2 - CheckMarkWidth \ 2, Control(i).Top + Control(i).Height \ 2 - CheckMarkHeight \ 2), ControlImage, , (0, CheckMarkIndex * CheckMarkHeight - CheckMarkHeight)-STEP(6, 6)
8719 END IF
8720 ELSE
8721 'Does this menu item have a helper canvas (icon)?
8722 DIM IconWidth AS INTEGER, IconHeight AS INTEGER
8723 IF Control(i).HelperCanvas < -1 THEN
8724 IF _HEIGHT(Control(i).HelperCanvas) = 16 AND _WIDTH(Control(i).HelperCanvas) MOD 16 = 0 THEN
8725 'If the HelperCanvas is 16px in height and either 16, 32 or 48px in width,
8726 'we assume that we have icons for Hover and Disabled states.
8727 SELECT CASE CheckMarkIndex
8728 CASE 1 'normal
8729 _PUTIMAGE(3, Control(i).Top + Control(i).Height / 2 - 8)-STEP(15, 15), Control(i).HelperCanvas, ,(0, 0)-STEP(15, 15)
8730 CASE 2 'hovered/selected
8731 IF _WIDTH(Control(i).HelperCanvas) >= 32 THEN
8732 _PUTIMAGE(3, Control(i).Top + Control(i).Height / 2 - 8)-STEP(15, 15), Control(i).HelperCanvas, ,(16, 0)-STEP(15, 15)
8733 ELSE
8734 _PUTIMAGE(3, Control(i).Top + Control(i).Height / 2 - 8)-STEP(15, 15), Control(i).HelperCanvas, ,(0, 0)-STEP(15, 15)
8735 END IF
8736 CASE 3 'disabled
8737 IF _WIDTH(Control(i).HelperCanvas) >= 48 THEN
8738 _PUTIMAGE(3, Control(i).Top + Control(i).Height / 2 - 8)-STEP(15, 15), Control(i).HelperCanvas, ,(32, 0)-STEP(15, 15)
8739 ELSE
8740 _PUTIMAGE(3, Control(i).Top + Control(i).Height / 2 - 8)-STEP(15, 15), Control(i).HelperCanvas, ,(0, 0)-STEP(15, 15)
8741 END IF
8742 END SELECT
8743 ELSE
8744 'Icon will be to the left of caption
8745 IconHeight = 16
8746 IconWidth = _WIDTH(Control(i).HelperCanvas) * IconHeight / _HEIGHT(Control(i).HelperCanvas)
8747 _PUTIMAGE (3, Control(i).Top + Control(i).Height / 2 - IconHeight / 2)-STEP(IconWidth - 1, IconHeight - 1), Control(i).HelperCanvas
8748 END IF
8749 END IF
8750 END IF
8751
8752 IF HasSeparator THEN
8753 LINE (4, Control(i).Top + Control(i).Height + 3)-STEP(This.Width - 9, 0), This.BorderColor
8754 END IF
8755 END IF
8756 NEXT
8757
8758 IF __UI_DesignMode AND LEFT$(This.Name, 5) <> "__UI_" THEN
8759 COLOR Darken(Control(__UI_FormID).BackColor, 80)
8760 __UI_PrintString __UI_MenuItemOffset, This.Height - (uheight& + 6), "Add new"
8761 END IF
8762 '---
8763
8764 __UI_MakeHardwareImageFromCanvas This
8765 _DEST PrevDest
8766 END IF
8767
8768 IF This.Canvas THEN _PUTIMAGE (This.Left, This.Top), This.Canvas
8769END SUB
8770
8771'---------------------------------------------------------------------------------
8772SUB __UI_DrawContextMenuHandle (This AS __UI_ControlTYPE, ControlState AS _BYTE)
8773 DIM PrevDest AS LONG
8774 DIM i AS LONG
8775
8776 IF This.Redraw OR Control(__UI_FormID).Height <> This.PreviousValue OR This.ControlState <> ControlState OR __UI_ForceRedraw THEN
8777 'Last time this control was drawn it had a different state/caption, so it'll be redrawn
8778 This.Redraw = False
8779 This.ControlState = ControlState
8780 This.PreviousValue = Control(__UI_FormID).Height
8781
8782 IF This.Canvas <> 0 THEN
8783 _FREEIMAGE This.Canvas
8784 END IF
8785
8786 This.Canvas = _NEWIMAGE(This.Width, This.Height, 32)
8787
8788 This.Top = Control(__UI_FormID).Height - This.Height - __UI_SnapDistanceFromForm
8789
8790 PrevDest = _DEST
8791 _DEST This.Canvas
8792 _FONT This.Font
8793 '------
8794 SELECT CASE This.ControlState
8795 '1 = Normal; 2 = Hover/focus; 3 = Mouse down; 4 = Disabled;
8796 CASE 1
8797 COLOR This.SelectedBackColor, This.SelectedForeColor
8798 CASE 2
8799 COLOR This.SelectedForeColor, This.SelectedBackColor
8800 END SELECT
8801
8802 CLS
8803
8804 IF This.HelperCanvas < -1 THEN
8805 _PUTIMAGE ((_WIDTH - _WIDTH(This.HelperCanvas)) / 2, (_HEIGHT - _HEIGHT(This.HelperCanvas)) / 2), This.HelperCanvas
8806 END IF
8807
8808 i = 0
8809 LINE (i, i)-STEP(This.Width - 1 - i * 2, This.Height - 1 - i * 2), This.BorderColor, B
8810 '------
8811
8812 __UI_MakeHardwareImageFromCanvas This
8813 _DEST PrevDest
8814 END IF
8815
8816 IF This.Canvas THEN _PUTIMAGE (This.Left, This.Top), This.Canvas
8817END SUB
8818
8819'---------------------------------------------------------------------------------
8820SUB __UI_DrawPictureBox (This AS __UI_ControlTYPE, ControlState AS _BYTE)
8821 DIM PrevDest AS LONG, TheX AS INTEGER, TheY AS INTEGER
8822 DIM i AS LONG
8823
8824 IF This.Redraw OR This.Stretch <> This.PreviousStretch OR This.PreviousValue <> This.HelperCanvas OR This.ControlState <> ControlState OR This.PreviousParentID <> This.ParentID _
8825 OR __UI_ForceRedraw OR This.PreviousFont <> This.Font THEN
8826 'Last time this control was drawn it had a different state/caption, so it'll be redrawn
8827 This.Redraw = False
8828 This.ControlState = ControlState
8829 This.PreviousFont = This.Font
8830 IF This.ParentID THEN Control(This.ParentID).ChildrenRedrawn = True
8831 This.PreviousParentID = This.ParentID
8832 This.PreviousValue = This.HelperCanvas
8833 This.PreviousStretch = This.Stretch
8834
8835 IF This.Canvas <> 0 THEN
8836 _FREEIMAGE This.Canvas
8837 END IF
8838
8839 This.Canvas = _NEWIMAGE(This.Width, This.Height, 32)
8840
8841 PrevDest = _DEST
8842 _DEST This.Canvas
8843 '------
8844 IF This.BackStyle = __UI_Opaque THEN
8845 CLS , This.BackColor
8846 ELSE
8847 CLS , _RGBA32(0, 0, 0, 0)
8848 END IF
8849
8850 IF This.HasBorder THEN
8851 IF This.BorderSize > __UI_MaxBorderSize THEN
8852 This.BorderSize = __UI_MaxBorderSize
8853 ELSEIF This.BorderSize < 1 THEN
8854 This.BorderSize = 1
8855 END IF
8856 END IF
8857
8858 IF This.Stretch THEN
8859 _PUTIMAGE (This.BorderSize * ABS(This.HasBorder), This.BorderSize * ABS(This.HasBorder))-(This.Width - (This.BorderSize * ABS(This.HasBorder) + 1), This.Height - (This.BorderSize * ABS(This.HasBorder) + 1)), This.HelperCanvas, This.Canvas
8860 ELSE
8861 TheX = This.BorderSize * ABS(This.HasBorder) 'Default = Left
8862 IF This.Align = __UI_Center THEN TheX = This.Width / 2 - _WIDTH(This.HelperCanvas) / 2
8863 IF This.Align = __UI_Right THEN TheX = This.Width - 1 - _WIDTH(This.HelperCanvas) - (This.BorderSize * ABS(This.HasBorder))
8864
8865 TheY = This.BorderSize * ABS(This.HasBorder) 'Default = Top
8866 IF This.VAlign = __UI_Middle THEN TheY = This.Height / 2 - _HEIGHT(This.HelperCanvas) / 2
8867 IF This.VAlign = __UI_Bottom THEN TheY = This.Height - 1 - _HEIGHT(This.HelperCanvas) - (This.BorderSize * ABS(This.HasBorder))
8868
8869 _PUTIMAGE (TheX, TheY), This.HelperCanvas, This.Canvas
8870 END IF
8871
8872 IF This.HasBorder THEN
8873 FOR i = 0 TO This.BorderSize - 1
8874 LINE (i, i)-STEP(This.Width - 1 - i * 2, This.Height - 1 - i * 2), This.BorderColor, B
8875 NEXT
8876 END IF
8877 '------
8878
8879 __UI_MakeHardwareImageFromCanvas This
8880 _DEST PrevDest
8881 END IF
8882
8883 IF This.Canvas THEN _PUTIMAGE (This.Left, This.Top), This.Canvas
8884END SUB
8885
8886'---------------------------------------------------------------------------------
8887SUB __UI_ShadowBox (bX AS INTEGER, bY AS INTEGER, bW AS INTEGER, bH AS INTEGER, C AS LONG, shadowLevel AS INTEGER, shadowSize AS INTEGER)
8888 DIM i AS INTEGER
8889
8890 FOR i = 1 TO shadowSize
8891 LINE (bX + i, bY + i)-STEP(bW, bH), _RGBA32(0, 0, 0, shadowLevel - (shadowLevel / shadowSize) * i), BF
8892 NEXT i
8893
8894 LINE (bX, bY)-STEP(bW, bH), C, BF
8895END SUB
8896
8897'VWATCH64:ON