mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-12 22:19:18 +02:00
MG: gradient fill, minor issues from Andrew
git-svn-id: trunk@2703 -
This commit is contained in:
parent
275daf8807
commit
2d9631147e
@ -26,11 +26,11 @@ uses
|
|||||||
StdCtrls, Buttons, ComCtrls, Menus, ExtCtrls, Dialogs, LCLLinux, PropEdits;
|
StdCtrls, Buttons, ComCtrls, Menus, ExtCtrls, Dialogs, LCLLinux, PropEdits;
|
||||||
|
|
||||||
type
|
type
|
||||||
{TPixmapPropertyEditor
|
{TGraphicPropertyEditor
|
||||||
The default property editor for all TGraphic's and sub types (e.g. TBitmap,
|
The default property editor for all TGraphic's and sub types (e.g. TBitmap,
|
||||||
TPixmap, TIcon, etc.). }
|
TPixmap, TIcon, etc.). }
|
||||||
|
|
||||||
TPixmapPropertyEditor = class(TClassPropertyEditor)
|
TGraphicPropertyEditor = class(TClassPropertyEditor)
|
||||||
public
|
public
|
||||||
procedure Edit; override;
|
procedure Edit; override;
|
||||||
function GetAttributes: TPropertyAttributes; override;
|
function GetAttributes: TPropertyAttributes; override;
|
||||||
@ -39,14 +39,14 @@ type
|
|||||||
{ TPicturePropertyEditor
|
{ TPicturePropertyEditor
|
||||||
The default property editor for TPicture}
|
The default property editor for TPicture}
|
||||||
|
|
||||||
TPicturePropertyEditor = class(TPixmapPropertyEditor)
|
TPicturePropertyEditor = class(TGraphicPropertyEditor)
|
||||||
public
|
public
|
||||||
procedure Edit; override;
|
procedure Edit; override;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TButtonGlyphPropEditor
|
{ TButtonGlyphPropEditor
|
||||||
The default property editor for the Glyphs of TSpeedButton and TBitBtn }
|
The default property editor for the Glyphs of TSpeedButton and TBitBtn }
|
||||||
TButtonGlyphPropEditor = class(TPixmapPropertyEditor)
|
TButtonGlyphPropEditor = class(TGraphicPropertyEditor)
|
||||||
public
|
public
|
||||||
procedure Edit; override;
|
procedure Edit; override;
|
||||||
end;
|
end;
|
||||||
@ -135,7 +135,7 @@ var
|
|||||||
|
|
||||||
{Form For Picture/Graphic Property Editor}
|
{Form For Picture/Graphic Property Editor}
|
||||||
type
|
type
|
||||||
TPicturePropertyEditorForm = class(TForm)
|
TGraphicPropertyEditorForm = class(TForm)
|
||||||
protected
|
protected
|
||||||
Opendlg: TOPENDIALOG;
|
Opendlg: TOPENDIALOG;
|
||||||
Savedlg: TSAVEDIALOG;
|
Savedlg: TSAVEDIALOG;
|
||||||
@ -147,8 +147,6 @@ type
|
|||||||
SaveBTN: TBUTTON;
|
SaveBTN: TBUTTON;
|
||||||
ClearBTN : TBUTTON;
|
ClearBTN : TBUTTON;
|
||||||
|
|
||||||
ScrollPanel : TPanel;
|
|
||||||
|
|
||||||
ScrollBox : TScrollBox;
|
ScrollBox : TScrollBox;
|
||||||
|
|
||||||
procedure LoadBTNCLICK(Sender: TObject);
|
procedure LoadBTNCLICK(Sender: TObject);
|
||||||
@ -162,7 +160,7 @@ type
|
|||||||
Constructor Create(AOwner : TComponent); Override;
|
Constructor Create(AOwner : TComponent); Override;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Constructor TPicturePropertyEditorForm.Create(AOwner : TComponent);
|
Constructor TGraphicPropertyEditorForm.Create(AOwner : TComponent);
|
||||||
begin
|
begin
|
||||||
Inherited Create(AOwner);
|
Inherited Create(AOwner);
|
||||||
|
|
||||||
@ -217,28 +215,14 @@ begin
|
|||||||
TOP := 8;
|
TOP := 8;
|
||||||
WIDTH := 310;
|
WIDTH := 310;
|
||||||
AutoSize := False;
|
AutoSize := False;
|
||||||
|
Color := clWhite;
|
||||||
AutoScroll := True;
|
AutoScroll := True;
|
||||||
Show;
|
Show;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
ScrollPanel := TPanel.Create(ScrollBox);
|
Preview := TIMAGE.Create(ScrollBox);
|
||||||
With ScrollPanel do begin
|
|
||||||
Parent := ScrollBox;
|
|
||||||
Caption := '';
|
|
||||||
BorderStyle := bsNone;
|
|
||||||
BevelInner := bvNone;
|
|
||||||
BevelOuter := bvNone;
|
|
||||||
Color := clWhite;
|
|
||||||
LEFT := 0;
|
|
||||||
HEIGHT := 356;
|
|
||||||
TOP := 0;
|
|
||||||
WIDTH := 302;
|
|
||||||
Show;
|
|
||||||
end;
|
|
||||||
|
|
||||||
Preview := TIMAGE.Create(ScrollPanel);
|
|
||||||
With Preview do begin
|
With Preview do begin
|
||||||
Parent := ScrollPanel;
|
Parent := ScrollBox;
|
||||||
LEFT := 0;
|
LEFT := 0;
|
||||||
HEIGHT := 356;
|
HEIGHT := 356;
|
||||||
TOP := 0;
|
TOP := 0;
|
||||||
@ -254,8 +238,6 @@ begin
|
|||||||
Show;
|
Show;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
ScrollPanel.AutoSize := True;
|
|
||||||
|
|
||||||
CANCELBTN := TBITBTN.Create(Self);
|
CANCELBTN := TBITBTN.Create(Self);
|
||||||
With CANCELBTN do begin
|
With CANCELBTN do begin
|
||||||
Parent := Self;
|
Parent := Self;
|
||||||
@ -308,7 +290,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TPicturePropertyEditorForm.LoadBTNCLICK(Sender: TObject);
|
procedure TGraphicPropertyEditorForm.LoadBTNCLICK(Sender: TObject);
|
||||||
Const
|
Const
|
||||||
Formats : Array[0..1{7}] of String =
|
Formats : Array[0..1{7}] of String =
|
||||||
('.xpm',
|
('.xpm',
|
||||||
@ -340,32 +322,32 @@ begin
|
|||||||
SaveBTN.Enabled := True;
|
SaveBTN.Enabled := True;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TPicturePropertyEditorForm.SaveBTNCLICK(Sender: TObject);
|
procedure TGraphicPropertyEditorForm.SaveBTNCLICK(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
If SaveDlg.Execute then
|
If SaveDlg.Execute then
|
||||||
Preview.Picture.SaveToFile(SaveDlg.FileName);
|
Preview.Picture.SaveToFile(SaveDlg.FileName);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TPicturePropertyEditorForm.ClearBTNCLICK(Sender: TObject);
|
procedure TGraphicPropertyEditorForm.ClearBTNCLICK(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
With Preview do begin
|
With Preview do begin
|
||||||
Picture.Graphic := nil;
|
Picture.Graphic := nil;
|
||||||
Width := 0;
|
Width := 0;
|
||||||
Height := 0;
|
Height := 0;
|
||||||
end;
|
end;
|
||||||
ScrollPanel.Invalidate;
|
ScrollBox.Invalidate;
|
||||||
SaveBTN.Enabled := False;
|
SaveBTN.Enabled := False;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TPixmapPropertyEditor }
|
{ TGraphicPropertyEditor }
|
||||||
procedure TPixmapPropertyEditor.Edit;
|
procedure TGraphicPropertyEditor.Edit;
|
||||||
var
|
var
|
||||||
TheDialog: TPicturePropertyEditorForm;
|
TheDialog: TGraphicPropertyEditorForm;
|
||||||
Pixmap : TBitmap;
|
Pixmap : TBitmap;
|
||||||
Ext : String;
|
Ext : String;
|
||||||
begin
|
begin
|
||||||
Pixmap := TBitmap(GetOrdValue);
|
Pixmap := TBitmap(GetOrdValue);
|
||||||
TheDialog := TPicturePropertyEditorForm.Create(Application);
|
TheDialog := TGraphicPropertyEditorForm.Create(Application);
|
||||||
If not Pixmap.Empty then begin
|
If not Pixmap.Empty then begin
|
||||||
TheDialog.Preview.Picture.Pixmap.Width := Pixmap.Width;
|
TheDialog.Preview.Picture.Pixmap.Width := Pixmap.Width;
|
||||||
TheDialog.Preview.Picture.Pixmap.Height := Pixmap.Height;
|
TheDialog.Preview.Picture.Pixmap.Height := Pixmap.Height;
|
||||||
@ -403,7 +385,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TPixmapPropertyEditor.GetAttributes: TPropertyAttributes;
|
function TGraphicPropertyEditor.GetAttributes: TPropertyAttributes;
|
||||||
begin
|
begin
|
||||||
Result := [paDialog, paRevertable, paReadOnly];
|
Result := [paDialog, paRevertable, paReadOnly];
|
||||||
end;
|
end;
|
||||||
@ -411,11 +393,11 @@ end;
|
|||||||
{ TPicturePropertyEditor }
|
{ TPicturePropertyEditor }
|
||||||
procedure TPicturePropertyEditor.Edit;
|
procedure TPicturePropertyEditor.Edit;
|
||||||
var
|
var
|
||||||
TheDialog: TPicturePropertyEditorForm;
|
TheDialog: TGraphicPropertyEditorForm;
|
||||||
Picture : TPicture;
|
Picture : TPicture;
|
||||||
begin
|
begin
|
||||||
Picture := TPicture(GetOrdValue);
|
Picture := TPicture(GetOrdValue);
|
||||||
TheDialog := TPicturePropertyEditorForm.Create(Application);
|
TheDialog := TGraphicPropertyEditorForm.Create(Application);
|
||||||
If (Picture.Graphic <> nil) and (Picture.Graphic is TBitmap) then begin
|
If (Picture.Graphic <> nil) and (Picture.Graphic is TBitmap) then begin
|
||||||
TheDialog.Preview.Picture.Bitmap.Width := Picture.Width;
|
TheDialog.Preview.Picture.Bitmap.Width := Picture.Width;
|
||||||
TheDialog.Preview.Picture.Bitmap.Height := Picture.Height;
|
TheDialog.Preview.Picture.Bitmap.Height := Picture.Height;
|
||||||
@ -444,10 +426,9 @@ end;
|
|||||||
|
|
||||||
procedure TButtonGlyphPropEditor.Edit;
|
procedure TButtonGlyphPropEditor.Edit;
|
||||||
var
|
var
|
||||||
TheDialog: TPicturePropertyEditorForm;
|
TheDialog: TGraphicPropertyEditorForm;
|
||||||
Pixmap : TPixmap;
|
Pixmap : TPixmap;
|
||||||
Component : TComponent;
|
|
||||||
|
|
||||||
Procedure LoadPixmap;
|
Procedure LoadPixmap;
|
||||||
var
|
var
|
||||||
ext : String;
|
ext : String;
|
||||||
@ -455,9 +436,8 @@ var
|
|||||||
Ext := ExtractFileName(TheDialog.FileName);
|
Ext := ExtractFileName(TheDialog.FileName);
|
||||||
Pixmap := TPixmap.Create;
|
Pixmap := TPixmap.Create;
|
||||||
if AnsiCompareText(Ext, '.xpm') = 0 then begin
|
if AnsiCompareText(Ext, '.xpm') = 0 then begin
|
||||||
If TheDialog.FileName <> '' then
|
If FileExists(TheDialog.FileName) then
|
||||||
If FileExists(TheDialog.FileName) then
|
Pixmap.LoadFromFile(TheDialog.FileName);
|
||||||
Pixmap.LoadFromFile(TheDialog.FileName);
|
|
||||||
end
|
end
|
||||||
else begin
|
else begin
|
||||||
Pixmap.Width := TheDialog.Preview.Picture.Graphic.Width;
|
Pixmap.Width := TheDialog.Preview.Picture.Graphic.Width;
|
||||||
@ -469,16 +449,10 @@ var
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
Component := TComponent(GetComponent(0));
|
|
||||||
If (Component = nil) or ((not (Component is TSpeedButton)) and
|
|
||||||
(not (Component is TBitBtn))) or (LowerCase(GetName) <> 'glyph')
|
|
||||||
then begin
|
|
||||||
Inherited Edit;
|
|
||||||
exit;
|
|
||||||
end;
|
|
||||||
Pixmap := TPixmap(GetOrdValue);
|
Pixmap := TPixmap(GetOrdValue);
|
||||||
TheDialog := TPicturePropertyEditorForm.Create(Application);
|
TheDialog := TGraphicPropertyEditorForm.Create(Application);
|
||||||
If not Pixmap.Empty then begin
|
If not Pixmap.Empty then begin
|
||||||
TheDialog.Preview.Picture.Pixmap.Width := Pixmap.Width;
|
TheDialog.Preview.Picture.Pixmap.Width := Pixmap.Width;
|
||||||
TheDialog.Preview.Picture.Pixmap.Height := Pixmap.Height;
|
TheDialog.Preview.Picture.Pixmap.Height := Pixmap.Height;
|
||||||
@ -808,8 +782,7 @@ initialization
|
|||||||
RegisterPropertyEditor(DummyClassForPropTypes.PTypeInfos('TPenStyle'),
|
RegisterPropertyEditor(DummyClassForPropTypes.PTypeInfos('TPenStyle'),
|
||||||
nil,'',TPenStylePropertyEditor);
|
nil,'',TPenStylePropertyEditor);
|
||||||
RegisterPropertyEditor(ClassTypeInfo(TFont), nil,'',TFontPropertyEditor);
|
RegisterPropertyEditor(ClassTypeInfo(TFont), nil,'',TFontPropertyEditor);
|
||||||
RegisterPropertyEditor(ClassTypeInfo(TPixmap), nil,'',TPixmapPropertyEditor);
|
RegisterPropertyEditor(ClassTypeInfo(TGraphic), nil,'',TGraphicPropertyEditor);
|
||||||
RegisterPropertyEditor(ClassTypeInfo(TBitmap), nil,'',TPixmapPropertyEditor);
|
|
||||||
RegisterPropertyEditor(ClassTypeInfo(TPicture), nil,'',TPicturePropertyEditor);
|
RegisterPropertyEditor(ClassTypeInfo(TPicture), nil,'',TPicturePropertyEditor);
|
||||||
|
|
||||||
RegisterPropertyEditor(ClassTypeInfo(TBitmap), TSpeedButton,'Glyph',
|
RegisterPropertyEditor(ClassTypeInfo(TBitmap), TSpeedButton,'Glyph',
|
||||||
|
Loading…
Reference in New Issue
Block a user