diff options
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/gui_combobox.pas | 20 | ||||
-rw-r--r-- | src/gui/gui_listbox.pas | 51 |
2 files changed, 63 insertions, 8 deletions
diff --git a/src/gui/gui_combobox.pas b/src/gui/gui_combobox.pas index b7c3db14..16c54c7e 100644 --- a/src/gui/gui_combobox.pas +++ b/src/gui/gui_combobox.pas @@ -45,6 +45,7 @@ type private FDropDownCount: integer; FBackgroundColor: TfpgColor; + FTextColor: TfpgColor; FFocusItem: integer; FFont: TfpgFont; FInternalBtnRect: TfpgRect; @@ -52,6 +53,7 @@ type FOnChange: TNotifyEvent; function GetFontDesc: string; procedure SetBackgroundColor(const AValue: TfpgColor); + procedure SetTextColor(const AValue: TfpgColor); procedure SetDropDownCount(const AValue: integer); procedure InternalBtnClick(Sender: TObject); procedure InternalListBoxSelect(Sender: TObject); @@ -78,7 +80,8 @@ type property Items: TStringList read FItems; {$Note Make this read/write } // property is 1-based property FocusItem: integer read FFocusItem write SetFocusItem; - property BackgroundColor: TfpgColor read FBackgroundColor write SetBackgroundColor; + property BackgroundColor: TfpgColor read FBackgroundColor write SetBackgroundColor default clBoxColor; + property TextColor: TfpgColor read FTextColor write SetTextColor default clText1; property FontDesc: string read GetFontDesc write SetFontDesc; property OnChange: TNotifyEvent read FOnChange write FOnChange; property Text: string read GetText write SetText; @@ -96,10 +99,11 @@ type property DropDownCount; property FocusItem; property FontDesc; + property Height; property Items; property Text; + property TextColor; property Width; - property Height; property OnChange; end; @@ -213,6 +217,15 @@ begin end; end; +procedure TfpgAbstractComboBox.SetTextColor(const AValue: TfpgColor); +begin + if FTextColor <> AValue then + begin + FTextColor := AValue; + Repaint; + end; +end; + function TfpgAbstractComboBox.GetFontDesc: string; begin Result := FFont.FontDesc; @@ -421,7 +434,7 @@ begin Canvas.SetColor(FBackgroundColor) else Canvas.SetColor(clWindowBackground); - Canvas.SetTextColor(clText1); + Canvas.SetTextColor(FTextColor); end; Canvas.FillRectangle(r); @@ -468,6 +481,7 @@ begin inherited Create(AOwner); FFont := fpgGetFont('#List'); FBackgroundColor := clBoxColor; + FTextColor := clText1; FDropDownCount := 8; FWidth := 120; FHeight := FFont.Height + 6; diff --git a/src/gui/gui_listbox.pas b/src/gui/gui_listbox.pas index 52cf0e6c..626d82e7 100644 --- a/src/gui/gui_listbox.pas +++ b/src/gui/gui_listbox.pas @@ -50,10 +50,14 @@ type FOnScroll: TNotifyEvent; FOnSelect: TNotifyEvent; FPopupFrame: boolean; + FTextColor: TfpgColor; + FBackgroundColor: TfpgColor; // This should move to TfpgWidget function GetFontDesc: string; procedure SetFocusItem(const AValue: integer); procedure SetFontDesc(const AValue: string); procedure SetPopupFrame(const AValue: boolean); + procedure SetTextColor(const AValue: TfpgColor); + procedure SetBackgroundColor(const AValue: TfpgColor); procedure UpdateScrollbarCoords; protected FFont: TfpgFont; @@ -62,7 +66,6 @@ type FMouseDragging: boolean; FFirstItem: integer; FMargin: integer; - FBackgroundColor: TfpgColor; // This should move to TfpgWidget procedure SetFirstItem(item: integer); procedure UpdateScrollBar; procedure FollowFocus; @@ -80,10 +83,12 @@ type procedure HandleMouseScroll(x, y: integer; shiftstate: TShiftState; delta: smallint); override; procedure HandleShow; override; procedure HandlePaint; override; - property PopupFrame: boolean read FPopupFrame write SetPopupFrame; - property HotTrack: boolean read FHotTrack write FHotTrack; + property BackgroundColor: TfpgColor read FBackgroundColor write SetBackgroundColor default clBoxColor; property FocusItem: integer read FFocusItem write SetFocusItem; property FontDesc: string read GetFontDesc write SetFontDesc; + property HotTrack: boolean read FHotTrack write FHotTrack; + property PopupFrame: boolean read FPopupFrame write SetPopupFrame; + property TextColor: TfpgColor read FTextColor write SetTextColor default clText1; public constructor Create(AOwner: TComponent); override; destructor Destroy; override; @@ -115,14 +120,19 @@ type // The standard strings listbox we will actually use in a GUI. TfpgListBox = class(TfpgTextListBox) published + property BackgroundColor; property FocusItem; property FontDesc; property HotTrack; property Items; property PopupFrame; + property TextColor; end; +function CreateListBox(AOwner: TComponent; x, y, w, h: TfpgCoord): TfpgListBox; + + implementation type @@ -138,6 +148,18 @@ type procedure Delete(Index: Integer); override; end; + +function CreateListBox(AOwner: TComponent; x, y, w, h: TfpgCoord): TfpgListBox; +begin + Result := TfpgListBox.Create(AOwner); + Result.Left := x; + Result.Top := y; + Result.Width := w; + if h > 0 then + Result.Height := h; +end; + + { TfpgListBoxStrings } procedure TfpgListBoxStrings.SetUpdateState(Updating: Boolean); @@ -205,6 +227,24 @@ begin RePaint; end; +procedure TfpgBaseListBox.SetTextColor(const AValue: TfpgColor); +begin + if FTextColor <> AValue then + begin + FTextColor := AValue; + RePaint; + end; +end; + +procedure TfpgBaseListBox.SetBackgroundColor(const AValue: TfpgColor); +begin + if FBackgroundColor <> AValue then + begin + FBackgroundColor := AValue; + Repaint; + end; +end; + procedure TfpgBaseListBox.UpdateScrollbarCoords; var HWidth: integer; @@ -530,7 +570,7 @@ begin else begin Canvas.SetColor(FBackgroundColor); - Canvas.SetTextColor(clText1); + Canvas.SetTextColor(FTextColor); end; { if/else } Canvas.FillRectangle(r); @@ -581,7 +621,8 @@ begin inherited Create(AOwner); FFont := fpgGetFont('#List'); FBackgroundColor := clListBox; - + FTextColor := clText1; + FScrollBar := TfpgScrollBar.Create(self); FScrollBar.OnScroll := @ScrollBarMove; // FScrollBar.Visible := False; |