diff options
Diffstat (limited to 'libgtk_kylix/GTKStdCtrls.pas')
| -rw-r--r-- | libgtk_kylix/GTKStdCtrls.pas | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/libgtk_kylix/GTKStdCtrls.pas b/libgtk_kylix/GTKStdCtrls.pas index 2bca3bb..7f73594 100644 --- a/libgtk_kylix/GTKStdCtrls.pas +++ b/libgtk_kylix/GTKStdCtrls.pas @@ -23,7 +23,7 @@ unit GTKStdCtrls; interface -uses lazglib2, lazgobject2, lazgtk3, Classes, GTKControls, GTKConsts; +uses lazglib2, lazgobject2, lazgtk3, Classes, GTKControls, GTKPixbuf, GTKConsts; type @@ -32,12 +32,14 @@ type TGTKButton = class(TGTKBin) private FOnClick: TNotifyEvent; + FImage: PGtkWidget; function GetCaption: string; function GetUseUnderline: boolean; function GetBorderStyle: TGTKBorderStyle; procedure SetCaption(Value: string); procedure SetUseUnderline(Value: boolean); procedure SetBorderStyle(Value: TGTKBorderStyle); + procedure SetIcon(Value: TGDKPixbuf); public constructor Create(AOwner: TComponent); override; constructor CreateFromIconName(AOwner: TComponent; const IconName: string); @@ -47,6 +49,7 @@ type property OnClick: TNotifyEvent read FOnClick write FOnClick; property UseUnderline: boolean read GetUseUnderline write SetUseUnderline; property BorderStyle: TGTKBorderStyle read GetBorderStyle write SetBorderStyle; + property Icon: TGDKPixbuf write SetIcon; end; (****************************************** TGTKLABEL **************************************************************************) @@ -302,6 +305,20 @@ begin gtk_button_set_relief(PGtkButton(FWidget), TGtkReliefStyle(Value)); end; +procedure TGTKButton.SetIcon(Value: TGDKPixbuf); +begin + if Assigned(Value) then begin + if Assigned(FImage) then g_object_unref(PGObject(FImage)); + FImage := gtk_image_new_from_pixbuf(Value.FPixbuf); + gtk_button_set_image(PGtkButton(FWidget), FImage); + gtk_button_set_always_show_image(PGtkButton(FWidget), True); + end else begin + gtk_button_set_image(PGtkButton(FWidget), nil); + g_object_unref(PGObject(FImage)); + FImage := nil; + end; +end; + (********************************************************************************************************************************) (********************************************************************************************************************************) constructor TGTKLabel.Create(AOwner: TComponent); |
