spktoolbar: Activate Hi-DPI toolbar features.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@6193 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz 2018-02-10 00:38:06 +00:00
parent 856716b59f
commit bf14d85c04
7 changed files with 289 additions and 25 deletions

View File

@ -12,7 +12,8 @@ interface
{$MESSAGE HINT 'Every rect in this module are exact rectanges (not like in WINAPI without right and bottom)'} {$MESSAGE HINT 'Every rect in this module are exact rectanges (not like in WINAPI without right and bottom)'}
uses uses
LCLType, Graphics, SysUtils, Classes, Controls, StdCtrls, SpkGraphTools, SpkMath; LCLType, LCLVersion, Graphics, SysUtils, Classes, Controls, StdCtrls,
SpkGraphTools, SpkMath;
type type
TCornerPos = (cpLeftTop, cpRightTop, cpLeftBottom, cpRightBottom); TCornerPos = (cpLeftTop, cpRightTop, cpLeftBottom, cpRightBottom);
@ -273,6 +274,13 @@ type
ImageIndex : integer; ImageIndex : integer;
Point : T2DIntVector; Point : T2DIntVector;
ClipRect : T2DIntRect); overload; ClipRect : T2DIntRect); overload;
class procedure DrawImage(ACanvas: TCanvas;
Imagelist: TImageList;
ImageIndex: integer;
Point : T2DIntVector;
ClipRect: T2DIntRect;
AImageWidthAt96PPI, ATargetPPI: Integer;
ACanvasFactor: Double); overload;
class procedure DrawDisabledImage(ABitmap : TBitmap; class procedure DrawDisabledImage(ABitmap : TBitmap;
Imagelist : TImageList; Imagelist : TImageList;
@ -1907,12 +1915,15 @@ begin
CombineRgn(ClipRgn, ClipRgn, OrgRgn, RGN_AND); CombineRgn(ClipRgn, ClipRgn, OrgRgn, RGN_AND);
SelectClipRgn(ACanvas.Handle, ClipRgn); SelectClipRgn(ACanvas.Handle, ClipRgn);
ImageList.Draw(ACanvas, Point.X, Point.Y, ImageIndex);
(*
{ wp: Next part fixes issue https://sourceforge.net/p/lazarus-ccr/bugs/35/ } { wp: Next part fixes issue https://sourceforge.net/p/lazarus-ccr/bugs/35/ }
ImageBitmap := TBitmap.Create; ImageBitmap := TBitmap.Create;
ImageList.GetBitmap(ImageIndex, ImageBitmap); ImageList.GetBitmap(ImageIndex, ImageBitmap);
ACanvas.Draw(Point.x, Point.y, ImageBitmap); ACanvas.Draw(Point.x, Point.y, ImageBitmap);
ImageBitmap.Free; ImageBitmap.Free;
*)
{ wp: The following lines were removed and replaced by the "ImageBitmap" lines { wp: The following lines were removed and replaced by the "ImageBitmap" lines
above in order to fix the "handle leak" of above in order to fix the "handle leak" of
@ -1937,6 +1948,64 @@ begin
DeleteObject(ClipRgn); DeleteObject(ClipRgn);
end; end;
class procedure TGUITools.DrawImage(ACanvas: TCanvas; Imagelist: TImageList;
ImageIndex: integer; Point : T2DIntVector; ClipRect: T2DIntRect;
AImageWidthAt96PPI, ATargetPPI: Integer; ACanvasFactor: Double);
var
UseOrgClipRgn: Boolean;
OrgRgn: HRGN;
ClipRgn: HRGN;
//ImageIcon: TIcon; // wp: no longer needed -- see below
ImageBitmap: TBitmap;
begin
// Storing original ClipRgn and applying a new one
SaveClipRgn(ACanvas.Handle, UseOrgClipRgn, OrgRgn);
ClipRgn := CreateRectRgn(ClipRect.left, ClipRect.Top, ClipRect.Right+1, ClipRect.Bottom+1);
if UseOrgClipRgn then
CombineRgn(ClipRgn, ClipRgn, OrgRgn, RGN_AND);
SelectClipRgn(ACanvas.Handle, ClipRgn);
{$IF LCL_FULLVERSION >= 1090000}
ImageList.DrawForPPI(ACanvas, Point.X, Point.Y, ImageIndex,
AImageWidthAt96PPI, ATargetPPI, ACanvasFactor);
{$ELSE}
ImageList.Draw(ACanvas, Point.X, Point.Y, ImageIndex);
{$ENDIF}
(*
{ wp: Next part fixes issue https://sourceforge.net/p/lazarus-ccr/bugs/35/ }
ImageBitmap := TBitmap.Create;
ImageList.GetBitmap(ImageIndex, ImageBitmap);
ACanvas.Draw(Point.x, Point.y, ImageBitmap);
ImageBitmap.Free;
*)
{ wp: The following lines were removed and replaced by the "ImageBitmap" lines
above in order to fix the "handle leak" of
https://sourceforge.net/p/lazarus-ccr/bugs/35/
Not daring to touch the ImageList.Draw which would have worked as well. }
(*
// avoid exclusive draw. draw with local canvas itself.
//ImageList.Draw(ACanvas, Point.x, Point.y, ImageIndex);
{$IfDef LCLWin32}
ImageIcon := TIcon.Create;
ImageList.GetIcon(ImageIndex, ImageIcon);
ACanvas.Draw(Point.x, Point.y, ImageIcon);
ImageIcon.Free;
{$Else}
ImageBitmap := TBitmap.Create;
ImageList.GetBitmap(ImageIndex, ImageBitmap);
ACanvas.Draw(Point.x, Point.y, ImageBitmap);
ImageBitmap.Free;
{$EndIf}
*)
RestoreClipRgn(ACanvas.Handle, UseOrgClipRgn, OrgRgn);
DeleteObject(ClipRgn);
end;
class procedure TGUITools.DrawMarkedText(ACanvas: TCanvas; x, y: integer; const AText, class procedure TGUITools.DrawMarkedText(ACanvas: TCanvas; x, y: integer; const AText,
AMarkPhrase: string; TextColor : TColor; ClipRect: T2DIntRect; CaseSensitive: boolean); AMarkPhrase: string; TextColor : TColor; ClipRect: T2DIntRect; CaseSensitive: boolean);
var var

View File

@ -182,6 +182,12 @@ type
automatically } automatically }
FDisabledLargeImages: TImageList; FDisabledLargeImages: TImageList;
{ Unscaled width of the small images }
FImagesWidth: Integer;
{ Unscaled width of the large images }
FLargeImagesWidth: Integer;
function DoTabChanging(OldIndex, NewIndex: integer): boolean; function DoTabChanging(OldIndex, NewIndex: integer): boolean;
// ***************************************************** // *****************************************************
@ -326,8 +332,23 @@ type
{$ENDIF} {$ENDIF}
{$ENDIF} {$ENDIF}
{ Hi-DPI image list support }
procedure SetImagesWidth(const AValue: Integer);
procedure SetLargeImagesWidth(const AValue: Integer);
public public
// **********************************
// *** Constructor and Destructor ***
// **********************************
{ Constructor }
constructor Create(AOwner: TComponent); override;
{ Destructor }
destructor Destroy; override;
// ************************* // *************************
// *** Dispatcher events *** // *** Dispatcher events ***
// ************************* // *************************
@ -347,15 +368,6 @@ type
{ Method gives back the instance of supporting bitmap } { Method gives back the instance of supporting bitmap }
function GetTempBitmap: TBitmap; function GetTempBitmap: TBitmap;
// **********************************
// *** Constructor and Destructor ***
// **********************************
{ Constructor }
constructor Create(AOwner: TComponent); override;
{ Destructor }
destructor Destroy; override;
// *************** // ***************
// *** Drawing *** // *** Drawing ***
@ -425,6 +437,12 @@ type
property DisabledLargeImages: TImageList property DisabledLargeImages: TImageList
read FDisabledLargeImages write SetDisabledLargeImages; read FDisabledLargeImages write SetDisabledLargeImages;
{ Unscaled size of the small images }
property ImagesWidth: Integer read FImagesWidth write SetImagesWidth default 16;
{ Unscaled size of the large images }
property LargeImagesWidth: Integer read FLargeImagesWidth write SetLargeImagesWidth default 32;
{ Events called before and after another tab is selected } { Events called before and after another tab is selected }
property OnTabChanging: TSpkTabChangingEvent property OnTabChanging: TSpkTabChangingEvent
read FOnTabChanging write FOnTabChanging; read FOnTabChanging write FOnTabChanging;
@ -541,6 +559,9 @@ constructor TSpkToolbar.Create(AOwner: TComponent);
begin begin
inherited Create(AOwner); inherited Create(AOwner);
FImagesWidth := 16;
FLargeImagesWidth := 32;
// Initialization of inherited property // Initialization of inherited property
Align := alTop; Align := alTop;
DoubleBuffered := true; // required after Laz 1.9 DoubleBuffered := true; // required after Laz 1.9
@ -564,7 +585,7 @@ begin
FTemporary := TBitmap.Create; FTemporary := TBitmap.Create;
FTemporary.Pixelformat := pf24bit; FTemporary.Pixelformat := pf24bit;
setlength(FTabRects, 0); SetLength(FTabRects, 0);
{$IFDEF EnhancedRecordSupport} {$IFDEF EnhancedRecordSupport}
FTabClipRect := T2DIntRect.Create(0, 0, 0, 0); FTabClipRect := T2DIntRect.Create(0, 0, 0, 0);
@ -585,6 +606,8 @@ begin
FTabs := TSpkTabs.Create(self); FTabs := TSpkTabs.Create(self);
FTabs.ToolbarDispatch := FToolbarDispatch; FTabs.ToolbarDispatch := FToolbarDispatch;
FTabs.Appearance := FAppearance; FTabs.Appearance := FAppearance;
FTabs.ImagesWidth := FImagesWidth;
FTabs.LargeImagesWidth := FLargeImagesWidth;
FTabIndex := -1; FTabIndex := -1;
Color := clSkyBlue; Color := clSkyBlue;
@ -1751,7 +1774,7 @@ begin
TabAppearance := FTabs[i].CustomAppearance TabAppearance := FTabs[i].CustomAppearance
else else
TabAppearance := FAppearance; TabAppearance := FAppearance;
FBuffer.Canvas.font.Assign(TabAppearance.Tab.TabHeaderFont); FBuffer.Canvas.Font.Assign(TabAppearance.Tab.TabHeaderFont);
TabWidth := 2 + // Frame TabWidth := 2 + // Frame
2 * TabCornerRadius + 2 * TabCornerRadius +
@ -1915,4 +1938,21 @@ end;
{$ENDIF} {$ENDIF}
{$ENDIF} {$ENDIF}
{ Hi-DPI image list support }
procedure TSpkToolbar.SetImagesWidth(const AValue: Integer);
begin
if FImagesWidth = AValue then Exit;
FImagesWidth := AValue;
NotifyMetricsChanged
end;
procedure TSpkToolbar.SetLargeImagesWidth(const AValue: Integer);
begin
if FLargeImagesWidth = AValue then Exit;
FLargeImagesWidth := AValue;
NotifyMetricsChanged
end;
end. end.

View File

@ -36,6 +36,8 @@ type
FDisabledImages: TImageList; FDisabledImages: TImageList;
FLargeImages: TImageList; FLargeImages: TImageList;
FDisabledLargeImages: TImageList; FDisabledLargeImages: TImageList;
FImagesWidth: Integer;
FLargeImagesWidth: Integer;
FVisible: boolean; FVisible: boolean;
FEnabled: boolean; FEnabled: boolean;
@ -47,6 +49,8 @@ type
procedure SetLargeImages(const Value: TImageList); virtual; procedure SetLargeImages(const Value: TImageList); virtual;
procedure SetDisabledLargeImages(const Value: TImageList); virtual; procedure SetDisabledLargeImages(const Value: TImageList); virtual;
procedure SetAppearance(const Value: TSpkToolbarAppearance); procedure SetAppearance(const Value: TSpkToolbarAppearance);
procedure SetImagesWidth(const Value: Integer);
procedure SetLargeImagesWidth(const Value: Integer);
public public
constructor Create(AOwner: TComponent); override; constructor Create(AOwner: TComponent); override;
@ -72,6 +76,8 @@ type
property DisabledImages: TImageList read FDisabledImages write SetDisabledImages; property DisabledImages: TImageList read FDisabledImages write SetDisabledImages;
property LargeImages: TImageList read FLargeImages write SetLargeImages; property LargeImages: TImageList read FLargeImages write SetLargeImages;
property DisabledLargeImages: TImageList read FDisabledLargeImages write SetDisabledLargeImages; property DisabledLargeImages: TImageList read FDisabledLargeImages write SetDisabledLargeImages;
property ImagesWidth: Integer read FImagesWidth write SetImagesWidth;
property LargeImagesWidth: Integer read FLargeImagesWidth write SetLargeImagesWidth;
property Rect: T2DIntRect read FRect write SetRect; property Rect: T2DIntRect read FRect write SetRect;
published published
@ -144,11 +150,21 @@ begin
FImages := Value; FImages := Value;
end; end;
procedure TSpkBaseItem.SetImagesWidth(const Value: Integer);
begin
FImagesWidth := Value;
end;
procedure TSpkBaseItem.SetLargeImages(const Value: TImageList); procedure TSpkBaseItem.SetLargeImages(const Value: TImageList);
begin begin
FLargeImages := Value; FLargeImages := Value;
end; end;
procedure TSpkBaseItem.SetLargeImagesWidth(const Value: Integer);
begin
FLargeImagesWidth := Value;
end;
procedure TSpkBaseItem.SetRect(const Value: T2DIntRect); procedure TSpkBaseItem.SetRect(const Value: T2DIntRect);
begin begin
FRect := Value; FRect := Value;

View File

@ -203,7 +203,7 @@ type
implementation implementation
uses uses
LCLType, LCLIntf, LCLProc, SysUtils, LCLType, LCLIntf, LCLProc, LCLVersion, SysUtils,
spkt_Pane, spkt_Appearance; spkt_Pane, spkt_Appearance;
@ -987,11 +987,13 @@ var
delta: Integer; delta: Integer;
cornerRadius: Integer; cornerRadius: Integer;
imgList: TImageList; imgList: TImageList;
imgSize: TSize;
txtHeight: Integer; txtHeight: Integer;
breakPos, breakWidth: Integer; breakPos, breakWidth: Integer;
s: String; s: String;
P: T2DIntPoint; P: T2DIntPoint;
drawBtn: Boolean; drawBtn: Boolean;
ppi: Integer;
R: TRect; R: TRect;
begin begin
if FToolbarDispatch = nil then if FToolbarDispatch = nil then
@ -1151,17 +1153,19 @@ begin
if (imgList <> nil) and (FLargeImageIndex >= 0) and (FLargeImageIndex < imgList.Count) then if (imgList <> nil) and (FLargeImageIndex >= 0) and (FLargeImageIndex < imgList.Count) then
begin begin
ppi := FAppearance.Element.CaptionFont.PixelsPerInch;
{$IF LCL_FULLVERSION >= 1090000}
imgSize := imgList.SizeForPPI[FLargeImagesWidth, ppi];
{$ELSE}
imgSize := Size(imgList.Width, imgList.Height);
{$ENDIF}
P := {$IFDEF EnhancedRecordSupport}T2DIntPoint.Create{$ELSE}Create2DIntPoint{$ENDIF}( P := {$IFDEF EnhancedRecordSupport}T2DIntPoint.Create{$ELSE}Create2DIntPoint{$ENDIF}(
FButtonRect.Left + (FButtonRect.Width - imgList.Width) div 2, FButtonRect.Left + (FButtonRect.Width - imgSize.CX) div 2,
FButtonRect.Top + LargeButtonBorderSize + LargeButtonGlyphMargin FButtonRect.Top + LargeButtonBorderSize + LargeButtonGlyphMargin
); );
TGUITools.DrawImage( TGUITools.DrawImage(ABuffer.Canvas, imgList, FLargeImageIndex, P, ClipRect,
ABuffer.Canvas, FLargeImagesWidth, ppi, 1.0);
imgList,
FLargeImageIndex,
P,
ClipRect
);
end; end;
// Text // Text
@ -1506,9 +1510,11 @@ var
delta: Integer; delta: Integer;
cornerRadius: Integer; cornerRadius: Integer;
imgList: TImageList; imgList: TImageList;
imgSize: TSize;
drawBtn: Boolean; drawBtn: Boolean;
R: TRect; R: TRect;
dx: Integer; dx: Integer;
ppi: Integer;
begin begin
if (FToolbarDispatch = nil) or (FAppearance = nil) then if (FToolbarDispatch = nil) or (FAppearance = nil) then
exit; exit;
@ -1585,18 +1591,27 @@ begin
if (imgList <> nil) and (FImageIndex >= 0) and (FImageIndex < imgList.Count) then if (imgList <> nil) and (FImageIndex >= 0) and (FImageIndex < imgList.Count) then
begin begin
ppi := FAppearance.Element.CaptionFont.PixelsPerInch;
{$IF LCL_FULLVERSION >= 1090000}
imgSize := imgList.SizeForPPI[FImagesWidth, ppi];
{$ELSE}
imgSize := Size(imgList.Width, imgList.Height);
{$ENDIF}
if (FGroupBehaviour in [gbContinuesGroup, gbEndsGroup]) then if (FGroupBehaviour in [gbContinuesGroup, gbEndsGroup]) then
x := FButtonRect.Left + SmallButtonHalfBorderWidth + SmallButtonPadding x := FButtonRect.Left + SmallButtonHalfBorderWidth + SmallButtonPadding
else else
x := FButtonRect.Left + SmallButtonBorderWidth + SmallButtonPadding; x := FButtonRect.Left + SmallButtonBorderWidth + SmallButtonPadding;
y := FButtonRect.top + (FButtonRect.height - imgList.Height) div 2; y := FButtonRect.top + (FButtonRect.height - imgSize.CY) div 2;
P := {$IFDEF EnhancedRecordSupport}T2DIntPoint.Create{$ELSE}Create2DIntPoint{$ENDIF}(x, y); P := {$IFDEF EnhancedRecordSupport}T2DIntPoint.Create{$ELSE}Create2DIntPoint{$ENDIF}(x, y);
TGUITools.DrawImage( TGUITools.DrawImage(
ABuffer.Canvas, ABuffer.Canvas,
imgList, imgList,
FImageIndex, FImageIndex,
P, P,
ClipRect ClipRect,
FImagesWidth,
ppi, 1.0
); );
end; end;

View File

@ -29,6 +29,8 @@ type
FDisabledImages: TImageList; FDisabledImages: TImageList;
FLargeImages: TImageList; FLargeImages: TImageList;
FDisabledLargeImages: TImageList; FDisabledLargeImages: TImageList;
FImagesWidth: Integer;
FLargeImagesWidth: Integer;
// *** Gettery i settery *** // *** Gettery i settery ***
procedure SetToolbarDispatch(const Value: TSpkBaseToolbarDispatch); procedure SetToolbarDispatch(const Value: TSpkBaseToolbarDispatch);
@ -38,6 +40,8 @@ type
procedure SetDisabledImages(const Value: TImageList); procedure SetDisabledImages(const Value: TImageList);
procedure SetLargeImages(const Value: TImageList); procedure SetLargeImages(const Value: TImageList);
procedure SetDisabledLargeImages(const Value: TImageList); procedure SetDisabledLargeImages(const Value: TImageList);
procedure SetImagesWidth(const Value: Integer);
procedure SetLargeImagesWidth(const Value: Integer);
public public
function AddLargeButton: TSpkLargeButton; function AddLargeButton: TSpkLargeButton;
@ -56,6 +60,8 @@ type
property DisabledImages: TImageList read FDisabledImages write SetDisabledImages; property DisabledImages: TImageList read FDisabledImages write SetDisabledImages;
property LargeImages: TImageList read FLargeImages write SetLargeImages; property LargeImages: TImageList read FLargeImages write SetLargeImages;
property DisabledLargeImages: TImageList read FDisabledLargeImages write SetDisabledLargeImages; property DisabledLargeImages: TImageList read FDisabledLargeImages write SetDisabledLargeImages;
property ImagesWidth: Integer read FImagesWidth write SetImagesWidth;
property LargeImagesWidth: Integer read FLargeImagesWidth write SetLargeImagesWidth;
end; end;
implementation implementation
@ -110,6 +116,8 @@ begin
TSpkBaseItem(Item).DisabledImages := FDisabledImages; TSpkBaseItem(Item).DisabledImages := FDisabledImages;
TSpkBaseItem(Item).LargeImages := FLargeImages; TSpkBaseItem(Item).LargeImages := FLargeImages;
TSpkBaseItem(Item).DisabledLargeImages := FDisabledLargeImages; TSpkBaseItem(Item).DisabledLargeImages := FDisabledLargeImages;
TSpkBaseItem(Item).ImagesWidth := FImagesWidth;
TSpkBaseItem(Item).LargeImagesWidth := FLargeImagesWidth;
TSpkBaseItem(Item).ToolbarDispatch := FToolbarDispatch; TSpkBaseItem(Item).ToolbarDispatch := FToolbarDispatch;
end; end;
@ -122,6 +130,8 @@ begin
TSpkBaseItem(Item).DisabledImages := nil; TSpkBaseItem(Item).DisabledImages := nil;
TSpkBaseItem(Item).LargeImages := nil; TSpkBaseItem(Item).LargeImages := nil;
TSpkBaseItem(Item).DisabledLargeImages := nil; TSpkBaseItem(Item).DisabledLargeImages := nil;
// TSpkBaseitem(Item).ImagesWidth := 0;
// TSpkBaseItem(Item).LargeImagesWidth := 0;
end; end;
end; end;
end; end;
@ -162,6 +172,15 @@ begin
Items[i].Images := Value; Items[i].Images := Value;
end; end;
procedure TSpkItems.SetImagesWidth(const Value: Integer);
var
i: Integer;
begin
FImagesWidth := Value;
for i := 0 to Count - 1 do
Items[i].ImagesWidth := Value;
end;
procedure TSpkItems.SetLargeImages(const Value: TImageList); procedure TSpkItems.SetLargeImages(const Value: TImageList);
var var
i: Integer; i: Integer;
@ -171,6 +190,15 @@ begin
Items[i].LargeImages := Value; Items[i].LargeImages := Value;
end; end;
procedure TSpkItems.SetLargeImagesWidth(const Value: Integer);
var
i: Integer;
begin
FLargeImagesWidth := Value;
for i := 0 to Count - 1 do
Items[i].LargeImagesWidth := Value;
end;
procedure TSpkItems.SetToolbarDispatch(const Value: TSpkBaseToolbarDispatch); procedure TSpkItems.SetToolbarDispatch(const Value: TSpkBaseToolbarDispatch);
var var
i : integer; i : integer;

View File

@ -54,6 +54,8 @@ type
FDisabledImages: TImageList; FDisabledImages: TImageList;
FLargeImages: TImageList; FLargeImages: TImageList;
FDisabledLargeImages: TImageList; FDisabledLargeImages: TImageList;
FImagesWidth: Integer;
FLargeImagesWidth: Integer;
FVisible: boolean; FVisible: boolean;
FItems: TSpkItems; FItems: TSpkItems;
@ -73,6 +75,8 @@ type
procedure SetDisabledImages(const Value: TImageList); procedure SetDisabledImages(const Value: TImageList);
procedure SetLargeImages(const Value: TImageList); procedure SetLargeImages(const Value: TImageList);
procedure SetDisabledLargeImages(const Value: TImageList); procedure SetDisabledLargeImages(const Value: TImageList);
procedure SetImagesWidth(const Value: Integer);
procedure SetLargeImagesWidth(const Value: Integer);
procedure SetRect(ARect : T2DIntRect); procedure SetRect(ARect : T2DIntRect);
procedure SetToolbarDispatch(const Value: TSpkBaseToolbarDispatch); procedure SetToolbarDispatch(const Value: TSpkBaseToolbarDispatch);
@ -102,6 +106,8 @@ type
property DisabledImages: TImageList read FDisabledImages write SetDisabledImages; property DisabledImages: TImageList read FDisabledImages write SetDisabledImages;
property LargeImages: TImageList read FLargeImages write SetLargeImages; property LargeImages: TImageList read FLargeImages write SetLargeImages;
property DisabledLargeImages: TImageList read FDisabledLargeImages write SetDisabledLargeImages; property DisabledLargeImages: TImageList read FDisabledLargeImages write SetDisabledLargeImages;
property ImagesWidth: Integer read FImagesWidth write SetImagesWidth;
property LargeImagesWidth: Integer read FLargeImagesWidth write SetLargeImagesWidth;
property Items: TSpkItems read FItems; property Items: TSpkItems read FItems;
published published
@ -118,6 +124,8 @@ type
FDisabledImages: TImageList; FDisabledImages: TImageList;
FLargeImages: TImageList; FLargeImages: TImageList;
FDisabledLargeImages: TImageList; FDisabledLargeImages: TImageList;
FImagesWidth: Integer;
FLargeImagesWidth: Integer;
// *** Gettery i settery *** // *** Gettery i settery ***
procedure SetToolbarDispatch(const Value: TSpkBaseToolbarDispatch); procedure SetToolbarDispatch(const Value: TSpkBaseToolbarDispatch);
@ -127,6 +135,8 @@ type
procedure SetDisabledImages(const Value: TImageList); procedure SetDisabledImages(const Value: TImageList);
procedure SetLargeImages(const Value: TImageList); procedure SetLargeImages(const Value: TImageList);
procedure SetDisabledLargeImages(const Value: TImageList); procedure SetDisabledLargeImages(const Value: TImageList);
procedure SetImagesWidth(const Value: Integer);
procedure SetLargeImagesWidth(const Value: Integer);
public public
// *** Dodawanie i wstawianie elementów *** // *** Dodawanie i wstawianie elementów ***
@ -144,6 +154,8 @@ type
property DisabledImages: TImageList read FDisabledImages write SetDisabledImages; property DisabledImages: TImageList read FDisabledImages write SetDisabledImages;
property LargeImages: TImageList read FLargeImages write SetLargeImages; property LargeImages: TImageList read FLargeImages write SetLargeImages;
property DisabledLargeImages: TImageList read FDisabledLargeImages write SetDisabledLargeImages; property DisabledLargeImages: TImageList read FDisabledLargeImages write SetDisabledLargeImages;
property ImagesWidth: Integer read FImagesWidth write SetImagesWidth;
property LargeImagesWidth: Integer read FLargeImagesWidth write SetLargeImagesWidth;
end; end;
@ -179,6 +191,8 @@ begin
FItems := TSpkItems.Create(self); FItems := TSpkItems.Create(self);
FItems.ToolbarDispatch := FToolbarDispatch; FItems.ToolbarDispatch := FToolbarDispatch;
FItems.Appearance := FAppearance; FItems.Appearance := FAppearance;
FItems.ImagesWidth := FImagesWidth;
FItems.LargeImagesWidth := FLargeImagesWidth;
end; end;
destructor TSpkPane.Destroy; destructor TSpkPane.Destroy;
@ -950,12 +964,24 @@ begin
FItems.Images := FImages; FItems.Images := FImages;
end; end;
procedure TSpkPane.SetImagesWidth(const Value: Integer);
begin
FImagesWidth := Value;
FItems.ImagesWidth := FImagesWidth;
end;
procedure TSpkPane.SetLargeImages(const Value: TImageList); procedure TSpkPane.SetLargeImages(const Value: TImageList);
begin begin
FLargeImages := Value; FLargeImages := Value;
FItems.LargeImages := FLargeImages; FItems.LargeImages := FLargeImages;
end; end;
procedure TSpkPane.SetLargeImagesWidth(const Value: Integer);
begin
FLargeImagesWidth := Value;
FItems.LargeImagesWidth := FLargeImagesWidth;
end;
procedure TSpkPane.SetVisible(const Value: boolean); procedure TSpkPane.SetVisible(const Value: boolean);
begin begin
FVisible := Value; FVisible := Value;
@ -1025,6 +1051,8 @@ begin
TSpkPane(Item).DisabledImages := FDisabledImages; TSpkPane(Item).DisabledImages := FDisabledImages;
TSpkPane(Item).LargeImages := FLargeImages; TSpkPane(Item).LargeImages := FLargeImages;
TSpkPane(Item).DisabledLargeImages := FDisabledLargeImages; TSpkPane(Item).DisabledLargeImages := FDisabledLargeImages;
TSpkPane(Item).ImagesWidth := FImagesWidth;
TSpkPane(Item).LargeImagesWidth := FLargeImagesWidth;
TSpkPane(Item).ToolbarDispatch := FToolbarDispatch; TSpkPane(Item).ToolbarDispatch := FToolbarDispatch;
end; end;
opRemove: opRemove:
@ -1036,6 +1064,8 @@ begin
TSpkPane(Item).DisabledImages := nil; TSpkPane(Item).DisabledImages := nil;
TSpkPane(Item).LargeImages := nil; TSpkPane(Item).LargeImages := nil;
TSpkPane(Item).DisabledLargeImages := nil; TSpkPane(Item).DisabledLargeImages := nil;
// TSpkPane(Item).ImagesWidth := 0;
// TSpkPane(Item).LargeImagesWidth := 0;
end; end;
end; end;
end; end;
@ -1049,6 +1079,15 @@ begin
Items[i].Images := Value; Items[i].Images := Value;
end; end;
procedure TSpkPanes.SetImagesWidth(const Value: Integer);
var
I: Integer;
begin
FImagesWidth := Value;
for I := 0 to Count - 1 do
Items[i].ImagesWidth := Value;
end;
procedure TSpkPanes.SetLargeImages(const Value: TImageList); procedure TSpkPanes.SetLargeImages(const Value: TImageList);
var var
I: Integer; I: Integer;
@ -1058,6 +1097,15 @@ begin
Items[i].LargeImages := Value; Items[i].LargeImages := Value;
end; end;
procedure TSpkPanes.SetLargeImagesWidth(const Value: Integer);
var
I: Integer;
begin
FLargeImagesWidth := Value;
for I := 0 to Count - 1 do
Items[i].LargeImagesWidth := Value;
end;
procedure TSpkPanes.SetToolbarDispatch(const Value: TSpkBaseToolbarDispatch); procedure TSpkPanes.SetToolbarDispatch(const Value: TSpkBaseToolbarDispatch);
var var
i: integer; i: integer;

View File

@ -62,6 +62,8 @@ type
FDisabledImages: TImageList; FDisabledImages: TImageList;
FLargeImages: TImageList; FLargeImages: TImageList;
FDisabledLargeImages: TImageList; FDisabledLargeImages: TImageList;
FImagesWidth: Integer;
FLargeImagesWidth: Integer;
// *** Makro ustawia odpowiednie appearance taflom *** // *** Makro ustawia odpowiednie appearance taflom ***
procedure SetPaneAppearance; inline; procedure SetPaneAppearance; inline;
@ -84,6 +86,8 @@ type
procedure SetDisabledImages(const Value: TImageList); procedure SetDisabledImages(const Value: TImageList);
procedure SetLargeImages(const Value: TImageList); procedure SetLargeImages(const Value: TImageList);
procedure SetDisabledLargeImages(const Value: TImageList); procedure SetDisabledLargeImages(const Value: TImageList);
procedure SetImagesWidth(const Value: Integer);
procedure SetLargeImagesWidth(const Value: Integer);
procedure SetRect(ARect: T2DIntRect); procedure SetRect(ARect: T2DIntRect);
procedure SetToolbarDispatch(const Value: TSpkBaseToolbarDispatch); procedure SetToolbarDispatch(const Value: TSpkBaseToolbarDispatch);
@ -118,6 +122,8 @@ type
property DisabledImages: TImageList read FDisabledImages write SetDisabledImages; property DisabledImages: TImageList read FDisabledImages write SetDisabledImages;
property LargeImages: TImageList read FLargeImages write SetLargeImages; property LargeImages: TImageList read FLargeImages write SetLargeImages;
property DisabledLargeImages: TImageList read FDisabledLargeImages write SetDisabledLargeImages; property DisabledLargeImages: TImageList read FDisabledLargeImages write SetDisabledLargeImages;
property ImagesWidth: Integer read FImagesWidth write SetImagesWidth;
property LargeImagesWidth: Integer read FLargeImagesWidth write SetLargeImagesWidth;
published published
property CustomAppearance: TSpkToolbarAppearance read FCustomAppearance write SetCustomAppearance; property CustomAppearance: TSpkToolbarAppearance read FCustomAppearance write SetCustomAppearance;
@ -135,6 +141,8 @@ type
FDisabledImages: TImageList; FDisabledImages: TImageList;
FLargeImages: TImageList; FLargeImages: TImageList;
FDisabledLargeImages: TImageList; FDisabledLargeImages: TImageList;
FImagesWidth: Integer;
FLargeImagesWidth: Integer;
procedure SetToolbarDispatch(const Value: TSpkBaseToolbarDispatch); procedure SetToolbarDispatch(const Value: TSpkBaseToolbarDispatch);
function GetItems(AIndex: integer): TSpkTab; reintroduce; function GetItems(AIndex: integer): TSpkTab; reintroduce;
procedure SetAppearance(const Value: TSpkToolbarAppearance); procedure SetAppearance(const Value: TSpkToolbarAppearance);
@ -142,6 +150,8 @@ type
procedure SetDisabledImages(const Value: TImageList); procedure SetDisabledImages(const Value: TImageList);
procedure SetLargeImages(const Value: TImageList); procedure SetLargeImages(const Value: TImageList);
procedure SetDisabledLargeImages(const Value: TImageList); procedure SetDisabledLargeImages(const Value: TImageList);
procedure SetImagesWidth(const Value: Integer);
procedure SetLargeImagesWidth(const Value: Integer);
public public
function Add: TSpkTab; function Add: TSpkTab;
function Insert(AIndex: integer): TSpkTab; function Insert(AIndex: integer): TSpkTab;
@ -155,6 +165,8 @@ type
property DisabledImages: TImageList read FDisabledImages write SetDisabledImages; property DisabledImages: TImageList read FDisabledImages write SetDisabledImages;
property LargeImages: TImageList read FLargeImages write SetLargeImages; property LargeImages: TImageList read FLargeImages write SetLargeImages;
property DisabledLargeImages: TImageList read FDisabledLargeImages write SetDisabledLargeImages; property DisabledLargeImages: TImageList read FDisabledLargeImages write SetDisabledLargeImages;
property ImagesWidth: Integer read FImagesWidth write SetImagesWidth;
property LargeImagesWidth: Integer read FLargeImagesWidth write SetLargeImagesWidth;
end; end;
@ -190,6 +202,8 @@ begin
FCustomAppearance := TSpkToolbarAppearance.Create(FAppearanceDispatch); FCustomAppearance := TSpkToolbarAppearance.Create(FAppearanceDispatch);
FPanes := TSpkPanes.Create(self); FPanes := TSpkPanes.Create(self);
FPanes.ToolbarDispatch := FToolbarDispatch; FPanes.ToolbarDispatch := FToolbarDispatch;
FPanes.ImagesWidth := FImagesWidth;
FPanes.LargeImagesWidth := FLargeImagesWidth;
{$IFDEF EnhancedRecordSupport} {$IFDEF EnhancedRecordSupport}
FRect := T2DIntRect.Create(0,0,0,0); FRect := T2DIntRect.Create(0,0,0,0);
{$ELSE} {$ELSE}
@ -532,12 +546,24 @@ begin
FPanes.Images := Value; FPanes.Images := Value;
end; end;
procedure TSpkTab.SetImagesWidth(const Value: Integer);
begin
FImagesWidth := Value;
FPanes.ImagesWidth := Value;
end;
procedure TSpkTab.SetLargeImages(const Value: TImageList); procedure TSpkTab.SetLargeImages(const Value: TImageList);
begin begin
FLargeImages := Value; FLargeImages := Value;
FPanes.LargeImages := Value; FPanes.LargeImages := Value;
end; end;
procedure TSpkTab.SetLargeImagesWidth(const Value: Integer);
begin
FLargeImagesWidth := Value;
FPanes.LargeImagesWidth := Value;
end;
procedure TSpkTab.SetAppearance(const Value: TSpkToolbarAppearance); procedure TSpkTab.SetAppearance(const Value: TSpkToolbarAppearance);
begin begin
FAppearance := Value; FAppearance := Value;
@ -598,7 +624,7 @@ var
i: Integer; i: Integer;
begin begin
if (AIndex < 0) or (AIndex >= self.Count) then if (AIndex < 0) or (AIndex >= self.Count) then
raise InternalException.create('TSpkTabs.Insert: Nieprawid³owy indeks!'); raise InternalException.Create('TSpkTabs.Insert: Nieprawid³owy indeks!');
if FRootComponent<>nil then if FRootComponent<>nil then
begin begin
@ -611,7 +637,7 @@ begin
lParent := nil; lParent := nil;
end; end;
Result := TSpkTab.create(lOwner); Result := TSpkTab.Create(lOwner);
Result.Parent := lParent; Result.Parent := lParent;
if FRootComponent<>nil then if FRootComponent<>nil then
@ -640,6 +666,8 @@ begin
TSpkTab(Item).DisabledImages := self.FDisabledImages; TSpkTab(Item).DisabledImages := self.FDisabledImages;
TSpkTab(Item).LargeImages := self.FLargeImages; TSpkTab(Item).LargeImages := self.FLargeImages;
TSpkTab(Item).DisabledLargeImages := self.FDisabledLargeImages; TSpkTab(Item).DisabledLargeImages := self.FDisabledLargeImages;
TSpkTab(Item).ImagesWidth := self.FImagesWidth;
TSpkTab(Item).LargeImagesWidth := self.FLargeImagesWidth;
TSpkTab(Item).ToolbarDispatch := self.FToolbarDispatch; TSpkTab(Item).ToolbarDispatch := self.FToolbarDispatch;
end; end;
opRemove: opRemove:
@ -651,6 +679,8 @@ begin
TSpkTab(Item).DisabledImages := nil; TSpkTab(Item).DisabledImages := nil;
TSpkTab(Item).LargeImages := nil; TSpkTab(Item).LargeImages := nil;
TSpkTab(Item).DisabledLargeImages := nil; TSpkTab(Item).DisabledLargeImages := nil;
// TSpkTab(Item).ImagesWidth := 0;
// TSpkTab(Item).LargeImagesWidth := 0;
end; end;
end; end;
end; end;
@ -691,6 +721,15 @@ begin
Items[i].Images := Value; Items[i].Images := Value;
end; end;
procedure TSpkTabs.SetImagesWidth(const Value: Integer);
var
i: Integer;
begin
FImagesWidth := Value;
for i := 0 to Count - 1 do
Items[i].ImagesWidth := Value;
end;
procedure TSpkTabs.SetLargeImages(const Value: TImageList); procedure TSpkTabs.SetLargeImages(const Value: TImageList);
var var
i: Integer; i: Integer;
@ -700,6 +739,15 @@ begin
Items[i].LargeImages := Value; Items[i].LargeImages := Value;
end; end;
procedure TSpkTabs.SetLargeImagesWidth(const Value: Integer);
var
i: Integer;
begin
FLargeImagesWidth := Value;
for i := 0 to Count - 1 do
Items[i].LargeImagesWidth := Value;
end;
procedure TSpkTabs.SetToolbarDispatch(const Value: TSpkBaseToolbarDispatch); procedure TSpkTabs.SetToolbarDispatch(const Value: TSpkBaseToolbarDispatch);
var var
i: integer; i: integer;