diff options
author | graemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf> | 2007-07-15 10:52:08 +0000 |
---|---|---|
committer | graemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf> | 2007-07-15 10:52:08 +0000 |
commit | 9d17f385213027f6a6da2e3dd32d05de97847b5d (patch) | |
tree | 79aa5bc0ba0dd18fc6cf2ccbb901348030199be9 /prototypes | |
parent | 586585fa5758fbc44a2953f32ece46356663f5f1 (diff) | |
download | fpGUI-9d17f385213027f6a6da2e3dd32d05de97847b5d.tar.xz |
* ListBox: Fixed scrollbar positioning.
* Listbox: Got basic mouse click functionality working.
Diffstat (limited to 'prototypes')
-rw-r--r-- | prototypes/fpgui2/source/gui/gui_listbox.pas | 36 | ||||
-rw-r--r-- | prototypes/fpgui2/source/gui/gui_memo.pas | 25 |
2 files changed, 49 insertions, 12 deletions
diff --git a/prototypes/fpgui2/source/gui/gui_listbox.pas b/prototypes/fpgui2/source/gui/gui_listbox.pas index ec1683bd..e8ad4dde 100644 --- a/prototypes/fpgui2/source/gui/gui_listbox.pas +++ b/prototypes/fpgui2/source/gui/gui_listbox.pas @@ -23,6 +23,7 @@ type procedure SetFocusItem(const AValue: integer); procedure SetFontName(const AValue: string); procedure SetPopupFrame(const AValue: boolean); + procedure UpdateScrollbarCoords; protected FFont: TfpgFont; FScrollBar: TfpgScrollBar; @@ -44,6 +45,7 @@ type procedure HandleKeyPress(var keycode: word; var shiftstate: word; var consumed : boolean); override; procedure HandleLMouseDown(x, y: integer; shiftstate: word); override; procedure HandleLMouseUp(x, y: integer; shiftstate: word); override; + procedure HandleShow; override; // ToDo // * handle mouse move // * handle window scrolling @@ -105,6 +107,22 @@ begin RePaint; end; +procedure TfpgBaseListBox.UpdateScrollbarCoords; +var + HWidth: integer; + VHeight: integer; +begin + VHeight := Height - 4; + HWidth := Width - 4; + + if FScrollBar.Visible then Dec(HWidth, FScrollBar.Width); + + FScrollBar.Top := 2; + FScrollBar.Left := Width - FScrollBar.Width - 2; + FScrollBar.Height := VHeight; + FScrollBar.UpdateWindowPosition; +end; + procedure TfpgBaseListBox.DoShow; begin TfpgScrollbarFriend(FScrollBar).SetPosition(Width-18, 0, 18, Height); @@ -210,6 +228,18 @@ end; procedure TfpgBaseListBox.HandleLMouseDown(x, y: integer; shiftstate: word); begin inherited HandleLMouseDown(x, y, shiftstate); + + if ItemCount < 1 then + Exit; //==> + + FFocusItem := FFirstItem + Trunc((y - FMargin) / RowHeight); + if FFocusItem > ItemCount then + FFocusItem := ItemCount; + + FollowFocus; + FMouseDragging := true; + Repaint; + DoChange; end; procedure TfpgBaseListBox.HandleLMouseUp(x, y: integer; shiftstate: word); @@ -217,6 +247,12 @@ begin inherited HandleLMouseUp(x, y, shiftstate); end; +procedure TfpgBaseListBox.HandleShow; +begin + inherited HandleShow; + UpdateScrollBarCoords; +end; + procedure TfpgBaseListBox.HandleResize(dwidth, dheight: integer); begin inherited HandleResize(dwidth, dheight); diff --git a/prototypes/fpgui2/source/gui/gui_memo.pas b/prototypes/fpgui2/source/gui/gui_memo.pas index 53b0b7db..3b946105 100644 --- a/prototypes/fpgui2/source/gui/gui_memo.pas +++ b/prototypes/fpgui2/source/gui/gui_memo.pas @@ -22,6 +22,7 @@ type FMaxLength: integer; FCursorPos: integer; FCursorLine: integer; + FOnChange: TNotifyEvent; FSideMargin: integer; FSelStartLine: integer; FSelEndLine: integer; @@ -77,7 +78,7 @@ type property CursorLine: integer read FCursorLine write SetCursorLine; property Text: string read GetText write SetText; property Font: TfpgFont read FFont; - OnChange: TNotifyEvent; + property OnChange: TNotifyEvent read FOnChange write FOnChange; published property Lines: TStringList read FLines; property FontDesc: string read GetFontDesc write SetFontDesc; @@ -137,8 +138,8 @@ end; procedure TfpgMemo.UpdateScrollBarCoords; var - HWidth, - VHeight: Integer; + HWidth: integer; + VHeight: integer; begin VHeight := Height - 4; HWidth := Width - 4; @@ -146,13 +147,13 @@ begin if FVScrollBar.Visible then Dec(HWidth, FVScrollBar.Width); if FHScrollBar.Visible then Dec(VHeight, FHScrollBar.Height); - FHScrollBar.Top := Height -FHScrollBar.Height - 2; - FHScrollBar.Left := 2; - FHScrollBar.Width := HWidth; + FHScrollBar.Top := Height -FHScrollBar.Height - 2; + FHScrollBar.Left := 2; + FHScrollBar.Width := HWidth; - FVScrollBar.Top := 2; - FVScrollBar.Left := Width - FVScrollBar.Width - 2; - FVScrollBar.Height := VHeight; + FVScrollBar.Top := 2; + FVScrollBar.Left := Width - FVScrollBar.Width - 2; + FVScrollBar.Height := VHeight; FVScrollBar.UpdateWindowPosition; FHScrollBar.UpdateWindowPosition; end; @@ -170,7 +171,7 @@ begin FSideMargin := 3; FMaxLength := 0; - OnChange := nil; + FOnChange := nil; FLines := TStringList.Create; FFirstLine := 1; @@ -941,8 +942,8 @@ begin end; if prevval <> Text then - if Assigned(OnChange) then - OnChange(self); + if Assigned(FOnChange) then + FOnChange(self); if consumed then RePaint; |