From de3e52e6ece3138503ac255908a937a15d76e83f Mon Sep 17 00:00:00 2001 From: graemeg Date: Mon, 9 Mar 2009 07:23:28 +0000 Subject: ExtraHint property for EditCombo. Thanks to Jean-Marc. --- src/gui/fpg_combobox.pas | 24 ++++++++++++------------ src/gui/fpg_editcombo.pas | 8 +++++++- 2 files changed, 19 insertions(+), 13 deletions(-) (limited to 'src/gui') diff --git a/src/gui/fpg_combobox.pas b/src/gui/fpg_combobox.pas index 8de11146..06bc91a9 100644 --- a/src/gui/fpg_combobox.pas +++ b/src/gui/fpg_combobox.pas @@ -69,10 +69,12 @@ type FOnCloseUp: TNotifyEvent; FOnDropDown: TNotifyEvent; FOptions: TfpgComboOptions; + FExtraHint: string; function GetFontDesc: string; procedure SetDropDownCount(const AValue: integer); procedure SetFocusItem(const AValue: integer); procedure SetFontDesc(const AValue: string); + procedure SetExtraHint(const AValue: string); protected FMargin: integer; FInternalBtnRect: TfpgRect; @@ -91,6 +93,7 @@ type procedure PaintInternalButton; virtual; function GetDropDownPos(AParent, AComboBox, ADropDown: TfpgWidget): TfpgRect; virtual; property DropDownCount: integer read FDropDownCount write SetDropDownCount default 8; + property ExtraHint: string read FExtraHint write SetExtraHint; property FocusItem: integer read FFocusItem write SetFocusItem; property FontDesc: string read GetFontDesc write SetFontDesc; property Items: TStringList read FItems; {$Note Make this read/write } @@ -108,9 +111,7 @@ type TfpgBaseStaticCombo = class(TfpgBaseComboBox) private - FExtraHint: string; procedure InternalBtnClick(Sender: TObject); - procedure SetExtraHint(const AValue: string); protected FDropDown: TfpgPopupWindow; procedure DoDropDown; override; @@ -124,7 +125,6 @@ type procedure HandleMouseScroll(x, y: integer; shiftstate: TShiftState; delta: smallint); override; procedure HandlePaint; override; property Text: string read GetText write SetText; - property ExtraHint: string read FExtraHint write SetExtraHint; public constructor Create(AOwner: TComponent); override; destructor Destroy; override; @@ -230,6 +230,14 @@ begin RePaint; end; +procedure TfpgBaseComboBox.SetExtraHint(const AValue: string); +begin + if FExtraHint = AValue then + Exit; //==> + FExtraHint := AValue; + Repaint; +end; + procedure TfpgBaseComboBox.SetMargin(const AValue: integer); begin if (FMargin = AValue) or (AValue <= 0) then @@ -385,6 +393,7 @@ begin FOptions := []; FBtnPressed := False; FOnChange := nil; + FExtraHint := ''; end; destructor TfpgBaseComboBox.Destroy; @@ -543,14 +552,6 @@ begin DoDropDown; end; -procedure TfpgBaseStaticCombo.SetExtraHint(const AValue: string); -begin - if FExtraHint = AValue then - Exit; //==> - FExtraHint := AValue; - Repaint; -end; - procedure TfpgBaseStaticCombo.SetText(const AValue: string); var i: integer; @@ -688,7 +689,6 @@ begin FWidth := 120; FHeight := Font.Height + (2*FMargin); FFocusable := True; - FExtraHint := ''; CalculateInternalButtonRect; end; diff --git a/src/gui/fpg_editcombo.pas b/src/gui/fpg_editcombo.pas index efe0e233..8d660664 100644 --- a/src/gui/fpg_editcombo.pas +++ b/src/gui/fpg_editcombo.pas @@ -116,6 +116,7 @@ type property AutoCompletion; property BackgroundColor; property DropDownCount; + property ExtraHint; property FocusItem; property FontDesc; property Height; @@ -695,7 +696,12 @@ begin if not AutoCompletion then begin if HasText then - fpgStyle.DrawString(Canvas, FMargin+1, FMargin, Text, Enabled); + fpgStyle.DrawString(Canvas, FMargin+1, FMargin, Text, Enabled) + else + begin + Canvas.SetTextColor(clShadow1); + fpgStyle.DrawString(Canvas, FMargin+1, FMargin, ExtraHint, Enabled); + end; end else begin -- cgit v1.2.3-70-g09d2