mirror of
https://github.com/FellippeHeitor/InForm.git
synced 2025-01-15 11:59:34 +00:00
UiEditorPreview: Constanly inform the editor that a menu is active. Also:
- Accept "new menu bar" and "new menu item" commands. - Automatically adapt menu bar when form colors are changed. - Automatically adapt menu bar when form font is changed.
This commit is contained in:
parent
c1f0eb5770
commit
2ec4a957f1
2 changed files with 54 additions and 6 deletions
|
@ -13,8 +13,9 @@ CONST OffsetNewDataFromPreview = 17
|
||||||
CONST OffsetTotalControlsSelected = 19
|
CONST OffsetTotalControlsSelected = 19
|
||||||
CONST OffsetFormID = 23
|
CONST OffsetFormID = 23
|
||||||
CONST OffsetFirstSelectedID = 27
|
CONST OffsetFirstSelectedID = 27
|
||||||
CONST OffsetPropertyChanged = 31
|
CONST OffsetMenuPanelIsON = 31
|
||||||
CONST OffsetPropertyValue = 33
|
CONST OffsetPropertyChanged = 33
|
||||||
|
CONST OffsetPropertyValue = 35
|
||||||
|
|
||||||
DIM SHARED UiPreviewPID AS LONG
|
DIM SHARED UiPreviewPID AS LONG
|
||||||
DIM SHARED ExeIcon AS LONG
|
DIM SHARED ExeIcon AS LONG
|
||||||
|
@ -79,6 +80,9 @@ SUB __UI_BeforeUpdateDisplay
|
||||||
b$ = MKL$(UiPreviewPID)
|
b$ = MKL$(UiPreviewPID)
|
||||||
SendData b$, OffsetPreviewPID
|
SendData b$, OffsetPreviewPID
|
||||||
|
|
||||||
|
IF __UI_ActiveMenu > 0 AND LEFT$(__UI_Controls(__UI_ParentMenu).Name, 5) <> "__UI_" THEN b$ = MKI$(-1) ELSE b$ = MKI$(0)
|
||||||
|
SendData b$, OffsetMenuPanelIsON
|
||||||
|
|
||||||
UiEditorFile = FREEFILE
|
UiEditorFile = FREEFILE
|
||||||
OPEN "UiEditor.dat" FOR BINARY AS #UiEditorFile
|
OPEN "UiEditor.dat" FOR BINARY AS #UiEditorFile
|
||||||
|
|
||||||
|
@ -140,8 +144,6 @@ SUB __UI_BeforeUpdateDisplay
|
||||||
__UI_SetCaption __UI_Controls(TempValue).Name, RTRIM$(__UI_Controls(TempValue).Name)
|
__UI_SetCaption __UI_Controls(TempValue).Name, RTRIM$(__UI_Controls(TempValue).Name)
|
||||||
CASE __UI_Type_TextBox
|
CASE __UI_Type_TextBox
|
||||||
TempValue = __UI_NewControl(__UI_Type_TextBox, "", 120, 23, TempWidth \ 2 - 60, TempHeight \ 2 - 12, ThisContainer)
|
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("", 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)
|
__UI_SetCaption __UI_Controls(TempValue).Name, RTRIM$(__UI_Controls(TempValue).Name)
|
||||||
CASE __UI_Type_ListBox
|
CASE __UI_Type_ListBox
|
||||||
TempValue = __UI_NewControl(__UI_Type_ListBox, "", 200, 200, TempWidth \ 2 - 100, TempHeight \ 2 - 100, ThisContainer)
|
TempValue = __UI_NewControl(__UI_Type_ListBox, "", 200, 200, TempWidth \ 2 - 100, TempHeight \ 2 - 100, ThisContainer)
|
||||||
|
@ -157,7 +159,21 @@ SUB __UI_BeforeUpdateDisplay
|
||||||
CASE __UI_Type_Frame
|
CASE __UI_Type_Frame
|
||||||
TempValue = __UI_NewControl(TempValue, "", 230, 150, TempWidth \ 2 - 115, TempHeight \ 2 - 75, 0)
|
TempValue = __UI_NewControl(TempValue, "", 230, 150, TempWidth \ 2 - 115, TempHeight \ 2 - 75, 0)
|
||||||
__UI_SetCaption __UI_Controls(TempValue).Name, RTRIM$(__UI_Controls(TempValue).Name)
|
__UI_SetCaption __UI_Controls(TempValue).Name, RTRIM$(__UI_Controls(TempValue).Name)
|
||||||
|
CASE __UI_Type_MenuBar
|
||||||
|
TempValue = __UI_NewControl(TempValue, "", 0, 0, 0, 0, 0)
|
||||||
|
__UI_SetCaption __UI_Controls(TempValue).Name, RTRIM$(__UI_Controls(TempValue).Name)
|
||||||
|
__UI_RefreshMenuBar
|
||||||
|
__UI_ActivateMenu __UI_Controls(TempValue), __UI_False
|
||||||
|
CASE __UI_Type_MenuItem
|
||||||
|
IF __UI_ActiveMenu > 0 AND LEFT$(__UI_Controls(__UI_ParentMenu).Name, 5) <> "__UI_" THEN
|
||||||
|
TempValue = __UI_NewControl(TempValue, "", 0, 0, 0, 0, __UI_ParentMenu)
|
||||||
|
__UI_SetCaption __UI_Controls(TempValue).Name, "New menu item"
|
||||||
|
__UI_ActivateMenu __UI_Controls(__UI_ParentMenu), __UI_False
|
||||||
|
END IF
|
||||||
END SELECT
|
END SELECT
|
||||||
|
IF __UI_ActiveMenu > 0 AND (__UI_Controls(TempValue).Type <> __UI_Type_MenuBar AND __UI_Controls(TempValue).Type <> __UI_Type_MenuItem) THEN
|
||||||
|
__UI_DestroyControl __UI_Controls(__UI_ActiveMenu)
|
||||||
|
END IF
|
||||||
FOR i = 1 TO UBOUND(__UI_Controls)
|
FOR i = 1 TO UBOUND(__UI_Controls)
|
||||||
__UI_Controls(i).ControlIsSelected = __UI_False
|
__UI_Controls(i).ControlIsSelected = __UI_False
|
||||||
NEXT
|
NEXT
|
||||||
|
@ -203,6 +219,9 @@ SUB __UI_BeforeUpdateDisplay
|
||||||
FOR i = 1 TO UBOUND(__UI_Controls)
|
FOR i = 1 TO UBOUND(__UI_Controls)
|
||||||
IF __UI_Controls(i).ControlIsSelected THEN
|
IF __UI_Controls(i).ControlIsSelected THEN
|
||||||
__UI_SetCaption RTRIM$(__UI_Controls(i).Name), b$
|
__UI_SetCaption RTRIM$(__UI_Controls(i).Name), b$
|
||||||
|
IF __UI_Controls(i).Type = __UI_Type_MenuItem THEN
|
||||||
|
__UI_ActivateMenu __UI_Controls(__UI_Controls(i).ParentID), __UI_False
|
||||||
|
END IF
|
||||||
END IF
|
END IF
|
||||||
NEXT
|
NEXT
|
||||||
ELSE
|
ELSE
|
||||||
|
@ -309,6 +328,14 @@ SUB __UI_BeforeUpdateDisplay
|
||||||
NEXT
|
NEXT
|
||||||
ELSE
|
ELSE
|
||||||
__UI_Controls(__UI_FormID).Font = __UI_Font(NewFontFile, NewFontSize, NewFontParameters)
|
__UI_Controls(__UI_FormID).Font = __UI_Font(NewFontFile, NewFontSize, NewFontParameters)
|
||||||
|
DIM MustRedrawMenus AS _BYTE
|
||||||
|
FOR i = 1 TO UBOUND(__UI_Controls)
|
||||||
|
IF __UI_Controls(i).Type = __UI_Type_MenuBar OR __UI_Controls(i).Type = __UI_Type_MenuItem OR __UI_Controls(i).Type = __UI_Type_MenuPanel OR __UI_Controls(i).Type = __UI_Type_ContextMenu THEN
|
||||||
|
__UI_Controls(i).Font = __UI_Font(NewFontFile, NewFontSize, NewFontParameters)
|
||||||
|
MustRedrawMenus = __UI_True
|
||||||
|
END IF
|
||||||
|
NEXT
|
||||||
|
IF MustRedrawMenus THEN __UI_RefreshMenuBar
|
||||||
END IF
|
END IF
|
||||||
END IF
|
END IF
|
||||||
CASE 9 'Tooltip
|
CASE 9 'Tooltip
|
||||||
|
@ -419,6 +446,11 @@ SUB __UI_BeforeUpdateDisplay
|
||||||
NEXT
|
NEXT
|
||||||
ELSE
|
ELSE
|
||||||
__UI_Controls(__UI_FormID).ForeColor = _CV(_UNSIGNED LONG, b$)
|
__UI_Controls(__UI_FormID).ForeColor = _CV(_UNSIGNED LONG, b$)
|
||||||
|
FOR i = 1 TO UBOUND(__UI_Controls)
|
||||||
|
IF __UI_Controls(i).Type = __UI_Type_MenuBar THEN
|
||||||
|
__UI_Controls(i).ForeColor = _CV(_UNSIGNED LONG, b$)
|
||||||
|
END IF
|
||||||
|
NEXT
|
||||||
END IF
|
END IF
|
||||||
CASE 24 'BackColor
|
CASE 24 'BackColor
|
||||||
b$ = SPACE$(4): GET #UiEditorFile, OffsetPropertyValue, b$
|
b$ = SPACE$(4): GET #UiEditorFile, OffsetPropertyValue, b$
|
||||||
|
@ -430,6 +462,11 @@ SUB __UI_BeforeUpdateDisplay
|
||||||
NEXT
|
NEXT
|
||||||
ELSE
|
ELSE
|
||||||
__UI_Controls(__UI_FormID).BackColor = _CV(_UNSIGNED LONG, b$)
|
__UI_Controls(__UI_FormID).BackColor = _CV(_UNSIGNED LONG, b$)
|
||||||
|
FOR i = 1 TO UBOUND(__UI_Controls)
|
||||||
|
IF __UI_Controls(i).Type = __UI_Type_MenuBar THEN
|
||||||
|
__UI_Controls(i).BackColor = _CV(_UNSIGNED LONG, b$)
|
||||||
|
END IF
|
||||||
|
NEXT
|
||||||
END IF
|
END IF
|
||||||
CASE 25 'SelectedForeColor
|
CASE 25 'SelectedForeColor
|
||||||
b$ = SPACE$(4): GET #UiEditorFile, OffsetPropertyValue, b$
|
b$ = SPACE$(4): GET #UiEditorFile, OffsetPropertyValue, b$
|
||||||
|
@ -441,6 +478,11 @@ SUB __UI_BeforeUpdateDisplay
|
||||||
NEXT
|
NEXT
|
||||||
ELSE
|
ELSE
|
||||||
__UI_Controls(__UI_FormID).SelectedForeColor = _CV(_UNSIGNED LONG, b$)
|
__UI_Controls(__UI_FormID).SelectedForeColor = _CV(_UNSIGNED LONG, b$)
|
||||||
|
FOR i = 1 TO UBOUND(__UI_Controls)
|
||||||
|
IF __UI_Controls(i).Type = __UI_Type_MenuBar OR __UI_Controls(i).Type = __UI_Type_MenuItem OR __UI_Controls(i).Type = __UI_Type_MenuPanel OR __UI_Controls(i).Type = __UI_Type_ContextMenu THEN
|
||||||
|
__UI_Controls(i).SelectedForeColor = _CV(_UNSIGNED LONG, b$)
|
||||||
|
END IF
|
||||||
|
NEXT
|
||||||
END IF
|
END IF
|
||||||
CASE 26 'SelectedBackColor
|
CASE 26 'SelectedBackColor
|
||||||
b$ = SPACE$(4): GET #UiEditorFile, OffsetPropertyValue, b$
|
b$ = SPACE$(4): GET #UiEditorFile, OffsetPropertyValue, b$
|
||||||
|
@ -452,6 +494,11 @@ SUB __UI_BeforeUpdateDisplay
|
||||||
NEXT
|
NEXT
|
||||||
ELSE
|
ELSE
|
||||||
__UI_Controls(__UI_FormID).SelectedBackColor = _CV(_UNSIGNED LONG, b$)
|
__UI_Controls(__UI_FormID).SelectedBackColor = _CV(_UNSIGNED LONG, b$)
|
||||||
|
FOR i = 1 TO UBOUND(__UI_Controls)
|
||||||
|
IF __UI_Controls(i).Type = __UI_Type_MenuBar OR __UI_Controls(i).Type = __UI_Type_MenuItem OR __UI_Controls(i).Type = __UI_Type_MenuPanel OR __UI_Controls(i).Type = __UI_Type_ContextMenu THEN
|
||||||
|
__UI_Controls(i).SelectedBackColor = _CV(_UNSIGNED LONG, b$)
|
||||||
|
END IF
|
||||||
|
NEXT
|
||||||
END IF
|
END IF
|
||||||
CASE 27 'BorderColor
|
CASE 27 'BorderColor
|
||||||
b$ = SPACE$(4): GET #UiEditorFile, OffsetPropertyValue, b$
|
b$ = SPACE$(4): GET #UiEditorFile, OffsetPropertyValue, b$
|
||||||
|
@ -493,6 +540,7 @@ SUB __UI_BeforeUpdateDisplay
|
||||||
|
|
||||||
b$ = MKL$(__UI_TotalSelectedControls)
|
b$ = MKL$(__UI_TotalSelectedControls)
|
||||||
PUT #UiEditorFile, OffsetTotalControlsSelected, b$
|
PUT #UiEditorFile, OffsetTotalControlsSelected, b$
|
||||||
|
IF __UI_Controls(__UI_FirstSelectedID).ID = 0 THEN __UI_FirstSelectedID = 0
|
||||||
b$ = MKL$(__UI_FirstSelectedID)
|
b$ = MKL$(__UI_FirstSelectedID)
|
||||||
PUT #UiEditorFile, OffsetFirstSelectedID, b$
|
PUT #UiEditorFile, OffsetFirstSelectedID, b$
|
||||||
b$ = MKL$(__UI_FormID)
|
b$ = MKL$(__UI_FormID)
|
||||||
|
@ -536,7 +584,7 @@ SUB LoadPreview
|
||||||
DIM Dummy AS LONG
|
DIM Dummy AS LONG
|
||||||
DIM BinaryFileNum AS INTEGER, LogFileNum AS INTEGER
|
DIM BinaryFileNum AS INTEGER, LogFileNum AS INTEGER
|
||||||
|
|
||||||
CONST LogFileLoad = __UI_True
|
CONST LogFileLoad = __UI_False
|
||||||
|
|
||||||
IF _FILEEXISTS("UiEditorPreview.frmbin") = 0 THEN
|
IF _FILEEXISTS("UiEditorPreview.frmbin") = 0 THEN
|
||||||
EXIT SUB
|
EXIT SUB
|
||||||
|
|
|
@ -5,5 +5,5 @@ SUB __UI_LoadForm
|
||||||
DIM __UI_NewID AS LONG
|
DIM __UI_NewID AS LONG
|
||||||
|
|
||||||
__UI_NewID = __UI_NewControl(__UI_Type_Form, "Form1", 640, 400, 0, 0,0)
|
__UI_NewID = __UI_NewControl(__UI_Type_Form, "Form1", 640, 400, 0, 0,0)
|
||||||
__UI_Controls(__UI_NewID).Font = __UI_Font("segoeui.ttf", 13, "")
|
__UI_Controls(__UI_NewID).Font = __UI_Font("segoeui.ttf", 12, "")
|
||||||
END SUB
|
END SUB
|
||||||
|
|
Loading…
Reference in a new issue