From 745e2709b7dbe97b2a06a35f57f623e43b5fc0d1 Mon Sep 17 00:00:00 2001 From: FellippeHeitor Date: Mon, 10 Feb 2020 00:11:47 -0300 Subject: [PATCH] Gets Editor and Preview working with Binding data. --- InForm/InForm.ui | 161 ++++++++++++++++++++++++------------- InForm/UiEditor.bas | 78 ++++++++++++++++-- InForm/UiEditor.frm | 63 +++++---------- InForm/UiEditorPreview.bas | 49 ++++++++++- 4 files changed, 241 insertions(+), 110 deletions(-) diff --git a/InForm/InForm.ui b/InForm/InForm.ui index 7b4c4d6..f3c05d1 100644 --- a/InForm/InForm.ui +++ b/InForm/InForm.ui @@ -456,8 +456,8 @@ SUB __UI_InternalMenus ToolTip(__UI_NewID) = "The default button can be triggered with Enter even if it doesn't have focus at run time." __UI_NewID = __UI_NewControl(__UI_Type_MenuItem, "__UI_PreviewMenuBindControls", 0, 0, 0, 0, __UI_GetID("__UI_PreviewMenu")) - SetCaption __UI_GetID("__UI_PreviewMenuBindControls"), "Bind selected controls-" - ToolTip(__UI_NewID) = "The default button can be triggered with Enter even if it doesn't have focus at run time." + SetCaption __UI_GetID("__UI_PreviewMenuBindControls"), "Bind selected controls...-" + ToolTip(__UI_NewID) = "Binds a control's property to another control's property." __UI_NewID = __UI_NewControl(__UI_Type_MenuItem, "__UI_PreviewMenuConvertType", 0, 0, 0, 0, __UI_GetID("__UI_PreviewMenu")) SetCaption __UI_GetID("__UI_PreviewMenuConvertType"), "Co&nvert to type-" @@ -1161,6 +1161,18 @@ SUB __UI_UpdateDisplay _DEST 0 END IF + IF i = __UI_FirstSelectedID AND Control(i).BoundTo > 0 AND __UI_DesignMode = True AND __UI_ShowInvisibleControls = True THEN + LINE (Control(i).Left - 5 + Control(Control(i).ParentID).Left, _ + Control(i).Top - 5 + Control(Control(i).ParentID).Top)- _ + STEP(Control(i).Width + 10, Control(i).Height + 10), _ + _RGB32(127, 105, 183, 50), BF + + LINE (Control(Control(i).BoundTo).Left - 5 + Control(Control(Control(i).BoundTo).ParentID).Left, _ + Control(Control(i).BoundTo).Top - 5 + Control(Control(Control(i).BoundTo).ParentID).Top)- _ + STEP(Control(Control(i).BoundTo).Width + 10, Control(Control(i).BoundTo).Height + 10), _ + _RGB32(127, 105, 183, 50), BF + END IF + IF Control(i).Hidden = True AND __UI_DesignMode = True AND __UI_ShowInvisibleControls = True THEN LINE (Control(i).Left, Control(i).Top)-STEP(Control(i).Width - 1, Control(i).Height - 1), _RGBA32(127, 127, 127, 80), BF _FONT 8 @@ -2032,6 +2044,7 @@ SUB __UI_EventDispatcher Control(__UI_GetID("__UI_PreviewMenuImageOriginalSize")).Hidden = True Control(__UI_GetID("__UI_PreviewMenuNumericOnly")).Hidden = True Control(__UI_GetID("__UI_PreviewMenuSetDefaultButton")).Hidden = True + Control(__UI_GetID("__UI_PreviewMenuBindControls")).Hidden = True Control(__UI_GetID("__UI_PreviewMenuShowInvisibleControls")).Hidden = False Control(__UI_GetID("__UI_PreviewMenuConvertType")).Hidden = True Control(__UI_GetID("__UI_PreviewMenuNewMenuBar")).Hidden = False @@ -2113,7 +2126,19 @@ SUB __UI_EventDispatcher ELSE Control(__UI_GetID("__UI_PreviewMenuConvertType")).Hidden = True END IF + + IF Control(__UI_FirstSelectedID).BoundTo > 0 THEN + Control(__UI_GetID("__UI_PreviewMenuBindControls")).Hidden = False + SetCaption __UI_GetID("__UI_PreviewMenuBindControls"), "Edit binding...-" + END IF ELSEIF __UI_TotalSelectedControls = 2 THEN + Control(__UI_GetID("__UI_PreviewMenuBindControls")).Hidden = False + IF Control(__UI_FirstSelectedID).BoundTo > 0 THEN + SetCaption __UI_GetID("__UI_PreviewMenuBindControls"), "Edit binding...-" + ELSE + SetCaption __UI_GetID("__UI_PreviewMenuBindControls"), "Bind selected controls...-" + END IF + Control(__UI_GetID("__UI_PreviewMenuNewMenuBar")).Hidden = True Control(__UI_GetID("__UI_PreviewMenuNewContextMenu")).Hidden = True Control(__UI_GetID("__UI_PreviewMenuShowInvisibleControls")).Hidden = True @@ -2931,12 +2956,14 @@ SUB __UI_EventDispatcher END IF CASE UCASE$("__UI_PreviewMenuNewMenuBar") __UI_KeyPress 224 - CASE UCASE$("__UI_PreviewMenuShowInvisibleControls") - __UI_KeyPress 227 CASE UCASE$("__UI_PreviewMenuConvertType") __UI_KeyPress 225 CASE UCASE$("__UI_PreviewMenuNewContextMenu") __UI_KeyPress 226 + CASE UCASE$("__UI_PreviewMenuShowInvisibleControls") + __UI_KeyPress 227 + CASE UCASE$("__UI_PreviewMenuBindControls") + __UI_KeyPress 228 CASE "__UI_PREVIEWMENUCUT": GOTO ControlCut CASE "__UI_PREVIEWMENUCOPY": GOTO ControlCopy CASE "__UI_PREVIEWMENUPASTE": GOTO ControlPaste @@ -6856,10 +6883,10 @@ SUB __UI_Bind(id AS LONG, targetID AS LONG, __PropertyID$, __PropertyTargetID$) Control(id).BoundTo = targetID - Control(id).BoundProperty = __UI_PropertyEnum(PropertyID$) + Control(id).BoundProperty = __UI_PropertyEnum(PropertyID$, 0) IF Control(id).BoundProperty = 0 THEN Control(id).BoundTo = 0: EXIT SUB Control(targetID).BoundTo = id - Control(targetID).BoundProperty = __UI_PropertyEnum(PropertyTargetID$) + Control(targetID).BoundProperty = __UI_PropertyEnum(PropertyTargetID$, 0) IF Control(targetID).BoundProperty = 0 THEN Control(id).BoundTo = 0 Control(targetID).BoundTo = 0 @@ -6867,37 +6894,57 @@ SUB __UI_Bind(id AS LONG, targetID AS LONG, __PropertyID$, __PropertyTargetID$) __UI_CheckBinding targetID 'acquire current value of targetID END SUB -FUNCTION __UI_PropertyEnum& (__property$) - DIM property$ +FUNCTION __UI_PropertyEnum& (__property$, index AS LONG) + 'If __property$ is passed: + ' - __UI_PropertyEnum& returns the index/hash value; + 'If index is passed: + ' - __property$ returns the property name found and + ' - __UI_PropertyEnum& returns True (-1) + + DIM property$, NextAt AS LONG STATIC EnumInitialized AS _BYTE, Enum$ - IF LEN(_TRIM$(__property$)) = 0 THEN EXIT FUNCTION + IF LEN(_TRIM$(__property$)) = 0 AND index = 0 THEN EXIT FUNCTION IF NOT EnumInitialized THEN RESTORE EnumNames DO READ property$ IF property$ = "*" THEN EXIT DO - Enum$ = Enum$ + "@" + UCASE$(property$) + Enum$ = Enum$ + "@" + property$ LOOP Enum$ = Enum$ + "@" EnumInitialized = True END IF - property$ = "@" + _TRIM$(UCASE$(__property$)) + "@" - __UI_PropertyEnum& = INSTR(Enum$, property$) + IF index > 0 THEN + 'return property name + IF index > LEN(Enum$) THEN EXIT FUNCTION + IF ASC(Enum$, index) <> 64 THEN EXIT FUNCTION + NextAt = INSTR(index + 1, Enum$, "@") + __property$ = MID$(Enum$, index + 1, NextAt - index - 1) + __UI_PropertyEnum& = -1 + ELSE + 'return index + property$ = "@" + _TRIM$(UCASE$(__property$)) + "@" + __UI_PropertyEnum& = INSTR(UCASE$(Enum$), property$) + END IF EXIT FUNCTION EnumNames: - DATA Top, Left, Width, Height, Bordersize, Padding, Value - DATA Min, Max, Interval, MinInterval, Stretch, HasBorder, ShowPercentage - DATA AutoScroll, AutoSize, PasswordField, Disabled, Hidden + DATA Top,Left,Width,Height,Bordersize,Padding,Value + DATA Min,Max,Interval,MinInterval,Stretch,HasBorder,ShowPercentage + DATA AutoScroll,AutoSize,PasswordMask,Disabled,Hidden DATA * END FUNCTION -SUB __UI_UnBind(id AS LONG, targetID AS LONG) - Control(id).BoundTo = 0 - Control(targetID).BoundTo = 0 +SUB __UI_UnBind(id AS LONG) + IF Control(id).BoundTo > 0 THEN + Control(Control(id).BoundTo).Redraw = True + Control(Control(id).BoundTo).BoundTo = 0 + Control(id).BoundTo = 0 + Control(id).Redraw = True + END IF END SUB SUB __UI_CheckBinding(id AS LONG) @@ -6907,90 +6954,90 @@ SUB __UI_CheckBinding(id AS LONG) IF BindTarget = 0 THEN EXIT SUB IF Control(id).BoundProperty = Control(BindTarget).BoundProperty AND _ - Control(id).BoundProperty = __UI_PropertyEnum&("Value") THEN + Control(id).BoundProperty = __UI_PropertyEnum&("Value", 0) THEN Control(id).Min = Control(BindTarget).Min Control(id).Max = Control(BindTarget).Max END IF SELECT CASE Control(id).BoundProperty - CASE __UI_PropertyEnum&("Top") + CASE __UI_PropertyEnum&("Top", 0) Temp = Control(id).Top - CASE __UI_PropertyEnum&("Left") + CASE __UI_PropertyEnum&("Left", 0) Temp = Control(id).Left - CASE __UI_PropertyEnum&("Width") + CASE __UI_PropertyEnum&("Width", 0) Temp = Control(id).Width - CASE __UI_PropertyEnum&("Height") + CASE __UI_PropertyEnum&("Height", 0) Temp = Control(id).Height - CASE __UI_PropertyEnum&("BorderSize") + CASE __UI_PropertyEnum&("BorderSize", 0) Temp = Control(id).BorderSize - CASE __UI_PropertyEnum&("Padding") + CASE __UI_PropertyEnum&("Padding", 0) Temp = Control(id).Padding - CASE __UI_PropertyEnum&("Value") + CASE __UI_PropertyEnum&("Value", 0) Temp = Control(id).Value - CASE __UI_PropertyEnum&("Min") + CASE __UI_PropertyEnum&("Min", 0) Temp = Control(id).Min - CASE __UI_PropertyEnum&("Max") + CASE __UI_PropertyEnum&("Max", 0) Temp = Control(id).Max - CASE __UI_PropertyEnum&("Interval") + CASE __UI_PropertyEnum&("Interval", 0) Temp = Control(id).Interval - CASE __UI_PropertyEnum&("Mininterval") + CASE __UI_PropertyEnum&("Mininterval", 0) Temp = Control(id).Mininterval - CASE __UI_PropertyEnum&("Stretch") + CASE __UI_PropertyEnum&("Stretch", 0) Temp = Control(id).Stretch - CASE __UI_PropertyEnum&("HasBorder") + CASE __UI_PropertyEnum&("HasBorder", 0) Temp = Control(id).HasBorder - CASE __UI_PropertyEnum&("ShowPercentage") + CASE __UI_PropertyEnum&("ShowPercentage", 0) Temp = Control(id).ShowPercentage - CASE __UI_PropertyEnum&("AutoScroll") + CASE __UI_PropertyEnum&("AutoScroll", 0) Temp = Control(id).AutoScroll - CASE __UI_PropertyEnum&("AutoSize") + CASE __UI_PropertyEnum&("AutoSize", 0) Temp = Control(id).AutoSize - CASE __UI_PropertyEnum&("PasswordField") + CASE __UI_PropertyEnum&("PasswordField", 0) Temp = Control(id).PasswordField - CASE __UI_PropertyEnum&("Disabled") + CASE __UI_PropertyEnum&("Disabled", 0) Temp = Control(id).Disabled - CASE __UI_PropertyEnum&("Hidden") + CASE __UI_PropertyEnum&("Hidden", 0) Temp = Control(id).Hidden END SELECT SELECT CASE Control(BindTarget).BoundProperty - CASE __UI_PropertyEnum&("Top") + CASE __UI_PropertyEnum&("Top", 0) Control(BindTarget).Top = Temp - CASE __UI_PropertyEnum&("Left") + CASE __UI_PropertyEnum&("Left", 0) Control(BindTarget).Left = Temp - CASE __UI_PropertyEnum&("Width") + CASE __UI_PropertyEnum&("Width", 0) Control(BindTarget).Width = Temp - CASE __UI_PropertyEnum&("Height") + CASE __UI_PropertyEnum&("Height", 0) Control(BindTarget).Height = Temp - CASE __UI_PropertyEnum&("BorderSize") + CASE __UI_PropertyEnum&("BorderSize", 0) Control(BindTarget).BorderSize = Temp - CASE __UI_PropertyEnum&("Padding") + CASE __UI_PropertyEnum&("Padding", 0) Control(BindTarget).Padding = Temp - CASE __UI_PropertyEnum&("Value") + CASE __UI_PropertyEnum&("Value", 0) Control(BindTarget).Value = Temp - CASE __UI_PropertyEnum&("Min") + CASE __UI_PropertyEnum&("Min", 0) Control(BindTarget).Min = Temp - CASE __UI_PropertyEnum&("Max") + CASE __UI_PropertyEnum&("Max", 0) Control(BindTarget).Max = Temp - CASE __UI_PropertyEnum&("Interval") + CASE __UI_PropertyEnum&("Interval", 0) Control(BindTarget).Interval = Temp - CASE __UI_PropertyEnum&("MinInterval") + CASE __UI_PropertyEnum&("MinInterval", 0) Control(BindTarget).MinInterval = Temp - CASE __UI_PropertyEnum&("Stretch") + CASE __UI_PropertyEnum&("Stretch", 0) Control(BindTarget).Stretch = Temp - CASE __UI_PropertyEnum&("HasBorder") + CASE __UI_PropertyEnum&("HasBorder", 0) Control(BindTarget).HasBorder = Temp - CASE __UI_PropertyEnum&("ShowPercentage") + CASE __UI_PropertyEnum&("ShowPercentage", 0) Control(BindTarget).ShowPercentage = Temp - CASE __UI_PropertyEnum&("AutoScroll") + CASE __UI_PropertyEnum&("AutoScroll", 0) Control(BindTarget).AutoScroll = Temp - CASE __UI_PropertyEnum&("AutoSize") + CASE __UI_PropertyEnum&("AutoSize", 0) Control(BindTarget).AutoSize = Temp - CASE __UI_PropertyEnum&("PasswordField") + CASE __UI_PropertyEnum&("PasswordField", 0) Control(BindTarget).PasswordField = Temp - CASE __UI_PropertyEnum&("Disabled") + CASE __UI_PropertyEnum&("Disabled", 0) Control(BindTarget).Disabled = Temp - CASE __UI_PropertyEnum&("Hidden") + CASE __UI_PropertyEnum&("Hidden", 0) Control(BindTarget).Hidden = Temp END SELECT diff --git a/InForm/UiEditor.bas b/InForm/UiEditor.bas index c48f873..a892cae 100644 --- a/InForm/UiEditor.bas +++ b/InForm/UiEditor.bas @@ -188,6 +188,7 @@ REDIM SHARED PreviewActualFonts(0) AS STRING REDIM SHARED PreviewControls(0) AS __UI_ControlTYPE REDIM SHARED PreviewParentIDS(0) AS STRING REDIM SHARED PreviewContextMenu(0) AS STRING +REDIM SHARED PreviewBoundTo(0) AS STRING REDIM SHARED PreviewKeyCombos(0) AS STRING REDIM SHARED PreviewAnimatedGif(0) AS _BYTE REDIM SHARED PreviewAutoPlayGif(0) AS _BYTE @@ -583,7 +584,7 @@ SUB __UI_Click (id AS LONG) SYSTEM CASE EditMenuZOrdering 'Fill the list: - Caption(StatusBar) = "Editing z-ordering/tab ordering..." + Caption(StatusBar) = "Editing z-ordering/tab ordering" DIM j AS LONG, i AS LONG STATIC Moving AS _BYTE REDIM _PRESERVE zOrderIDs(1 TO UBOUND(PreviewControls)) AS LONG @@ -603,17 +604,60 @@ SUB __UI_Click (id AS LONG) __UI_Focus = ControlList ZOrderingDialogOpen = True CASE EditMenuBindControls - Caption(StatusBar) = "Setting control bindings..." + 'Get controls' names + DIM CurrentSource$ + j = 0 + FOR i = 1 TO UBOUND(PreviewControls) + IF PreviewControls(i).ControlIsSelected THEN + j = j + 1 + IF j = 1 THEN + Caption(SourceControlNameLB) = RTRIM$(PreviewControls(i).Name) + CurrentSource$ = PreviewBoundTo(i) + END IF + IF j = 2 THEN + Caption(TargetControlNameLB) = RTRIM$(PreviewControls(i).Name) + EXIT FOR + END IF + END IF + NEXT + + IF CurrentSource$ = Caption(TargetControlNameLB) THEN + Caption(CancelBindBT) = "Unbind" + ELSE + Caption(CancelBindBT) = "Cancel" + END IF + + Caption(StatusBar) = "Defining control bindings" Control(DialogBG).Left = 0: Control(DialogBG).Top = 0 - Control(SetControlBinding).Left = 83: Control(SetControlBinding).Top = 192 + Control(SetControlBinding).Left = 83: Control(SetControlBinding).Top = 169 __UI_Focus = SourcePropertyList SetBindingDialogOpen = True CASE SwapBT SWAP Caption(SourceControlNameLB), Caption(TargetControlNameLB) - CASE BindBT, CancelBindBT + SWAP Control(SourcePropertyList).Value, Control(TargetPropertyList).Value + CASE BindBT Control(DialogBG).Left = -600: Control(DialogBG).Top = -600 Control(SetControlBinding).Left = -600: Control(SetControlBinding).Top = -600 SetBindingDialogOpen = False + b$ = "BINDCONTROLS>" + b$ = b$ + MKL$(LEN(Caption(SourceControlNameLB))) + Caption(SourceControlNameLB) + b$ = b$ + MKL$(LEN(Caption(TargetControlNameLB))) + Caption(TargetControlNameLB) + b$ = b$ + MKL$(LEN(GetItem(SourcePropertyList, Control(SourcePropertyList).Value))) + b$ = b$ + GetItem(SourcePropertyList, Control(SourcePropertyList).Value) + b$ = b$ + MKL$(LEN(GetItem(TargetPropertyList, Control(TargetPropertyList).Value))) + b$ = b$ + GetItem(TargetPropertyList, Control(TargetPropertyList).Value) + b$ = b$ + "" + Send Client, b$ + CASE CancelBindBT + Control(DialogBG).Left = -600: Control(DialogBG).Top = -600 + Control(SetControlBinding).Left = -600: Control(SetControlBinding).Top = -600 + SetBindingDialogOpen = False + IF Caption(CancelBindBT) = "Unbind" THEN + b$ = "UNBINDCONTROLS>" + b$ = b$ + Caption(SourceControlNameLB) + b$ = b$ + "" + Send Client, b$ + END IF CASE CloseZOrderingBT Caption(StatusBar) = "Ready." Control(DialogBG).Left = -600: Control(DialogBG).Top = -600 @@ -927,7 +971,7 @@ SUB __UI_MouseEnter (id AS LONG) CASE ViewMenuShowPositionAndSize Caption(StatusBar) = "Toggles whether size and position indicators will be shown in the preview." CASE ViewMenuShowInvisibleControls - Caption(StatusBar) = "Toggles whether invisible controls (e.g. ContextMenus) will be shown in the preview." + Caption(StatusBar) = "Show or hide invisible controls and binding indicators in the preview dialog." CASE ViewMenuPreview Caption(StatusBar) = "Launches the preview window in case it's been closed accidentaly." CASE ViewMenuLoadedFonts @@ -1543,6 +1587,20 @@ SUB __UI_BeforeUpdateDisplay CASE "SHOWINVISIBLECONTROLS" __UI_ShowInvisibleControls = CVI(thisData$) Control(ViewMenuShowInvisibleControls).Value = __UI_ShowInvisibleControls + CASE "SHOWBINDCONTROLDIALOG" + b$ = ReadSequential(thisData$, 4) + IF CVL(b$) = 0 THEN + j = SelectItem(SourcePropertyList, "Value") + ELSE + j = SelectItem(SourcePropertyList, ReadSequential(thisData$, CVL(b$))) + END IF + b$ = ReadSequential(thisData$, 4) + IF CVL(b$) = 0 THEN + j = SelectItem(TargetPropertyList, "Value") + ELSE + j = SelectItem(TargetPropertyList, ReadSequential(thisData$, CVL(b$))) + END IF + __UI_Click EditMenuBindControls CASE "ORIGINALIMAGEWIDTH" OriginalImageWidth = CVI(thisData$) CASE "ORIGINALIMAGEHEIGHT" @@ -1705,6 +1763,7 @@ SUB __UI_BeforeUpdateDisplay Control(EditMenuSetDefaultButton).Disabled = True Control(EditMenuSetDefaultButton).Value = False + Control(EditMenuBindControls).Disabled = True Control(EditMenuAllowMinMax).Disabled = True Control(EditMenuAllowMinMax).Value = False IF INSTR(LCASE$(PreviewControls(PreviewFormID).Name), "form") = 0 THEN @@ -1787,6 +1846,8 @@ SUB __UI_BeforeUpdateDisplay END IF END IF ELSEIF TotalSelected = 2 THEN + Control(EditMenuBindControls).Disabled = False + Caption(ControlProperties) = "Control properties: (multiple selection)" Control(EditMenuCut).Disabled = False @@ -3718,6 +3779,7 @@ SUB LoadPreview REDIM PreviewControls(0 TO CVL(b$)) AS __UI_ControlTYPE REDIM PreviewParentIDS(0 TO CVL(b$)) AS STRING REDIM PreviewContextMenu(0 TO CVL(b$)) AS STRING + REDIM PreviewBoundTo(0 TO CVL(b$)) AS STRING REDIM PreviewKeyCombos(0 TO CVL(b$)) AS STRING REDIM PreviewAnimatedGif(0 TO CVL(b$)) AS _BYTE REDIM PreviewAutoPlayGif(0 TO CVL(b$)) AS _BYTE @@ -3890,6 +3952,12 @@ SUB LoadPreview END IF CASE -46 'Auto-play Gif PreviewAutoPlayGif(Dummy) = True + CASE -47 'ControlIsSelected + PreviewControls(Dummy).ControlIsSelected = True + CASE -48 'BoundTo + b$ = ReadSequential$(FormData$, 2) + b$ = ReadSequential$(FormData$, CVI(b$)) + PreviewBoundTo(Dummy) = b$ CASE -1 'new control EXIT DO CASE -1024 diff --git a/InForm/UiEditor.frm b/InForm/UiEditor.frm index 9102d64..b842395 100644 --- a/InForm/UiEditor.frm +++ b/InForm/UiEditor.frm @@ -152,7 +152,7 @@ SUB __UI_LoadForm __UI_NewID = __UI_NewControl(__UI_Type_MenuItem, "EditMenuBindControls", 103, 18, 0, 88, __UI_GetID("EditMenu")) SetCaption __UI_NewID, "&Bind controls..." - 'Control(__UI_NewID).Disabled = True + Control(__UI_NewID).Disabled = True __UI_NewID = __UI_NewControl(__UI_Type_MenuItem, "EditMenuAllowMinMax", 103, 18, 0, 88, __UI_GetID("EditMenu")) SetCaption __UI_NewID, "Validate .Min/.Ma&x bounds-" @@ -170,7 +170,7 @@ SUB __UI_LoadForm Control(__UI_NewID).Value = -1 __UI_NewID = __UI_NewControl(__UI_Type_MenuItem, "ViewMenuShowInvisibleControls", 253, 18, 0, 22, __UI_GetID("ViewMenu")) - SetCaption __UI_NewID, "&Show invisible controls on the preview" + SetCaption __UI_NewID, "&Show invisible elements on the preview" Control(__UI_NewID).Value = -1 __UI_NewID = __UI_NewControl(__UI_Type_MenuItem, "ViewMenuPreview", 168, 18, 0, 40, __UI_GetID("ViewMenu")) @@ -768,37 +768,33 @@ SUB __UI_LoadForm SetCaption __UI_NewID, "Close" Control(__UI_NewID).CanHaveFocus = True - __UI_NewID = __UI_NewControl(__UI_Type_Frame, "SetControlBinding", 434, 216, -600, -600, 0) + __UI_NewID = __UI_NewControl(__UI_Type_Frame, "SetControlBinding", 434, 263, -600, -600, 0) SetCaption __UI_NewID, "Set control binding" + Control(__UI_NewID).Font = SetFont("segoeui.ttf?arial.ttf?/Library/Fonts/Arial.ttf?/usr/share/fonts/truetype/liberation/LiberationSans-Regular.ttf?/usr/share/fonts/TTF/arial.ttf?InForm/resources/NotoMono-Regular.ttf?cour.ttf", 12) Control(__UI_NewID).HasBorder = True - Control(__UI_NewID).Value = 11 Control(__UI_NewID).BorderSize = 1 - __UI_NewID = __UI_NewControl(__UI_Type_Label, "SourceControlLB", 100, 23, 19, 18, __UI_GetID("SetControlBinding")) - SetCaption __UI_NewID, "Source control:" + __UI_NewID = __UI_NewControl(__UI_Type_Label, "SourceControlLB", 81, 23, 19, 18, __UI_GetID("SetControlBinding")) + SetCaption __UI_NewID, "Bind:" Control(__UI_NewID).VAlign = __UI_Middle - __UI_NewID = __UI_NewControl(__UI_Type_Label, "SourceControlNameLB", 311, 23, 110, 18, __UI_GetID("SetControlBinding")) + __UI_NewID = __UI_NewControl(__UI_Type_Label, "SourceControlNameLB", 380, 23, 35, 43, __UI_GetID("SetControlBinding")) SetCaption __UI_NewID, "SourceControlName" Control(__UI_NewID).VAlign = __UI_Middle - __UI_NewID = __UI_NewControl(__UI_Type_Label, "TargetControlLB", 100, 23, 19, 46, __UI_GetID("SetControlBinding")) - SetCaption __UI_NewID, "Target control:" + __UI_NewID = __UI_NewControl(__UI_Type_Label, "TargetControlLB", 81, 23, 19, 114, __UI_GetID("SetControlBinding")) + SetCaption __UI_NewID, "To:" Control(__UI_NewID).VAlign = __UI_Middle - __UI_NewID = __UI_NewControl(__UI_Type_Label, "TargetControlNameLB", 311, 23, 110, 46, __UI_GetID("SetControlBinding")) + __UI_NewID = __UI_NewControl(__UI_Type_Label, "TargetControlNameLB", 380, 23, 35, 133, __UI_GetID("SetControlBinding")) SetCaption __UI_NewID, "TargetControlName" Control(__UI_NewID).VAlign = __UI_Middle - __UI_NewID = __UI_NewControl(__UI_Type_Button, "SwapBT", 62, 23, 359, 32, __UI_GetID("SetControlBinding")) - SetCaption __UI_NewID, "Swap" + __UI_NewID = __UI_NewControl(__UI_Type_Button, "SwapBT", 160, 23, 19, 220, __UI_GetID("SetControlBinding")) + SetCaption __UI_NewID, "Swap source and target" Control(__UI_NewID).CanHaveFocus = True - __UI_NewID = __UI_NewControl(__UI_Type_Label, "SourcePropertyLB", 112, 23, 19, 99, __UI_GetID("SetControlBinding")) - SetCaption __UI_NewID, "Source property:" - Control(__UI_NewID).VAlign = __UI_Middle - - __UI_NewID = __UI_NewControl(__UI_Type_DropdownList, "SourcePropertyList", 295, 23, 124, 99, __UI_GetID("SetControlBinding")) + __UI_NewID = __UI_NewControl(__UI_Type_DropdownList, "SourcePropertyList", 380, 23, 35, 71, __UI_GetID("SetControlBinding")) AddItem __UI_NewID, "Top" AddItem __UI_NewID, "Left" AddItem __UI_NewID, "Width" @@ -815,7 +811,7 @@ SUB __UI_LoadForm AddItem __UI_NewID, "ShowPercentage" AddItem __UI_NewID, "AutoScroll" AddItem __UI_NewID, "AutoSize" - AddItem __UI_NewID, "PasswordField" + AddItem __UI_NewID, "PasswordMask" AddItem __UI_NewID, "Disabled" AddItem __UI_NewID, "Hidden" Control(__UI_NewID).HasBorder = True @@ -823,40 +819,19 @@ SUB __UI_LoadForm Control(__UI_NewID).CanHaveFocus = True Control(__UI_NewID).BorderSize = 1 - __UI_NewID = __UI_NewControl(__UI_Type_Label, "TargetPropertyLB", 112, 23, 19, 127, __UI_GetID("SetControlBinding")) - SetCaption __UI_NewID, "Target property:" - Control(__UI_NewID).VAlign = __UI_Middle - - __UI_NewID = __UI_NewControl(__UI_Type_DropdownList, "TargetPropertyList", 295, 23, 124, 127, __UI_GetID("SetControlBinding")) - AddItem __UI_NewID, "Top" - AddItem __UI_NewID, "Left" - AddItem __UI_NewID, "Width" - AddItem __UI_NewID, "Height" - AddItem __UI_NewID, "Bordersize" - AddItem __UI_NewID, "Padding" - AddItem __UI_NewID, "Value" - AddItem __UI_NewID, "Min" - AddItem __UI_NewID, "Max" - AddItem __UI_NewID, "Interval" - AddItem __UI_NewID, "MinInterval" - AddItem __UI_NewID, "Stretch" - AddItem __UI_NewID, "HasBorder" - AddItem __UI_NewID, "ShowPercentage" - AddItem __UI_NewID, "AutoScroll" - AddItem __UI_NewID, "AutoSize" - AddItem __UI_NewID, "PasswordField" - AddItem __UI_NewID, "Disabled" - AddItem __UI_NewID, "Hidden" + __UI_NewID = __UI_NewControl(__UI_Type_DropdownList, "TargetPropertyList", 380, 23, 35, 161, __UI_GetID("SetControlBinding")) + Text(__UI_NewID) = Text(__UI_GetID("SourcePropertyList")) + Control(__UI_NewID).Max = Control(__UI_GetID("SourcePropertyList")).Max Control(__UI_NewID).HasBorder = True Control(__UI_NewID).Value = 7 Control(__UI_NewID).CanHaveFocus = True Control(__UI_NewID).BorderSize = 1 - __UI_NewID = __UI_NewControl(__UI_Type_Button, "BindBT", 80, 23, 131, 173, __UI_GetID("SetControlBinding")) + __UI_NewID = __UI_NewControl(__UI_Type_Button, "BindBT", 80, 23, 248, 220, __UI_GetID("SetControlBinding")) SetCaption __UI_NewID, "Bind" Control(__UI_NewID).CanHaveFocus = True - __UI_NewID = __UI_NewControl(__UI_Type_Button, "CancelBindBT", 80, 23, 224, 173, __UI_GetID("SetControlBinding")) + __UI_NewID = __UI_NewControl(__UI_Type_Button, "CancelBindBT", 80, 23, 341, 220, __UI_GetID("SetControlBinding")) SetCaption __UI_NewID, "Cancel" Control(__UI_NewID).CanHaveFocus = True END SUB diff --git a/InForm/UiEditorPreview.bas b/InForm/UiEditorPreview.bas index 9c36678..9e932c4 100644 --- a/InForm/UiEditorPreview.bas +++ b/InForm/UiEditorPreview.bas @@ -47,6 +47,7 @@ CONST EmptyForm$ = "9iVA_9GK1P<000`ooO7000@00D006mVL]53;1`B000000000noO100006mVL ' 225 = Convert control type to alternative type ' 226 = Add new ContextMenu control ' 227 = Toggle __UI_ShowInvisibleControls +' 228 = Bind/Unbind selected controls 'SavePreview parameters: CONST InDisk = 1 @@ -329,6 +330,19 @@ SUB __UI_BeforeUpdateDisplay StopGif i END IF NEXT + CASE "BINDCONTROLS" + DIM BindInfo$(1 TO 4) + + FOR i = 1 TO 4 + TempValue = CVL(LEFT$(thisData$, 4)) + thisData$ = MID$(thisData$, 5) + BindInfo$(i) = LEFT$(thisData$, TempValue) + thisData$ = MID$(thisData$, TempValue + 1) + NEXT + + __UI_Bind __UI_GetID(BindInfo$(1)), __UI_GetID(BindInfo$(2)), BindInfo$(3), BindInfo$(4) + CASE "UNBINDCONTROLS" + __UI_UnBind __UI_GetID(thisData$) END SELECT LOOP @@ -1750,6 +1764,23 @@ SUB __UI_KeyPress (id AS LONG) SelectNewControl TempValue CASE 227 'Toggle __UI_ShowInvisibleControls __UI_ShowInvisibleControls = NOT __UI_ShowInvisibleControls + CASE 228 'Bind/unbind controls + DIM a$, b$, c$, found AS _BYTE + DIM i AS LONG, j AS LONG + FOR i = 1 TO UBOUND(Control) + IF Control(i).ControlIsSelected THEN + j = j + 1 + IF j = 1 THEN + found = __UI_PropertyEnum(a$, Control(i).BoundProperty) + IF __UI_TotalSelectedControls = 1 THEN EXIT FOR + ELSEIF j = 2 THEN + found = __UI_PropertyEnum(b$, Control(i).BoundProperty) + EXIT FOR + END IF + END IF + NEXT + c$ = MKL$(LEN(a$)) + a$ + MKL$(LEN(b$)) + b$ + SendData c$, "SHOWBINDCONTROLDIALOG" END SELECT END SUB @@ -2674,6 +2705,8 @@ SUB LoadPreview (Destination AS _BYTE) IF TempValue <= UBOUND(AutoPlayGif) THEN AutoPlayGif(i) = True END IF + CASE -47 + Control(TempValue).ControlIsSelected = True CASE -1 'new control IF LogFileLoad THEN PRINT #LogFileNum, "READ NEW CONTROL: -1" EXIT DO @@ -3502,6 +3535,18 @@ SUB SavePreview (Destination AS _BYTE) END IF END IF END IF + IF Control(i).ControlIsSelected THEN + b$ = MKI$(-47) + IF Disk THEN + PUT #BinFileNum, , b$ + ELSE + Clip$ = Clip$ + b$ + END IF + END IF + IF Control(i).BoundTo > 0 THEN + b$ = MKI$(-48) + MKI$(LEN(RTRIM$(Control(Control(i).BoundTo).Name))) + RTRIM$(Control(Control(i).BoundTo).Name) + IF Disk THEN PUT #BinFileNum, , b$ ELSE Clip$ = Clip$ + b$ + END IF END IF NEXT NEXT @@ -3558,10 +3603,6 @@ SUB SavePreview (Destination AS _BYTE) END SUB SUB SendData (b$, thisCommand$) - 'DIM FileNum AS INTEGER - 'FileNum = FREEFILE - 'OPEN "InForm/UiEditor.dat" FOR BINARY AS #FileNum - b$ = UCASE$(thisCommand$) + ">" + b$ + "" PUT #Host, , b$ END SUB