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

Improves clipboard handling for controls.

This commit is contained in:
FellippeHeitor 2018-05-10 02:13:10 -03:00
parent 32ad8e5abb
commit a1eaae561d
4 changed files with 76 additions and 21 deletions

View file

@ -204,6 +204,7 @@ DIM SHARED __UI_SnappedX AS INTEGER, __UI_SnappedY AS INTEGER
DIM SHARED __UI_SnappedXID AS LONG, __UI_SnappedYID AS LONG
DIM SHARED __UI_SnapLines AS _BYTE, __UI_SnapDistance AS INTEGER, __UI_SnapDistanceFromForm AS INTEGER
DIM SHARED __UI_FrameRate AS SINGLE, __UI_Font8Offset AS INTEGER, __UI_Font16Offset AS INTEGER
DIM SHARED __UI_ClipboardCheck$
'Control types:
DIM SHARED __UI_Type(0 TO 18) AS __UI_Types
@ -231,6 +232,7 @@ __UI_SnapDistance = 5
__UI_SnapDistanceFromForm = 10
__UI_Font8Offset = 5
__UI_Font16Offset = 3
__UI_ClipboardCheck$ = "InForm" + STRING$(2, 10) + "BEGIN CONTROL DATA" + CHR$(10) + STRING$(60, 45) + CHR$(10)
__UI_ThemeSetup
__UI_InternalMenus
@ -1647,7 +1649,7 @@ SUB __UI_EventDispatcher
Control(__UI_GetID("__UI_PreviewMenuSetDefaultButton")).Hidden = True
END IF
IF LEFT$(_CLIPBOARD$, 7) = "InForm" + CHR$(1) THEN
IF LEFT$(_CLIPBOARD$, LEN(__UI_ClipboardCheck$)) = __UI_ClipboardCheck$ THEN
Control(__UI_GetID("__UI_PreviewMenuPaste")).Disabled = False
ELSE
Control(__UI_GetID("__UI_PreviewMenuPaste")).Disabled = True
@ -3861,7 +3863,7 @@ SUB __UI_EventDispatcher
IF __UI_CtrlIsDown THEN
ControlPaste:
Clip$ = _CLIPBOARD$
IF LEFT$(Clip$, 7) = "InForm" + CHR$(1) THEN
IF LEFT$(Clip$, LEN(__UI_ClipboardCheck$)) = __UI_ClipboardCheck$ THEN
__UI_KeyPress 218
__UI_Click 0 'Force the preview to inform it was edited
END IF

View file

@ -177,7 +177,6 @@ CONST OffsetOriginalImageWidth = 47
CONST OffsetOriginalImageHeight = 49
CONST OffsetPropertyValue = 51
REDIM SHARED PreviewCaptions(0) AS STRING
REDIM SHARED PreviewTexts(0) AS STRING
REDIM SHARED PreviewMasks(0) AS STRING
@ -959,7 +958,7 @@ SUB __UI_BeforeUpdateDisplay
Caption(AlignMenuAlignCenterH) = "Center Horizontally (group)-"
Control(EditMenuPaste).Disabled = True
IF LEFT$(_CLIPBOARD$, 7) = "InForm" + CHR$(1) THEN
IF LEFT$(_CLIPBOARD$, LEN(__UI_ClipboardCheck$)) = __UI_ClipboardCheck$ THEN
Control(EditMenuPaste).Disabled = False
END IF

View file

@ -69,7 +69,7 @@ SUB __UI_LoadForm
SetCaption __UI_NewID, "&New"
__UI_NewID = __UI_NewControl(__UI_Type_MenuItem, "FileMenuOpen", 91, 18, 0, 22, __UI_GetID("FileMenu"))
SetCaption __UI_NewID, "Open...-"
SetCaption __UI_NewID, "&Open...-"
ToolTip(__UI_NewID) = "File names are automatically taken from your form's name property"
__UI_NewID = __UI_NewControl(__UI_Type_MenuItem, "FileMenuSave", 91, 18, 0, 22, __UI_GetID("FileMenu"))
@ -77,7 +77,7 @@ SUB __UI_LoadForm
ToolTip(__UI_NewID) = "File names are automatically taken from your form's name property" + CHR$(10) + "Only the .frm file will be updated."
__UI_NewID = __UI_NewControl(__UI_Type_MenuItem, "FileMenuSaveFrm", 91, 18, 0, 22, __UI_GetID("FileMenu"))
SetCaption __UI_NewID, "&Save form only-"
SetCaption __UI_NewID, "Save &form only-"
__UI_NewID = __UI_NewControl(__UI_Type_MenuItem, "FileMenuExit", 56, 18, 0, 40, __UI_GetID("FileMenu"))
SetCaption __UI_NewID, "E&xit"
@ -115,7 +115,7 @@ SUB __UI_LoadForm
Control(__UI_NewID).Disabled = True
__UI_NewID = __UI_NewControl(__UI_Type_MenuItem, "EditMenuRestoreDimensions", 103, 18, 0, 88, __UI_GetID("EditMenu"))
SetCaption __UI_NewID, "Restore image dimensions-"
SetCaption __UI_NewID, "Restore &image dimensions-"
Control(__UI_NewID).Disabled = True
__UI_NewID = __UI_NewControl(__UI_Type_MenuItem, "EditMenuZOrdering", 103, 18, 0, 88, __UI_GetID("EditMenu"))
@ -139,11 +139,11 @@ SUB __UI_LoadForm
SetCaption __UI_NewID, "Menu &Bar"
__UI_NewID = __UI_NewControl(__UI_Type_MenuItem, "InsertMenuMenuItem", 101, 18, 0, 22, __UI_GetID("InsertMenu"))
SetCaption __UI_NewID, "Menu Item"
ToolTip(__UI_NewID) = "Automatically snap control's edges to other controls, for easy aligning. Can be temporarily bypassed by holding Ctrl."
SetCaption __UI_NewID, "Menu &Item"
Control(__UI_NewID).Disabled = True
__UI_NewID = __UI_NewControl(__UI_Type_MenuItem, "OptionsMenuSnapLines", 128, 18, 0, 4, __UI_GetID("AlignMenu"))
ToolTip(__UI_NewID) = "Automatically snap control's edges to other controls, for easy aligning. Can be temporarily bypassed by holding Ctrl."
SetCaption __UI_NewID, "&Snap to edges-"
__UI_NewID = __UI_NewControl(__UI_Type_MenuItem, "AlignMenuAlignLeft", 94, 18, 0, 28, __UI_GetID("AlignMenu"))
@ -175,7 +175,6 @@ SUB __UI_LoadForm
__UI_NewID = __UI_NewControl(__UI_Type_MenuItem, "AlignMenuDistributeH", 163, 18, 0, 202, __UI_GetID("AlignMenu"))
SetCaption __UI_NewID, "Distribute Hori&zontally"
ToolTip(__UI_NewID) = "Automatically set control names based on caption and type"
__UI_NewID = __UI_NewControl(__UI_Type_MenuItem, "OptionsMenuAutoName", 155, 18, 0, 4, __UI_GetID("OptionsMenu"))
$IF WIN THEN

View file

@ -138,6 +138,8 @@ SUB __UI_BeforeUpdateDisplay
STATIC MidRead AS _BYTE, UiEditorFile AS INTEGER, EditorWasActive AS _BYTE
STATIC WasDragging AS _BYTE, WasResizing AS _BYTE
IF __UI_TotalSelectedControls < 0 THEN __UI_TotalSelectedControls = 0
SavePreview InDisk
b$ = MKL$(UiPreviewPID)
@ -1040,7 +1042,10 @@ SUB DeleteSelectedControls
didDelete = True
END IF
NEXT
IF didDelete THEN __UI_Click 0 'Force the preview to inform it was edited
IF didDelete THEN
IF __UI_TotalSelectedControls > 0 THEN __UI_TotalSelectedControls = 0
__UI_Click 0 'Force the preview to inform it was edited
END IF
END SUB
SUB __UI_TextChanged (id AS LONG)
@ -1141,6 +1146,7 @@ SUB LoadPreview (Destination AS _BYTE)
DIM NewParentID AS STRING, FloatValue AS _FLOAT, TempValue AS LONG
DIM Dummy AS LONG, Disk AS _BYTE, Clip$, FirstToBeSelected AS LONG
DIM BinaryFileNum AS INTEGER, LogFileNum AS INTEGER
DIM CorruptedData AS _BYTE
CONST LogFileLoad = False
@ -1159,14 +1165,17 @@ SUB LoadPreview (Destination AS _BYTE)
IF Disk THEN
b$ = SPACE$(7): GET #BinaryFileNum, 1, b$
IF b$ <> "InForm" + CHR$(1) THEN
GOTO LoadError
EXIT SUB
END IF
ELSE
Clip$ = _CLIPBOARD$
b$ = ReadSequential$(Clip$, 7)
END IF
IF b$ <> "InForm" + CHR$(1) THEN
GOTO LoadError
EXIT SUB
b$ = ReadSequential$(Clip$, LEN(__UI_ClipboardCheck$))
IF b$ <> __UI_ClipboardCheck$ THEN
GOTO LoadError
EXIT SUB
END IF
END IF
IF LogFileLoad THEN PRINT #LogFileNum, "FOUND INFORM+1"
@ -1197,7 +1206,26 @@ SUB LoadPreview (Destination AS _BYTE)
NEXT
__UI_TotalSelectedControls = 0
Clip$ = Unpack$(Clip$)
'Clip$ = "InForm" + CHR$(10) + CHR$(10)
'Clip$ = Clip$ + "BEGIN CONTROL DATA" + CHR$(10)
'Clip$ = Clip$ + STRING$(60, "-") + CHR$(10)
'Clip$ = Clip$ + HEX$(LEN(b$)) + CHR$(10)
'Clip$ = Clip$ + b$ + CHR$(10)
'Clip$ = Clip$ + STRING$(60, "-") + CHR$(10)
'Clip$ = Clip$ + "END CONTROL DATA"
DIM ClipLen$
DO
a$ = ReadSequential$(Clip$, 1)
IF a$ = CHR$(10) THEN EXIT DO
IF a$ = "" THEN GOTO LoadError
ClipLen$ = ClipLen$ + a$
LOOP
b$ = ReadSequential$(Clip$, VAL("&H" + ClipLen$))
b$ = Replace$(b$, CHR$(10), "", False, 0)
Clip$ = Unpack$(b$)
END IF
IF NOT Disk THEN b$ = ReadSequential$(Clip$, 2) ELSE b$ = SPACE$(2): GET #BinaryFileNum, , b$
@ -1264,6 +1292,7 @@ SUB LoadPreview (Destination AS _BYTE)
END IF
TempValue = __UI_NewControl(NewType, NewName, NewWidth, NewHeight, NewLeft, NewTop, __UI_GetID(NewParentID))
IF NOT Disk THEN
Control(TempValue).ControlIsSelected = True
__UI_TotalSelectedControls = __UI_TotalSelectedControls + 1
@ -1431,6 +1460,8 @@ SUB LoadPreview (Destination AS _BYTE)
EXIT DO
CASE ELSE
IF LogFileLoad THEN PRINT #LogFileNum, "UNKNOWN PROPERTY ="; CVI(b$)
__UI_EOF = True 'Stop reading if corrupted data is found
CorruptedData = True
EXIT DO
END SELECT
LOOP
@ -1438,7 +1469,12 @@ SUB LoadPreview (Destination AS _BYTE)
IF Disk THEN CLOSE #BinaryFileNum
IF LogFileLoad THEN CLOSE #LogFileNum
IF NOT Disk THEN
__UI_FirstSelectedID = FirstToBeSelected
IF NOT CorruptedData THEN
__UI_FirstSelectedID = FirstToBeSelected
ELSE
__UI_DestroyControl Control(TempValue)
__UI_TotalSelectedControls = __UI_TotalSelectedControls - 1
END IF
__UI_ForceRedraw = True
END IF
__UI_AutoRefresh = True
@ -1454,7 +1490,7 @@ SUB LoadPreview (Destination AS _BYTE)
END SUB
SUB LoadPreviewText
DIM a$, b$, i AS LONG, __UI_EOF AS _BYTE, Answer AS _BYTE
DIM b$, i AS LONG, __UI_EOF AS _BYTE, Answer AS _BYTE
DIM NewType AS INTEGER, NewWidth AS INTEGER, NewHeight AS INTEGER
DIM NewLeft AS INTEGER, NewTop AS INTEGER, NewName AS STRING
DIM NewParentID AS STRING, FloatValue AS _FLOAT, TempValue AS LONG
@ -2044,7 +2080,26 @@ SUB SavePreview (Destination AS _BYTE)
CLOSE #BinFileNum
ELSE
Clip$ = Clip$ + b$
Clip$ = "InForm" + CHR$(1) + Pack$(Clip$)
b$ = Pack$(Clip$)
IF LEN(b$) > 60 THEN
a$ = ""
DO
a$ = a$ + LEFT$(b$, 60) + CHR$(10)
b$ = MID$(b$, 61)
IF LEN(b$) <= 60 THEN
a$ = a$ + b$
b$ = a$
EXIT DO
END IF
LOOP
END IF
Clip$ = __UI_ClipboardCheck$
Clip$ = Clip$ + HEX$(LEN(b$)) + CHR$(10)
Clip$ = Clip$ + b$ + CHR$(10)
Clip$ = Clip$ + STRING$(60, "-") + CHR$(10)
Clip$ = Clip$ + "END CONTROL DATA"
_CLIPBOARD$ = Clip$
END IF
IF Debug THEN CLOSE #TxtFileNum