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

Adjusts ListBox height to give items more vertical spacing.

This commit is contained in:
FellippeHeitor 2018-09-04 11:23:00 -03:00
parent 6c4f729ef7
commit e83bd67965
2 changed files with 17 additions and 14 deletions

View file

@ -81,6 +81,7 @@ TYPE __UI_ControlTYPE
InputViewStart AS LONG
PreviousInputViewStart AS LONG
LastVisibleItem AS INTEGER
ItemHeight AS INTEGER
HasVScrollbar AS _BYTE
VScrollbarButton2Top AS INTEGER
HoveringVScrollbarButton AS _BYTE
@ -1677,7 +1678,7 @@ SUB __UI_EventDispatcher
'Dropdown list items are preselected when hovered
LastMouseTop = __UI_MouseTop
IF Control(__UI_HoveringID).Font > 0 THEN _FONT Control(__UI_HoveringID).Font
ThisItem% = ((__UI_MouseTop - (ContainerOffsetTop + Control(__UI_HoveringID).Top)) \ uspacing&) + Control(__UI_HoveringID).InputViewStart
ThisItem% = ((__UI_MouseTop - (ContainerOffsetTop + Control(__UI_HoveringID).Top) - (ABS(Control(__UI_HoveringID).HasBorder) * __UI_DefaultCaptionIndent)) \ Control(__UI_HoveringID).ItemHeight) + Control(__UI_HoveringID).InputViewStart
IF ThisItem% >= Control(__UI_HoveringID).Min AND ThisItem% <= Control(__UI_HoveringID).Max THEN
Control(__UI_HoveringID).Value = ThisItem%
IF Control(__UI_HoveringID).PreviousValue <> Control(__UI_HoveringID).Value THEN
@ -2678,7 +2679,7 @@ SUB __UI_EventDispatcher
END IF
ELSE
_FONT Control(__UI_HoveringID).Font
ThisItem% = ((__UI_MouseTop - (ContainerOffsetTop + Control(__UI_HoveringID).Top)) \ uspacing&) + Control(__UI_HoveringID).InputViewStart
ThisItem% = ((__UI_MouseTop - (ContainerOffsetTop + Control(__UI_HoveringID).Top)) \ Control(__UI_HoveringID).ItemHeight) + Control(__UI_HoveringID).InputViewStart
IF ThisItem% >= Control(__UI_HoveringID).Min AND ThisItem% <= Control(__UI_HoveringID).Max THEN
Control(__UI_HoveringID).Value = ThisItem%
ELSE
@ -3674,7 +3675,7 @@ SUB __UI_EventDispatcher
END IF
END SELECT
CASE __UI_Type_ListBox, __UI_Type_DropdownList
DIM ThisItemTop%, CaptionIndent AS INTEGER
DIM CaptionIndent AS INTEGER
IF NOT Control(__UI_Focus).Disabled AND Control(__UI_Focus).Max > 0 THEN
_FONT (Control(__UI_Focus).Font)
SELECT EVERYCASE __UI_KeyHit
@ -5204,8 +5205,8 @@ SUB AddItem (WhichListBox AS LONG, TempItem$)
BorderOffset = ABS(Control(ThisID).HasBorder) * 5
_FONT Control(ThisID).Font
IF Control(ThisID).Max > FIX((Control(ThisID).Height - BorderOffset) \ uspacing) THEN
Control(ThisID).InputViewStart = Control(ThisID).Max - FIX((Control(ThisID).Height - BorderOffset) \ uspacing) + 1
IF Control(ThisID).Max > FIX((Control(ThisID).Height - BorderOffset) \ Control(ThisID).ItemHeight) THEN
Control(ThisID).InputViewStart = Control(ThisID).Max - FIX((Control(ThisID).Height - BorderOffset) \ Control(ThisID).ItemHeight) + 1
END IF
_FONT prevFont
END IF
@ -5612,7 +5613,7 @@ SUB __UI_ActivateDropdownlist (This AS __UI_ControlTYPE)
IF This.Max > 14 THEN MaxVisible = 14 ELSE MaxVisible = This.Max
_FONT This.Font
Control(__UI_ActiveDropdownList).Height = uspacing& * (MaxVisible + .5)
Control(__UI_ActiveDropdownList).Height = (falcon_uspacing& + (((_FONT = 8) * -1) * __UI_Font8Offset + ((_FONT = 16) * -1) * __UI_Font16Offset) + 3) * (MaxVisible + .5)
IF Control(__UI_ActiveDropdownList).Top + Control(__UI_ActiveDropdownList).Height > Control(__UI_FormID).Height THEN
Control(__UI_ActiveDropdownList).Top = Control(__UI_FormID).Height - Control(__UI_ActiveDropdownList).Height

View file

@ -1014,8 +1014,10 @@ SUB __UI_DrawListBox (This AS __UI_ControlTYPE, ControlState)
IF LEN(Text(This.ID)) THEN
DIM TempText$, FindLF&, ThisItem%, ThisItemTop%
DIM LastVisibleItem AS INTEGER
DIM ItemHeight AS INTEGER, LastVisibleItem AS INTEGER
ItemHeight = falcon_uspacing& + (((_FONT = 8) * -1) * __UI_Font8Offset + ((_FONT = 16) * -1) * __UI_Font16Offset) + 3
This.ItemHeight = ItemHeight
TempText$ = __UI_TrimAt0$(Text(This.ID))
ThisItem% = 0
DO WHILE LEN(TempText$)
@ -1029,8 +1031,8 @@ SUB __UI_DrawListBox (This AS __UI_ControlTYPE, ControlState)
TempText$ = ""
END IF
IF ThisItem% >= This.InputViewStart THEN
ThisItemTop% = ((ThisItem% - This.InputViewStart + 1) * uspacing& - uspacing&) + CaptionIndent
IF ThisItemTop% + uspacing& > This.Height THEN EXIT DO
ThisItemTop% = ((ThisItem% - This.InputViewStart + 1) * ItemHeight - ItemHeight) + CaptionIndent
IF ThisItemTop% + ItemHeight > This.Height THEN EXIT DO
LastVisibleItem = LastVisibleItem + 1
IF ThisItem% = This.Value AND __UI_Focus = This.ID THEN Caption(This.ID) = TempCaption$
@ -1044,19 +1046,19 @@ SUB __UI_DrawListBox (This AS __UI_ControlTYPE, ControlState)
IF ThisItem% = This.Value THEN
IF __UI_Focus = This.ID THEN
COLOR This.SelectedForeColor, This.SelectedBackColor
LINE (CaptionIndent, ThisItemTop% - 1)-STEP(This.Width - CaptionIndent * 2, uspacing&), This.SelectedBackColor, BF
LINE (CaptionIndent, ThisItemTop% - 1)-STEP(This.Width - CaptionIndent * 2, ItemHeight), This.SelectedBackColor, BF
ELSE
LINE (CaptionIndent, ThisItemTop% - 1)-STEP(This.Width - CaptionIndent * 2, uspacing&), _RGBA32(0, 0, 0, 50), BF
LINE (CaptionIndent, ThisItemTop% - 1)-STEP(This.Width - CaptionIndent * 2, ItemHeight), _RGBA32(0, 0, 0, 50), BF
END IF
END IF
SELECT CASE This.Align
CASE __UI_Left
__UI_PrintString CaptionIndent * 2, ThisItemTop%, TempCaption$
__UI_PrintString CaptionIndent * 2, ThisItemTop% + ((ItemHeight - uspacing&) / 2), TempCaption$
CASE __UI_Center
__UI_PrintString (This.Width \ 2 - __UI_PrintWidth(TempCaption$) \ 2), ThisItemTop%, TempCaption$
__UI_PrintString (This.Width \ 2 - __UI_PrintWidth(TempCaption$) \ 2), ThisItemTop% + ((ItemHeight - uspacing&) / 2), TempCaption$
CASE __UI_Right
__UI_PrintString (This.Width - __UI_PrintWidth(TempCaption$)) - CaptionIndent, ThisItemTop%, TempCaption$
__UI_PrintString (This.Width - __UI_PrintWidth(TempCaption$)) - CaptionIndent, ThisItemTop% + ((ItemHeight - uspacing&) / 2), TempCaption$
END SELECT
END IF
LOOP