diff --git a/InForm.ui b/InForm.ui index c500130..549b9df 100644 --- a/InForm.ui +++ b/InForm.ui @@ -57,6 +57,7 @@ TYPE __UI_ControlTYPE Interval AS _FLOAT HotKey AS INTEGER HotKeyOffset AS INTEGER + HotKeyPosition AS INTEGER ShowPercentage AS _BYTE InputViewStart AS LONG PreviousInputViewStart AS LONG @@ -137,13 +138,13 @@ DIM SHARED __UI_ActiveMenu AS LONG, __UI_ParentMenu AS LONG DIM SHARED __UI_ActiveTipID AS LONG, __UI_TipTimer AS DOUBLE DIM SHARED __UI_ActiveTipTop AS INTEGER, __UI_ActiveTipLeft AS INTEGER DIM SHARED __UI_FormID AS LONG, __UI_HasMenuBar AS LONG -DIM SHARED __UI_ScrollbarWidth AS INTEGER -DIM SHARED __UI_ScrollbarButtonHeight AS INTEGER +DIM SHARED __UI_ScrollbarWidth AS INTEGER, __UI_ScrollbarButtonHeight AS INTEGER +DIM SHARED __UI_MenuBarOffset AS INTEGER, __UI_MenuItemOffset AS INTEGER DIM SHARED __UI_ForceRedraw AS _BYTE, __UI_AutoRefresh AS _BYTE DIM SHARED __UI_CurrentTitle AS STRING, __UI_WindowHandle AS LONG DIM SHARED __UI_DesignMode AS _BYTE, __UI_FirstSelectedID AS LONG, __UI_ResizingForm AS _BYTE DIM SHARED __UI_WaitMessage AS STRING, __UI_TotalSelectedControls AS LONG -DIM SHARED __UI_WaitMessageHandle AS LONG, __UI_ControlOperation AS _BYTE +DIM SHARED __UI_WaitMessageHandle AS LONG 'Control types: DIM SHARED __UI_Type(0 TO 17) AS __UI_Types @@ -211,6 +212,8 @@ CONST __UI_MsgBox_Continue = 11 CONST __UI_True = -1 CONST __UI_False = 0 +ON ERROR GOTO __UI_ErrorHandler + __UI_LoadForm __UI_Init @@ -220,6 +223,10 @@ DO _LIMIT 1 LOOP +SYSTEM +__UI_ErrorHandler: +RESUME NEXT + '--------------------------------------------------------------------------------- SUB __UI_Init DIM i AS LONG @@ -231,7 +238,7 @@ SUB __UI_Init IF __UI_Controls(__UI_FormID).CenteredWindow THEN _SCREENMOVE _MIDDLE - IF __UI_Controls(__UI_FormID).Font = 0 THEN __UI_Controls(__UI_FormID).Font = __UI_Font("VGA Emulated", "", 16, "") + IF __UI_Controls(__UI_FormID).Font = 0 THEN __UI_Controls(__UI_FormID).Font = __UI_Font("", 16, "") IF __UI_Captions(__UI_FormID) = "" THEN __UI_Captions(__UI_FormID) = RTRIM$(__UI_Controls(__UI_FormID).Name) @@ -555,6 +562,8 @@ SUB __UI_UpdateDisplay IF __UI_AutoRefresh = __UI_False THEN EXIT SUB + ON ERROR GOTO __UI_ErrorHandler + __UI_BeforeUpdateDisplay 'Clear frames canvases and count its children: @@ -1335,12 +1344,10 @@ SUB __UI_EventDispatcher __UI_Controls(__UI_DraggingID).Top = __UI_PreviewTop __UI_Controls(__UI_DraggingID).Left = __UI_PreviewLeft __UI_DraggingID = 0 - __UI_EndDrag END IF IF __UI_IsResizing THEN __UI_IsResizing = __UI_False __UI_ResizingID = 0 - __UI_EndResize END IF IF __UI_DraggingThumb THEN __UI_DraggingThumb = __UI_False @@ -2063,7 +2070,6 @@ SUB __UI_EventDispatcher NEXT END IF END IF - __UI_ControlOperation = __UI_True CASE ASC("C"), ASC("c") IF __UI_CtrlIsDown AND __UI_TotalSelectedControls > 0 THEN ControlClipboard$ = MKL$(__UI_TotalSelectedControls) @@ -2074,7 +2080,6 @@ SUB __UI_EventDispatcher NEXT _CLIPBOARD$ = "InForm" + CHR$(1) END IF - __UI_ControlOperation = __UI_True CASE ASC("V"), ASC("v") IF __UI_CtrlIsDown THEN Clip$ = _CLIPBOARD$ @@ -2122,7 +2127,6 @@ SUB __UI_EventDispatcher __UI_AutoRefresh = __UI_True END IF END IF - __UI_ControlOperation = __UI_True CASE 21248 'Delete FOR i = 1 TO UBOUND(__UI_Controls) IF __UI_Controls(i).ControlIsSelected THEN @@ -2140,7 +2144,6 @@ SUB __UI_EventDispatcher __UI_TotalSelectedControls = __UI_TotalSelectedControls - 1 END IF NEXT - __UI_ControlOperation = __UI_True CASE 19200 'Left arrow key FOR i = 1 TO UBOUND(__UI_Controls) IF __UI_Controls(i).ControlIsSelected THEN @@ -2204,8 +2207,8 @@ FUNCTION __UI_GetFontID (FontHandle&) END FUNCTION '--------------------------------------------------------------------------------- -FUNCTION __UI_Font& (NewFontName AS STRING, NewFontFile AS STRING, NewFontSize AS INTEGER, NewFontAttributes AS STRING) - DIM NextSlot AS LONG, i AS LONG, Temp$ +FUNCTION __UI_Font& (NewFontFile AS STRING, NewFontSize AS INTEGER, TempNewFontAttributes AS STRING) + DIM NextSlot AS LONG, i AS LONG, Temp$, NewFontAttributes AS STRING 'If the passed font is already loaded, we'll just return its handle FOR NextSlot = 1 TO UBOUND(__UI_Controls) @@ -2242,13 +2245,41 @@ FUNCTION __UI_Font& (NewFontName AS STRING, NewFontFile AS STRING, NewFontSize A __UI_DestroyControl __UI_Controls(NextSlot) 'This control is inactive but may still retain properties __UI_Controls(NextSlot).ID = NextSlot __UI_Controls(NextSlot).Type = __UI_Type_Font - __UI_Controls(NextSlot).Name = NewFontName + __UI_Controls(NextSlot).Name = "Font" + LTRIM$(STR$(__UI_Type(__UI_Type_Font).Count)) IF NewFontFile = "" THEN 'Internal emulated fonts - __UI_Controls(NextSlot).Value = NewFontSize - __UI_Controls(NextSlot).Max = NewFontSize + IF NewFontSize <> 8 AND NewFontSize <> 16 THEN + __UI_Controls(NextSlot).Value = 16 + __UI_Controls(NextSlot).Max = 16 + ELSE + __UI_Controls(NextSlot).Value = NewFontSize + __UI_Controls(NextSlot).Max = NewFontSize + END IF ELSE + 'Parse attributes + IF INSTR(UCASE$(TempNewFontAttributes), "MONOSPACE") THEN NewFontAttributes = "MONOSPACE" + IF INSTR(UCASE$(TempNewFontAttributes), "BOLD") THEN + IF LEN(NewFontAttributes) > 0 THEN NewFontAttributes = NewFontAttributes + "," + NewFontAttributes = NewFontAttributes + "BOLD" + END IF + IF INSTR(UCASE$(TempNewFontAttributes), "ITALIC") THEN + IF LEN(NewFontAttributes) > 0 THEN NewFontAttributes = NewFontAttributes + "," + NewFontAttributes = NewFontAttributes + "ITALIC" + END IF + IF INSTR(UCASE$(TempNewFontAttributes), "UNDERLINE") THEN + IF LEN(NewFontAttributes) > 0 THEN NewFontAttributes = NewFontAttributes + "," + NewFontAttributes = NewFontAttributes + "UNDERLINE" + END IF + IF INSTR(UCASE$(TempNewFontAttributes), "UNICODE") THEN + IF LEN(NewFontAttributes) > 0 THEN NewFontAttributes = NewFontAttributes + "," + NewFontAttributes = NewFontAttributes + "UNICODE" + END IF + IF INSTR(UCASE$(TempNewFontAttributes), "DONTBLEND") THEN + IF LEN(NewFontAttributes) > 0 THEN NewFontAttributes = NewFontAttributes + "," + NewFontAttributes = NewFontAttributes + "DONTBLEND" + END IF + __UI_Controls(NextSlot).Value = _LOADFONT(NewFontFile, NewFontSize, NewFontAttributes) __UI_Controls(NextSlot).Max = NewFontSize __UI_Texts(NextSlot) = NewFontFile @@ -2259,6 +2290,7 @@ FUNCTION __UI_Font& (NewFontName AS STRING, NewFontFile AS STRING, NewFontSize A 'If loading the requested font fails, we default to _FONT 16 IF __UI_Controls(NextSlot).Value <= 0 THEN __UI_DestroyControl __UI_Controls(NextSlot) + __UI_Controls(NextSlot).Value = 16 __UI_Font& = 16 END IF END IF @@ -2320,7 +2352,7 @@ FUNCTION __UI_NewControl (ControlType AS INTEGER, ControlName AS STRING, NewWidt __UI_Controls(NextSlot).Font = __UI_Controls(ParentID).Font END IF - IF __UI_Controls(NextSlot).Font = 0 THEN __UI_Controls(NextSlot).Font = __UI_Font("VGA Emulated", "", 16, "") + IF __UI_Controls(NextSlot).Font = 0 THEN __UI_Controls(NextSlot).Font = __UI_Font("", 16, "") __UI_Controls(NextSlot).Width = NewWidth __UI_Controls(NextSlot).Height = NewHeight @@ -2504,7 +2536,7 @@ END SUB '--------------------------------------------------------------------------------- SUB __UI_SetCaption (Control$, TempCaption$) DIM i AS LONG, FindSep%, ThisID AS LONG, NewCaption$, UsedList$, TempKey AS _UNSIGNED _BYTE - DIM PrevFont AS LONG, TempCanvas AS LONG, PrevDest AS LONG, ItemOffset AS INTEGER + DIM PrevFont AS LONG, TempCanvas AS LONG, PrevDest AS LONG ThisID = __UI_GetID(Control$) IF ThisID = 0 THEN EXIT SUB @@ -2524,6 +2556,7 @@ SUB __UI_SetCaption (Control$, TempCaption$) TempKey = ASC(UCASE$(NewCaption$), FindSep%) IF INSTR(UsedList$, CHR$(TempKey)) = 0 THEN __UI_Controls(ThisID).HotKey = TempKey + __UI_Controls(ThisID).HotKeyPosition = FindSep% PrevFont = _FONT @@ -2580,10 +2613,6 @@ SUB __UI_LoadImage (This AS __UI_ControlTYPE, File$) IF This.HelperCanvas <> 0 THEN _FREEIMAGE This.HelperCanvas - IF This.Type = __UI_Type_PictureBox OR This.Type = __UI_Type_Button THEN - __UI_Texts(This.ID) = File$ - END IF - IF _FILEEXISTS(File$) THEN This.HelperCanvas = _LOADIMAGE(File$, 32) IF This.HelperCanvas = -1 THEN ErrorMessage$ = "Unable to load file:" @@ -2607,6 +2636,10 @@ SUB __UI_LoadImage (This AS __UI_ControlTYPE, File$) _PRINTSTRING (5, 5), ErrorMessage$ _PRINTSTRING (5, 5 + _FONTHEIGHT), File$ _DEST PrevDest + ELSE + IF This.Type = __UI_Type_PictureBox OR This.Type = __UI_Type_Button OR This.Type = __UI_Type_MenuItem THEN + __UI_Texts(This.ID) = File$ + END IF END IF END SUB @@ -2783,7 +2816,7 @@ SUB __UI_RemoveListBoxItem (WhichListBox$, ItemToRemove AS INTEGER) DIM This AS __UI_ControlTYPE, TempText$, ThisItem%, FindLF&, TempCaption$ This = __UI_Controls(__UI_GetID(WhichListBox$)) - IF This.Type <> __UI_Type_ListBox THEN ERROR 5: EXIT SUB + IF This.Type <> __UI_Type_ListBox AND This.Type <> __UI_Type_DropdownList THEN ERROR 5: EXIT SUB IF ItemToRemove > This.Max THEN ERROR 6: EXIT SUB @@ -2816,6 +2849,38 @@ SUB __UI_RemoveListBoxItem (WhichListBox$, ItemToRemove AS INTEGER) __UI_Controls(This.ID) = This END SUB +'--------------------------------------------------------------------------------- +SUB __UI_ReplaceListBoxItem (WhichListBox$, ItemToReplace AS INTEGER, NewText$) + DIM This AS __UI_ControlTYPE, TempText$, ThisItem%, FindLF&, TempCaption$ + + This = __UI_Controls(__UI_GetID(WhichListBox$)) + IF This.Type <> __UI_Type_ListBox AND This.Type <> __UI_Type_DropdownList THEN ERROR 5: EXIT SUB + + IF ItemToReplace > This.Max THEN ERROR 6: EXIT SUB + + TempText$ = __UI_Texts(This.ID) + __UI_Texts(This.ID) = "" + + 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$ = "" + END IF + + IF ThisItem% <> ItemToReplace THEN + __UI_Texts(This.ID) = __UI_Texts(This.ID) + TempCaption$ + CHR$(13) + ELSE + __UI_Texts(This.ID) = __UI_Texts(This.ID) + NewText$ + CHR$(13) + END IF + LOOP +END SUB + '--------------------------------------------------------------------------------- SUB __UI_ListBoxSearchItem (This AS __UI_ControlTYPE) STATIC SearchPattern$, LastListKeyHit AS DOUBLE @@ -2968,7 +3033,7 @@ END SUB '--------------------------------------------------------------------------------- SUB __UI_ActivateMenu (This AS __UI_ControlTYPE, SelectFirstItem AS _BYTE) - DIM i AS LONG, ItemOffset AS INTEGER, TotalItems AS INTEGER, ItemHeight AS INTEGER + DIM i AS LONG, TotalItems AS INTEGER, ItemHeight AS INTEGER IF NOT This.Disabled THEN IF __UI_ActiveMenu > 0 THEN __UI_DestroyControl __UI_Controls(__UI_ActiveMenu) @@ -2987,17 +3052,13 @@ SUB __UI_ActivateMenu (This AS __UI_ControlTYPE, SelectFirstItem AS _BYTE) __UI_Controls(__UI_ActiveMenu).Top = __UI_MouseTop END IF - IF _PRINTWIDTH("W") <> _PRINTWIDTH("I") THEN ItemOffset = _PRINTWIDTH("____") ELSE ItemOffset = _PRINTWIDTH("__") - 'Calculate panel's width and position the menu items - __UI_Controls(__UI_ActiveMenu).Width = 120 - ItemHeight = _FONTHEIGHT * 1.5 __UI_Controls(__UI_ActiveMenu).Height = _FONTHEIGHT * .3 FOR i = 1 TO UBOUND(__UI_Controls) IF __UI_Controls(i).ParentID = This.ID AND NOT __UI_Controls(i).Hidden THEN TotalItems = TotalItems + 1 - __UI_Controls(i).Width = ItemOffset * 2 + _PRINTWIDTH(__UI_Captions(i)) + __UI_Controls(i).Width = __UI_MenuItemOffset * 2 + _PRINTWIDTH(__UI_Captions(i)) IF __UI_Controls(__UI_ActiveMenu).Width < __UI_Controls(i).Width THEN __UI_Controls(__UI_ActiveMenu).Width = __UI_Controls(i).Width END IF @@ -3138,26 +3199,25 @@ END FUNCTION '--------------------------------------------------------------------------------- SUB __UI_RefreshMenuBar 'Calculate menu items' .Left and .Width - DIM LeftOffset AS INTEGER, ItemOffset AS INTEGER, i AS LONG + DIM LeftOffset AS INTEGER, i AS LONG DIM TotalItems AS INTEGER, LastMenuItem AS LONG _FONT (__UI_Controls(__UI_FormID).Font) - IF _PRINTWIDTH("W") <> _PRINTWIDTH("I") THEN ItemOffset = _PRINTWIDTH("__") ELSE ItemOffset = _PRINTWIDTH("__") FOR i = 1 TO UBOUND(__UI_Controls) IF __UI_Controls(i).ID > 0 THEN IF __UI_Controls(i).Type = __UI_Type_MenuBar AND NOT __UI_Controls(i).Hidden THEN TotalItems = TotalItems + 1 IF TotalItems = 1 THEN - LeftOffset = ItemOffset + LeftOffset = __UI_MenuBarOffset ELSE LeftOffset = LeftOffset + __UI_Controls(LastMenuItem).Width END IF - __UI_Controls(i).Width = ItemOffset + _PRINTWIDTH(__UI_Captions(i)) + ItemOffset + __UI_Controls(i).Width = __UI_MenuBarOffset + _PRINTWIDTH(__UI_Captions(i)) + __UI_MenuBarOffset IF __UI_Controls(i).Align = __UI_Left THEN __UI_Controls(i).Left = LeftOffset ELSE - __UI_Controls(i).Left = __UI_Controls(__UI_FormID).Width - 1 - ItemOffset - __UI_Controls(i).Width + __UI_Controls(i).Left = __UI_Controls(__UI_FormID).Width - 1 - __UI_MenuBarOffset - __UI_Controls(i).Width END IF LastMenuItem = i END IF diff --git a/InForm/disk.png b/InForm/disk.png new file mode 100644 index 0000000..71dfaf8 Binary files /dev/null and b/InForm/disk.png differ diff --git a/UiEditor.bas b/UiEditor.bas index 79afb3a..794df46 100644 --- a/UiEditor.bas +++ b/UiEditor.bas @@ -5,9 +5,10 @@ _ICON DIM SHARED RedTrackID AS LONG, GreenTrackID AS LONG, BlueTrackID AS LONG DIM SHARED RedTextBoxID AS LONG, GreenTextBoxID AS LONG, BlueTextBoxID AS LONG -DIM SHARED ColorPropertiesListID AS LONG +DIM SHARED ColorPropertiesListID AS LONG, PropertyValueID AS LONG DIM SHARED UiPreviewPID AS LONG, TotalSelected AS LONG, FirstSelected AS LONG DIM SHARED PreviewFormID AS LONG, ColorPreviewID AS LONG +DIM SHARED BackStyleListID AS LONG DIM SHARED CheckPreviewTimer AS INTEGER, PreviewAttached AS _BYTE CONST OffsetEditorPID = 1 @@ -28,6 +29,7 @@ REDIM SHARED PreviewTexts(0) AS STRING REDIM SHARED PreviewTips(0) AS STRING REDIM SHARED PreviewFonts(0) AS STRING REDIM SHARED PreviewControls(0) AS __UI_ControlTYPE +REDIM SHARED PreviewParentIDS(0) AS STRING CheckPreviewTimer = _FREETIMER ON TIMER(CheckPreviewTimer, .003) CheckPreview @@ -67,8 +69,8 @@ SUB __UI_Click (id AS LONG) CASE "ADDPICTUREBOX": Dummy = __UI_Type_PictureBox CASE "ADDFRAME": Dummy = __UI_Type_Frame CASE "ADDBUTTON", "ADDLABEL", "ADDTEXTBOX", "ADDCHECKBOX", _ - "ADDRADIOBUTTON", "ADDLISTBOX", "ADDDROPDOWNLIST", _ - "ADDTRACKBAR", "ADDPROGRESSBAR", "ADDPICTUREBOX", "ADDFRAME" + "ADDRADIOBUTTON", "ADDLISTBOX", "ADDDROPDOWNLIST", _ + "ADDTRACKBAR", "ADDPROGRESSBAR", "ADDPICTUREBOX", "ADDFRAME" UiEditorFile = FREEFILE OPEN "UiEditor.dat" FOR BINARY AS #UiEditorFile b$ = MKI$(Dummy) @@ -98,18 +100,21 @@ SUB __UI_Click (id AS LONG) CASE "CENTEREDWINDOW" b$ = MKI$(__UI_Controls(__UI_GetID("CenteredWindow")).Value) SendData b$, 21 + CASE "RESIZABLE" + b$ = MKI$(__UI_Controls(__UI_GetID("Resizable")).Value) + SendData b$, 29 CASE "VIEWMENUPREVIEW" $IF WIN THEN SHELL _DONTWAIT "UiEditorPreview.exe" $ELSE SHELL _DONTWAIT "./UiEditorPreview" $END IF - CASE "LOADEDFONTS" + CASE "VIEWMENULOADEDFONTS" DIM Temp$ - FOR Dummy = 1 TO UBOUND(__UI_Controls) - IF __UI_Controls(Dummy).Type = __UI_Type_Font THEN + FOR Dummy = 1 TO UBOUND(PreviewFonts) + IF LEN(PreviewFonts(Dummy)) THEN IF LEN(Temp$) THEN Temp$ = Temp$ + CHR$(10) - Temp$ = Temp$ + RTRIM$(__UI_Controls(Dummy).Name) + " (" + __UI_Texts(Dummy) + ")" + STR$(__UI_Controls(Dummy).Max) + "pt, " + __UI_Captions(Dummy) + Temp$ = Temp$ + PreviewFonts(Dummy) END IF NEXT IF LEN(Temp$) THEN @@ -212,24 +217,21 @@ SUB __UI_Click (id AS LONG) CASE -5 'Font IF LogFileLoad THEN PRINT #2, "FONT:"; DIM FontSetup$, FindSep AS INTEGER - DIM NewFontName AS STRING, NewFontFile AS STRING + DIM NewFontFile AS STRING DIM NewFontSize AS INTEGER, NewFontAttributes AS STRING b$ = SPACE$(2): GET #1, , b$ FontSetup$ = SPACE$(CVI(b$)): GET #1, , FontSetup$ IF LogFileLoad THEN PRINT #2, FontSetup$ - FindSep = INSTR(FontSetup$, "\") - NewFontName = LEFT$(FontSetup$, FindSep - 1): FontSetup$ = MID$(FontSetup$, FindSep + 1) - - FindSep = INSTR(FontSetup$, "\") + FindSep = INSTR(FontSetup$, "*") NewFontFile = LEFT$(FontSetup$, FindSep - 1): FontSetup$ = MID$(FontSetup$, FindSep + 1) - FindSep = INSTR(FontSetup$, "\") + FindSep = INSTR(FontSetup$, "*") NewFontSize = VAL(LEFT$(FontSetup$, FindSep - 1)): FontSetup$ = MID$(FontSetup$, FindSep + 1) NewFontAttributes = FontSetup$ - __UI_Controls(Dummy).Font = __UI_Font(NewFontName, NewFontFile, NewFontSize, NewFontAttributes) + __UI_Controls(Dummy).Font = __UI_Font(NewFontFile, NewFontSize, NewFontAttributes) CASE -6 'ForeColor b$ = SPACE$(4): GET #1, , b$ __UI_Controls(Dummy).ForeColor = _CV(_UNSIGNED LONG, b$) @@ -346,316 +348,11 @@ SUB __UI_Click (id AS LONG) CLOSE #1 END IF CASE "FILEMENUSAVE" - OPEN "form.frm" FOR OUTPUT AS #1 - IF _FILEEXISTS("form.frmbin") THEN KILL "form.frmbin" - OPEN "form.frmbin" FOR BINARY AS #2 - PRINT #1, "'InForm - GUI system for QB64" - PRINT #1, "'Fellippe Heitor, 2016 - fellippe@qb64.org - @fellippeheitor" - PRINT #1, "'Beta version 1" - PRINT #1, "SUB __UI_LoadForm" - PRINT #1, " DIM __UI_NewID AS LONG" - PRINT #1, - b$ = "InForm" + CHR$(1) - PUT #2, 1, b$ - b$ = MKL$(UBOUND(__UI_Controls)) - PUT #2, , b$ - FOR i = 1 TO UBOUND(__UI_Controls) - IF __UI_Controls(i).ID > 0 AND __UI_Controls(i).Type <> __UI_Type_MenuPanel AND __UI_Controls(i).Type <> __UI_Type_Font AND LEN(RTRIM$(__UI_Controls(i).Name)) > 0 THEN - a$ = " __UI_NewID = __UI_NewControl(" - SELECT CASE __UI_Controls(i).Type - CASE __UI_Type_Form: a$ = a$ + "__UI_Type_Form, " - CASE __UI_Type_Frame: a$ = a$ + "__UI_Type_Frame, " - CASE __UI_Type_Button: a$ = a$ + "__UI_Type_Button, " - CASE __UI_Type_Label: a$ = a$ + "__UI_Type_Label, " - CASE __UI_Type_CheckBox: a$ = a$ + "__UI_Type_CheckBox, " - CASE __UI_Type_RadioButton: a$ = a$ + "__UI_Type_RadioButton, " - CASE __UI_Type_TextBox: a$ = a$ + "__UI_Type_TextBox, " - CASE __UI_Type_ProgressBar: a$ = a$ + "__UI_Type_ProgressBar, " - CASE __UI_Type_ListBox: a$ = a$ + "__UI_Type_ListBox, " - CASE __UI_Type_DropdownList: a$ = a$ + "__UI_Type_DropdownList, " - CASE __UI_Type_MenuBar: a$ = a$ + "__UI_Type_MenuBar, " - CASE __UI_Type_MenuItem: a$ = a$ + "__UI_Type_MenuItem, " - CASE __UI_Type_PictureBox: a$ = a$ + "__UI_Type_PictureBox, " - CASE __UI_Type_TrackBar: a$ = a$ + "__UI_Type_TrackBar, " - CASE __UI_Type_ContextMenu: a$ = a$ + "__UI_Type_ContextMenu, " - END SELECT - a$ = a$ + CHR$(34) + RTRIM$(__UI_Controls(i).Name) + CHR$(34) + "," - a$ = a$ + STR$(__UI_Controls(i).Width) + "," - a$ = a$ + STR$(__UI_Controls(i).Height) + "," - a$ = a$ + STR$(__UI_Controls(i).Left) + "," - a$ = a$ + STR$(__UI_Controls(i).Top) + "," - IF __UI_Controls(i).ParentID > 0 THEN - a$ = a$ + " __UI_GetID(" + CHR$(34) + RTRIM$(__UI_Controls(__UI_Controls(i).ParentID).Name) + CHR$(34) + "))" - ELSE - a$ = a$ + " 0)" - END IF - PRINT #1, a$ - b$ = MKI$(-1) + MKI$(__UI_Controls(i).Type) '-1 indicates a new control - b$ = b$ + MKI$(LEN(RTRIM$(__UI_Controls(i).Name))) - b$ = b$ + RTRIM$(__UI_Controls(i).Name) - b$ = b$ + MKI$(__UI_Controls(i).Width) + MKI$(__UI_Controls(i).Height) + MKI$(__UI_Controls(i).Left) + MKI$(__UI_Controls(i).Top) + MKI$(LEN(RTRIM$(__UI_Controls(__UI_Controls(i).ParentID).Name))) + RTRIM$(__UI_Controls(__UI_Controls(i).ParentID).Name) - PUT #2, , b$ - - IF LEN(__UI_Captions(i)) > 0 THEN - a$ = " __UI_SetCaption " + CHR$(34) + RTRIM$(__UI_Controls(i).Name) + CHR$(34) + ", " + __UI_SpecialCharsToCHR$(__UI_Captions(i)) - b$ = MKI$(-2) + MKL$(LEN(__UI_Captions(i))) '-2 indicates a caption - PUT #2, , b$ - PUT #2, , __UI_Captions(i) - PRINT #1, a$ - END IF - - IF LEN(__UI_Tips(i)) > 0 THEN - a$ = " __UI_SetTip " + CHR$(34) + RTRIM$(__UI_Controls(i).Name) + CHR$(34) + ", " + __UI_SpecialCharsToCHR$(__UI_Tips(i)) - b$ = MKI$(-24) + MKL$(LEN(__UI_Tips(i))) '-24 indicates a tip - PUT #2, , b$ - PUT #2, , __UI_Tips(i) - PRINT #1, a$ - END IF - - IF LEN(__UI_Texts(i)) > 0 THEN - SELECT CASE __UI_Controls(i).Type - CASE __UI_Type_ListBox, __UI_Type_DropdownList - DIM TempCaption$, 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$ = "" - END IF - a$ = " __UI_AddListBoxItem " + CHR$(34) + RTRIM$(__UI_Controls(i).Name) + CHR$(34) + ", " + CHR$(34) + TempCaption$ + CHR$(34) - PRINT #1, a$ - LOOP - CASE __UI_Type_PictureBox, __UI_Type_Button - a$ = " __UI_LoadImage __UI_Controls(__UI_NewID), " + CHR$(34) + __UI_Texts(i) + CHR$(34) - PRINT #1, a$ - CASE ELSE - a$ = " __UI_SetText " + CHR$(34) + RTRIM$(__UI_Controls(i).Name) + CHR$(34) + ", " + __UI_SpecialCharsToCHR$(__UI_Captions(i)) - PRINT #1, a$ - END SELECT - b$ = MKI$(-3) + MKL$(LEN(__UI_Texts(i))) '-3 indicates a text - PUT #2, , b$ - PUT #2, , __UI_Texts(i) - END IF - IF __UI_Controls(i).TransparentColor > 0 THEN - PRINT #1, " __UI_ClearColor __UI_Controls(__UI_NewID).HelperCanvas, " + LTRIM$(STR$(__UI_Controls(i).TransparentColor)) + ", -1" - b$ = MKI$(-28) + _MK$(_UNSIGNED LONG, __UI_Controls(i).TransparentColor) - PUT #2, , b$ - END IF - IF __UI_Controls(i).Stretch THEN - PRINT #1, " __UI_Controls(__UI_NewID).Stretch = __UI_True" - b$ = MKI$(-4) - PUT #2, , b$ - END IF - 'Inheritable properties won't be saved if they are the same as the parent's - IF __UI_Controls(i).Type = __UI_Type_Form THEN - IF __UI_Controls(i).Font = 8 OR __UI_Controls(i).Font = 16 THEN - 'Internal fonts - SaveInternalFont: - FontSetup$ = "__UI_Font(" + CHR$(34) + "VGA Emulated" + CHR$(34) + ", " + CHR$(34) + CHR$(34) + "," + STR$(__UI_Controls(__UI_GetFontID(__UI_Controls(i).Font)).Max) + ", " + CHR$(34) + CHR$(34) + ")" - PRINT #1, " __UI_Controls(__UI_NewID).Font = " + FontSetup$ - FontSetup$ = "VGA Emulated\\" + LTRIM$(STR$(__UI_Controls(__UI_GetFontID(__UI_Controls(i).Font)).Max)) + "\" - b$ = MKI$(-5) + MKI$(LEN(FontSetup$)) + FontSetup$ - PUT #2, , b$ - ELSE - SaveExternalFont: - FontSetup$ = "__UI_Font(" + CHR$(34) + RTRIM$(__UI_Controls(__UI_GetFontID(__UI_Controls(i).Font)).Name) + CHR$(34) + ", " + CHR$(34) + __UI_Texts(__UI_GetFontID(__UI_Controls(i).Font)) + CHR$(34) + "," + STR$(__UI_Controls(__UI_GetFontID(__UI_Controls(i).Font)).Max) + ", " + CHR$(34) + __UI_Captions(__UI_GetFontID(__UI_Controls(i).Font)) + CHR$(34) + ")" - PRINT #1, " __UI_Controls(__UI_NewID).Font = " + FontSetup$ - FontSetup$ = RTRIM$(__UI_Controls(__UI_GetFontID(__UI_Controls(i).Font)).Name) + "\" + __UI_Texts(__UI_GetFontID(__UI_Controls(i).Font)) + "\" + LTRIM$(STR$(__UI_Controls(__UI_GetFontID(__UI_Controls(i).Font)).Max)) + "\" + __UI_Captions(__UI_GetFontID(__UI_Controls(i).Font)) - b$ = MKI$(-5) + MKI$(LEN(FontSetup$)) + FontSetup$ - PUT #2, , b$ - END IF - ELSE - IF __UI_Controls(i).ParentID > 0 THEN - IF __UI_Controls(i).Font > 0 AND __UI_Controls(i).Font <> __UI_Controls(__UI_Controls(i).ParentID).Font THEN - IF __UI_Controls(i).Font = 8 OR __UI_Controls(i).Font = 167 THEN - GOTO SaveInternalFont - ELSE - GOTO SaveExternalFont - END IF - END IF - ELSE - IF __UI_Controls(i).Font > 0 AND __UI_Controls(i).Font <> __UI_Controls(__UI_FormID).Font THEN - IF __UI_Controls(i).Font = 8 OR __UI_Controls(i).Font = 167 THEN - GOTO SaveInternalFont - ELSE - GOTO SaveExternalFont - END IF - END IF - END IF - END IF - 'Colors are saved only if they differ from the theme's defaults - IF __UI_Controls(i).ForeColor <> __UI_DefaultColor(__UI_Controls(i).Type, 1) THEN - PRINT #1, " __UI_Controls(__UI_NewID).ForeColor = _RGB32(" + LTRIM$(STR$(_RED32(__UI_Controls(i).ForeColor))) + ", " + LTRIM$(STR$(_GREEN32(__UI_Controls(i).ForeColor))) + ", " + LTRIM$(STR$(_BLUE32(__UI_Controls(i).ForeColor))) + ")" - b$ = MKI$(-6) + _MK$(_UNSIGNED LONG, __UI_Controls(i).ForeColor) - PUT #2, , b$ - END IF - IF __UI_Controls(i).BackColor <> __UI_DefaultColor(__UI_Controls(i).Type, 2) THEN - PRINT #1, " __UI_Controls(__UI_NewID).BackColor = _RGB32(" + LTRIM$(STR$(_RED32(__UI_Controls(i).BackColor))) + ", " + LTRIM$(STR$(_GREEN32(__UI_Controls(i).BackColor))) + ", " + LTRIM$(STR$(_BLUE32(__UI_Controls(i).BackColor))) + ")" - b$ = MKI$(-7) + _MK$(_UNSIGNED LONG, __UI_Controls(i).BackColor) - PUT #2, , b$ - END IF - IF __UI_Controls(i).SelectedForeColor <> __UI_DefaultColor(__UI_Controls(i).Type, 3) THEN - PRINT #1, " __UI_Controls(__UI_NewID).SelectedForeColor = _RGB32(" + LTRIM$(STR$(_RED32(__UI_Controls(i).SelectedForeColor))) + ", " + LTRIM$(STR$(_GREEN32(__UI_Controls(i).SelectedForeColor))) + ", " + LTRIM$(STR$(_BLUE32(__UI_Controls(i).SelectedForeColor))) + ")" - b$ = MKI$(-8) + _MK$(_UNSIGNED LONG, __UI_Controls(i).SelectedForeColor) - PUT #2, , b$ - END IF - IF __UI_Controls(i).SelectedBackColor <> __UI_DefaultColor(__UI_Controls(i).Type, 4) THEN - PRINT #1, " __UI_Controls(__UI_NewID).SelectedBackColor = _RGB32(" + LTRIM$(STR$(_RED32(__UI_Controls(i).SelectedBackColor))) + ", " + LTRIM$(STR$(_GREEN32(__UI_Controls(i).SelectedBackColor))) + ", " + LTRIM$(STR$(_BLUE32(__UI_Controls(i).SelectedBackColor))) + ")" - b$ = MKI$(-9) + _MK$(_UNSIGNED LONG, __UI_Controls(i).SelectedBackColor) - PUT #2, , b$ - END IF - IF __UI_Controls(i).BorderColor <> __UI_DefaultColor(__UI_Controls(i).Type, 5) THEN - PRINT #1, " __UI_Controls(__UI_NewID).BorderColor = _RGB32(" + LTRIM$(STR$(_RED32(__UI_Controls(i).BorderColor))) + ", " + LTRIM$(STR$(_GREEN32(__UI_Controls(i).BorderColor))) + ", " + LTRIM$(STR$(_BLUE32(__UI_Controls(i).BorderColor))) + ")" - b$ = MKI$(-10) + _MK$(_UNSIGNED LONG, __UI_Controls(i).BorderColor) - PUT #2, , b$ - END IF - IF __UI_Controls(i).BackStyle = __UI_Transparent THEN - PRINT #1, " __UI_Controls(__UI_NewID).BackStyle = __UI_Transparent" - b$ = MKI$(-11): PUT #2, , b$ - END IF - IF __UI_Controls(i).HasBorder THEN - PRINT #1, " __UI_Controls(__UI_NewID).HasBorder = __UI_True" - b$ = MKI$(-12): PUT #2, , b$ - END IF - IF __UI_Controls(i).Align = __UI_Center THEN - PRINT #1, " __UI_Controls(__UI_NewID).Align = __UI_Center" - b$ = MKI$(-13) + _MK$(_BYTE, __UI_Controls(i).Align): PUT #2, , b$ - ELSEIF __UI_Controls(i).Align = __UI_Right THEN - PRINT #1, " __UI_Controls(__UI_NewID).Align = __UI_Right" - b$ = MKI$(-13) + _MK$(_BYTE, __UI_Controls(i).Align): PUT #2, , b$ - END IF - IF __UI_Controls(i).Value <> 0 THEN - PRINT #1, " __UI_Controls(__UI_NewID).Value = " + LTRIM$(STR$(__UI_Controls(i).Value)) - b$ = MKI$(-14) + _MK$(_FLOAT, __UI_Controls(i).Value): PUT #2, , b$ - END IF - IF __UI_Controls(i).Min <> 0 THEN - PRINT #1, " __UI_Controls(__UI_NewID).Min = " + LTRIM$(STR$(__UI_Controls(i).Min)) - b$ = MKI$(-15) + _MK$(_FLOAT, __UI_Controls(i).Min): PUT #2, , b$ - END IF - IF __UI_Controls(i).Max <> 0 THEN - PRINT #1, " __UI_Controls(__UI_NewID).Max = " + LTRIM$(STR$(__UI_Controls(i).Max)) - b$ = MKI$(-16) + _MK$(_FLOAT, __UI_Controls(i).Max): PUT #2, , b$ - END IF - IF __UI_Controls(i).HotKey <> 0 THEN - PRINT #1, " __UI_Controls(__UI_NewID).HotKey = " + LTRIM$(STR$(__UI_Controls(i).HotKey)) - b$ = MKI$(-17) + MKI$(__UI_Controls(i).HotKey): PUT #2, , b$ - END IF - IF __UI_Controls(i).HotKeyOffset <> 0 THEN - PRINT #1, " __UI_Controls(__UI_NewID).HotKeyOffset = " + LTRIM$(STR$(__UI_Controls(i).HotKeyOffset)) - b$ = MKI$(-18) + MKI$(__UI_Controls(i).HotKeyOffset): PUT #2, , b$ - END IF - IF __UI_Controls(i).ShowPercentage THEN - PRINT #1, " __UI_Controls(__UI_NewID).ShowPercentage = __UI_True" - b$ = MKI$(-19): PUT #2, , b$ - END IF - IF __UI_Controls(i).CanHaveFocus THEN - PRINT #1, " __UI_Controls(__UI_NewID).CanHaveFocus = __UI_True" - b$ = MKI$(-20): PUT #2, , b$ - END IF - IF __UI_Controls(i).Disabled THEN - PRINT #1, " __UI_Controls(__UI_NewID).Disabled = __UI_True" - b$ = MKI$(-21): PUT #2, , b$ - END IF - IF __UI_Controls(i).Hidden THEN - PRINT #1, " __UI_Controls(__UI_NewID).Hidden = __UI_True" - b$ = MKI$(-22): PUT #2, , b$ - END IF - IF __UI_Controls(i).CenteredWindow THEN - PRINT #1, " __UI_Controls(__UI_NewID).CenteredWindow = __UI_True" - b$ = MKI$(-23): PUT #2, , b$ - END IF - IF __UI_Controls(i).ContextMenuID THEN - PRINT #1, " __UI_Controls(__UI_NewID).ContextMenuID = __UI_GetID(" + CHR$(34) + RTRIM$(__UI_Controls(__UI_Controls(i).ContextMenuID).Name) + CHR$(34) + ")" - b$ = MKI$(-25) + MKI$(LEN(RTRIM$(__UI_Controls(__UI_Controls(i).ContextMenuID).Name))) + RTRIM$(__UI_Controls(__UI_Controls(i).ContextMenuID).Name): PUT #2, , b$ - END IF - IF __UI_Controls(i).Interval THEN - PRINT #1, " __UI_Controls(__UI_NewID).Interval = " + LTRIM$(STR$(__UI_Controls(i).Interval)) - b$ = MKI$(-26) + _MK$(_FLOAT, __UI_Controls(i).Interval): PUT #2, , b$ - END IF - IF __UI_Controls(i).WordWrap THEN - PRINT #1, " __UI_Controls(__UI_NewID).WordWrap = __UI_True" - b$ = MKI$(-27): PUT #2, , b$ - END IF - IF __UI_Controls(i).CanResize AND __UI_Controls(i).Type = __UI_Type_Form THEN - PRINT #1, " __UI_Controls(__UI_NewID).CanResize = __UI_True" - b$ = MKI$(-29): PUT #2, , b$ - END IF - PRINT #1, - END IF - NEXT - b$ = MKI$(-1024): PUT #2, , b$ 'end of file - PRINT #1, "END SUB" - CLOSE #1, #2 - OPEN "program.bas" FOR OUTPUT AS #1 - PRINT #1, "'$INCLUDE:'InForm.ui'" - PRINT #1, "'$INCLUDE:'form.frm'" - PRINT #1, "'$INCLUDE:'xp.uitheme'" - PRINT #1, - PRINT #1, "'Event procedures: ---------------------------------------------------------------" - FOR i = 1 TO 12 - SELECT EVERYCASE i - CASE 1: PRINT #1, "SUB __UI_OnLoad" - CASE 2: PRINT #1, "SUB __UI_BeforeUpdateDisplay" - CASE 3: PRINT #1, "SUB __UI_BeforeUnload" - CASE 4: PRINT #1, "SUB __UI_Click (id AS LONG)" - CASE 5: PRINT #1, "SUB __UI_MouseEnter (id AS LONG)" - CASE 6: PRINT #1, "SUB __UI_MouseLeave (id AS LONG)" - CASE 7: PRINT #1, "SUB __UI_FocusIn (id AS LONG)" - CASE 8: PRINT #1, "SUB __UI_FocusOut (id AS LONG)" - CASE 9: PRINT #1, "SUB __UI_MouseDown (id AS LONG)" - CASE 10: PRINT #1, "SUB __UI_MouseUp (id AS LONG)" - CASE 11: PRINT #1, "SUB __UI_KeyPress (id AS LONG)" - CASE 12: PRINT #1, "SUB __UI_ValueChanged (id AS LONG)" - - CASE 1 TO 3 - PRINT #1, - - CASE 4 TO 6, 9, 10 'All controls except for Menu panels, and internal context menus - PRINT #1, " SELECT CASE UCASE$(RTRIM$(__UI_Controls(id).Name))" - FOR Dummy = 1 TO UBOUND(__UI_Controls) - IF __UI_Controls(Dummy).ID AND __UI_Controls(Dummy).Type <> __UI_Type_Font AND __UI_Controls(Dummy).Type <> __UI_Type_ContextMenu AND RTRIM$(__UI_Controls(Dummy).Name) <> "__UI_TextFieldMenu" AND __UI_Controls(Dummy).ParentID <> __UI_GetID("__UI_TextFieldMenu") THEN - PRINT #1, " CASE " + CHR$(34) + UCASE$(RTRIM$(__UI_Controls(Dummy).Name)) + CHR$(34) - PRINT #1, - END IF - NEXT - PRINT #1, " END SELECT" - - CASE 7, 8, 11 'Controls that can have focus only - PRINT #1, " SELECT CASE UCASE$(RTRIM$(__UI_Controls(id).Name))" - FOR Dummy = 1 TO UBOUND(__UI_Controls) - IF __UI_Controls(Dummy).ID AND __UI_Controls(Dummy).CanHaveFocus THEN - PRINT #1, " CASE " + CHR$(34) + UCASE$(RTRIM$(__UI_Controls(Dummy).Name)) + CHR$(34) - PRINT #1, - END IF - NEXT - PRINT #1, " END SELECT" - - CASE 12 'Dropdown list, List box and Track bar - PRINT #1, " SELECT CASE UCASE$(RTRIM$(__UI_Controls(id).Name))" - FOR Dummy = 1 TO UBOUND(__UI_Controls) - IF __UI_Controls(Dummy).ID AND (__UI_Controls(Dummy).Type = __UI_Type_ListBox OR __UI_Controls(Dummy).Type = __UI_Type_DropdownList OR __UI_Controls(Dummy).Type = __UI_Type_TrackBar) THEN - PRINT #1, " CASE " + CHR$(34) + UCASE$(RTRIM$(__UI_Controls(Dummy).Name)) + CHR$(34) - PRINT #1, - END IF - NEXT - PRINT #1, " END SELECT" - END SELECT - PRINT #1, "END SUB" - PRINT #1, - NEXT - CLOSE #1 + SaveForm CASE "HELPMENUABOUT" - Answer = __UI_MessageBox("UI beta" + CHR$(10) + "by Fellippe Heitor" + CHR$(10) + CHR$(10) + "Twitter: @fellippeheitor" + CHR$(10) + "e-mail: fellippe@qb64.org", "About", __UI_MsgBox_OkOnly + __UI_MsgBox_Information) + Answer = __UI_MessageBox("InForm Designer" + CHR$(10) + "by Fellippe Heitor" + CHR$(10) + CHR$(10) + "Twitter: @fellippeheitor" + CHR$(10) + "e-mail: fellippe@qb64.org", "About", __UI_MsgBox_OkOnly + __UI_MsgBox_Information) CASE "HELPMENUHELP" - Answer = __UI_MessageBox("This will soon become a GUI editor, which will allow an event-driven approach to programs written in QB64.", "What's all this?", __UI_MsgBox_OkOnly + __UI_MsgBox_Information) + Answer = __UI_MessageBox("Design a form and export the resulting code to generate an event-driven QB64 program.", "What's all this?", __UI_MsgBox_OkOnly + __UI_MsgBox_Information) CASE "FILEMENUEXIT" SYSTEM END SELECT @@ -742,35 +439,37 @@ SUB __UI_BeforeUpdateDisplay IF FirstSelected = 0 THEN FirstSelected = PreviewFormID - IF __UI_Focus <> __UI_GetID("PropertyValue") THEN + IF __UI_Focus <> PropertyValueID THEN SELECT CASE SelectedProperty CASE 1 'Name - __UI_Texts(__UI_GetID("PropertyValue")) = RTRIM$(PreviewControls(FirstSelected).Name) + __UI_Texts(PropertyValueID) = RTRIM$(PreviewControls(FirstSelected).Name) CASE 2 'Caption - __UI_Texts(__UI_GetID("PropertyValue")) = PreviewCaptions(FirstSelected) + __UI_Texts(PropertyValueID) = PreviewCaptions(FirstSelected) CASE 3 'Text - __UI_Texts(__UI_GetID("PropertyValue")) = PreviewTexts(FirstSelected) + __UI_Texts(PropertyValueID) = PreviewTexts(FirstSelected) CASE 4 'Top - __UI_Texts(__UI_GetID("PropertyValue")) = LTRIM$(STR$(PreviewControls(FirstSelected).Top)) + __UI_Texts(PropertyValueID) = LTRIM$(STR$(PreviewControls(FirstSelected).Top)) CASE 5 'Left - __UI_Texts(__UI_GetID("PropertyValue")) = LTRIM$(STR$(PreviewControls(FirstSelected).Left)) + __UI_Texts(PropertyValueID) = LTRIM$(STR$(PreviewControls(FirstSelected).Left)) CASE 6 'Width - __UI_Texts(__UI_GetID("PropertyValue")) = LTRIM$(STR$(PreviewControls(FirstSelected).Width)) + __UI_Texts(PropertyValueID) = LTRIM$(STR$(PreviewControls(FirstSelected).Width)) CASE 7 'Height - __UI_Texts(__UI_GetID("PropertyValue")) = LTRIM$(STR$(PreviewControls(FirstSelected).Height)) + __UI_Texts(PropertyValueID) = LTRIM$(STR$(PreviewControls(FirstSelected).Height)) CASE 8 'Font - __UI_Texts(__UI_GetID("PropertyValue")) = PreviewFonts(FirstSelected) - CASE 9 'BackStyle - __UI_Texts(__UI_GetID("PropertyValue")) = LTRIM$(STR$(PreviewControls(FirstSelected).BackStyle)) + __UI_Texts(PropertyValueID) = PreviewFonts(FirstSelected) + CASE 9 'Tooltip + __UI_Texts(PropertyValueID) = PreviewTips(FirstSelected) CASE 10 'Value - __UI_Texts(__UI_GetID("PropertyValue")) = LTRIM$(STR$(PreviewControls(FirstSelected).Value)) + __UI_Texts(PropertyValueID) = LTRIM$(STR$(PreviewControls(FirstSelected).Value)) CASE 11 'Min - __UI_Texts(__UI_GetID("PropertyValue")) = LTRIM$(STR$(PreviewControls(FirstSelected).Min)) + __UI_Texts(PropertyValueID) = LTRIM$(STR$(PreviewControls(FirstSelected).Min)) CASE 12 'Max - __UI_Texts(__UI_GetID("PropertyValue")) = LTRIM$(STR$(PreviewControls(FirstSelected).Max)) + __UI_Texts(PropertyValueID) = LTRIM$(STR$(PreviewControls(FirstSelected).Max)) CASE 13 'Interval - __UI_Texts(__UI_GetID("PropertyValue")) = LTRIM$(STR$(PreviewControls(FirstSelected).Interval)) + __UI_Texts(PropertyValueID) = LTRIM$(STR$(PreviewControls(FirstSelected).Interval)) END SELECT + ELSE + __UI_CursorAdjustments END IF 'Update checkboxes: @@ -783,6 +482,114 @@ SUB __UI_BeforeUpdateDisplay __UI_Controls(__UI_GetID("Hidden")).Value = PreviewControls(FirstSelected).Hidden __UI_Controls(__UI_GetID("CenteredWindow")).Value = PreviewControls(FirstSelected).CenteredWindow __UI_Controls(__UI_GetID("AlignOptions")).Value = PreviewControls(FirstSelected).Align + 1 + IF PreviewControls(FirstSelected).BackStyle THEN + __UI_Controls(__UI_GetID("BackStyleOptions")).Value = 2 + ELSE + __UI_Controls(__UI_GetID("BackStyleOptions")).Value = 1 + END IF + __UI_Controls(__UI_GetID("Resizable")).Value = PreviewControls(FirstSelected).CanResize + + 'Disable properties that don't apply + __UI_Controls(__UI_GetID("Stretch")).Disabled = __UI_True + __UI_Controls(__UI_GetID("HasBorder")).Disabled = __UI_True + __UI_Controls(__UI_GetID("ShowPercentage")).Disabled = __UI_True + __UI_Controls(__UI_GetID("WordWrap")).Disabled = __UI_True + __UI_Controls(__UI_GetID("CanHaveFocus")).Disabled = __UI_True + __UI_Controls(__UI_GetID("Disabled")).Disabled = __UI_True + __UI_Controls(__UI_GetID("Hidden")).Disabled = __UI_True + __UI_Controls(__UI_GetID("CenteredWindow")).Disabled = __UI_True + __UI_Controls(__UI_GetID("AlignOptions")).Disabled = __UI_True + __UI_Controls(BackStyleListID).Disabled = __UI_True + __UI_ReplaceListBoxItem "PropertiesList", 3, "Text" + __UI_Controls(__UI_GetID("Resizable")).Disabled = __UI_True + IF TotalSelected > 0 THEN + SELECT EVERYCASE PreviewControls(FirstSelected).Type + CASE __UI_Type_PictureBox + __UI_ReplaceListBoxItem "PropertiesList", 3, "Image file" + __UI_Controls(__UI_GetID("Stretch")).Disabled = __UI_False + __UI_Controls(BackStyleListID).Disabled = __UI_False + SELECT CASE SelectedProperty + CASE 1, 3, 4, 5, 6, 7, 9 + __UI_Controls(PropertyValueID).Disabled = __UI_False + CASE ELSE + __UI_Controls(PropertyValueID).Disabled = __UI_True + END SELECT + CASE __UI_Type_Frame, __UI_Type_Label + __UI_Controls(BackStyleListID).Disabled = __UI_False + SELECT CASE SelectedProperty + CASE 1, 2, 4, 5, 6, 7, 8, 9 + __UI_Controls(PropertyValueID).Disabled = __UI_False + CASE ELSE + __UI_Controls(PropertyValueID).Disabled = __UI_True + END SELECT + CASE __UI_Type_TextBox + __UI_Controls(BackStyleListID).Disabled = __UI_False + CASE __UI_Type_Button + __UI_ReplaceListBoxItem "PropertiesList", 3, "Image file" + CASE __UI_Type_Button, __UI_Type_TextBox + SELECT CASE SelectedProperty + CASE 1, 2, 3, 4, 5, 6, 7, 8, 9 + __UI_Controls(PropertyValueID).Disabled = __UI_False + CASE ELSE + __UI_Controls(PropertyValueID).Disabled = __UI_True + END SELECT + CASE __UI_Type_CheckBox, __UI_Type_RadioButton + __UI_Controls(BackStyleListID).Disabled = __UI_False + SELECT CASE SelectedProperty + CASE 1, 2, 4, 5, 6, 7, 8, 9, 10 + __UI_Controls(PropertyValueID).Disabled = __UI_False + CASE ELSE + __UI_Controls(PropertyValueID).Disabled = __UI_True + END SELECT + CASE __UI_Type_ProgressBar + SELECT CASE SelectedProperty + CASE 1, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12 + __UI_Controls(PropertyValueID).Disabled = __UI_False + CASE ELSE + __UI_Controls(PropertyValueID).Disabled = __UI_True + END SELECT + CASE __UI_Type_TrackBar + SELECT CASE SelectedProperty + CASE 1, 4, 5, 6, 7, 9, 10, 11, 12, 13 + __UI_Controls(PropertyValueID).Disabled = __UI_False + CASE ELSE + __UI_Controls(PropertyValueID).Disabled = __UI_True + END SELECT + CASE __UI_Type_ListBox, __UI_Type_DropdownList + __UI_Controls(BackStyleListID).Disabled = __UI_False + SELECT CASE SelectedProperty + CASE 1, 3, 4, 5, 6, 7, 8, 9, 10, 12 + __UI_Controls(PropertyValueID).Disabled = __UI_False + CASE ELSE + __UI_Controls(PropertyValueID).Disabled = __UI_True + END SELECT + CASE __UI_Type_Frame, __UI_Type_Label, __UI_Type_TextBox, __UI_Type_ListBox, __UI_Type_DropdownList, __UI_Type_PictureBox + __UI_Controls(__UI_GetID("HasBorder")).Disabled = __UI_False + CASE __UI_Type_ProgressBar + __UI_Controls(__UI_GetID("ShowPercentage")).Disabled = __UI_False + CASE __UI_Type_Label + __UI_Controls(__UI_GetID("WordWrap")).Disabled = __UI_False + CASE __UI_Type_Button, __UI_Type_CheckBox, __UI_Type_RadioButton, __UI_Type_TextBox, __UI_Type_ListBox, __UI_Type_DropdownList, __UI_Type_TrackBar + __UI_Controls(__UI_GetID("CanHaveFocus")).Disabled = __UI_False + CASE __UI_Type_Button, __UI_Type_CheckBox, __UI_Type_RadioButton, __UI_Type_TextBox, __UI_Type_ListBox, __UI_Type_DropdownList, __UI_Type_TrackBar, __UI_Type_Label, __UI_Type_ProgressBar + __UI_Controls(__UI_GetID("Disabled")).Disabled = __UI_False + CASE __UI_Type_Frame, __UI_Type_Button, __UI_Type_CheckBox, __UI_Type_RadioButton, __UI_Type_TextBox, __UI_Type_ListBox, __UI_Type_DropdownList, __UI_Type_TrackBar, __UI_Type_Label, __UI_Type_ProgressBar, __UI_Type_PictureBox + __UI_Controls(__UI_GetID("Hidden")).Disabled = __UI_False + CASE __UI_Type_Label + __UI_Controls(__UI_GetID("AlignOptions")).Disabled = __UI_False + END SELECT + ELSE + 'Properties relative to the form + __UI_Controls(__UI_GetID("CenteredWindow")).Disabled = __UI_False + __UI_Controls(__UI_GetID("Resizable")).Disabled = __UI_False + + SELECT CASE SelectedProperty + CASE 1, 2, 6, 7, 8 'Name, Caption, Width, Height, Font + __UI_Controls(PropertyValueID).Disabled = __UI_False + CASE ELSE + __UI_Controls(PropertyValueID).Disabled = __UI_True + END SELECT + END IF 'Update the color mixer DIM ThisColor AS _UNSIGNED LONG, ThisBackColor AS _UNSIGNED LONG @@ -894,6 +701,21 @@ SUB __UI_OnLoad __UI_Controls(__UI_GetID("AddFrame")).HelperCanvas = _NEWIMAGE(16, 16, 32) i = i + 1: _PUTIMAGE (0, 0), CommControls, __UI_Controls(__UI_GetID("AddFrame")).HelperCanvas, (0, i * 16 - 16)-STEP(15, 15) + + 'Properly loaded helper images assign a file name to the control's text property. + 'Any text will do for internallly stored images: + __UI_Texts(__UI_GetID("AddButton")) = "." + __UI_Texts(__UI_GetID("AddLabel")) = "." + __UI_Texts(__UI_GetID("AddTextBox")) = "." + __UI_Texts(__UI_GetID("AddCheckBox")) = "." + __UI_Texts(__UI_GetID("AddRadioButton")) = "." + __UI_Texts(__UI_GetID("AddListBox")) = "." + __UI_Texts(__UI_GetID("AddDropdownList")) = "." + __UI_Texts(__UI_GetID("AddTrackBar")) = "." + __UI_Texts(__UI_GetID("AddProgressBar")) = "." + __UI_Texts(__UI_GetID("AddPictureBox")) = "." + __UI_Texts(__UI_GetID("AddFrame")) = "." + _FREEIMAGE CommControls __UI_ForceRedraw = __UI_True @@ -903,11 +725,40 @@ SUB __UI_OnLoad GreenTrackID = __UI_GetID("Green"): GreenTextBoxID = __UI_GetID("GreenValue") BlueTrackID = __UI_GetID("Blue"): BlueTextBoxID = __UI_GetID("BlueValue") ColorPropertiesListID = __UI_GetID("ColorPropertiesList") + BackStyleListID = __UI_GetID("BackStyleOptions") ColorPreviewID = __UI_GetID("ColorPreview") + PropertyValueID = __UI_GetID("PropertyValue") PreviewAttached = __UI_True IF _FILEEXISTS("UiEditorPreview.frmbin") THEN KILL "UiEditorPreview.frmbin" + + DIM FileToOpen$, FreeFileNum AS INTEGER + IF _FILEEXISTS(COMMAND$) THEN + SELECT CASE LCASE$(RIGHT$(COMMAND$, 4)) + CASE ".bas", ".frm" + IF _FILEEXISTS(LEFT$(COMMAND$, LEN(COMMAND$) - 4) + ".frmbin") THEN + FileToOpen$ = LEFT$(COMMAND$, LEN(COMMAND$) - 4) + ".frmbin" + END IF + CASE ELSE + IF LCASE$(RIGHT$(COMMAND$, 7)) = ".frmbin" THEN + FileToOpen$ = COMMAND$ + END IF + END SELECT + + IF LEN(FileToOpen$) > 0 THEN + FreeFileNum = FREEFILE + OPEN FileToOpen$ FOR BINARY AS #FreeFileNum + b$ = SPACE$(LOF(FreeFileNum)) + GET #FreeFileNum, 1, b$ + CLOSE #FreeFileNum + + OPEN "UiEditorPreview.frmbin" FOR BINARY AS #FreeFileNum + PUT #FreeFileNum, 1, b$ + CLOSE #FreeFileNum + END IF + END IF + IF _FILEEXISTS("UiEditor.dat") THEN KILL "UiEditor.dat" $IF WIN THEN @@ -967,17 +818,15 @@ SUB __UI_KeyPress (id AS LONG) CASE "PROPERTYVALUE" 'Send the preview the new property value DIM FloatValue AS _FLOAT, b$, TempValue AS LONG, i AS LONG - DIM PropertyValueID AS LONG - PropertyValueID = __UI_GetID("PropertyValue") TempValue = __UI_Controls(__UI_GetID("PropertiesList")).Value SELECT CASE TempValue - CASE 1, 2, 3 'Name, caption, text + CASE 1, 2, 3, 9 'Name, caption, text, tooltips b$ = MKL$(LEN(__UI_Texts(PropertyValueID))) + __UI_Texts(PropertyValueID) CASE 4, 5, 6, 7 'Top, left, width, height b$ = MKI$(VAL(__UI_Texts(PropertyValueID))) CASE 8 'Font - CASE 9 'BackStyle + b$ = MKL$(LEN(__UI_Texts(PropertyValueID))) + __UI_Texts(PropertyValueID) CASE 10, 11, 12, 13 'Value, min, max, interval b$ = _MK$(_FLOAT, VAL(__UI_Texts(PropertyValueID))) END SELECT @@ -986,11 +835,15 @@ SUB __UI_KeyPress (id AS LONG) END SUB SUB __UI_ValueChanged (id AS LONG) + DIM b$ SELECT EVERYCASE UCASE$(RTRIM$(__UI_Controls(id).Name)) CASE "ALIGNOPTIONS" - DIM b$ b$ = MKI$(__UI_Controls(__UI_GetID("AlignOptions")).Value - 1) SendData b$, 22 + CASE "BACKSTYLEOPTIONS" + b$ = MKI$(0) + IF __UI_Controls(__UI_GetID("BACKSTYLEOPTIONS")).Value = 2 THEN b$ = MKI$(-1) + SendData b$, 28 CASE "RED" __UI_Texts(RedTextBoxID) = LTRIM$(STR$(__UI_Controls(RedTrackID).Value)) CASE "GREEN" @@ -1005,12 +858,6 @@ SUB __UI_ValueChanged (id AS LONG) END SELECT END SUB -SUB __UI_EndDrag -END SUB - -SUB __UI_EndResize -END SUB - FUNCTION EditorImageData$ (FileName$) DIM A$ @@ -1239,6 +1086,7 @@ SUB LoadPreview REDIM PreviewTips(1 TO CVL(b$)) AS STRING REDIM PreviewFonts(1 TO CVL(b$)) AS STRING REDIM PreviewControls(0 TO CVL(b$)) AS __UI_ControlTYPE + REDIM PreviewParentIDS(0 TO CVL(b$)) AS STRING b$ = SPACE$(2): GET #BinaryFileNum, , b$ IF CVI(b$) <> -1 THEN GOTO LoadError @@ -1260,9 +1108,15 @@ SUB LoadPreview b$ = SPACE$(2): GET #BinaryFileNum, , b$ NewTop = CVI(b$) b$ = SPACE$(2): GET #BinaryFileNum, , b$ - NewParentID = SPACE$(CVI(b$)): GET #BinaryFileNum, , NewParentID + IF CVI(b$) > 0 THEN + NewParentID = SPACE$(CVI(b$)): GET #BinaryFileNum, , NewParentID + ELSE + NewParentID = "" + END IF PreviewControls(Dummy).ID = Dummy + PreviewParentIDS(Dummy) = RTRIM$(NewParentID) + PreviewControls(Dummy).Type = NewType PreviewControls(Dummy).Name = NewName PreviewControls(Dummy).Width = NewWidth PreviewControls(Dummy).Height = NewHeight @@ -1350,6 +1204,9 @@ SUB LoadPreview PreviewControls(Dummy).WordWrap = __UI_True CASE -29 PreviewControls(Dummy).CanResize = __UI_True + CASE -30 + b$ = SPACE$(2): GET #BinaryFileNum, , b$ + PreviewControls(Dummy).HotKeyPosition = CVI(b$) CASE -1 'new control EXIT DO CASE -1024 @@ -1476,3 +1333,576 @@ SUB CheckPreview END IF $END IF END SUB + +SUB SaveForm + DIM BaseOutputFileName AS STRING, BinaryFileNum AS INTEGER + DIM TextFileNum AS INTEGER, Answer AS _BYTE, b$, i AS LONG + DIM a$, FontSetup$, FindSep AS INTEGER, NewFontFile AS STRING + DIM NewFontSize AS INTEGER, Dummy AS LONG + + BaseOutputFileName = RTRIM$(PreviewControls(PreviewFormID).Name) + IF _FILEEXISTS(BaseOutputFileName + ".bas") OR _FILEEXISTS(BaseOutputFileName + ".frmbin") OR _FILEEXISTS(BaseOutputFileName + ".bas") THEN + Answer = __UI_MessageBox("Some files will be overwritten. Proceed?", "", __UI_MsgBox_YesNo + __UI_MsgBox_Question) + IF Answer = __UI_MsgBox_No THEN EXIT SUB + END IF + TextFileNum = FREEFILE + OPEN BaseOutputFileName + ".frm" FOR OUTPUT AS #TextFileNum + IF _FILEEXISTS(BaseOutputFileName + ".frmbin") THEN KILL BaseOutputFileName + ".frmbin" + BinaryFileNum = FREEFILE + OPEN BaseOutputFileName + ".frmbin" FOR BINARY AS #BinaryFileNum + PRINT #TextFileNum, "'InForm - GUI system for QB64 - Beta version 1" + PRINT #TextFileNum, "'Fellippe Heitor, 2016 - fellippe@qb64.org - @fellippeheitor" + PRINT #TextFileNum, "'-----------------------------------------------------------" + PRINT #TextFileNum, "SUB __UI_LoadForm" + PRINT #TextFileNum, + PRINT #TextFileNum, " DIM __UI_NewID AS LONG" + PRINT #TextFileNum, + b$ = "InForm" + CHR$(1) + PUT #BinaryFileNum, 1, b$ + b$ = MKL$(UBOUND(PreviewControls)) + PUT #BinaryFileNum, , b$ + + 'First pass is for the main form and containers (frames and menubars) + 'Second pass is for the rest of controls + DIM ThisPass AS _BYTE + FOR ThisPass = 1 TO 2 + FOR i = 1 TO UBOUND(PreviewControls) + IF PreviewControls(i).ID > 0 AND PreviewControls(i).Type <> __UI_Type_MenuPanel AND PreviewControls(i).Type <> __UI_Type_Font AND LEN(RTRIM$(PreviewControls(i).Name)) > 0 THEN + a$ = " __UI_NewID = __UI_NewControl(" + SELECT CASE PreviewControls(i).Type + CASE __UI_Type_Form: a$ = a$ + "__UI_Type_Form, ": IF ThisPass = 2 THEN GOTO EndOfThisPass + CASE __UI_Type_Frame: a$ = a$ + "__UI_Type_Frame, ": IF ThisPass = 2 THEN GOTO EndOfThisPass + CASE __UI_Type_Button: a$ = a$ + "__UI_Type_Button, ": IF ThisPass = 1 THEN GOTO EndOfThisPass + CASE __UI_Type_Label: a$ = a$ + "__UI_Type_Label, ": IF ThisPass = 1 THEN GOTO EndOfThisPass + CASE __UI_Type_CheckBox: a$ = a$ + "__UI_Type_CheckBox, ": IF ThisPass = 1 THEN GOTO EndOfThisPass + CASE __UI_Type_RadioButton: a$ = a$ + "__UI_Type_RadioButton, ": IF ThisPass = 1 THEN GOTO EndOfThisPass + CASE __UI_Type_TextBox: a$ = a$ + "__UI_Type_TextBox, ": IF ThisPass = 1 THEN GOTO EndOfThisPass + CASE __UI_Type_ProgressBar: a$ = a$ + "__UI_Type_ProgressBar, ": IF ThisPass = 1 THEN GOTO EndOfThisPass + CASE __UI_Type_ListBox: a$ = a$ + "__UI_Type_ListBox, ": IF ThisPass = 1 THEN GOTO EndOfThisPass + CASE __UI_Type_DropdownList: a$ = a$ + "__UI_Type_DropdownList, ": IF ThisPass = 1 THEN GOTO EndOfThisPass + CASE __UI_Type_MenuBar: a$ = a$ + "__UI_Type_MenuBar, ": IF ThisPass = 2 THEN GOTO EndOfThisPass + CASE __UI_Type_MenuItem: a$ = a$ + "__UI_Type_MenuItem, ": IF ThisPass = 1 THEN GOTO EndOfThisPass + CASE __UI_Type_PictureBox: a$ = a$ + "__UI_Type_PictureBox, ": IF ThisPass = 1 THEN GOTO EndOfThisPass + CASE __UI_Type_TrackBar: a$ = a$ + "__UI_Type_TrackBar, ": IF ThisPass = 1 THEN GOTO EndOfThisPass + CASE __UI_Type_ContextMenu: a$ = a$ + "__UI_Type_ContextMenu, ": IF ThisPass = 1 THEN GOTO EndOfThisPass + END SELECT + a$ = a$ + CHR$(34) + RTRIM$(PreviewControls(i).Name) + CHR$(34) + "," + a$ = a$ + STR$(PreviewControls(i).Width) + "," + a$ = a$ + STR$(PreviewControls(i).Height) + "," + a$ = a$ + STR$(PreviewControls(i).Left) + "," + a$ = a$ + STR$(PreviewControls(i).Top) + "," + IF LEN(PreviewParentIDS(i)) > 0 THEN + a$ = a$ + " __UI_GetID(" + CHR$(34) + PreviewParentIDS(i) + CHR$(34) + "))" + ELSE + a$ = a$ + " 0)" + END IF + PRINT #TextFileNum, a$ + b$ = MKI$(-1) + MKL$(0) + MKI$(PreviewControls(i).Type) '-1 indicates a new control + b$ = b$ + MKI$(LEN(RTRIM$(PreviewControls(i).Name))) + b$ = b$ + RTRIM$(PreviewControls(i).Name) + b$ = b$ + MKI$(PreviewControls(i).Width) + MKI$(PreviewControls(i).Height) + MKI$(PreviewControls(i).Left) + MKI$(PreviewControls(i).Top) + MKI$(LEN(PreviewParentIDS(i))) + PreviewParentIDS(i) + PUT #BinaryFileNum, , b$ + + IF LEN(PreviewCaptions(i)) > 0 THEN + IF PreviewControls(i).HotKeyPosition > 0 THEN + a$ = LEFT$(PreviewCaptions(i), PreviewControls(i).HotKeyPosition - 1) + "&" + MID$(PreviewCaptions(i), PreviewControls(i).HotKeyPosition) + ELSE + a$ = PreviewCaptions(i) + END IF + a$ = " __UI_SetCaption " + CHR$(34) + RTRIM$(PreviewControls(i).Name) + CHR$(34) + ", " + __UI_SpecialCharsToCHR$(a$) + b$ = MKI$(-2) + MKL$(LEN(PreviewCaptions(i))) '-2 indicates a caption + PUT #BinaryFileNum, , b$ + PUT #BinaryFileNum, , PreviewCaptions(i) + PRINT #TextFileNum, a$ + END IF + + IF LEN(PreviewTips(i)) > 0 THEN + a$ = " __UI_SetTip " + CHR$(34) + RTRIM$(PreviewControls(i).Name) + CHR$(34) + ", " + __UI_SpecialCharsToCHR$(PreviewTips(i)) + b$ = MKI$(-24) + MKL$(LEN(PreviewTips(i))) '-24 indicates a tip + PUT #BinaryFileNum, , b$ + PUT #BinaryFileNum, , PreviewTips(i) + PRINT #TextFileNum, a$ + END IF + + IF LEN(PreviewTexts(i)) > 0 THEN + SELECT CASE PreviewControls(i).Type + CASE __UI_Type_ListBox, __UI_Type_DropdownList + DIM TempCaption$, TempText$, FindLF&, ThisItem%, ThisItemTop% + DIM LastVisibleItem AS INTEGER + + TempText$ = PreviewTexts(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$ = "" + END IF + a$ = " __UI_AddListBoxItem " + CHR$(34) + RTRIM$(PreviewControls(i).Name) + CHR$(34) + ", " + CHR$(34) + TempCaption$ + CHR$(34) + PRINT #TextFileNum, a$ + LOOP + CASE __UI_Type_PictureBox, __UI_Type_Button + a$ = " __UI_LoadImage __UI_Controls(__UI_NewID), " + CHR$(34) + PreviewTexts(i) + CHR$(34) + PRINT #TextFileNum, a$ + CASE ELSE + a$ = " __UI_SetText " + CHR$(34) + RTRIM$(PreviewControls(i).Name) + CHR$(34) + ", " + __UI_SpecialCharsToCHR$(PreviewCaptions(i)) + PRINT #TextFileNum, a$ + END SELECT + b$ = MKI$(-3) + MKL$(LEN(PreviewTexts(i))) '-3 indicates a text + PUT #BinaryFileNum, , b$ + PUT #BinaryFileNum, , PreviewTexts(i) + END IF + IF PreviewControls(i).TransparentColor > 0 THEN + PRINT #TextFileNum, " __UI_ClearColor __UI_Controls(__UI_NewID).HelperCanvas, " + LTRIM$(STR$(PreviewControls(i).TransparentColor)) + ", -1" + b$ = MKI$(-28) + _MK$(_UNSIGNED LONG, PreviewControls(i).TransparentColor) + PUT #BinaryFileNum, , b$ + END IF + IF PreviewControls(i).Stretch THEN + PRINT #TextFileNum, " __UI_Controls(__UI_NewID).Stretch = __UI_True" + b$ = MKI$(-4) + PUT #BinaryFileNum, , b$ + END IF + 'Fonts + IF LEN(PreviewFonts(i)) > 0 THEN + DIM NewFontParameters AS STRING + FontSetup$ = PreviewFonts(i) + b$ = MKI$(-5) + MKI$(LEN(FontSetup$)) + FontSetup$ + PUT #BinaryFileNum, , b$ + + 'Parse FontSetup$ into Font variables + FindSep = INSTR(FontSetup$, "*") + NewFontFile = LEFT$(FontSetup$, FindSep - 1) + FontSetup$ = MID$(FontSetup$, FindSep + 1) + + FindSep = INSTR(FontSetup$, "*") + NewFontParameters = LEFT$(FontSetup$, FindSep - 1) + FontSetup$ = MID$(FontSetup$, FindSep + 1) + + FontSetup$ = "__UI_Font(" + CHR$(34) + NewFontFile + CHR$(34) + ", " + FontSetup$ + ", " + CHR$(34) + NewFontParameters + CHR$(34) + ")" + PRINT #TextFileNum, " __UI_Controls(__UI_NewID).Font = " + FontSetup$ + END IF + 'Colors are saved only if they differ from the theme's defaults + IF PreviewControls(i).ForeColor > 0 AND PreviewControls(i).ForeColor <> __UI_DefaultColor(PreviewControls(i).Type, 1) THEN + PRINT #TextFileNum, " __UI_Controls(__UI_NewID).ForeColor = _RGB32(" + LTRIM$(STR$(_RED32(PreviewControls(i).ForeColor))) + ", " + LTRIM$(STR$(_GREEN32(PreviewControls(i).ForeColor))) + ", " + LTRIM$(STR$(_BLUE32(PreviewControls(i).ForeColor))) + ")" + b$ = MKI$(-6) + _MK$(_UNSIGNED LONG, PreviewControls(i).ForeColor) + PUT #BinaryFileNum, , b$ + END IF + IF PreviewControls(i).BackColor > 0 AND PreviewControls(i).BackColor <> __UI_DefaultColor(PreviewControls(i).Type, 2) THEN + PRINT #TextFileNum, " __UI_Controls(__UI_NewID).BackColor = _RGB32(" + LTRIM$(STR$(_RED32(PreviewControls(i).BackColor))) + ", " + LTRIM$(STR$(_GREEN32(PreviewControls(i).BackColor))) + ", " + LTRIM$(STR$(_BLUE32(PreviewControls(i).BackColor))) + ")" + b$ = MKI$(-7) + _MK$(_UNSIGNED LONG, PreviewControls(i).BackColor) + PUT #BinaryFileNum, , b$ + END IF + IF PreviewControls(i).SelectedForeColor > 0 AND PreviewControls(i).SelectedForeColor <> __UI_DefaultColor(PreviewControls(i).Type, 3) THEN + PRINT #TextFileNum, " __UI_Controls(__UI_NewID).SelectedForeColor = _RGB32(" + LTRIM$(STR$(_RED32(PreviewControls(i).SelectedForeColor))) + ", " + LTRIM$(STR$(_GREEN32(PreviewControls(i).SelectedForeColor))) + ", " + LTRIM$(STR$(_BLUE32(PreviewControls(i).SelectedForeColor))) + ")" + b$ = MKI$(-8) + _MK$(_UNSIGNED LONG, PreviewControls(i).SelectedForeColor) + PUT #BinaryFileNum, , b$ + END IF + IF PreviewControls(i).SelectedBackColor > 0 AND PreviewControls(i).SelectedBackColor <> __UI_DefaultColor(PreviewControls(i).Type, 4) THEN + PRINT #TextFileNum, " __UI_Controls(__UI_NewID).SelectedBackColor = _RGB32(" + LTRIM$(STR$(_RED32(PreviewControls(i).SelectedBackColor))) + ", " + LTRIM$(STR$(_GREEN32(PreviewControls(i).SelectedBackColor))) + ", " + LTRIM$(STR$(_BLUE32(PreviewControls(i).SelectedBackColor))) + ")" + b$ = MKI$(-9) + _MK$(_UNSIGNED LONG, PreviewControls(i).SelectedBackColor) + PUT #BinaryFileNum, , b$ + END IF + IF PreviewControls(i).BorderColor > 0 AND PreviewControls(i).BorderColor <> __UI_DefaultColor(PreviewControls(i).Type, 5) THEN + PRINT #TextFileNum, " __UI_Controls(__UI_NewID).BorderColor = _RGB32(" + LTRIM$(STR$(_RED32(PreviewControls(i).BorderColor))) + ", " + LTRIM$(STR$(_GREEN32(PreviewControls(i).BorderColor))) + ", " + LTRIM$(STR$(_BLUE32(PreviewControls(i).BorderColor))) + ")" + b$ = MKI$(-10) + _MK$(_UNSIGNED LONG, PreviewControls(i).BorderColor) + PUT #BinaryFileNum, , b$ + END IF + IF PreviewControls(i).BackStyle = __UI_Transparent THEN + PRINT #TextFileNum, " __UI_Controls(__UI_NewID).BackStyle = __UI_Transparent" + b$ = MKI$(-11): PUT #BinaryFileNum, , b$ + END IF + IF PreviewControls(i).HasBorder THEN + PRINT #TextFileNum, " __UI_Controls(__UI_NewID).HasBorder = __UI_True" + b$ = MKI$(-12): PUT #BinaryFileNum, , b$ + END IF + IF PreviewControls(i).Align = __UI_Center THEN + PRINT #TextFileNum, " __UI_Controls(__UI_NewID).Align = __UI_Center" + b$ = MKI$(-13) + _MK$(_BYTE, PreviewControls(i).Align): PUT #BinaryFileNum, , b$ + ELSEIF PreviewControls(i).Align = __UI_Right THEN + PRINT #TextFileNum, " __UI_Controls(__UI_NewID).Align = __UI_Right" + b$ = MKI$(-13) + _MK$(_BYTE, PreviewControls(i).Align): PUT #BinaryFileNum, , b$ + END IF + IF PreviewControls(i).Value <> 0 THEN + PRINT #TextFileNum, " __UI_Controls(__UI_NewID).Value = " + LTRIM$(STR$(PreviewControls(i).Value)) + b$ = MKI$(-14) + _MK$(_FLOAT, PreviewControls(i).Value): PUT #BinaryFileNum, , b$ + END IF + IF PreviewControls(i).Min <> 0 THEN + PRINT #TextFileNum, " __UI_Controls(__UI_NewID).Min = " + LTRIM$(STR$(PreviewControls(i).Min)) + b$ = MKI$(-15) + _MK$(_FLOAT, PreviewControls(i).Min): PUT #BinaryFileNum, , b$ + END IF + IF PreviewControls(i).Max <> 0 THEN + PRINT #TextFileNum, " __UI_Controls(__UI_NewID).Max = " + LTRIM$(STR$(PreviewControls(i).Max)) + b$ = MKI$(-16) + _MK$(_FLOAT, PreviewControls(i).Max): PUT #BinaryFileNum, , b$ + END IF + 'IF PreviewControls(i).HotKey <> 0 THEN + ' PRINT #TextFileNum, " __UI_Controls(__UI_NewID).HotKey = " + LTRIM$(STR$(PreviewControls(i).HotKey)) + ' b$ = MKI$(-17) + MKI$(PreviewControls(i).HotKey): PUT #BinaryFileNum, , b$ + 'END IF + 'IF PreviewControls(i).HotKeyOffset <> 0 THEN + ' PRINT #TextFileNum, " __UI_Controls(__UI_NewID).HotKeyOffset = " + LTRIM$(STR$(PreviewControls(i).HotKeyOffset)) + ' b$ = MKI$(-18) + MKI$(PreviewControls(i).HotKeyOffset): PUT #BinaryFileNum, , b$ + 'END IF + IF PreviewControls(i).ShowPercentage THEN + PRINT #TextFileNum, " __UI_Controls(__UI_NewID).ShowPercentage = __UI_True" + b$ = MKI$(-19): PUT #BinaryFileNum, , b$ + END IF + IF PreviewControls(i).CanHaveFocus THEN + PRINT #TextFileNum, " __UI_Controls(__UI_NewID).CanHaveFocus = __UI_True" + b$ = MKI$(-20): PUT #BinaryFileNum, , b$ + END IF + IF PreviewControls(i).Disabled THEN + PRINT #TextFileNum, " __UI_Controls(__UI_NewID).Disabled = __UI_True" + b$ = MKI$(-21): PUT #BinaryFileNum, , b$ + END IF + IF PreviewControls(i).Hidden THEN + PRINT #TextFileNum, " __UI_Controls(__UI_NewID).Hidden = __UI_True" + b$ = MKI$(-22): PUT #BinaryFileNum, , b$ + END IF + IF PreviewControls(i).CenteredWindow THEN + PRINT #TextFileNum, " __UI_Controls(__UI_NewID).CenteredWindow = __UI_True" + b$ = MKI$(-23): PUT #BinaryFileNum, , b$ + END IF + IF PreviewControls(i).ContextMenuID THEN + PRINT #TextFileNum, " __UI_Controls(__UI_NewID).ContextMenuID = __UI_GetID(" + CHR$(34) + RTRIM$(PreviewControls(PreviewControls(i).ContextMenuID).Name) + CHR$(34) + ")" + b$ = MKI$(-25) + MKI$(LEN(RTRIM$(PreviewControls(PreviewControls(i).ContextMenuID).Name))) + RTRIM$(PreviewControls(PreviewControls(i).ContextMenuID).Name): PUT #BinaryFileNum, , b$ + END IF + IF PreviewControls(i).Interval THEN + PRINT #TextFileNum, " __UI_Controls(__UI_NewID).Interval = " + LTRIM$(STR$(PreviewControls(i).Interval)) + b$ = MKI$(-26) + _MK$(_FLOAT, PreviewControls(i).Interval): PUT #BinaryFileNum, , b$ + END IF + IF PreviewControls(i).WordWrap THEN + PRINT #TextFileNum, " __UI_Controls(__UI_NewID).WordWrap = __UI_True" + b$ = MKI$(-27): PUT #BinaryFileNum, , b$ + END IF + IF PreviewControls(i).CanResize AND PreviewControls(i).Type = __UI_Type_Form THEN + PRINT #TextFileNum, " __UI_Controls(__UI_NewID).CanResize = __UI_True" + b$ = MKI$(-29): PUT #BinaryFileNum, , b$ + END IF + PRINT #TextFileNum, + END IF + EndOfThisPass: + NEXT + NEXT ThisPass + + b$ = MKI$(-1024): PUT #BinaryFileNum, , b$ 'end of file + PRINT #TextFileNum, "END SUB" + CLOSE #TextFileNum, #BinaryFileNum + OPEN BaseOutputFileName + ".bas" FOR OUTPUT AS #TextFileNum + PRINT #TextFileNum, "'This program was generated by" + PRINT #TextFileNum, "'InForm - GUI system for QB64 - Beta version 1" + PRINT #TextFileNum, "'Fellippe Heitor, 2016 - fellippe@qb64.org - @fellippeheitor" + PRINT #TextFileNum, "'-----------------------------------------------------------" + PRINT #TextFileNum, "'$INCLUDE:'InForm.ui'" + PRINT #TextFileNum, "'$INCLUDE:'" + BaseOutputFileName + ".frm'" + PRINT #TextFileNum, "'$INCLUDE:'xp.uitheme'" + PRINT #TextFileNum, + PRINT #TextFileNum, "'Event procedures: ---------------------------------------------------------------" + FOR i = 1 TO 12 + SELECT EVERYCASE i + CASE 1: PRINT #TextFileNum, "SUB __UI_OnLoad" + CASE 2: PRINT #TextFileNum, "SUB __UI_BeforeUpdateDisplay" + CASE 3: PRINT #TextFileNum, "SUB __UI_BeforeUnload" + CASE 4: PRINT #TextFileNum, "SUB __UI_Click (id AS LONG)" + CASE 5: PRINT #TextFileNum, "SUB __UI_MouseEnter (id AS LONG)" + CASE 6: PRINT #TextFileNum, "SUB __UI_MouseLeave (id AS LONG)" + CASE 7: PRINT #TextFileNum, "SUB __UI_FocusIn (id AS LONG)" + CASE 8: PRINT #TextFileNum, "SUB __UI_FocusOut (id AS LONG)" + CASE 9: PRINT #TextFileNum, "SUB __UI_MouseDown (id AS LONG)" + CASE 10: PRINT #TextFileNum, "SUB __UI_MouseUp (id AS LONG)" + CASE 11: PRINT #TextFileNum, "SUB __UI_KeyPress (id AS LONG)" + CASE 12: PRINT #TextFileNum, "SUB __UI_ValueChanged (id AS LONG)" + + CASE 1 TO 3 + PRINT #TextFileNum, + + CASE 4 TO 6, 9, 10 'All controls except for Menu panels, and internal context menus + PRINT #TextFileNum, " SELECT CASE UCASE$(RTRIM$(__UI_Controls(id).Name))" + FOR Dummy = 1 TO UBOUND(PreviewControls) + IF PreviewControls(Dummy).ID > 0 AND PreviewControls(Dummy).Type <> __UI_Type_Font AND PreviewControls(Dummy).Type <> __UI_Type_ContextMenu THEN + PRINT #TextFileNum, " CASE " + CHR$(34) + UCASE$(RTRIM$(PreviewControls(Dummy).Name)) + CHR$(34) + PRINT #TextFileNum, + END IF + NEXT + PRINT #TextFileNum, " END SELECT" + + CASE 7, 8, 11 'Controls that can have focus only + PRINT #TextFileNum, " SELECT CASE UCASE$(RTRIM$(__UI_Controls(id).Name))" + FOR Dummy = 1 TO UBOUND(PreviewControls) + IF PreviewControls(Dummy).ID > 0 AND PreviewControls(Dummy).CanHaveFocus THEN + PRINT #TextFileNum, " CASE " + CHR$(34) + UCASE$(RTRIM$(PreviewControls(Dummy).Name)) + CHR$(34) + PRINT #TextFileNum, + END IF + NEXT + PRINT #TextFileNum, " END SELECT" + + CASE 12 'Dropdown list, List box and Track bar + PRINT #TextFileNum, " SELECT CASE UCASE$(RTRIM$(__UI_Controls(id).Name))" + FOR Dummy = 1 TO UBOUND(PreviewControls) + IF PreviewControls(Dummy).ID > 0 AND (PreviewControls(Dummy).Type = __UI_Type_ListBox OR PreviewControls(Dummy).Type = __UI_Type_DropdownList OR PreviewControls(Dummy).Type = __UI_Type_TrackBar) THEN + PRINT #TextFileNum, " CASE " + CHR$(34) + UCASE$(RTRIM$(PreviewControls(Dummy).Name)) + CHR$(34) + PRINT #TextFileNum, + END IF + NEXT + PRINT #TextFileNum, " END SELECT" + END SELECT + PRINT #TextFileNum, "END SUB" + PRINT #TextFileNum, + NEXT + CLOSE #TextFileNum + Answer = __UI_MessageBox("Exporting successful. Files output:" + CHR$(10) + " " + BaseOutputFileName + ".bas" + CHR$(10) + " " + BaseOutputFileName + ".frm" + CHR$(10) + " " + BaseOutputFileName + ".frmbin" + CHR$(10) + CHR$(10) + "Exit to QB64?", "", __UI_MsgBox_YesNo + __UI_MsgBox_Question) + IF Answer = __UI_MsgBox_No THEN EXIT SUB + $IF WIN THEN + SHELL _DONTWAIT "qb64.exe " + BaseOutputFileName + ".bas" + $ELSE + SHELL _DONTWAIT "./qb64 " + BaseOutputFileName + ".bas" + $END IF + SYSTEM +END SUB + +SUB SaveSelf + DIM b$, i AS LONG, a$, FontSetup$ + OPEN "form.frm" FOR OUTPUT AS #1 + IF _FILEEXISTS("form.frmbin") THEN KILL "form.frmbin" + OPEN "form.frmbin" FOR BINARY AS #2 + PRINT #1, "'UI form, beta version" + PRINT #1, "DIM __UI_NewID AS LONG" + PRINT #1, + b$ = "UI" + PUT #2, 1, b$ + b$ = MKL$(UBOUND(__UI_Controls)) + PUT #2, , b$ + FOR i = 1 TO UBOUND(__UI_Controls) + IF __UI_Controls(i).ID > 0 AND __UI_Controls(i).Type <> __UI_Type_MenuPanel AND __UI_Controls(i).Type <> __UI_Type_Font AND LEN(RTRIM$(__UI_Controls(i).Name)) > 0 THEN + a$ = "__UI_NewID = __UI_NewControl(" + SELECT CASE __UI_Controls(i).Type + CASE __UI_Type_Form: a$ = a$ + "__UI_Type_Form, " + CASE __UI_Type_Frame: a$ = a$ + "__UI_Type_Frame, " + CASE __UI_Type_Button: a$ = a$ + "__UI_Type_Button, " + CASE __UI_Type_Label: a$ = a$ + "__UI_Type_Label, " + CASE __UI_Type_CheckBox: a$ = a$ + "__UI_Type_CheckBox, " + CASE __UI_Type_RadioButton: a$ = a$ + "__UI_Type_RadioButton, " + CASE __UI_Type_TextBox: a$ = a$ + "__UI_Type_TextBox, " + CASE __UI_Type_ProgressBar: a$ = a$ + "__UI_Type_ProgressBar, " + CASE __UI_Type_ListBox: a$ = a$ + "__UI_Type_ListBox, " + CASE __UI_Type_DropdownList: a$ = a$ + "__UI_Type_DropdownList, " + CASE __UI_Type_MenuBar: a$ = a$ + "__UI_Type_MenuBar, " + CASE __UI_Type_MenuItem: a$ = a$ + "__UI_Type_MenuItem, " + CASE __UI_Type_PictureBox: a$ = a$ + "__UI_Type_PictureBox, " + CASE __UI_Type_TrackBar: a$ = a$ + "__UI_Type_TrackBar, " + CASE __UI_Type_ContextMenu: a$ = a$ + "__UI_Type_ContextMenu, " + END SELECT + a$ = a$ + CHR$(34) + RTRIM$(__UI_Controls(i).Name) + CHR$(34) + "," + a$ = a$ + STR$(__UI_Controls(i).Width) + "," + a$ = a$ + STR$(__UI_Controls(i).Height) + "," + a$ = a$ + STR$(__UI_Controls(i).Left) + "," + a$ = a$ + STR$(__UI_Controls(i).Top) + "," + IF __UI_Controls(i).ParentID > 0 THEN + a$ = a$ + " __UI_GetID(" + CHR$(34) + RTRIM$(__UI_Controls(__UI_Controls(i).ParentID).Name) + CHR$(34) + "))" + ELSE + a$ = a$ + "0)" + END IF + PRINT #1, a$ + b$ = MKI$(-1) + MKL$(0) + MKI$(__UI_Controls(i).Type) '-1 indicates a new control + b$ = b$ + MKI$(LEN(RTRIM$(__UI_Controls(i).Name))) + b$ = b$ + RTRIM$(__UI_Controls(i).Name) + b$ = b$ + MKI$(__UI_Controls(i).Width) + MKI$(__UI_Controls(i).Height) + MKI$(__UI_Controls(i).Left) + MKI$(__UI_Controls(i).Top) + MKI$(LEN(RTRIM$(__UI_Controls(__UI_Controls(i).ParentID).Name))) + RTRIM$(__UI_Controls(__UI_Controls(i).ParentID).Name) + PUT #2, , b$ + + IF LEN(__UI_Captions(i)) > 0 THEN + a$ = "__UI_SetCaption " + CHR$(34) + RTRIM$(__UI_Controls(i).Name) + CHR$(34) + ", " + __UI_SpecialCharsToCHR$(__UI_Captions(i)) + b$ = MKI$(-2) + MKL$(LEN(__UI_Captions(i))) '-2 indicates a caption + PUT #2, , b$ + PUT #2, , __UI_Captions(i) + PRINT #1, a$ + END IF + + IF LEN(__UI_Tips(i)) > 0 THEN + a$ = "__UI_SetTip " + CHR$(34) + RTRIM$(__UI_Controls(i).Name) + CHR$(34) + ", " + __UI_SpecialCharsToCHR$(__UI_Tips(i)) + b$ = MKI$(-24) + MKL$(LEN(__UI_Tips(i))) '-24 indicates a tip + PUT #2, , b$ + PUT #2, , __UI_Tips(i) + PRINT #1, a$ + END IF + + IF LEN(__UI_Texts(i)) > 0 THEN + SELECT CASE __UI_Controls(i).Type + CASE __UI_Type_ListBox, __UI_Type_DropdownList + DIM TempCaption$, 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$ = "" + END IF + a$ = "__UI_AddListBoxItem " + CHR$(34) + RTRIM$(__UI_Controls(i).Name) + CHR$(34) + ", " + CHR$(34) + TempCaption$ + CHR$(34) + PRINT #1, a$ + LOOP + CASE __UI_Type_PictureBox, __UI_Type_Button + a$ = "__UI_LoadImage __UI_Controls(__UI_NewID), " + CHR$(34) + __UI_Texts(i) + CHR$(34) + PRINT #1, a$ + CASE ELSE + a$ = "__UI_SetText " + CHR$(34) + RTRIM$(__UI_Controls(i).Name) + CHR$(34) + ", " + __UI_SpecialCharsToCHR$(__UI_Captions(i)) + PRINT #1, a$ + END SELECT + b$ = MKI$(-3) + MKL$(LEN(__UI_Texts(i))) '-3 indicates a text + PUT #2, , b$ + PUT #2, , __UI_Texts(i) + END IF + IF __UI_Controls(i).TransparentColor > 0 THEN + PRINT #1, "__UI_ClearColor __UI_Controls(__UI_NewID).HelperCanvas, " + LTRIM$(STR$(__UI_Controls(i).TransparentColor)) + ", -1" + b$ = MKI$(-28) + _MK$(_UNSIGNED LONG, __UI_Controls(i).TransparentColor) + PUT #2, , b$ + END IF + IF __UI_Controls(i).Stretch THEN + PRINT #1, "__UI_Controls(__UI_NewID).Stretch = __UI_True" + b$ = MKI$(-4) + PUT #2, , b$ + END IF + 'Inheritable properties won't be saved if they are the same as the parent's + IF __UI_Controls(i).Type = __UI_Type_Form THEN + IF __UI_Controls(i).Font = 8 OR __UI_Controls(i).Font = 16 THEN + 'Internal fonts + SaveInternalFont: + FontSetup$ = "__UI_Font(" + CHR$(34) + "VGA Emulated" + CHR$(34) + ", " + CHR$(34) + CHR$(34) + "," + STR$(__UI_Controls(__UI_GetFontID(__UI_Controls(i).Font)).Max) + ", " + CHR$(34) + CHR$(34) + ")" + PRINT #1, "__UI_Controls(__UI_NewID).Font = " + FontSetup$ + FontSetup$ = "**" + LTRIM$(STR$(__UI_Controls(__UI_GetFontID(__UI_Controls(i).Font)).Max)) + b$ = MKI$(-5) + MKI$(LEN(FontSetup$)) + FontSetup$ + PUT #2, , b$ + ELSE + SaveExternalFont: + FontSetup$ = "__UI_Font(" + CHR$(34) + __UI_Texts(__UI_GetFontID(__UI_Controls(i).Font)) + CHR$(34) + "," + STR$(__UI_Controls(__UI_GetFontID(__UI_Controls(i).Font)).Max) + ", " + CHR$(34) + __UI_Captions(__UI_GetFontID(__UI_Controls(i).Font)) + CHR$(34) + ")" + PRINT #1, "__UI_Controls(__UI_NewID).Font = " + FontSetup$ + FontSetup$ = RTRIM$(__UI_Controls(__UI_GetFontID(__UI_Controls(i).Font)).Name) + "\" + __UI_Texts(__UI_GetFontID(__UI_Controls(i).Font)) + "\" + LTRIM$(STR$(__UI_Controls(__UI_GetFontID(__UI_Controls(i).Font)).Max)) + "\" + __UI_Captions(__UI_GetFontID(__UI_Controls(i).Font)) + b$ = MKI$(-5) + MKI$(LEN(FontSetup$)) + FontSetup$ + PUT #2, , b$ + END IF + ELSE + IF __UI_Controls(i).ParentID > 0 THEN + IF __UI_Controls(i).Font > 0 AND __UI_Controls(i).Font <> __UI_Controls(__UI_Controls(i).ParentID).Font THEN + IF __UI_Controls(i).Font = 8 OR __UI_Controls(i).Font = 167 THEN + GOTO SaveInternalFont + ELSE + GOTO SaveExternalFont + END IF + END IF + ELSE + IF __UI_Controls(i).Font > 0 AND __UI_Controls(i).Font <> __UI_Controls(__UI_FormID).Font THEN + IF __UI_Controls(i).Font = 8 OR __UI_Controls(i).Font = 167 THEN + GOTO SaveInternalFont + ELSE + GOTO SaveExternalFont + END IF + END IF + END IF + END IF + 'Colors are saved only if they differ from the theme's defaults + IF __UI_Controls(i).ForeColor <> __UI_DefaultColor(__UI_Controls(i).Type, 1) THEN + PRINT #1, "__UI_Controls(__UI_NewID).ForeColor = _RGB32(" + LTRIM$(STR$(_RED32(__UI_Controls(i).ForeColor))) + ", " + LTRIM$(STR$(_GREEN32(__UI_Controls(i).ForeColor))) + ", " + LTRIM$(STR$(_BLUE32(__UI_Controls(i).ForeColor))) + ")" + b$ = MKI$(-6) + _MK$(_UNSIGNED LONG, __UI_Controls(i).ForeColor) + PUT #2, , b$ + END IF + IF __UI_Controls(i).BackColor <> __UI_DefaultColor(__UI_Controls(i).Type, 2) THEN + PRINT #1, "__UI_Controls(__UI_NewID).BackColor = _RGB32(" + LTRIM$(STR$(_RED32(__UI_Controls(i).BackColor))) + ", " + LTRIM$(STR$(_GREEN32(__UI_Controls(i).BackColor))) + ", " + LTRIM$(STR$(_BLUE32(__UI_Controls(i).BackColor))) + ")" + b$ = MKI$(-7) + _MK$(_UNSIGNED LONG, __UI_Controls(i).BackColor) + PUT #2, , b$ + END IF + IF __UI_Controls(i).SelectedForeColor <> __UI_DefaultColor(__UI_Controls(i).Type, 3) THEN + PRINT #1, "__UI_Controls(__UI_NewID).SelectedForeColor = _RGB32(" + LTRIM$(STR$(_RED32(__UI_Controls(i).SelectedForeColor))) + ", " + LTRIM$(STR$(_GREEN32(__UI_Controls(i).SelectedForeColor))) + ", " + LTRIM$(STR$(_BLUE32(__UI_Controls(i).SelectedForeColor))) + ")" + b$ = MKI$(-8) + _MK$(_UNSIGNED LONG, __UI_Controls(i).SelectedForeColor) + PUT #2, , b$ + END IF + IF __UI_Controls(i).SelectedBackColor <> __UI_DefaultColor(__UI_Controls(i).Type, 4) THEN + PRINT #1, "__UI_Controls(__UI_NewID).SelectedBackColor = _RGB32(" + LTRIM$(STR$(_RED32(__UI_Controls(i).SelectedBackColor))) + ", " + LTRIM$(STR$(_GREEN32(__UI_Controls(i).SelectedBackColor))) + ", " + LTRIM$(STR$(_BLUE32(__UI_Controls(i).SelectedBackColor))) + ")" + b$ = MKI$(-9) + _MK$(_UNSIGNED LONG, __UI_Controls(i).SelectedBackColor) + PUT #2, , b$ + END IF + IF __UI_Controls(i).BorderColor <> __UI_DefaultColor(__UI_Controls(i).Type, 5) THEN + PRINT #1, "__UI_Controls(__UI_NewID).BorderColor = _RGB32(" + LTRIM$(STR$(_RED32(__UI_Controls(i).BorderColor))) + ", " + LTRIM$(STR$(_GREEN32(__UI_Controls(i).BorderColor))) + ", " + LTRIM$(STR$(_BLUE32(__UI_Controls(i).BorderColor))) + ")" + b$ = MKI$(-10) + _MK$(_UNSIGNED LONG, __UI_Controls(i).BorderColor) + PUT #2, , b$ + END IF + IF __UI_Controls(i).BackStyle = __UI_Transparent THEN + PRINT #1, "__UI_Controls(__UI_NewID).BackStyle = __UI_Transparent" + b$ = MKI$(-11): PUT #2, , b$ + END IF + IF __UI_Controls(i).HasBorder THEN + PRINT #1, "__UI_Controls(__UI_NewID).HasBorder = __UI_True" + b$ = MKI$(-12): PUT #2, , b$ + END IF + IF __UI_Controls(i).Align = __UI_Center THEN + PRINT #1, "__UI_Controls(__UI_NewID).Align = __UI_Center" + b$ = MKI$(-13) + _MK$(_BYTE, __UI_Controls(i).Align): PUT #2, , b$ + ELSEIF __UI_Controls(i).Align = __UI_Right THEN + PRINT #1, "__UI_Controls(__UI_NewID).Align = __UI_Right" + b$ = MKI$(-13) + _MK$(_BYTE, __UI_Controls(i).Align): PUT #2, , b$ + END IF + IF __UI_Controls(i).Value <> 0 THEN + PRINT #1, "__UI_Controls(__UI_NewID).Value = " + LTRIM$(STR$(__UI_Controls(i).Value)) + b$ = MKI$(-14) + _MK$(_FLOAT, __UI_Controls(i).Value): PUT #2, , b$ + END IF + IF __UI_Controls(i).Min <> 0 THEN + PRINT #1, "__UI_Controls(__UI_NewID).Min = " + LTRIM$(STR$(__UI_Controls(i).Min)) + b$ = MKI$(-15) + _MK$(_FLOAT, __UI_Controls(i).Min): PUT #2, , b$ + END IF + IF __UI_Controls(i).Max <> 0 THEN + PRINT #1, "__UI_Controls(__UI_NewID).Max = " + LTRIM$(STR$(__UI_Controls(i).Max)) + b$ = MKI$(-16) + _MK$(_FLOAT, __UI_Controls(i).Max): PUT #2, , b$ + END IF + IF __UI_Controls(i).HotKey <> 0 THEN + PRINT #1, "__UI_Controls(__UI_NewID).HotKey = " + LTRIM$(STR$(__UI_Controls(i).HotKey)) + b$ = MKI$(-17) + MKI$(__UI_Controls(i).HotKey): PUT #2, , b$ + END IF + IF __UI_Controls(i).HotKeyOffset <> 0 THEN + PRINT #1, "__UI_Controls(__UI_NewID).HotKeyOffset = " + LTRIM$(STR$(__UI_Controls(i).HotKeyOffset)) + b$ = MKI$(-18) + MKI$(__UI_Controls(i).HotKeyOffset): PUT #2, , b$ + END IF + IF __UI_Controls(i).ShowPercentage THEN + PRINT #1, "__UI_Controls(__UI_NewID).ShowPercentage = __UI_True" + b$ = MKI$(-19): PUT #2, , b$ + END IF + IF __UI_Controls(i).CanHaveFocus THEN + PRINT #1, "__UI_Controls(__UI_NewID).CanHaveFocus = __UI_True" + b$ = MKI$(-20): PUT #2, , b$ + END IF + IF __UI_Controls(i).Disabled THEN + PRINT #1, "__UI_Controls(__UI_NewID).Disabled = __UI_True" + b$ = MKI$(-21): PUT #2, , b$ + END IF + IF __UI_Controls(i).Hidden THEN + PRINT #1, "__UI_Controls(__UI_NewID).Hidden = __UI_True" + b$ = MKI$(-22): PUT #2, , b$ + END IF + IF __UI_Controls(i).CenteredWindow THEN + PRINT #1, "__UI_Controls(__UI_NewID).CenteredWindow = __UI_True" + b$ = MKI$(-23): PUT #2, , b$ + END IF + IF __UI_Controls(i).ContextMenuID THEN + PRINT #1, "__UI_Controls(__UI_NewID).ContextMenuID = __UI_GetID(" + CHR$(34) + RTRIM$(__UI_Controls(__UI_Controls(i).ContextMenuID).Name) + CHR$(34) + ")" + b$ = MKI$(-25) + MKI$(LEN(RTRIM$(__UI_Controls(__UI_Controls(i).ContextMenuID).Name))) + RTRIM$(__UI_Controls(__UI_Controls(i).ContextMenuID).Name): PUT #2, , b$ + END IF + IF __UI_Controls(i).Interval THEN + PRINT #1, "__UI_Controls(__UI_NewID).Interval = " + LTRIM$(STR$(__UI_Controls(i).Interval)) + b$ = MKI$(-26) + _MK$(_FLOAT, __UI_Controls(i).Interval): PUT #2, , b$ + END IF + IF __UI_Controls(i).WordWrap THEN + PRINT #1, "__UI_Controls(__UI_NewID).WordWrap = __UI_True" + b$ = MKI$(-27): PUT #2, , b$ + END IF + PRINT #1, + END IF + NEXT + b$ = MKI$(-1024): PUT #2, , b$ 'end of file + CLOSE #1, #2 +END SUB diff --git a/UiEditor.frm b/UiEditor.frm index fc02460..0cc588d 100644 --- a/UiEditor.frm +++ b/UiEditor.frm @@ -1,42 +1,51 @@ -'InForm - GUI system for QB64 +'InForm - GUI system for QB64 - Beta version 1 'Fellippe Heitor, 2016 - fellippe@qb64.org - @fellippeheitor -'Beta version 1 +'----------------------------------------------------------- SUB __UI_LoadForm + DIM __UI_NewID AS LONG - __UI_NewID = __UI_NewControl(__UI_Type_Form, "Form1", 598, 430, 0, 0, 0) - __UI_SetCaption "Form1", "InForm Designer" - __UI_Controls(__UI_NewID).Font = __UI_Font("Noto Mono", "InForm\NotoMono-Regular.ttf", 12, "MONOSPACE") + __UI_NewID = __UI_NewControl(__UI_Type_Form, "UiEditorForm", 598, 430, 0, 0, 0) + __UI_SetCaption "UiEditorForm", "InForm Designer" + __UI_Controls(__UI_NewID).Font = __UI_Font("InForm\NotoMono-Regular.ttf", 12, "MONOSPACE") - __UI_NewID = __UI_NewControl(__UI_Type_MenuBar, "FileMenu", 56, 18, 14, 0, 0) + __UI_NewID = __UI_NewControl(__UI_Type_MenuBar, "FileMenu", 44, 18, 8, 0, 0) __UI_SetCaption "FileMenu", "&File" - __UI_NewID = __UI_NewControl(__UI_Type_MenuItem, "FileMenuLoad", 140, 18, 0, 4, __UI_GetID("FileMenu")) - __UI_SetCaption "FileMenuLoad", "&Load form.frmbin" - __UI_Controls(__UI_NewID).Disabled = __UI_True + __UI_NewID = __UI_NewControl(__UI_Type_MenuBar, "ViewMenu", 44, 18, 52, 0, 0) + __UI_SetCaption "ViewMenu", "&View" + + __UI_NewID = __UI_NewControl(__UI_Type_MenuBar, "HelpMenu", 44, 18, 545, 0, 0) + __UI_SetCaption "HelpMenu", "&Help" + __UI_Controls(__UI_NewID).Align = __UI_Right + + __UI_NewID = __UI_NewControl(__UI_Type_Frame, "ToolBox", 62, 376, 30, 40, 0) + __UI_Controls(__UI_NewID).HasBorder = __UI_True + + __UI_NewID = __UI_NewControl(__UI_Type_Frame, "PropertiesFrame", 457, 186, 110, 40, 0) + __UI_SetCaption "PropertiesFrame", "Control properties: Main form" + __UI_Controls(__UI_NewID).HasBorder = __UI_True + + __UI_NewID = __UI_NewControl(__UI_Type_Frame, "ColorMixer", 457, 175, 110, 240, 0) + __UI_SetCaption "ColorMixer", "Color mixer" + __UI_Controls(__UI_NewID).HasBorder = __UI_True __UI_NewID = __UI_NewControl(__UI_Type_MenuItem, "FileMenuSave", 91, 18, 0, 22, __UI_GetID("FileMenu")) __UI_SetCaption "FileMenuSave", "&Save form-" - __UI_Controls(__UI_NewID).Disabled = __UI_True - + __UI_LoadImage __UI_Controls(__UI_NewID), "InForm\disk.png" + __UI_NewID = __UI_NewControl(__UI_Type_MenuItem, "FileMenuExit", 56, 18, 0, 40, __UI_GetID("FileMenu")) __UI_SetCaption "FileMenuExit", "E&xit" - __UI_NewID = __UI_NewControl(__UI_Type_MenuBar, "ViewMenu", 56, 18, 14, 0, 0) - __UI_SetCaption "ViewMenu", "&View" + __UI_NewID = __UI_NewControl(__UI_Type_MenuItem, "ViewMenuPreviewDetach", 56, 18, 0, 40, __UI_GetID("ViewMenu")) + __UI_SetCaption "ViewMenuPreviewDetach", "&Keep preview window attached" + __UI_Controls(__UI_NewID).Value = -1 __UI_NewID = __UI_NewControl(__UI_Type_MenuItem, "ViewMenuPreview", 56, 18, 0, 40, __UI_GetID("ViewMenu")) - __UI_SetCaption "ViewMenuPreview", "Open &preview window" + __UI_SetCaption "ViewMenuPreview", "&Open preview window-" - $IF WIN THEN - __UI_NewID = __UI_NewControl(__UI_Type_MenuItem, "ViewMenuPreviewDetach", 56, 18, 0, 40, __UI_GetID("ViewMenu")) - __UI_Controls(__UI_NewID).Value = __UI_True - __UI_SetCaption "ViewMenuPreviewDetach", "&Keep preview window attached" - $END IF - - __UI_NewID = __UI_NewControl(__UI_Type_MenuBar, "HelpMenu", 56, 18, 527, 0, 0) - __UI_SetCaption "HelpMenu", "&Help" - __UI_Controls(__UI_NewID).Align = __UI_Right + __UI_NewID = __UI_NewControl(__UI_Type_MenuItem, "ViewMenuLoadedFonts", 56, 18, 0, 40, __UI_GetID("ViewMenu")) + __UI_SetCaption "ViewMenuLoadedFonts", "&Loaded fonts" __UI_NewID = __UI_NewControl(__UI_Type_MenuItem, "HelpMenuHelp", 0, 0, 0, 0, __UI_GetID("HelpMenu")) __UI_SetCaption "HelpMenuHelp", "&What's all this?" @@ -44,46 +53,39 @@ SUB __UI_LoadForm __UI_NewID = __UI_NewControl(__UI_Type_MenuItem, "HelpMenuAbout", 0, 0, 0, 0, __UI_GetID("HelpMenu")) __UI_SetCaption "HelpMenuAbout", "&About..." - __UI_NewID = __UI_NewControl(__UI_Type_Frame, "ToolBox", 62, 376, 30, 40, 0) - __UI_Controls(__UI_NewID).HasBorder = __UI_True - - __UI_NewID = __UI_NewControl(__UI_Type_Button, "AddButton", 22, 22, 20, 20, __UI_GetID("ToolBox")) + __UI_NewID = __UI_NewControl(__UI_Type_Button, "AddButton", 22, 22, 20, 26, __UI_GetID("ToolBox")) __UI_Controls(__UI_NewID).CanHaveFocus = __UI_True - __UI_NewID = __UI_NewControl(__UI_Type_Button, "AddLabel", 22, 22, 20, 50, __UI_GetID("ToolBox")) + __UI_NewID = __UI_NewControl(__UI_Type_Button, "AddLabel", 22, 22, 20, 56, __UI_GetID("ToolBox")) __UI_Controls(__UI_NewID).CanHaveFocus = __UI_True - __UI_NewID = __UI_NewControl(__UI_Type_Button, "AddTextBox", 22, 22, 20, 80, __UI_GetID("ToolBox")) + __UI_NewID = __UI_NewControl(__UI_Type_Button, "AddTextBox", 22, 22, 20, 86, __UI_GetID("ToolBox")) __UI_Controls(__UI_NewID).CanHaveFocus = __UI_True - __UI_NewID = __UI_NewControl(__UI_Type_Button, "AddCheckBox", 22, 22, 20, 110, __UI_GetID("ToolBox")) + __UI_NewID = __UI_NewControl(__UI_Type_Button, "AddCheckBox", 22, 22, 20, 116, __UI_GetID("ToolBox")) __UI_Controls(__UI_NewID).CanHaveFocus = __UI_True - __UI_NewID = __UI_NewControl(__UI_Type_Button, "AddRadioButton", 22, 22, 20, 140, __UI_GetID("ToolBox")) + __UI_NewID = __UI_NewControl(__UI_Type_Button, "AddRadioButton", 22, 22, 20, 146, __UI_GetID("ToolBox")) __UI_Controls(__UI_NewID).CanHaveFocus = __UI_True - __UI_NewID = __UI_NewControl(__UI_Type_Button, "AddListBox", 22, 22, 20, 170, __UI_GetID("ToolBox")) + __UI_NewID = __UI_NewControl(__UI_Type_Button, "AddListBox", 22, 22, 20, 176, __UI_GetID("ToolBox")) __UI_Controls(__UI_NewID).CanHaveFocus = __UI_True - __UI_NewID = __UI_NewControl(__UI_Type_Button, "AddDropdownList", 22, 22, 20, 200, __UI_GetID("ToolBox")) + __UI_NewID = __UI_NewControl(__UI_Type_Button, "AddDropdownList", 22, 22, 20, 206, __UI_GetID("ToolBox")) __UI_Controls(__UI_NewID).CanHaveFocus = __UI_True - __UI_NewID = __UI_NewControl(__UI_Type_Button, "AddTrackBar", 22, 22, 20, 230, __UI_GetID("ToolBox")) + __UI_NewID = __UI_NewControl(__UI_Type_Button, "AddTrackBar", 22, 22, 20, 236, __UI_GetID("ToolBox")) __UI_Controls(__UI_NewID).CanHaveFocus = __UI_True - __UI_NewID = __UI_NewControl(__UI_Type_Button, "AddProgressBar", 22, 22, 20, 260, __UI_GetID("ToolBox")) + __UI_NewID = __UI_NewControl(__UI_Type_Button, "AddProgressBar", 22, 22, 20, 266, __UI_GetID("ToolBox")) __UI_Controls(__UI_NewID).CanHaveFocus = __UI_True - __UI_NewID = __UI_NewControl(__UI_Type_Button, "AddPictureBox", 22, 22, 20, 290, __UI_GetID("ToolBox")) + __UI_NewID = __UI_NewControl(__UI_Type_Button, "AddPictureBox", 22, 22, 20, 296, __UI_GetID("ToolBox")) __UI_Controls(__UI_NewID).CanHaveFocus = __UI_True - __UI_NewID = __UI_NewControl(__UI_Type_Button, "AddFrame", 22, 22, 20, 320, __UI_GetID("ToolBox")) + __UI_NewID = __UI_NewControl(__UI_Type_Button, "AddFrame", 22, 22, 20, 326, __UI_GetID("ToolBox")) __UI_Controls(__UI_NewID).CanHaveFocus = __UI_True - __UI_NewID = __UI_NewControl(__UI_Type_Frame, "PropertiesFrame", 457, 186, 110, 40, 0) - __UI_SetCaption "PropertiesFrame", "Control properties: Form1" - __UI_Controls(__UI_NewID).HasBorder = __UI_True - __UI_NewID = __UI_NewControl(__UI_Type_DropdownList, "PropertiesList", 174, 23, 20, 20, __UI_GetID("PropertiesFrame")) __UI_AddListBoxItem "PropertiesList", "Name" __UI_AddListBoxItem "PropertiesList", "Caption" @@ -93,71 +95,80 @@ SUB __UI_LoadForm __UI_AddListBoxItem "PropertiesList", "Width" __UI_AddListBoxItem "PropertiesList", "Height" __UI_AddListBoxItem "PropertiesList", "Font" - __UI_AddListBoxItem "PropertiesList", "BackStyle" + __UI_AddListBoxItem "PropertiesList", "Tool tip" __UI_AddListBoxItem "PropertiesList", "Value" __UI_AddListBoxItem "PropertiesList", "Min" __UI_AddListBoxItem "PropertiesList", "Max" __UI_AddListBoxItem "PropertiesList", "Interval" __UI_Controls(__UI_NewID).HasBorder = __UI_True __UI_Controls(__UI_NewID).Value = 1 + __UI_Controls(__UI_NewID).Max = 13 __UI_Controls(__UI_NewID).CanHaveFocus = __UI_True __UI_NewID = __UI_NewControl(__UI_Type_TextBox, "PropertyValue", 250, 23, 200, 20, __UI_GetID("PropertiesFrame")) __UI_Controls(__UI_NewID).HasBorder = __UI_True __UI_Controls(__UI_NewID).CanHaveFocus = __UI_True - __UI_NewID = __UI_NewControl(__UI_Type_CheckBox, "Stretch", 150, 17, 70, 59, __UI_GetID("PropertiesFrame")) + __UI_NewID = __UI_NewControl(__UI_Type_CheckBox, "Stretch", 150, 17, 22, 59, __UI_GetID("PropertiesFrame")) __UI_SetCaption "Stretch", "Stretch" __UI_Controls(__UI_NewID).CanHaveFocus = __UI_True - __UI_NewID = __UI_NewControl(__UI_Type_CheckBox, "HasBorder", 150, 17, 70, 79, __UI_GetID("PropertiesFrame")) + __UI_NewID = __UI_NewControl(__UI_Type_CheckBox, "HasBorder", 150, 17, 22, 79, __UI_GetID("PropertiesFrame")) __UI_SetCaption "HasBorder", "Has border" - __UI_Controls(__UI_NewID).Value = -1 __UI_Controls(__UI_NewID).CanHaveFocus = __UI_True - __UI_NewID = __UI_NewControl(__UI_Type_CheckBox, "ShowPercentage", 149, 17, 70, 99, __UI_GetID("PropertiesFrame")) + __UI_NewID = __UI_NewControl(__UI_Type_CheckBox, "ShowPercentage", 149, 17, 22, 99, __UI_GetID("PropertiesFrame")) __UI_SetCaption "ShowPercentage", "Show percentage" __UI_Controls(__UI_NewID).CanHaveFocus = __UI_True - __UI_NewID = __UI_NewControl(__UI_Type_CheckBox, "WordWrap", 150, 17, 70, 119, __UI_GetID("PropertiesFrame")) + __UI_NewID = __UI_NewControl(__UI_Type_CheckBox, "WordWrap", 150, 17, 22, 119, __UI_GetID("PropertiesFrame")) __UI_SetCaption "WordWrap", "Word wrap" __UI_Controls(__UI_NewID).CanHaveFocus = __UI_True - __UI_NewID = __UI_NewControl(__UI_Type_CheckBox, "CanHaveFocus", 150, 17, 230, 59, __UI_GetID("PropertiesFrame")) + __UI_NewID = __UI_NewControl(__UI_Type_CheckBox, "CanHaveFocus", 150, 17, 182, 59, __UI_GetID("PropertiesFrame")) __UI_SetCaption "CanHaveFocus", "Can have focus" - __UI_Controls(__UI_NewID).Value = -1 __UI_Controls(__UI_NewID).CanHaveFocus = __UI_True - __UI_NewID = __UI_NewControl(__UI_Type_CheckBox, "Disabled", 150, 17, 230, 79, __UI_GetID("PropertiesFrame")) + __UI_NewID = __UI_NewControl(__UI_Type_CheckBox, "Disabled", 150, 17, 182, 79, __UI_GetID("PropertiesFrame")) __UI_SetCaption "Disabled", "Disabled" - __UI_Controls(__UI_NewID).Value = -1 __UI_Controls(__UI_NewID).CanHaveFocus = __UI_True - __UI_NewID = __UI_NewControl(__UI_Type_CheckBox, "Hidden", 150, 17, 230, 99, __UI_GetID("PropertiesFrame")) + __UI_NewID = __UI_NewControl(__UI_Type_CheckBox, "Hidden", 150, 17, 182, 99, __UI_GetID("PropertiesFrame")) __UI_SetCaption "Hidden", "Hidden" - __UI_Controls(__UI_NewID).Value = -1 __UI_Controls(__UI_NewID).CanHaveFocus = __UI_True - __UI_NewID = __UI_NewControl(__UI_Type_CheckBox, "CenteredWindow", 150, 17, 230, 119, __UI_GetID("PropertiesFrame")) + __UI_NewID = __UI_NewControl(__UI_Type_CheckBox, "CenteredWindow", 150, 17, 182, 119, __UI_GetID("PropertiesFrame")) __UI_SetCaption "CenteredWindow", "Centered window" - __UI_Controls(__UI_NewID).Value = -1 __UI_Controls(__UI_NewID).CanHaveFocus = __UI_True - __UI_NewID = __UI_NewControl(__UI_Type_Label, "Label1", 83, 20, 70, 150, __UI_GetID("PropertiesFrame")) + __UI_NewID = __UI_NewControl(__UI_Type_CheckBox, "Resizable", 102, 17, 339, 59, __UI_GetID("PropertiesFrame")) + __UI_SetCaption "Resizable", "Resizable" + __UI_Controls(__UI_NewID).CanHaveFocus = __UI_True + + __UI_NewID = __UI_NewControl(__UI_Type_Label, "Label1", 83, 20, 24, 151, __UI_GetID("PropertiesFrame")) __UI_SetCaption "Label1", "Text align:" - __UI_NewID = __UI_NewControl(__UI_Type_DropdownList, "AlignOptions", 155, 20, 160, 150, __UI_GetID("PropertiesFrame")) + __UI_NewID = __UI_NewControl(__UI_Type_DropdownList, "AlignOptions", 104, 20, 109, 151, __UI_GetID("PropertiesFrame")) __UI_SetCaption "AlignOptions", "Left" __UI_AddListBoxItem "AlignOptions", "Left" __UI_AddListBoxItem "AlignOptions", "Center" __UI_AddListBoxItem "AlignOptions", "Right" __UI_Controls(__UI_NewID).HasBorder = __UI_True __UI_Controls(__UI_NewID).Value = 1 + __UI_Controls(__UI_NewID).Max = 3 __UI_Controls(__UI_NewID).CanHaveFocus = __UI_True - __UI_NewID = __UI_NewControl(__UI_Type_Frame, "ColorMixer", 457, 175, 110, 240, 0) - __UI_SetCaption "ColorMixer", "Color mixer" + __UI_NewID = __UI_NewControl(__UI_Type_Label, "Label2", 83, 20, 225, 151, __UI_GetID("PropertiesFrame")) + __UI_SetCaption "Label2", "Back style:" + + __UI_NewID = __UI_NewControl(__UI_Type_DropdownList, "BackStyleOptions", 134, 20, 311, 151, __UI_GetID("PropertiesFrame")) + __UI_SetCaption "BackStyleOptions", "Left" + __UI_AddListBoxItem "BackStyleOptions", "Opaque" + __UI_AddListBoxItem "BackStyleOptions", "Transparent" __UI_Controls(__UI_NewID).HasBorder = __UI_True + __UI_Controls(__UI_NewID).Value = 1 + __UI_Controls(__UI_NewID).Max = 2 + __UI_Controls(__UI_NewID).CanHaveFocus = __UI_True __UI_NewID = __UI_NewControl(__UI_Type_DropdownList, "ColorPropertiesList", 161, 21, 10, 20, __UI_GetID("ColorMixer")) __UI_AddListBoxItem "ColorPropertiesList", "ForeColor" @@ -167,6 +178,7 @@ SUB __UI_LoadForm __UI_AddListBoxItem "ColorPropertiesList", "BorderColor" __UI_Controls(__UI_NewID).HasBorder = __UI_True __UI_Controls(__UI_NewID).Value = 1 + __UI_Controls(__UI_NewID).Max = 5 __UI_Controls(__UI_NewID).CanHaveFocus = __UI_True __UI_NewID = __UI_NewControl(__UI_Type_PictureBox, "ColorPreview", 159, 115, 10, 51, __UI_GetID("ColorMixer")) @@ -201,4 +213,5 @@ SUB __UI_LoadForm __UI_Controls(__UI_NewID).BorderColor = _RGB32(0, 0, 255) __UI_Controls(__UI_NewID).HasBorder = __UI_True __UI_Controls(__UI_NewID).CanHaveFocus = __UI_True + END SUB diff --git a/UiEditorPreview.bas b/UiEditorPreview.bas index 56350a8..d425476 100644 --- a/UiEditorPreview.bas +++ b/UiEditorPreview.bas @@ -41,12 +41,6 @@ SUB __UI_Click (id AS LONG) SendData b$, OffsetNewDataFromPreview END SUB -SUB __UI_EndDrag -END SUB - -SUB __UI_EndResize -END SUB - SUB __UI_MouseEnter (id AS LONG) DIM b$ b$ = MKI$(-1) @@ -84,11 +78,6 @@ SUB __UI_BeforeUpdateDisplay b$ = MKL$(UiPreviewPID) SendData b$, OffsetPreviewPID - IF __UI_ControlOperation THEN - __UI_ControlOperation = __UI_False - b$ = MKI$(-1): SendData b$, OffsetNewDataFromPreview - END IF - UiEditorFile = FREEFILE OPEN "UiEditor.dat" FOR BINARY AS #UiEditorFile @@ -150,7 +139,7 @@ SUB __UI_BeforeUpdateDisplay __UI_SetCaption __UI_Controls(TempValue).Name, RTRIM$(__UI_Controls(TempValue).Name) CASE __UI_Type_TextBox TempValue = __UI_NewControl(__UI_Type_TextBox, "", 120, 23, TempWidth \ 2 - 60, TempHeight \ 2 - 12, ThisContainer) - IF _FONTWIDTH(__UI_Controls(TempValue).Font) = 0 THEN __UI_Controls(TempValue).Font = __UI_Font("VGA Emulated", "", 16, "") + IF _FONTWIDTH(__UI_Controls(TempValue).Font) = 0 THEN __UI_Controls(TempValue).Font = __UI_Font("", 16, "") __UI_Controls(TempValue).FieldArea = __UI_Controls(TempValue).Width \ _FONTWIDTH(__UI_Controls(TempValue).Font) - 1 __UI_SetCaption __UI_Controls(TempValue).Name, RTRIM$(__UI_Controls(TempValue).Name) CASE __UI_Type_ListBox @@ -162,7 +151,7 @@ SUB __UI_BeforeUpdateDisplay TempValue = __UI_NewControl(__UI_Type_TrackBar, "", 300, 45, TempWidth \ 2 - 150, TempHeight \ 2 - 23, ThisContainer) CASE __UI_Type_ProgressBar TempValue = __UI_NewControl(__UI_Type_ProgressBar, "", 300, 23, TempWidth \ 2 - 150, TempHeight \ 2 - 12, ThisContainer) - CASE __UI_Type_PictureBox, __UI_Type_Frame + CASE __UI_Type_PictureBox TempValue = __UI_NewControl(TempValue, "", 230, 150, TempWidth \ 2 - 115, TempHeight \ 2 - 75, ThisContainer) CASE __UI_Type_Frame TempValue = __UI_NewControl(TempValue, "", 230, 150, TempWidth \ 2 - 115, TempHeight \ 2 - 75, 0) @@ -187,10 +176,18 @@ SUB __UI_BeforeUpdateDisplay TempValue = CVI(b$) SELECT CASE TempValue CASE 1 'Name + b$ = SPACE$(4): GET #UiEditorFile, OffsetPropertyValue, b$ + b$ = SPACE$(CVL(b$)): GET #UiEditorFile, , b$ + IF __UI_GetID(b$) > 0 THEN + DO + b$ = b$ + "_" + IF __UI_GetID(b$) = 0 THEN EXIT DO + LOOP + END IF IF __UI_TotalSelectedControls = 1 THEN - b$ = SPACE$(4): GET #UiEditorFile, OffsetPropertyValue, b$ - b$ = SPACE$(CVL(b$)): GET #UiEditorFile, , b$ __UI_Controls(__UI_FirstSelectedID).Name = b$ + ELSE + __UI_Controls(__UI_FormID).Name = b$ END IF CASE 2 'Caption b$ = SPACE$(4): GET #UiEditorFile, OffsetPropertyValue, b$ @@ -198,7 +195,7 @@ SUB __UI_BeforeUpdateDisplay IF __UI_TotalSelectedControls > 0 THEN FOR i = 1 TO UBOUND(__UI_Controls) IF __UI_Controls(i).ControlIsSelected THEN - __UI_Captions(i) = b$ + __UI_SetCaption RTRIM$(__UI_Controls(i).Name), b$ END IF NEXT ELSE @@ -210,6 +207,9 @@ SUB __UI_BeforeUpdateDisplay FOR i = 1 TO UBOUND(__UI_Controls) IF __UI_Controls(i).ControlIsSelected THEN __UI_Texts(i) = b$ + IF __UI_Controls(i).Type = __UI_Type_Button OR __UI_Controls(i).Type = __UI_Type_PictureBox THEN + __UI_LoadImage __UI_Controls(i), b$ + END IF END IF NEXT CASE 4 'Top @@ -257,7 +257,44 @@ SUB __UI_BeforeUpdateDisplay __UI_Controls(__UI_FormID).Height = TempValue END IF CASE 8 'Font - CASE 9 'BackStyle + b$ = SPACE$(4): GET #UiEditorFile, OffsetPropertyValue, b$ + b$ = SPACE$(CVL(b$)): GET #UiEditorFile, , b$ + DIM NewFontFile AS STRING + DIM NewFontSize AS INTEGER, NewFontParameters AS STRING + DIM FindSep AS INTEGER, TotalSep AS INTEGER + + 'Parse b$ into Font data + FindSep = INSTR(b$, "*") + IF FindSep THEN TotalSep = TotalSep + 1 + NewFontFile = LEFT$(b$, FindSep - 1) + b$ = MID$(b$, FindSep + 1) + + FindSep = INSTR(b$, "*") + IF FindSep THEN TotalSep = TotalSep + 1 + NewFontParameters = LEFT$(b$, FindSep - 1) + b$ = MID$(b$, FindSep + 1) + + NewFontSize = VAL(b$) + + IF TotalSep = 2 AND NewFontSize > 0 THEN + IF __UI_TotalSelectedControls > 0 THEN + FOR i = 1 TO UBOUND(__UI_Controls) + IF __UI_Controls(i).ControlIsSelected THEN + __UI_Controls(i).Font = __UI_Font(NewFontFile, NewFontSize, NewFontParameters) + END IF + NEXT + ELSE + __UI_Controls(__UI_FormID).Font = __UI_Font(NewFontFile, NewFontSize, NewFontParameters) + END IF + END IF + CASE 9 'Tooltip + b$ = SPACE$(4): GET #UiEditorFile, OffsetPropertyValue, b$ + b$ = SPACE$(CVL(b$)): GET #UiEditorFile, , b$ + FOR i = 1 TO UBOUND(__UI_Controls) + IF __UI_Controls(i).ControlIsSelected THEN + __UI_Tips(i) = b$ + END IF + NEXT CASE 10 'Value b$ = SPACE$(LEN(FloatValue)): GET #UiEditorFile, OffsetPropertyValue, b$ FOR i = 1 TO UBOUND(__UI_Controls) @@ -337,6 +374,7 @@ SUB __UI_BeforeUpdateDisplay NEXT CASE 21 'CenteredWindow b$ = SPACE$(2): GET #UiEditorFile, OffsetPropertyValue, b$ + TempValue = CVI(b$) IF __UI_TotalSelectedControls = 0 THEN __UI_Controls(__UI_FormID).CenteredWindow = TempValue END IF @@ -402,6 +440,19 @@ SUB __UI_BeforeUpdateDisplay ELSE __UI_Controls(__UI_FormID).BorderColor = _CV(_UNSIGNED LONG, b$) END IF + CASE 28 'BackStyle + b$ = SPACE$(2): GET #UiEditorFile, OffsetPropertyValue, b$ + FOR i = 1 TO UBOUND(__UI_Controls) + IF __UI_Controls(i).ControlIsSelected THEN + __UI_Controls(i).BackStyle = CVI(b$) + END IF + NEXT + CASE 29 'CanResize + b$ = SPACE$(2): GET #UiEditorFile, OffsetPropertyValue, b$ + TempValue = CVI(b$) + IF __UI_TotalSelectedControls = 0 THEN + __UI_Controls(__UI_FormID).CanResize = TempValue + END IF END SELECT __UI_ForceRedraw = __UI_True END IF @@ -473,7 +524,7 @@ SUB LoadPreview IF LogFileLoad THEN PRINT #LogFileNum, "DESTROYED CONTROLS" b$ = SPACE$(4): GET #BinaryFileNum, , b$ - IF LogFileLoad THEN PRINT #LogFileNum, "READ NEW ARRAYS:" + STR$(CVI(b$)) + IF LogFileLoad THEN PRINT #LogFileNum, "READ NEW ARRAYS:" + STR$(CVL(b$)) REDIM _PRESERVE __UI_Captions(1 TO CVL(b$)) AS STRING REDIM _PRESERVE __UI_TempCaptions(1 TO CVL(b$)) AS STRING @@ -528,7 +579,7 @@ SUB LoadPreview b$ = SPACE$(4): GET #BinaryFileNum, , b$ b$ = SPACE$(CVL(b$)) GET #BinaryFileNum, , b$ - __UI_Captions(TempValue) = b$ + __UI_SetCaption RTRIM$(__UI_Controls(TempValue).Name), b$ IF LogFileLoad THEN PRINT #LogFileNum, "CAPTION:" + __UI_Captions(TempValue) CASE -3 'Text b$ = SPACE$(4): GET #BinaryFileNum, , b$ @@ -551,18 +602,15 @@ SUB LoadPreview FontSetup$ = SPACE$(CVI(b$)): GET #BinaryFileNum, , FontSetup$ IF LogFileLoad THEN PRINT #LogFileNum, FontSetup$ - FindSep = INSTR(FontSetup$, "\") - NewFontName = LEFT$(FontSetup$, FindSep - 1): FontSetup$ = MID$(FontSetup$, FindSep + 1) - - FindSep = INSTR(FontSetup$, "\") + FindSep = INSTR(FontSetup$, "*") NewFontFile = LEFT$(FontSetup$, FindSep - 1): FontSetup$ = MID$(FontSetup$, FindSep + 1) - FindSep = INSTR(FontSetup$, "\") - NewFontSize = VAL(LEFT$(FontSetup$, FindSep - 1)): FontSetup$ = MID$(FontSetup$, FindSep + 1) + FindSep = INSTR(FontSetup$, "*") + NewFontAttributes = LEFT$(FontSetup$, FindSep - 1): FontSetup$ = MID$(FontSetup$, FindSep + 1) - NewFontAttributes = FontSetup$ + NewFontSize = VAL(FontSetup$) - __UI_Controls(TempValue).Font = __UI_Font(NewFontName, NewFontFile, NewFontSize, NewFontAttributes) + __UI_Controls(TempValue).Font = __UI_Font(NewFontFile, NewFontSize, NewFontAttributes) CASE -6 'ForeColor b$ = SPACE$(4): GET #BinaryFileNum, , b$ __UI_Controls(TempValue).ForeColor = _CV(_UNSIGNED LONG, b$) @@ -707,13 +755,23 @@ SUB SavePreview b$ = MKI$(-1) + MKL$(i) + MKI$(__UI_Controls(i).Type) '-1 indicates a new control b$ = b$ + MKI$(LEN(RTRIM$(__UI_Controls(i).Name))) b$ = b$ + RTRIM$(__UI_Controls(i).Name) - b$ = b$ + MKI$(__UI_Controls(i).Width) + MKI$(__UI_Controls(i).Height) + MKI$(__UI_Controls(i).Left) + MKI$(__UI_Controls(i).Top) + MKI$(LEN(RTRIM$(__UI_Controls(__UI_Controls(i).ParentID).Name))) + RTRIM$(__UI_Controls(__UI_Controls(i).ParentID).Name) + b$ = b$ + MKI$(__UI_Controls(i).Width) + MKI$(__UI_Controls(i).Height) + MKI$(__UI_Controls(i).Left) + MKI$(__UI_Controls(i).Top) + IF __UI_Controls(i).ParentID > 0 THEN + b$ = b$ + MKI$(LEN(RTRIM$(__UI_Controls(__UI_Controls(i).ParentID).Name))) + RTRIM$(__UI_Controls(__UI_Controls(i).ParentID).Name) + ELSE + b$ = b$ + MKI$(0) + END IF PUT #BinFileNum, , b$ IF LEN(__UI_Captions(i)) > 0 THEN - b$ = MKI$(-2) + MKL$(LEN(__UI_Captions(i))) '-2 indicates a caption + IF __UI_Controls(i).HotKeyPosition > 0 THEN + a$ = LEFT$(__UI_Captions(i), __UI_Controls(i).HotKeyPosition - 1) + "&" + MID$(__UI_Captions(i), __UI_Controls(i).HotKeyPosition) + ELSE + a$ = __UI_Captions(i) + END IF + b$ = MKI$(-2) + MKL$(LEN(a$)) '-2 indicates a caption PUT #BinFileNum, , b$ - PUT #BinFileNum, , __UI_Captions(i) + PUT #BinFileNum, , a$ END IF IF LEN(__UI_Tips(i)) > 0 THEN @@ -740,12 +798,12 @@ SUB SavePreview IF __UI_Controls(i).Font = 8 OR __UI_Controls(i).Font = 16 THEN 'Internal fonts SaveInternalFont: - FontSetup$ = "VGA Emulated\\" + LTRIM$(STR$(__UI_Controls(__UI_GetFontID(__UI_Controls(i).Font)).Max)) + "\" + FontSetup$ = "**" + LTRIM$(STR$(__UI_Controls(__UI_GetFontID(__UI_Controls(i).Font)).Max)) b$ = MKI$(-5) + MKI$(LEN(FontSetup$)) + FontSetup$ PUT #BinFileNum, , b$ ELSE SaveExternalFont: - FontSetup$ = RTRIM$(__UI_Controls(__UI_GetFontID(__UI_Controls(i).Font)).Name) + "\" + __UI_Texts(__UI_GetFontID(__UI_Controls(i).Font)) + "\" + LTRIM$(STR$(__UI_Controls(__UI_GetFontID(__UI_Controls(i).Font)).Max)) + "\" + __UI_Captions(__UI_GetFontID(__UI_Controls(i).Font)) + FontSetup$ = __UI_Texts(__UI_GetFontID(__UI_Controls(i).Font)) + "*" + __UI_Captions(__UI_GetFontID(__UI_Controls(i).Font)) + "*" + LTRIM$(STR$(__UI_Controls(__UI_GetFontID(__UI_Controls(i).Font)).Max)) b$ = MKI$(-5) + MKI$(LEN(FontSetup$)) + FontSetup$ PUT #BinFileNum, , b$ END IF @@ -809,12 +867,12 @@ SUB SavePreview IF __UI_Controls(i).Max <> 0 THEN b$ = MKI$(-16) + _MK$(_FLOAT, __UI_Controls(i).Max): PUT #BinFileNum, , b$ END IF - IF __UI_Controls(i).HotKey <> 0 THEN - b$ = MKI$(-17) + MKI$(__UI_Controls(i).HotKey): PUT #BinFileNum, , b$ - END IF - IF __UI_Controls(i).HotKeyOffset <> 0 THEN - b$ = MKI$(-18) + MKI$(__UI_Controls(i).HotKeyOffset): PUT #BinFileNum, , b$ - END IF + 'IF __UI_Controls(i).HotKey <> 0 THEN + ' b$ = MKI$(-17) + MKI$(__UI_Controls(i).HotKey): PUT #BinFileNum, , b$ + 'END IF + 'IF __UI_Controls(i).HotKeyOffset <> 0 THEN + ' b$ = MKI$(-18) + MKI$(__UI_Controls(i).HotKeyOffset): PUT #BinFileNum, , b$ + 'END IF IF __UI_Controls(i).ShowPercentage THEN b$ = MKI$(-19): PUT #BinFileNum, , b$ END IF @@ -842,6 +900,9 @@ SUB SavePreview IF __UI_Controls(i).CanResize AND __UI_Controls(i).Type = __UI_Type_Form THEN b$ = MKI$(-29): PUT #BinFileNum, , b$ END IF + IF __UI_Controls(i).HotKey > 0 THEN + b$ = MKI$(-30) + MKI$(__UI_Controls(i).HotKeyPosition): PUT #BinFileNum, , b$ + END IF END IF NEXT b$ = MKI$(-1024): PUT #BinFileNum, , b$ 'end of file diff --git a/xp.uitheme b/xp.uitheme index e6a160e..e2120d0 100644 --- a/xp.uitheme +++ b/xp.uitheme @@ -9,6 +9,8 @@ SUB __UI_ThemeSetup 'Metrics __UI_ScrollbarWidth = 17 __UI_ScrollbarButtonHeight = 17 + __UI_MenuBarOffset = 8 + __UI_MenuItemOffset = 22 END SUB '--------------------------------------------------------------------------------- @@ -91,7 +93,7 @@ SUB __UI_DrawButton (This AS __UI_ControlTYPE, ControlState AS _BYTE) 'Does this button have a helper canvas (icon)? DIM IconRatio AS INTEGER, IconWidth AS INTEGER, IconHeight AS INTEGER - IF This.HelperCanvas < -1 THEN + IF This.HelperCanvas < -1 AND LEN(__UI_Texts(This.ID)) > 0 THEN IF LEN(TempCaption$) THEN 'Icon will be to the left of caption IconHeight = This.Height - 6 @@ -131,7 +133,7 @@ SUB __UI_DrawButton (This AS __UI_ControlTYPE, ControlState AS _BYTE) _PRINTSTRING ((IconWidth / 2) + (This.Width \ 2 - _PRINTWIDTH(TempCaption$) \ 2), ((This.Height \ 2) - _FONTHEIGHT \ 2) + 2), TempCaption$ 'Hot key: - IF This.HotKey > 0 AND __UI_ShowHotKeys AND NOT This.Disabled THEN + IF This.HotKey > 0 AND ((__UI_ShowHotKeys AND NOT This.Disabled) OR __UI_DesignMode) THEN LINE ((This.Width \ 2 - _PRINTWIDTH(TempCaption$) \ 2) + This.HotKeyOffset, ((This.Height \ 2) + _FONTHEIGHT \ 2) + 1)-STEP(_PRINTWIDTH(CHR$(This.HotKey)) - 1, 0), This.ForeColor END IF @@ -222,7 +224,7 @@ SUB __UI_DrawLabel (This AS __UI_ControlTYPE, ControlState AS _BYTE) LOOP 'Hot key: - IF This.HotKey > 0 AND __UI_ShowHotKeys AND NOT This.Disabled THEN + IF This.HotKey > 0 AND ((__UI_ShowHotKeys AND NOT This.Disabled) OR __UI_DesignMode) THEN LINE (CaptionLeftFirstLine + This.HotKeyOffset, CaptionIndent + _FONTHEIGHT + 2)-STEP(_PRINTWIDTH(CHR$(This.HotKey)) - 1, 0), This.ForeColor END IF ELSE @@ -240,7 +242,7 @@ SUB __UI_DrawLabel (This AS __UI_ControlTYPE, ControlState AS _BYTE) _PRINTSTRING (CaptionLeft, ((This.Height \ 2) - _FONTHEIGHT \ 2)), TempCaption$ 'Hot key: - IF This.HotKey > 0 AND __UI_ShowHotKeys AND NOT This.Disabled THEN + IF This.HotKey > 0 AND ((__UI_ShowHotKeys AND NOT This.Disabled) OR __UI_DesignMode) THEN LINE (CaptionLeftFirstLine + This.HotKeyOffset, ((This.Height \ 2) + (_FONTHEIGHT \ 2)))-STEP(_PRINTWIDTH(CHR$(This.HotKey)) - 1, 0), This.ForeColor END IF END IF @@ -319,7 +321,7 @@ SUB __UI_DrawRadioButton (This AS __UI_ControlTYPE, ControlState AS _BYTE) _PRINTSTRING (CaptionIndent, ((This.Height \ 2) - _FONTHEIGHT \ 2) + 1), TempCaption$ 'Hot key: - IF This.HotKey > 0 AND __UI_ShowHotKeys AND NOT This.Disabled THEN + IF This.HotKey > 0 AND ((__UI_ShowHotKeys AND NOT This.Disabled) OR __UI_DesignMode) THEN LINE (CaptionIndent + This.HotKeyOffset, ((This.Height \ 2) + _FONTHEIGHT \ 2))-STEP(_PRINTWIDTH(CHR$(This.HotKey)) - 1, 0), This.ForeColor END IF @@ -397,7 +399,7 @@ SUB __UI_DrawCheckBox (This AS __UI_ControlTYPE, ControlState AS _BYTE) _PRINTSTRING (CaptionIndent, ((This.Height \ 2) - _FONTHEIGHT \ 2) + 1), TempCaption$ 'Hot key: - IF This.HotKey > 0 AND __UI_ShowHotKeys AND NOT This.Disabled THEN + IF This.HotKey > 0 AND ((__UI_ShowHotKeys AND NOT This.Disabled) OR __UI_DesignMode) THEN LINE (CaptionIndent + This.HotKeyOffset, ((This.Height \ 2) + _FONTHEIGHT \ 2))-STEP(_PRINTWIDTH(CHR$(This.HotKey)) - 1, 0), This.ForeColor END IF @@ -591,9 +593,11 @@ SUB __UI_DrawTextBox (This AS __UI_ControlTYPE, ControlState, ss1 AS LONG, ss2 A IF This.Type = __UI_Type_TextBox THEN 'Make sure textboxes have fixed width fonts and a proper FieldArea property IF _FONTWIDTH((This.Font)) = 0 THEN - This.Font = __UI_Font(RTRIM$(__UI_Controls(__UI_GetFontID(This.Font)).Name), __UI_Texts(__UI_GetFontID(This.Font)), __UI_Controls(__UI_GetFontID(This.Font)).Max, "monospace") + This.Font = __UI_Font(__UI_Texts(__UI_GetFontID(This.Font)), __UI_Controls(__UI_GetFontID(This.Font)).Max, "monospace") END IF - This.FieldArea = This.Width \ _FONTWIDTH((This.Font)) - 1 + This.FieldArea = This.Width / _FONTWIDTH((This.Font)) - 1 + ELSE + EXIT SUB END IF IF This.ControlState <> ControlState OR _ @@ -1109,7 +1113,7 @@ SUB __UI_DrawFrame (This AS __UI_ControlTYPE) _PRINTSTRING (CaptionLeft, 0), TempCaption$ 'Hot key: - IF This.HotKey > 0 AND __UI_ShowHotKeys AND NOT This.Disabled THEN + IF This.HotKey > 0 AND ((__UI_ShowHotKeys AND NOT This.Disabled) OR __UI_DesignMode) THEN LINE (CaptionLeft + _PRINTWIDTH(" ") + This.HotKeyOffset, 0 + _FONTHEIGHT)-STEP(_PRINTWIDTH(CHR$(This.HotKey)) - 1, 0), This.ForeColor END IF END IF @@ -1152,9 +1156,6 @@ SUB __UI_DrawMenuBar (This AS __UI_ControlTYPE, ControlState AS _BYTE) _FONT (This.Font) '--- - DIM ItemOffset% - IF _PRINTWIDTH("W") <> _PRINTWIDTH("I") THEN ItemOffset% = _PRINTWIDTH("__") ELSE ItemOffset% = _PRINTWIDTH("__") - CLS , This.BackColor _PRINTMODE _KEEPBACKGROUND @@ -1176,10 +1177,10 @@ SUB __UI_DrawMenuBar (This AS __UI_ControlTYPE, ControlState AS _BYTE) COLOR c - _PRINTSTRING (ItemOffset%, ((This.Height \ 2) - _FONTHEIGHT \ 2)), TempCaption$ - IF This.HotKey > 0 AND (__UI_AltIsDown OR __UI_Controls(__UI_Focus).Type = __UI_Type_MenuBar) THEN + _PRINTSTRING (__UI_MenuBarOffset, ((This.Height \ 2) - _FONTHEIGHT \ 2)), TempCaption$ + IF This.HotKey > 0 AND ((__UI_AltIsDown OR __UI_Controls(__UI_Focus).Type = __UI_Type_MenuBar) OR __UI_DesignMode) THEN 'Has "hot-key" - LINE (ItemOffset% + This.HotKeyOffset, ((This.Height \ 2) + _FONTHEIGHT \ 2) - 1)-STEP(_PRINTWIDTH(CHR$(This.HotKey)) - 1, 0), c + LINE (__UI_MenuBarOffset + This.HotKeyOffset, ((This.Height \ 2) + _FONTHEIGHT \ 2) - 1)-STEP(_PRINTWIDTH(CHR$(This.HotKey)) - 1, 0), c END IF '--- @@ -1220,9 +1221,6 @@ SUB __UI_DrawMenuPanel (This AS __UI_ControlTYPE, ControlState AS _BYTE) _FONT (This.Font) '--- - DIM ItemOffset AS INTEGER - IF _PRINTWIDTH("W") <> _PRINTWIDTH("I") THEN ItemOffset = _PRINTWIDTH("____") ELSE ItemOffset = _PRINTWIDTH("__") - COLOR , _RGBA32(0, 0, 0, 0) CLS _PRINTMODE _KEEPBACKGROUND @@ -1259,16 +1257,25 @@ SUB __UI_DrawMenuPanel (This AS __UI_ControlTYPE, ControlState AS _BYTE) COLOR c - _PRINTSTRING (__UI_Controls(i).Left + ItemOffset, __UI_Controls(i).Top + __UI_Controls(i).Height \ 2 - _FONTHEIGHT \ 2), TempCaption$ + _PRINTSTRING (__UI_Controls(i).Left + __UI_MenuItemOffset, __UI_Controls(i).Top + __UI_Controls(i).Height \ 2 - _FONTHEIGHT \ 2), TempCaption$ IF __UI_Controls(i).HotKey > 0 THEN 'Has "hot-key" - LINE (__UI_Controls(i).Left + ItemOffset + __UI_Controls(i).HotKeyOffset, __UI_Controls(i).Top + __UI_Controls(i).Height \ 2 + _FONTHEIGHT \ 2 - 1)-STEP(_PRINTWIDTH(CHR$(__UI_Controls(i).HotKey)) - 1, 0), c + LINE (__UI_Controls(i).Left + __UI_MenuItemOffset + __UI_Controls(i).HotKeyOffset, __UI_Controls(i).Top + __UI_Controls(i).Height \ 2 + _FONTHEIGHT \ 2 - 1)-STEP(_PRINTWIDTH(CHR$(__UI_Controls(i).HotKey)) - 1, 0), c END IF IF __UI_Controls(i).Value = __UI_True THEN 'Checked menu item - _PUTIMAGE (ItemOffset \ 2 - CheckMarkWidth \ 2, __UI_Controls(i).Top + __UI_Controls(i).Height \ 2 - CheckMarkHeight \ 2), ControlImage, , (0, CheckMarkIndex * CheckMarkHeight - CheckMarkHeight)-STEP(6, 6) + _PUTIMAGE (__UI_MenuItemOffset \ 2 - CheckMarkWidth \ 2, __UI_Controls(i).Top + __UI_Controls(i).Height \ 2 - CheckMarkHeight \ 2), ControlImage, , (0, CheckMarkIndex * CheckMarkHeight - CheckMarkHeight)-STEP(6, 6) + ELSE + 'Does this menu item have a helper canvas (icon)? + DIM IconRatio AS INTEGER, IconWidth AS INTEGER, IconHeight AS INTEGER + IF __UI_Controls(i).HelperCanvas < -1 AND LEN(__UI_Texts(__UI_Controls(i).ID)) > 0 THEN + 'Icon will be to the left of caption + IconHeight = 16 + IconWidth = _WIDTH(__UI_Controls(i).HelperCanvas) * IconHeight / _HEIGHT(__UI_Controls(i).HelperCanvas) + _PUTIMAGE (3, __UI_Controls(i).Top + __UI_Controls(i).Height / 2 - IconHeight / 2)-STEP(IconWidth - 1, IconHeight - 1), __UI_Controls(i).HelperCanvas + END IF END IF IF HasSeparator THEN