Browse Source

Glyph Assign

PreserveGlyphOnAssign added, by default is on and prevents the glyph being replaced in any Assign call.
lainz 8 years ago
parent
commit
de4932c834
3 changed files with 14 additions and 3 deletions
  1. 2 1
      .gitignore
  2. 6 1
      bcbutton.pas
  3. 6 1
      bcbuttonfocus.pas

+ 2 - 1
.gitignore

@@ -11,4 +11,5 @@ debug
 *.o
 *.ppu
 *.or
-*.compiled
+*.compiled
+*Thumbs.db

+ 6 - 1
bcbutton.pas

@@ -108,6 +108,7 @@ type
     FBGRANormal, FBGRAHover, FBGRAClick: TBGRABitmapEx;
     FInnerMargin: single;
     FMemoryUsage: TBCButtonMemoryUsage;
+    FPreserveGlyphOnAssign: boolean;
     FRounding: TBCRounding;
     FRoundingDropDown: TBCRounding;
     FStateClicked: TBCButtonState;
@@ -243,6 +244,7 @@ type
     property OnButtonClick: TNotifyEvent read FOnButtonClick write FOnButtonClick;
     property MemoryUsage: TBCButtonMemoryUsage read FMemoryUsage write SetMemoryUsage;
     property InnerMargin: single read FInnerMargin write SetInnerMargin;
+    property PreserveGlyphOnAssign: boolean read FPreserveGlyphOnAssign write FPreserveGlyphOnAssign default True;
   public
     { Constructor }
     constructor Create(AOwner: TComponent); override;
@@ -301,6 +303,7 @@ type
     property GlobalOpacity;
     { The glyph icon. }
     property Glyph;
+    property PreserveGlyphOnAssign;
     { The margin of the glyph icon. }
     property GlyphMargin;
     property Hint;
@@ -1688,6 +1691,7 @@ begin
     FImageIndex := -1;
 
     FShowCaption := True;
+    FPreserveGlyphOnAssign := True;
   finally
     Exclude(FControlState, csCreating);
     EnableAutoSizing;
@@ -1714,7 +1718,8 @@ procedure TCustomBCButton.Assign(Source: TPersistent);
 begin
   if Source is TCustomBCButton then
   begin
-    Glyph := TCustomBCButton(Source).Glyph;
+    if not PreserveGlyphOnAssign then
+      Glyph := TCustomBCButton(Source).Glyph;
     FGlyphMargin := TCustomBCButton(Source).FGlyphMargin;
     FStyle := TCustomBCButton(Source).FStyle;
     FFlipArrow := TCustomBCButton(Source).FFlipArrow;

+ 6 - 1
bcbuttonfocus.pas

@@ -109,6 +109,7 @@ type
     FInnerMargin: single;
     FMemoryUsage: TBCButtonFocusMemoryUsage;
     FOnPaintButton: TNotifyEvent;
+    FPreserveGlyphOnAssign: boolean;
     FRounding: TBCRounding;
     FRoundingDropDown: TBCRounding;
     FStateClicked: TBCButtonFocusState;
@@ -250,6 +251,7 @@ type
     property MemoryUsage: TBCButtonFocusMemoryUsage read FMemoryUsage write SetMemoryUsage;
     property InnerMargin: single read FInnerMargin write SetInnerMargin;
     property OnPaintButton: TNotifyEvent read FOnPaintButton write FOnPaintButton;
+    property PreserveGlyphOnAssign: boolean read FPreserveGlyphOnAssign write FPreserveGlyphOnAssign default True;
   public
     { Constructor }
     constructor Create(AOwner: TComponent); override;
@@ -308,6 +310,7 @@ type
     property GlobalOpacity;
     { The glyph icon. }
     property Glyph;
+    property PreserveGlyphOnAssign;
     { The margin of the glyph icon. }
     property GlyphMargin;
     property Hint;
@@ -1754,6 +1757,7 @@ begin
     FImageIndex := -1;
 
     FShowCaption := True;
+    FPreserveGlyphOnAssign := True;
   finally
     Exclude(FControlState, csCreating);
     EnableAutoSizing;
@@ -1780,7 +1784,8 @@ procedure TCustomBCButtonFocus.Assign(Source: TPersistent);
 begin
   if Source is TCustomBCButtonFocus then
   begin
-    Glyph := TCustomBCButtonFocus(Source).Glyph;
+    if not PreserveGlyphOnAssign then
+      Glyph := TCustomBCButtonFocus(Source).Glyph;
     FGlyphMargin := TCustomBCButtonFocus(Source).FGlyphMargin;
     FStyle := TCustomBCButtonFocus(Source).FStyle;
     FFlipArrow := TCustomBCButtonFocus(Source).FFlipArrow;