1
1
Fork 0
mirror of https://github.com/FellippeHeitor/InForm.git synced 2025-01-14 19:49:33 +00:00

Adds .BorderSize to all controls that can have .HasBorder = True.

Closes #71.
This commit is contained in:
FellippeHeitor 2018-08-28 01:27:10 -03:00
parent 233ebaa4cc
commit 6075c87976
3 changed files with 70 additions and 33 deletions

View file

@ -1547,19 +1547,22 @@ END SUB
'---------------------------------------------------------------------------------
SUB AutoSizeLabel (this AS __UI_ControlTYPE)
DIM tempFont AS LONG, tempCenter AS INTEGER, autoWidth AS INTEGER
DIM tempFont AS LONG, tempCenter AS INTEGER
DIM autoWidth AS INTEGER, autoHeight AS INTEGER
IF this.AutoSize = False THEN EXIT SUB
IF this.WordWrap = False THEN
tempFont = _FONT
_FONT this.Font
autoWidth = __UI_PrintWidth(Caption(this.ID))
IF this.Padding THEN autoWidth = autoWidth + this.Padding * 2
IF this.HasBorder THEN autoWidth = autoWidth + __UI_DefaultCaptionIndent * 2
IF this.HasBorder THEN autoWidth = autoWidth + (__UI_DefaultCaptionIndent + this.BorderSize) * 2
IF this.Width <> autoWidth OR this.Height <> uspacing + 6 THEN
this.Width = autoWidth
IF this.Height <> uspacing + 6 THEN
autoHeight = uspacing + 6
IF this.HasBorder THEN autoHeight = autoHeight + this.BorderSize * 2
IF this.Height <> autoHeight THEN
tempCenter = this.Top + this.Height / 2
this.Height = uspacing + 6
this.Height = autoHeight
this.Top = tempCenter - this.Height / 2
END IF
this.Redraw = True
@ -1880,8 +1883,8 @@ SUB __UI_EventDispatcher
Control(__UI_GetID("__UI_PreviewMenuAlignCenterH")).Hidden = True
END IF
IF Control(__UI_FirstSelectedID).Type = __UI_Type_PictureBox AND LEN(Text(__UI_FirstSelectedID)) > 0 THEN
IF Control(__UI_FirstSelectedID).Height <> _HEIGHT(Control(__UI_FirstSelectedID).HelperCanvas) OR _
Control(__UI_FirstSelectedID).Width <> _WIDTH(Control(__UI_FirstSelectedID).HelperCanvas) THEN
IF Control(__UI_FirstSelectedID).Height - (Control(__UI_FirstSelectedID).BorderSize * ABS(Control(__UI_FirstSelectedID).HasBorder)) <> _HEIGHT(Control(__UI_FirstSelectedID).HelperCanvas) OR _
Control(__UI_FirstSelectedID).Width - (Control(__UI_FirstSelectedID).BorderSize * ABS(Control(__UI_FirstSelectedID).HasBorder)) <> _WIDTH(Control(__UI_FirstSelectedID).HelperCanvas) THEN
Control(__UI_GetID("__UI_PreviewMenuImageOriginalSize")).Hidden = False
SetCaption __UI_GetID("__UI_PreviewMenuImageOriginalSize"), "Restore &image dimensions (" + LTRIM$(STR$(_WIDTH(Control(__UI_FirstSelectedID).HelperCanvas))) + "x" + LTRIM$(STR$(_HEIGHT(Control(__UI_FirstSelectedID).HelperCanvas))) + ")-"
ELSE
@ -4203,8 +4206,8 @@ SUB __UI_RestoreImageOriginalSize
KeepCenterY = Control(__UI_FirstSelectedID).Top + Control(__UI_FirstSelectedID).Height / 2
KeepCenterX = Control(__UI_FirstSelectedID).Left + Control(__UI_FirstSelectedID).Width / 2
Control(__UI_FirstSelectedID).Height = _HEIGHT(Control(__UI_FirstSelectedID).HelperCanvas)
Control(__UI_FirstSelectedID).Width = _WIDTH(Control(__UI_FirstSelectedID).HelperCanvas)
Control(__UI_FirstSelectedID).Height = _HEIGHT(Control(__UI_FirstSelectedID).HelperCanvas) + Control(__UI_FirstSelectedID).BorderSize * ABS(Control(__UI_FirstSelectedID).HasBorder)
Control(__UI_FirstSelectedID).Width = _WIDTH(Control(__UI_FirstSelectedID).HelperCanvas) + Control(__UI_FirstSelectedID).BorderSize * ABS(Control(__UI_FirstSelectedID).HasBorder)
Control(__UI_FirstSelectedID).Top = KeepCenterY - Control(__UI_FirstSelectedID).Height / 2
Control(__UI_FirstSelectedID).Left = KeepCenterX - Control(__UI_FirstSelectedID).Width / 2

View file

@ -1156,8 +1156,8 @@ SUB __UI_BeforeUpdateDisplay
Control(EditMenuRestoreDimensions).Disabled = True
SetCaption EditMenuRestoreDimensions, "Restore &image dimensions"
IF TotalSelected = 1 AND PreviewControls(FirstSelected).Type = __UI_Type_PictureBox AND OriginalImageWidth > 0 AND OriginalImageHeight > 0 THEN
IF PreviewControls(FirstSelected).Height <> OriginalImageHeight OR _
PreviewControls(FirstSelected).Width <> OriginalImageWidth THEN
IF PreviewControls(FirstSelected).Height - (PreviewControls(FirstSelected).BorderSize * ABS(PreviewControls(FirstSelected).HasBorder)) <> OriginalImageHeight OR _
PreviewControls(FirstSelected).Width - (PreviewControls(FirstSelected).BorderSize * ABS(PreviewControls(FirstSelected).HasBorder)) <> OriginalImageWidth THEN
Control(EditMenuRestoreDimensions).Disabled = False
SetCaption EditMenuRestoreDimensions, "Restore &image dimensions (" + LTRIM$(STR$(OriginalImageWidth)) + "x" + LTRIM$(STR$(OriginalImageHeight)) + ")"
END IF

View file

@ -155,7 +155,7 @@ END SUB
'---------------------------------------------------------------------------------
SUB __UI_DrawLabel (This AS __UI_ControlTYPE, ControlState AS _BYTE)
DIM PrevDest AS LONG, Temp&
DIM PrevDest AS LONG, Temp&, i AS LONG
DIM CaptionIndent AS INTEGER, TempCaption$, TempLine$
IF This.Redraw OR This.ControlState <> ControlState OR Caption(This.ID) <> __UI_TempCaptions(This.ID) OR This.PreviousParentID <> This.ParentID OR __UI_ForceRedraw THEN
@ -176,7 +176,14 @@ SUB __UI_DrawLabel (This AS __UI_ControlTYPE, ControlState AS _BYTE)
_DEST This.Canvas
_FONT This.Font
IF This.HasBorder THEN CaptionIndent = __UI_DefaultCaptionIndent ELSE CaptionIndent = 0
IF This.HasBorder THEN
IF This.BorderSize > __UI_MaxBorderSize THEN
This.BorderSize = __UI_MaxBorderSize
ELSEIF This.BorderSize < 1 THEN
This.BorderSize = 1
END IF
CaptionIndent = __UI_DefaultCaptionIndent + This.BorderSize
END IF
IF This.BackStyle = __UI_Opaque THEN
CLS , This.BackColor
@ -276,7 +283,9 @@ SUB __UI_DrawLabel (This AS __UI_ControlTYPE, ControlState AS _BYTE)
END IF
IF This.HasBorder THEN
LINE (0, 0)-STEP(This.Width - 1, This.Height - 1), This.BorderColor, B
FOR i = 0 TO This.BorderSize - 1
LINE (i, i)-STEP(This.Width - 1 - i * 2, This.Height - 1 - i * 2), This.BorderColor, B
NEXT
END IF
__UI_MakeHardwareImageFromCanvas This
@ -770,7 +779,7 @@ SUB __UI_DrawTextBox (This AS __UI_ControlTYPE, ControlState, ss1 AS LONG, ss2 A
ELSEIF This.BorderSize < 1 THEN
This.BorderSize = 1
END IF
CaptionIndent = 5 + This.BorderSize
CaptionIndent = __UI_DefaultCaptionIndent + This.BorderSize
END IF
IF NOT This.Disabled AND (LEN(Text(This.ID)) OR This.Multiline) THEN
@ -940,7 +949,7 @@ SUB __UI_DrawTextBox (This AS __UI_ControlTYPE, ControlState, ss1 AS LONG, ss2 A
END IF
END IF
IF This.HasBorder = True THEN
IF This.HasBorder THEN
FOR i = 0 TO This.BorderSize - 1
LINE (i, i)-STEP(This.Width - 1 - i * 2, This.Height - 1 - i * 2), This.BorderColor, B
NEXT
@ -956,7 +965,7 @@ END SUB
'---------------------------------------------------------------------------------
SUB __UI_DrawListBox (This AS __UI_ControlTYPE, ControlState)
DIM PrevDest AS LONG, Temp&
DIM PrevDest AS LONG, Temp&, i AS LONG
DIM CaptionIndent AS INTEGER, TempCaption$
IF This.Redraw OR This.ControlState <> ControlState OR This.FocusState <> (__UI_Focus = This.ID) OR This.PreviousValue <> This.Value OR Text(This.ID) <> __UI_TempTexts(This.ID) OR This.PreviousInputViewStart <> This.InputViewStart OR This.PreviousParentID <> This.ParentID OR __UI_ForceRedraw THEN
@ -994,8 +1003,14 @@ SUB __UI_DrawListBox (This AS __UI_ControlTYPE, ControlState)
CLS , _RGBA32(0, 0, 0, 0)
END IF
CaptionIndent = 0
CaptionIndent = ABS(This.HasBorder) * 5
IF This.HasBorder THEN
IF This.BorderSize > __UI_MaxBorderSize THEN
This.BorderSize = __UI_MaxBorderSize
ELSEIF This.BorderSize < 1 THEN
This.BorderSize = 1
END IF
CaptionIndent = __UI_DefaultCaptionIndent + This.BorderSize
END IF
IF LEN(Text(This.ID)) THEN
DIM TempText$, FindLF&, ThisItem%, ThisItemTop%
@ -1056,7 +1071,9 @@ SUB __UI_DrawListBox (This AS __UI_ControlTYPE, ControlState)
END IF
IF This.HasBorder THEN
LINE (0, 0)-STEP(This.Width - 1, This.Height - 1), This.BorderColor, B
FOR i = 0 TO This.BorderSize - 1
LINE (i, i)-STEP(This.Width - 1 - i * 2, This.Height - 1 - i * 2), This.BorderColor, B
NEXT
END IF
'------
@ -1178,7 +1195,7 @@ END SUB
'---------------------------------------------------------------------------------
SUB __UI_DrawDropdownList (This AS __UI_ControlTYPE, ControlState)
DIM PrevDest AS LONG, Temp&
DIM PrevDest AS LONG, Temp&, i AS LONG
DIM CaptionIndent AS INTEGER, TempCaption$
STATIC ControlImage AS LONG
@ -1231,10 +1248,17 @@ SUB __UI_DrawDropdownList (This AS __UI_ControlTYPE, ControlState)
CLS , _RGBA32(0, 0, 0, 0)
END IF
CaptionIndent = 0
IF This.HasBorder THEN
CaptionIndent = 5
LINE (0, 0)-STEP(This.Width - 1, This.Height - 1), This.BorderColor, B
IF This.BorderSize > __UI_MaxBorderSize THEN
This.BorderSize = __UI_MaxBorderSize
ELSEIF This.BorderSize < 1 THEN
This.BorderSize = 1
END IF
CaptionIndent = __UI_DefaultCaptionIndent + This.BorderSize
FOR i = 0 TO This.BorderSize - 1
LINE (i, i)-STEP(This.Width - 1 - i * 2, This.Height - 1 - i * 2), This.BorderColor, B
NEXT
END IF
DIM TempText$, ThisItem%, FindLF&, ThisItemTop%
@ -1630,7 +1654,7 @@ END SUB
'---------------------------------------------------------------------------------
SUB __UI_DrawPictureBox (This AS __UI_ControlTYPE, ControlState AS _BYTE)
DIM PrevDest AS LONG, TheX AS INTEGER, TheY AS INTEGER
DIM CaptionIndent AS INTEGER, TempCaption$
DIM CaptionIndent AS INTEGER, TempCaption$, i AS LONG
IF This.Redraw OR This.Stretch <> This.PreviousStretch OR This.PreviousValue <> This.HelperCanvas OR This.ControlState <> ControlState OR This.PreviousParentID <> This.ParentID OR __UI_ForceRedraw THEN
'Last time this control was drawn it had a different state/caption, so it'll be redrawn
@ -1656,22 +1680,32 @@ SUB __UI_DrawPictureBox (This AS __UI_ControlTYPE, ControlState AS _BYTE)
CLS , _RGBA32(0, 0, 0, 0)
END IF
IF This.Stretch THEN
_PUTIMAGE (0, 0)-(This.Width - 1, This.Height - 1), This.HelperCanvas, This.Canvas
ELSE
TheX = 0 'Default = Left
IF This.Align = __UI_Center THEN TheX = This.Width / 2 - _WIDTH(This.HelperCanvas) / 2
IF This.Align = __UI_Right THEN TheX = This.Width - 1 - _WIDTH(This.HelperCanvas)
IF This.HasBorder THEN
IF This.BorderSize > __UI_MaxBorderSize THEN
This.BorderSize = __UI_MaxBorderSize
ELSEIF This.BorderSize < 1 THEN
This.BorderSize = 1
END IF
END IF
TheY = 0 'Default = Top
IF This.Stretch THEN
_PUTIMAGE (This.BorderSize * ABS(This.HasBorder), This.BorderSize * ABS(This.HasBorder))-(This.Width - (This.BorderSize * ABS(This.HasBorder) + 1), This.Height - (This.BorderSize * ABS(This.HasBorder) + 1)), This.HelperCanvas, This.Canvas
ELSE
TheX = This.BorderSize * ABS(This.HasBorder) 'Default = Left
IF This.Align = __UI_Center THEN TheX = This.Width / 2 - _WIDTH(This.HelperCanvas) / 2
IF This.Align = __UI_Right THEN TheX = This.Width - 1 - _WIDTH(This.HelperCanvas) - (This.BorderSize * ABS(This.HasBorder))
TheY = This.BorderSize * ABS(This.HasBorder) 'Default = Top
IF This.VAlign = __UI_Middle THEN TheY = This.Height / 2 - _HEIGHT(This.HelperCanvas) / 2
IF This.VAlign = __UI_Bottom THEN TheY = This.Height - 1 - _HEIGHT(This.HelperCanvas)
IF This.VAlign = __UI_Bottom THEN TheY = This.Height - 1 - _HEIGHT(This.HelperCanvas) - (This.BorderSize * ABS(This.HasBorder))
_PUTIMAGE (TheX, TheY), This.HelperCanvas, This.Canvas
END IF
IF This.HasBorder THEN
LINE (0, 0)-STEP(This.Width - 1, This.Height - 1), This.BorderColor, B
FOR i = 0 TO This.BorderSize - 1
LINE (i, i)-STEP(This.Width - 1 - i * 2, This.Height - 1 - i * 2), This.BorderColor, B
NEXT
END IF
'------