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

Fixes and improvements to UiEditorPreview:

- Segoe UI is now used as default font for new forms.
- Fix: preview window now properly reloads if inadvertenly closed.
- Internal contextual menus are not saved any longer.
This commit is contained in:
FellippeHeitor 2016-11-21 23:20:13 -02:00
parent abcdebbf73
commit a91c32c8b1
2 changed files with 42 additions and 37 deletions

View file

@ -30,6 +30,7 @@ $ELSE
FUNCTION PROCESS_CLOSED& ALIAS kill (BYVAL pid AS INTEGER, BYVAL signal AS INTEGER) FUNCTION PROCESS_CLOSED& ALIAS kill (BYVAL pid AS INTEGER, BYVAL signal AS INTEGER)
END DECLARE END DECLARE
$END IF $END IF
'$include:'InForm.ui' '$include:'InForm.ui'
'$include:'UiEditorPreview.frm' '$include:'UiEditorPreview.frm'
'$include:'xp.uitheme' '$include:'xp.uitheme'
@ -512,15 +513,15 @@ SUB __UI_BeforeUnload
'END IF 'END IF
END SUB END SUB
SUB __UI_OnLoad SUB __UI_BeforeInit
DIM b$
__UI_DesignMode = __UI_True __UI_DesignMode = __UI_True
UiPreviewPID = __UI_GetPID UiPreviewPID = __UI_GetPID
LoadPreview LoadPreview
END SUB END SUB
SUB __UI_OnLoad
END SUB
SUB __UI_KeyPress (id AS LONG) SUB __UI_KeyPress (id AS LONG)
END SUB END SUB
@ -532,9 +533,10 @@ SUB LoadPreview
DIM NewType AS INTEGER, NewWidth AS INTEGER, NewHeight AS INTEGER DIM NewType AS INTEGER, NewWidth AS INTEGER, NewHeight AS INTEGER
DIM NewLeft AS INTEGER, NewTop AS INTEGER, NewName AS STRING DIM NewLeft AS INTEGER, NewTop AS INTEGER, NewName AS STRING
DIM NewParentID AS STRING, FloatValue AS _FLOAT, TempValue AS LONG DIM NewParentID AS STRING, FloatValue AS _FLOAT, TempValue AS LONG
DIM Dummy AS LONG
DIM BinaryFileNum AS INTEGER, LogFileNum AS INTEGER DIM BinaryFileNum AS INTEGER, LogFileNum AS INTEGER
CONST LogFileLoad = __UI_False CONST LogFileLoad = __UI_True
IF _FILEEXISTS("UiEditorPreview.frmbin") = 0 THEN IF _FILEEXISTS("UiEditorPreview.frmbin") = 0 THEN
EXIT SUB EXIT SUB
@ -551,8 +553,10 @@ SUB LoadPreview
END IF END IF
IF LogFileLoad THEN PRINT #LogFileNum, "FOUND INFORM+1" IF LogFileLoad THEN PRINT #LogFileNum, "FOUND INFORM+1"
__UI_AutoRefresh = __UI_False __UI_AutoRefresh = __UI_False
FOR i = 1 TO UBOUND(__UI_Controls) FOR i = UBOUND(__UI_Controls) TO 1 STEP -1
__UI_DestroyControl __UI_Controls(i) IF LEFT$(__UI_Controls(i).Name, 9) <> "__UI_Text" AND LEFT$(__UI_Controls(i).Name, 16) <> "__UI_PreviewMenu" THEN
__UI_DestroyControl __UI_Controls(i)
END IF
NEXT NEXT
IF LogFileLoad THEN PRINT #LogFileNum, "DESTROYED CONTROLS" IF LogFileLoad THEN PRINT #LogFileNum, "DESTROYED CONTROLS"
@ -560,16 +564,18 @@ SUB LoadPreview
IF LogFileLoad THEN PRINT #LogFileNum, "READ NEW ARRAYS:" + STR$(CVL(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_Captions(1 TO CVL(b$)) AS STRING
REDIM _PRESERVE __UI_TempCaptions(1 TO CVL(b$)) AS STRING REDIM __UI_TempCaptions(1 TO CVL(b$)) AS STRING
REDIM _PRESERVE __UI_Texts(1 TO CVL(b$)) AS STRING REDIM __UI_Texts(1 TO CVL(b$)) AS STRING
REDIM _PRESERVE __UI_TempTexts(1 TO CVL(b$)) AS STRING REDIM __UI_TempTexts(1 TO CVL(b$)) AS STRING
REDIM _PRESERVE __UI_Tips(1 TO CVL(b$)) AS STRING REDIM __UI_Tips(1 TO CVL(b$)) AS STRING
REDIM __UI_TempTips(1 TO CVL(b$)) AS STRING
REDIM _PRESERVE __UI_Controls(0 TO CVL(b$)) AS __UI_ControlTYPE REDIM _PRESERVE __UI_Controls(0 TO CVL(b$)) AS __UI_ControlTYPE
b$ = SPACE$(2): GET #BinaryFileNum, , b$ b$ = SPACE$(2): GET #BinaryFileNum, , b$
IF LogFileLoad THEN PRINT #LogFileNum, "READ NEW CONTROL:" + STR$(CVI(b$)) IF LogFileLoad THEN PRINT #LogFileNum, "READ NEW CONTROL:" + STR$(CVI(b$))
IF CVI(b$) <> -1 THEN GOTO LoadError IF CVI(b$) <> -1 THEN GOTO LoadError
DO DO
b$ = SPACE$(4): GET #BinaryFileNum, , b$ 'skip id number b$ = SPACE$(4): GET #BinaryFileNum, , b$
Dummy = CVL(b$)
b$ = SPACE$(2): GET #BinaryFileNum, , b$ b$ = SPACE$(2): GET #BinaryFileNum, , b$
NewType = CVI(b$) NewType = CVI(b$)
IF LogFileLoad THEN PRINT #LogFileNum, "TYPE:" + STR$(CVI(b$)) IF LogFileLoad THEN PRINT #LogFileNum, "TYPE:" + STR$(CVI(b$))
@ -590,16 +596,12 @@ SUB LoadPreview
NewTop = CVI(b$) NewTop = CVI(b$)
IF LogFileLoad THEN PRINT #LogFileNum, "TOP:" + STR$(CVI(b$)) IF LogFileLoad THEN PRINT #LogFileNum, "TOP:" + STR$(CVI(b$))
b$ = SPACE$(2): GET #BinaryFileNum, , b$ b$ = SPACE$(2): GET #BinaryFileNum, , b$
NewParentID = SPACE$(CVI(b$)): GET #BinaryFileNum, , NewParentID IF CVI(b$) > 0 THEN
IF LogFileLoad THEN PRINT #LogFileNum, "PARENT:" + NewParentID NewParentID = SPACE$(CVI(b$)): GET #BinaryFileNum, , NewParentID
IF LogFileLoad THEN PRINT #LogFileNum, "PARENT:" + NewParentID
IF NewType = __UI_Type_Form THEN ELSE
IF NewWidth <> _WIDTH OR NewHeight <> _HEIGHT THEN NewParentID = ""
DIM OldScreen& IF LogFileLoad THEN PRINT #LogFileNum, "PARENT: ORPHAN/CONTAINER"
OldScreen& = _DEST
SCREEN _NEWIMAGE(NewWidth, NewHeight, 32)
_FREEIMAGE OldScreen&
END IF
END IF END IF
TempValue = __UI_NewControl(NewType, NewName, NewWidth, NewHeight, NewLeft, NewTop, __UI_GetID(NewParentID)) TempValue = __UI_NewControl(NewType, NewName, NewWidth, NewHeight, NewLeft, NewTop, __UI_GetID(NewParentID))
@ -747,14 +749,14 @@ SUB LoadPreview
__UI_Controls(TempValue).Padding = CVI(b$) __UI_Controls(TempValue).Padding = CVI(b$)
IF LogFileLoad THEN PRINT #LogFileNum, "PADDING" + STR$(CVI(b$)) IF LogFileLoad THEN PRINT #LogFileNum, "PADDING" + STR$(CVI(b$))
CASE -1 'new control CASE -1 'new control
IF LogFileLoad THEN PRINT #LogFileNum, "READ NEW CONTROL:-1" IF LogFileLoad THEN PRINT #LogFileNum, "READ NEW CONTROL: -1"
EXIT DO EXIT DO
CASE -1024 CASE -1024
IF LogFileLoad THEN PRINT #LogFileNum, "READ END OF FILE:-1024" IF LogFileLoad THEN PRINT #LogFileNum, "READ END OF FILE: -1024"
__UI_EOF = __UI_True __UI_EOF = __UI_True
EXIT DO EXIT DO
CASE ELSE CASE ELSE
IF LogFileLoad THEN PRINT #LogFileNum, "UNKNOWN DATA="; CVI(b$) IF LogFileLoad THEN PRINT #LogFileNum, "UNKNOWN PROPERTY ="; CVI(b$)
EXIT DO EXIT DO
END SELECT END SELECT
LOOP LOOP
@ -775,7 +777,7 @@ SUB SavePreview
DIM b$, i AS LONG, a$, FontSetup$, TempValue AS LONG DIM b$, i AS LONG, a$, FontSetup$, TempValue AS LONG
DIM BinFileNum AS INTEGER, TxtFileNum AS INTEGER DIM BinFileNum AS INTEGER, TxtFileNum AS INTEGER
CONST Debug = __UI_False CONST Debug = __UI_True
BinFileNum = FREEFILE BinFileNum = FREEFILE
OPEN "UiEditorPreview.frmbin" FOR BINARY AS #BinFileNum OPEN "UiEditorPreview.frmbin" FOR BINARY AS #BinFileNum
@ -790,11 +792,11 @@ SUB SavePreview
b$ = MKL$(UBOUND(__UI_Controls)) b$ = MKL$(UBOUND(__UI_Controls))
PUT #BinFileNum, , b$ PUT #BinFileNum, , b$
FOR i = 1 TO UBOUND(__UI_Controls) FOR i = 1 TO UBOUND(__UI_Controls)
IF Debug THEN 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 AND LEFT$(RTRIM$(__UI_Controls(i).Name), 9) <> "__UI_Text" AND LEFT$(RTRIM$(__UI_Controls(i).Name), 16) <> "__UI_PreviewMenu" THEN
PRINT #TxtFileNum, __UI_Controls(i).ID, IF Debug THEN
PRINT #TxtFileNum, RTRIM$(__UI_Controls(i).Name) PRINT #TxtFileNum, __UI_Controls(i).ID,
END IF PRINT #TxtFileNum, RTRIM$(__UI_Controls(i).Name)
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 END IF
b$ = MKI$(-1) + MKL$(i) + MKI$(__UI_Controls(i).Type) '-1 indicates a new control 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$ + MKI$(LEN(RTRIM$(__UI_Controls(i).Name)))
b$ = b$ + RTRIM$(__UI_Controls(i).Name) b$ = b$ + RTRIM$(__UI_Controls(i).Name)
@ -853,7 +855,7 @@ SUB SavePreview
ELSE ELSE
IF __UI_Controls(i).ParentID > 0 THEN 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 > 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 IF __UI_Controls(i).Font = 8 OR __UI_Controls(i).Font = 16 THEN
GOTO SaveInternalFont GOTO SaveInternalFont
ELSE ELSE
GOTO SaveExternalFont GOTO SaveExternalFont
@ -861,7 +863,7 @@ SUB SavePreview
END IF END IF
ELSE ELSE
IF __UI_Controls(i).Font > 0 AND __UI_Controls(i).Font <> __UI_Controls(__UI_FormID).Font THEN 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 IF __UI_Controls(i).Font = 8 OR __UI_Controls(i).Font = 16 THEN
GOTO SaveInternalFont GOTO SaveInternalFont
ELSE ELSE
GOTO SaveExternalFont GOTO SaveExternalFont
@ -932,7 +934,9 @@ SUB SavePreview
b$ = MKI$(-23): PUT #BinFileNum, , b$ b$ = MKI$(-23): PUT #BinFileNum, , b$
END IF END IF
IF __UI_Controls(i).ContextMenuID THEN IF __UI_Controls(i).ContextMenuID THEN
b$ = MKI$(-25) + MKI$(LEN(RTRIM$(__UI_Controls(__UI_Controls(i).ContextMenuID).Name))) + RTRIM$(__UI_Controls(__UI_Controls(i).ContextMenuID).Name): PUT #BinFileNum, , b$ IF LEFT$(__UI_Controls(__UI_Controls(i).ContextMenuID).Name, 9) <> "__UI_Text" AND LEFT$(__UI_Controls(__UI_Controls(i).ContextMenuID).Name, 16) <> "__UI_PreviewMenu" THEN
b$ = MKI$(-25) + MKI$(LEN(RTRIM$(__UI_Controls(__UI_Controls(i).ContextMenuID).Name))) + RTRIM$(__UI_Controls(__UI_Controls(i).ContextMenuID).Name): PUT #BinFileNum, , b$
END IF
END IF END IF
IF __UI_Controls(i).Interval THEN IF __UI_Controls(i).Interval THEN
b$ = MKI$(-26) + _MK$(_FLOAT, __UI_Controls(i).Interval): PUT #BinFileNum, , b$ b$ = MKI$(-26) + _MK$(_FLOAT, __UI_Controls(i).Interval): PUT #BinFileNum, , b$
@ -943,9 +947,9 @@ SUB SavePreview
IF __UI_Controls(i).CanResize AND __UI_Controls(i).Type = __UI_Type_Form THEN IF __UI_Controls(i).CanResize AND __UI_Controls(i).Type = __UI_Type_Form THEN
b$ = MKI$(-29): PUT #BinFileNum, , b$ b$ = MKI$(-29): PUT #BinFileNum, , b$
END IF END IF
IF __UI_Controls(i).HotKey > 0 THEN 'IF __UI_Controls(i).HotKey > 0 THEN
b$ = MKI$(-30) + MKI$(__UI_Controls(i).HotKeyPosition): PUT #BinFileNum, , b$ ' b$ = MKI$(-30) + MKI$(__UI_Controls(i).HotKeyPosition): PUT #BinFileNum, , b$
END IF 'END IF
IF __UI_Controls(i).Padding > 0 THEN IF __UI_Controls(i).Padding > 0 THEN
b$ = MKI$(-31) + MKI$(__UI_Controls(i).Padding): PUT #BinFileNum, , b$ b$ = MKI$(-31) + MKI$(__UI_Controls(i).Padding): PUT #BinFileNum, , b$
END IF END IF

View file

@ -5,4 +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, "")
END SUB END SUB