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

Fix "CopyOfCopyOf..." control naming issue when copying/pasting. Also:

- Bypass display of position/size panel when the selected control is a menubar/menuitem.
This commit is contained in:
FellippeHeitor 2017-01-08 01:44:53 -02:00
parent 109d822c6e
commit e94cda2a11
3 changed files with 65 additions and 41 deletions

View file

@ -1017,51 +1017,53 @@ SUB __UI_UpdateDisplay
ELSE ELSE
_DEST Control(__UI_FormID).HelperCanvas _DEST Control(__UI_FormID).HelperCanvas
END IF END IF
OverlayisVisible = True
i = __UI_FirstSelectedID i = __UI_FirstSelectedID
IF Control(__UI_HoveringID).ControlIsSelected THEN i = __UI_HoveringID IF Control(__UI_HoveringID).ControlIsSelected THEN i = __UI_HoveringID
DIM SizeAndPosition1$, SizeAndPosition2$, pw& IF Control(i).Type <> __UI_Type_MenuBar AND Control(i).Type <> __UI_Type_MenuItem THEN
DIM InfoLeft AS INTEGER, InfoTop AS INTEGER OverlayisVisible = True
_FONT Control(__UI_FormID).Font DIM SizeAndPosition1$, SizeAndPosition2$, pw&
'Calculate the info panel width DIM InfoLeft AS INTEGER, InfoTop AS INTEGER
SizeAndPosition1$ = LTRIM$(STR$(Control(i).Left)) + "," + LTRIM$(STR$(Control(i).Top)) _FONT Control(__UI_FormID).Font
pw& = __UI_PrintWidth(SizeAndPosition1$) 'Calculate the info panel width
SizeAndPosition2$ = LTRIM$(STR$(Control(i).Width)) + "x" + LTRIM$(STR$(Control(i).Height)) SizeAndPosition1$ = LTRIM$(STR$(Control(i).Left)) + "," + LTRIM$(STR$(Control(i).Top))
IF __UI_PrintWidth(SizeAndPosition2$) > pw& THEN pw& = __UI_PrintWidth(SizeAndPosition2$) pw& = __UI_PrintWidth(SizeAndPosition1$)
SizeAndPosition2$ = LTRIM$(STR$(Control(i).Width)) + "x" + LTRIM$(STR$(Control(i).Height))
IF __UI_PrintWidth(SizeAndPosition2$) > pw& THEN pw& = __UI_PrintWidth(SizeAndPosition2$)
'Calculate the info panel position 'Calculate the info panel position
InfoLeft = Control(Control(i).ParentID).Left + Control(i).Left InfoLeft = Control(Control(i).ParentID).Left + Control(i).Left
IF InfoLeft < 0 THEN InfoLeft = 0 IF InfoLeft < 0 THEN InfoLeft = 0
IF InfoLeft + pw& + 4 > Control(__UI_FormID).Width THEN InfoLeft = Control(__UI_FormID).Width - (pw& + 4) IF InfoLeft + pw& + 4 > Control(__UI_FormID).Width THEN InfoLeft = Control(__UI_FormID).Width - (pw& + 4)
InfoTop = Control(Control(i).ParentID).Top + Control(i).Top + Control(i).Height + 2 InfoTop = Control(Control(i).ParentID).Top + Control(i).Top + Control(i).Height + 2
IF InfoTop < 0 THEN InfoTop = 0 IF InfoTop < 0 THEN InfoTop = 0
IF InfoTop + uspacing& * 2 + 4 > Control(__UI_FormID).Height THEN InfoTop = Control(__UI_FormID).Height - (uspacing& * 2 + 4) IF InfoTop + uspacing& * 2 + 4 > Control(__UI_FormID).Height THEN InfoTop = Control(__UI_FormID).Height - (uspacing& * 2 + 4)
'Reposition the panel if it intersects with the controls 'Reposition the panel if it intersects with the controls
IF InfoLeft < Control(Control(i).ParentID).Left + Control(i).Left + Control(i).Width AND _ IF InfoLeft < Control(Control(i).ParentID).Left + Control(i).Left + Control(i).Width AND _
Control(Control(i).ParentID).Left + Control(i).Left < InfoLeft + pw& + 4 AND _ Control(Control(i).ParentID).Left + Control(i).Left < InfoLeft + pw& + 4 AND _
InfoTop < Control(Control(i).ParentID).Top + Control(i).Top + Control(i).Height + 2 AND _ InfoTop < Control(Control(i).ParentID).Top + Control(i).Top + Control(i).Height + 2 AND _
Control(Control(i).ParentID).Top + Control(i).Top < InfoTop + uspacing& * 2 + 4 THEN Control(Control(i).ParentID).Top + Control(i).Top < InfoTop + uspacing& * 2 + 4 THEN
InfoTop = Control(Control(i).ParentID).Top + Control(i).Top - (uspacing& * 2 + 4) InfoTop = Control(Control(i).ParentID).Top + Control(i).Top - (uspacing& * 2 + 4)
END IF
'Reposition the panel if the mouse is where it'd be drawn
IF __UI_MouseLeft >= InfoLeft AND __UI_MouseLeft <= InfoLeft + pw& + 4 AND _
__UI_MouseTop >= InfoTop AND __UI_MouseTop <= InfoTop + uspacing& * 2 + 4 THEN
InfoLeft = InfoLeft + Control(i).Width
END IF
'Draw the info panel
__UI_ShadowBox InfoLeft, InfoTop, pw& + 4, uspacing& * 2 + 4, __UI_DefaultColor(__UI_Type_Form, 6), 40, 5
'Print the info
COLOR _RGB32(0, 0, 0)
__UI_PrintString InfoLeft + 3, InfoTop + 3, SizeAndPosition1$
__UI_PrintString InfoLeft + 3, InfoTop + 3 + uspacing&, SizeAndPosition2$
END IF END IF
'Reposition the panel if the mouse is where it'd be drawn
IF __UI_MouseLeft >= InfoLeft AND __UI_MouseLeft <= InfoLeft + pw& + 4 AND _
__UI_MouseTop >= InfoTop AND __UI_MouseTop <= InfoTop + uspacing& * 2 + 4 THEN
InfoLeft = InfoLeft + Control(i).Width
END IF
'Draw the info panel
__UI_ShadowBox InfoLeft, InfoTop, pw& + 4, uspacing& * 2 + 4, __UI_DefaultColor(__UI_Type_Form, 6), 40, 5
'Print the info
COLOR _RGB32(0, 0, 0)
__UI_PrintString InfoLeft + 3, InfoTop + 3, SizeAndPosition1$
__UI_PrintString InfoLeft + 3, InfoTop + 3 + uspacing&, SizeAndPosition2$
_DEST 0 _DEST 0
END IF END IF
END IF END IF
@ -1071,8 +1073,10 @@ SUB __UI_UpdateDisplay
END IF END IF
IF OverlayisVisible THEN IF OverlayisVisible THEN
__UI_MakeHardwareImage Control(__UI_FormID).HelperCanvas IF Control(__UI_FormID).HelperCanvas < -1 THEN
IF Control(__UI_FormID).HelperCanvas < -1 THEN _PUTIMAGE , Control(__UI_FormID).HelperCanvas __UI_MakeHardwareImage Control(__UI_FormID).HelperCanvas
_PUTIMAGE , Control(__UI_FormID).HelperCanvas
END IF
END IF END IF
IF __UI_ActiveMenu > 0 AND LEFT$(Control(__UI_ParentMenu).Name, 5) = "__UI_" THEN IF __UI_ActiveMenu > 0 AND LEFT$(Control(__UI_ParentMenu).Name, 5) = "__UI_" THEN
@ -3425,6 +3429,7 @@ SUB __UI_EventDispatcher
IF Clip$ = "InForm" + CHR$(1) THEN IF Clip$ = "InForm" + CHR$(1) THEN
DIM PasteID AS LONG, ThisControl AS LONG, FirstToBeSelected AS LONG DIM PasteID AS LONG, ThisControl AS LONG, FirstToBeSelected AS LONG
DIM TempCanvas AS LONG, TempTop AS INTEGER, TempLeft AS INTEGER DIM TempCanvas AS LONG, TempTop AS INTEGER, TempLeft AS INTEGER
DIM TempName$, OriginalIndex$, c$
j = CVL(MID$(ControlClipboard$, 1, 4)) j = CVL(MID$(ControlClipboard$, 1, 4))
@ -3446,12 +3451,31 @@ SUB __UI_EventDispatcher
FOR i = 1 TO j FOR i = 1 TO j
ThisControl = CVL(MID$(Clip$, (i * 4 - 3), 4)) ThisControl = CVL(MID$(Clip$, (i * 4 - 3), 4))
IF Control(ThisControl).ID > 0 AND Control(ThisControl).Type <> __UI_Type_Frame THEN IF Control(ThisControl).ID > 0 AND Control(ThisControl).Type <> __UI_Type_Frame THEN
PasteID = __UI_NewControl(Control(ThisControl).Type, "", 0, 0, 0, 0, 0) PasteID = __UI_NewControl(Control(ThisControl).Type, "", Control(ThisControl).Width, Control(ThisControl).Height, 0, 0, 0)
TempCanvas = Control(PasteID).Canvas TempCanvas = Control(PasteID).Canvas
Control(PasteID) = Control(ThisControl) Control(PasteID) = Control(ThisControl)
Control(PasteID).ID = 0 Control(PasteID).ID = 0
DO WHILE __UI_GetID(Control(PasteID).Name) > 0 DO WHILE __UI_GetID(Control(PasteID).Name) > 0
Control(PasteID).Name = "Cp" + Control(PasteID).Name TempName$ = RTRIM$(Control(PasteID).Name)
c$ = RIGHT$(TempName$, 1)
IF ASC(c$) >= 48 AND ASC(c$) <= 57 THEN
'Update this control's name by the ID # assigned to it, if any
OriginalIndex$ = c$
TempName$ = LEFT$(TempName$, LEN(TempName$) - 1)
DO
c$ = RIGHT$(TempName$, 1)
IF ASC(c$) >= 48 AND ASC(c$) <= 57 THEN
OriginalIndex$ = c$ + OriginalIndex$
TempName$ = LEFT$(TempName$, LEN(TempName$) - 1)
IF LEN(TempName$) = 0 THEN EXIT DO
ELSE
EXIT DO
END IF
LOOP
ELSE
OriginalIndex$ = "1"
END IF
Control(PasteID).Name = TempName$ + LTRIM$(STR$(VAL(OriginalIndex$) + 1))
LOOP LOOP
Control(PasteID).ID = PasteID Control(PasteID).ID = PasteID
Control(PasteID).ParentID = 0 Control(PasteID).ParentID = 0
@ -3460,7 +3484,7 @@ SUB __UI_EventDispatcher
ToolTip(PasteID) = ToolTip(ThisControl) ToolTip(PasteID) = ToolTip(ThisControl)
Control(PasteID).Canvas = TempCanvas Control(PasteID).Canvas = TempCanvas
IF Control(ThisControl).HelperCanvas <> 0 THEN IF Control(ThisControl).HelperCanvas <> 0 THEN
Control(ThisControl).HelperCanvas = _COPYIMAGE(Control(ThisControl).HelperCanvas, 32) Control(PasteID).HelperCanvas = _COPYIMAGE(Control(ThisControl).HelperCanvas, 32)
END IF END IF
IF j = 1 AND TempTop + TempLeft >= 0 THEN IF j = 1 AND TempTop + TempLeft >= 0 THEN
Control(PasteID).Top = TempTop Control(PasteID).Top = TempTop

Binary file not shown.

Binary file not shown.