lcl: TButtonGlyph

- show always in design time and don't react on ShowMode change
  - show always for TSpeedButton

git-svn-id: trunk@19947 -
This commit is contained in:
paul 2009-05-13 02:58:39 +00:00
parent ac4b855749
commit 695d17aeb1
4 changed files with 10 additions and 1 deletions

View File

@ -88,6 +88,7 @@ type
TButtonGlyph = class(TObject, IUnknown, IImageCacheListener) TButtonGlyph = class(TObject, IUnknown, IImageCacheListener)
private private
FIsDesigning: Boolean;
FShowMode: TGlyphShowMode; FShowMode: TGlyphShowMode;
FImageIndexes: array[TButtonState] of Integer; FImageIndexes: array[TButtonState] of Integer;
FImages: TCustomImageList; FImages: TCustomImageList;
@ -125,6 +126,7 @@ type
BiDiFlags: Longint): TRect; BiDiFlags: Longint): TRect;
procedure Refresh; procedure Refresh;
property Glyph: TBitmap read FOriginal write SetGlyph; property Glyph: TBitmap read FOriginal write SetGlyph;
property IsDesigning: Boolean read FIsDesigning write FIsDesigning;
property NumGlyphs: TNumGlyphs read FNumGlyphs write SetNumGlyphs; property NumGlyphs: TNumGlyphs read FNumGlyphs write SetNumGlyphs;
property Images: TCustomImageList read FImages; property Images: TCustomImageList read FImages;
property Width: Integer read GetWidth; property Width: Integer read GetWidth;

View File

@ -29,6 +29,7 @@ begin
FButtonGlyph := TButtonGlyph.Create; FButtonGlyph := TButtonGlyph.Create;
FButtonGlyph.NumGlyphs := 1; FButtonGlyph.NumGlyphs := 1;
FButtonGlyph.OnChange := @GlyphChanged; FButtonGlyph.OnChange := @GlyphChanged;
FButtonGlyph.IsDesigning := csDesigning in ComponentState;
Align := alNone; Align := alNone;
RealizeKind; RealizeKind;
end; end;

View File

@ -68,6 +68,7 @@ end;
constructor TButtonGlyph.Create; constructor TButtonGlyph.Create;
begin begin
FImagesCache := nil; FImagesCache := nil;
FIsDesigning := False;
FShowMode:= gsmApplication; FShowMode:= gsmApplication;
FOriginal := TGlyphBitmap.Create(Self); FOriginal := TGlyphBitmap.Create(Self);
FOriginal.OnChange := @GlyphChanged; FOriginal.OnChange := @GlyphChanged;
@ -156,6 +157,7 @@ procedure TButtonGlyph.SetShowMode(const AValue: TGlyphShowMode);
begin begin
if FShowMode = AValue then Exit; if FShowMode = AValue then Exit;
FShowMode := AValue; FShowMode := AValue;
if not IsDesigning then
Refresh; Refresh;
end; end;
@ -189,6 +191,8 @@ procedure TButtonGlyph.GlyphChanged(Sender: TObject);
end; end;
begin begin
if IsDesigning then
Exit(True);
case ShowMode of case ShowMode of
gsmAlways: gsmAlways:
Result := True; Result := True;

View File

@ -42,6 +42,8 @@ constructor TCustomSpeedButton.Create(AOwner: TComponent);
begin begin
inherited Create(AOwner); inherited Create(AOwner);
FGlyph := TButtonGlyph.Create; FGlyph := TButtonGlyph.Create;
FGlyph.IsDesigning := csDesigning in ComponentState;
FGlyph.ShowMode := gsmAlways;
FGlyph.SetTransparentMode(gtmTransparent); FGlyph.SetTransparentMode(gtmTransparent);
FGlyph.OnChange := @GlyphChanged; FGlyph.OnChange := @GlyphChanged;