1
1
Fork 0
mirror of https://github.com/FellippeHeitor/InForm.git synced 2025-01-15 11:59:34 +00:00

UiEditor: New AutoNameControls feature. Also:

- New Align menu, for when the preview window is too small to display the contextual menu.
- The Align menu is automatically opened when the user right clicks the Preview Window, if it's too small.
- Less calls to __UI_GetID inside event procedures.
- A message box now asks user if the current form should be saved upon exiting.
- Display the project's name in the Title bar.
- Display the container's font if a control with the same font is selected.
- Properly enable/disable options when menu bar/menu items are selected.
- First property shown is now Caption, as the new AutoNameControl feature will automatically rename based on captions.
- New event: __UI_TextChanged (for textboxes).
- Color Mixer textboxes are now editable (they were editable before but they didn't trigger a change in the sliders' values).
- $RESIZE is saved within the .frm file, if CanResize is enabled.
- Padding is now properly saved for controls that have it set.
This commit is contained in:
FellippeHeitor 2016-12-05 10:59:23 -02:00
parent b02bc14c2d
commit fd3a270fe3
2 changed files with 266 additions and 44 deletions

View file

@ -9,7 +9,7 @@ DIM SHARED ColorPropertiesListID AS LONG, PropertyValueID AS LONG
DIM SHARED UiPreviewPID AS LONG, TotalSelected AS LONG, FirstSelected AS LONG DIM SHARED UiPreviewPID AS LONG, TotalSelected AS LONG, FirstSelected AS LONG
DIM SHARED PreviewFormID AS LONG, ColorPreviewID AS LONG DIM SHARED PreviewFormID AS LONG, ColorPreviewID AS LONG
DIM SHARED BackStyleListID AS LONG, PropertyUpdateStatusID AS LONG DIM SHARED BackStyleListID AS LONG, PropertyUpdateStatusID AS LONG
DIM SHARED CheckPreviewTimer AS INTEGER, PreviewAttached AS _BYTE DIM SHARED CheckPreviewTimer AS INTEGER, PreviewAttached AS _BYTE, AutoNameControls AS _BYTE
DIM SHARED PropertyUpdateStatusImage AS LONG, LastKeyPress AS DOUBLE DIM SHARED PropertyUpdateStatusImage AS LONG, LastKeyPress AS DOUBLE
DIM SHARED UiEditorTitle$ DIM SHARED UiEditorTitle$
@ -24,8 +24,9 @@ CONST OffsetTotalControlsSelected = 19
CONST OffsetFormID = 23 CONST OffsetFormID = 23
CONST OffsetFirstSelectedID = 27 CONST OffsetFirstSelectedID = 27
CONST OffsetMenuPanelIsON = 31 CONST OffsetMenuPanelIsON = 31
CONST OffsetPropertyChanged = 33 CONST OffsetAutoName = 33
CONST OffsetPropertyValue = 35 CONST OffsetPropertyChanged = 35
CONST OffsetPropertyValue = 37
REDIM SHARED PreviewCaptions(0) AS STRING REDIM SHARED PreviewCaptions(0) AS STRING
REDIM SHARED PreviewTexts(0) AS STRING REDIM SHARED PreviewTexts(0) AS STRING
@ -126,6 +127,25 @@ SUB __UI_Click (id AS LONG)
DIM Answer AS _BYTE, Dummy AS LONG, b$, UiEditorFile AS INTEGER DIM Answer AS _BYTE, Dummy AS LONG, b$, UiEditorFile AS INTEGER
SELECT EVERYCASE UCASE$(RTRIM$(__UI_Controls(id).Name)) SELECT EVERYCASE UCASE$(RTRIM$(__UI_Controls(id).Name))
CASE "ALIGNMENUALIGNLEFT": Dummy = 201
CASE "ALIGNMENUALIGNRIGHT": Dummy = 202
CASE "ALIGNMENUALIGNTOPS": Dummy = 203
CASE "ALIGNMENUALIGNBOTTOMS": Dummy = 204
CASE "ALIGNMENUALIGNCENTERSV": Dummy = 205
CASE "ALIGNMENUALIGNCENTERSH": Dummy = 206
CASE "ALIGNMENUALIGNCENTERV": Dummy = 207
CASE "ALIGNMENUALIGNCENTERH": Dummy = 208
CASE "ALIGNMENUDISTRIBUTEV": Dummy = 209
CASE "ALIGNMENUDISTRIBUTEH": Dummy = 210
CASE "ALIGNMENUALIGNLEFT", "ALIGNMENUALIGNRIGHT", "ALIGNMENUALIGNTOPS", _
"ALIGNMENUALIGNBOTTOMS", "ALIGNMENUALIGNCENTERSV", "ALIGNMENUALIGNCENTERSH", _
"ALIGNMENUALIGNCENTERV", "ALIGNMENUALIGNCENTERH", "ALIGNMENUDISTRIBUTEV", _
"ALIGNMENUDISTRIBUTEH"
b$ = MKI$(0)
SendData b$, Dummy
CASE "OPTIONSMENUAUTONAME"
AutoNameControls = NOT AutoNameControls
__UI_Controls(id).Value = AutoNameControls
CASE "INSERTMENUMENUBAR" CASE "INSERTMENUMENUBAR"
UiEditorFile = FREEFILE UiEditorFile = FREEFILE
OPEN "UiEditor.dat" FOR BINARY AS #UiEditorFile OPEN "UiEditor.dat" FOR BINARY AS #UiEditorFile
@ -140,7 +160,7 @@ SUB __UI_Click (id AS LONG)
CLOSE #UiEditorFile CLOSE #UiEditorFile
CASE "VIEWMENUPREVIEWDETACH" CASE "VIEWMENUPREVIEWDETACH"
PreviewAttached = NOT PreviewAttached PreviewAttached = NOT PreviewAttached
__UI_Controls(__UI_GetID("ViewMenuPreviewDetach")).Value = PreviewAttached __UI_Controls(id).Value = PreviewAttached
CASE "ADDBUTTON": Dummy = __UI_Type_Button CASE "ADDBUTTON": Dummy = __UI_Type_Button
CASE "ADDLABEL": Dummy = __UI_Type_Label CASE "ADDLABEL": Dummy = __UI_Type_Label
CASE "ADDTEXTBOX": Dummy = __UI_Type_TextBox CASE "ADDTEXTBOX": Dummy = __UI_Type_TextBox
@ -161,31 +181,31 @@ SUB __UI_Click (id AS LONG)
PUT #UiEditorFile, OffsetNewControl, b$ PUT #UiEditorFile, OffsetNewControl, b$
CLOSE #UiEditorFile CLOSE #UiEditorFile
CASE "STRETCH" CASE "STRETCH"
b$ = MKI$(__UI_Controls(__UI_GetID("Stretch")).Value) b$ = MKI$(__UI_Controls(id).Value)
SendData b$, 14 SendData b$, 14
CASE "HASBORDER" CASE "HASBORDER"
b$ = MKI$(__UI_Controls(__UI_GetID("HasBorder")).Value) b$ = MKI$(__UI_Controls(id).Value)
SendData b$, 15 SendData b$, 15
CASE "SHOWPERCENTAGE" CASE "SHOWPERCENTAGE"
b$ = MKI$(__UI_Controls(__UI_GetID("ShowPercentage")).Value) b$ = MKI$(__UI_Controls(id).Value)
SendData b$, 16 SendData b$, 16
CASE "WORDWRAP" CASE "WORDWRAP"
b$ = MKI$(__UI_Controls(__UI_GetID("WordWrap")).Value) b$ = MKI$(__UI_Controls(id).Value)
SendData b$, 17 SendData b$, 17
CASE "CANHAVEFOCUS" CASE "CANHAVEFOCUS"
b$ = MKI$(__UI_Controls(__UI_GetID("CanHaveFocus")).Value) b$ = MKI$(__UI_Controls(id).Value)
SendData b$, 18 SendData b$, 18
CASE "DISABLED" CASE "DISABLED"
b$ = MKI$(__UI_Controls(__UI_GetID("Disabled")).Value) b$ = MKI$(__UI_Controls(id).Value)
SendData b$, 19 SendData b$, 19
CASE "HIDDEN" CASE "HIDDEN"
b$ = MKI$(__UI_Controls(__UI_GetID("Hidden")).Value) b$ = MKI$(__UI_Controls(id).Value)
SendData b$, 20 SendData b$, 20
CASE "CENTEREDWINDOW" CASE "CENTEREDWINDOW"
b$ = MKI$(__UI_Controls(__UI_GetID("CenteredWindow")).Value) b$ = MKI$(__UI_Controls(id).Value)
SendData b$, 21 SendData b$, 21
CASE "RESIZABLE" CASE "RESIZABLE"
b$ = MKI$(__UI_Controls(__UI_GetID("Resizable")).Value) b$ = MKI$(__UI_Controls(id).Value)
SendData b$, 29 SendData b$, 29
CASE "VIEWMENUPREVIEW" CASE "VIEWMENUPREVIEW"
$IF WIN THEN $IF WIN THEN
@ -431,13 +451,20 @@ SUB __UI_Click (id AS LONG)
Answer = __UI_MessageBox("File form.frmbin is not valid.", "", __UI_MsgBox_OkOnly + __UI_MsgBox_Critical) Answer = __UI_MessageBox("File form.frmbin is not valid.", "", __UI_MsgBox_OkOnly + __UI_MsgBox_Critical)
CLOSE #1 CLOSE #1
END IF END IF
CASE "FILEMENUNEW"
CASE "FILEMENUSAVE" CASE "FILEMENUSAVE"
SaveForm SaveForm __UI_True
CASE "HELPMENUABOUT" CASE "HELPMENUABOUT"
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) 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" CASE "HELPMENUHELP"
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) 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" CASE "FILEMENUEXIT"
Answer = __UI_MessageBox("Save the current form before leaving?", "", __UI_MsgBox_YesNoCancel + __UI_MsgBox_Question)
IF Answer = __UI_MsgBox_Cancel THEN
EXIT SUB
ELSEIF Answer = __UI_MsgBox_Yes THEN
SaveForm __UI_False
END IF
SYSTEM SYSTEM
END SELECT END SELECT
END SUB END SUB
@ -471,8 +498,8 @@ END SUB
SUB __UI_BeforeUpdateDisplay SUB __UI_BeforeUpdateDisplay
DIM b$, PreviewChanged AS _BYTE, SelectedProperty AS INTEGER, UiEditorFile AS INTEGER DIM b$, PreviewChanged AS _BYTE, SelectedProperty AS INTEGER, UiEditorFile AS INTEGER
DIM PreviewHasMenuActive AS INTEGER DIM PreviewHasMenuActive AS INTEGER, i AS LONG
STATIC MidRead AS _BYTE STATIC MidRead AS _BYTE, PrevFirstSelected AS LONG
IF NOT MidRead THEN IF NOT MidRead THEN
MidRead = __UI_True MidRead = __UI_True
@ -483,10 +510,18 @@ SUB __UI_BeforeUpdateDisplay
$IF WIN THEN $IF WIN THEN
IF PreviewAttached THEN IF PreviewAttached THEN
IF _SCREENX > 0 THEN
b$ = MKI$(_SCREENX) b$ = MKI$(_SCREENX)
ELSE
b$ = MKI$(-1)
END IF
PUT #UiEditorFile, OffsetWindowLeft, b$ PUT #UiEditorFile, OffsetWindowLeft, b$
IF _SCREENY > 0 THEN
b$ = MKI$(_SCREENY) b$ = MKI$(_SCREENY)
ELSE
b$ = MKI$(-1)
END IF
PUT #UiEditorFile, OffsetWindowTop, b$ PUT #UiEditorFile, OffsetWindowTop, b$
ELSE ELSE
b$ = MKI$(-1) b$ = MKI$(-1)
@ -495,10 +530,20 @@ SUB __UI_BeforeUpdateDisplay
END IF END IF
$END IF $END IF
b$ = MKI$(AutoNameControls)
PUT #UiEditorFile, OffsetAutoName, b$
'Controls in the editor lose focus when the preview is manipulated 'Controls in the editor lose focus when the preview is manipulated
b$ = SPACE$(2): GET #UiEditorFile, OffsetNewDataFromPreview, b$ b$ = SPACE$(2): GET #UiEditorFile, OffsetNewDataFromPreview, b$
IF CVI(b$) = -1 THEN IF CVI(b$) = -1 THEN
__UI_Focus = 0 IF __UI_ActiveMenu = 0 THEN __UI_Focus = 0
b$ = MKI$(0): PUT #UiEditorFile, OffsetNewDataFromPreview, b$
ELSEIF CVI(b$) = -2 THEN
'User attempted to right-click a control but the preview
'form is smaller than the menu panel. In such case the "Align"
'menu is shown in the editor.
__UI_ActivateMenu __UI_Controls(__UI_GetID("AlignMenu")), __UI_False
__UI_ForceRedraw = __UI_True
b$ = MKI$(0): PUT #UiEditorFile, OffsetNewDataFromPreview, b$ b$ = MKI$(0): PUT #UiEditorFile, OffsetNewDataFromPreview, b$
END IF END IF
@ -508,9 +553,17 @@ SUB __UI_BeforeUpdateDisplay
PreviewFormID = CVL(b$) PreviewFormID = CVL(b$)
b$ = SPACE$(4): GET #UiEditorFile, OffsetFirstSelectedID, b$ b$ = SPACE$(4): GET #UiEditorFile, OffsetFirstSelectedID, b$
FirstSelected = CVL(b$) FirstSelected = CVL(b$)
IF PrevFirstSelected <> FirstSelected THEN
PrevFirstSelected = FirstSelected
__UI_ForceRedraw = __UI_True
END IF
b$ = SPACE$(2): GET #UiEditorFile, OffsetMenuPanelIsON, b$ b$ = SPACE$(2): GET #UiEditorFile, OffsetMenuPanelIsON, b$
PreviewHasMenuActive = CVI(b$) PreviewHasMenuActive = CVI(b$)
IF LEN(RTRIM$(__UI_TrimAt0$(PreviewControls(PreviewFormID).Name))) > 0 THEN
__UI_Captions(__UI_FormID) = UiEditorTitle$ + " - " + RTRIM$(PreviewControls(PreviewFormID).Name) + ".frm"
END IF
SelectedProperty = __UI_Controls(__UI_GetID("PropertiesList")).Value SelectedProperty = __UI_Controls(__UI_GetID("PropertiesList")).Value
IF PreviewHasMenuActive THEN IF PreviewHasMenuActive THEN
@ -522,12 +575,68 @@ SUB __UI_BeforeUpdateDisplay
IF TotalSelected = 0 THEN IF TotalSelected = 0 THEN
__UI_SetCaption "PropertiesFrame", "Control properties: " + RTRIM$(PreviewControls(PreviewFormID).Name) __UI_SetCaption "PropertiesFrame", "Control properties: " + RTRIM$(PreviewControls(PreviewFormID).Name)
FirstSelected = PreviewFormID FirstSelected = PreviewFormID
__UI_Controls(__UI_GetID("AlignMenuAlignLeft")).Disabled = __UI_True
__UI_Controls(__UI_GetID("AlignMenuAlignRight")).Disabled = __UI_True
__UI_Controls(__UI_GetID("AlignMenuAlignTops")).Disabled = __UI_True
__UI_Controls(__UI_GetID("AlignMenuAlignBottoms")).Disabled = __UI_True
__UI_Controls(__UI_GetID("AlignMenuAlignCenterV")).Disabled = __UI_True
__UI_Controls(__UI_GetID("AlignMenuAlignCenterH")).Disabled = __UI_True
__UI_Controls(__UI_GetID("AlignMenuAlignCentersV")).Disabled = __UI_True
__UI_Controls(__UI_GetID("AlignMenuAlignCentersH")).Disabled = __UI_True
__UI_Controls(__UI_GetID("AlignMenuDistributeV")).Disabled = __UI_True
__UI_Controls(__UI_GetID("AlignMenuDistributeH")).Disabled = __UI_True
ELSEIF TotalSelected = 1 THEN ELSEIF TotalSelected = 1 THEN
IF FirstSelected > 0 AND FirstSelected <= UBOUND(PreviewControls) THEN IF FirstSelected > 0 AND FirstSelected <= UBOUND(PreviewControls) THEN
__UI_SetCaption "PropertiesFrame", "Control properties: " + RTRIM$(PreviewControls(FirstSelected).Name) __UI_SetCaption "PropertiesFrame", "Control properties: " + RTRIM$(PreviewControls(FirstSelected).Name)
__UI_Controls(__UI_GetID("AlignMenuAlignLeft")).Disabled = __UI_True
__UI_Controls(__UI_GetID("AlignMenuAlignRight")).Disabled = __UI_True
__UI_Controls(__UI_GetID("AlignMenuAlignTops")).Disabled = __UI_True
__UI_Controls(__UI_GetID("AlignMenuAlignBottoms")).Disabled = __UI_True
IF PreviewControls(FirstSelected).Type <> __UI_Type_MenuBar AND PreviewControls(FirstSelected).Type <> __UI_Type_MenuItem THEN
__UI_Controls(__UI_GetID("AlignMenuAlignCenterV")).Disabled = __UI_False
__UI_Controls(__UI_GetID("AlignMenuAlignCenterH")).Disabled = __UI_False
ELSE
__UI_Controls(__UI_GetID("AlignMenuAlignCenterV")).Disabled = __UI_True
__UI_Controls(__UI_GetID("AlignMenuAlignCenterH")).Disabled = __UI_True
END IF END IF
__UI_Controls(__UI_GetID("AlignMenuAlignCentersV")).Disabled = __UI_True
__UI_Controls(__UI_GetID("AlignMenuAlignCentersH")).Disabled = __UI_True
__UI_Controls(__UI_GetID("AlignMenuDistributeV")).Disabled = __UI_True
__UI_Controls(__UI_GetID("AlignMenuDistributeH")).Disabled = __UI_True
END IF
ELSEIF TotalSelected = 2 THEN
__UI_SetCaption "PropertiesFrame", "Control properties: (multiple selection)"
__UI_Controls(__UI_GetID("AlignMenuAlignLeft")).Disabled = __UI_False
__UI_Controls(__UI_GetID("AlignMenuAlignRight")).Disabled = __UI_False
__UI_Controls(__UI_GetID("AlignMenuAlignTops")).Disabled = __UI_False
__UI_Controls(__UI_GetID("AlignMenuAlignBottoms")).Disabled = __UI_False
__UI_Controls(__UI_GetID("AlignMenuAlignCenterV")).Disabled = __UI_False
__UI_Controls(__UI_GetID("AlignMenuAlignCenterH")).Disabled = __UI_False
__UI_Controls(__UI_GetID("AlignMenuAlignCentersV")).Disabled = __UI_False
__UI_Controls(__UI_GetID("AlignMenuAlignCentersH")).Disabled = __UI_False
__UI_Controls(__UI_GetID("AlignMenuDistributeV")).Disabled = __UI_True
__UI_Controls(__UI_GetID("AlignMenuDistributeH")).Disabled = __UI_True
ELSE ELSE
__UI_SetCaption "PropertiesFrame", "Control properties: (multiple selection)" __UI_SetCaption "PropertiesFrame", "Control properties: (multiple selection)"
__UI_Controls(__UI_GetID("AlignMenuAlignLeft")).Disabled = __UI_False
__UI_Controls(__UI_GetID("AlignMenuAlignRight")).Disabled = __UI_False
__UI_Controls(__UI_GetID("AlignMenuAlignTops")).Disabled = __UI_False
__UI_Controls(__UI_GetID("AlignMenuAlignBottoms")).Disabled = __UI_False
__UI_Controls(__UI_GetID("AlignMenuAlignCenterV")).Disabled = __UI_False
__UI_Controls(__UI_GetID("AlignMenuAlignCenterH")).Disabled = __UI_False
__UI_Controls(__UI_GetID("AlignMenuAlignCentersV")).Disabled = __UI_False
__UI_Controls(__UI_GetID("AlignMenuAlignCentersH")).Disabled = __UI_False
__UI_Controls(__UI_GetID("AlignMenuDistributeV")).Disabled = __UI_False
__UI_Controls(__UI_GetID("AlignMenuDistributeH")).Disabled = __UI_False
END IF END IF
IF FirstSelected = 0 THEN FirstSelected = PreviewFormID IF FirstSelected = 0 THEN FirstSelected = PreviewFormID
@ -553,7 +662,11 @@ SUB __UI_BeforeUpdateDisplay
CASE 7 'Height CASE 7 'Height
__UI_Texts(PropertyValueID) = LTRIM$(STR$(PreviewControls(FirstSelected).Height)) __UI_Texts(PropertyValueID) = LTRIM$(STR$(PreviewControls(FirstSelected).Height))
CASE 8 'Font CASE 8 'Font
IF LEN(PreviewFonts(FirstSelected)) > 0 THEN
__UI_Texts(PropertyValueID) = PreviewFonts(FirstSelected) __UI_Texts(PropertyValueID) = PreviewFonts(FirstSelected)
ELSE
__UI_Texts(PropertyValueID) = PreviewFonts(PreviewFormID)
END IF
CASE 9 'Tooltip CASE 9 'Tooltip
__UI_Texts(PropertyValueID) = PreviewTips(FirstSelected) __UI_Texts(PropertyValueID) = PreviewTips(FirstSelected)
CASE 10 'Value CASE 10 'Value
@ -591,7 +704,11 @@ SUB __UI_BeforeUpdateDisplay
CASE 7 'Height CASE 7 'Height
IF __UI_Texts(PropertyValueID) = LTRIM$(STR$(PreviewControls(FirstSelected).Height)) THEN PropertyAccept = __UI_True IF __UI_Texts(PropertyValueID) = LTRIM$(STR$(PreviewControls(FirstSelected).Height)) THEN PropertyAccept = __UI_True
CASE 8 'Font CASE 8 'Font
IF LEN(PreviewFonts(FirstSelected)) > 0 THEN
IF LCASE$(__UI_Texts(PropertyValueID)) = LCASE$(PreviewFonts(FirstSelected)) THEN PropertyAccept = __UI_True IF LCASE$(__UI_Texts(PropertyValueID)) = LCASE$(PreviewFonts(FirstSelected)) THEN PropertyAccept = __UI_True
ELSE
IF LCASE$(__UI_Texts(PropertyValueID)) = LCASE$(PreviewFonts(PreviewFormID)) THEN PropertyAccept = __UI_True
END IF
CASE 9 'Tooltip CASE 9 'Tooltip
IF __UI_Texts(PropertyValueID) = PreviewTips(FirstSelected) THEN PropertyAccept = __UI_True IF __UI_Texts(PropertyValueID) = PreviewTips(FirstSelected) THEN PropertyAccept = __UI_True
CASE 10 'Value CASE 10 'Value
@ -610,11 +727,11 @@ SUB __UI_BeforeUpdateDisplay
CLS , _RGBA32(0, 0, 0, 0) CLS , _RGBA32(0, 0, 0, 0)
IF PropertyAccept AND LEN(RTRIM$(__UI_Texts(PropertyValueID))) > 0 THEN IF PropertyAccept AND LEN(RTRIM$(__UI_Texts(PropertyValueID))) > 0 THEN
_PUTIMAGE (0, 0), PropertyUpdateStatusImage, , (0, 0)-STEP(15, 15) _PUTIMAGE (0, 0), PropertyUpdateStatusImage, , (0, 0)-STEP(15, 15)
__UI_SetTip "PropertyUpdateStatus", "The property value entered is valid" __UI_SetTip "PropertyUpdateStatus", "The property value entered was accepted"
ELSEIF LEN(RTRIM$(__UI_Texts(PropertyValueID))) > 0 THEN ELSEIF LEN(RTRIM$(__UI_Texts(PropertyValueID))) > 0 THEN
IF TIMER - LastKeyPress > .5 THEN IF TIMER - LastKeyPress > .5 THEN
_PUTIMAGE (0, 0), PropertyUpdateStatusImage, , (0, 16)-STEP(15, 15) _PUTIMAGE (0, 0), PropertyUpdateStatusImage, , (0, 16)-STEP(15, 15)
__UI_SetTip "PropertyUpdateStatus", "Invalid property value" __UI_SetTip "PropertyUpdateStatus", "Property value not accepted"
ELSE ELSE
_PUTIMAGE (0, 0), PropertyUpdateStatusImage, , (0, 32)-STEP(15, 15) _PUTIMAGE (0, 0), PropertyUpdateStatusImage, , (0, 32)-STEP(15, 15)
__UI_SetTip "PropertyUpdateStatus", "" __UI_SetTip "PropertyUpdateStatus", ""
@ -657,6 +774,32 @@ SUB __UI_BeforeUpdateDisplay
__UI_Captions(PropertyValueID) = "" __UI_Captions(PropertyValueID) = ""
IF TotalSelected > 0 THEN IF TotalSelected > 0 THEN
SELECT EVERYCASE PreviewControls(FirstSelected).Type SELECT EVERYCASE PreviewControls(FirstSelected).Type
CASE __UI_Type_MenuBar, __UI_Type_MenuItem
__UI_Controls(__UI_GetID("Disabled")).Disabled = __UI_False
__UI_Controls(__UI_GetID("Hidden")).Disabled = __UI_False
CASE __UI_Type_MenuBar
'Check if this is the last menu bar item so that Align options can be enabled
FOR i = UBOUND(PreviewControls) TO 1 STEP -1
IF PreviewControls(i).ID > 0 AND PreviewControls(i).Type = __UI_Type_MenuBar THEN
EXIT FOR
END IF
NEXT
IF i = FirstSelected THEN
__UI_Controls(__UI_GetID("AlignOptions")).Disabled = __UI_False
END IF
SELECT CASE SelectedProperty
CASE 1, 2, 9
__UI_Controls(PropertyValueID).Disabled = __UI_False
CASE ELSE
__UI_Controls(PropertyValueID).Disabled = __UI_True
END SELECT
CASE __UI_Type_MenuItem
SELECT CASE SelectedProperty
CASE 1, 2, 3, 9, 10
__UI_Controls(PropertyValueID).Disabled = __UI_False
CASE ELSE
__UI_Controls(PropertyValueID).Disabled = __UI_True
END SELECT
CASE __UI_Type_PictureBox CASE __UI_Type_PictureBox
__UI_ReplaceListBoxItem "PropertiesList", 3, "Image file" __UI_ReplaceListBoxItem "PropertiesList", 3, "Image file"
__UI_Controls(__UI_GetID("Stretch")).Disabled = __UI_False __UI_Controls(__UI_GetID("Stretch")).Disabled = __UI_False
@ -677,7 +820,7 @@ SUB __UI_BeforeUpdateDisplay
END SELECT END SELECT
CASE __UI_Type_TextBox CASE __UI_Type_TextBox
__UI_Controls(BackStyleListID).Disabled = __UI_False __UI_Controls(BackStyleListID).Disabled = __UI_False
CASE __UI_Type_Button CASE __UI_Type_Button, __UI_Type_MenuItem
__UI_ReplaceListBoxItem "PropertiesList", 3, "Image file" __UI_ReplaceListBoxItem "PropertiesList", 3, "Image file"
CASE __UI_Type_Button, __UI_Type_TextBox CASE __UI_Type_Button, __UI_Type_TextBox
SELECT CASE SelectedProperty SELECT CASE SelectedProperty
@ -820,13 +963,13 @@ SUB __UI_BeforeUpdateDisplay
END SUB END SUB
SUB __UI_BeforeUnload SUB __UI_BeforeUnload
'DIM Answer AS _BYTE DIM Answer AS _BYTE
'Answer = __UI_MessageBox("Leaving UI", "Copy current form data to clipboard?", __UI_MsgBox_YesNoCancel + __UI_MsgBox_Question) Answer = __UI_MessageBox("Save the current form before leaving?", "", __UI_MsgBox_YesNoCancel + __UI_MsgBox_Question)
'IF Answer = __UI_MsgBox_Cancel THEN IF Answer = __UI_MsgBox_Cancel THEN
' __UI_UnloadSignal = __UI_False __UI_UnloadSignal = __UI_False
'ELSEIF Answer = __UI_MsgBox_Yes THEN ELSEIF Answer = __UI_MsgBox_Yes THEN
' Answer = __UI_MessageBox("Leaving UI", "Not yet implemented", __UI_MsgBox_OkOnly + __UI_MsgBox_Information) SaveForm __UI_False
'END IF END IF
END SUB END SUB
SUB __UI_BeforeInit SUB __UI_BeforeInit
@ -896,9 +1039,10 @@ SUB __UI_OnLoad
PropertyValueID = __UI_GetID("PropertyValue") PropertyValueID = __UI_GetID("PropertyValue")
PropertyUpdateStatusID = __UI_GetID("PropertyUpdateStatus") PropertyUpdateStatusID = __UI_GetID("PropertyUpdateStatus")
__UI_Controls(PropertyValueID).FieldArea = __UI_Controls(PropertyValueID).Width / _FONTWIDTH((__UI_Controls(PropertyValueID).Font)) - 4 __UI_Controls(__UI_GetID("PropertiesList")).Value = 2
PreviewAttached = __UI_True PreviewAttached = __UI_True
AutoNameControls = __UI_True
IF _FILEEXISTS("UiEditorPreview.frmbin") THEN KILL "UiEditorPreview.frmbin" IF _FILEEXISTS("UiEditorPreview.frmbin") THEN KILL "UiEditorPreview.frmbin"
@ -985,6 +1129,12 @@ END SUB
SUB __UI_KeyPress (id AS LONG) SUB __UI_KeyPress (id AS LONG)
LastKeyPress = TIMER LastKeyPress = TIMER
SELECT CASE UCASE$(RTRIM$(__UI_Controls(id).Name)) SELECT CASE UCASE$(RTRIM$(__UI_Controls(id).Name))
CASE "PROPERTYVALUE"
END SELECT
END SUB
SUB __UI_TextChanged (id AS LONG)
SELECT EVERYCASE UCASE$(RTRIM$(__UI_Controls(id).Name))
CASE "PROPERTYVALUE" CASE "PROPERTYVALUE"
'Send the preview the new property value 'Send the preview the new property value
DIM FloatValue AS _FLOAT, b$, TempValue AS LONG, i AS LONG DIM FloatValue AS _FLOAT, b$, TempValue AS LONG, i AS LONG
@ -1006,6 +1156,12 @@ SUB __UI_KeyPress (id AS LONG)
END SELECT END SELECT
SendData b$, TempValue SendData b$, TempValue
END IF END IF
CASE "REDVALUE", "GREENVALUE", "BLUEVALUE"
IF VAL(__UI_Texts(id)) > 255 THEN __UI_Texts(id) = "255"
DIM TempID AS LONG
TempID = __UI_GetID(LEFT$(UCASE$(RTRIM$(__UI_Controls(id).Name)), LEN(UCASE$(RTRIM$(__UI_Controls(id).Name))) - 5))
__UI_Controls(TempID).Value = VAL(__UI_Texts(id))
__UI_MouseUp TempID
END SELECT END SELECT
END SUB END SUB
@ -1522,7 +1678,7 @@ SUB CheckPreview
$END IF $END IF
END SUB END SUB
SUB SaveForm SUB SaveForm (ExitToQB64 AS _BYTE)
DIM BaseOutputFileName AS STRING, BinaryFileNum AS INTEGER DIM BaseOutputFileName AS STRING, BinaryFileNum AS INTEGER
DIM TextFileNum AS INTEGER, Answer AS _BYTE, b$, i AS LONG DIM TextFileNum AS INTEGER, Answer AS _BYTE, b$, i AS LONG
DIM a$, FontSetup$, FindSep AS INTEGER, NewFontFile AS STRING DIM a$, FontSetup$, FindSep AS INTEGER, NewFontFile AS STRING
@ -1547,6 +1703,9 @@ SUB SaveForm
PRINT #TextFileNum, " $EXEICON:'" + PreviewTexts(PreviewFormID) + "'" PRINT #TextFileNum, " $EXEICON:'" + PreviewTexts(PreviewFormID) + "'"
PRINT #TextFileNum, " _ICON" PRINT #TextFileNum, " _ICON"
END IF END IF
IF PreviewControls(PreviewFormID).CanResize THEN
PRINT #TextFileNum, " $RESIZE:ON"
END IF
PRINT #TextFileNum, " DIM __UI_NewID AS LONG" PRINT #TextFileNum, " DIM __UI_NewID AS LONG"
PRINT #TextFileNum, PRINT #TextFileNum,
b$ = "InForm" + CHR$(1) b$ = "InForm" + CHR$(1)
@ -1776,6 +1935,10 @@ SUB SaveForm
PRINT #TextFileNum, " __UI_Controls(__UI_NewID).CanResize = __UI_True" PRINT #TextFileNum, " __UI_Controls(__UI_NewID).CanResize = __UI_True"
b$ = MKI$(-29): PUT #BinaryFileNum, , b$ b$ = MKI$(-29): PUT #BinaryFileNum, , b$
END IF END IF
IF PreviewControls(i).Padding > 0 THEN
PRINT #TextFileNum, " __UI_Controls(__UI_NewID).Padding = " + LTRIM$(STR$(PreviewControls(i).Padding))
b$ = MKI$(-31) + MKI$(PreviewControls(i).Padding): PUT #BinaryFileNum, , b$
END IF
PRINT #TextFileNum, PRINT #TextFileNum,
END IF END IF
EndOfThisPass: EndOfThisPass:
@ -1795,7 +1958,7 @@ SUB SaveForm
PRINT #TextFileNum, "'$INCLUDE:'xp.uitheme'" PRINT #TextFileNum, "'$INCLUDE:'xp.uitheme'"
PRINT #TextFileNum, PRINT #TextFileNum,
PRINT #TextFileNum, "'Event procedures: ---------------------------------------------------------------" PRINT #TextFileNum, "'Event procedures: ---------------------------------------------------------------"
FOR i = 0 TO 12 FOR i = 0 TO 13
SELECT EVERYCASE i SELECT EVERYCASE i
CASE 0: PRINT #TextFileNum, "SUB __UI_BeforeInit" CASE 0: PRINT #TextFileNum, "SUB __UI_BeforeInit"
CASE 1: PRINT #TextFileNum, "SUB __UI_OnLoad" CASE 1: PRINT #TextFileNum, "SUB __UI_OnLoad"
@ -1809,7 +1972,8 @@ SUB SaveForm
CASE 9: PRINT #TextFileNum, "SUB __UI_MouseDown (id AS LONG)" CASE 9: PRINT #TextFileNum, "SUB __UI_MouseDown (id AS LONG)"
CASE 10: PRINT #TextFileNum, "SUB __UI_MouseUp (id AS LONG)" CASE 10: PRINT #TextFileNum, "SUB __UI_MouseUp (id AS LONG)"
CASE 11: PRINT #TextFileNum, "SUB __UI_KeyPress (id AS LONG)" CASE 11: PRINT #TextFileNum, "SUB __UI_KeyPress (id AS LONG)"
CASE 12: PRINT #TextFileNum, "SUB __UI_ValueChanged (id AS LONG)" CASE 12: PRINT #TextFileNum, "SUB __UI_TextChanged (id AS LONG)"
CASE 13: PRINT #TextFileNum, "SUB __UI_ValueChanged (id AS LONG)"
CASE 0 TO 3 CASE 0 TO 3
PRINT #TextFileNum, PRINT #TextFileNum,
@ -1834,7 +1998,17 @@ SUB SaveForm
NEXT NEXT
PRINT #TextFileNum, " END SELECT" PRINT #TextFileNum, " END SELECT"
CASE 12 'Dropdown list, List box and Track bar CASE 12 'Text boxes
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_TextBox) THEN
PRINT #TextFileNum, " CASE " + CHR$(34) + UCASE$(RTRIM$(PreviewControls(Dummy).Name)) + CHR$(34)
PRINT #TextFileNum,
END IF
NEXT
PRINT #TextFileNum, " END SELECT"
CASE 13 'Dropdown list, List box and Track bar
PRINT #TextFileNum, " SELECT CASE UCASE$(RTRIM$(__UI_Controls(id).Name))" PRINT #TextFileNum, " SELECT CASE UCASE$(RTRIM$(__UI_Controls(id).Name))"
FOR Dummy = 1 TO UBOUND(PreviewControls) 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 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
@ -1848,6 +2022,7 @@ SUB SaveForm
PRINT #TextFileNum, PRINT #TextFileNum,
NEXT NEXT
CLOSE #TextFileNum CLOSE #TextFileNum
IF ExitToQB64 THEN
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) 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 Answer = __UI_MsgBox_No THEN EXIT SUB
$IF WIN THEN $IF WIN THEN
@ -1856,6 +2031,9 @@ SUB SaveForm
SHELL _DONTWAIT "./qb64 " + BaseOutputFileName + ".bas" SHELL _DONTWAIT "./qb64 " + BaseOutputFileName + ".bas"
$END IF $END IF
SYSTEM SYSTEM
ELSE
Answer = __UI_MessageBox("Exporting successful. Files output:" + CHR$(10) + " " + BaseOutputFileName + ".bas" + CHR$(10) + " " + BaseOutputFileName + ".frm" + CHR$(10) + " " + BaseOutputFileName + ".frmbin", "", __UI_MsgBox_OkOnly + __UI_MsgBox_Information)
END IF
END SUB END SUB
SUB SaveSelf SUB SaveSelf

View file

@ -18,6 +18,12 @@ SUB __UI_LoadForm
__UI_NewID = __UI_NewControl(__UI_Type_MenuBar, "InsertMenu", 44, 18, 52, 0, 0) __UI_NewID = __UI_NewControl(__UI_Type_MenuBar, "InsertMenu", 44, 18, 52, 0, 0)
__UI_SetCaption "InsertMenu", "&Insert" __UI_SetCaption "InsertMenu", "&Insert"
__UI_NewID = __UI_NewControl(__UI_Type_MenuBar, "AlignMenu", 0, 0, 0, 0, 0)
__UI_SetCaption "AlignMenu", "Align"
__UI_NewID = __UI_NewControl(__UI_Type_MenuBar, "OptionsMenu", 44, 18, 52, 0, 0)
__UI_SetCaption "OptionsMenu", "&Options"
__UI_NewID = __UI_NewControl(__UI_Type_MenuBar, "HelpMenu", 44, 18, 545, 0, 0) __UI_NewID = __UI_NewControl(__UI_Type_MenuBar, "HelpMenu", 44, 18, 545, 0, 0)
__UI_SetCaption "HelpMenu", "&Help" __UI_SetCaption "HelpMenu", "&Help"
__UI_Controls(__UI_NewID).Align = __UI_Right __UI_Controls(__UI_NewID).Align = __UI_Right
@ -33,6 +39,9 @@ SUB __UI_LoadForm
__UI_SetCaption "ColorMixer", "Color mixer" __UI_SetCaption "ColorMixer", "Color mixer"
__UI_Controls(__UI_NewID).HasBorder = __UI_True __UI_Controls(__UI_NewID).HasBorder = __UI_True
'__UI_NewID = __UI_NewControl(__UI_Type_MenuItem, "FileMenuNew", 91, 18, 0, 22, __UI_GetID("FileMenu"))
'__UI_SetCaption "FileMenuNew", "&New"
__UI_NewID = __UI_NewControl(__UI_Type_MenuItem, "FileMenuSave", 91, 18, 0, 22, __UI_GetID("FileMenu")) __UI_NewID = __UI_NewControl(__UI_Type_MenuItem, "FileMenuSave", 91, 18, 0, 22, __UI_GetID("FileMenu"))
__UI_SetCaption "FileMenuSave", "&Save form-" __UI_SetCaption "FileMenuSave", "&Save form-"
__UI_LoadImage __UI_Controls(__UI_NewID), "InForm\disk.png" __UI_LoadImage __UI_Controls(__UI_NewID), "InForm\disk.png"
@ -57,6 +66,41 @@ SUB __UI_LoadForm
__UI_SetCaption "InsertMenuMenuItem", "Menu &Item" __UI_SetCaption "InsertMenuMenuItem", "Menu &Item"
__UI_Controls(__UI_NewID).Disabled = __UI_True __UI_Controls(__UI_NewID).Disabled = __UI_True
__UI_NewID = __UI_NewControl(__UI_Type_MenuItem, "AlignMenuAlignLeft", 0, 0, 0, 0, __UI_GetID("AlignMenu"))
__UI_SetCaption "AlignMenuAlignLeft", "Align &Left"
__UI_NewID = __UI_NewControl(__UI_Type_MenuItem, "AlignMenuAlignRight", 0, 0, 0, 0, __UI_GetID("AlignMenu"))
__UI_SetCaption "AlignMenuAlignRight", "Align &Right"
__UI_NewID = __UI_NewControl(__UI_Type_MenuItem, "AlignMenuAlignTops", 0, 0, 0, 0, __UI_GetID("AlignMenu"))
__UI_SetCaption "AlignMenuAlignTops", "Align T&op"
__UI_NewID = __UI_NewControl(__UI_Type_MenuItem, "AlignMenuAlignBottoms", 0, 0, 0, 0, __UI_GetID("AlignMenu"))
__UI_SetCaption "AlignMenuAlignBottoms", "Align &Bottom-"
__UI_NewID = __UI_NewControl(__UI_Type_MenuItem, "AlignMenuAlignCentersV", 0, 0, 0, 0, __UI_GetID("AlignMenu"))
__UI_SetCaption "AlignMenuAlignCentersV", "Align cent&ers Vertically"
__UI_NewID = __UI_NewControl(__UI_Type_MenuItem, "AlignMenuAlignCentersH", 0, 0, 0, 0, __UI_GetID("AlignMenu"))
__UI_SetCaption "AlignMenuAlignCentersH", "Ali&gn centers Horizontally"
__UI_NewID = __UI_NewControl(__UI_Type_MenuItem, "AlignMenuAlignCenterV", 0, 0, 0, 0, __UI_GetID("AlignMenu"))
__UI_SetCaption "AlignMenuAlignCenterV", "Center &Vertically"
__UI_NewID = __UI_NewControl(__UI_Type_MenuItem, "AlignMenuAlignCenterH", 0, 0, 0, 0, __UI_GetID("AlignMenu"))
__UI_SetCaption "AlignMenuAlignCenterH", "Center &Horizontally-"
__UI_NewID = __UI_NewControl(__UI_Type_MenuItem, "AlignMenuDistributeV", 0, 0, 0, 0, __UI_GetID("AlignMenu"))
__UI_SetCaption "AlignMenuDistributeV", "Distribute Ver&tically"
__UI_NewID = __UI_NewControl(__UI_Type_MenuItem, "AlignMenuDistributeH", 0, 0, 0, 0, __UI_GetID("AlignMenu"))
__UI_SetCaption "AlignMenuDistributeH", "Distribute Hori&zontally"
__UI_NewID = __UI_NewControl(__UI_Type_MenuItem, "OptionsMenuAutoName", 0, 0, 0, 0, __UI_GetID("OptionsMenu"))
__UI_SetCaption "OptionsMenuAutoName", "&Auto-name controls"
__UI_Controls(__UI_NewID).Value = __UI_True
__UI_SetTip "OptionsMenuAutoName", "Automatically set control names based on caption and type"
__UI_NewID = __UI_NewControl(__UI_Type_MenuItem, "HelpMenuHelp", 0, 0, 0, 0, __UI_GetID("HelpMenu")) __UI_NewID = __UI_NewControl(__UI_Type_MenuItem, "HelpMenuHelp", 0, 0, 0, 0, __UI_GetID("HelpMenu"))
__UI_SetCaption "HelpMenuHelp", "&What's all this?" __UI_SetCaption "HelpMenuHelp", "&What's all this?"