mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-18 19:59:31 +02:00
LCL, components: TCustomEditButton: enable image list support, use LCLBtnGlyphs.
git-svn-id: trunk@57722 -
This commit is contained in:
parent
aab1ffcedf
commit
801f6efb1b
@ -18,7 +18,7 @@ interface
|
|||||||
uses
|
uses
|
||||||
Classes, TypInfo, SysUtils, LCLProc, Forms, Controls, LCLType, GraphType,
|
Classes, TypInfo, SysUtils, LCLProc, Forms, Controls, LCLType, GraphType,
|
||||||
LazFileUtils, Graphics, Buttons, Menus, ExtCtrls, Dialogs,
|
LazFileUtils, Graphics, Buttons, Menus, ExtCtrls, Dialogs,
|
||||||
LCLIntf, PropEdits, PropEditUtils, ImgList, Math,
|
LCLIntf, PropEdits, PropEditUtils, ImgList, EditBtn, Math,
|
||||||
GraphicPropEdit; // defines TGraphicPropertyEditorForm
|
GraphicPropEdit; // defines TGraphicPropertyEditorForm
|
||||||
|
|
||||||
type
|
type
|
||||||
@ -674,7 +674,8 @@ begin
|
|||||||
begin
|
begin
|
||||||
if not (
|
if not (
|
||||||
(Component is TCustomSpeedButton)
|
(Component is TCustomSpeedButton)
|
||||||
or (Component is TCustomBitBtn))
|
or (Component is TCustomBitBtn)
|
||||||
|
or (Component is TCustomEditButton))
|
||||||
then
|
then
|
||||||
Component := Component.GetParentComponent;
|
Component := Component.GetParentComponent;
|
||||||
if Component = nil then
|
if Component = nil then
|
||||||
|
@ -53,7 +53,7 @@ type
|
|||||||
function ReturnKeyHandled: Boolean; override;
|
function ReturnKeyHandled: Boolean; override;
|
||||||
procedure SortAndFilter; override;
|
procedure SortAndFilter; override;
|
||||||
procedure ApplyFilterCore; override;
|
procedure ApplyFilterCore; override;
|
||||||
function GetDefaultGlyph: TBitmap; override;
|
function GetDefaultGlyphName: string; override;
|
||||||
public
|
public
|
||||||
constructor Create(AOwner: TComponent); override;
|
constructor Create(AOwner: TComponent); override;
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
@ -68,9 +68,6 @@ type
|
|||||||
property FilteredListbox: TCustomListBox read fFilteredListbox write SetFilteredListbox;
|
property FilteredListbox: TCustomListBox read fFilteredListbox write SetFilteredListbox;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
var
|
|
||||||
ListFilterGlyph: TBitmap;
|
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
{ TListBoxFilterEdit }
|
{ TListBoxFilterEdit }
|
||||||
@ -133,9 +130,9 @@ begin
|
|||||||
MoveTo(0, ASelect);
|
MoveTo(0, ASelect);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TListFilterEdit.GetDefaultGlyph: TBitmap;
|
function TListFilterEdit.GetDefaultGlyphName: string;
|
||||||
begin
|
begin
|
||||||
Result := ListFilterGlyph;
|
Result := 'btnfiltercancel';
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TListFilterEdit.SetFilteredListbox(const AValue: TCustomListBox);
|
procedure TListFilterEdit.SetFilteredListbox(const AValue: TCustomListBox);
|
||||||
|
@ -68,7 +68,7 @@ type
|
|||||||
function ReturnKeyHandled: Boolean; override;
|
function ReturnKeyHandled: Boolean; override;
|
||||||
procedure SortAndFilter; override;
|
procedure SortAndFilter; override;
|
||||||
procedure ApplyFilterCore; override;
|
procedure ApplyFilterCore; override;
|
||||||
function GetDefaultGlyph: TBitmap; override;
|
function GetDefaultGlyphName: string; override;
|
||||||
public
|
public
|
||||||
constructor Create(AOwner: TComponent); override;
|
constructor Create(AOwner: TComponent); override;
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
@ -82,9 +82,6 @@ type
|
|||||||
property ByAllFields: Boolean read fByAllFields write fByAllFields default False;
|
property ByAllFields: Boolean read fByAllFields write fByAllFields default False;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
var
|
|
||||||
ListFilterGlyph: TBitmap;
|
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
{ TListViewDataItem }
|
{ TListViewDataItem }
|
||||||
@ -118,9 +115,9 @@ begin
|
|||||||
inherited Destroy;
|
inherited Destroy;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TListViewFilterEdit.GetDefaultGlyph: TBitmap;
|
function TListViewFilterEdit.GetDefaultGlyphName: string;
|
||||||
begin
|
begin
|
||||||
Result := ListFilterGlyph;
|
Result := 'btnfiltercancel';
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TListViewFilterEdit.GetLastSelectedIndex: Integer;
|
function TListViewFilterEdit.GetLastSelectedIndex: Integer;
|
||||||
|
@ -96,7 +96,7 @@ type
|
|||||||
function ReturnKeyHandled: Boolean; override;
|
function ReturnKeyHandled: Boolean; override;
|
||||||
procedure SortAndFilter; override;
|
procedure SortAndFilter; override;
|
||||||
procedure ApplyFilterCore; override;
|
procedure ApplyFilterCore; override;
|
||||||
function GetDefaultGlyph: TBitmap; override;
|
function GetDefaultGlyphName: string; override;
|
||||||
public
|
public
|
||||||
constructor Create(AOwner: TComponent); override;
|
constructor Create(AOwner: TComponent); override;
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
@ -133,9 +133,6 @@ type
|
|||||||
constructor Create(AFilename: string; aData: Pointer);
|
constructor Create(AFilename: string; aData: Pointer);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
var
|
|
||||||
TreeFilterGlyph: TBitmap;
|
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
{ TTreeFilterBranch }
|
{ TTreeFilterBranch }
|
||||||
@ -430,9 +427,9 @@ begin
|
|||||||
inherited Destroy;
|
inherited Destroy;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TTreeFilterEdit.GetDefaultGlyph: TBitmap;
|
function TTreeFilterEdit.GetDefaultGlyphName: string;
|
||||||
begin
|
begin
|
||||||
Result := TreeFilterGlyph;
|
Result := 'btnfiltercancel';
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TTreeFilterEdit.OnBeforeTreeDestroy(Sender: TObject);
|
procedure TTreeFilterEdit.OnBeforeTreeDestroy(Sender: TObject);
|
||||||
|
245
lcl/editbtn.pas
245
lcl/editbtn.pas
@ -33,7 +33,7 @@ uses
|
|||||||
Classes, SysUtils, LCLProc, LResources, LCLStrConsts, Types, LCLType,
|
Classes, SysUtils, LCLProc, LResources, LCLStrConsts, Types, LCLType,
|
||||||
LMessages, Graphics, Controls, Forms, LazFileUtils, LazUTF8, Dialogs,
|
LMessages, Graphics, Controls, Forms, LazFileUtils, LazUTF8, Dialogs,
|
||||||
StdCtrls, Buttons, Calendar, ExtDlgs, GroupedEdit, CalendarPopup, MaskEdit,
|
StdCtrls, Buttons, Calendar, ExtDlgs, GroupedEdit, CalendarPopup, MaskEdit,
|
||||||
Menus, StrUtils, DateUtils, TimePopup, CalcForm;
|
Menus, StrUtils, DateUtils, TimePopup, CalcForm, ImgList;
|
||||||
|
|
||||||
const
|
const
|
||||||
NullDate: TDateTime = 0;
|
NullDate: TDateTime = 0;
|
||||||
@ -48,6 +48,11 @@ type
|
|||||||
procedure DoExit; override;
|
procedure DoExit; override;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
TEditSpeedButton = class(TSpeedButton)
|
||||||
|
protected
|
||||||
|
procedure GlyphChanged(Sender: TObject); override;
|
||||||
|
end;
|
||||||
|
|
||||||
{ TCustomEditButton }
|
{ TCustomEditButton }
|
||||||
|
|
||||||
TCustomEditButton = class(TCustomAbstractGroupedEdit)
|
TCustomEditButton = class(TCustomAbstractGroupedEdit)
|
||||||
@ -63,7 +68,6 @@ type
|
|||||||
function GetGlyph: TBitmap;
|
function GetGlyph: TBitmap;
|
||||||
function GetNumGlyps: Integer;
|
function GetNumGlyps: Integer;
|
||||||
function GetEdit: TEbEdit;
|
function GetEdit: TEbEdit;
|
||||||
function IsCustomGlyph : Boolean;
|
|
||||||
procedure SetFocusOnButtonClick(AValue: Boolean);
|
procedure SetFocusOnButtonClick(AValue: Boolean);
|
||||||
procedure SetOnButtonClick(AValue: TNotifyEvent);
|
procedure SetOnButtonClick(AValue: TNotifyEvent);
|
||||||
|
|
||||||
@ -71,6 +75,12 @@ type
|
|||||||
procedure SetFlat(AValue: Boolean);
|
procedure SetFlat(AValue: Boolean);
|
||||||
procedure SetGlyph(AValue: TBitmap);
|
procedure SetGlyph(AValue: TBitmap);
|
||||||
procedure SetNumGlyphs(AValue: Integer);
|
procedure SetNumGlyphs(AValue: Integer);
|
||||||
|
function GetImages: TCustomImageList;
|
||||||
|
procedure SetImages(const aImages: TCustomImageList);
|
||||||
|
function GetImageIndex: TImageIndex;
|
||||||
|
procedure SetImageIndex(const aImageIndex: TImageIndex);
|
||||||
|
function GetImageWidth: Integer;
|
||||||
|
procedure SetImageWidth(const aImageWidth: Integer);
|
||||||
protected
|
protected
|
||||||
procedure ButtonClick; virtual;
|
procedure ButtonClick; virtual;
|
||||||
procedure BuddyClick; override;
|
procedure BuddyClick; override;
|
||||||
@ -78,13 +88,14 @@ type
|
|||||||
function GetBuddyClassType: TControlClass; override;
|
function GetBuddyClassType: TControlClass; override;
|
||||||
class function GetControlClassDefaultSize: TSize; override;
|
class function GetControlClassDefaultSize: TSize; override;
|
||||||
function CalcButtonVisible: Boolean; virtual;
|
function CalcButtonVisible: Boolean; virtual;
|
||||||
function GetDefaultGlyph: TBitmap; virtual;
|
function GetDefaultGlyphName: string; virtual;
|
||||||
function GetDefaultGlyphName: String; virtual;
|
|
||||||
|
|
||||||
procedure CalculatePreferredSize(var PreferredWidth,
|
procedure CalculatePreferredSize(var PreferredWidth,
|
||||||
PreferredHeight: integer;
|
PreferredHeight: integer;
|
||||||
WithThemeSpace: Boolean); override;
|
WithThemeSpace: Boolean); override;
|
||||||
procedure CheckButtonVisible;
|
procedure CheckButtonVisible;
|
||||||
|
procedure LoadDefaultGlyph;
|
||||||
|
procedure GlyphChanged(Sender: TObject); virtual;
|
||||||
|
|
||||||
property Button: TSpeedButton read GetButton;
|
property Button: TSpeedButton read GetButton;
|
||||||
property ButtonCaption: TCaption read GetBuddyCaption write SetBuddyCaption;
|
property ButtonCaption: TCaption read GetBuddyCaption write SetBuddyCaption;
|
||||||
@ -95,8 +106,11 @@ type
|
|||||||
property Edit: TEbEdit read GetEdit;
|
property Edit: TEbEdit read GetEdit;
|
||||||
property Flat: Boolean read FFlat write SetFlat default False;
|
property Flat: Boolean read FFlat write SetFlat default False;
|
||||||
property FocusOnButtonClick: Boolean read GetFocusOnButtonClick write SetFocusOnButtonClick default False;
|
property FocusOnButtonClick: Boolean read GetFocusOnButtonClick write SetFocusOnButtonClick default False;
|
||||||
property Glyph: TBitmap read GetGlyph write SetGlyph stored IsCustomGlyph;
|
property Glyph: TBitmap read GetGlyph write SetGlyph;
|
||||||
property NumGlyphs: Integer read GetNumGlyps write SetNumGlyphs;
|
property NumGlyphs: Integer read GetNumGlyps write SetNumGlyphs;
|
||||||
|
property Images: TCustomImageList read GetImages write SetImages;
|
||||||
|
property ImageIndex: TImageIndex read GetImageIndex write SetImageIndex default -1;
|
||||||
|
property ImageWidth: Integer read GetImageWidth write SetImageWidth default 0;
|
||||||
property Spacing default 4;
|
property Spacing default 4;
|
||||||
|
|
||||||
property OnButtonClick: TNotifyEvent read GetOnButtonClick write SetOnButtonClick;
|
property OnButtonClick: TNotifyEvent read GetOnButtonClick write SetOnButtonClick;
|
||||||
@ -140,6 +154,9 @@ type
|
|||||||
property Glyph;
|
property Glyph;
|
||||||
// property HideSelection;
|
// property HideSelection;
|
||||||
property Hint;
|
property Hint;
|
||||||
|
property Images;
|
||||||
|
property ImageIndex;
|
||||||
|
property ImageWidth;
|
||||||
property Layout;
|
property Layout;
|
||||||
property MaxLength;
|
property MaxLength;
|
||||||
property NumGlyphs;
|
property NumGlyphs;
|
||||||
@ -233,7 +250,7 @@ type
|
|||||||
procedure MoveHome(ASelect: Boolean = False); virtual; abstract;
|
procedure MoveHome(ASelect: Boolean = False); virtual; abstract;
|
||||||
procedure MoveEnd(ASelect: Boolean = False); virtual; abstract;
|
procedure MoveEnd(ASelect: Boolean = False); virtual; abstract;
|
||||||
function ReturnKeyHandled: Boolean; virtual; abstract;
|
function ReturnKeyHandled: Boolean; virtual; abstract;
|
||||||
function GetDefaultGlyphName: String; override;
|
function GetDefaultGlyphName: string; override;
|
||||||
public
|
public
|
||||||
constructor Create(AOwner: TComponent); override;
|
constructor Create(AOwner: TComponent); override;
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
@ -261,7 +278,6 @@ type
|
|||||||
property ButtonWidth;
|
property ButtonWidth;
|
||||||
property Constraints;
|
property Constraints;
|
||||||
property DirectInput;
|
property DirectInput;
|
||||||
property NumGlyphs;
|
|
||||||
property Flat;
|
property Flat;
|
||||||
property FocusOnButtonClick;
|
property FocusOnButtonClick;
|
||||||
// Other properties
|
// Other properties
|
||||||
@ -278,6 +294,10 @@ type
|
|||||||
property Enabled;
|
property Enabled;
|
||||||
property Font;
|
property Font;
|
||||||
property Glyph;
|
property Glyph;
|
||||||
|
property NumGlyphs;
|
||||||
|
property Images;
|
||||||
|
property ImageIndex;
|
||||||
|
property ImageWidth;
|
||||||
property Layout;
|
property Layout;
|
||||||
property MaxLength;
|
property MaxLength;
|
||||||
property ParentBidiMode;
|
property ParentBidiMode;
|
||||||
@ -340,8 +360,7 @@ type
|
|||||||
FFileNameChangeLock: Integer;
|
FFileNameChangeLock: Integer;
|
||||||
procedure SetFileName(const AValue: String);
|
procedure SetFileName(const AValue: String);
|
||||||
protected
|
protected
|
||||||
function GetDefaultGlyph: TBitmap; override;
|
function GetDefaultGlyphName: string; override;
|
||||||
function GetDefaultGlyphName: String; override;
|
|
||||||
function CreateDialog(AKind: TDialogKind): TCommonDialog; virtual;
|
function CreateDialog(AKind: TDialogKind): TCommonDialog; virtual;
|
||||||
procedure SaveDialogResult(AKind: TDialogKind; D: TCommonDialog); virtual;
|
procedure SaveDialogResult(AKind: TDialogKind; D: TCommonDialog); virtual;
|
||||||
procedure ButtonClick; override;
|
procedure ButtonClick; override;
|
||||||
@ -376,6 +395,9 @@ type
|
|||||||
property DirectInput;
|
property DirectInput;
|
||||||
property Glyph;
|
property Glyph;
|
||||||
property NumGlyphs;
|
property NumGlyphs;
|
||||||
|
property Images;
|
||||||
|
property ImageIndex;
|
||||||
|
property ImageWidth;
|
||||||
property Flat;
|
property Flat;
|
||||||
property FocusOnButtonClick;
|
property FocusOnButtonClick;
|
||||||
// Other properties
|
// Other properties
|
||||||
@ -445,8 +467,7 @@ type
|
|||||||
function GetDirectory: String;
|
function GetDirectory: String;
|
||||||
procedure SetDirectory(const AValue: String);
|
procedure SetDirectory(const AValue: String);
|
||||||
protected
|
protected
|
||||||
function GetDefaultGlyph: TBitmap; override;
|
function GetDefaultGlyphName: string; override;
|
||||||
function GetDefaultGlyphName: String; override;
|
|
||||||
function CreateDialog: TCommonDialog; virtual;
|
function CreateDialog: TCommonDialog; virtual;
|
||||||
function GetDialogResult(D : TCommonDialog) : String; virtual;
|
function GetDialogResult(D : TCommonDialog) : String; virtual;
|
||||||
procedure ButtonClick; override;
|
procedure ButtonClick; override;
|
||||||
@ -472,6 +493,9 @@ type
|
|||||||
property DirectInput;
|
property DirectInput;
|
||||||
property Glyph;
|
property Glyph;
|
||||||
property NumGlyphs;
|
property NumGlyphs;
|
||||||
|
property Images;
|
||||||
|
property ImageIndex;
|
||||||
|
property ImageWidth;
|
||||||
property Flat;
|
property Flat;
|
||||||
property FocusOnButtonClick;
|
property FocusOnButtonClick;
|
||||||
// Other properties
|
// Other properties
|
||||||
@ -556,8 +580,7 @@ type
|
|||||||
procedure SetDateOrder(const AValue: TDateOrder);
|
procedure SetDateOrder(const AValue: TDateOrder);
|
||||||
function DateToText(Value: TDateTime): String;
|
function DateToText(Value: TDateTime): String;
|
||||||
protected
|
protected
|
||||||
function GetDefaultGlyph: TBitmap; override;
|
function GetDefaultGlyphName: string; override;
|
||||||
function GetDefaultGlyphName: String; override;
|
|
||||||
procedure ButtonClick; override;
|
procedure ButtonClick; override;
|
||||||
procedure EditDblClick; override;
|
procedure EditDblClick; override;
|
||||||
procedure EditEditingDone; override;
|
procedure EditEditingDone; override;
|
||||||
@ -599,6 +622,9 @@ type
|
|||||||
property DirectInput;
|
property DirectInput;
|
||||||
property Glyph;
|
property Glyph;
|
||||||
property NumGlyphs;
|
property NumGlyphs;
|
||||||
|
property Images;
|
||||||
|
property ImageIndex;
|
||||||
|
property ImageWidth;
|
||||||
property DragMode;
|
property DragMode;
|
||||||
property EchoMode;
|
property EchoMode;
|
||||||
property Enabled;
|
property Enabled;
|
||||||
@ -667,8 +693,7 @@ type
|
|||||||
procedure ParseInput;
|
procedure ParseInput;
|
||||||
function TryParseInput(AInput: String; out ParseResult: TDateTime): Boolean;
|
function TryParseInput(AInput: String; out ParseResult: TDateTime): Boolean;
|
||||||
protected
|
protected
|
||||||
function GetDefaultGlyph: TBitmap; override;
|
function GetDefaultGlyphName: string; override;
|
||||||
function GetDefaultGlyphName: String; override;
|
|
||||||
procedure ButtonClick; override;
|
procedure ButtonClick; override;
|
||||||
procedure EditDblClick; override;
|
procedure EditDblClick; override;
|
||||||
procedure EditEditingDone; override;
|
procedure EditEditingDone; override;
|
||||||
@ -701,6 +726,9 @@ type
|
|||||||
property DirectInput;
|
property DirectInput;
|
||||||
property Glyph;
|
property Glyph;
|
||||||
property NumGlyphs;
|
property NumGlyphs;
|
||||||
|
property Images;
|
||||||
|
property ImageIndex;
|
||||||
|
property ImageWidth;
|
||||||
property DragMode;
|
property DragMode;
|
||||||
property EchoMode;
|
property EchoMode;
|
||||||
property Enabled;
|
property Enabled;
|
||||||
@ -764,8 +792,7 @@ type
|
|||||||
function TitleStored: boolean;
|
function TitleStored: boolean;
|
||||||
protected
|
protected
|
||||||
FCalcDialog : TForm;
|
FCalcDialog : TForm;
|
||||||
function GetDefaultGlyph: TBitmap; override;
|
function GetDefaultGlyphName: string; override;
|
||||||
function GetDefaultGlyphName: String; override;
|
|
||||||
procedure ButtonClick; override;
|
procedure ButtonClick; override;
|
||||||
public
|
public
|
||||||
constructor Create(AOwner: TComponent); override;
|
constructor Create(AOwner: TComponent); override;
|
||||||
@ -791,6 +818,9 @@ type
|
|||||||
property DirectInput;
|
property DirectInput;
|
||||||
property Glyph;
|
property Glyph;
|
||||||
property NumGlyphs;
|
property NumGlyphs;
|
||||||
|
property Images;
|
||||||
|
property ImageIndex;
|
||||||
|
property ImageWidth;
|
||||||
property Flat;
|
property Flat;
|
||||||
property FocusOnButtonClick;
|
property FocusOnButtonClick;
|
||||||
// Other properties
|
// Other properties
|
||||||
@ -846,13 +876,6 @@ type
|
|||||||
property TextHint;
|
property TextHint;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
var
|
|
||||||
FileOpenGlyph: TBitmap;
|
|
||||||
DateGlyph: TBitmap;
|
|
||||||
CalcGlyph: TBitmap;
|
|
||||||
TimeGlyph: TBitmap;
|
|
||||||
|
|
||||||
const
|
const
|
||||||
ResBtnListFilter = 'btnfiltercancel';
|
ResBtnListFilter = 'btnfiltercancel';
|
||||||
ResBtnFileOpen = 'btnselfile';
|
ResBtnFileOpen = 'btnselfile';
|
||||||
@ -867,6 +890,14 @@ implementation
|
|||||||
|
|
||||||
{$R lcl_edbtnimg.res}
|
{$R lcl_edbtnimg.res}
|
||||||
|
|
||||||
|
{ TEditSpeedButton }
|
||||||
|
|
||||||
|
procedure TEditSpeedButton.GlyphChanged(Sender: TObject);
|
||||||
|
begin
|
||||||
|
inherited GlyphChanged(Sender);
|
||||||
|
if (Owner is TCustomEditButton) then TCustomEditButton(Owner).GlyphChanged(Sender);
|
||||||
|
end;
|
||||||
|
|
||||||
{ TEbEdit }
|
{ TEbEdit }
|
||||||
|
|
||||||
procedure TEbEdit.DoEnter;
|
procedure TEbEdit.DoEnter;
|
||||||
@ -891,60 +922,6 @@ begin
|
|||||||
PreferredWidth := 0;
|
PreferredWidth := 0;
|
||||||
end;
|
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 := TPortableNetworkGraphic.Create;
|
|
||||||
C.LoadFromResourceName(hInstance, 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;
|
|
||||||
|
|
||||||
procedure TCustomEditButton.SetFocusOnButtonClick(AValue: Boolean);
|
procedure TCustomEditButton.SetFocusOnButtonClick(AValue: Boolean);
|
||||||
begin
|
begin
|
||||||
FocusOnBuddyClick := AValue;
|
FocusOnBuddyClick := AValue;
|
||||||
@ -969,6 +946,27 @@ begin
|
|||||||
Result := Button.Glyph;
|
Result := Button.Glyph;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TCustomEditButton.GetImageIndex: TImageIndex;
|
||||||
|
begin
|
||||||
|
if Button.Images=LCLBtnGlyphs then
|
||||||
|
Result := -1
|
||||||
|
else
|
||||||
|
Result := Button.ImageIndex;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TCustomEditButton.GetImages: TCustomImageList;
|
||||||
|
begin
|
||||||
|
if Button.Images=LCLBtnGlyphs then
|
||||||
|
Result := nil
|
||||||
|
else
|
||||||
|
Result := Button.Images;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TCustomEditButton.GetImageWidth: Integer;
|
||||||
|
begin
|
||||||
|
Result := Button.ImageWidth;
|
||||||
|
end;
|
||||||
|
|
||||||
function TCustomEditButton.GetButton: TSpeedButton;
|
function TCustomEditButton.GetButton: TSpeedButton;
|
||||||
begin
|
begin
|
||||||
Result := TSpeedButton(Buddy);
|
Result := TSpeedButton(Buddy);
|
||||||
@ -979,6 +977,25 @@ begin
|
|||||||
Result := OnBuddyClick;
|
Result := OnBuddyClick;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TCustomEditButton.GlyphChanged(Sender: TObject);
|
||||||
|
begin
|
||||||
|
if ((Button.Glyph=nil) or (Button.Glyph.Empty))
|
||||||
|
and (Button.Images=nil) then
|
||||||
|
LoadDefaultGlyph;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TCustomEditButton.LoadDefaultGlyph;
|
||||||
|
var
|
||||||
|
N: string;
|
||||||
|
begin
|
||||||
|
N := GetDefaultGlyphName;
|
||||||
|
if N <> '' then
|
||||||
|
begin
|
||||||
|
Images := LCLBtnGlyphs;
|
||||||
|
ImageIndex := LCLBtnGlyphs.GetImageIndex(N);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
function TCustomEditButton.GetFocusOnButtonClick: Boolean;
|
function TCustomEditButton.GetFocusOnButtonClick: Boolean;
|
||||||
begin
|
begin
|
||||||
Result := FocusOnBuddyClick;
|
Result := FocusOnBuddyClick;
|
||||||
@ -1001,12 +1018,7 @@ begin
|
|||||||
Result.CY := 23; //as TCustomEdit
|
Result.CY := 23; //as TCustomEdit
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TCustomEditButton.GetDefaultGlyph: TBitmap;
|
function TCustomEditButton.GetDefaultGlyphName: string;
|
||||||
begin
|
|
||||||
Result := nil;
|
|
||||||
end;
|
|
||||||
|
|
||||||
function TCustomEditButton.GetDefaultGlyphName: String;
|
|
||||||
begin
|
begin
|
||||||
Result := '';
|
Result := '';
|
||||||
end;
|
end;
|
||||||
@ -1054,9 +1066,26 @@ end;
|
|||||||
procedure TCustomEditButton.SetGlyph(AValue: TBitmap);
|
procedure TCustomEditButton.SetGlyph(AValue: TBitmap);
|
||||||
begin
|
begin
|
||||||
Button.Glyph := AValue;
|
Button.Glyph := AValue;
|
||||||
|
if AValue=nil then
|
||||||
|
LoadDefaultGlyph;
|
||||||
Invalidate;
|
Invalidate;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TCustomEditButton.SetImageIndex(const aImageIndex: TImageIndex);
|
||||||
|
begin
|
||||||
|
Button.ImageIndex := aImageIndex;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TCustomEditButton.SetImages(const aImages: TCustomImageList);
|
||||||
|
begin
|
||||||
|
Button.Images := aImages;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TCustomEditButton.SetImageWidth(const aImageWidth: Integer);
|
||||||
|
begin
|
||||||
|
Button.ImageWidth := aImageWidth;
|
||||||
|
end;
|
||||||
|
|
||||||
function TCustomEditButton.GetEditorClassType: TGEEditClass;
|
function TCustomEditButton.GetEditorClassType: TGEEditClass;
|
||||||
begin
|
begin
|
||||||
Result := TEbEdit;
|
Result := TEbEdit;
|
||||||
@ -1064,12 +1093,10 @@ end;
|
|||||||
|
|
||||||
function TCustomEditButton.GetBuddyClassType: TControlClass;
|
function TCustomEditButton.GetBuddyClassType: TControlClass;
|
||||||
begin
|
begin
|
||||||
Result := TSpeedButton;
|
Result := TEditSpeedButton;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
constructor TCustomEditButton.Create(AOwner: TComponent);
|
constructor TCustomEditButton.Create(AOwner: TComponent);
|
||||||
var
|
|
||||||
B: TBitmap;
|
|
||||||
begin
|
begin
|
||||||
inherited Create(AOwner);
|
inherited Create(AOwner);
|
||||||
FButtonOnlyWhenFocused := False;
|
FButtonOnlyWhenFocused := False;
|
||||||
@ -1077,12 +1104,7 @@ begin
|
|||||||
|
|
||||||
SetInitialBounds(0, 0, GetControlClassDefaultSize.CX, GetControlClassDefaultSize.CY);
|
SetInitialBounds(0, 0, GetControlClassDefaultSize.CX, GetControlClassDefaultSize.CY);
|
||||||
|
|
||||||
B := GetDefaultGlyph;
|
LoadDefaultGlyph;
|
||||||
if B = nil
|
|
||||||
then
|
|
||||||
Button.LoadGlyphFromResourceName(hInstance, GetDefaultGlyphName)
|
|
||||||
else
|
|
||||||
Button.Glyph := B;
|
|
||||||
Spacing := 4;
|
Spacing := 4;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -1261,7 +1283,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TCustomControlFilterEdit.GetDefaultGlyphName: String;
|
function TCustomControlFilterEdit.GetDefaultGlyphName: string;
|
||||||
begin
|
begin
|
||||||
Result := ResBtnListFilter;
|
Result := ResBtnListFilter;
|
||||||
end;
|
end;
|
||||||
@ -1378,12 +1400,7 @@ begin
|
|||||||
if FocusOnButtonClick then FocusAndMaybeSelectAll;
|
if FocusOnButtonClick then FocusAndMaybeSelectAll;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TFileNameEdit.GetDefaultGlyph: TBitmap;
|
function TFileNameEdit.GetDefaultGlyphName: string;
|
||||||
begin
|
|
||||||
Result := FileOpenGlyph;
|
|
||||||
end;
|
|
||||||
|
|
||||||
function TFileNameEdit.GetDefaultGlyphName: String;
|
|
||||||
begin
|
begin
|
||||||
Result := ResBtnFileOpen;
|
Result := ResBtnFileOpen;
|
||||||
end;
|
end;
|
||||||
@ -1469,12 +1486,7 @@ begin
|
|||||||
if FocusOnButtonClick then FocusAndMaybeSelectAll;
|
if FocusOnButtonClick then FocusAndMaybeSelectAll;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TDirectoryEdit.GetDefaultGlyph: TBitmap;
|
function TDirectoryEdit.GetDefaultGlyphName: string;
|
||||||
begin
|
|
||||||
Result := FileOpenGlyph;
|
|
||||||
end;
|
|
||||||
|
|
||||||
function TDirectoryEdit.GetDefaultGlyphName: String;
|
|
||||||
begin
|
begin
|
||||||
Result := ResBtnSelDir;
|
Result := ResBtnSelDir;
|
||||||
end;
|
end;
|
||||||
@ -1537,12 +1549,7 @@ begin
|
|||||||
Result := FFixedDateFormat;
|
Result := FFixedDateFormat;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TDateEdit.GetDefaultGlyph: TBitmap;
|
function TDateEdit.GetDefaultGlyphName: string;
|
||||||
begin
|
|
||||||
Result := DateGlyph;
|
|
||||||
end;
|
|
||||||
|
|
||||||
function TDateEdit.GetDefaultGlyphName: String;
|
|
||||||
begin
|
begin
|
||||||
Result := ResBtnCalendar;
|
Result := ResBtnCalendar;
|
||||||
end;
|
end;
|
||||||
@ -2121,12 +2128,7 @@ begin
|
|||||||
SetTime(FTime);
|
SetTime(FTime);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TTimeEdit.GetDefaultGlyph: TBitmap;
|
function TTimeEdit.GetDefaultGlyphName: string;
|
||||||
begin
|
|
||||||
Result := TimeGlyph;
|
|
||||||
end;
|
|
||||||
|
|
||||||
function TTimeEdit.GetDefaultGlyphName: String;
|
|
||||||
begin
|
begin
|
||||||
Result := ResBtnTime;
|
Result := ResBtnTime;
|
||||||
end;
|
end;
|
||||||
@ -2168,12 +2170,7 @@ begin
|
|||||||
Result:=StrToIntDef(Text,0);
|
Result:=StrToIntDef(Text,0);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TCalcEdit.GetDefaultGlyph: TBitmap;
|
function TCalcEdit.GetDefaultGlyphName: string;
|
||||||
begin
|
|
||||||
Result := CalcGlyph;
|
|
||||||
end;
|
|
||||||
|
|
||||||
function TCalcEdit.GetDefaultGlyphName: String;
|
|
||||||
begin
|
begin
|
||||||
Result := ResBtnCalculator;
|
Result := ResBtnCalculator;
|
||||||
end;
|
end;
|
||||||
|
Loading…
Reference in New Issue
Block a user