From 8bbbed6353842be99f955831a0fa55033fc2a23e Mon Sep 17 00:00:00 2001 From: FellippeHeitor Date: Sat, 18 Aug 2018 21:16:47 -0300 Subject: [PATCH] Adds "Convert Type" to UiEditor's Edit menu. --- InForm/UiEditor.bas | 35 ++++++++++++++++++++++++++++++++++- InForm/UiEditor.frm | 5 +++++ InForm/UiEditorPreview.bas | 12 ++++++++++++ InForm/docs/frmbin format.txt | 2 ++ 4 files changed, 53 insertions(+), 1 deletion(-) diff --git a/InForm/UiEditor.bas b/InForm/UiEditor.bas index 0e39ae6..3c399ed 100644 --- a/InForm/UiEditor.bas +++ b/InForm/UiEditor.bas @@ -26,7 +26,7 @@ DIM SHARED EditMenuUndo AS LONG, EditMenuRedo AS LONG, EditMenuCut AS LONG DIM SHARED EditMenuCopy AS LONG, EditMenuPaste AS LONG DIM SHARED EditMenuDelete AS LONG, EditMenuSelectAll AS LONG DIM SHARED EditMenuCP437 AS LONG, EditMenuCP1252 AS LONG -DIM SHARED EditMenuSetDefaultButton AS LONG +DIM SHARED EditMenuConvertType AS LONG, EditMenuSetDefaultButton AS LONG DIM SHARED EditMenuRestoreDimensions AS LONG DIM SHARED EditMenuAllowMinMax AS LONG, EditMenuZOrdering AS LONG @@ -289,6 +289,9 @@ SUB __UI_Click (id AS LONG) CheckUpdates = NOT CheckUpdates Control(id).Value = CheckUpdates SaveSettings + CASE EditMenuConvertType + b$ = MKI$(0) + SendData b$, 225 CASE EditMenuSetDefaultButton SendSignal -6 CASE EditMenuRestoreDimensions @@ -670,6 +673,8 @@ SUB __UI_MouseEnter (id AS LONG) Caption(StatusBar) = "Applies code page 437 to the current form." CASE EditMenuCP1252 Caption(StatusBar) = "Applies code page 1252 to the current form." + CASE EditMenuConvertType + Caption(StatusBar) = "Converts this control's type into another similar in functionality." CASE EditMenuSetDefaultButton Caption(StatusBar) = "Makes the currently selected button the default button." CASE EditMenuRestoreDimensions @@ -1223,6 +1228,8 @@ SUB __UI_BeforeUpdateDisplay Control(InsertMenuMenuItem).Disabled = True END IF + Control(EditMenuConvertType).Disabled = True + SetCaption EditMenuConvertType, "Co&nvert type" Control(EditMenuSetDefaultButton).Disabled = True Control(EditMenuSetDefaultButton).Value = False Control(EditMenuAllowMinMax).Disabled = True @@ -1305,6 +1312,11 @@ SUB __UI_BeforeUpdateDisplay IF INSTR(PreviewControls(FirstSelected).Name, "NumericTextBox") = 0 THEN Caption(ControlProperties) = "Control properties (Type = NumericTextBox):" END IF END IF + + IF __UI_Type(PreviewControls(FirstSelected).Type).TurnsInto THEN + Control(EditMenuConvertType).Disabled = False + SetCaption EditMenuConvertType, "Co&nvert to " + RTRIM$(__UI_Type(__UI_Type(PreviewControls(FirstSelected).Type).TurnsInto).Name) + END IF END IF ELSEIF TotalSelected = 2 THEN @@ -1325,6 +1337,7 @@ SUB __UI_BeforeUpdateDisplay Control(AlignMenuDistributeV).Disabled = True Control(AlignMenuDistributeH).Disabled = True + GOTO EnableConvertMenuItem ELSE SetCaption ControlProperties, "Control properties: (multiple selection)" @@ -1343,6 +1356,24 @@ SUB __UI_BeforeUpdateDisplay Control(AlignMenuDistributeV).Disabled = False Control(AlignMenuDistributeH).Disabled = False + EnableConvertMenuItem: + IF __UI_Type(PreviewControls(FirstSelected).Type).TurnsInto THEN + DIM SearchType AS INTEGER, EnableConvertMenuItemCheck AS _BYTE + SearchType = PreviewControls(FirstSelected).Type + EnableConvertMenuItemCheck = True + FOR i = 1 TO UBOUND(PreviewControls) + IF PreviewControls(i).ControlIsSelected THEN + IF PreviewControls(i).Type <> SearchType THEN + EnableConvertMenuItemCheck = False + EXIT FOR + END IF + END IF + NEXT + IF EnableConvertMenuItemCheck THEN + Control(EditMenuConvertType).Disabled = False + SetCaption EditMenuConvertType, "Co&nvert to " + RTRIM$(__UI_Type(__UI_Type(PreviewControls(FirstSelected).Type).TurnsInto).Name) + END IF + END IF END IF IF FirstSelected = 0 THEN FirstSelected = PreviewFormID @@ -3121,6 +3152,8 @@ SUB LoadPreview PreviewControls(Dummy).BulletStyle = __UI_Bullet CASE -41 PreviewControls(Dummy).AutoScroll = True + CASE -42 + PreviewControls(Dummy).ControlIsSelected = True CASE -1 'new control EXIT DO CASE -1024 diff --git a/InForm/UiEditor.frm b/InForm/UiEditor.frm index ef7f172..f1e2337 100644 --- a/InForm/UiEditor.frm +++ b/InForm/UiEditor.frm @@ -110,6 +110,10 @@ SUB __UI_LoadForm SetCaption __UI_NewID, "Use code page &Windows-1252-" Control(__UI_NewID).BulletStyle = __UI_Bullet + __UI_NewID = __UI_NewControl(__UI_Type_MenuItem, "EditMenuConvertType", 103, 18, 0, 88, __UI_GetID("EditMenu")) + SetCaption __UI_NewID, "Co&nvert type" + Control(__UI_NewID).Disabled = True + __UI_NewID = __UI_NewControl(__UI_Type_MenuItem, "EditMenuSetDefaultButton", 103, 18, 0, 88, __UI_GetID("EditMenu")) SetCaption __UI_NewID, "Set as &default button" Control(__UI_NewID).Disabled = True @@ -816,4 +820,5 @@ SUB __UI_AssignIDs FontSwitchMenu = __UI_GetID("FontSwitchMenu") AutoScroll = __UI_GetID("AutoScroll") PasteListBT = __UI_GetID("PasteListBT") + EditMenuConvertType = __UI_GetID("EditMenuConvertType") END SUB diff --git a/InForm/UiEditorPreview.bas b/InForm/UiEditorPreview.bas index 0173cf9..7d1da62 100644 --- a/InForm/UiEditorPreview.bas +++ b/InForm/UiEditorPreview.bas @@ -979,6 +979,8 @@ SUB __UI_BeforeUpdateDisplay CASE 223 b$ = ReadSequential$(Property$, 2) AlternateNumericOnlyProperty + CASE 225 + ConvertControlToAlternativeType END SELECT __UI_ForceRedraw = True LOOP @@ -1990,6 +1992,8 @@ SUB LoadPreview (Destination AS _BYTE) Control(TempValue).BulletStyle = __UI_Bullet CASE -41 Control(TempValue).AutoScroll = True + CASE -42 + 'ControlIsSelected; ignored; CASE -1 'new control IF LogFileLoad THEN PRINT #LogFileNum, "READ NEW CONTROL: -1" EXIT DO @@ -2700,6 +2704,14 @@ SUB SavePreview (Destination AS _BYTE) Clip$ = Clip$ + b$ END IF END IF + IF Control(i).ControlIsSelected THEN + b$ = MKI$(-42) + IF Disk THEN + 'Don't save this property (design time only) + ELSE + Clip$ = Clip$ + b$ + END IF + END IF END IF NEXT NEXT diff --git a/InForm/docs/frmbin format.txt b/InForm/docs/frmbin format.txt index e824a6e..0898084 100644 --- a/InForm/docs/frmbin format.txt +++ b/InForm/docs/frmbin format.txt @@ -76,5 +76,7 @@ FOR EACH CONTROL (FORM INCLUDED): INTEGER -40 (BulletStyle = __UI_Bullet) INTEGER -41 (AutoScroll = True) For ListBox controls + INTEGER -42 ControlIsSelected + (doesn't get saved; used at design time only) ------------------- INTEGER -1024 (End of file) \ No newline at end of file