diff options
author | graemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf> | 2007-07-16 06:47:38 +0000 |
---|---|---|
committer | graemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf> | 2007-07-16 06:47:38 +0000 |
commit | 167e5426af087de59f81423cad14b42f8c1a8cb1 (patch) | |
tree | 1e837e8187c456c6c9efbfeddf6ef0f1056a4f21 | |
parent | d9637e875d710eb52d9128d540a9885101b5f407 (diff) | |
download | fpGUI-167e5426af087de59f81423cad14b42f8c1a8cb1.tar.xz |
* scrollbar: code formatting
* listbox: fixed the initial size or the scrollbar slider
-rw-r--r-- | prototypes/fpgui2/source/gui/gui_listbox.pas | 28 | ||||
-rw-r--r-- | prototypes/fpgui2/source/gui/gui_scrollbar.pas | 52 |
2 files changed, 46 insertions, 34 deletions
diff --git a/prototypes/fpgui2/source/gui/gui_listbox.pas b/prototypes/fpgui2/source/gui/gui_listbox.pas index 2ce55e7c..43287cdb 100644 --- a/prototypes/fpgui2/source/gui/gui_listbox.pas +++ b/prototypes/fpgui2/source/gui/gui_listbox.pas @@ -47,9 +47,6 @@ type procedure HandleMouseMove(x, y: integer; btnstate: word; shiftstate: word); override; procedure HandleMouseScroll(x, y: integer; shiftstate: word; delta: smallint); override; procedure HandleShow; override; - // ToDo - // * handle mouse move - // * handle window scrolling procedure HandleResize(dwidth, dheight: integer); override; procedure HandlePaint; override; public @@ -370,6 +367,7 @@ end; procedure TfpgBaseListBox.HandleShow; begin inherited HandleShow; + UpdateScrollBar; UpdateScrollBarCoords; end; @@ -453,21 +451,21 @@ end; constructor TfpgBaseListBox.Create(AOwner: TComponent); begin inherited Create(AOwner); - FFont := fpgGetFont('#List'); - FBackgroundColor := clListBox; - FScrollBar := TfpgScrollBar.Create(self); + FBackgroundColor := clListBox; + + FScrollBar := TfpgScrollBar.Create(self); FScrollBar.OnScroll := @ScrollBarMove; - FFocusable := true; - FFocusItem := 1; - FFirstItem := 1; - FWidth := 80; - FHeight := 80; - FMargin := 2; - FMouseDragging := false; - FPopupFrame := false; - FHotTrack := false; + FFocusable := True; + FFocusItem := 1; + FFirstItem := 1; + FWidth := 80; + FHeight := 80; + FMargin := 2; + FMouseDragging := False; + FPopupFrame := False; + FHotTrack := False; FOnChange := nil; FOnSelect := nil; diff --git a/prototypes/fpgui2/source/gui/gui_scrollbar.pas b/prototypes/fpgui2/source/gui/gui_scrollbar.pas index 84fc2859..1c1bb7e5 100644 --- a/prototypes/fpgui2/source/gui/gui_scrollbar.pas +++ b/prototypes/fpgui2/source/gui/gui_scrollbar.pas @@ -2,6 +2,14 @@ unit gui_scrollbar; {$mode objfpc}{$H+} +{ + TODO: + * Set slider button to minimum length (default setting) + * Create property to enable dynamic sizing of slider button length. + * Paint scroll area between arrow buttons and slider button a different + color on click. +} + interface uses @@ -106,7 +114,7 @@ end; procedure TfpgScrollBar.RepaintSlider; begin if not HasHandle then - Exit; + Exit; //==> DrawSlider(True); end; @@ -114,16 +122,17 @@ procedure TfpgScrollBar.ScrollTimer(Sender: TObject); begin FScrollTimer.Interval := 25; if (FMousePosition.X < FActiveButtonRect.Right) - and (FMousePosition.X > FActiveButtonRect.Left) - and (FMousePosition.Y < FActiveButtonRect.Bottom) - and (FMousePosition.Y > FActiveButtonRect.Top) - then begin - if FStartBtnPressed then PositionChange(-FScrollStep); - if FEndBtnPressed then PositionChange(FScrollStep); + and (FMousePosition.X > FActiveButtonRect.Left) + and (FMousePosition.Y < FActiveButtonRect.Bottom) + and (FMousePosition.Y > FActiveButtonRect.Top) then + begin + if FStartBtnPressed then + PositionChange(-FScrollStep); + if FEndBtnPressed then + PositionChange(FScrollStep); end - else begin + else FScrollTimer.Enabled := False; - end; end; procedure TfpgScrollBar.DrawButton(x, y, w, h: TfpgCoord; const imgname: string; Pressed: Boolean = False); @@ -171,9 +180,9 @@ begin if FPosition < FMin then FPosition := FMin; - FSliderLength := trunc(area * SliderSize); - if FSliderLength < 8 then - FSliderLength := 8; + FSliderLength := Trunc(area * SliderSize); + if FSliderLength < 20 then + FSliderLength := 20; area := area - FSliderLength; mm := FMax - FMin; if mm = 0 then @@ -200,12 +209,14 @@ begin if Orientation = orVertical then begin - if y <= Width then begin + if y <= Width then + begin PositionChange(-FScrollStep); FStartBtnPressed := True; FActiveButtonRect := Rect(0, 0, Width, Width); end - else if y >= Height - Width then begin + else if y >= Height - Width then + begin PositionChange(FScrollStep); FEndBtnPressed := True; FActiveButtonRect := Rect(0,Height-Width, Width, Height); @@ -216,13 +227,16 @@ begin FSliderDragPos := y; end; end - else begin - if x <= Height then begin + else + begin + if x <= Height then + begin PositionChange(-FScrollStep); FStartBtnPressed := True; FActiveButtonRect := Rect(0, 0, Height, Height); end - else if x >= Width - Height then begin + else if x >= Width - Height then + begin PositionChange(FScrollStep); FEndBtnPressed := True; FActiveButtonRect := Rect(Width-Height, 0, Width, Height); @@ -239,13 +253,13 @@ begin FSliderDragStart := FSliderPos; DrawSlider(False); end - else if FStartBtnPressed or FEndBtnPressed then begin + else if FStartBtnPressed or FEndBtnPressed then + begin FScrollTimer.Interval := 500; FScrollTimer.Enabled := True; HandlePaint; end; - end; procedure TfpgScrollBar.HandleLMouseUp(x, y: integer; shiftstate: word); |