mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-10 07:36:19 +02:00
prepared image sharing
git-svn-id: trunk@4724 -
This commit is contained in:
parent
ae02013fa3
commit
24a046fcf6
@ -62,6 +62,7 @@ type
|
|||||||
FOnOpenUnit: TNotifyEvent;
|
FOnOpenUnit: TNotifyEvent;
|
||||||
FSelected: TRegisteredComponent;
|
FSelected: TRegisteredComponent;
|
||||||
fUnregisteredIcon: TBitmap;
|
fUnregisteredIcon: TBitmap;
|
||||||
|
fSelectButtonIcon: TBitmap;
|
||||||
fUpdatingNotebook: boolean;
|
fUpdatingNotebook: boolean;
|
||||||
procedure SetNoteBook(const AValue: TNotebook);
|
procedure SetNoteBook(const AValue: TNotebook);
|
||||||
procedure SelectionToolClick(Sender: TObject);
|
procedure SelectionToolClick(Sender: TObject);
|
||||||
@ -284,6 +285,10 @@ begin
|
|||||||
fUnregisteredIcon.Free;
|
fUnregisteredIcon.Free;
|
||||||
fUnregisteredIcon:=nil;
|
fUnregisteredIcon:=nil;
|
||||||
end;
|
end;
|
||||||
|
if fSelectButtonIcon<>nil then begin
|
||||||
|
fSelectButtonIcon.Free;
|
||||||
|
fSelectButtonIcon:=nil;
|
||||||
|
end;
|
||||||
PopupMenu.Free;
|
PopupMenu.Free;
|
||||||
PopupMenu:=nil;
|
PopupMenu:=nil;
|
||||||
inherited Destroy;
|
inherited Destroy;
|
||||||
@ -310,9 +315,12 @@ end;
|
|||||||
|
|
||||||
function TComponentPalette.GetSelectButtonIcon: TBitmap;
|
function TComponentPalette.GetSelectButtonIcon: TBitmap;
|
||||||
begin
|
begin
|
||||||
Result:=TPixmap.Create;
|
if fSelectButtonIcon=nil then begin
|
||||||
Result.TransparentColor:=clWhite;
|
fSelectButtonIcon:=TPixmap.Create;
|
||||||
Result.LoadFromLazarusResource('tmouse');
|
fSelectButtonIcon.TransparentColor:=clWhite;
|
||||||
|
fSelectButtonIcon.LoadFromLazarusResource('tmouse');
|
||||||
|
end;
|
||||||
|
Result:=fSelectButtonIcon;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TComponentPalette.ClearButtons;
|
procedure TComponentPalette.ClearButtons;
|
||||||
@ -396,7 +404,7 @@ begin
|
|||||||
Name:='PaletteSelectBtn'+IntToStr(i);
|
Name:='PaletteSelectBtn'+IntToStr(i);
|
||||||
Parent:=CurNoteBookPage;
|
Parent:=CurNoteBookPage;
|
||||||
OnClick := @SelectionToolClick;
|
OnClick := @SelectionToolClick;
|
||||||
Glyph:=GetSelectButtonIcon;
|
Glyph.LoadFromLazarusResource('tmouse');
|
||||||
Flat := True;
|
Flat := True;
|
||||||
GroupIndex:= 1;
|
GroupIndex:= 1;
|
||||||
Down := True;
|
Down := True;
|
||||||
@ -417,7 +425,7 @@ begin
|
|||||||
Name:='PaletteBtnPage'+IntToStr(i)+'_'+IntToStr(j)
|
Name:='PaletteBtnPage'+IntToStr(i)+'_'+IntToStr(j)
|
||||||
+'_'+CurComponent.ComponentClass.ClassName;
|
+'_'+CurComponent.ComponentClass.ClassName;
|
||||||
Parent := CurNoteBookPage;
|
Parent := CurNoteBookPage;
|
||||||
Glyph:=CurComponent.GetIconCopy;
|
Glyph := CurComponent.Icon;
|
||||||
Width := ComponentPaletteBtnWidth;
|
Width := ComponentPaletteBtnWidth;
|
||||||
Height := ComponentPaletteBtnHeight;
|
Height := ComponentPaletteBtnHeight;
|
||||||
GroupIndex := 1;
|
GroupIndex := 1;
|
||||||
|
@ -65,8 +65,8 @@ type
|
|||||||
//fOwner: TControl;
|
//fOwner: TControl;
|
||||||
//FOnPressed: TNotifyEvent;
|
//FOnPressed: TNotifyEvent;
|
||||||
//FOnReleased: TNotifyEvent;
|
//FOnReleased: TNotifyEvent;
|
||||||
FOnLeave: TNotifyEvent;
|
FOnMouseLeave: TNotifyEvent;
|
||||||
FOnEnter: TNotifyEvent;
|
FOnMouseEnter: TNotifyEvent;
|
||||||
//FOnResize: TNotifyEvent;
|
//FOnResize: TNotifyEvent;
|
||||||
FShortCut : TLMShortcut;
|
FShortCut : TLMShortcut;
|
||||||
Procedure SetDefault(Value : Boolean);
|
Procedure SetDefault(Value : Boolean);
|
||||||
@ -79,8 +79,8 @@ type
|
|||||||
procedure CreateWnd; override;
|
procedure CreateWnd; override;
|
||||||
procedure DoSendBtnDefault; virtual;
|
procedure DoSendBtnDefault; virtual;
|
||||||
|
|
||||||
property OnMouseEnter : TNotifyEvent read FOnEnter write FOnEnter;
|
property OnMouseEnter : TNotifyEvent read FOnMouseEnter write FOnMouseEnter;
|
||||||
property OnMouseLeave : TNotifyEvent read FOnLeave write FOnLeave;
|
property OnMouseLeave : TNotifyEvent read FOnMouseLeave write FOnMouseLeave;
|
||||||
procedure SetParent(AParent: TWinControl); override;
|
procedure SetParent(AParent: TWinControl); override;
|
||||||
procedure SetText(const Value: TCaption); override;
|
procedure SetText(const Value: TCaption); override;
|
||||||
public
|
public
|
||||||
@ -117,24 +117,23 @@ type
|
|||||||
|
|
||||||
TButtonGlyph = class
|
TButtonGlyph = class
|
||||||
private
|
private
|
||||||
FOriginal : TBitmap;
|
FOriginal: TBitmap;
|
||||||
FNumGlyphs : TNumGlyphs;
|
FNumGlyphs: TNumGlyphs;
|
||||||
|
FOnChange: TNotifyEvent;
|
||||||
FOnChange : TNotifyEvent;
|
procedure SetGlyph(Value: TBitmap);
|
||||||
procedure SetGlyph(Value : TBitmap);
|
procedure SetNumGlyphs(Value: TNumGlyphs);
|
||||||
procedure SetNumGlyphs(Value : TNumGlyphs);
|
|
||||||
protected
|
protected
|
||||||
procedure GlyphChanged(Sender : TObject);
|
procedure GlyphChanged(Sender: TObject);
|
||||||
public
|
public
|
||||||
constructor Create;
|
constructor Create;
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
|
|
||||||
function Draw(Canvas: TCanvas; const Client: TRect; const Offset: TPoint;
|
function Draw(Canvas: TCanvas; const Client: TRect; const Offset: TPoint;
|
||||||
State: TButtonState; Transparent: Boolean; BiDiFlags: Longint): TRect;
|
State: TButtonState; Transparent: Boolean;
|
||||||
property Glyph : TBitmap read FOriginal write SetGlyph;
|
BiDiFlags: Longint): TRect;
|
||||||
property NumGlyphs : TNumGlyphs read FNumGlyphs write SetNumGlyphs;
|
property Glyph: TBitmap read FOriginal write SetGlyph;
|
||||||
|
property NumGlyphs: TNumGlyphs read FNumGlyphs write SetNumGlyphs;
|
||||||
property OnChange : TNotifyEvent read FOnChange write FOnChange;
|
public
|
||||||
|
property OnChange: TNotifyEvent read FOnChange write FOnChange;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
@ -307,6 +306,9 @@ end.
|
|||||||
{ =============================================================================
|
{ =============================================================================
|
||||||
|
|
||||||
$Log$
|
$Log$
|
||||||
|
Revision 1.52 2003/10/22 18:43:23 mattias
|
||||||
|
prepared image sharing
|
||||||
|
|
||||||
Revision 1.51 2003/09/27 09:49:30 mattias
|
Revision 1.51 2003/09/27 09:49:30 mattias
|
||||||
fix for speedbutton from Micha
|
fix for speedbutton from Micha
|
||||||
|
|
||||||
|
@ -52,12 +52,13 @@ var
|
|||||||
begin
|
begin
|
||||||
if Source=Self then exit;
|
if Source=Self then exit;
|
||||||
if Source is TBitmap then begin
|
if Source is TBitmap then begin
|
||||||
//writeln('TBitMap.Assign ',ClassName,' ',Source.ClassName);
|
writeln('TBitMap.Assign ',ClassName,' ',Source.ClassName);
|
||||||
// TBitmap can share image data
|
// TBitmap can share image data
|
||||||
// -> check if already shared
|
// -> check if already shared
|
||||||
SrcBitmap:=TBitmap(Source);
|
SrcBitmap:=TBitmap(Source);
|
||||||
if SrcBitmap.FImage=FImage then exit;
|
if SrcBitmap.FImage=FImage then exit;
|
||||||
|
|
||||||
|
writeln('TBitMap.Assign A RefCount=',FImage.RefCount);
|
||||||
// image is not shared => new image data
|
// image is not shared => new image data
|
||||||
// -> free canvas (interface handles)
|
// -> free canvas (interface handles)
|
||||||
FreeCanvasContext;
|
FreeCanvasContext;
|
||||||
@ -66,6 +67,7 @@ begin
|
|||||||
// share FImage with assign graphic
|
// share FImage with assign graphic
|
||||||
FImage:=SrcBitmap.FImage;
|
FImage:=SrcBitmap.FImage;
|
||||||
FImage.Reference;
|
FImage.Reference;
|
||||||
|
writeln('TBitMap.Assign B ',Width,',',Height,' ',HandleAllocated,' RefCount=',FImage.RefCount);
|
||||||
{$IFDEF UseFPImage}
|
{$IFDEF UseFPImage}
|
||||||
end else if Source is TFPCustomImage then begin
|
end else if Source is TFPCustomImage then begin
|
||||||
SrcFPImage:=TFPCustomImage(Source);
|
SrcFPImage:=TFPCustomImage(Source);
|
||||||
@ -149,7 +151,9 @@ end;
|
|||||||
|
|
||||||
function TBitmap.LazarusResourceTypeValid(const ResourceType: string): boolean;
|
function TBitmap.LazarusResourceTypeValid(const ResourceType: string): boolean;
|
||||||
begin
|
begin
|
||||||
Result:=true;
|
Result:=((ClassType=TBitmap) or (ClassType=TPixmap))
|
||||||
|
and ((AnsiCompareText(ResourceType,'XPM')=0)
|
||||||
|
or (AnsiCompareText(ResourceType,'BMP')=0));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TBitMap.Mask(ATransparentColor: TColor);
|
procedure TBitMap.Mask(ATransparentColor: TColor);
|
||||||
@ -949,6 +953,9 @@ end;
|
|||||||
{ =============================================================================
|
{ =============================================================================
|
||||||
|
|
||||||
$Log$
|
$Log$
|
||||||
|
Revision 1.49 2003/10/22 18:43:23 mattias
|
||||||
|
prepared image sharing
|
||||||
|
|
||||||
Revision 1.48 2003/10/22 17:50:16 mattias
|
Revision 1.48 2003/10/22 17:50:16 mattias
|
||||||
updated rpm scripts
|
updated rpm scripts
|
||||||
|
|
||||||
|
@ -43,12 +43,19 @@ var
|
|||||||
GlyphCount : integer;
|
GlyphCount : integer;
|
||||||
begin
|
begin
|
||||||
if FOriginal = Value then exit;
|
if FOriginal = Value then exit;
|
||||||
// FOriginal.Assign(Value);
|
{$IFDEF BitmapSharingWorks}
|
||||||
|
if FOriginal=nil then begin
|
||||||
|
FOriginal:=TBitmap.Create;
|
||||||
|
end;
|
||||||
|
FOriginal.OnChange:=nil;
|
||||||
|
FOriginal.Assign(Value);
|
||||||
|
{$ELSE}
|
||||||
if FOriginal<>nil then begin
|
if FOriginal<>nil then begin
|
||||||
FOriginal.OnChange:=nil;
|
FOriginal.OnChange:=nil;
|
||||||
FOriginal.Free;
|
FOriginal.Free;
|
||||||
end;
|
end;
|
||||||
FOriginal:= Value;
|
FOriginal:= Value;
|
||||||
|
{$ENDIF}
|
||||||
FOriginal.OnChange := @GlyphChanged;
|
FOriginal.OnChange := @GlyphChanged;
|
||||||
FNumGlyphs:=1;
|
FNumGlyphs:=1;
|
||||||
if (FOriginal <> nil) and (FOriginal.Height > 0) then begin
|
if (FOriginal <> nil) and (FOriginal.Height > 0) then begin
|
||||||
|
@ -113,8 +113,8 @@ procedure TButton.CMMouseEnter(var Message: TMessage);
|
|||||||
begin
|
begin
|
||||||
Assert(False,'Trace:[TButton.CMMouseEnter]');
|
Assert(False,'Trace:[TButton.CMMouseEnter]');
|
||||||
inherited CMMouseEnter(Message);
|
inherited CMMouseEnter(Message);
|
||||||
If assigned(FOnEnter) then
|
If assigned(FOnMouseEnter) then
|
||||||
FOnEnter(Self);
|
FOnMouseEnter(Self);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
@ -122,14 +122,14 @@ end;
|
|||||||
Params: None
|
Params: None
|
||||||
Returns: Nothing
|
Returns: Nothing
|
||||||
|
|
||||||
Handles the event when the button Leaves
|
Handles the event when the mouse leaves the button
|
||||||
------------------------------------------------------------------------------}
|
------------------------------------------------------------------------------}
|
||||||
procedure TButton.CMMouseLeave(var Message: TMessage);
|
procedure TButton.CMMouseLeave(var Message: TMessage);
|
||||||
begin
|
begin
|
||||||
Assert(False,'Trace:[TButton.CMMouseLeave]');
|
Assert(False,'Trace:[TButton.CMMouseLeave]');
|
||||||
inherited CMMouseLeave(Message);
|
inherited CMMouseLeave(Message);
|
||||||
If assigned(FOnLeave) then
|
If assigned(FOnMouseLeave) then
|
||||||
FOnLeave(Self);
|
FOnMouseLeave(Self);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
@ -165,6 +165,9 @@ end;
|
|||||||
{ =============================================================================
|
{ =============================================================================
|
||||||
|
|
||||||
$Log$
|
$Log$
|
||||||
|
Revision 1.14 2003/10/22 18:43:23 mattias
|
||||||
|
prepared image sharing
|
||||||
|
|
||||||
Revision 1.13 2003/06/10 00:46:16 mattias
|
Revision 1.13 2003/06/10 00:46:16 mattias
|
||||||
fixed aligning controls
|
fixed aligning controls
|
||||||
|
|
||||||
|
@ -2652,11 +2652,12 @@ var
|
|||||||
ResName: string;
|
ResName: string;
|
||||||
res: TLResource;
|
res: TLResource;
|
||||||
begin
|
begin
|
||||||
Result:=TPixmap.Create;
|
Result:=TBitmap.Create;
|
||||||
Result.TransparentColor:=clWhite;
|
Result.TransparentColor:=clWhite;
|
||||||
ResName:=ComponentClass.ClassName;
|
ResName:=ComponentClass.ClassName;
|
||||||
res:=LazarusResources.Find(ResName);
|
res:=LazarusResources.Find(ResName);
|
||||||
if (res<>nil) and (res.Value<>'') and (res.ValueType='XPM') then begin
|
if (res<>nil) and (res.Value<>'')
|
||||||
|
and Result.LazarusResourceTypeValid(res.ValueType) then begin
|
||||||
Result.LoadFromLazarusResource(ResName);
|
Result.LoadFromLazarusResource(ResName);
|
||||||
end else begin
|
end else begin
|
||||||
Result.LoadFromLazarusResource('default');
|
Result.LoadFromLazarusResource('default');
|
||||||
|
Loading…
Reference in New Issue
Block a user