diff --git a/UI.bas b/UI.bas index 14842e7..231b3d2 100644 --- a/UI.bas +++ b/UI.bas @@ -12,6 +12,7 @@ TYPE ObjectTYPE Left AS INTEGER Width AS INTEGER Height AS INTEGER + Canvas AS LONG Font AS INTEGER BackColor AS _UNSIGNED LONG ForeColor AS _UNSIGNED LONG @@ -36,6 +37,7 @@ TYPE ObjectTYPE CanDrag AS _BYTE CanHaveFocus AS _BYTE Enabled AS _BYTE + Hidden AS _BYTE END TYPE REDIM SHARED __UI_Captions(1 TO 100) AS STRING @@ -47,7 +49,8 @@ __UI_Fonts(0) = 16 __UI_Fonts(1) = 8 __UI_Fonts(2) = __UI_LoadFont("cyberbit.ttf", 14, "") -DIM SHARED __UI_MouseX AS INTEGER, __UI_MouseY AS INTEGER +DIM SHARED __UI_MouseLeft AS INTEGER, __UI_MouseTop AS INTEGER +DIM SHARED __UI_MouseWheel AS INTEGER DIM SHARED __UI_PrevMouseX AS INTEGER, __UI_PrevMouseY AS INTEGER DIM SHARED __UI_MouseButton1 AS _BYTE, __UI_MouseButton2 AS _BYTE DIM SHARED __UI_PrevMouseButton1 AS _BYTE, __UI_PrevMouseButton2 AS _BYTE @@ -103,15 +106,13 @@ CONST __UI_False = 0 DIM NewID AS LONG, ParentID AS LONG -NewID = __UI_NewObject(__UI_Type_Form, "Form1", 0) -__UI_Controls(NewID).Width = 640 -__UI_Controls(NewID).Height = 400 +NewID = __UI_NewObject(__UI_Type_Form, "Form1", 640, 400, 0) __UI_Controls(NewID).ForeColor = _RGB32(0, 0, 0) __UI_Controls(NewID).BackColor = _RGB32(235, 233, 237) __UI_Controls(NewID).Enabled = __UI_True __UI_SetCaption "Form1", "Hello, world!" -NewID = __UI_NewObject(__UI_Type_Button, "Button1", 0) +NewID = __UI_NewObject(__UI_Type_Button, "Button1", 0, 0, 0) __UI_Controls(NewID).Top = 100 __UI_Controls(NewID).Left = 100 __UI_Controls(NewID).Width = 200 @@ -122,18 +123,18 @@ __UI_Controls(NewID).CanHaveFocus = __UI_True __UI_Controls(NewID).Enabled = __UI_True __UI_SetCaption "Button1", "Click me" -NewID = __UI_NewObject(__UI_Type_Button, "Button2", 0) +NewID = __UI_NewObject(__UI_Type_Button, "Button2", 0, 0, 0) __UI_Controls(NewID).Top = 200 __UI_Controls(NewID).Left = 100 -__UI_Controls(NewID).Width = 200 +__UI_Controls(NewID).Width = 230 __UI_Controls(NewID).Height = 20 __UI_Controls(NewID).ForeColor = _RGB32(255, 255, 255) __UI_Controls(NewID).BackColor = _RGB32(51, 152, 219) __UI_Controls(NewID).CanHaveFocus = __UI_True __UI_Controls(NewID).Enabled = __UI_True -__UI_SetCaption "Button2", "Make this form resizable" +__UI_SetCaption "Button2", "Detach ListBox from frame" -NewID = __UI_NewObject(__UI_Type_TextBox, "Textbox1", 0) +NewID = __UI_NewObject(__UI_Type_TextBox, "Textbox1", 0, 0, 0) __UI_Controls(NewID).Top = 250 __UI_Controls(NewID).Left = 30 __UI_Controls(NewID).Width = 300 @@ -147,7 +148,7 @@ __UI_Controls(NewID).CanHaveFocus = __UI_True __UI_Controls(NewID).Enabled = __UI_True __UI_SetCaption "Textbox1", "Edit me" -NewID = __UI_NewObject(__UI_Type_Button, "DragButton", 0) +NewID = __UI_NewObject(__UI_Type_Button, "DragButton", 0, 0, 0) __UI_Controls(NewID).Top = 300 __UI_Controls(NewID).Left = 100 __UI_Controls(NewID).Width = 200 @@ -156,14 +157,112 @@ __UI_Controls(NewID).ForeColor = _RGB32(255, 255, 255) __UI_Controls(NewID).BackColor = _RGB32(188, 152, 116) __UI_Controls(NewID).CanHaveFocus = __UI_True __UI_Controls(NewID).Enabled = __UI_True -__UI_SetCaption "DragButton", "Make frame draggable" +__UI_SetCaption "DragButton", "Make ListBox draggable" -NewID = __UI_NewObject(__UI_Type_ListBox, "ListBox1", 0) -__UI_Controls(NewID).Top = 160 -__UI_Controls(NewID).Left = 350 +NewID = __UI_NewObject(__UI_Type_Label, "Label1", 0, 0, 0) +__UI_Controls(NewID).Top = 30 +__UI_Controls(NewID).Left = 10 +__UI_Controls(NewID).Width = 400 +__UI_Controls(NewID).Height = 20 +__UI_Controls(NewID).Font = 2 +__UI_Controls(NewID).ForeColor = _RGB32(238, 238, 200) +__UI_Controls(NewID).BackColor = _RGB32(33, 100, 78) +__UI_Controls(NewID).Align = __UI_Center +__UI_Controls(NewID).Enabled = __UI_True +__UI_SetCaption "Label1", "Waiting for you to click" + +NewID = __UI_NewObject(__UI_Type_Label, "FocusLabel", 0, 0, 0) +__UI_Controls(NewID).Top = 55 +__UI_Controls(NewID).Left = 10 +__UI_Controls(NewID).Width = 400 +__UI_Controls(NewID).Height = 20 +__UI_Controls(NewID).ForeColor = _RGB32(0, 0, 0) +__UI_Controls(NewID).Enabled = __UI_True +__UI_SetCaption "FocusLabel", "No object has focus now" +__UI_Controls(NewID).Font = 1 + +NewID = __UI_NewObject(__UI_Type_Label, "HoverLabel", 0, 0, 0) +__UI_Controls(NewID).Top = 75 +__UI_Controls(NewID).Left = 10 +__UI_Controls(NewID).Width = 400 +__UI_Controls(NewID).Height = 20 +__UI_Controls(NewID).ForeColor = _RGB32(0, 0, 0) +__UI_Controls(NewID).Enabled = __UI_True +__UI_Controls(NewID).Font = 1 + +NewID = __UI_NewObject(__UI_Type_Label, "Label2", 0, 0, 0) +__UI_Controls(NewID).Top = 350 +__UI_Controls(NewID).Left = 30 +__UI_Controls(NewID).Width = 300 +__UI_Controls(NewID).Height = 20 +__UI_Controls(NewID).ForeColor = _RGB32(0, 0, 0) +__UI_Controls(NewID).BackStyle = __UI_Transparent +__UI_Controls(NewID).HasBorder = __UI_False +__UI_Controls(NewID).BorderColor = _RGB32(0, 0, 0) +__UI_Controls(NewID).Enabled = __UI_True + +NewID = __UI_NewObject(__UI_Type_Frame, "Frame1", 230, 280, 0) +__UI_Controls(NewID).Top = 60 +__UI_Controls(NewID).Left = 400 +__UI_Controls(NewID).ForeColor = _RGB32(0, 0, 0) +__UI_Controls(NewID).BackColor = __UI_Controls(__UI_GetID("Form1")).BackColor +__UI_Controls(NewID).HasBorder = __UI_True +__UI_Controls(NewID).BorderColor = _RGB32(0, 0, 0) +__UI_Controls(NewID).Enabled = __UI_True +__UI_SetCaption "Frame1", "A cute container" + +NewID = __UI_NewObject(__UI_Type_RadioButton, "Option1", 0, 0, __UI_GetID("Frame1")) +__UI_Controls(NewID).Top = 15 +__UI_Controls(NewID).Left = 15 +__UI_Controls(NewID).Width = 110 +__UI_Controls(NewID).Height = 10 +__UI_Controls(NewID).ForeColor = _RGB32(0, 0, 0) +__UI_Controls(NewID).Enabled = __UI_True +__UI_Controls(NewID).Value = __UI_True +__UI_Controls(NewID).CanHaveFocus = __UI_True +__UI_SetCaption "Option1", "Option 1" +__UI_Controls(NewID).Font = 2 + +NewID = __UI_NewObject(__UI_Type_RadioButton, "Option2", 0, 0, __UI_GetID("Frame1")) +__UI_Controls(NewID).Top = 40 +__UI_Controls(NewID).Left = 15 +__UI_Controls(NewID).Width = 110 +__UI_Controls(NewID).Height = 10 +__UI_Controls(NewID).ForeColor = _RGB32(0, 0, 0) +__UI_Controls(NewID).Enabled = __UI_True +__UI_Controls(NewID).CanHaveFocus = __UI_True +__UI_SetCaption "Option2", "Option 2" +__UI_Controls(NewID).Font = 2 + +NewID = __UI_NewObject(__UI_Type_CheckBox, "Check1", 0, 0, __UI_GetID("Frame1")) +__UI_Controls(NewID).Top = 65 +__UI_Controls(NewID).Left = 15 +__UI_Controls(NewID).Width = 110 +__UI_Controls(NewID).Height = 10 +__UI_Controls(NewID).ForeColor = _RGB32(0, 0, 0) +__UI_Controls(NewID).Enabled = __UI_True +__UI_Controls(NewID).CanHaveFocus = __UI_True +__UI_SetCaption "Check1", "Checkbox 1" +__UI_Controls(NewID).Font = 2 + +NewID = __UI_NewObject(__UI_Type_CheckBox, "Check2", 0, 0, __UI_GetID("Frame1")) +__UI_Controls(NewID).Top = 90 +__UI_Controls(NewID).Left = 15 +__UI_Controls(NewID).Width = 110 +__UI_Controls(NewID).Height = 10 +__UI_Controls(NewID).ForeColor = _RGB32(0, 0, 0) +__UI_Controls(NewID).Enabled = __UI_True +__UI_Controls(NewID).Value = __UI_True +__UI_Controls(NewID).CanHaveFocus = __UI_True +__UI_SetCaption "Check2", "Checkbox 2" +__UI_Controls(NewID).Font = 2 + +NewID = __UI_NewObject(__UI_Type_ListBox, "ListBox1", 0, 0, __UI_GetID("Frame1")) +__UI_Controls(NewID).Top = 110 +__UI_Controls(NewID).Left = 15 __UI_Controls(NewID).Width = 200 -__UI_Controls(NewID).Height = 200 -'__UI_Controls(NewID).Font = 2 +__UI_Controls(NewID).Height = 155 +'__UI_Controls(NewID).Font = 1 __UI_Controls(NewID).ForeColor = _RGB32(0, 0, 0) __UI_Controls(NewID).BackColor = _RGB32(255, 255, 255) __UI_Controls(NewID).SelectedForeColor = _RGB32(255, 255, 255) @@ -190,107 +289,7 @@ __UI_AddListBoxItem "ListBox1", "And" __UI_AddListBoxItem "ListBox1", "END" __UI_Controls(NewID).Value = 1 -NewID = __UI_NewObject(__UI_Type_Label, "Label1", 0) -__UI_Controls(NewID).Top = 30 -__UI_Controls(NewID).Left = 10 -__UI_Controls(NewID).Width = 400 -__UI_Controls(NewID).Height = 20 -__UI_Controls(NewID).Font = 2 -__UI_Controls(NewID).ForeColor = _RGB32(238, 238, 200) -__UI_Controls(NewID).BackColor = _RGB32(33, 100, 78) -__UI_Controls(NewID).Align = __UI_Center -__UI_Controls(NewID).Enabled = __UI_True -__UI_SetCaption "Label1", "Waiting for you to click" - -NewID = __UI_NewObject(__UI_Type_Label, "FocusLabel", 0) -__UI_Controls(NewID).Top = 55 -__UI_Controls(NewID).Left = 10 -__UI_Controls(NewID).Width = 400 -__UI_Controls(NewID).Height = 20 -__UI_Controls(NewID).ForeColor = _RGB32(0, 0, 0) -__UI_Controls(NewID).Enabled = __UI_True -__UI_SetCaption "FocusLabel", "No object has focus now" -__UI_Controls(NewID).Font = 1 - -NewID = __UI_NewObject(__UI_Type_Label, "HoverLabel", 0) -__UI_Controls(NewID).Top = 75 -__UI_Controls(NewID).Left = 10 -__UI_Controls(NewID).Width = 400 -__UI_Controls(NewID).Height = 20 -__UI_Controls(NewID).ForeColor = _RGB32(0, 0, 0) -__UI_Controls(NewID).Enabled = __UI_True -__UI_Controls(NewID).Font = 1 - -NewID = __UI_NewObject(__UI_Type_Label, "Label2", 0) -__UI_Controls(NewID).Top = 350 -__UI_Controls(NewID).Left = 30 -__UI_Controls(NewID).Width = 300 -__UI_Controls(NewID).Height = 20 -__UI_Controls(NewID).ForeColor = _RGB32(0, 0, 0) -__UI_Controls(NewID).BackStyle = __UI_Transparent -__UI_Controls(NewID).HasBorder = __UI_False -__UI_Controls(NewID).BorderColor = _RGB32(0, 0, 0) -__UI_Controls(NewID).Enabled = __UI_True - -NewID = __UI_NewObject(__UI_Type_Frame, "Frame1", 0) -__UI_Controls(NewID).Top = 30 -__UI_Controls(NewID).Left = 430 -__UI_Controls(NewID).Width = 200 -__UI_Controls(NewID).Height = 110 -__UI_Controls(NewID).ForeColor = _RGB32(0, 0, 0) -__UI_Controls(NewID).BackColor = __UI_Controls(__UI_GetID("Form1")).BackColor -__UI_Controls(NewID).HasBorder = __UI_True -__UI_Controls(NewID).BorderColor = _RGB32(0, 0, 0) -__UI_Controls(NewID).Enabled = __UI_True -__UI_SetCaption "Frame1", "A cute container" - -NewID = __UI_NewObject(__UI_Type_RadioButton, "Option1", __UI_GetID("Frame1")) -__UI_Controls(NewID).Top = 15 -__UI_Controls(NewID).Left = 15 -__UI_Controls(NewID).Width = 110 -__UI_Controls(NewID).Height = 10 -__UI_Controls(NewID).ForeColor = _RGB32(0, 0, 0) -__UI_Controls(NewID).Enabled = __UI_True -__UI_Controls(NewID).Value = __UI_True -__UI_Controls(NewID).CanHaveFocus = __UI_True -__UI_SetCaption "Option1", "Option 1" -__UI_Controls(NewID).Font = 2 - -NewID = __UI_NewObject(__UI_Type_RadioButton, "Option2", __UI_GetID("Frame1")) -__UI_Controls(NewID).Top = 40 -__UI_Controls(NewID).Left = 15 -__UI_Controls(NewID).Width = 110 -__UI_Controls(NewID).Height = 10 -__UI_Controls(NewID).ForeColor = _RGB32(0, 0, 0) -__UI_Controls(NewID).Enabled = __UI_True -__UI_Controls(NewID).CanHaveFocus = __UI_True -__UI_SetCaption "Option2", "Option 2" -__UI_Controls(NewID).Font = 2 - -NewID = __UI_NewObject(__UI_Type_CheckBox, "Check1", __UI_GetID("Frame1")) -__UI_Controls(NewID).Top = 65 -__UI_Controls(NewID).Left = 15 -__UI_Controls(NewID).Width = 110 -__UI_Controls(NewID).Height = 10 -__UI_Controls(NewID).ForeColor = _RGB32(0, 0, 0) -__UI_Controls(NewID).Enabled = __UI_True -__UI_Controls(NewID).CanHaveFocus = __UI_True -__UI_SetCaption "Check1", "Checkbox 1" -__UI_Controls(NewID).Font = 2 - -NewID = __UI_NewObject(__UI_Type_CheckBox, "Check2", __UI_GetID("Frame1")) -__UI_Controls(NewID).Top = 90 -__UI_Controls(NewID).Left = 15 -__UI_Controls(NewID).Width = 110 -__UI_Controls(NewID).Height = 10 -__UI_Controls(NewID).ForeColor = _RGB32(0, 0, 0) -__UI_Controls(NewID).Enabled = __UI_True -__UI_Controls(NewID).Value = __UI_True -__UI_Controls(NewID).CanHaveFocus = __UI_True -__UI_SetCaption "Check2", "Checkbox 2" -__UI_Controls(NewID).Font = 2 - -NewID = __UI_NewObject(__UI_Type_ProgressBar, "ProgressBar1", 0) +NewID = __UI_NewObject(__UI_Type_ProgressBar, "ProgressBar1", 0, 0, 0) __UI_Controls(NewID).Top = 375 __UI_Controls(NewID).Left = 30 __UI_Controls(NewID).Width = 300 @@ -305,9 +304,20 @@ __UI_Controls(NewID).Max = 500 __UI_Controls(NewID).ShowPercentage = __UI_True __UI_Controls(NewID).Height = 20 __UI_Controls(NewID).Enabled = __UI_True -'__UI_SetCaption "ProgressBar1", "Performing task" +__UI_SetCaption "ProgressBar1", "Performing task... \#" -NewID = __UI_NewObject(__UI_Type_Button, "OkButton", 0) +NewID = __UI_NewObject(__UI_Type_Button, "StopBar", 0, 0, 0) +__UI_Controls(NewID).Top = 370 +__UI_Controls(NewID).Left = 340 +__UI_Controls(NewID).Width = 130 +__UI_Controls(NewID).Height = 20 +__UI_Controls(NewID).ForeColor = _RGB32(255, 255, 255) +__UI_Controls(NewID).BackColor = _RGB32(51, 152, 219) +__UI_Controls(NewID).CanHaveFocus = __UI_True +__UI_Controls(NewID).Enabled = __UI_True +__UI_SetCaption "StopBar", "Stop task" + +NewID = __UI_NewObject(__UI_Type_Button, "OkButton", 0, 0, 0) __UI_Controls(NewID).Top = 370 __UI_Controls(NewID).Left = 550 __UI_Controls(NewID).Width = 70 @@ -338,11 +348,11 @@ SUB __UI_Load DO UNTIL _SCREENEXISTS: _LIMIT 10: LOOP FOR i = 1 TO UBOUND(__UI_Controls) - IF __UI_Controls(i).ParentID THEN - IF __UI_Controls(i).Width + __UI_Controls(i).Left > __UI_Controls(__UI_Controls(i).ParentID).Width THEN - __UI_Controls(i).Width = __UI_Controls(__UI_Controls(i).ParentID).Width - __UI_Controls(i).Left - END IF - END IF + 'IF __UI_Controls(i).ParentID THEN + ' IF __UI_Controls(i).Width + __UI_Controls(i).Left > __UI_Controls(__UI_Controls(i).ParentID).Width THEN + ' __UI_Controls(i).Width = __UI_Controls(__UI_Controls(i).ParentID).Width - __UI_Controls(i).Left + ' END IF + 'END IF IF __UI_Controls(i).Type = __UI_Type_TextBox THEN IF _FONTWIDTH(__UI_Fonts(__UI_Controls(i).Font)) = 0 THEN __UI_Controls(i).Font = 0 @@ -387,18 +397,30 @@ SUB __UI_Click (id AS LONG) END IF END SELECT CASE "BUTTON2" - __UI_Controls(__UI_GetID("Form1")).Resizable = NOT __UI_Controls(__UI_GetID("Form1")).Resizable - IF __UI_Controls(__UI_GetID("Form1")).Resizable THEN - __UI_Captions(__UI_GetID("Button2")) = "Form is resizable" + IF __UI_Controls(__UI_GetID("listbox1")).ParentID THEN + __UI_Controls(__UI_GetID("listbox1")).ParentID = 0 + __UI_Captions(__UI_GetID("Button2")) = "Move ListBox into frame" ELSE - __UI_Captions(__UI_GetID("Button2")) = "Form is not resizable" + __UI_Controls(__UI_GetID("listbox1")).ParentID = __UI_GetID("Frame1") + IF __UI_Controls(__UI_GetID("listbox1")).Left > __UI_Controls(__UI_GetID("Frame1")).Width THEN _ + __UI_Controls(__UI_GetID("listbox1")).Left = 0 + IF __UI_Controls(__UI_GetID("listbox1")).Top > __UI_Controls(__UI_GetID("Frame1")).Height THEN _ + __UI_Controls(__UI_GetID("listbox1")).Top = 0 + __UI_Captions(__UI_GetID("Button2")) = "Move ListBox out of frame" + END IF + CASE "STOPBAR" + __UI_Controls(__UI_GetID("ProgressBar1")).Enabled = NOT __UI_Controls(__UI_GetID("ProgressBar1")).Enabled + IF __UI_Controls(__UI_GetID("ProgressBar1")).Enabled THEN + __UI_SetCaption "StopBar", "Stop task" + ELSE + __UI_SetCaption "StopBar", "Continue task" END IF CASE "DRAGBUTTON" - __UI_Controls(__UI_GetID("frame1")).CanDrag = NOT __UI_Controls(__UI_GetID("frame1")).CanDrag - IF __UI_Controls(__UI_GetID("frame1")).CanDrag THEN - __UI_Captions(__UI_GetID("DragButton")) = "Frame is draggable" + __UI_Controls(__UI_GetID("listbox1")).CanDrag = NOT __UI_Controls(__UI_GetID("listbox1")).CanDrag + IF __UI_Controls(__UI_GetID("listbox1")).CanDrag THEN + __UI_Captions(__UI_GetID("DragButton")) = "List is draggable" ELSE - __UI_Captions(__UI_GetID("DragButton")) = "Frame is not draggable" + __UI_Captions(__UI_GetID("DragButton")) = "List is not draggable" END IF CASE "LABEL1" __UI_Captions(__UI_GetID("Label1")) = "I'm not a button..." @@ -476,12 +498,16 @@ SUB __UI_MouseUp (id AS LONG) END SUB SUB __UI_BeforeUpdateDisplay - STATIC Iterations AS LONG + STATIC Iterations AS LONG, Pass AS LONG Iterations = Iterations + 1 - __UI_Controls(__UI_GetID("ProgressBar1")).Value = __UI_Controls(__UI_GetID("ProgressBar1")).Value + 1 - IF __UI_Controls(__UI_GetID("ProgressBar1")).Value > __UI_Controls(__UI_GetID("ProgressBar1")).Max THEN - __UI_Controls(__UI_GetID("ProgressBar1")).Value = 0 + IF __UI_Controls(__UI_GetID("ProgressBar1")).Enabled THEN + __UI_Controls(__UI_GetID("ProgressBar1")).Value = __UI_Controls(__UI_GetID("ProgressBar1")).Value + 1 + IF __UI_Controls(__UI_GetID("ProgressBar1")).Value > __UI_Controls(__UI_GetID("ProgressBar1")).Max THEN + Pass = Pass + 1 + __UI_SetCaption "ProgressBar1", "Aligning planets (" + LTRIM$(STR$(Pass)) + ")... \#" + __UI_Controls(__UI_GetID("ProgressBar1")).Value = 0 + END IF END IF IF __UI_Focus THEN @@ -490,7 +516,7 @@ SUB __UI_BeforeUpdateDisplay __UI_SetCaption "FocusLabel", "Selected text: " + __UI_SelectedText END IF IF __UI_Focus = __UI_GetID("ListBox1") THEN - __UI_SetCaption "FocusLabel", "Selected item: " + STR$(__UI_Controls(__UI_Focus).Value) + " InpStart: " + STR$(__UI_Controls(__UI_Focus).InputViewStart) + "Selected text: " + __UI_SelectedText + __UI_SetCaption "FocusLabel", "Selected: " + STR$(__UI_Controls(__UI_Focus).Value) + " ListStart: " + STR$(__UI_Controls(__UI_Focus).InputViewStart) + " Text: " + __UI_SelectedText END IF END IF @@ -562,18 +588,22 @@ SUB __UI_ProcessInput IF __UI_ExitTriggered AND 1 THEN __UI_ExitTriggered = __UI_True: __UI_HasInput = __UI_True 'Mouse input: + __UI_MouseWheel = 0 WHILE _MOUSEINPUT + __UI_MouseWheel = __UI_MouseWheel + _MOUSEWHEEL WEND - __UI_MouseX = _MOUSEX - __UI_MouseY = _MOUSEY + IF __UI_MouseWheel THEN __UI_HasInput = __UI_True + + __UI_MouseLeft = _MOUSEX + __UI_MouseTop = _MOUSEY __UI_MouseButton1 = _MOUSEBUTTON(1) __UI_MouseButton2 = _MOUSEBUTTON(2) - IF __UI_PrevMouseX <> __UI_MouseX THEN _ - __UI_HasInput = __UI_True: __UI_PrevMouseX = __UI_MouseX - IF __UI_PrevMouseY <> __UI_MouseY THEN _ - __UI_HasInput = __UI_True: __UI_PrevMouseY = __UI_MouseY + IF __UI_PrevMouseX <> __UI_MouseLeft THEN _ + __UI_HasInput = __UI_True: __UI_PrevMouseX = __UI_MouseLeft + IF __UI_PrevMouseY <> __UI_MouseTop THEN _ + __UI_HasInput = __UI_True: __UI_PrevMouseY = __UI_MouseTop IF __UI_PrevMouseButton1 <> __UI_MouseButton1 THEN _ __UI_HasInput = __UI_True: __UI_PrevMouseButton1 = __UI_MouseButton1 IF __UI_PrevMouseButton2 <> __UI_MouseButton2 THEN _ @@ -627,16 +657,37 @@ SUB __UI_UpdateDisplay COLOR __UI_Controls(__UI_GetID("Form1")).ForeColor, __UI_Controls(__UI_GetID("Form1")).BackColor CLS + 'Clear frames canvases first: + FOR i = 1 TO UBOUND(__UI_Controls) + IF __UI_Controls(i).Type = __UI_Type_Frame THEN + _DEST __UI_Controls(i).Canvas + COLOR , __UI_Controls(i).BackColor + CLS + END IF + NEXT + + _DEST 0 + IF __UI_IsDragging AND NOT (_KEYDOWN(100305) OR _KEYDOWN(100306)) THEN 'Draw the alignment grid DIM GridX AS INTEGER, GridY AS INTEGER - FOR GridX = 0 TO __UI_Controls(__UI_GetID("Form1")).Width STEP 10 - FOR GridY = 0 TO __UI_Controls(__UI_GetID("Form1")).Height STEP 10 - PSET (GridX, GridY), __UI_Controls(__UI_GetID("Form1")).ForeColor + IF __UI_Controls(__UI_DraggingID).ParentID THEN + _DEST __UI_Controls(__UI_Controls(__UI_DraggingID).ParentID).Canvas + FOR GridX = 0 TO __UI_Controls(__UI_Controls(__UI_DraggingID).ParentID).Width STEP 10 + FOR GridY = 0 TO __UI_Controls(__UI_Controls(__UI_DraggingID).ParentID).Height STEP 10 + PSET (GridX, GridY), __UI_Controls(__UI_Controls(__UI_DraggingID).ParentID).ForeColor + NEXT NEXT - NEXT - + LINE (__UI_PreviewLeft - __UI_Controls(__UI_Controls(__UI_DraggingID).ParentID).Left, __UI_PreviewTop - __UI_Controls(__UI_Controls(__UI_DraggingID).ParentID).Top)-STEP(__UI_Controls(__UI_DraggingID).Width - 1, __UI_Controls(__UI_DraggingID).Height - 1), __UI_Darken(__UI_Controls(__UI_GetID("Form1")).BackColor, 80), B + ELSE + FOR GridX = 0 TO __UI_Controls(__UI_GetID("Form1")).Width STEP 10 + FOR GridY = 0 TO __UI_Controls(__UI_GetID("Form1")).Height STEP 10 + PSET (GridX, GridY), __UI_Controls(__UI_GetID("Form1")).ForeColor + NEXT + NEXT + END IF + _DEST 0 LINE (__UI_PreviewLeft, __UI_PreviewTop)-STEP(__UI_Controls(__UI_DraggingID).Width - 1, __UI_Controls(__UI_DraggingID).Height - 1), __UI_Darken(__UI_Controls(__UI_GetID("Form1")).BackColor, 80), B END IF @@ -646,343 +697,390 @@ SUB __UI_UpdateDisplay IF __UI_Controls(i).ParentID THEN ContainerOffsetTop = __UI_Controls(__UI_Controls(i).ParentID).Top ContainerOffsetLeft = __UI_Controls(__UI_Controls(i).ParentID).Left + 'First make sure the mouse is inside the container: + IF __UI_MouseLeft >= ContainerOffsetLeft AND _ + __UI_MouseLeft <= ContainerOffsetLeft + __UI_Controls(__UI_Controls(i).ParentID).Width - 1 AND _ + __UI_MouseTop >= ContainerOffsetTop AND _ + __UI_MouseTop <= ContainerOffsetTop + __UI_Controls(__UI_Controls(i).ParentID).Height - 1 THEN + 'We're in. Now check for individual control: + IF __UI_MouseLeft >= ContainerOffsetLeft + __UI_Controls(i).Left AND _ + __UI_MouseLeft <= ContainerOffsetLeft + __UI_Controls(i).Left + __UI_Controls(i).Width - 1 AND _ + __UI_MouseTop >= ContainerOffsetTop + __UI_Controls(i).Top AND _ + __UI_MouseTop <= ContainerOffsetTop + __UI_Controls(i).Top + __UI_Controls(i).Height - 1 THEN + __UI_HoveringID = i + END IF + END IF ELSE - ContainerOffsetTop = 0 - ContainerOffsetLeft = 0 - END IF - - IF __UI_MouseX >= ContainerOffsetLeft + __UI_Controls(i).Left AND _ - __UI_MouseX <= ContainerOffsetLeft + __UI_Controls(i).Left + __UI_Controls(i).Width - 1 AND _ - __UI_MouseY >= ContainerOffsetTop + __UI_Controls(i).Top AND _ - __UI_MouseY <= ContainerOffsetTop + __UI_Controls(i).Top + __UI_Controls(i).Height - 1 THEN - __UI_HoveringID = i + IF __UI_MouseLeft >= __UI_Controls(i).Left AND _ + __UI_MouseLeft <= __UI_Controls(i).Left + __UI_Controls(i).Width - 1 AND _ + __UI_MouseTop >= __UI_Controls(i).Top AND _ + __UI_MouseTop <= __UI_Controls(i).Top + __UI_Controls(i).Height - 1 THEN + __UI_HoveringID = i + END IF END IF END IF NEXT + 'Control drawing + ContainerOffsetTop = 0 + ContainerOffsetLeft = 0 FOR i = 1 TO UBOUND(__UI_Controls) IF __UI_Controls(i).ID THEN - _FONT __UI_Fonts(__UI_Controls(i).Font) - TempCaption$ = __UI_Captions(i) DO WHILE _PRINTWIDTH(TempCaption$) > __UI_Controls(i).Width TempCaption$ = MID$(TempCaption$, 1, LEN(TempCaption$) - 1) LOOP IF __UI_Controls(i).ParentID THEN - ContainerOffsetTop = __UI_Controls(__UI_Controls(i).ParentID).Top - ContainerOffsetLeft = __UI_Controls(__UI_Controls(i).ParentID).Left + _DEST __UI_Controls(__UI_Controls(i).ParentID).Canvas ELSE - ContainerOffsetTop = 0 - ContainerOffsetLeft = 0 + _DEST 0 END IF - SELECT CASE __UI_Controls(i).Type - CASE __UI_Type_Button + _FONT __UI_Fonts(__UI_Controls(i).Font) + + IF __UI_Controls(i).Hidden = __UI_False THEN + SELECT CASE __UI_Controls(i).Type + CASE __UI_Type_Button IF ((__UI_MouseIsDown AND i = __UI_MouseDownOnID) OR _ (__UI_KeyIsDown AND i = __UI_KeyDownOnID AND __UI_KeyDownOnID = __UI_Focus)) AND _ __UI_Controls(i).Enabled THEN - TempColor~& = __UI_Darken(__UI_Controls(i).BackColor, 70) - ELSEIF i = __UI_HoveringID AND __UI_Controls(i).Enabled THEN - TempColor~& = __UI_Darken(__UI_Controls(i).BackColor, 90) - ELSEIF __UI_Controls(i).Enabled = __UI_False THEN - TempColor~& = _RGB32(208, 213, 216) - ELSE - TempColor~& = __UI_Controls(i).BackColor - END IF + TempColor~& = __UI_Darken(__UI_Controls(i).BackColor, 70) + ELSEIF i = __UI_HoveringID AND __UI_Controls(i).Enabled THEN + TempColor~& = __UI_Darken(__UI_Controls(i).BackColor, 90) + ELSEIF __UI_Controls(i).Enabled = __UI_False THEN + TempColor~& = _RGB32(208, 213, 216) + ELSE + TempColor~& = __UI_Controls(i).BackColor + END IF IF ((__UI_HoveringID = i OR __UI_Focus = i) AND _ __UI_Controls(i).Enabled AND __UI_MouseDownOnID <> i AND _ __UI_KeyDownOnID <> i) OR _ (__UI_DefaultButtonID = i AND __UI_Controls(__UI_Focus).Type <> __UI_Type_Button) THEN - __UI_DrawRectangle __UI_Controls(i).Left + 2, __UI_Controls(i).Top + 2, __UI_Controls(i).Width, __UI_Controls(i).Height, __UI_Controls(i).BorderColor, __UI_Darken(__UI_Controls(__UI_GetID("Form1")).BackColor, 50), __UI_True - END IF + __UI_DrawRectangle __UI_Controls(i).Left + 2, __UI_Controls(i).Top + 2, __UI_Controls(i).Width, __UI_Controls(i).Height, __UI_Controls(i).BorderColor, __UI_Darken(__UI_Controls(__UI_GetID("Form1")).BackColor, 50), __UI_True + END IF - __UI_DrawRectangle ContainerOffsetLeft + __UI_Controls(i).Left, ContainerOffsetTop + __UI_Controls(i).Top, __UI_Controls(i).Width, __UI_Controls(i).Height, __UI_Controls(i).BorderColor, TempColor~&, __UI_True + __UI_DrawRectangle ContainerOffsetLeft + __UI_Controls(i).Left, ContainerOffsetTop + __UI_Controls(i).Top, __UI_Controls(i).Width, __UI_Controls(i).Height, __UI_Controls(i).BorderColor, TempColor~&, __UI_True - IF __UI_Controls(i).Enabled THEN - COLOR __UI_Controls(i).ForeColor, TempColor~& - ELSE - COLOR __UI_Darken(__UI_Controls(__UI_GetID("Form1")).BackColor, 80), TempColor~& - END IF + IF __UI_Controls(i).Enabled THEN + COLOR __UI_Controls(i).ForeColor, TempColor~& + ELSE + COLOR __UI_Darken(__UI_Controls(__UI_GetID("Form1")).BackColor, 80), TempColor~& + END IF - _PRINTMODE _FILLBACKGROUND - _PRINTSTRING (ContainerOffsetLeft + __UI_Controls(i).Left + (__UI_Controls(i).Width \ 2 - _PRINTWIDTH(TempCaption$) \ 2), ContainerOffsetTop + __UI_Controls(i).Top + ((__UI_Controls(i).Height \ 2) - _FONTHEIGHT \ 2)), TempCaption$ - CASE __UI_Type_Label - IF __UI_Controls(i).BackStyle = __UI_Opaque THEN _PRINTMODE _FILLBACKGROUND - ELSE - _PRINTMODE _KEEPBACKGROUND - END IF + _PRINTSTRING (ContainerOffsetLeft + __UI_Controls(i).Left + (__UI_Controls(i).Width \ 2 - _PRINTWIDTH(TempCaption$) \ 2), ContainerOffsetTop + __UI_Controls(i).Top + ((__UI_Controls(i).Height \ 2) - _FONTHEIGHT \ 2)), TempCaption$ + CASE __UI_Type_Label + IF __UI_Controls(i).BackStyle = __UI_Opaque THEN + _PRINTMODE _FILLBACKGROUND + ELSE + _PRINTMODE _KEEPBACKGROUND + END IF - CaptionIndent = 0 - IF __UI_Controls(i).BackStyle = __UI_Opaque THEN - __UI_DrawRectangle ContainerOffsetLeft + __UI_Controls(i).Left, ContainerOffsetTop + __UI_Controls(i).Top, __UI_Controls(i).Width, __UI_Controls(i).Height, __UI_Controls(i).BackColor, __UI_Controls(i).BackColor, __UI_True - END IF + CaptionIndent = 0 + IF __UI_Controls(i).BackStyle = __UI_Opaque THEN + __UI_DrawRectangle ContainerOffsetLeft + __UI_Controls(i).Left, ContainerOffsetTop + __UI_Controls(i).Top, __UI_Controls(i).Width, __UI_Controls(i).Height, __UI_Controls(i).BackColor, __UI_Controls(i).BackColor, __UI_True + END IF - IF __UI_Controls(i).HasBorder = __UI_True THEN - CaptionIndent = 5 - __UI_DrawRectangle ContainerOffsetLeft + __UI_Controls(i).Left, ContainerOffsetTop + __UI_Controls(i).Top, __UI_Controls(i).Width, __UI_Controls(i).Height, __UI_Controls(i).BorderColor, TempColor~&, __UI_False - END IF + IF __UI_Controls(i).HasBorder = __UI_True THEN + CaptionIndent = 5 + __UI_DrawRectangle ContainerOffsetLeft + __UI_Controls(i).Left, ContainerOffsetTop + __UI_Controls(i).Top, __UI_Controls(i).Width, __UI_Controls(i).Height, __UI_Controls(i).BorderColor, TempColor~&, __UI_False + END IF - IF __UI_Controls(i).Enabled THEN - COLOR __UI_Controls(i).ForeColor, __UI_Controls(i).BackColor - ELSE - COLOR __UI_Darken(__UI_Controls(__UI_GetID("Form1")).BackColor, 80), __UI_Controls(i).BackColor - END IF + IF __UI_Controls(i).Enabled THEN + COLOR __UI_Controls(i).ForeColor, __UI_Controls(i).BackColor + ELSE + COLOR __UI_Darken(__UI_Controls(__UI_GetID("Form1")).BackColor, 80), __UI_Controls(i).BackColor + END IF - SELECT CASE __UI_Controls(i).Align - CASE __UI_Left - _PRINTSTRING (ContainerOffsetLeft + __UI_Controls(i).Left + CaptionIndent, ContainerOffsetTop + __UI_Controls(i).Top + ((__UI_Controls(i).Height \ 2) - _FONTHEIGHT \ 2)), TempCaption$ - CASE __UI_Center - _PRINTSTRING (ContainerOffsetLeft + __UI_Controls(i).Left + (__UI_Controls(i).Width \ 2 - _PRINTWIDTH(TempCaption$) \ 2), ContainerOffsetTop + __UI_Controls(i).Top + ((__UI_Controls(i).Height \ 2) - _FONTHEIGHT \ 2)), TempCaption$ - CASE __UI_Right - _PRINTSTRING (ContainerOffsetLeft + __UI_Controls(i).Left + (__UI_Controls(i).Width - _PRINTWIDTH(TempCaption$)) - CaptionIndent, ContainerOffsetTop + __UI_Controls(i).Top + ((__UI_Controls(i).Height \ 2) - _FONTHEIGHT \ 2)), TempCaption$ - END SELECT - CASE __UI_Type_Frame - IF __UI_Controls(i).BackStyle = __UI_Opaque THEN - _PRINTMODE _FILLBACKGROUND - ELSE - _PRINTMODE _KEEPBACKGROUND - END IF + SELECT CASE __UI_Controls(i).Align + CASE __UI_Left + _PRINTSTRING (ContainerOffsetLeft + __UI_Controls(i).Left + CaptionIndent, ContainerOffsetTop + __UI_Controls(i).Top + ((__UI_Controls(i).Height \ 2) - _FONTHEIGHT \ 2)), TempCaption$ + CASE __UI_Center + _PRINTSTRING (ContainerOffsetLeft + __UI_Controls(i).Left + (__UI_Controls(i).Width \ 2 - _PRINTWIDTH(TempCaption$) \ 2), ContainerOffsetTop + __UI_Controls(i).Top + ((__UI_Controls(i).Height \ 2) - _FONTHEIGHT \ 2)), TempCaption$ + CASE __UI_Right + _PRINTSTRING (ContainerOffsetLeft + __UI_Controls(i).Left + (__UI_Controls(i).Width - _PRINTWIDTH(TempCaption$)) - CaptionIndent, ContainerOffsetTop + __UI_Controls(i).Top + ((__UI_Controls(i).Height \ 2) - _FONTHEIGHT \ 2)), TempCaption$ + END SELECT + CASE __UI_Type_RadioButton + IF __UI_Controls(i).BackStyle = __UI_Opaque THEN + _PRINTMODE _FILLBACKGROUND + ELSE + _PRINTMODE _KEEPBACKGROUND + END IF - IF __UI_Controls(i).BackStyle = __UI_Opaque THEN - __UI_DrawRectangle __UI_Controls(i).Left, __UI_Controls(i).Top, __UI_Controls(i).Width, __UI_Controls(i).Height, __UI_Controls(i).BackColor, __UI_Controls(i).BackColor, __UI_True - END IF - - CaptionIndent = 0 - IF __UI_Controls(i).HasBorder = __UI_True THEN - CaptionIndent = 5 - __UI_DrawRectangle __UI_Controls(i).Left, __UI_Controls(i).Top, __UI_Controls(i).Width, __UI_Controls(i).Height, __UI_Controls(i).BorderColor, TempColor~&, __UI_False - END IF - - IF __UI_Controls(i).Enabled THEN - COLOR __UI_Controls(i).ForeColor, __UI_Controls(i).BackColor - ELSE - COLOR __UI_Darken(__UI_Controls(__UI_GetID("Form1")).BackColor, 80), __UI_Controls(i).BackColor - END IF - - SELECT CASE __UI_Controls(i).Align - CASE __UI_Left - _PRINTSTRING (__UI_Controls(i).Left + CaptionIndent, __UI_Controls(i).Top - _FONTHEIGHT \ 2), TempCaption$ - CASE __UI_Center - _PRINTSTRING (__UI_Controls(i).Left + (__UI_Controls(i).Width \ 2 - _PRINTWIDTH(TempCaption$) \ 2), __UI_Controls(i).Top - _FONTHEIGHT \ 2), TempCaption$ - CASE __UI_Right - _PRINTSTRING (__UI_Controls(i).Left + (__UI_Controls(i).Width - _PRINTWIDTH(TempCaption$)) - CaptionIndent, __UI_Controls(i).Top - _FONTHEIGHT \ 2), TempCaption$ - END SELECT - CASE __UI_Type_RadioButton - IF __UI_Controls(i).BackStyle = __UI_Opaque THEN - _PRINTMODE _FILLBACKGROUND - ELSE - _PRINTMODE _KEEPBACKGROUND - END IF - - DIM CircleDiameter AS INTEGER + DIM CircleDiameter AS INTEGER __UI_DrawRadioButton __UI_Controls(i).Value, _ ContainerOffsetLeft + __UI_Controls(i).Left, _ ContainerOffsetTop + __UI_Controls(i).Top + __UI_Controls(i).Height \ 2, _ CircleDiameter - CaptionIndent = 0 - IF __UI_Controls(i).BackStyle = __UI_Opaque THEN - __UI_DrawRectangle ContainerOffsetLeft + __UI_Controls(i).Left, ContainerOffsetTop + __UI_Controls(i).Top, __UI_Controls(i).Width, __UI_Controls(i).Height, __UI_Controls(i).BackColor, __UI_Controls(i).BackColor, __UI_True - END IF + CaptionIndent = 0 + IF __UI_Controls(i).BackStyle = __UI_Opaque THEN + __UI_DrawRectangle ContainerOffsetLeft + __UI_Controls(i).Left, ContainerOffsetTop + __UI_Controls(i).Top, __UI_Controls(i).Width, __UI_Controls(i).Height, __UI_Controls(i).BackColor, __UI_Controls(i).BackColor, __UI_True + END IF - IF __UI_Controls(i).HasBorder = __UI_True THEN - CaptionIndent = 5 - __UI_DrawRectangle ContainerOffsetLeft + __UI_Controls(i).Left, ContainerOffsetTop + __UI_Controls(i).Top, __UI_Controls(i).Width, __UI_Controls(i).Height, __UI_Controls(i).BorderColor, TempColor~&, __UI_False - END IF + IF __UI_Controls(i).HasBorder = __UI_True THEN + CaptionIndent = 5 + __UI_DrawRectangle ContainerOffsetLeft + __UI_Controls(i).Left, ContainerOffsetTop + __UI_Controls(i).Top, __UI_Controls(i).Width, __UI_Controls(i).Height, __UI_Controls(i).BorderColor, TempColor~&, __UI_False + END IF - CaptionIndent = CaptionIndent + CircleDiameter * 1.5 + CaptionIndent = CaptionIndent + CircleDiameter * 1.5 - IF __UI_Controls(i).Enabled THEN - COLOR __UI_Controls(i).ForeColor, __UI_Controls(i).BackColor - ELSE - COLOR __UI_Darken(__UI_Controls(__UI_GetID("Form1")).BackColor, 80), __UI_Controls(i).BackColor - END IF + IF __UI_Controls(i).Enabled THEN + COLOR __UI_Controls(i).ForeColor, __UI_Controls(i).BackColor + ELSE + COLOR __UI_Darken(__UI_Controls(__UI_GetID("Form1")).BackColor, 80), __UI_Controls(i).BackColor + END IF - _PRINTSTRING (ContainerOffsetLeft + __UI_Controls(i).Left + CaptionIndent, ContainerOffsetTop + __UI_Controls(i).Top + ((__UI_Controls(i).Height \ 2) - _FONTHEIGHT \ 2)), TempCaption$ - IF __UI_Focus = i THEN - LINE (ContainerOffsetLeft + __UI_Controls(i).Left + CaptionIndent - 2, ContainerOffsetTop + __UI_Controls(i).Top + ((__UI_Controls(i).Height \ 2) - _FONTHEIGHT \ 2) - 2)-STEP(_PRINTWIDTH(TempCaption$) + 4, _FONTHEIGHT + 4), __UI_Darken(__UI_Controls(i).BackColor, 70), B , 63 - END IF - CASE __UI_Type_CheckBox - IF __UI_Controls(i).BackStyle = __UI_Opaque THEN - _PRINTMODE _FILLBACKGROUND - ELSE - _PRINTMODE _KEEPBACKGROUND - END IF + _PRINTSTRING (ContainerOffsetLeft + __UI_Controls(i).Left + CaptionIndent, ContainerOffsetTop + __UI_Controls(i).Top + ((__UI_Controls(i).Height \ 2) - _FONTHEIGHT \ 2)), TempCaption$ + IF __UI_Focus = i THEN + LINE (ContainerOffsetLeft + __UI_Controls(i).Left + CaptionIndent - 2, ContainerOffsetTop + __UI_Controls(i).Top + ((__UI_Controls(i).Height \ 2) - _FONTHEIGHT \ 2) - 2)-STEP(_PRINTWIDTH(TempCaption$) + 4, _FONTHEIGHT + 4), __UI_Darken(__UI_Controls(i).BackColor, 70), B , 63 + END IF + CASE __UI_Type_CheckBox + IF __UI_Controls(i).BackStyle = __UI_Opaque THEN + _PRINTMODE _FILLBACKGROUND + ELSE + _PRINTMODE _KEEPBACKGROUND + END IF - DIM CheckBoxSize AS INTEGER + DIM CheckBoxSize AS INTEGER __UI_DrawCheckBox __UI_Controls(i).Value, _ ContainerOffsetLeft + __UI_Controls(i).Left, _ ContainerOffsetTop + __UI_Controls(i).Top + __UI_Controls(i).Height \ 2, _ CheckBoxSize - CaptionIndent = 0 - IF __UI_Controls(i).BackStyle = __UI_Opaque THEN - __UI_DrawRectangle ContainerOffsetLeft + __UI_Controls(i).Left, ContainerOffsetTop + __UI_Controls(i).Top, __UI_Controls(i).Width, __UI_Controls(i).Height, __UI_Controls(i).BackColor, __UI_Controls(i).BackColor, __UI_True - END IF + CaptionIndent = 0 + IF __UI_Controls(i).BackStyle = __UI_Opaque THEN + __UI_DrawRectangle ContainerOffsetLeft + __UI_Controls(i).Left, ContainerOffsetTop + __UI_Controls(i).Top, __UI_Controls(i).Width, __UI_Controls(i).Height, __UI_Controls(i).BackColor, __UI_Controls(i).BackColor, __UI_True + END IF - IF __UI_Controls(i).HasBorder = __UI_True THEN - CaptionIndent = 5 - __UI_DrawRectangle ContainerOffsetLeft + __UI_Controls(i).Left, ContainerOffsetTop + __UI_Controls(i).Top, __UI_Controls(i).Width, __UI_Controls(i).Height, __UI_Controls(i).BorderColor, TempColor~&, __UI_False - END IF + IF __UI_Controls(i).HasBorder = __UI_True THEN + CaptionIndent = 5 + __UI_DrawRectangle ContainerOffsetLeft + __UI_Controls(i).Left, ContainerOffsetTop + __UI_Controls(i).Top, __UI_Controls(i).Width, __UI_Controls(i).Height, __UI_Controls(i).BorderColor, TempColor~&, __UI_False + END IF - CaptionIndent = CaptionIndent + CheckBoxSize * 1.5 + CaptionIndent = CaptionIndent + CheckBoxSize * 1.5 - IF __UI_Controls(i).Enabled THEN - COLOR __UI_Controls(i).ForeColor, __UI_Controls(i).BackColor - ELSE - COLOR __UI_Darken(__UI_Controls(__UI_GetID("Form1")).BackColor, 80), __UI_Controls(i).BackColor - END IF + IF __UI_Controls(i).Enabled THEN + COLOR __UI_Controls(i).ForeColor, __UI_Controls(i).BackColor + ELSE + COLOR __UI_Darken(__UI_Controls(__UI_GetID("Form1")).BackColor, 80), __UI_Controls(i).BackColor + END IF - _PRINTSTRING (ContainerOffsetLeft + __UI_Controls(i).Left + CaptionIndent, ContainerOffsetTop + __UI_Controls(i).Top + ((__UI_Controls(i).Height \ 2) - _FONTHEIGHT \ 2)), TempCaption$ - IF __UI_Focus = i THEN - LINE (ContainerOffsetLeft + __UI_Controls(i).Left + CaptionIndent - 2, ContainerOffsetTop + __UI_Controls(i).Top + ((__UI_Controls(i).Height \ 2) - _FONTHEIGHT \ 2) - 2)-STEP(_PRINTWIDTH(TempCaption$) + 4, _FONTHEIGHT + 4), __UI_Darken(__UI_Controls(i).BackColor, 70), B , 63 - END IF - CASE __UI_Type_TextBox - IF __UI_Controls(i).InputViewStart = 0 THEN __UI_Controls(i).InputViewStart = 1 + _PRINTSTRING (ContainerOffsetLeft + __UI_Controls(i).Left + CaptionIndent, ContainerOffsetTop + __UI_Controls(i).Top + ((__UI_Controls(i).Height \ 2) - _FONTHEIGHT \ 2)), TempCaption$ + IF __UI_Focus = i THEN + LINE (ContainerOffsetLeft + __UI_Controls(i).Left + CaptionIndent - 2, ContainerOffsetTop + __UI_Controls(i).Top + ((__UI_Controls(i).Height \ 2) - _FONTHEIGHT \ 2) - 2)-STEP(_PRINTWIDTH(TempCaption$) + 4, _FONTHEIGHT + 4), __UI_Darken(__UI_Controls(i).BackColor, 70), B , 63 + END IF + CASE __UI_Type_TextBox + IF __UI_Controls(i).InputViewStart = 0 THEN __UI_Controls(i).InputViewStart = 1 - IF __UI_Controls(i).BackStyle = __UI_Opaque THEN - _PRINTMODE _FILLBACKGROUND - ELSE - _PRINTMODE _KEEPBACKGROUND - END IF + IF __UI_Controls(i).BackStyle = __UI_Opaque THEN + _PRINTMODE _FILLBACKGROUND + ELSE + _PRINTMODE _KEEPBACKGROUND + END IF IF (__UI_HoveringID = i OR __UI_Focus = i) AND _ __UI_Controls(i).Enabled THEN - __UI_DrawRectangle ContainerOffsetLeft + __UI_Controls(i).Left + 2, ContainerOffsetTop + __UI_Controls(i).Top + 2, __UI_Controls(i).Width, __UI_Controls(i).Height, __UI_Controls(i).BorderColor, __UI_Darken(__UI_Controls(__UI_GetID("Form1")).BackColor, 50), __UI_True - END IF + __UI_DrawRectangle ContainerOffsetLeft + __UI_Controls(i).Left + 2, ContainerOffsetTop + __UI_Controls(i).Top + 2, __UI_Controls(i).Width, __UI_Controls(i).Height, __UI_Controls(i).BorderColor, __UI_Darken(__UI_Controls(__UI_GetID("Form1")).BackColor, 50), __UI_True + END IF - CaptionIndent = 0 - IF __UI_Controls(i).BackStyle = __UI_Opaque THEN - __UI_DrawRectangle ContainerOffsetLeft + __UI_Controls(i).Left, ContainerOffsetTop + __UI_Controls(i).Top, __UI_Controls(i).Width, __UI_Controls(i).Height, __UI_Controls(i).BackColor, __UI_Controls(i).BackColor, __UI_True - END IF + CaptionIndent = 0 + IF __UI_Controls(i).BackStyle = __UI_Opaque THEN + __UI_DrawRectangle ContainerOffsetLeft + __UI_Controls(i).Left, ContainerOffsetTop + __UI_Controls(i).Top, __UI_Controls(i).Width, __UI_Controls(i).Height, __UI_Controls(i).BackColor, __UI_Controls(i).BackColor, __UI_True + END IF - IF __UI_Controls(i).HasBorder = __UI_True THEN - CaptionIndent = 5 - __UI_DrawRectangle ContainerOffsetLeft + __UI_Controls(i).Left, ContainerOffsetTop + __UI_Controls(i).Top, __UI_Controls(i).Width, __UI_Controls(i).Height, __UI_Controls(i).BorderColor, TempColor~&, __UI_False - END IF + IF __UI_Controls(i).HasBorder = __UI_True THEN + CaptionIndent = 5 + __UI_DrawRectangle ContainerOffsetLeft + __UI_Controls(i).Left, ContainerOffsetTop + __UI_Controls(i).Top, __UI_Controls(i).Width, __UI_Controls(i).Height, __UI_Controls(i).BorderColor, TempColor~&, __UI_False + END IF - IF __UI_Controls(i).Enabled AND LEN(__UI_Texts(i)) THEN - COLOR __UI_Controls(i).ForeColor, __UI_Controls(i).BackColor - ELSE - COLOR __UI_Darken(__UI_Controls(__UI_GetID("Form1")).BackColor, 80), __UI_Controls(i).BackColor - END IF + IF __UI_Controls(i).Enabled AND LEN(__UI_Texts(i)) THEN + COLOR __UI_Controls(i).ForeColor, __UI_Controls(i).BackColor + ELSE + COLOR __UI_Darken(__UI_Controls(__UI_GetID("Form1")).BackColor, 80), __UI_Controls(i).BackColor + END IF - IF LEN(__UI_Texts(i)) THEN - _PRINTSTRING (ContainerOffsetLeft + __UI_Controls(i).Left + CaptionIndent, ContainerOffsetTop + __UI_Controls(i).Top + ((__UI_Controls(i).Height \ 2) - _FONTHEIGHT \ 2)), MID$(__UI_Texts(i), __UI_Controls(i).InputViewStart, __UI_Controls(i).FieldArea) - ELSE - _PRINTSTRING (ContainerOffsetLeft + __UI_Controls(i).Left + CaptionIndent, ContainerOffsetTop + __UI_Controls(i).Top + ((__UI_Controls(i).Height \ 2) - _FONTHEIGHT \ 2)), TempCaption$ - END IF + IF LEN(__UI_Texts(i)) THEN + _PRINTSTRING (ContainerOffsetLeft + __UI_Controls(i).Left + CaptionIndent, ContainerOffsetTop + __UI_Controls(i).Top + ((__UI_Controls(i).Height \ 2) - _FONTHEIGHT \ 2)), MID$(__UI_Texts(i), __UI_Controls(i).InputViewStart, __UI_Controls(i).FieldArea) + ELSE + _PRINTSTRING (ContainerOffsetLeft + __UI_Controls(i).Left + CaptionIndent, ContainerOffsetTop + __UI_Controls(i).Top + ((__UI_Controls(i).Height \ 2) - _FONTHEIGHT \ 2)), TempCaption$ + END IF - IF __UI_Controls(i).Selected THEN - DIM s1 AS LONG, s2 AS LONG - DIM ss1 AS LONG, ss2 AS LONG - s1 = __UI_Controls(i).SelectionStart - s2 = __UI_Controls(i).Cursor - IF s1 > s2 THEN - SWAP s1, s2 - IF __UI_Controls(i).InputViewStart > 1 THEN - ss1 = s1 - __UI_Controls(i).InputViewStart + 1 + IF __UI_Controls(i).Selected THEN + DIM s1 AS LONG, s2 AS LONG + DIM ss1 AS LONG, ss2 AS LONG + s1 = __UI_Controls(i).SelectionStart + s2 = __UI_Controls(i).Cursor + IF s1 > s2 THEN + SWAP s1, s2 + IF __UI_Controls(i).InputViewStart > 1 THEN + ss1 = s1 - __UI_Controls(i).InputViewStart + 1 + ELSE + ss1 = s1 + END IF + ss2 = s2 - s1 + IF ss1 + ss2 > __UI_Controls(__UI_Focus).FieldArea THEN ss2 = __UI_Controls(__UI_Focus).FieldArea - ss1 ELSE ss1 = s1 + ss2 = s2 - s1 + IF ss1 < __UI_Controls(i).InputViewStart THEN ss1 = 0: ss2 = s2 - __UI_Controls(i).InputViewStart + 1 + IF ss1 > __UI_Controls(i).InputViewStart THEN ss1 = ss1 - __UI_Controls(i).InputViewStart + 1: ss2 = s2 - s1 END IF - ss2 = s2 - s1 - IF ss1 + ss2 > __UI_Controls(__UI_Focus).FieldArea THEN ss2 = __UI_Controls(__UI_Focus).FieldArea - ss1 - ELSE - ss1 = s1 - ss2 = s2 - s1 - IF ss1 < __UI_Controls(i).InputViewStart THEN ss1 = 0: ss2 = s2 - __UI_Controls(i).InputViewStart + 1 - IF ss1 > __UI_Controls(i).InputViewStart THEN ss1 = ss1 - __UI_Controls(i).InputViewStart + 1: ss2 = s2 - s1 + __UI_SelectedText = MID$(__UI_Texts(i), s1 + 1, s2 - s1) + + LINE (ContainerOffsetLeft + __UI_Controls(i).Left + CaptionIndent + ss1 * _FONTWIDTH, ContainerOffsetTop + __UI_Controls(i).Top + ((__UI_Controls(i).Height \ 2) - _FONTHEIGHT \ 2))-STEP(ss2 * _FONTWIDTH, _FONTHEIGHT), _RGBA32(0, 0, 0, 50), BF END IF - __UI_SelectedText = MID$(__UI_Texts(i), s1 + 1, s2 - s1) - LINE (ContainerOffsetLeft + __UI_Controls(i).Left + CaptionIndent + ss1 * _FONTWIDTH, ContainerOffsetTop + __UI_Controls(i).Top + ((__UI_Controls(i).Height \ 2) - _FONTHEIGHT \ 2))-STEP(ss2 * _FONTWIDTH, _FONTHEIGHT), _RGBA32(0, 0, 0, 50), BF - END IF - - IF __UI_Focus = i THEN - STATIC SetCursor#, cursorBlink%% - IF TIMER - SetCursor# > .4 THEN - SetCursor# = TIMER - cursorBlink%% = NOT cursorBlink%% - END IF - IF cursorBlink%% THEN - LINE (ContainerOffsetLeft + __UI_Controls(i).Left + CaptionIndent + (__UI_Controls(i).Cursor - (__UI_Controls(i).InputViewStart - 1)) * _FONTWIDTH, ContainerOffsetTop + __UI_Controls(i).Top + ((__UI_Controls(i).Height \ 2) - _FONTHEIGHT \ 2))-STEP(0, _FONTHEIGHT), _RGB32(0, 0, 0) - END IF - END IF - CASE __UI_Type_ProgressBar - __UI_DrawProgressBar __UI_Controls(i) - CASE __UI_Type_ListBox - IF __UI_Controls(i).InputViewStart = 0 THEN __UI_Controls(i).InputViewStart = 1 - - _PRINTMODE _KEEPBACKGROUND - - IF __UI_Controls(i).BackStyle = __UI_Opaque THEN - __UI_DrawRectangle ContainerOffsetLeft + __UI_Controls(i).Left, ContainerOffsetTop + __UI_Controls(i).Top, __UI_Controls(i).Width, __UI_Controls(i).Height, __UI_Controls(i).BackColor, __UI_Controls(i).BackColor, __UI_True - END IF - - CaptionIndent = 0 - IF __UI_Controls(i).HasBorder = __UI_True THEN - CaptionIndent = 5 - __UI_DrawRectangle ContainerOffsetLeft + __UI_Controls(i).Left, ContainerOffsetTop + __UI_Controls(i).Top, __UI_Controls(i).Width, __UI_Controls(i).Height, __UI_Controls(i).BorderColor, TempColor~&, __UI_False - END IF - - IF LEN(__UI_Texts(i)) THEN - DIM TempText$, FindLF&, ThisItem%, ThisItemTop% - DIM LastVisibleItem AS INTEGER - - TempText$ = __UI_Texts(i) - ThisItem% = 0 - DO WHILE LEN(TempText$) - ThisItem% = ThisItem% + 1 - FindLF& = INSTR(TempText$, CHR$(13)) - IF FindLF& THEN - TempCaption$ = LEFT$(TempText$, FindLF& - 1) - TempText$ = MID$(TempText$, FindLF& + 1) - ELSE - TempCaption$ = TempText$ - TempText$ = "" + IF __UI_Focus = i THEN + STATIC SetCursor#, cursorBlink%% + IF TIMER - SetCursor# > .4 THEN + SetCursor# = TIMER + cursorBlink%% = NOT cursorBlink%% END IF - IF ThisItem% >= __UI_Controls(i).InputViewStart THEN - ThisItemTop% = __UI_Controls(i).Top + ((ThisItem% - __UI_Controls(i).InputViewStart + 1) * _FONTHEIGHT - _FONTHEIGHT) + CaptionIndent - IF ThisItemTop% + _FONTHEIGHT > __UI_Controls(i).Top + __UI_Controls(i).Height THEN EXIT DO - LastVisibleItem = LastVisibleItem + 1 + IF cursorBlink%% THEN + LINE (ContainerOffsetLeft + __UI_Controls(i).Left + CaptionIndent + (__UI_Controls(i).Cursor - (__UI_Controls(i).InputViewStart - 1)) * _FONTWIDTH, ContainerOffsetTop + __UI_Controls(i).Top + ((__UI_Controls(i).Height \ 2) - _FONTHEIGHT \ 2))-STEP(0, _FONTHEIGHT), _RGB32(0, 0, 0) + END IF + END IF + CASE __UI_Type_ProgressBar + __UI_DrawProgressBar __UI_Controls(i) + CASE __UI_Type_ListBox + IF __UI_Controls(i).InputViewStart <= 0 THEN __UI_Controls(i).InputViewStart = 1 - DO WHILE _PRINTWIDTH(TempCaption$) > __UI_Controls(i).Width - CaptionIndent * 2 - TempCaption$ = MID$(TempCaption$, 1, LEN(TempCaption$) - 1) - LOOP + _PRINTMODE _KEEPBACKGROUND - IF __UI_Controls(i).Enabled THEN - COLOR __UI_Controls(i).ForeColor, __UI_Controls(i).BackColor + IF __UI_Controls(i).BackStyle = __UI_Opaque THEN + IF ((__UI_HoveringID = i OR __UI_Focus = i) AND __UI_Controls(i).Enabled) THEN + __UI_DrawRectangle __UI_Controls(i).Left + 2, __UI_Controls(i).Top + 2, __UI_Controls(i).Width, __UI_Controls(i).Height, __UI_Controls(i).BorderColor, __UI_Darken(__UI_Controls(__UI_GetID("Form1")).BackColor, 50), __UI_True + END IF + + __UI_DrawRectangle ContainerOffsetLeft + __UI_Controls(i).Left, ContainerOffsetTop + __UI_Controls(i).Top, __UI_Controls(i).Width, __UI_Controls(i).Height, __UI_Controls(i).BackColor, __UI_Controls(i).BackColor, __UI_True + END IF + + CaptionIndent = 0 + IF __UI_Controls(i).HasBorder = __UI_True THEN + CaptionIndent = 5 + __UI_DrawRectangle ContainerOffsetLeft + __UI_Controls(i).Left, ContainerOffsetTop + __UI_Controls(i).Top, __UI_Controls(i).Width, __UI_Controls(i).Height, __UI_Controls(i).BorderColor, TempColor~&, __UI_False + END IF + + IF LEN(__UI_Texts(i)) THEN + DIM TempText$, FindLF&, ThisItem%, ThisItemTop% + DIM LastVisibleItem AS INTEGER + + TempText$ = __UI_Texts(i) + ThisItem% = 0 + DO WHILE LEN(TempText$) + ThisItem% = ThisItem% + 1 + FindLF& = INSTR(TempText$, CHR$(13)) + IF FindLF& THEN + TempCaption$ = LEFT$(TempText$, FindLF& - 1) + TempText$ = MID$(TempText$, FindLF& + 1) ELSE - COLOR __UI_Darken(__UI_Controls(__UI_GetID("Form1")).BackColor, 80), __UI_Controls(i).BackColor + TempCaption$ = TempText$ + TempText$ = "" END IF + IF ThisItem% >= __UI_Controls(i).InputViewStart THEN + ThisItemTop% = __UI_Controls(i).Top + ((ThisItem% - __UI_Controls(i).InputViewStart + 1) * _FONTHEIGHT - _FONTHEIGHT) + CaptionIndent + IF ThisItemTop% + _FONTHEIGHT > __UI_Controls(i).Top + __UI_Controls(i).Height THEN EXIT DO + LastVisibleItem = LastVisibleItem + 1 - IF ThisItem% = __UI_Controls(i).Value THEN - IF __UI_Focus = i THEN - COLOR __UI_Controls(i).SelectedForeColor - __UI_SelectedText = TempCaption$ - LINE (ContainerOffsetLeft + __UI_Controls(i).Left + CaptionIndent, ContainerOffsetTop + ThisItemTop%)-STEP(__UI_Controls(i).Width - CaptionIndent * 2, _FONTHEIGHT - 1), __UI_Controls(i).SelectedBackColor, BF + IF ThisItem% = __UI_Controls(i).Value THEN __UI_SelectedText = TempCaption$ + DO WHILE _PRINTWIDTH(TempCaption$) > __UI_Controls(i).Width - CaptionIndent * 2 + TempCaption$ = MID$(TempCaption$, 1, LEN(TempCaption$) - 1) + LOOP + + IF __UI_Controls(i).Enabled THEN + COLOR __UI_Controls(i).ForeColor, __UI_Controls(i).BackColor ELSE - LINE (ContainerOffsetLeft + __UI_Controls(i).Left + CaptionIndent, ContainerOffsetTop + ThisItemTop%)-STEP(__UI_Controls(i).Width - CaptionIndent * 2, _FONTHEIGHT - 1), _RGBA32(0, 0, 0, 50), BF + COLOR __UI_Darken(__UI_Controls(__UI_GetID("Form1")).BackColor, 80), __UI_Controls(i).BackColor END IF - END IF - SELECT CASE __UI_Controls(i).Align - CASE __UI_Left - _PRINTSTRING (ContainerOffsetLeft + __UI_Controls(i).Left + CaptionIndent * 2, ContainerOffsetTop + ThisItemTop%), TempCaption$ - CASE __UI_Center - _PRINTSTRING (ContainerOffsetLeft + __UI_Controls(i).Left + (__UI_Controls(i).Width \ 2 - _PRINTWIDTH(TempCaption$) \ 2), ContainerOffsetTop + ThisItemTop%), TempCaption$ - CASE __UI_Right - _PRINTSTRING (ContainerOffsetLeft + __UI_Controls(i).Left + (__UI_Controls(i).Width - _PRINTWIDTH(TempCaption$)) - CaptionIndent, ContainerOffsetTop + ThisItemTop%), TempCaption$ - END SELECT - END IF - LOOP - IF __UI_Controls(i).LastVisibleItem = 0 THEN __UI_Controls(i).LastVisibleItem = LastVisibleItem + IF ThisItem% = __UI_Controls(i).Value THEN + IF __UI_Focus = i THEN + COLOR __UI_Controls(i).SelectedForeColor + LINE (ContainerOffsetLeft + __UI_Controls(i).Left + CaptionIndent, ContainerOffsetTop + ThisItemTop%)-STEP(__UI_Controls(i).Width - CaptionIndent * 2, _FONTHEIGHT - 1), __UI_Controls(i).SelectedBackColor, BF + ELSE + LINE (ContainerOffsetLeft + __UI_Controls(i).Left + CaptionIndent, ContainerOffsetTop + ThisItemTop%)-STEP(__UI_Controls(i).Width - CaptionIndent * 2, _FONTHEIGHT - 1), _RGBA32(0, 0, 0, 50), BF + END IF + END IF + + SELECT CASE __UI_Controls(i).Align + CASE __UI_Left + _PRINTSTRING (ContainerOffsetLeft + __UI_Controls(i).Left + CaptionIndent * 2, ContainerOffsetTop + ThisItemTop%), TempCaption$ + CASE __UI_Center + _PRINTSTRING (ContainerOffsetLeft + __UI_Controls(i).Left + (__UI_Controls(i).Width \ 2 - _PRINTWIDTH(TempCaption$) \ 2), ContainerOffsetTop + ThisItemTop%), TempCaption$ + CASE __UI_Right + _PRINTSTRING (ContainerOffsetLeft + __UI_Controls(i).Left + (__UI_Controls(i).Width - _PRINTWIDTH(TempCaption$)) - CaptionIndent, ContainerOffsetTop + ThisItemTop%), TempCaption$ + END SELECT + END IF + LOOP + IF __UI_Controls(i).LastVisibleItem = 0 THEN __UI_Controls(i).LastVisibleItem = LastVisibleItem + END IF + END SELECT + END IF + + IF __UI_Controls(i).ParentID THEN + 'Check if no more controls will be drawn in this frame so it can be drawn too + DIM CheckChildControls AS LONG, NoMoreChildren AS _BYTE, ThisParent AS LONG + + ThisParent = __UI_Controls(i).ParentID + NoMoreChildren = __UI_True + FOR CheckChildControls = i + 1 TO UBOUND(__UI_Controls) + IF __UI_Controls(CheckChildControls).ParentID = ThisParent THEN + NoMoreChildren = __UI_False + EXIT FOR END IF - END SELECT - END IF + NEXT + + IF NoMoreChildren THEN + _DEST 0 + TempCaption$ = __UI_Captions(ThisParent) + DO WHILE _PRINTWIDTH(TempCaption$) > __UI_Controls(ThisParent).Width + TempCaption$ = MID$(TempCaption$, 1, LEN(TempCaption$) - 1) + LOOP + + _FONT __UI_Fonts(__UI_Controls(ThisParent).Font) + + IF __UI_Controls(ThisParent).Hidden = __UI_False THEN + IF __UI_Controls(ThisParent).BackStyle = __UI_Opaque THEN + _PRINTMODE _FILLBACKGROUND + ELSE + _PRINTMODE _KEEPBACKGROUND + END IF + + IF __UI_Controls(ThisParent).BackStyle = __UI_Opaque THEN + __UI_DrawRectangle __UI_Controls(ThisParent).Left, __UI_Controls(ThisParent).Top, __UI_Controls(ThisParent).Width, __UI_Controls(ThisParent).Height, __UI_Controls(ThisParent).BackColor, __UI_Controls(ThisParent).BackColor, __UI_True + END IF + + CaptionIndent = 0 + IF __UI_Controls(ThisParent).HasBorder = __UI_True THEN CaptionIndent = 5 + + IF __UI_Controls(ThisParent).Enabled THEN + COLOR __UI_Controls(ThisParent).ForeColor, __UI_Controls(ThisParent).BackColor + ELSE + COLOR __UI_Darken(__UI_Controls(__UI_GetID("Form1")).BackColor, 80), __UI_Controls(ThisParent).BackColor + END IF + + _PUTIMAGE (__UI_Controls(ThisParent).Left + CaptionIndent, __UI_Controls(ThisParent).Top + CaptionIndent), __UI_Controls(ThisParent).Canvas, 0, (CaptionIndent, CaptionIndent)-(__UI_Controls(ThisParent).Width, __UI_Controls(ThisParent).Height) + + IF __UI_Controls(ThisParent).HasBorder = __UI_True THEN + CaptionIndent = 5 + __UI_DrawRectangle __UI_Controls(ThisParent).Left, __UI_Controls(ThisParent).Top, __UI_Controls(ThisParent).Width, __UI_Controls(ThisParent).Height, __UI_Controls(ThisParent).BorderColor, TempColor~&, __UI_False + END IF + + SELECT CASE __UI_Controls(ThisParent).Align + CASE __UI_Left + _PRINTSTRING (__UI_Controls(ThisParent).Left + CaptionIndent, __UI_Controls(ThisParent).Top - _FONTHEIGHT \ 2), TempCaption$ + CASE __UI_Center + _PRINTSTRING (__UI_Controls(ThisParent).Left + (__UI_Controls(ThisParent).Width \ 2 - _PRINTWIDTH(TempCaption$) \ 2), __UI_Controls(ThisParent).Top - _FONTHEIGHT \ 2), TempCaption$ + CASE __UI_Right + _PRINTSTRING (__UI_Controls(ThisParent).Left + (__UI_Controls(ThisParent).Width - _PRINTWIDTH(TempCaption$)) - CaptionIndent, __UI_Controls(ThisParent).Top - _FONTHEIGHT \ 2), TempCaption$ + END SELECT + END IF + END IF + END IF 'Has Parent + END IF 'Valid ID NEXT _DISPLAY @@ -1062,9 +1160,15 @@ END SUB SUB __UI_EventDispatcher STATIC __UI_LastHoveringID AS LONG DIM i AS LONG + DIM ContainerOffsetLeft AS INTEGER, ContainerOffsetTop AS INTEGER IF __UI_HoveringID = 0 THEN EXIT SUB + IF __UI_Controls(__UI_HoveringID).ParentID THEN + ContainerOffsetLeft = __UI_Controls(__UI_Controls(__UI_HoveringID).ParentID).Left + ContainerOffsetTop = __UI_Controls(__UI_Controls(__UI_HoveringID).ParentID).Top + END IF + $IF WIN THEN 'Alt+F4 - Windows IF ((_KEYDOWN(100308) OR _KEYDOWN(100307)) AND __UI_KeyHit = -15872) OR __UI_ExitTriggered THEN @@ -1112,6 +1216,16 @@ SUB __UI_EventDispatcher LOOP END IF + 'MouseWheel + IF __UI_MouseWheel THEN + IF __UI_Controls(__UI_HoveringID).Type = __UI_Type_ListBox THEN + __UI_Controls(__UI_HoveringID).InputViewStart = __UI_Controls(__UI_HoveringID).InputViewStart + __UI_MouseWheel + IF __UI_Controls(__UI_HoveringID).InputViewStart + __UI_Controls(__UI_HoveringID).LastVisibleItem > __UI_Controls(__UI_HoveringID).Max THEN + __UI_Controls(__UI_HoveringID).InputViewStart = __UI_Controls(__UI_HoveringID).Max - __UI_Controls(__UI_HoveringID).LastVisibleItem + 1 + END IF + END IF + END IF + 'MouseDown, MouseUp, BeginDrag IF __UI_MouseButton1 THEN IF __UI_MouseIsDown = __UI_False THEN @@ -1123,8 +1237,8 @@ SUB __UI_EventDispatcher __UI_IsDragging = __UI_True __UI_DraggingID = __UI_HoveringID __UI_BeginDrag __UI_DraggingID - __UI_DragY = __UI_MouseY - __UI_DragX = __UI_MouseX + __UI_DragY = __UI_MouseTop + __UI_DragX = __UI_MouseLeft END IF END IF IF __UI_Controls(__UI_HoveringID).Type = __UI_Type_TextBox THEN @@ -1132,7 +1246,7 @@ SUB __UI_EventDispatcher IF __UI_IsSelectingText = __UI_False THEN __UI_Controls(__UI_HoveringID).Selected = __UI_False __UI_SelectedText = "" - __UI_Controls(__UI_HoveringID).SelectionStart = ((__UI_MouseX - __UI_Controls(__UI_HoveringID).Left) / _FONTWIDTH) + (__UI_Controls(__UI_HoveringID).InputViewStart - 1) + __UI_Controls(__UI_HoveringID).SelectionStart = ((__UI_MouseLeft - __UI_Controls(__UI_HoveringID).Left) / _FONTWIDTH) + (__UI_Controls(__UI_HoveringID).InputViewStart - 1) __UI_Controls(__UI_HoveringID).Cursor = __UI_Controls(__UI_HoveringID).SelectionStart IF __UI_Controls(__UI_HoveringID).SelectionStart > LEN(__UI_Texts(__UI_HoveringID)) THEN __UI_Controls(__UI_HoveringID).SelectionStart = LEN(__UI_Texts(__UI_HoveringID)) IF __UI_Controls(__UI_HoveringID).Cursor > LEN(__UI_Texts(__UI_HoveringID)) THEN __UI_Controls(__UI_HoveringID).Cursor = LEN(__UI_Texts(__UI_HoveringID)) @@ -1147,11 +1261,11 @@ SUB __UI_EventDispatcher ELSE IF __UI_IsSelectingText THEN _FONT __UI_Fonts(__UI_Controls(__UI_IsSelectingTextOnID).Font) - IF __UI_MouseX <= __UI_Controls(__UI_IsSelectingTextOnID).Left AND __UI_Controls(__UI_IsSelectingTextOnID).InputViewStart > 1 THEN + IF __UI_MouseLeft <= __UI_Controls(__UI_IsSelectingTextOnID).Left AND __UI_Controls(__UI_IsSelectingTextOnID).InputViewStart > 1 THEN __UI_Controls(__UI_IsSelectingTextOnID).InputViewStart = __UI_Controls(__UI_IsSelectingTextOnID).InputViewStart - 1 __UI_Controls(__UI_IsSelectingTextOnID).Cursor = __UI_Controls(__UI_IsSelectingTextOnID).InputViewStart ELSE - __UI_Controls(__UI_IsSelectingTextOnID).Cursor = ((__UI_MouseX - __UI_Controls(__UI_IsSelectingTextOnID).Left) / _FONTWIDTH) + (__UI_Controls(__UI_IsSelectingTextOnID).InputViewStart - 1) + __UI_Controls(__UI_IsSelectingTextOnID).Cursor = ((__UI_MouseLeft - __UI_Controls(__UI_IsSelectingTextOnID).Left) / _FONTWIDTH) + (__UI_Controls(__UI_IsSelectingTextOnID).InputViewStart - 1) IF __UI_Controls(__UI_IsSelectingTextOnID).Cursor < 0 THEN __UI_Controls(__UI_IsSelectingTextOnID).Cursor = 0 IF __UI_Controls(__UI_IsSelectingTextOnID).Cursor > LEN(__UI_Texts(__UI_IsSelectingTextOnID)) THEN __UI_Controls(__UI_IsSelectingTextOnID).Cursor = LEN(__UI_Texts(__UI_IsSelectingTextOnID)) IF __UI_Controls(__UI_IsSelectingTextOnID).Cursor <> __UI_Controls(__UI_IsSelectingTextOnID).SelectionStart THEN @@ -1167,6 +1281,10 @@ SUB __UI_EventDispatcher __UI_EndDrag __UI_DraggingID __UI_IsDragging = __UI_False 'Snap the previously dragged object to the grid (unless Ctrl is down): + IF __UI_Controls(__UI_DraggingID).ParentID THEN + __UI_PreviewTop = __UI_PreviewTop - __UI_Controls(__UI_Controls(__UI_DraggingID).ParentID).Top + __UI_PreviewLeft = __UI_PreviewLeft - __UI_Controls(__UI_Controls(__UI_DraggingID).ParentID).Left + END IF __UI_Controls(__UI_DraggingID).Top = __UI_PreviewTop __UI_Controls(__UI_DraggingID).Left = __UI_PreviewLeft __UI_DraggingID = 0 @@ -1182,16 +1300,18 @@ SUB __UI_EventDispatcher __UI_Controls(__UI_HoveringID).Value = NOT __UI_Controls(__UI_HoveringID).Value CASE __UI_Type_TextBox _FONT __UI_Fonts(__UI_Controls(__UI_HoveringID).Font) - __UI_Controls(__UI_HoveringID).Cursor = ((__UI_MouseX - __UI_Controls(__UI_HoveringID).Left) / _FONTWIDTH) + (__UI_Controls(__UI_HoveringID).InputViewStart - 1) + __UI_Controls(__UI_HoveringID).Cursor = ((__UI_MouseLeft - __UI_Controls(__UI_HoveringID).Left) / _FONTWIDTH) + (__UI_Controls(__UI_HoveringID).InputViewStart - 1) IF __UI_Controls(__UI_HoveringID).Cursor > LEN(__UI_Texts(__UI_HoveringID)) THEN __UI_Controls(__UI_HoveringID).Cursor = LEN(__UI_Texts(__UI_HoveringID)) - __UI_IsSelectingText = __UI_False - __UI_IsSelectingTextOnID = 0 + CASE __UI_Type_ListBox + __UI_Controls(__UI_HoveringID).Value = ((__UI_MouseTop - (ContainerOffsetTop + __UI_Controls(__UI_HoveringID).Top)) \ _FONTHEIGHT(__UI_Fonts(__UI_Controls(__UI_HoveringID).Font))) + __UI_Controls(__UI_HoveringID).InputViewStart END SELECT __UI_Click __UI_HoveringID __UI_LastMouseClick = TIMER __UI_MouseDownOnID = 0 END IF END IF + __UI_IsSelectingText = __UI_False + __UI_IsSelectingTextOnID = 0 __UI_MouseIsDown = __UI_False __UI_MouseUp __UI_HoveringID END IF @@ -1199,11 +1319,11 @@ SUB __UI_EventDispatcher 'Drag update IF __UI_IsDragging AND __UI_DraggingID > 0 THEN - __UI_Controls(__UI_DraggingID).Top = __UI_Controls(__UI_DraggingID).Top + (__UI_MouseY - __UI_DragY) - __UI_DragY = __UI_MouseY + __UI_Controls(__UI_DraggingID).Top = __UI_Controls(__UI_DraggingID).Top + (__UI_MouseTop - __UI_DragY) + __UI_DragY = __UI_MouseTop - __UI_Controls(__UI_DraggingID).Left = __UI_Controls(__UI_DraggingID).Left + (__UI_MouseX - __UI_DragX) - __UI_DragX = __UI_MouseX + __UI_Controls(__UI_DraggingID).Left = __UI_Controls(__UI_DraggingID).Left + (__UI_MouseLeft - __UI_DragX) + __UI_DragX = __UI_MouseLeft 'Draw preview rectangle to show where the object will be snapped '(Ctrl overrides snapping): @@ -1232,6 +1352,11 @@ SUB __UI_EventDispatcher LOOP END IF END IF + + IF __UI_Controls(__UI_DraggingID).ParentID THEN + __UI_PreviewTop = __UI_PreviewTop + __UI_Controls(__UI_Controls(__UI_DraggingID).ParentID).Top + __UI_PreviewLeft = __UI_PreviewLeft + __UI_Controls(__UI_Controls(__UI_DraggingID).ParentID).Left + END IF END IF 'Keyboard handler @@ -1316,24 +1441,19 @@ SUB __UI_EventDispatcher _FONT __UI_Fonts(__UI_Controls(__UI_Focus).Font) SELECT EVERYCASE __UI_KeyHit CASE 18432 'Up - IF __UI_CtrlIsDown THEN - __UI_Controls(__UI_Focus).InputViewStart = __UI_Controls(__UI_Focus).InputViewStart - 1 - ELSE - IF __UI_Controls(__UI_Focus).Value > 1 THEN _ - __UI_Controls(__UI_Focus).Value = __UI_Controls(__UI_Focus).Value - 1 + IF __UI_Controls(__UI_Focus).Value > 1 THEN + __UI_Controls(__UI_Focus).Value = __UI_Controls(__UI_Focus).Value - 1 END IF CASE 20480 'Down - IF __UI_CtrlIsDown THEN - __UI_Controls(__UI_Focus).InputViewStart = __UI_Controls(__UI_Focus).InputViewStart + 1 - ELSE - IF __UI_Controls(__UI_Focus).Value < __UI_Controls(__UI_Focus).Max THEN _ - __UI_Controls(__UI_Focus).Value = __UI_Controls(__UI_Focus).Value + 1 + IF __UI_Controls(__UI_Focus).Value < __UI_Controls(__UI_Focus).Max THEN + __UI_Controls(__UI_Focus).Value = __UI_Controls(__UI_Focus).Value + 1 END IF - CASE 18432, 20480 'Either up or down, let's adjust the view: - IF __UI_Controls(__UI_Focus).Value - __UI_Controls(__UI_Focus).InputViewStart + 1 > __UI_Controls(__UI_Focus).LastVisibleItem THEN - __UI_Controls(__UI_Focus).InputViewStart = __UI_Controls(__UI_Focus).InputViewStart + 1 - ELSEIF __UI_Controls(__UI_Focus).Value < __UI_Controls(__UI_Focus).InputViewStart THEN - __UI_Controls(__UI_Focus).InputViewStart = __UI_Controls(__UI_Focus).InputViewStart - 1 + CASE 18432, 20480 'Either up or down + 'Adjust view: + IF __UI_Controls(__UI_Focus).Value < __UI_Controls(__UI_Focus).InputViewStart THEN + __UI_Controls(__UI_Focus).InputViewStart = __UI_Controls(__UI_Focus).Value + ELSEIF __UI_Controls(__UI_Focus).Value > __UI_Controls(__UI_Focus).InputViewStart + __UI_Controls(__UI_Focus).LastVisibleItem - 1 THEN + __UI_Controls(__UI_Focus).InputViewStart = __UI_Controls(__UI_Focus).Value - __UI_Controls(__UI_Focus).LastVisibleItem + 1 END IF END SELECT CASE __UI_Type_TextBox @@ -1482,7 +1602,7 @@ FUNCTION __UI_GetID (ObjectName$) END FUNCTION '--------------------------------------------------------------------------------- -FUNCTION __UI_NewObject (ObjType AS INTEGER, ObjName AS STRING, ParentID AS LONG) +FUNCTION __UI_NewObject (ObjType AS INTEGER, ObjName AS STRING, NewWidth AS INTEGER, NewHeight AS INTEGER, ParentID AS LONG) DIM NextSlot AS LONG, i AS LONG IF ObjType = __UI_Type_Form THEN @@ -1514,6 +1634,12 @@ FUNCTION __UI_NewObject (ObjType AS INTEGER, ObjName AS STRING, ParentID AS LONG __UI_Controls(NextSlot).ParentID = ParentID __UI_Controls(NextSlot).Type = ObjType __UI_Controls(NextSlot).Name = ObjName + __UI_Controls(NextSlot).Width = NewWidth + __UI_Controls(NextSlot).Height = NewHeight + IF __UI_Controls(NextSlot).Type = __UI_Type_Frame THEN + __UI_Controls(NextSlot).Canvas = _NEWIMAGE(NewWidth, NewHeight, 32) + END IF + __UI_NewObject = NextSlot END FUNCTION @@ -1740,10 +1866,17 @@ SUB __UI_DrawProgressBar (ProgressBar AS ObjectTYPE) STEP(ProgressBar.Width - 1, _ ProgressBar.Height -1), ProgressBar.BackColor, BF - LINE (ContainerOffsetLeft + ProgressBar.Left, _ - ContainerOffsetTop + ProgressBar.Top)-_ - STEP(((ProgressBar.Width - 1) / ProgressBar.Max) * ProgressBar.Value, _ - ProgressBar.Height -1), ProgressBar.ForeColor, BF + IF ProgressBar.Enabled THEN + LINE (ContainerOffsetLeft + ProgressBar.Left, _ + ContainerOffsetTop + ProgressBar.Top)-_ + STEP(((ProgressBar.Width - 1) / ProgressBar.Max) * ProgressBar.Value, _ + ProgressBar.Height -1), ProgressBar.ForeColor, BF + ELSE + LINE (ContainerOffsetLeft + ProgressBar.Left, _ + ContainerOffsetTop + ProgressBar.Top)-_ + STEP(((ProgressBar.Width - 1) / ProgressBar.Max) * ProgressBar.Value, _ + ProgressBar.Height -1), _RGBA32(0, 0, 0, 50), BF + END IF IF ProgressBar.HasBorder THEN LINE (ContainerOffsetLeft + ProgressBar.Left, _ @@ -1753,21 +1886,32 @@ SUB __UI_DrawProgressBar (ProgressBar AS ObjectTYPE) END IF IF ProgressBar.ShowPercentage OR LEN(__UI_Captions(ProgressBar.ID)) THEN - DIM ProgressString$ + DIM TempCaption$, ProgressString$, ReplaceCode% ProgressString$ = LTRIM$(STR$(FIX((ProgressBar.Value / ProgressBar.Max) * 100))) + "%" IF LEN(__UI_Captions(ProgressBar.ID)) THEN - ProgressString$ = __UI_Captions(ProgressBar.ID) - DO WHILE _PRINTWIDTH(ProgressString$) > ProgressBar.Width - ProgressString$ = MID$(ProgressString$, 1, LEN(ProgressString$) - 1) + TempCaption$ = __UI_Captions(ProgressBar.ID) + ReplaceCode% = INSTR(TempCaption$, "\#") + IF ReplaceCode% THEN + TempCaption$ = LEFT$(TempCaption$, ReplaceCode% - 1) + ProgressString$ + MID$(TempCaption$, ReplaceCode% + 2) + END IF + DO WHILE _PRINTWIDTH(TempCaption$) > ProgressBar.Width + TempCaption$ = MID$(TempCaption$, 1, LEN(TempCaption$) - 1) LOOP + ELSE + TempCaption$ = ProgressString$ END IF _FONT __UI_Fonts(ProgressBar.Font) _PRINTMODE _KEEPBACKGROUND - COLOR ProgressBar.BorderColor - IF _PRINTWIDTH(ProgressString$) < ProgressBar.Width THEN - _PRINTSTRING (ContainerOffsetLeft + ProgressBar.Left + ProgressBar.Width / 2 - _PRINTWIDTH(ProgressString$) / 2, _ + + IF ProgressBar.Enabled THEN + COLOR ProgressBar.BorderColor + ELSE + COLOR __UI_Darken(__UI_Controls(__UI_GetID("Form1")).BackColor, 70) + END IF + IF _PRINTWIDTH(TempCaption$) < ProgressBar.Width THEN + _PRINTSTRING (ContainerOffsetLeft + ProgressBar.Left + ProgressBar.Width / 2 - _PRINTWIDTH(TempCaption$) / 2, _ ContainerOffsetTop + ProgressBar.Top + ProgressBar.Height / 2 - _FONTHEIGHT / 2), _ - ProgressString$ + TempCaption$ END IF END IF END SUB