diff options
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/gui_combobox.pas | 85 | ||||
-rw-r--r-- | src/gui/gui_editcombo.pas | 43 | ||||
-rw-r--r-- | src/gui/gui_listbox.pas | 10 |
3 files changed, 57 insertions, 81 deletions
diff --git a/src/gui/gui_combobox.pas b/src/gui/gui_combobox.pas index 8452495c..31dc8989 100644 --- a/src/gui/gui_combobox.pas +++ b/src/gui/gui_combobox.pas @@ -77,6 +77,8 @@ type FInternalBtnRect: TfpgRect; FFocusItem: integer; FItems: TStringList; + FBtnPressed: Boolean; + procedure CalculateInternalButtonRect; virtual; procedure InternalOnClose(Sender: TObject); procedure InternalItemsChanged(Sender: TObject); virtual; procedure HandleKeyPress(var keycode: word; var shiftstate: TShiftState; var consumed: boolean); override; @@ -84,6 +86,7 @@ type procedure DoOnDropDown; virtual; procedure DoDropDown; virtual; abstract; procedure DoOnCloseUp; virtual; + procedure PaintInternalButton; virtual; function GetDropDownPos(AParent, AComboBox, ADropDown: TfpgWidget): TfpgRect; virtual; property DropDownCount: integer read FDropDownCount write SetDropDownCount default 8; property FocusItem: integer read FFocusItem write SetFocusItem; @@ -96,6 +99,7 @@ type public constructor Create(AOwner: TComponent); override; destructor Destroy; override; + procedure SetPosition(aleft, atop, awidth, aheight: TfpgCoord); override; property Font: TfpgFont read FFont; end; @@ -103,10 +107,8 @@ type TfpgAbstractComboBox = class(TfpgBaseComboBox) private procedure InternalBtnClick(Sender: TObject); - procedure CalculateInternalButtonRect; protected FMargin: integer; - FBtnPressed: Boolean; FDropDown: TfpgPopupWindow; procedure DoDropDown; override; function GetText: string; virtual; @@ -120,7 +122,6 @@ type procedure HandleMouseScroll(x, y: integer; shiftstate: TShiftState; delta: smallint); override; procedure HandleResize(awidth, aheight: TfpgCoord); override; procedure HandlePaint; override; - procedure PaintInternalButton; virtual; property Text: string read GetText write SetText; public constructor Create(AOwner: TComponent); override; @@ -221,6 +222,11 @@ begin RePaint; end; +procedure TfpgBaseComboBox.CalculateInternalButtonRect; +begin + FInternalBtnRect.SetRect(Width - Min(Height, 20), 2, Min(Height, 20)-2, Height-4); +end; + procedure TfpgBaseComboBox.InternalOnClose(Sender: TObject); begin DoOnCloseUp; @@ -284,6 +290,36 @@ begin OnCloseUp(self); end; +procedure TfpgBaseComboBox.PaintInternalButton; +var + ar: TfpgRect; + btnflags: TFButtonFlags; +begin + Canvas.BeginDraw; + btnflags := []; + ar := FInternalBtnRect; + InflateRect(ar, -2, -2); + if FBtnPressed then + begin + Include(btnflags, btfIsPressed); + OffsetRect(ar, 1, 1); + end; + // paint button face + fpgStyle.DrawButtonFace(Canvas, + FInternalBtnRect.Left, + FInternalBtnRect.Top, + FInternalBtnRect.Width, + FInternalBtnRect.Height, btnflags); + if Enabled then + Canvas.SetColor(clText1) + else + Canvas.SetColor(clShadow1); + + // paint arrow + fpgStyle.DrawDirectionArrow(Canvas, ar.Left, ar.Top, ar.Width, ar.Height, 1); + Canvas.EndDraw(FInternalBtnRect); +end; + function TfpgBaseComboBox.GetDropDownPos(AParent, AComboBox, ADropDown: TfpgWidget): TfpgRect; var pt: TPoint; @@ -320,6 +356,7 @@ begin FItems.OnChange := @InternalItemsChanged; FFont := fpgGetFont('#List'); FOptions := []; + FBtnPressed := False; FOnChange := nil; end; @@ -330,6 +367,11 @@ begin inherited Destroy; end; +procedure TfpgBaseComboBox.SetPosition(aleft, atop, awidth, aheight: TfpgCoord); +begin + inherited SetPosition(aleft, atop, awidth, aheight); + CalculateInternalButtonRect +end; { TComboboxDropdownWindow } @@ -515,11 +557,6 @@ begin RePaint end; -procedure TfpgAbstractComboBox.CalculateInternalButtonRect; -begin - FInternalBtnRect.SetRect(Width - Min(Height, 20), 2, Min(Height, 20)-2, Height-4); -end; - procedure TfpgAbstractComboBox.SetHeight(const AValue: TfpgCoord); begin inherited SetHeight(AValue); @@ -622,37 +659,6 @@ begin fpgStyle.DrawString(Canvas, FMargin+1, FMargin, Text, Enabled); end; -procedure TfpgAbstractComboBox.PaintInternalButton; -var - ar: TfpgRect; - btnflags: TFButtonFlags; -begin - Canvas.BeginDraw; - btnflags := []; - ar := FInternalBtnRect; - InflateRect(ar, -2, -2); - if FBtnPressed then - begin - Include(btnflags, btfIsPressed); - OffsetRect(ar, 1, 1); - end; - // paint button face - fpgStyle.DrawButtonFace(Canvas, - FInternalBtnRect.Left, - FInternalBtnRect.Top, - FInternalBtnRect.Width, - FInternalBtnRect.Height, btnflags); - if Enabled then - Canvas.SetColor(clText1) - else - begin - Canvas.SetColor(clShadow1); - end; - // paint arrow - fpgStyle.DrawDirectionArrow(Canvas, ar.Left, ar.Top, ar.Width, ar.Height, 1); - Canvas.EndDraw(FInternalBtnRect); -end; - constructor TfpgAbstractComboBox.Create(AOwner: TComponent); begin inherited Create(AOwner); @@ -662,7 +668,6 @@ begin FMargin := 3; FHeight := Font.Height + (2*FMargin); FFocusable := True; - FBtnPressed := False; CalculateInternalButtonRect; end; diff --git a/src/gui/gui_editcombo.pas b/src/gui/gui_editcombo.pas index 154d130c..dc1f271d 100644 --- a/src/gui/gui_editcombo.pas +++ b/src/gui/gui_editcombo.pas @@ -76,10 +76,8 @@ type procedure SetAllowNew(const AValue: TAllowNew); procedure InternalBtnClick(Sender: TObject); procedure InternalListBoxSelect(Sender: TObject); - procedure CalculateInternalButtonRect; protected FMargin: integer; - FBtnPressed: Boolean; FDropDown: TfpgPopupWindow; FDrawOffset: integer; FSelStart: integer; @@ -97,12 +95,11 @@ type procedure HandleLMouseUp(x, y: integer; shiftstate: TShiftState); override; procedure HandleResize(awidth, aheight: TfpgCoord); override; procedure HandlePaint; override; - procedure PaintInternalButton; virtual; property AutoCompletion: Boolean read FAutocompletion write FAutoCompletion default False; property AutoDropDown: Boolean read FAutoDropDown write FAutoDropDown default False; property AllowNew: TAllowNew read FAllowNew write SetAllowNew default anNo; - property BackgroundColor: TfpgColor read FBackgroundColor write SetBackgroundColor default clBoxColor; - property TextColor: TfpgColor read FTextColor write SetTextColor default clText1; + property BackgroundColor default clBoxColor; + property TextColor default clText1; property Text: string read GetText write SetText; public constructor Create(AOwner: TComponent); override; @@ -385,12 +382,6 @@ begin RePaint; end; -procedure TfpgAbstractEditCombo.CalculateInternalButtonRect; -begin - FInternalBtnRect.SetRect(Width - Min(Height, 20), 2, Min(Height, 20)-2, - Height-4); -end; - procedure TfpgAbstractEditCombo.SetHeight(const AValue: TfpgCoord); begin inherited SetHeight(AValue); @@ -726,35 +717,6 @@ begin Canvas.EndDraw; end; -procedure TfpgAbstractEditCombo.PaintInternalButton; -var - ar: TfpgRect; - btnflags: TFButtonFlags; -begin - Canvas.BeginDraw; - btnflags := []; - ar := FInternalBtnRect; - InflateRect(ar, -2, -2); - if FBtnPressed then - begin - Include(btnflags, btfIsPressed); - OffsetRect(ar, 1, 1); - end; - // paint button face - fpgStyle.DrawButtonFace(Canvas, - FInternalBtnRect.Left, - FInternalBtnRect.Top, - FInternalBtnRect.Width, - FInternalBtnRect.Height, btnflags); - if Enabled then - Canvas.SetColor(clText1) - else - Canvas.SetColor(clShadow1); - // paint arrow - fpgStyle.DrawDirectionArrow(Canvas, ar.Left, ar.Top, ar.Width, ar.Height, 1); - Canvas.EndDraw(FInternalBtnRect); -end; - constructor TfpgAbstractEditCombo.Create(AOwner: TComponent); begin inherited Create(AOwner); @@ -764,7 +726,6 @@ begin FHeight := Font.Height + 6; FMargin := 3; FFocusable := True; - FBtnPressed := False; FAutocompletion := False; FAutoDropDown := False; FAllowNew := anNo; diff --git a/src/gui/gui_listbox.pas b/src/gui/gui_listbox.pas index dd631dd7..bd493efd 100644 --- a/src/gui/gui_listbox.pas +++ b/src/gui/gui_listbox.pas @@ -81,6 +81,7 @@ type procedure HandleLMouseUp(x, y: integer; shiftstate: TShiftState); override; procedure HandleMouseMove(x, y: integer; btnstate: word; shiftstate: TShiftState); override; procedure HandleMouseScroll(x, y: integer; shiftstate: TShiftState; delta: smallint); override; + procedure HandleResize(awidth, aheight: TfpgCoord); override; procedure HandleShow; override; procedure HandlePaint; override; property AutoHeight: boolean read FAutoHeight write SetAutoHeight default False; @@ -571,6 +572,15 @@ begin end; end; +procedure TfpgBaseListBox.HandleResize(awidth, aheight: TfpgCoord); +begin + inherited HandleResize(awidth, aheight); + if (csLoading in ComponentState) then + Exit; + UpdateScrollbarCoords; + UpdateScrollBar; +end; + procedure TfpgBaseListBox.HandleShow; begin inherited HandleShow; |