From 3e716f473fa9b2da03cfaa201548f1c91eacc9cb Mon Sep 17 00:00:00 2001 From: juha Date: Sat, 19 May 2012 08:04:22 +0000 Subject: [PATCH] =?UTF-8?q?LCL:=20Do=20not=20save=20the=20default=20glyph?= =?UTF-8?q?=20of=20EditButton=20in=20LFM,=20issue=20#22053,=20patch=20from?= =?UTF-8?q?=20Silvio=20Cl=C3=A9cio?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: trunk@37343 - --- lcl/editbtn.pas | 56 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 55 insertions(+), 1 deletion(-) diff --git a/lcl/editbtn.pas b/lcl/editbtn.pas index 28562cf9d9..384d30bd4b 100644 --- a/lcl/editbtn.pas +++ b/lcl/editbtn.pas @@ -61,6 +61,7 @@ type function GetMinHeight: Integer; procedure WMSetFocus(var Message: TLMSetFocus); message LM_SETFOCUS; procedure WMKillFocus(var Message: TLMKillFocus); message LM_KILLFOCUS; + function IsCustomGlyph : Boolean; protected procedure CheckButtonVisible; function CalcButtonVisible: boolean; virtual; @@ -80,7 +81,7 @@ type // New properties. property ButtonWidth : Integer read GetButtonWidth write SetButtonWidth; property DirectInput : Boolean read GetDirectInput write SetDirectInput default True; - property Glyph : TBitmap read GetGlyph write SetGlyph; + property Glyph : TBitmap read GetGlyph write SetGlyph stored IsCustomGlyph; property NumGlyphs : Integer read GetNumGlyphs write SetNumGlyphs; property OnButtonClick : TNotifyEvent read FOnButtonClick write FOnButtonClick; property Button: TSpeedButton read FButton; @@ -796,6 +797,59 @@ begin inherited; end; +function TCustomEditButton.IsCustomGlyph : Boolean; + + function _LoadRes: TBitmap; + var + ResName: String; + C : TCustomBitmap; + begin + ResName := GetDefaultGlyphName; + if ResName = '' then + Exit(nil); + Result := TBitmap.Create; + try + try + C := CreateBitmapFromLazarusResource(ResName); + Result.Assign(C); // the "Equals" did not work with ClassType different + // maybe it should compare the "RawImage" because it is independent of ClassType + finally + C.Free; + end; + except + Result.Free; + raise; + end; + end; + +var + B, GlypRes, GlypActual: TBitmap; +begin + GlypActual := nil; + GlypRes := nil; + try + B := GetDefaultGlyph; + if B = nil then // if Default Glyph is nil, use the resource + begin + GlypRes := _LoadRes; + B := GlypRes; + end; + if B = nil then + Result := Glyph <> nil + else if Glyph = nil then + Result := True + else + begin + GlypActual := TBitmap.Create; // the "Equals" did not work with ClassType different. + GlypActual.Assign(Glyph); + Result := not GlypActual.Equals(B); + end; + finally + GlypRes.Free; + GlypActual.Free; + end; +end; + function TCustomEditButton.GetReadOnly: Boolean; begin Result := FIsReadOnly;