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

New PictureBox methods: BeginDraw and EndDraw. Also:

- Events __UI_TextChanged and __UI_ValueChanged are now also triggered if changes are detected while the display routines are run.
- Minor fixes to ToolTip display routine.
- New TrackBar behavior allows for negative ranges.
- Exposes new __UI_MAP function (borrowed from p5.js).
- Experimental support for multiline textboxes (not yet accessible via the editor).
This commit is contained in:
FellippeHeitor 2017-03-21 22:53:46 -03:00
parent 5a666b0eaf
commit 85c9f97383
5 changed files with 172 additions and 87 deletions

View file

@ -162,6 +162,7 @@ DIM SHARED __UI_IsResizing AS _BYTE, __UI_ResizingID AS LONG
DIM SHARED __UI_ResizeHandleHover AS _BYTE
DIM SHARED __UI_IsSelectingText AS _BYTE, __UI_IsSelectingTextOnID AS LONG
DIM SHARED __UI_SelectedText AS STRING, __UI_SelectionLength AS LONG
DIM SHARED __UI_StateHasChanged AS _BYTE
DIM SHARED __UI_DraggingThumb AS _BYTE, __UI_ThumbDragTop AS INTEGER
DIM SHARED __UI_DraggingThumbOnID AS LONG
DIM SHARED __UI_HasInput AS _BYTE, __UI_LastInputReceived AS DOUBLE
@ -806,7 +807,9 @@ SUB __UI_UpdateDisplay
__UI_DrawProgressBar Control(i), ControlState
CASE __UI_Type_TrackBar
'Track bars
__UI_StateHasChanged = False
__UI_DrawTrackBar Control(i), ControlState
IF __UI_StateHasChanged THEN __UI_ValueChanged i
CASE __UI_Type_TextBox
'Text boxes
'IF Control(i).InputViewStart = 0 THEN Control(i).InputViewStart = 1
@ -837,7 +840,9 @@ SUB __UI_UpdateDisplay
__UI_SelectionLength = LEN(__UI_SelectedText)
END IF
__UI_StateHasChanged = False
__UI_DrawTextBox Control(i), ControlState, ss1, ss2
IF __UI_StateHasChanged THEN __UI_TextChanged i
CASE __UI_Type_ListBox
'List boxes
IF Control(i).InputViewStart <= 0 THEN Control(i).InputViewStart = 1
@ -1083,17 +1088,16 @@ SUB __UI_UpdateDisplay
__UI_TempTips(__UI_ActiveTipID) = ToolTip(__UI_ActiveTipID)
DIM ThisLine%, TextTop%, Temp&
DIM FindLF AS LONG, TotalLines AS INTEGER, TempLine$
DIM FindLF AS LONG, TotalLines AS INTEGER, LongestLine AS INTEGER, TempLine$
_FONT Control(__UI_FormID).Font
TempCaption$ = __UI_WordWrap(ToolTip(__UI_ActiveTipID), Control(__UI_FormID).Width / 2, TotalLines)
TempCaption$ = __UI_WordWrap(ToolTip(__UI_ActiveTipID), Control(__UI_FormID).Width / 2, LongestLine, TotalLines)
PanelWidth = LongestLine + 16
IF TotalLines = 1 THEN
PanelWidth = __UI_PrintWidth(TempCaption$) + 10
PanelHeight = uspacing& + 5 + 5
PanelHeight = uspacing& + 8
ELSE
PanelWidth = Control(__UI_FormID).Width / 2 + 10
PanelHeight = (TotalLines * uspacing&) + 5 + 5
PanelHeight = (TotalLines * uspacing&) + 8
END IF
IF ActiveTipPanel <> 0 THEN _FREEIMAGE ActiveTipPanel
@ -1108,7 +1112,7 @@ SUB __UI_UpdateDisplay
ELSE
DO WHILE LEN(TempCaption$)
ThisLine% = ThisLine% + 1
TextTop% = 3 + ThisLine% * uheight& - uheight&
TextTop% = 3 + ThisLine% * uspacing& - uspacing&
FindLF& = INSTR(TempCaption$, CHR$(1))
IF FindLF& > 0 THEN
@ -1117,7 +1121,7 @@ SUB __UI_UpdateDisplay
ELSE
TempLine$ = TempCaption$
TempCaption$ = ""
IF ThisLine% = 1 THEN TextTop% = ((_HEIGHT \ 2) - uheight& \ 2)
IF ThisLine% = 1 THEN TextTop% = ((_HEIGHT \ 2) - uspacing& \ 2)
END IF
__UI_PrintString 5, TextTop%, TempLine$
@ -1269,9 +1273,10 @@ SUB __UI_EventDispatcher
IF __UI_LastHoveringID THEN __UI_MouseLeave __UI_LastHoveringID
__UI_MouseEnter __UI_HoveringID
STATIC LastMouseLeft AS INTEGER
IF NOT __UI_DraggingThumb AND __UI_HoveringID = __UI_ActiveDropdownList AND Control(__UI_HoveringID).HoveringVScrollbarButton = 0 THEN
STATIC LastMouseLeft AS INTEGER, LastMouseTop AS INTEGER
IF NOT __UI_DraggingThumb AND __UI_HoveringID = __UI_ActiveDropdownList AND Control(__UI_HoveringID).HoveringVScrollbarButton = 0 AND LastMouseTop <> __UI_MouseTop THEN
'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
IF ThisItem% >= Control(__UI_HoveringID).Min AND ThisItem% <= Control(__UI_HoveringID).Max THEN
@ -2012,17 +2017,20 @@ SUB __UI_EventDispatcher
END IF
IF Control(__UI_MouseDownOnID).Type = __UI_Type_TrackBar AND NOT Control(__UI_MouseDownOnID).Disabled THEN
Control(__UI_HoveringID).Value = INT(((__UI_MouseLeft - (ContainerOffsetLeft + Control(__UI_HoveringID).Left)) / Control(__UI_HoveringID).Width) * Control(__UI_HoveringID).Max)
Control(__UI_HoveringID).Value = __UI_MAP((__UI_MouseLeft - (ContainerOffsetLeft + Control(__UI_HoveringID).Left)), 0, Control(__UI_HoveringID).Width, Control(__UI_HoveringID).Min, Control(__UI_HoveringID).Max)
IF Control(__UI_HoveringID).Value < Control(__UI_HoveringID).Min THEN
Control(__UI_HoveringID).Value = Control(__UI_HoveringID).Min
END IF
IF Control(__UI_HoveringID).PreviousValue <> Control(__UI_HoveringID).Value THEN __UI_ValueChanged __UI_Focus
IF Control(__UI_HoveringID).Value > Control(__UI_HoveringID).Max THEN
Control(__UI_HoveringID).Value = Control(__UI_HoveringID).Max
END IF
IF Control(__UI_HoveringID).PreviousValue <> Control(__UI_HoveringID).Value THEN __UI_ValueChanged __UI_MouseDownOnID
END IF
END IF
END IF
IF __UI_MouseDownOnID = 0 AND Control(__UI_PreviousMouseDownOnID).Type = __UI_Type_TrackBar AND NOT Control(__UI_PreviousMouseDownOnID).Disabled THEN
Control(__UI_PreviousMouseDownOnID).Value = INT(((__UI_MouseLeft - (Control(Control(__UI_PreviousMouseDownOnID).ParentID).Left + Control(__UI_PreviousMouseDownOnID).Left)) / Control(__UI_PreviousMouseDownOnID).Width) * Control(__UI_PreviousMouseDownOnID).Max)
Control(__UI_PreviousMouseDownOnID).Value = __UI_MAP((__UI_MouseLeft - (Control(Control(__UI_PreviousMouseDownOnID).ParentID).Left + Control(__UI_PreviousMouseDownOnID).Left)), 0, Control(__UI_PreviousMouseDownOnID).Width, Control(__UI_PreviousMouseDownOnID).Min, Control(__UI_PreviousMouseDownOnID).Max)
IF Control(__UI_PreviousMouseDownOnID).Value > Control(__UI_PreviousMouseDownOnID).Max THEN Control(__UI_PreviousMouseDownOnID).Value = Control(__UI_PreviousMouseDownOnID).Max
IF Control(__UI_PreviousMouseDownOnID).Value < Control(__UI_PreviousMouseDownOnID).Min THEN Control(__UI_PreviousMouseDownOnID).Value = Control(__UI_PreviousMouseDownOnID).Min
IF Control(__UI_PreviousMouseDownOnID).PreviousValue <> Control(__UI_PreviousMouseDownOnID).Value THEN __UI_ValueChanged __UI_PreviousMouseDownOnID
@ -3210,6 +3218,7 @@ SUB __UI_EventDispatcher
END IF
IF __UI_KeyHit THEN
IF __UI_KeyHit = 13 THEN __UI_KeyHit = 10
IF Mask(__UI_Focus) = "" OR Control(__UI_Focus).Multiline THEN
IF NOT Control(__UI_Focus).TextIsSelected THEN
IF Control(__UI_Focus).Cursor = LEN(Text(__UI_Focus)) THEN
@ -4197,6 +4206,19 @@ SUB SetCaption (ThisID AS LONG, TempCaption$)
Caption(ThisID) = NewCaption$
END SUB
'---------------------------------------------------------------------------------
SUB BeginDraw(ThisID AS LONG)
IF Control(ThisID).Type <> __UI_Type_PictureBox THEN EXIT SUB
_DEST Control(ThisID).HelperCanvas
END SUB
'---------------------------------------------------------------------------------
SUB EndDraw(ThisID AS LONG)
IF Control(ThisID).Type <> __UI_Type_PictureBox THEN EXIT SUB
_DEST 0
Control(ThisID).PreviousValue = 0
END SUB
'---------------------------------------------------------------------------------
SUB LoadImage (This AS __UI_ControlTYPE, File$)
DIM PrevDest AS LONG, ErrorMessage$
@ -4400,21 +4422,21 @@ SUB __UI_DeleteSelectionMasked
END SUB
'---------------------------------------------------------------------------------
SUB __UI_CursorAdjustments
SUB __UI_CursorAdjustments(This AS LONG)
DIM i AS LONG, ThisLineStart AS LONG, ThisLineLen AS LONG
IF NOT Control(__UI_Focus).Multiline THEN
IF Control(__UI_Focus).VisibleCursor >= Control(__UI_Focus).Width THEN Control(__UI_Focus).InputViewStart = Control(__UI_Focus).InputViewStart + Control(__UI_Focus).Width / 4
IF Control(__UI_Focus).VisibleCursor <= 0 THEN Control(__UI_Focus).InputViewStart = Control(__UI_Focus).InputViewStart - Control(__UI_Focus).Width / 4
IF Control(__UI_Focus).InputViewStart < 0 THEN Control(__UI_Focus).InputViewStart = 0
ELSE
'ThisLineLen = LEN(__UI_GetTextBoxLine(__UI_Focus, Control(__UI_Focus).CurrentLine, ThisLineStart))
'IF Control(__UI_Focus).VisibleCursor > ThisLineLen THEN Control(__UI_Focus).VisibleCursor = ThisLineLen
'IF Control(__UI_Focus).VisibleCursor > Control(__UI_Focus).PrevVisibleCursor THEN
' IF Control(__UI_Focus).VisibleCursor - Control(__UI_Focus).InputViewStart + 2 > Control(__UI_Focus).FieldArea THEN Control(__UI_Focus).InputViewStart = (Control(__UI_Focus).VisibleCursor - Control(__UI_Focus).FieldArea) + 2
'ELSEIF Control(__UI_Focus).VisibleCursor < Control(__UI_Focus).PrevVisibleCursor THEN
' IF Control(__UI_Focus).VisibleCursor < Control(__UI_Focus).InputViewStart - 1 THEN Control(__UI_Focus).InputViewStart = Control(__UI_Focus).VisibleCursor
IF NOT Control(This).Multiline AND Control(This).Type = __UI_Type_TextBox THEN
IF Control(This).VisibleCursor >= Control(This).Width THEN Control(This).InputViewStart = Control(This).InputViewStart + Control(This).Width / 4
IF Control(This).VisibleCursor <= 0 THEN Control(This).InputViewStart = Control(This).InputViewStart - Control(This).Width / 4
IF Control(This).InputViewStart < 0 THEN Control(This).InputViewStart = 0
ELSEIF Control(This).Multiline AND Control(This).Type = __UI_Type_TextBox THEN
'ThisLineLen = LEN(__UI_GetTextBoxLine(This, Control(This).CurrentLine, ThisLineStart))
'IF Control(This).VisibleCursor > ThisLineLen THEN Control(This).VisibleCursor = ThisLineLen
'IF Control(This).VisibleCursor > Control(This).PrevVisibleCursor THEN
' IF Control(This).VisibleCursor - Control(This).InputViewStart + 2 > Control(This).FieldArea THEN Control(This).InputViewStart = (Control(This).VisibleCursor - Control(This).FieldArea) + 2
'ELSEIF Control(This).VisibleCursor < Control(This).PrevVisibleCursor THEN
' IF Control(This).VisibleCursor < Control(This).InputViewStart - 1 THEN Control(This).InputViewStart = Control(This).VisibleCursor
'END IF
'IF Control(__UI_Focus).InputViewStart < 1 THEN Control(__UI_Focus).InputViewStart = 1
'IF Control(This).InputViewStart < 1 THEN Control(This).InputViewStart = 1
END IF
END SUB
@ -4731,11 +4753,13 @@ FUNCTION __UI_PrintWidth&(Text$)
END FUNCTION
'---------------------------------------------------------------------------------
FUNCTION __UI_WordWrap$ (PassedText AS STRING, Width AS INTEGER, Lines AS INTEGER)
FUNCTION __UI_WordWrap$ (PassedText AS STRING, Width AS INTEGER, LongestLine AS INTEGER, Lines AS INTEGER)
DIM Temp$, TempCaption$, FindSep AS LONG, PrevSep AS LONG
DIM NextSlot AS LONG, TempLine$, i AS LONG, Text AS STRING
DIM ThisLineWidth AS INTEGER
Text = RTRIM$(PassedText)
IF Text = "" THEN Lines = 1: EXIT FUNCTION
FOR i = 1 TO UBOUND(__UI_WordWrapHistoryTexts)
IF __UI_WordWrapHistoryTexts(i) = "" THEN EXIT FOR
@ -4764,6 +4788,7 @@ FUNCTION __UI_WordWrap$ (PassedText AS STRING, Width AS INTEGER, Lines AS INTEGE
__UI_WordWrapHistory(NextSlot).Width = Width
__UI_WordWrapHistory(NextSlot).Font = _FONT
Lines = 0
LongestLine = 0
TempCaption$ = Text
IF __UI_PrintWidth&(TempCaption$) > Width THEN
'Word wrap is faster for fixed-width fonts.
@ -4781,6 +4806,8 @@ FUNCTION __UI_WordWrap$ (PassedText AS STRING, Width AS INTEGER, Lines AS INTEGE
DO WHILE LEN(TempLine$)
IF __UI_PrintWidth&(TempLine$) < Width THEN
IF LEN(Temp$) > 0 THEN Temp$ = Temp$ + CHR$(1)
ThisLineWidth = __UI_PrintWidth(Templine$)
IF LongestLine < ThisLineWidth THEN LongestLine = ThisLineWidth
Temp$ = Temp$ + TempLine$
TempLine$ = ""
Lines = Lines + 1
@ -4800,6 +4827,8 @@ FUNCTION __UI_WordWrap$ (PassedText AS STRING, Width AS INTEGER, Lines AS INTEGE
ELSE
IF LEN(Temp$) > 0 THEN Temp$ = Temp$ + CHR$(1)
Temp$ = Temp$ + LEFT$(TempLine$, PrevSep - 1)
ThisLineWidth = __UI_PrintWidth(LEFT$(TempLine$, PrevSep - 1))
IF LongestLine < ThisLineWidth THEN LongestLine = ThisLineWidth
TempLine$ = MID$(TempLine$, PrevSep + 1)
Lines = Lines + 1
EXIT DO
@ -4810,12 +4839,16 @@ FUNCTION __UI_WordWrap$ (PassedText AS STRING, Width AS INTEGER, Lines AS INTEGE
IF PrevSep > 0 THEN
IF LEN(Temp$) > 0 THEN Temp$ = Temp$ + CHR$(1)
Temp$ = Temp$ + LEFT$(TempLine$, PrevSep - 1)
ThisLineWidth = __UI_PrintWidth(LEFT$(TempLine$, PrevSep - 1))
IF LongestLine < ThisLineWidth THEN LongestLine = ThisLineWidth
TempLine$ = MID$(TempLine$, PrevSep + 1)
Lines = Lines + 1
EXIT DO
ELSE
IF LEN(Temp$) > 0 THEN Temp$ = Temp$ + CHR$(1)
Temp$ = Temp$ + Templine$
ThisLineWidth = __UI_PrintWidth(Templine$)
IF LongestLine < ThisLineWidth THEN LongestLine = ThisLineWidth
TempLine$ = ""
Lines = Lines + 1
EXIT DO
@ -4831,6 +4864,7 @@ FUNCTION __UI_WordWrap$ (PassedText AS STRING, Width AS INTEGER, Lines AS INTEGE
ELSE
'Count line breaks
Lines = 1
LongestLine = 0
Temp$ = TempCaption$
FindSep = INSTR(TempCaption$, CHR$(10))
IF FindSep > 0 THEN
@ -4842,6 +4876,8 @@ FUNCTION __UI_WordWrap$ (PassedText AS STRING, Width AS INTEGER, Lines AS INTEGE
Lines = Lines + 1
IF LEN(Temp$) > 0 THEN Temp$ = Temp$ + CHR$(1)
Temp$ = Temp$ + LEFT$(TempCaption$, FindSep - 1)
ThisLineWidth = __UI_PrintWidth(LEFT$(TempCaption$, FindSep - 1))
IF LongestLine < ThisLineWidth THEN LongestLine = ThisLineWidth
TempCaption$ = MID$(TempCaption$, FindSep + 1)
ELSE
Lines = Lines + 1
@ -4849,6 +4885,8 @@ FUNCTION __UI_WordWrap$ (PassedText AS STRING, Width AS INTEGER, Lines AS INTEGE
EXIT DO
END IF
LOOP
ELSE
LongestLine = __UI_PrintWidth(TempCaption$)
END IF
__UI_WordWrap$ = Temp$
@ -4874,6 +4912,11 @@ FUNCTION MessageBox& (Message$, Title$, Setup AS LONG)
$END IF
END FUNCTION
'---------------------------------------------------------------------------------
FUNCTION __UI_MAP## (value##, minRange##, maxRange##, newMinRange##, newMaxRange##)
__UI_MAP## = ((value## - minRange##) / (maxRange## - minRange##)) * (newMaxRange## - newMinRange##) + newMinRange##
END FUNCTION
'---------------------------------------------------------------------------------
SUB __UI_ActivateDropdownlist (This AS __UI_ControlTYPE)
IF NOT This.Disabled THEN

View file

@ -758,7 +758,7 @@ SUB __UI_BeforeUpdateDisplay
END SELECT
Control(PropertyUpdateStatusID).Hidden = True
ELSEIF FirstSelected > 0 THEN
__UI_CursorAdjustments
__UI_CursorAdjustments PropertyValueID
DIM PropertyAccept AS _BYTE
SELECT CASE SelectedProperty
CASE 1 'Name

Binary file not shown.

View file

@ -186,7 +186,7 @@ SUB __UI_DrawLabel (This AS __UI_ControlTYPE, ControlState AS _BYTE)
DIM CaptionLeftFirstLine AS INTEGER, CaptionTopFirstLine AS INTEGER, TextTop%
DIM TotalLines AS INTEGER
IF This.WordWrap THEN
TempCaption$ = __UI_TrimAt0$(__UI_WordWrap(Caption(This.ID), This.Width - ((CaptionIndent + This.Padding) * 2), TotalLines))
TempCaption$ = __UI_TrimAt0$(__UI_WordWrap(Caption(This.ID), This.Width - ((CaptionIndent + This.Padding) * 2), 0, TotalLines))
DO WHILE LEN(TempCaption$)
ThisLine% = ThisLine% + 1
@ -460,8 +460,6 @@ SUB __UI_DrawProgressBar (This AS __UI_ControlTYPE, ControlState)
CLS , _RGBA32(0, 0, 0, 0)
'------
DIM DisplayValue AS _FLOAT
'Draw track
'Back
_PUTIMAGE (5, 4)-STEP(This.Width - 9, This.Height - 8), ControlImage_Track, , (5, 4)-STEP(0, 11)
@ -540,7 +538,10 @@ SUB __UI_DrawTrackBar (This AS __UI_ControlTYPE, ControlState)
'Last time this control was drawn it had a different state/caption, so it'll be redrawn
This.ControlState = TempControlState
This.FocusState = __UI_Focus = This.ID
This.PreviousValue = This.Value
IF This.PreviousValue <> This.Value THEN
__UI_StateHasChanged = True
This.PreviousValue = This.Value
END IF
IF This.ParentID THEN Control(This.ParentID).ChildrenRedrawn = True
This.PreviousParentID = This.ParentID
@ -556,8 +557,6 @@ SUB __UI_DrawTrackBar (This AS __UI_ControlTYPE, ControlState)
CLS , _RGBA32(0, 0, 0, 0)
'------
DIM DisplayValue AS _FLOAT
'Draw track
_PUTIMAGE (3, 10), ControlImage_Track, , (0, 0)-STEP(1, 4)
_PUTIMAGE (5, 10)-STEP(This.Width - 10, 5), ControlImage_Track, , (2, 0)-STEP(0, 4)
@ -566,13 +565,13 @@ SUB __UI_DrawTrackBar (This AS __UI_ControlTYPE, ControlState)
'Interval ticks
LINE (5, 30)-STEP(0, 3), This.BorderColor
IF This.Interval = 0 THEN This.Interval = 1
FOR i = This.Interval TO This.Max STEP This.Interval
LINE (5 + (This.Width - SliderWidth) * (i / This.Max), 30)-STEP(0, 2), This.BorderColor
FOR i = This.Min TO This.Max STEP This.Interval
LINE (__UI_MAP(i, This.Min, This.Max, 5, This.Width - 6), 30)-STEP(0, 2), This.BorderColor
NEXT i
LINE (5 + (This.Width - SliderWidth), 30)-STEP(0, 3), This.BorderColor
'Draw slider
_PUTIMAGE ((This.Width - SliderWidth) * (This.Value / This.Max), 2), ControlImage_Slider, , (0, TempControlState * SliderHeight - SliderHeight)-STEP(SliderWidth - 1, SliderHeight - 1)
_PUTIMAGE (__UI_MAP(This.Value, This.Min, This.Max, 0, This.Width - SliderWidth), 2), ControlImage_Slider, , (0, TempControlState * SliderHeight - SliderHeight)-STEP(SliderWidth - 1, SliderHeight - 1)
'Focus outline
IF __UI_Focus = This.ID AND __UI_KeyboardFocus THEN
@ -596,7 +595,7 @@ SUB __UI_DrawTextBox (This AS __UI_ControlTYPE, ControlState, ss1 AS LONG, ss2 A
IF This.FirstVisibleLine = 0 THEN This.FirstVisibleLine = 1
IF This.CurrentLine = 0 THEN This.CurrentLine = 1
IF __UI_Focus = This.ID THEN __UI_CursorAdjustments
__UI_CursorAdjustments This.ID
IF This.ControlState <> ControlState OR _
This.FocusState <> (__UI_Focus = This.ID) OR _
@ -610,11 +609,16 @@ SUB __UI_DrawTextBox (This AS __UI_ControlTYPE, ControlState, ss1 AS LONG, ss2 A
This.CurrentLine <> This.PrevCurrentLine OR _
Mask(This.ID) <> __UI_TempMask(This.ID) OR _
__UI_ForceRedraw THEN
'Last time this control was drawn it had a different state/caption, so it'll be redrawn
This.ControlState = ControlState
This.FocusState = __UI_Focus = This.ID
__UI_TempCaptions(This.ID) = Caption(This.ID)
__UI_TempMask(This.ID) = Mask(This.ID)
IF __UI_TempTexts(This.ID) <> Text(This.ID) THEN
__UI_StateHasChanged = True
__UI_TempTexts(This.ID) = Text(This.ID)
END IF
This.SelectionLength = __UI_SelectionLength
This.PrevCursor = This.Cursor
This.PrevVisibleCursor = This.VisibleCursor
@ -642,7 +646,7 @@ SUB __UI_DrawTextBox (This AS __UI_ControlTYPE, ControlState, ss1 AS LONG, ss2 A
IF This.HasBorder THEN CaptionIndent = 5
IF NOT This.Disabled AND LEN(Text(This.ID)) THEN
IF NOT This.Disabled AND (LEN(Text(This.ID)) OR This.Multiline) THEN
COLOR This.ForeColor, This.BackColor
ELSE
COLOR Darken(Control(__UI_FormID).BackColor, 80), This.BackColor
@ -660,13 +664,6 @@ SUB __UI_DrawTextBox (This AS __UI_ControlTYPE, ControlState, ss1 AS LONG, ss2 A
IF LEN(ThisTempText$) > 0 AND This.PasswordField = True THEN
ThisTempText$ = STRING$(LEN(ThisTempText$), 7)
'IF This.Font <> 8 AND This.Font <> 16 THEN
' ThisTempText$ = ""
' FOR i = 1 TO LEN(Text(This.ID))
' ThisTempText$ = ThisTempText$ + CHR$(7)
' NEXT
'ELSE
'END IF
END IF
IF ((__UI_Focus = This.ID) OR (This.ID = __UI_PreviousFocus AND __UI_ParentMenu = This.ContextMenuID)) AND NOT This.Disabled THEN
@ -696,7 +693,6 @@ SUB __UI_DrawTextBox (This AS __UI_ControlTYPE, ControlState, ss1 AS LONG, ss2 A
LINE (This.VisibleCursor, ((This.Height \ 2) - uspacing& \ 2))-STEP(0, uspacing&), _RGB32(0, 0, 0)
END IF
END SELECT
ELSE
IF LEN(Text(This.ID)) THEN
__UI_PrintString CaptionIndent, ((This.Height \ 2) - uspacing& \ 2), ThisTempText$
@ -711,8 +707,9 @@ SUB __UI_DrawTextBox (This AS __UI_ControlTYPE, ControlState, ss1 AS LONG, ss2 A
ELSE
'Multi line textbox
DIM ThisLine AS LONG, ThisTop AS INTEGER, TempLine AS STRING
DIM TotalLines AS LONG, ThisLineStart AS LONG
DIM TotalLines AS INTEGER, ThisLineStart AS LONG
DIM s1 AS LONG, s2 AS LONG
STATIC PrevTotalLines AS LONG
IF This.TextIsSelected THEN
s1 = This.SelectionStart + 1
@ -722,58 +719,97 @@ SUB __UI_DrawTextBox (This AS __UI_ControlTYPE, ControlState, ss1 AS LONG, ss2 A
END IF
ThisTop = CaptionIndent - uspacing&
TotalLines = __UI_CountLines(This.ID)
TempCaption$ = __UI_TrimAt0$(__UI_WordWrap(Text(This.ID), This.Width - __UI_ScrollbarWidth - 5, 0, TotalLines))
IF This.HelperCanvas = 0 OR PrevTotalLines <> TotalLines THEN
PrevTotalLines = TotalLines
IF This.HelperCanvas < -1 THEN _FREEIMAGE This.HelperCanvas
This.HelperCanvas = _NEWIMAGE(This.Width - __UI_ScrollbarWidth, TotalLines * uspacing& + uspacing& / 2)
END IF
_DEST This.HelperCanvas
_FONT This.Font
CLS , This.BackColor
IF TIMER - SetCursor# > .3 THEN
SetCursor# = TIMER
cursorBlink%% = NOT cursorBlink%%
END IF
FOR ThisLine = This.FirstVisibleLine TO TotalLines
IF ThisTop > This.Height THEN EXIT FOR 'Print until out of the box
ThisTop = ThisTop + uspacing&
TempLine = __UI_GetTextBoxLine$(This.ID, ThisLine, ThisLineStart)
'FOR ThisLine = 1 TO TotalLines
' ThisTop = ThisTop + uspacing&
' TempLine = __UI_GetTextBoxLine$(This.ID, ThisLine, ThisLineStart)
IF LEN(TempLine) THEN
__UI_PrintString CaptionIndent, ThisTop, MID$(TempLine, This.InputViewStart)
END IF
' IF LEN(TempLine) THEN
' __UI_PrintString CaptionIndent, ThisTop, MID$(TempLine, This.InputViewStart)
' END IF
IF This.TextIsSelected THEN
IF s1 >= ThisLineStart AND s2 < ThisLineStart + LEN(TempLine) THEN
'Only a portion of this line is selected
LINE (CaptionIndent + __UI_ThisLineChars(s1 - ThisLineStart), ThisTop)-(__UI_ThisLineChars(s2 - ThisLineStart + 1), ThisTop + uspacing& - 1), c, BF
ELSEIF s1 >= ThisLineStart AND s1 <= ThisLineStart + LEN(TempLine) THEN
'The beginning of the selection is in this line waiting to be highlighted.
LINE (CaptionIndent + __UI_ThisLineChars(s1 - ThisLineStart), ThisTop)-STEP(This.Width, uspacing& - 1), c, BF
ELSEIF s1 < ThisLineStart AND s2 > ThisLineStart + LEN(TempLine) THEN
'This whole line is selected
LINE (CaptionIndent, ThisTop)-STEP(This.Width, uspacing& - 1), c, BF
ELSEIF s1< ThisLineStart AND s2 <= ThisLineStart + LEN(TempLine) THEN
'Selection ends in this line
LINE (CaptionIndent, ThisTop)-STEP(__UI_ThisLineChars(s2 - ThisLineStart), uspacing& - 1), c, BF
' IF This.TextIsSelected THEN
' IF s1 >= ThisLineStart AND s2 < ThisLineStart + LEN(TempLine) THEN
' 'Only a portion of this line is selected
' LINE (CaptionIndent + __UI_ThisLineChars(s1 - ThisLineStart), ThisTop)-(__UI_ThisLineChars(s2 - ThisLineStart + 1), ThisTop + uspacing& - 1), c, BF
' ELSEIF s1 >= ThisLineStart AND s1 <= ThisLineStart + LEN(TempLine) THEN
' 'The beginning of the selection is in this line waiting to be highlighted.
' LINE (CaptionIndent + __UI_ThisLineChars(s1 - ThisLineStart), ThisTop)-STEP(This.Width, uspacing& - 1), c, BF
' ELSEIF s1 < ThisLineStart AND s2 > ThisLineStart + LEN(TempLine) THEN
' 'This whole line is selected
' LINE (CaptionIndent, ThisTop)-STEP(This.Width, uspacing& - 1), c, BF
' ELSEIF s1< ThisLineStart AND s2 <= ThisLineStart + LEN(TempLine) THEN
' 'Selection ends in this line
' LINE (CaptionIndent, ThisTop)-STEP(__UI_ThisLineChars(s2 - ThisLineStart), uspacing& - 1), c, BF
' END IF
' END IF
' 'IF ThisLine = This.CurrentLine THEN
' ' IF cursorBlink%% AND __UI_Focus = This.ID AND This.CurrentLine >= This.FirstVisibleLine AND This.CurrentLine <= This.FirstVisibleLine + This.Height \ uspacing& THEN
' ' LINE (CaptionIndent + __UI_ThisLineChars(This.VisibleCursor - (This.InputViewStart - 1)), ThisTop)-STEP(0, uspacing&), _RGB32(0, 0, 0)
' ' END IF
' 'END IF
'NEXT
DO WHILE LEN(TempCaption$)
DIM ThisLine%, TextTop%, FindSep&, FindLF&, CaptionLeft AS INTEGER
ThisLine% = ThisLine% + 1
TextTop% = CaptionIndent + ThisLine% * uspacing& - uspacing&
FindSep& = INSTR(TempCaption$, CHR$(1)) 'Search for soft breaks
FindLF& = INSTR(TempCaption$, CHR$(10)) 'Search for hard breaks
IF (FindSep& > 0 AND FindLF& > 0 AND FindSep& < FindLF&) OR (FindSep& > 0 AND FindLF& = 0) THEN
TempLine$ = LEFT$(TempCaption$, FindSep& - 1)
TempCaption$ = MID$(TempCaption$, FindSep& + 1)
ELSEIF FindSep& = 0 THEN
IF FindLF& > 0 THEN
TempLine$ = LEFT$(TempCaption$, FindLF& - 1)
TempCaption$ = MID$(TempCaption$, FindLF& + 1)
ELSE
TempLine$ = TempCaption$
TempCaption$ = ""
END IF
END IF
IF ThisLine = This.CurrentLine THEN
IF cursorBlink%% AND __UI_Focus = This.ID AND This.CurrentLine >= This.FirstVisibleLine AND This.CurrentLine <= This.FirstVisibleLine + This.Height \ uspacing& THEN
LINE (CaptionIndent + __UI_ThisLineChars(This.VisibleCursor - (This.InputViewStart - 1)), ThisTop)-STEP(0, uspacing&), _RGB32(0, 0, 0)
END IF
END IF
NEXT
CaptionLeft = CaptionIndent
FOR i = Control(__UI_Focus).Cursor TO 0 STEP -1
IF MID$(Text(__UI_Focus), i, 1) = CHR$(10) OR i = 0 THEN
Control(__UI_Focus).VisibleCursor = Control(__UI_Focus).Cursor - i
EXIT FOR
END IF
NEXT
__UI_PrintString CaptionLeft, TextTop%, TempLine$
LOOP
IF This.ID = __UI_Focus THEN
FOR i = Control(__UI_Focus).Cursor TO 0 STEP -1
IF MID$(Text(__UI_Focus), i, 1) = CHR$(10) OR i = 0 THEN
Control(__UI_Focus).VisibleCursor = Control(__UI_Focus).Cursor - i
EXIT FOR
END IF
NEXT
END IF
_DEST This.Canvas
_PUTIMAGE (0,0),This.HelperCanvas
IF TotalLines > This.Height \ uspacing& THEN
This.FieldArea = This.Width / _FONTWIDTH((This.Font)) - 3
This.HasVScrollbar = True
__UI_DrawVScrollBar This, ControlState
ELSE
This.HasVScrollbar = False
__UI_DrawVScrollBar This, 4 'ControlState = 4 (Disabled)
END IF
END IF
@ -876,7 +912,7 @@ SUB __UI_DrawListBox (This AS __UI_ControlTYPE, ControlState)
END SELECT
END IF
LOOP
IF This.LastVisibleItem = 0 THEN This.LastVisibleItem = LastVisibleItem
IF This.LastVisibleItem < LastVisibleItem THEN This.LastVisibleItem = LastVisibleItem
IF This.Max > This.LastVisibleItem THEN
This.HasVScrollbar = True
@ -948,7 +984,7 @@ SUB __UI_DrawVScrollBar (TempThis AS __UI_ControlTYPE, ControlState AS _BYTE)
TempThis.ThumbTop = TempThis.Top + ThumbTop + __UI_ScrollbarButtonHeight
'Draw the bar
IF NOT This.Disabled THEN
IF ControlState <> 4 THEN
_PUTIMAGE (This.Left, This.Top)-STEP(ImageWidth_Button - 1, This.Height - 1), ControlImage_Track, , (0, 1 * ImageHeight_Button - ImageHeight_Button)-STEP(ImageWidth_Button - 1, ImageHeight_Button - 1)
ELSE
_PUTIMAGE (This.Left, This.Top)-STEP(ImageWidth_Button - 1, This.Height - 1), ControlImage_Track, , (0, 4 * ImageHeight_Button - ImageHeight_Button)-STEP(ImageWidth_Button - 1, ImageHeight_Button - 1)
@ -964,7 +1000,9 @@ SUB __UI_DrawVScrollBar (TempThis AS __UI_ControlTYPE, ControlState AS _BYTE)
END IF
'Draw buttons
IF This.HoveringVScrollbarButton = 1 AND __UI_MouseDownOnID = This.ID THEN
IF ControlState = 4 THEN
_PUTIMAGE (This.Left, This.Top)-STEP(ImageWidth_Button - 1, ImageHeight_Button - 1), ControlImage_Button, , (0, 4 * ImageHeight_Button - ImageHeight_Button)-STEP(ImageWidth_Button - 1, ImageHeight_Button - 1)
ELSEIF This.HoveringVScrollbarButton = 1 AND __UI_MouseDownOnID = This.ID THEN
_PUTIMAGE (This.Left, This.Top)-STEP(ImageWidth_Button - 1, ImageHeight_Button - 1), ControlImage_Button, , (0, 3 * ImageHeight_Button - ImageHeight_Button)-STEP(ImageWidth_Button - 1, ImageHeight_Button - 1)
ELSEIF This.HoveringVScrollbarButton = 1 THEN
_PUTIMAGE (This.Left, This.Top)-STEP(ImageWidth_Button - 1, ImageHeight_Button - 1), ControlImage_Button, , (0, 2 * ImageHeight_Button - ImageHeight_Button)-STEP(ImageWidth_Button - 1, ImageHeight_Button - 1)
@ -972,7 +1010,9 @@ SUB __UI_DrawVScrollBar (TempThis AS __UI_ControlTYPE, ControlState AS _BYTE)
_PUTIMAGE (This.Left, This.Top)-STEP(ImageWidth_Button - 1, ImageHeight_Button - 1), ControlImage_Button, , (0, 1 * ImageHeight_Button - ImageHeight_Button)-STEP(ImageWidth_Button - 1, ImageHeight_Button - 1)
END IF
IF This.HoveringVScrollbarButton = 2 AND __UI_MouseDownOnID = This.ID THEN
IF ControlState = 4 THEN
_PUTIMAGE (This.Left, This.Top + This.Height - ImageHeight_Button - 1)-STEP(ImageWidth_Button - 1, ImageHeight_Button - 1), ControlImage_Button, , (0, 8 * ImageHeight_Button - ImageHeight_Button)-STEP(ImageWidth_Button - 1, ImageHeight_Button - 1)
ELSEIF This.HoveringVScrollbarButton = 2 AND __UI_MouseDownOnID = This.ID THEN
_PUTIMAGE (This.Left, This.Top + This.Height - ImageHeight_Button - 1)-STEP(ImageWidth_Button - 1, ImageHeight_Button - 1), ControlImage_Button, , (0, 7 * ImageHeight_Button - ImageHeight_Button)-STEP(ImageWidth_Button - 1, ImageHeight_Button - 1)
ELSEIF This.HoveringVScrollbarButton = 2 THEN
_PUTIMAGE (This.Left, This.Top + This.Height - ImageHeight_Button - 1)-STEP(ImageWidth_Button - 1, ImageHeight_Button - 1), ControlImage_Button, , (0, 6 * ImageHeight_Button - ImageHeight_Button)-STEP(ImageWidth_Button - 1, ImageHeight_Button - 1)
@ -981,7 +1021,9 @@ SUB __UI_DrawVScrollBar (TempThis AS __UI_ControlTYPE, ControlState AS _BYTE)
END IF
'Draw thumb
IF __UI_DraggingThumb = True THEN
IF ControlState = 4 THEN
'No thumb is shown for disabled scrollbar
ELSEIF __UI_DraggingThumb = True THEN
_PUTIMAGE (This.Left + 1, ThumbTop + __UI_ScrollbarButtonHeight)-STEP(ImageWidth_Thumb - 2, ThumbHeight - 1), ControlImage_Thumb, , (0, 3 * ImageHeight_Thumb - ImageHeight_Thumb + 2)-STEP(ImageWidth_Thumb - 1, ImageHeight_Thumb - 5)
_PUTIMAGE (This.Left + 1, ThumbTop + __UI_ScrollbarButtonHeight)-STEP(ImageWidth_Thumb - 2, 1), ControlImage_Thumb, , (0, 3 * ImageHeight_Thumb - ImageHeight_Thumb)-STEP(ImageWidth_Thumb - 1, 1)
_PUTIMAGE (This.Left + 1, ThumbTop + __UI_ScrollbarButtonHeight + ThumbHeight - 2)-STEP(ImageWidth_Thumb - 2, 1), ControlImage_Thumb, , (0, 3 * ImageHeight_Thumb - 4)-STEP(ImageWidth_Thumb - 1, 3)

Binary file not shown.