From 5e67d9111797c24b809026a1771d643a9cca66a1 Mon Sep 17 00:00:00 2001 From: sekelsenmat Date: Mon, 3 Oct 2011 08:55:56 +0000 Subject: [PATCH] applies patch from bug #20252: [Patch] BitBtn with Kind<>bkCustom should not save Caption to LFM but be translated via lclstrconsts git-svn-id: trunk@32648 - --- lcl/buttons.pp | 6 ++++++ lcl/controls.pp | 2 +- lcl/include/bitbtn.inc | 21 ++++++++++++++++++--- lcl/include/control.inc | 16 ++++++++-------- 4 files changed, 33 insertions(+), 12 deletions(-) diff --git a/lcl/buttons.pp b/lcl/buttons.pp index 1e965be110..c4c5a32ea1 100644 --- a/lcl/buttons.pp +++ b/lcl/buttons.pp @@ -141,6 +141,7 @@ type TCustomBitBtn = class(TCustomButton) private + FDefaultCaption: Boolean; FKind: TBitBtnKind; FLayout: TButtonLayout; FMargin: integer; @@ -165,6 +166,8 @@ type procedure ActionChange(Sender: TObject; CheckDefaults: Boolean); override; procedure GlyphChanged(Sender: TObject); procedure InitializeWnd; override; + function IsCaptionStored: Boolean; + procedure Loaded; override; procedure TextChanged; override; class function GetControlClassDefaultSize: TSize; override; procedure CMAppShowBtnGlyphChanged(var Message: TLMessage); message CM_APPSHOWBTNGLYPHCHANGED; @@ -176,6 +179,8 @@ type procedure LoadGlyphFromStock(idButton: Integer); function CanShowGlyph: Boolean; public + property Caption stored IsCaptionStored; + property DefaultCaption: Boolean read FDefaultCaption write FDefaultCaption default False; property Glyph: TBitmap read GetGlyph write SetGlyph stored IsGlyphStored; property NumGlyphs: Integer read GetNumGlyphs write SetNumGlyphs default 1; property Kind: TBitBtnKind read FKind write SetKind default bkCustom; @@ -202,6 +207,7 @@ type property Color; property Constraints; property Default; + property DefaultCaption; property Enabled; property Font; property Glyph; diff --git a/lcl/controls.pp b/lcl/controls.pp index 86b83c5bd0..374c2ce6d9 100644 --- a/lcl/controls.pp +++ b/lcl/controls.pp @@ -1008,7 +1008,6 @@ type function GetUndockWidth: Integer; function IsAnchorsStored: boolean; function IsBiDiModeStored: boolean; - function IsCaptionStored: Boolean; function IsEnabledStored: Boolean; function IsFontStored: Boolean; function IsHintStored: Boolean; @@ -1073,6 +1072,7 @@ type procedure DoBorderSpacingChange(Sender: TObject; InnerSpaceChanged: Boolean); virtual; function IsBorderSpacingInnerBorderStored: Boolean; virtual; + function IsCaptionStored: Boolean; procedure SendMoveSizeMessages(SizeChanged, PosChanged: boolean); virtual; procedure ConstrainedResize(var MinWidth, MinHeight, MaxWidth, MaxHeight: TConstraintSize); virtual; diff --git a/lcl/include/bitbtn.inc b/lcl/include/bitbtn.inc index fea905f3ea..025aea2762 100644 --- a/lcl/include/bitbtn.inc +++ b/lcl/include/bitbtn.inc @@ -22,6 +22,7 @@ constructor TCustomBitBtn.Create(TheOwner: TComponent); begin inherited Create(TheOwner); FCompStyle := csBitBtn; + FDefaultCaption := False; FKind := bkCustom; FLayout := blGlyphLeft; FSpacing := 3; @@ -132,9 +133,10 @@ procedure TCustomBitBtn.SetKind(AValue: TBitBtnKind); begin if FKind = AValue then Exit; FKind := AValue; - if FKind = bkCustom then Exit; - - RealizeKind; + if FKind <> bkCustom then + RealizeKind; + if not (csLoading in ComponentState) then + DefaultCaption := FKind <> bkCustom; end; procedure TCustomBitBtn.SetLayout(AValue: TButtonLayout); @@ -256,10 +258,23 @@ begin TWSBitBtnClass(WidgetSetClass).SetSpacing(Self, FSpacing); end; +function TCustomBitBtn.IsCaptionStored: Boolean; +begin + Result := inherited IsCaptionStored and not DefaultCaption; +end; + +procedure TCustomBitBtn.Loaded; +begin + inherited Loaded; + if (Kind <> bkCustom) and DefaultCaption and (Caption = '') then + Caption := GetCaptionOfKind(Kind); +end; + procedure TCustomBitBtn.TextChanged; begin inherited TextChanged; AdjustSize; + DefaultCaption := False; end; class function TCustomBitBtn.GetControlClassDefaultSize: TSize; diff --git a/lcl/include/control.inc b/lcl/include/control.inc index 51a2822315..d494a3e98b 100644 --- a/lcl/include/control.inc +++ b/lcl/include/control.inc @@ -1048,6 +1048,14 @@ begin Result:=BorderSpacing.InnerBorder<>0; end; +{------------------------------------------------------------------------------ + TControl IsCaptionStored +------------------------------------------------------------------------------} +function TControl.IsCaptionStored: Boolean; +begin + Result := (ActionLink = nil) or not ActionLink.IsCaptionLinked; +end; + {------------------------------------------------------------------------------ procedure TControl.SendMoveSizeMessages(SizeChanged, PosChanged: boolean); ------------------------------------------------------------------------------} @@ -2856,14 +2864,6 @@ begin Result := TControlActionLink; end; -{------------------------------------------------------------------------------ - TControl IsCaptionStored -------------------------------------------------------------------------------} -function TControl.IsCaptionStored: Boolean; -begin - Result := (ActionLink = nil) or not ActionLink.IsCaptionLinked; -end; - function TControl.IsClientHeightStored: Boolean; begin Result:=false;