Стартовый пул
2963
spktoolbar/SpkGUITools/SpkGUITools.pas
Normal file
613
spktoolbar/SpkGraphTools/SpkGraphTools.pas
Normal file
@@ -0,0 +1,613 @@
|
||||
unit SpkGraphTools;
|
||||
|
||||
{$mode ObjFpc}
|
||||
{$H+}
|
||||
{$DEFINE SPKGRAPHTOOLS}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
LCLIntf, Graphics, LCLType, Classes, Math, Sysutils, Dialogs, SpkMath;
|
||||
|
||||
const
|
||||
NUM_ZERO = 0.00000001;
|
||||
|
||||
|
||||
(*******************************************************************************
|
||||
* *
|
||||
* Simple structure *
|
||||
* *
|
||||
*******************************************************************************)
|
||||
|
||||
type
|
||||
// Pointer to an array of TRGBTriple
|
||||
PRGBTripleArray = ^TRGBTripleArray;
|
||||
// Array of TRGBTriple records
|
||||
TRGBTripleArray = array[word] of TRGBTriple;
|
||||
|
||||
THSLTriple = record
|
||||
H, S, L: extended;
|
||||
end;
|
||||
|
||||
// Gradient types
|
||||
TGradientType = (gtVertical, gtHorizontal);
|
||||
// Line gradient types
|
||||
TGradientLineShade = (lsShadeStart, lsShadeEnds, lsShadeCenter, lsShadeEnd);
|
||||
// Line gradient types (3D)
|
||||
TGradient3dLine = (glRaised, glLowered);
|
||||
|
||||
|
||||
(*******************************************************************************
|
||||
* *
|
||||
* Utility classes *
|
||||
* *
|
||||
*******************************************************************************)
|
||||
|
||||
TColorTools = class
|
||||
public
|
||||
class function Darken(AColor: TColor; APercentage: byte): TColor;
|
||||
class function Brighten(AColor: TColor; APercentage: Integer): TColor;
|
||||
class function Shade(AColor1, AColor2: TColor; APercentage: Integer): TColor; overload;
|
||||
class function Shade(AColor1, AColor2: TColor; AStep: extended): TColor; overload;
|
||||
class function AddColors(AColor1, AColor2: TColor): TColor;
|
||||
class function MultiplyColors(AColor1, AColor2: TColor): TColor;
|
||||
class function MultiplyColor(AColor: TColor; AScalar: integer): TColor; overload;
|
||||
class function MultiplyColor(AColor: TColor; AScalar: extended): TColor; overload;
|
||||
class function percent(AMin, APos, AMax: integer): byte;
|
||||
class function RGB2HSL(ARGB: TRGBTriple): THSLTriple;
|
||||
class function HSL2RGB(AHSL: THSLTriple): TRGBTriple;
|
||||
class function RgbTripleToColor(ARgbTriple: TRGBTriple): TColor;
|
||||
class function ColorToRgbTriple(AColor: TColor): TRGBTriple;
|
||||
class function ColorToGrayscale(AColor: TColor): TColor;
|
||||
end;
|
||||
|
||||
TGradientTools = class
|
||||
public
|
||||
class procedure HGradient(ACanvas: TCanvas; cStart,cEnd: TColor; ARect: T2DIntRect); overload;
|
||||
class procedure HGradient(ACanvas: TCanvas; cStart,cEnd: TColor; p1, p2: TPoint); overload;
|
||||
class procedure HGradient(ACanvas: TCanvas; cStart,cEnd: TColor; x1,y1,x2,y2: integer); overload;
|
||||
|
||||
class procedure VGradient(ACanvas: TCanvas; cStart,cEnd: TColor; ARect: T2DIntRect); overload;
|
||||
class procedure VGradient(ACanvas: TCanvas; cStart,cEnd: TColor; p1, p2: TPoint); overload;
|
||||
class procedure VGradient(ACanvas: TCanvas; cStart,cEnd: TColor; x1,y1,x2,y2: integer); overload;
|
||||
|
||||
class procedure Gradient(ACanvas: TCanvas; cStart,cEnd: TColor; ARect: T2DIntRect; AGradientType : TGradientType); overload;
|
||||
class procedure Gradient(ACanvas: TCanvas; cStart,cEnd: TColor; p1, p2: TPoint; AGradientType : TGradientType); overload;
|
||||
class procedure Gradient(ACanvas: TCanvas; cStart,cEnd: TColor; x1,y1,x2,y2: integer; AGradientType : TGradientType); overload;
|
||||
|
||||
class procedure HGradientLine(ACanvas: TCanvas; cBase, cShade: TColor; x1, x2, y: integer; ShadeMode: TGradientLineShade);
|
||||
class procedure VGradientLine(ACanvas: TCanvas; cBase, cShade: TColor; x, y1, y2: integer; ShadeMode: TGradientLineShade);
|
||||
|
||||
class procedure HGradient3dLine(ACanvas: TCanvas; x1,x2,y: integer; ShadeMode: TGradientLineShade; A3dKind: TGradient3dLine = glLowered);
|
||||
class procedure VGradient3dLine(ACanvas: TCanvas; x,y1,y2: integer; ShadeMode: TGradientLineShade; A3dKind: TGradient3dLine = glLowered);
|
||||
end;
|
||||
|
||||
TTextTools = class
|
||||
public
|
||||
class procedure OutlinedText(ACanvas: TCanvas; x, y: integer; const AText: string);
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
type
|
||||
TRgbColor = packed record
|
||||
R,G,B,A: Byte;
|
||||
end;
|
||||
|
||||
|
||||
{ TColorTools }
|
||||
|
||||
class function TColorTools.Darken(AColor: TColor; APercentage: byte): TColor;
|
||||
var
|
||||
c: TRGBColor;
|
||||
f: extended;
|
||||
begin
|
||||
c := TRGBColor(ColorToRGB(AColor));
|
||||
f := (100 - APercentage) / 100;
|
||||
result := rgb(
|
||||
round(c.R * f),
|
||||
round(c.G * f),
|
||||
round(c.B * f)
|
||||
);
|
||||
end;
|
||||
|
||||
class function TColorTools.Brighten(AColor: TColor; APercentage: Integer): TColor;
|
||||
var
|
||||
c: TRgbColor;
|
||||
p: Extended;
|
||||
begin
|
||||
c := TRgbColor(ColorToRGB(AColor));
|
||||
p := APercentage/100;
|
||||
result := rgb(
|
||||
EnsureRange(round(c.R + (255-c.R)*p), 0, 255),
|
||||
EnsureRange(round(c.G + (255-c.G)*p), 0, 255),
|
||||
EnsureRange(round(c.B + (255-c.B)*p), 0, 255)
|
||||
);
|
||||
end;
|
||||
|
||||
class function TColorTools.Shade(AColor1, AColor2: TColor;
|
||||
APercentage: Integer): TColor;
|
||||
var
|
||||
c1, c2: TRgbColor;
|
||||
Step: Extended; // percentage as floating point number
|
||||
begin
|
||||
c1 := TRGBColor(ColorToRGB(AColor1));
|
||||
c2 := TRGBColor(ColorToRGB(AColor2));
|
||||
Step := APercentage / 100;
|
||||
result := rgb(
|
||||
EnsureRange(round(c1.R + (c2.R - c1.R) * Step), 0, 255),
|
||||
EnsureRange(round(c1.G + (c2.G - c1.G) * Step), 0, 255),
|
||||
EnsureRange(round(c1.B + (c2.B - c1.B) * Step), 0, 255)
|
||||
);
|
||||
end;
|
||||
|
||||
class function TColorTools.Shade(AColor1, AColor2: TColor; AStep: extended): TColor;
|
||||
var
|
||||
c1, c2: TRgbColor;
|
||||
begin
|
||||
c1 := TRgbColor(ColorToRGB(AColor1));
|
||||
c2 := TRgbColor(ColorToRGB(AColor2));
|
||||
result := rgb(
|
||||
round(c1.R + (c2.R - c1.R) * AStep),
|
||||
round(c1.G + (c2.G - c1.G) * AStep),
|
||||
round(c1.B + (c2.B - c1.B) * AStep)
|
||||
);
|
||||
end;
|
||||
|
||||
class function TColorTools.AddColors(AColor1, AColor2: TColor): TColor;
|
||||
var
|
||||
c1, c2: TRgbColor;
|
||||
begin
|
||||
c1 := TRgbColor(ColorToRGB(AColor1));
|
||||
c2 := TRgbColor(ColorToRGB(AColor2));
|
||||
result := rgb(
|
||||
max(0, min(255, Integer(c1.R) + c2.R)),
|
||||
max(0, min(255, Integer(c1.G) + c2.G)),
|
||||
max(0, min(255, Integer(c1.B) + c2.B))
|
||||
);
|
||||
end;
|
||||
|
||||
class function TColorTools.MultiplyColors(AColor1, AColor2: TColor): TColor;
|
||||
var
|
||||
c1, c2: TRgbColor;
|
||||
begin
|
||||
c1 := TRgbColor(ColorToRGB(AColor1));
|
||||
c2 := TRgbColor(ColorToRGB(AColor2));
|
||||
result := rgb(
|
||||
max(0, min(255, Integer(c1.R) * c2.R)),
|
||||
max(0, min(255, Integer(c1.G) * c2.G)),
|
||||
max(0, min(255, Integer(c1.B) * c2.B))
|
||||
);
|
||||
end;
|
||||
|
||||
class function TColorTools.MultiplyColor(AColor: TColor; AScalar: integer): TColor;
|
||||
var
|
||||
c: TRgbColor;
|
||||
begin
|
||||
c := TRgbColor(ColorToRGB(AColor));
|
||||
result := rgb(
|
||||
max(0, min(255, AScalar * c.R)),
|
||||
max(0, min(255, AScalar * c.G)),
|
||||
max(0, min(255, AScalar * c.B))
|
||||
);
|
||||
end;
|
||||
|
||||
class function TColorTools.MultiplyColor(AColor: TColor; AScalar: extended): TColor;
|
||||
var
|
||||
c: TRgbColor;
|
||||
begin
|
||||
c := TRgbColor(ColorToRGB(AColor));
|
||||
result := rgb(
|
||||
max(0, min(255, round(c.R * AScalar))),
|
||||
max(0, min(255, round(c.G * AScalar))),
|
||||
max(0, min(255, round(c.B * AScalar)))
|
||||
);
|
||||
end;
|
||||
|
||||
class function TColorTools.Percent(AMin, APos, AMax: integer): byte;
|
||||
begin
|
||||
if AMax = AMin then
|
||||
result := AMax // wp: is this correct? Shouldn't this be a value between a and 100?
|
||||
else
|
||||
result := round((APos - AMin) * 100 / (AMax - AMin));
|
||||
end;
|
||||
|
||||
{.$MESSAGE WARN 'Comparing real numbers? This has to be corrected.'}
|
||||
class function TColorTools.RGB2HSL(ARGB: TRGBTriple): THSLTriple;
|
||||
var
|
||||
RGBmin, RGBmax, RGBrange: extended;
|
||||
R, G, B: extended;
|
||||
H, S, L: extended;
|
||||
begin
|
||||
R := ARGB.rgbtRed/255;
|
||||
G := ARGB.rgbtGreen/255;
|
||||
B := ARGB.rgbtBlue/255;
|
||||
|
||||
RGBmin := min(R, min(G, B));
|
||||
RGBmax := max(R, min(G, B));
|
||||
RGBrange := RGBmax - RGBmin;
|
||||
|
||||
H := 0;
|
||||
if RGBmax = RGBmin then
|
||||
H := 0
|
||||
else
|
||||
if (R = RGBmax) and (G >= B) then
|
||||
H := pi/3 * (G-B) / RGBrange + 0
|
||||
else
|
||||
if (R = RGBmax) and (G < B) then
|
||||
H := pi/3 * (G-B) / RGBrange + 2*pi
|
||||
else
|
||||
if (G = RGBmax) then
|
||||
H := pi/3 * (B-R) / RGBrange + 2*pi/3
|
||||
else
|
||||
if (B = RGBmax) then
|
||||
H := pi/3 * (R-G) / RGBrange + 4*pi/3;
|
||||
|
||||
L := RGBrange / 2;
|
||||
|
||||
S:=0;
|
||||
if (L < NUM_ZERO) or (rgbMin = rgbMax) then
|
||||
S := 0
|
||||
else
|
||||
if (L <= 0.5) then
|
||||
S := RGBrange / (2*L)
|
||||
else
|
||||
if (L > 0.5) then
|
||||
S := RGBrange / (2-2*L);
|
||||
|
||||
result.H := H / (2*pi);
|
||||
result.S := S;
|
||||
result.L := L;
|
||||
end;
|
||||
|
||||
class function TColorTools.HSL2RGB(AHSL: THSLTriple): TRGBTriple;
|
||||
var
|
||||
R, G, B: extended;
|
||||
TR, TG, TB: extended;
|
||||
Q, P: extended;
|
||||
|
||||
function ProcessColor(c: extended): extended;
|
||||
begin
|
||||
if (c < 1/6) then
|
||||
result := P + (Q - P) * 6.0 * c
|
||||
else
|
||||
if (c < 1/2) then
|
||||
result := Q
|
||||
else
|
||||
if (c < 2/3) then
|
||||
result := P + (Q - P) * (2/3 - c) * 6.0
|
||||
else
|
||||
result := P;
|
||||
end;
|
||||
|
||||
begin
|
||||
if AHSL.S < NUM_ZERO then
|
||||
begin
|
||||
R := AHSL.L;
|
||||
G := AHSL.L;
|
||||
B := AHSL.L;
|
||||
end else
|
||||
begin
|
||||
if (AHSL.L < 0.5) then
|
||||
Q := AHSL.L * (AHSL.S + 1.0)
|
||||
else
|
||||
Q := AHSL.L + AHSL.S - AHSL.L*AHSL.S;
|
||||
|
||||
P := 2.0*AHSL.L - Q;
|
||||
|
||||
TR := AHSL.H + 1/3;
|
||||
TG := AHSL.H;
|
||||
TB := AHSL.H - 1/3;
|
||||
|
||||
if (TR < 0) then
|
||||
TR := TR + 1
|
||||
else
|
||||
if (TR > 1) then
|
||||
TR := TR - 1;
|
||||
|
||||
if (TG < 0) then
|
||||
TG := TG + 1
|
||||
else
|
||||
if (TG > 1) then
|
||||
TG := TG - 1;
|
||||
|
||||
if (TB < 0) then
|
||||
TB := TB + 1
|
||||
else
|
||||
if (TB > 1) then
|
||||
TB := TB - 1;
|
||||
|
||||
R := ProcessColor(TR);
|
||||
G := ProcessColor(TG);
|
||||
B := ProcessColor(TB);
|
||||
end;
|
||||
|
||||
result.rgbtRed := round(255*R);
|
||||
result.rgbtGreen := round(255*G);
|
||||
result.rgbtBlue := round(255*B);
|
||||
end;
|
||||
|
||||
class function TColorTools.RgbTripleToColor(ARgbTriple: TRGBTriple) : TColor;
|
||||
begin
|
||||
result := rgb(
|
||||
ARgbTriple.rgbtRed,
|
||||
ARgbTriple.rgbtGreen,
|
||||
ARgbTriple.rgbtBlue
|
||||
);
|
||||
end;
|
||||
|
||||
class function TColorTools.ColorToGrayscale(AColor: TColor): TColor;
|
||||
var
|
||||
c: TRgbColor;
|
||||
avg : byte;
|
||||
begin
|
||||
c := TRgbColor(ColorToRGB(AColor));
|
||||
avg := (c.R + c.G + c.B) div 3;
|
||||
result := rgb(avg, avg, avg);
|
||||
end;
|
||||
|
||||
class function TColorTools.ColorToRgbTriple(AColor: TColor): TRGBTriple;
|
||||
var
|
||||
c: TRgbColor;
|
||||
begin
|
||||
c := TRgbColor(ColorToRGB(AColor));
|
||||
result.rgbtRed := c.R;
|
||||
result.rgbtGreen := c.G;
|
||||
result.rgbtBlue := c.B;
|
||||
end;
|
||||
|
||||
|
||||
{ TGradientTools }
|
||||
|
||||
class procedure TGradientTools.HGradient(ACanvas: TCanvas; cStart, cEnd: TColor;
|
||||
ARect: T2DIntRect);
|
||||
begin
|
||||
ACanvas.GradientFill(ARect.ForWinAPI,cStart, cEnd, gdHorizontal);
|
||||
end;
|
||||
|
||||
{ -- old version ...
|
||||
var vert : array[0..1] of TRIVERTEX;
|
||||
gRect : GRADIENTRECT;
|
||||
Col1,Col2 : TColor;
|
||||
|
||||
begin
|
||||
Col1:=ColorToRGB(cStart);
|
||||
Col2:=ColorToRGB(cEnd);
|
||||
with vert[0] do
|
||||
begin
|
||||
x:=rect.left;
|
||||
y:=rect.top;
|
||||
Red:=GetRValue(Col1) shl 8;
|
||||
Green:=GetGValue(Col1) shl 8;
|
||||
Blue:=GetBValue(Col1) shl 8;
|
||||
Alpha:=0;
|
||||
end;
|
||||
|
||||
with vert[1] do
|
||||
begin
|
||||
x:=rect.right;
|
||||
y:=rect.bottom;
|
||||
Red:=GetRValue(Col2) shl 8;
|
||||
Green:=GetGValue(Col2) shl 8;
|
||||
Blue:=GetBValue(Col2) shl 8;
|
||||
Alpha:=0;
|
||||
end;
|
||||
|
||||
gRect.UpperLeft:=0;
|
||||
gRect.LowerRight:=1;
|
||||
GradientFill(canvas.Handle,@vert,2,@gRect,1,GRADIENT_FILL_RECT_H);
|
||||
end; }
|
||||
|
||||
class procedure TGradientTools.HGradient(ACanvas: TCanvas; cStart, cEnd: TColor;
|
||||
p1, p2: TPoint);
|
||||
begin
|
||||
HGradient(ACanvas, cStart, cEnd, rect(p1.x,p1.y,p2.x,p2.y));
|
||||
end;
|
||||
|
||||
class procedure TGradientTools.HGradient(ACanvas: TCanvas; cStart, cEnd: TColor;
|
||||
x1,y1,x2,y2: integer);
|
||||
begin
|
||||
HGradient(ACanvas, cStart, cEnd, rect(x1,y1,x2,y2));
|
||||
end;
|
||||
|
||||
class procedure TGradientTools.VGradient(ACanvas: TCanvas; cStart, cEnd: TColor;
|
||||
ARect: T2DIntRect);
|
||||
begin
|
||||
ACanvas.GradientFill(ARect.ForWinAPI, cStart, cEnd, gdVertical);
|
||||
end;
|
||||
|
||||
{ --- old version...
|
||||
class procedure TGradientTools.VGradient(canvas : TCanvas; cStart,cEnd : TColor; rect : T2DIntRect);
|
||||
|
||||
var vert : array[0..1] of TRIVERTEX;
|
||||
gRect : GRADIENTRECT;
|
||||
Col1,Col2 : TColor;
|
||||
|
||||
begin
|
||||
Col1:=ColorToRGB(cStart);
|
||||
Col2:=ColorToRGB(cEnd);
|
||||
with vert[0] do
|
||||
begin
|
||||
x:=rect.left;
|
||||
y:=rect.top;
|
||||
Red:=GetRValue(Col1) shl 8;
|
||||
Green:=GetGValue(Col1) shl 8;
|
||||
Blue:=GetBValue(Col1) shl 8;
|
||||
Alpha:=0;
|
||||
end;
|
||||
|
||||
with vert[1] do
|
||||
begin
|
||||
x:=rect.right;
|
||||
y:=rect.bottom;
|
||||
Red:=GetRValue(Col2) shl 8;
|
||||
Green:=GetGValue(Col2) shl 8;
|
||||
Blue:=GetBValue(Col2) shl 8;
|
||||
Alpha:=0;
|
||||
end;
|
||||
|
||||
gRect.UpperLeft:=0;
|
||||
gRect.LowerRight:=1;
|
||||
GradientFill(canvas.Handle,@vert,2,@gRect,1,GRADIENT_FILL_RECT_V);
|
||||
end; }
|
||||
|
||||
class procedure TGradientTools.VGradient(ACanvas: TCanvas; cStart, cEnd: TColor;
|
||||
p1, p2: TPoint);
|
||||
begin
|
||||
VGradient(ACanvas, cStart, cEnd, rect(p1.x,p1.y,p2.x,p2.y));
|
||||
end;
|
||||
|
||||
class procedure TGradientTools.VGradient(ACanvas: TCanvas; cStart, cEnd: TColor;
|
||||
x1,y1,x2,y2: integer);
|
||||
begin
|
||||
VGradient(ACanvas, cStart, cEnd, rect(x1,y1,x2,y2));
|
||||
end;
|
||||
|
||||
class procedure TGradientTools.Gradient(ACanvas: TCanvas; cStart, cEnd: TColor;
|
||||
ARect: T2DIntRect; AGradientType: TGradientType);
|
||||
begin
|
||||
if AGradientType = gtVertical then
|
||||
VGradient(ACanvas, cStart, cEnd, ARect)
|
||||
else
|
||||
HGradient(ACanvas, cStart, cEnd, ARect);
|
||||
end;
|
||||
|
||||
class procedure TGradientTools.Gradient(ACanvas: TCanvas; cStart, cEnd: TColor;
|
||||
p1, p2: TPoint; AGradientType: TGradientType);
|
||||
begin
|
||||
if AGradientType = gtVertical then
|
||||
VGradient(ACanvas, cStart, cEnd, p1, p2)
|
||||
else
|
||||
HGradient(ACanvas, cStart, cEnd, p1, p2);
|
||||
end;
|
||||
|
||||
class procedure TGradientTools.Gradient(ACanvas: TCanvas; cStart, cEnd: TColor;
|
||||
x1,y1,x2,y2: integer; AGradientType: TGradientType);
|
||||
begin
|
||||
if AGradientType = gtVertical then
|
||||
VGradient(ACanvas, cStart, cEnd, x1, y1, x2, y2)
|
||||
else
|
||||
HGradient(ACanvas, cStart, cEnd, x1, y1, x2, y2);
|
||||
end;
|
||||
|
||||
class procedure TGradientTools.HGradientLine(ACanvas: TCanvas;
|
||||
cBase, cShade: TColor; x1, x2, y: integer; ShadeMode: TGradientLineShade);
|
||||
var
|
||||
i: integer;
|
||||
begin
|
||||
if x1 = x2 then
|
||||
exit;
|
||||
if x1 > x2 then
|
||||
begin
|
||||
i := x1;
|
||||
x1 := x2;
|
||||
x2 := i;
|
||||
end;
|
||||
case ShadeMode of
|
||||
lsShadeStart:
|
||||
HGradient(ACanvas, cShade, cBase, rect(x1,y,x2,y+1));
|
||||
lsShadeEnds:
|
||||
begin
|
||||
i := (x1 + x2) div 2;
|
||||
HGradient(ACanvas, cShade, cBase, rect(x1,y,i,y+1));
|
||||
HGradient(ACanvas, cBase, cShade, rect(i,y,x2,y+1));
|
||||
end;
|
||||
lsShadeCenter:
|
||||
begin
|
||||
i := (x1 + x2) div 2;
|
||||
HGradient(ACanvas, cBase, cShade, rect(x1,y,i,y+1));
|
||||
HGradient(ACanvas, cShade, cBase, rect(i,y,x2,y+1));
|
||||
end;
|
||||
lsShadeEnd:
|
||||
HGradient(ACanvas,cBase,cShade,rect(x1,y,x2,y+1));
|
||||
end;
|
||||
end;
|
||||
|
||||
class procedure TGradientTools.VGradientLine(ACanvas: TCanvas;
|
||||
cBase, cShade: TColor; x, y1, y2: integer; ShadeMode: TGradientLineShade);
|
||||
var
|
||||
i : integer;
|
||||
begin
|
||||
if y1 = y2 then
|
||||
exit;
|
||||
if y1 > y2 then
|
||||
begin
|
||||
i := y1;
|
||||
y1 := y2;
|
||||
y2 := i;
|
||||
end;
|
||||
case ShadeMode of
|
||||
lsShadeStart:
|
||||
VGradient(ACanvas, cShade, cBase, rect(x,y1,x+1,y2));
|
||||
lsShadeEnds:
|
||||
begin
|
||||
i := (y1 + y2) div 2;
|
||||
VGradient(ACanvas, cShade, cBase, rect(x,y1,x+1,i));
|
||||
VGradient(ACanvas, cBase, cShade, rect(x,i,x+1,y2));
|
||||
end;
|
||||
lsShadeCenter:
|
||||
begin
|
||||
i := (y1 + y2) div 2;
|
||||
VGradient(ACanvas, cBase, cShade, rect(x,y1,x+1,i));
|
||||
VGradient(ACanvas, cShade, cBase, rect(x,i,x+1,y2));
|
||||
end;
|
||||
lsShadeEnd:
|
||||
VGradient(ACanvas, cBase, cShade, rect(x,y1,x+1,y2));
|
||||
end;
|
||||
end;
|
||||
|
||||
class procedure TGradientTools.HGradient3dLine(ACanvas: TCanvas; x1,x2,y: integer;
|
||||
ShadeMode: TGradientLineShade; A3dKind: TGradient3dLine = glLowered);
|
||||
begin
|
||||
if A3dKind = glRaised then
|
||||
begin
|
||||
HGradientLine(ACanvas, clBtnHighlight, clBtnFace, x1,x2,y, ShadeMode);
|
||||
HGradientLine(ACanvas, clBtnShadow, clBtnFace, x1,x2,y+1, ShadeMode);
|
||||
end else
|
||||
begin
|
||||
HGradientLine(ACanvas, clBtnShadow, clBtnFace, x1,x2,y, ShadeMode);
|
||||
HGradientLine(ACanvas, clBtnHighlight, clBtnFace, x1,x2,y+1, ShadeMode);
|
||||
end;
|
||||
end;
|
||||
|
||||
class procedure TGradientTools.VGradient3dLine(ACanvas: TCanvas; x,y1,y2: integer;
|
||||
ShadeMode: TGradientLineShade; A3dKind: TGradient3dLine = glLowered);
|
||||
begin
|
||||
if A3dKind = glLowered then
|
||||
begin
|
||||
VGradientLine(ACanvas, clBtnFace, clBtnHighlight, x,y1,y2, ShadeMode);
|
||||
VGradientLine(ACanvas, clBtnFace, clBtnShadow, x+1,y1,y2, ShadeMode);
|
||||
end else
|
||||
begin
|
||||
VGradientLine(ACanvas, clBtnFace, clBtnShadow, x,y1,y2, ShadeMode);
|
||||
VGradientLine(ACanvas, clBtnFace, clBtnHighlight, x+1,y1,y2, ShadeMode);
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
{ TTextTools }
|
||||
|
||||
class procedure TTextTools.OutlinedText(ACanvas: TCanvas; x, y: integer; const AText: string);
|
||||
var
|
||||
TmpColor: TColor;
|
||||
TmpBrushStyle: TBrushStyle;
|
||||
begin
|
||||
TmpColor := ACanvas.Font.Color;
|
||||
TmpBrushStyle := ACanvas.Brush.Style;
|
||||
|
||||
ACanvas.Brush.Style := bsClear;
|
||||
|
||||
ACanvas.Font.Color := clBlack;
|
||||
ACanvas.TextOut(x-1, y, AText);
|
||||
ACanvas.TextOut(x+1, y, AText);
|
||||
ACanvas.TextOut(x, y-1, AText);
|
||||
ACanvas.TextOut(x, y+1, AText);
|
||||
|
||||
ACanvas.Font.Color := TmpColor;
|
||||
ACanvas.TextOut(x, y, AText);
|
||||
|
||||
ACanvas.Brush.Style := TmpBrushStyle;
|
||||
end;
|
||||
|
||||
|
||||
end.
|
1712
spktoolbar/SpkMath/SpkMath.pas
Normal file
1959
spktoolbar/SpkToolbar/SpkToolbar.pas
Normal file
1611
spktoolbar/SpkToolbar/spkt_Appearance.pas
Normal file
183
spktoolbar/SpkToolbar/spkt_BaseItem.pas
Normal file
@@ -0,0 +1,183 @@
|
||||
unit spkt_BaseItem;
|
||||
|
||||
(*******************************************************************************
|
||||
* *
|
||||
* File: spkt_BaseItem.pas *
|
||||
* Description: The module containing the base class for the glass element. *
|
||||
* Copyright: (c) 2009 by Spook. *
|
||||
* License: Modified LGPL (with linking exception, like Lazarus LCL) *
|
||||
' See "license.txt" in this installation *
|
||||
* *
|
||||
*******************************************************************************)
|
||||
|
||||
{$mode delphi}
|
||||
{.$Define EnhancedRecordSupport}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Graphics, Classes, Controls,
|
||||
SpkMath, spkt_Appearance, spkt_Dispatch, spkt_Types;
|
||||
|
||||
type
|
||||
TSpkItemSize = (isLarge, isNormal);
|
||||
|
||||
TSpkItemTableBehaviour = (tbBeginsRow, tbBeginsColumn, tbContinuesRow);
|
||||
|
||||
TSpkItemGroupBehaviour = (gbSingleItem, gbBeginsGroup, gbContinuesGroup, gbEndsGroup);
|
||||
|
||||
TSpkBaseItem = class abstract(TSpkComponent)
|
||||
private
|
||||
protected
|
||||
FRect: T2DIntRect;
|
||||
FToolbarDispatch: TSpkBaseToolbarDispatch;
|
||||
FAppearance: TSpkToolbarAppearance;
|
||||
FImages: TImageList;
|
||||
FDisabledImages: TImageList;
|
||||
FLargeImages: TImageList;
|
||||
FDisabledLargeImages: TImageList;
|
||||
FImagesWidth: Integer;
|
||||
FLargeImagesWidth: Integer;
|
||||
FVisible: boolean;
|
||||
FEnabled: boolean;
|
||||
|
||||
procedure SetVisible(const Value: boolean); virtual;
|
||||
procedure SetEnabled(const Value: boolean); virtual;
|
||||
procedure SetRect(const Value: T2DIntRect); virtual;
|
||||
procedure SetImages(const Value: TImageList); virtual;
|
||||
procedure SetDisabledImages(const Value: TImageList); virtual;
|
||||
procedure SetLargeImages(const Value: TImageList); virtual;
|
||||
procedure SetDisabledLargeImages(const Value: TImageList); virtual;
|
||||
procedure SetAppearance(const Value: TSpkToolbarAppearance);
|
||||
procedure SetImagesWidth(const Value: Integer);
|
||||
procedure SetLargeImagesWidth(const Value: Integer);
|
||||
|
||||
public
|
||||
constructor Create(AOwner: TComponent); override;
|
||||
destructor Destroy; override;
|
||||
|
||||
procedure MouseLeave; virtual; abstract;
|
||||
procedure MouseDown(Button: TMouseButton; Shift: TShiftState;
|
||||
X, Y: Integer); virtual; abstract;
|
||||
procedure MouseMove(Shift: TShiftState; X, Y: Integer); virtual; abstract;
|
||||
procedure MouseUp(Button: TMouseButton; Shift: TShiftState;
|
||||
X, Y: Integer); virtual; abstract;
|
||||
|
||||
function GetWidth: integer; virtual; abstract;
|
||||
function GetTableBehaviour: TSpkItemTableBehaviour; virtual; abstract;
|
||||
function GetGroupBehaviour: TSpkItemGroupBehaviour; virtual; abstract;
|
||||
function GetSize: TSpkItemSize; virtual; abstract;
|
||||
|
||||
procedure Draw(ABuffer: TBitmap; ClipRect: T2DIntRect); virtual; abstract;
|
||||
|
||||
property ToolbarDispatch: TSpkBaseToolbarDispatch read FToolbarDispatch write FToolbarDispatch;
|
||||
property Appearance: TSpkToolbarAppearance read FAppearance write SetAppearance;
|
||||
property Images: TImageList read FImages write SetImages;
|
||||
property DisabledImages: TImageList read FDisabledImages write SetDisabledImages;
|
||||
property LargeImages: TImageList read FLargeImages write SetLargeImages;
|
||||
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;
|
||||
|
||||
published
|
||||
property Visible: boolean read FVisible write SetVisible default true;
|
||||
property Enabled: boolean read FEnabled write SetEnabled default true;
|
||||
end;
|
||||
|
||||
TSpkBaseItemClass = class of TSpkBaseItem;
|
||||
|
||||
|
||||
implementation
|
||||
|
||||
{ TSpkBaseItem }
|
||||
|
||||
constructor TSpkBaseItem.Create(AOwner: TComponent);
|
||||
begin
|
||||
inherited Create(AOwner);
|
||||
|
||||
{$IFDEF EnhancedRecordSupport}
|
||||
FRect := T2DIntRect.Create(0, 0, 0, 0);
|
||||
{$ELSE}
|
||||
FRect.Create(0, 0, 0, 0);
|
||||
{$ENDIF}
|
||||
|
||||
FToolbarDispatch := nil;
|
||||
FAppearance := nil;
|
||||
FImages := nil;
|
||||
FDisabledImages := nil;
|
||||
FLargeImages := nil;
|
||||
FDisabledLargeImages := nil;
|
||||
FVisible := true;
|
||||
FEnabled := true;
|
||||
end;
|
||||
|
||||
destructor TSpkBaseItem.Destroy;
|
||||
begin
|
||||
{ Pozosta³e operacje }
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
procedure TSpkBaseItem.SetAppearance(const Value: TSpkToolbarAppearance);
|
||||
begin
|
||||
FAppearance := Value;
|
||||
if Assigned(FToolbarDispatch) then
|
||||
FToolbarDispatch.NotifyMetricsChanged;
|
||||
end;
|
||||
|
||||
procedure TSpkBaseItem.SetDisabledImages(const Value: TImageList);
|
||||
begin
|
||||
FDisabledImages := Value;
|
||||
end;
|
||||
|
||||
procedure TSpkBaseItem.SetDisabledLargeImages(const Value: TImageList);
|
||||
begin
|
||||
FDisabledLargeImages := Value;
|
||||
end;
|
||||
|
||||
procedure TSpkBaseItem.SetEnabled(const Value: boolean);
|
||||
begin
|
||||
if Value <> FEnabled then
|
||||
begin
|
||||
FEnabled := Value;
|
||||
if FToolbarDispatch<>nil then
|
||||
FToolbarDispatch.NotifyVisualsChanged;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TSpkBaseItem.SetImages(const Value: TImageList);
|
||||
begin
|
||||
FImages := Value;
|
||||
end;
|
||||
|
||||
procedure TSpkBaseItem.SetImagesWidth(const Value: Integer);
|
||||
begin
|
||||
FImagesWidth := Value;
|
||||
end;
|
||||
|
||||
procedure TSpkBaseItem.SetLargeImages(const Value: TImageList);
|
||||
begin
|
||||
FLargeImages := Value;
|
||||
end;
|
||||
|
||||
procedure TSpkBaseItem.SetLargeImagesWidth(const Value: Integer);
|
||||
begin
|
||||
FLargeImagesWidth := Value;
|
||||
end;
|
||||
|
||||
procedure TSpkBaseItem.SetRect(const Value: T2DIntRect);
|
||||
begin
|
||||
FRect := Value;
|
||||
end;
|
||||
|
||||
procedure TSpkBaseItem.SetVisible(const Value: boolean);
|
||||
begin
|
||||
if Value <> FVisible then
|
||||
begin
|
||||
FVisible := Value;
|
||||
if FToolbarDispatch <> nil then
|
||||
FToolbarDispatch.NotifyMetricsChanged;
|
||||
end;
|
||||
end;
|
||||
|
||||
end.
|
1808
spktoolbar/SpkToolbar/spkt_Buttons.pas
Normal file
395
spktoolbar/SpkToolbar/spkt_Checkboxes.pas
Normal file
@@ -0,0 +1,395 @@
|
||||
unit spkt_Checkboxes;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Graphics, Classes, SysUtils, Controls, StdCtrls, ActnList,
|
||||
SpkMath, SpkGUITools, spkt_BaseItem, spkt_Buttons;
|
||||
|
||||
type
|
||||
TSpkCustomCheckBox = class(TSPkBaseButton)
|
||||
private
|
||||
FState: TCheckboxState; // unchecked, checked, grayed
|
||||
FHideFrameWhenIdle : boolean;
|
||||
FTableBehaviour : TSpkItemTableBehaviour;
|
||||
FGroupBehaviour : TSPkItemGroupBehaviour;
|
||||
FCheckboxStyle: TSpkCheckboxStyle;
|
||||
procedure SetTableBehaviour(const Value: TSpkItemTableBehaviour);
|
||||
protected
|
||||
procedure CalcRects; override;
|
||||
procedure ConstructRect(out BtnRect: T2DIntRect);
|
||||
function GetChecked: Boolean; override;
|
||||
function GetDefaultCaption: String; override;
|
||||
function GetDropdownPoint: T2DIntPoint; override;
|
||||
procedure SetChecked(const AValue: Boolean); override;
|
||||
procedure SetState(AValue: TCheckboxState); virtual;
|
||||
public
|
||||
constructor Create(AOwner: TComponent); override;
|
||||
procedure Draw(ABuffer: TBitmap; ClipRect: T2DIntRect); override;
|
||||
function GetGroupBehaviour : TSpkItemGroupBehaviour; override;
|
||||
function GetSize: TSpkItemSize; override;
|
||||
function GetTableBehaviour : TSpkItemTableBehaviour; override;
|
||||
function GetWidth: integer; override;
|
||||
published
|
||||
property Checked;
|
||||
property State: TCheckboxState read FState write SetState default cbUnchecked;
|
||||
property TableBehaviour: TSpkItemTableBehaviour read FTableBehaviour write SetTableBehaviour default tbContinuesRow;
|
||||
end;
|
||||
|
||||
TSpkCheckbox = class(TSpkCustomCheckbox)
|
||||
public
|
||||
constructor Create(AOwner: TComponent); override;
|
||||
end;
|
||||
|
||||
TSpkRadioButton = class(TSpkCustomCheckbox)
|
||||
protected
|
||||
function GetDefaultCaption: String; override;
|
||||
procedure SetState(AValue: TCheckboxState); override;
|
||||
procedure UncheckSiblings; override;
|
||||
public
|
||||
constructor Create(AOwner: TComponent); override;
|
||||
published
|
||||
property AllowAllUp;
|
||||
property GroupIndex;
|
||||
end;
|
||||
|
||||
|
||||
implementation
|
||||
|
||||
uses
|
||||
LCLType, LCLIntf, Math, Themes,
|
||||
SpkGraphTools, spkt_Const, spkt_Tools, spkt_Pane, spkt_Appearance;
|
||||
|
||||
|
||||
{ TSpkCustomCheckbox }
|
||||
|
||||
constructor TSpkCustomCheckbox.Create(AOwner: TComponent);
|
||||
begin
|
||||
inherited Create(AOwner);
|
||||
ButtonKind := bkToggle;
|
||||
FHideFrameWhenIdle := true;
|
||||
FTableBehaviour := tbContinuesRow;
|
||||
FGroupBehaviour := gbSingleItem;
|
||||
FCheckboxStyle := cbsCheckbox;
|
||||
FState := cbUnchecked;
|
||||
end;
|
||||
|
||||
procedure TSpkCustomCheckbox.CalcRects;
|
||||
var
|
||||
RectVector: T2DIntVector;
|
||||
begin
|
||||
ConstructRect(FButtonRect);
|
||||
{$IFDEF EnhancedRecordSupport}
|
||||
FDropdownRect := T2DIntRect.Create(0, 0, 0, 0);
|
||||
RectVector := T2DIntVector.Create(FRect.Left, FRect.Top);
|
||||
{$ELSE}
|
||||
FDropdownRect.Create(0, 0, 0, 0);
|
||||
RectVector.Create(FRect.Left, FRect.Top);
|
||||
{$ENDIF}
|
||||
FButtonRect := FButtonRect + RectVector;
|
||||
end;
|
||||
|
||||
procedure TSpkCustomCheckbox.ConstructRect(out BtnRect: T2DIntRect);
|
||||
var
|
||||
BtnWidth: integer;
|
||||
Bitmap: TBitmap;
|
||||
TextWidth: Integer;
|
||||
begin
|
||||
{$IFDEF EnhancedRecordSupport}
|
||||
BtnRect := T2DIntRect.Create(0, 0, 0, 0);
|
||||
{$ELSE}
|
||||
BtnRect.Create(0, 0, 0, 0);
|
||||
{$ENDIF}
|
||||
|
||||
if not(Assigned(FToolbarDispatch)) then
|
||||
exit;
|
||||
if not(Assigned(FAppearance)) then
|
||||
exit;
|
||||
|
||||
Bitmap := FToolbarDispatch.GetTempBitmap;
|
||||
if not Assigned(Bitmap) then
|
||||
exit;
|
||||
|
||||
Bitmap.Canvas.Font.Assign(FAppearance.Element.CaptionFont);
|
||||
TextWidth := Bitmap.Canvas.TextWidth(FCaption);
|
||||
|
||||
BtnWidth := SmallButtonPadding + SmallButtonGlyphWidth +
|
||||
SmallButtonPadding + TextWidth + SmallButtonPadding;
|
||||
BtnWidth := Max(SmallButtonMinWidth, BtnWidth);
|
||||
|
||||
if FGroupBehaviour in [gbContinuesGroup, gbEndsGroup] then
|
||||
BtnWidth := BtnWidth + SmallButtonHalfBorderWidth
|
||||
else
|
||||
BtnWidth := BtnWidth + SmallButtonBorderWidth;
|
||||
|
||||
// Prawa krawêdŸ przycisku
|
||||
if (FGroupBehaviour in [gbBeginsGroup, gbContinuesGroup]) then
|
||||
BtnWidth := BtnWidth + SmallButtonHalfBorderWidth
|
||||
else
|
||||
BtnWidth := BtnWidth + SmallButtonBorderWidth;
|
||||
|
||||
{$IFDEF EnhancedRecordSupport}
|
||||
BtnRect := T2DIntRect.Create(0, 0, BtnWidth - 1, PaneRowHeight - 1);
|
||||
{$ELSE}
|
||||
BtnRect.Create(0, 0, BtnWidth - 1, PaneRowHeight - 1);
|
||||
{$ENDIF}
|
||||
end;
|
||||
|
||||
procedure TSpkCustomCheckbox.Draw(ABuffer: TBitmap; ClipRect: T2DIntRect);
|
||||
var
|
||||
fontColor: TColor;
|
||||
x, y: Integer;
|
||||
h: Integer;
|
||||
te: TThemedElementDetails;
|
||||
cornerRadius: Integer;
|
||||
begin
|
||||
if FToolbarDispatch = nil then
|
||||
exit;
|
||||
if FAppearance = nil then
|
||||
exit;
|
||||
if (FRect.Width < 2*LargeButtonRadius) or (FRect.Height < 2*LargeButtonRadius) then
|
||||
exit;
|
||||
|
||||
case FAppearance.Element.Style of
|
||||
esRounded:
|
||||
cornerRadius := SmallButtonRadius;
|
||||
esRectangle:
|
||||
cornerRadius := 0;
|
||||
end;
|
||||
|
||||
// Border
|
||||
if (FButtonState = bsIdle) and (not(FHideFrameWhenIdle)) then
|
||||
begin
|
||||
with FAppearance.Element do
|
||||
TButtonTools.DrawButton(
|
||||
ABuffer,
|
||||
FButtonRect,
|
||||
IdleFrameColor,
|
||||
IdleInnerLightColor,
|
||||
IdleInnerDarkColor,
|
||||
IdleGradientFromColor,
|
||||
IdleGradientToColor,
|
||||
IdleGradientType,
|
||||
(FGroupBehaviour in [gbContinuesGroup, gbEndsGroup]),
|
||||
(FGroupBehaviour in [gbBeginsGroup, gbContinuesGroup]) or (FButtonKind = bkButtonDropdown),
|
||||
false,
|
||||
false,
|
||||
cornerRadius,
|
||||
ClipRect
|
||||
);
|
||||
end else
|
||||
if (FButtonState=bsBtnHottrack) then
|
||||
begin
|
||||
with FAppearance.Element do
|
||||
TButtonTools.DrawButton(
|
||||
ABuffer,
|
||||
FButtonRect,
|
||||
HotTrackFrameColor,
|
||||
HotTrackInnerLightColor,
|
||||
HotTrackInnerDarkColor,
|
||||
HotTrackGradientFromColor,
|
||||
HotTrackGradientToColor,
|
||||
HotTrackGradientType,
|
||||
(FGroupBehaviour in [gbContinuesGroup, gbEndsGroup]),
|
||||
(FGroupBehaviour in [gbBeginsGroup, gbContinuesGroup]) or (FButtonKind = bkButtonDropdown),
|
||||
false,
|
||||
false,
|
||||
cornerRadius,
|
||||
ClipRect
|
||||
);
|
||||
end else
|
||||
if (FButtonState = bsBtnPressed) then
|
||||
begin
|
||||
with FAppearance.Element do
|
||||
TButtonTools.DrawButton(
|
||||
ABuffer,
|
||||
FButtonRect,
|
||||
ActiveFrameColor,
|
||||
ActiveInnerLightColor,
|
||||
ActiveInnerDarkColor,
|
||||
ActiveGradientFromColor,
|
||||
ActiveGradientToColor,
|
||||
ActiveGradientType,
|
||||
(FGroupBehaviour in [gbContinuesGroup, gbEndsGroup]),
|
||||
(FGroupBehaviour in [gbBeginsGroup, gbContinuesGroup]) or (FButtonKind = bkButtonDropdown),
|
||||
false,
|
||||
false,
|
||||
cornerRadius,
|
||||
ClipRect
|
||||
);
|
||||
end;
|
||||
|
||||
// Checkbox
|
||||
if ThemeServices.ThemesEnabled then
|
||||
begin
|
||||
te := ThemeServices.GetElementDetails(tbCheckboxCheckedNormal);
|
||||
h := ThemeServices.GetDetailSize(te).cy;
|
||||
end else
|
||||
h := GetSystemMetrics(SM_CYMENUCHECK);
|
||||
|
||||
if (FGroupBehaviour in [gbContinuesGroup, gbEndsGroup]) then
|
||||
x := FButtonRect.Left + SmallButtonHalfBorderWidth + SmallButtonPadding
|
||||
else
|
||||
x := FButtonRect.Left + SmallButtonBorderWidth + SmallButtonPadding;
|
||||
y := FButtonRect.Top + (FButtonRect.Height - h) div 2;
|
||||
|
||||
TGUITools.DrawCheckbox(
|
||||
ABuffer.Canvas,
|
||||
x,y,
|
||||
FState,
|
||||
FButtonState,
|
||||
FCheckboxStyle,
|
||||
ClipRect
|
||||
);
|
||||
|
||||
// Text
|
||||
ABuffer.Canvas.Font.Assign(FAppearance.Element.CaptionFont);
|
||||
|
||||
case FButtonState of
|
||||
bsIdle : fontColor := FAppearance.Element.IdleCaptionColor;
|
||||
bsBtnHottrack,
|
||||
bsDropdownHottrack : fontColor := FAppearance.Element.HotTrackCaptionColor;
|
||||
bsBtnPressed,
|
||||
bsDropdownPressed : fontColor := FAppearance.ELement.ActiveCaptionColor;
|
||||
end;
|
||||
if not(FEnabled) then
|
||||
fontColor := TColorTools.ColorToGrayscale(fontColor);
|
||||
|
||||
if (FGroupBehaviour in [gbContinuesGroup, gbEndsGroup]) then
|
||||
x := FButtonRect.Left + SmallButtonHalfBorderWidth
|
||||
else
|
||||
x := FButtonRect.Left + SmallButtonBorderWidth;
|
||||
x := x + 2 * SmallButtonPadding + SmallButtonGlyphWidth;
|
||||
y := FButtonRect.Top + (FButtonRect.Height - ABuffer.Canvas.TextHeight('Wy')) div 2;
|
||||
|
||||
TGUITools.DrawText(ABuffer.Canvas, x, y, FCaption, fontColor, ClipRect);
|
||||
end;
|
||||
|
||||
function TSpkCustomCheckbox.GetChecked: Boolean;
|
||||
begin
|
||||
Result := (FState = cbChecked);
|
||||
end;
|
||||
|
||||
function TSpkCustomCheckbox.GetDefaultCaption: String;
|
||||
begin
|
||||
Result := 'Checkbox';
|
||||
end;
|
||||
|
||||
function TSpkCustomCheckbox.GetDropdownPoint: T2DIntPoint;
|
||||
begin
|
||||
{$IFDEF EnhancedRecordSupport}
|
||||
Result := T2DIntPoint.Create(0,0);
|
||||
{$ELSE}
|
||||
Result.Create(0,0);
|
||||
{$ENDIF}
|
||||
end;
|
||||
|
||||
function TSpkCustomCheckbox.GetGroupBehaviour: TSpkItemGroupBehaviour;
|
||||
begin
|
||||
Result := gbSingleitem; //FGroupBehaviour;
|
||||
end;
|
||||
|
||||
function TSpkCustomCheckbox.GetSize: TSpkItemSize;
|
||||
begin
|
||||
Result := isNormal;
|
||||
end;
|
||||
|
||||
function TSpkCustomCheckbox.GetTableBehaviour: TSpkItemTableBehaviour;
|
||||
begin
|
||||
Result := FTableBehaviour;
|
||||
end;
|
||||
|
||||
function TSpkCustomCheckbox.GetWidth: integer;
|
||||
var
|
||||
BtnRect: T2DIntRect;
|
||||
begin
|
||||
Result := -1;
|
||||
if FToolbarDispatch = nil then
|
||||
exit;
|
||||
if FAppearance = nil then
|
||||
exit;
|
||||
ConstructRect(BtnRect);
|
||||
Result := BtnRect.Right + 1;
|
||||
end;
|
||||
|
||||
procedure TSpkCustomCheckbox.SetChecked(const AValue: Boolean);
|
||||
begin
|
||||
inherited SetChecked(AValue);
|
||||
if FChecked then
|
||||
SetState(cbChecked)
|
||||
else
|
||||
SetState(cbUnchecked);
|
||||
end;
|
||||
|
||||
procedure TSpkCustomCheckbox.SetState(AValue:TCheckboxState);
|
||||
begin
|
||||
if AValue <> FState then
|
||||
begin
|
||||
FState := AValue;
|
||||
inherited SetChecked(Checked);
|
||||
if Assigned(FToolbarDispatch) then
|
||||
FToolbarDispatch.NotifyVisualsChanged;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TSpkCustomCheckbox.SetTableBehaviour(const Value: TSpkItemTableBehaviour);
|
||||
begin
|
||||
FTableBehaviour := Value;
|
||||
if Assigned(FToolbarDispatch) then
|
||||
FToolbarDispatch.NotifyMetricsChanged;
|
||||
end;
|
||||
|
||||
|
||||
{ TSpkCheckbox }
|
||||
|
||||
constructor TSpkCheckbox.Create(AOwner: TComponent);
|
||||
begin
|
||||
inherited Create(AOwner);
|
||||
FCheckboxStyle := cbsCheckbox;
|
||||
end;
|
||||
|
||||
|
||||
{ TSpkRadioButton }
|
||||
|
||||
constructor TSpkRadioButton.Create(AOwner: TComponent);
|
||||
begin
|
||||
inherited Create(AOwner);
|
||||
FCheckboxStyle := cbsRadioButton;
|
||||
end;
|
||||
|
||||
function TSpkRadioButton.GetDefaultCaption: string;
|
||||
begin
|
||||
Result := 'RadioButton';
|
||||
end;
|
||||
|
||||
procedure TSpkRadioButton.SetState(AValue: TCheckboxState);
|
||||
begin
|
||||
inherited SetState(AValue);
|
||||
if (AValue = cbChecked) then
|
||||
UncheckSiblings;
|
||||
end;
|
||||
|
||||
procedure TSpkRadioButton.UncheckSiblings;
|
||||
var
|
||||
i: Integer;
|
||||
pane: TSpkPane;
|
||||
rb: TSpkRadioButton;
|
||||
begin
|
||||
if (Parent is TSpkPane) then begin
|
||||
pane := TSpkPane(Parent);
|
||||
for i := 0 to pane.Items.Count-1 do
|
||||
if (pane.Items[i] is TSpkRadioButton) then
|
||||
begin
|
||||
rb := TSpkRadioButton(pane.Items[i]);
|
||||
if (rb <> self) and (rb.GroupIndex = GroupIndex) then begin
|
||||
rb.FChecked := false;
|
||||
rb.FState := cbUnchecked;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
end.
|
||||
|
424
spktoolbar/SpkToolbar/spkt_Const.pas
Normal file
@@ -0,0 +1,424 @@
|
||||
unit spkt_Const;
|
||||
|
||||
{$mode delphi}
|
||||
|
||||
(*******************************************************************************
|
||||
* *
|
||||
* File: spkt_Const.pas *
|
||||
* Description: Constants for calculation of toolbar geometry *
|
||||
* Copyright: (c) 2009 by Spook. *
|
||||
* License: Modified LGPL (with linking exception, like Lazarus LCL) *
|
||||
' See "license.txt" in this installation *
|
||||
* *
|
||||
*******************************************************************************)
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Graphics, LCLVersion;
|
||||
|
||||
const
|
||||
SPK_DPI_AWARE = true;
|
||||
|
||||
procedure SpkInitLayoutConsts(FromDPI: Integer; ToDPI: Integer = 0);
|
||||
function SpkScaleX(Size: Integer; FromDPI: Integer; ToDPI: Integer = 0): integer;
|
||||
function SpkScaleY(Size: Integer; FromDPI: Integer; ToDPI: Integer = 0): integer;
|
||||
|
||||
const
|
||||
// ****************
|
||||
// *** Elements ***
|
||||
// ****************
|
||||
|
||||
LARGEBUTTON_DROPDOWN_FIELD_SIZE = 29;
|
||||
LARGEBUTTON_GLYPH_MARGIN = 2;
|
||||
LARGEBUTTON_CAPTION_HMARGIN = 3;
|
||||
LARGEBUTTON_MIN_WIDTH = 24;
|
||||
LARGEBUTTON_RADIUS = 4;
|
||||
LARGEBUTTON_BORDER_SIZE = 2;
|
||||
LARGEBUTTON_CHEVRON_VMARGIN = 2;
|
||||
LARGEBUTTON_CAPTION_TOP_RAIL = 45;
|
||||
LARGEBUTTON_CAPTION_BOTTOM_RAIL = 58;
|
||||
|
||||
SMALLBUTTON_GLYPH_WIDTH = 16; //was: 20; //16;
|
||||
SMALLBUTTON_BORDER_WIDTH = 2;
|
||||
SMALLBUTTON_HALF_BORDER_WIDTH = 1;
|
||||
SMALLBUTTON_PADDING = 4; // was: 2
|
||||
SMALLBUTTON_DROPDOWN_WIDTH = 11;
|
||||
SMALLBUTTON_RADIUS = 4;
|
||||
|
||||
DROPDOWN_ARROW_WIDTH = 8;
|
||||
DROPDOWN_ARROW_HEIGHT = 8;
|
||||
|
||||
// ***********************
|
||||
// *** Tab page layout ***
|
||||
// ***********************
|
||||
|
||||
/// <summary>Maximum area height that can be used by an element</summary>
|
||||
MAX_ELEMENT_HEIGHT = 67;
|
||||
|
||||
/// <summary>Maximum row height</summary>
|
||||
PANE_ROW_HEIGHT = 22;
|
||||
|
||||
/// <summary>Single row top margin</summary>
|
||||
PANE_ONE_ROW_TOPPADDING = 22;
|
||||
/// <summary>Single row bottom margin</summary>
|
||||
PANE_ONE_ROW_BOTTOMPADDING = 23;
|
||||
|
||||
/// <summary>Space between rows in a double row layout</summary>
|
||||
PANE_TWO_ROWS_VSPACER = 7;
|
||||
/// <summary>Double row layout top margin</summary>
|
||||
PANE_TWO_ROWS_TOPPADDING = 8;
|
||||
/// <summary>Double row layout bottom margin</summary>
|
||||
PANE_TWO_ROWS_BOTTOMPADDING = 8;
|
||||
|
||||
/// <summary>Space between rows in triple row layout</summary>
|
||||
PANE_THREE_ROWS_VSPACER = 0;
|
||||
/// <summary>Triple row layout top margin</summary>
|
||||
PANE_THREE_ROWS_TOPPADDING = 0;
|
||||
/// <summary>Triple row layout bottom margin</summary>
|
||||
PANE_THREE_ROWS_BOTTOMPADDING = 1;
|
||||
|
||||
/// <summary>Pane left padding, space between left pane border and left element border</summary>
|
||||
PANE_LEFT_PADDING = 2;
|
||||
/// <summary>Pane right padding, space between right pane border and right element border</summary>
|
||||
PANE_RIGHT_PADDING = 2;
|
||||
/// <summary>Space between two columns inside the pane</summary>
|
||||
PANE_COLUMN_SPACER = 4;
|
||||
/// <summary>Space between groups on a row in pane</summary>
|
||||
PANE_GROUP_SPACER = 4;
|
||||
|
||||
|
||||
// *******************
|
||||
// *** Pane layout ***
|
||||
// *******************
|
||||
|
||||
/// <summary>Pane caption height</summary>
|
||||
PANE_CAPTION_HEIGHT = 15;
|
||||
/// <summary>Pane corner radius</summary>
|
||||
PANE_CORNER_RADIUS = 3;
|
||||
/// <summary>Pane border size.</summary>
|
||||
/// <remarks>Do not change?</remarks>
|
||||
PANE_BORDER_SIZE = 2;
|
||||
/// <summary>Half width of pane border?</summary>
|
||||
/// <remarks>Do not change?</remarks>
|
||||
PANE_BORDER_HALF_SIZE = 1;
|
||||
/// <summary>Pane caption horizontal padding</summary>
|
||||
PANE_CAPTION_HMARGIN = 6;
|
||||
|
||||
|
||||
// ************
|
||||
// *** Tabs ***
|
||||
// ************
|
||||
|
||||
/// <summary>Tab corner radius</summary>
|
||||
TAB_CORNER_RADIUS = 4;
|
||||
/// <summary>Tab page left margin</summary>
|
||||
TAB_PANE_LEFTPADDING = 2;
|
||||
/// <summary>Tab page right margin</summary>
|
||||
TAB_PANE_RIGHTPADDING = 2;
|
||||
/// <summary>Tab page top margin</summary>
|
||||
TAB_PANE_TOPPADDING = 2;
|
||||
/// <summary>Tab page bottom margin</summary>
|
||||
TAB_PANE_BOTTOMPADDING = 1;
|
||||
/// <summary>Space between panes</summary>
|
||||
TAB_PANE_HSPACING = 3;
|
||||
/// <summary>Tab border size</summary>
|
||||
TAB_BORDER_SIZE = 1;
|
||||
|
||||
|
||||
// ***************
|
||||
// *** Toolbar ***
|
||||
// ***************
|
||||
|
||||
/// <summary>Pane padding?</summary>
|
||||
TOOLBAR_BORDER_WIDTH = 1;
|
||||
TOOLBAR_CORNER_RADIUS = 3;
|
||||
/// <summary>Tab caption height</summary>
|
||||
TOOLBAR_TAB_CAPTIONS_HEIGHT = 22;
|
||||
/// <summary>Tab caption horizontal padding</summary>
|
||||
TOOLBAR_TAB_CAPTIONS_TEXT_HPADDING = 4;
|
||||
/// <summary>Min tab caption width</summary>
|
||||
TOOLBAR_MIN_TAB_CAPTION_WIDTH = 32;
|
||||
|
||||
var
|
||||
// ****************
|
||||
// *** Elements ***
|
||||
// ****************
|
||||
LargeButtonDropdownFieldSize: Integer;
|
||||
LargeButtonGlyphMargin: Integer;
|
||||
LargeButtonCaptionHMargin: Integer;
|
||||
LargeButtonMinWidth: Integer;
|
||||
LargeButtonRadius: Integer;
|
||||
LargeButtonBorderSize: Integer;
|
||||
LargeButtonChevronVMargin: Integer;
|
||||
LargeButtonCaptionTopRail: Integer;
|
||||
LargeButtonCaptionButtomRail: Integer;
|
||||
|
||||
SmallButtonGlyphWidth: Integer;
|
||||
SmallButtonBorderWidth: Integer;
|
||||
SmallButtonHalfBorderWidth: Integer;
|
||||
SmallButtonPadding: Integer;
|
||||
SmallButtonDropdownWidth: Integer;
|
||||
SmallButtonRadius: Integer;
|
||||
SmallButtonMinWidth: Integer;
|
||||
|
||||
DropdownArrowWidth: Integer;
|
||||
DropdownArrowHeight: Integer;
|
||||
|
||||
|
||||
// ***********************
|
||||
// *** Tab page layout ***
|
||||
// ***********************
|
||||
|
||||
/// <summary>Maximum area height that can be used by an element</summary>
|
||||
MaxElementHeight: Integer;
|
||||
|
||||
/// <summary>Maximum row height</summary>
|
||||
PaneRowHeight: Integer;
|
||||
PaneFullRowHeight: Integer;
|
||||
|
||||
/// <summary>Single row top margin</summary>
|
||||
PaneOneRowTopPadding: Integer;
|
||||
/// <summary>Single row bottom margin</summary>
|
||||
PaneOneRowBottomPadding: Integer;
|
||||
|
||||
/// <summary>Space between rows in a double row layout</summary>
|
||||
PaneTwoRowsVSpacer: Integer;
|
||||
/// <summary>Double row layout top margin</summary>
|
||||
PaneTwoRowsTopPadding: Integer;
|
||||
/// <summary>Double row layout bottom margin</summary>
|
||||
PaneTwoRowsBottomPadding: Integer;
|
||||
|
||||
/// <summary>Space between rows in triple row layout</summary>
|
||||
PaneThreeRowsVSpacer: Integer;
|
||||
/// <summary>Triple row layout top margin</summary>
|
||||
PaneThreeRowsTopPadding: Integer;
|
||||
/// <summary>Triple row layout bottom margin</summary>
|
||||
PaneThreeRowsBottomPadding: Integer;
|
||||
|
||||
PaneFullRowTopPadding: Integer;
|
||||
PaneFullRowBottomPadding: Integer;
|
||||
|
||||
/// <summary>Pane left padding, space between left pane border and left element border</summary>
|
||||
PaneLeftPadding: Integer;
|
||||
/// <summary>Pane right padding, space between right pane border and right element border</summary>
|
||||
PaneRightPadding: Integer;
|
||||
/// <summary>Space between two columns inside the pane</summary>
|
||||
PaneColumnSpacer: Integer;
|
||||
/// <summary>Space between groups on a row in pane</summary>
|
||||
PaneGroupSpacer: Integer;
|
||||
|
||||
|
||||
// *******************
|
||||
// *** Pane layout ***
|
||||
// *******************
|
||||
|
||||
/// <summary>Pane caption height</summary>
|
||||
PaneCaptionHeight: Integer;
|
||||
/// <summary>Pane corner radius</summary>
|
||||
PaneCornerRadius: Integer;
|
||||
/// <summary>Pane border size</summary>
|
||||
/// <remarks>Do not change?</remarks>
|
||||
PaneBorderSize: Integer;
|
||||
/// <summary>Half width of pane border?</summary>
|
||||
/// <remarks>Do not change?</remarks>
|
||||
PaneBorderHalfSize: Integer;
|
||||
/// <summary>Height of pane</summary>
|
||||
PaneHeight: Integer;
|
||||
/// <summary>Pane caption horizontal padding</summary>
|
||||
PaneCaptionHMargin: Integer;
|
||||
|
||||
|
||||
// ************
|
||||
// *** Tabs ***
|
||||
// ************
|
||||
|
||||
/// <summary>Tab corner radius</summary>
|
||||
TabCornerRadius: Integer;
|
||||
/// <summary>Tab page left margin</summary>
|
||||
TabPaneLeftPadding: Integer;
|
||||
/// <summary>Tab page right margin/summary>
|
||||
TabPaneRightPadding: Integer;
|
||||
/// <summary>Tab page top margin</summary>
|
||||
TabPaneTopPadding: Integer;
|
||||
/// <summary>Tab page bottom margin</summary>
|
||||
TabPaneBottomPadding: Integer;
|
||||
/// <summary>Space between panes</summary>
|
||||
TabPaneHSpacing: Integer;
|
||||
/// <summary>Tab border size</summary>
|
||||
TabBorderSize: Integer;
|
||||
/// <summary>Tab height</summary>
|
||||
TabHeight: Integer;
|
||||
|
||||
|
||||
// ***************
|
||||
// *** Toolbar ***
|
||||
// ***************
|
||||
|
||||
/// <summary>Pane padding?</summary>
|
||||
ToolbarBorderWidth: Integer;
|
||||
ToolbarCornerRadius: Integer;
|
||||
/// <summary>Tab caption height</summary>
|
||||
ToolbarTabCaptionsHeight: Integer;
|
||||
/// <summary>Tab caption horizontal padding</summary>
|
||||
ToolbarTabCaptionsTextHPadding: Integer;
|
||||
ToolbarMinTabCaptionWidth: Integer;
|
||||
/// <summary>Toolbar total height</summary>
|
||||
ToolbarHeight: Integer;
|
||||
|
||||
|
||||
implementation
|
||||
|
||||
uses
|
||||
LCLType;
|
||||
|
||||
procedure SpkInitLayoutConsts(FromDPI: Integer; ToDPI: Integer = 0);
|
||||
begin
|
||||
if not SPK_DPI_AWARE then
|
||||
ToDPI := FromDPI;
|
||||
|
||||
{$IfDef Darwin}
|
||||
ToDPI := FromDPI; //macOS raster scales by itself
|
||||
{$EndIf}
|
||||
|
||||
LargeButtonDropdownFieldSize := SpkScaleX(LARGEBUTTON_DROPDOWN_FIELD_SIZE, FromDPI, ToDPI);
|
||||
LargeButtonGlyphMargin := SpkScaleX(LARGEBUTTON_GLYPH_MARGIN, FromDPI, ToDPI);
|
||||
LargeButtonCaptionHMargin := SpkScaleX(LARGEBUTTON_CAPTION_HMARGIN, FromDPI, ToDPI);
|
||||
LargeButtonMinWidth := SpkScaleX(LARGEBUTTON_MIN_WIDTH, FromDPI, ToDPI);
|
||||
LargeButtonRadius := LARGEBUTTON_RADIUS;
|
||||
LargeButtonBorderSize := SpkScaleX(LARGEBUTTON_BORDER_SIZE, FromDPI, ToDPI);
|
||||
LargeButtonChevronVMargin := SpkScaleY(LARGEBUTTON_CHEVRON_VMARGIN, FromDPI, ToDPI);
|
||||
LargeButtonCaptionTopRail := SpkScaleY(LARGEBUTTON_CAPTION_TOP_RAIL, FromDPI, ToDPI);
|
||||
LargeButtonCaptionButtomRail := SpkScaleY(LARGEBUTTON_CAPTION_BOTTOM_RAIL, FromDPI, ToDPI);
|
||||
|
||||
SmallButtonGlyphWidth := SpkScaleX(SMALLBUTTON_GLYPH_WIDTH, FromDPI, ToDPI);
|
||||
SmallButtonBorderWidth := SpkScaleX(SMALLBUTTON_BORDER_WIDTH, FromDPI, ToDPI);
|
||||
SmallButtonHalfBorderWidth := SpkScaleX(SMALLBUTTON_HALF_BORDER_WIDTH, FromDPI, ToDPI);
|
||||
SmallButtonPadding := SpkScaleX(SMALLBUTTON_PADDING, FromDPI, ToDPI);
|
||||
SmallButtonDropdownWidth := SpkScaleX(SMALLBUTTON_DROPDOWN_WIDTH, FromDPI, ToDPI);
|
||||
SmallButtonRadius := SMALLBUTTON_RADIUS;
|
||||
SmallButtonMinWidth := 2 * SmallButtonPadding + SmallButtonGlyphWidth;
|
||||
|
||||
DropdownArrowWidth := SpkScaleX(DROPDOWN_ARROW_WIDTH, FromDPI, ToDPI);
|
||||
DropdownArrowHeight := SpkScaleY(DROPDOWN_ARROW_HEIGHT, FromDPI, ToDPI);
|
||||
|
||||
MaxElementHeight := SpkScaleY(MAX_ELEMENT_HEIGHT, FromDPI, ToDPI);
|
||||
PaneRowHeight := SpkScaleY(PANE_ROW_HEIGHT, FromDPI, ToDPI);
|
||||
PaneFullRowHeight := 3 * PaneRowHeight;
|
||||
PaneOneRowTopPadding := SpkScaleY(PANE_ONE_ROW_TOPPADDING, FromDPI, ToDPI);
|
||||
PaneOneRowBottomPadding := SpkScaleY(PANE_ONE_ROW_BOTTOMPADDING, FromDPI, ToDPI);
|
||||
PaneTwoRowsVSpacer := SpkScaleY(PANE_TWO_ROWS_VSPACER, FromDPI, ToDPI);
|
||||
PaneTwoRowsTopPadding := SpkScaleY(PANE_TWO_ROWS_TOPPADDING, FromDPI, ToDPI);
|
||||
PaneTwoRowsBottomPadding := SpkScaleY(PANE_TWO_ROWS_BOTTOMPADDING, FromDPI, ToDPI);
|
||||
PaneThreeRowsVSpacer := SpkScaleY(PANE_THREE_ROWS_VSPACER, FromDPI, ToDPI);
|
||||
PaneThreeRowsTopPadding := SpkScaleY(PANE_THREE_ROWS_TOPPADDING, FromDPI, ToDPI);
|
||||
PaneThreeRowsBottomPadding := SpkScaleY(PANE_THREE_ROWS_BOTTOMPADDING, FromDPI, ToDPI);
|
||||
PaneFullRowTopPadding := PaneThreeRowsTopPadding;
|
||||
PaneFullRowBottomPadding := PaneThreeRowsBottomPadding;
|
||||
PaneLeftPadding := SpkScaleX(PANE_LEFT_PADDING, FromDPI, ToDPI);
|
||||
PaneRightPadding := SpkScaleX(PANE_RIGHT_PADDING, FromDPI, ToDPI);
|
||||
PaneColumnSpacer := SpkScaleX(PANE_COLUMN_SPACER, FromDPI, ToDPI);
|
||||
PaneGroupSpacer := SpkScaleX(PANE_GROUP_SPACER, FromDPI, ToDPI);
|
||||
|
||||
PaneCaptionHeight := SpkScaleY(PANE_CAPTION_HEIGHT, FromDPI, ToDPI);
|
||||
PaneCornerRadius := PANE_CORNER_RADIUS;
|
||||
PaneBorderSize := SpkScaleX(PANE_BORDER_SIZE, FromDPI, ToDPI);
|
||||
PaneBorderHalfSize := SpkScaleX(PANE_BORDER_HALF_SIZE, FromDPI, ToDPI);
|
||||
PaneHeight := MaxElementHeight + PaneCaptionHeight + 2 * PaneBorderSize;
|
||||
PaneCaptionHMargin := SpkScaleX(PANE_CAPTION_HMARGIN, FromDPI, ToDPI);
|
||||
|
||||
TabCornerRadius := TAB_CORNER_RADIUS;
|
||||
TabPaneLeftPadding := SpkScaleX(TAB_PANE_LEFTPADDING, FromDPI, ToDPI);
|
||||
TabPaneRightPadding := SpkScaleX(TAB_PANE_RIGHTPADDING, FromDPI, ToDPI);
|
||||
TabPaneTopPadding := SpkScaleY(TAB_PANE_TOPPADDING, FromDPI, ToDPI);
|
||||
TabPaneBottomPadding := SpkScaleY(TAB_PANE_BOTTOMPADDING, FromDPI, ToDPI);
|
||||
TabPaneHSpacing := SpkScaleX(TAB_PANE_HSPACING, FromDPI, ToDPI);
|
||||
TabBorderSize := SpkScaleX(TAB_BORDER_SIZE, FromDPI, ToDPI);
|
||||
TabHeight := PaneHeight + TabPaneTopPadding + TabPaneBottomPadding + TabBorderSize;
|
||||
|
||||
ToolbarBorderWidth := SpkScaleX(TOOLBAR_BORDER_WIDTH, FromDPI, ToDPI);
|
||||
ToolbarCornerRadius := TOOLBAR_CORNER_RADIUS;
|
||||
ToolbarTabCaptionsHeight := SpkScaleY(TOOLBAR_TAB_CAPTIONS_HEIGHT, FromDPI, ToDPI);
|
||||
ToolbarTabCaptionsTextHPadding := SpkScaleX(TOOLBAR_TAB_CAPTIONS_TEXT_HPADDING, FromDPI, ToDPI);
|
||||
ToolbarMinTabCaptionWidth := SpkScaleX(TOOLBAR_MIN_TAB_CAPTION_WIDTH, FromDPI, ToDPI);
|
||||
ToolbarHeight := ToolbarTabCaptionsHeight + TabHeight;
|
||||
|
||||
// scaling radius if not square
|
||||
if LargeButtonRadius > 1 then
|
||||
LargeButtonRadius := SpkScaleX(LargeButtonRadius, FromDPI, ToDPI);
|
||||
|
||||
if SmallButtonRadius > 1 then
|
||||
SmallButtonRadius := SpkScaleX(SmallButtonRadius, FromDPI, ToDPI);
|
||||
|
||||
if PaneCornerRadius > 1 then
|
||||
PaneCornerRadius := SpkScaleX(PaneCornerRadius, FromDPI, ToDPI);
|
||||
|
||||
if TabCornerRadius > 1 then
|
||||
TabCornerRadius := SpkScaleX(TabCornerRadius, FromDPI, ToDPI);
|
||||
|
||||
if ToolbarCornerRadius > 1 then
|
||||
ToolbarCornerRadius := SpkScaleX(ToolbarCornerRadius, FromDPI, ToDPI);
|
||||
end;
|
||||
|
||||
function SpkScaleX(Size: Integer; FromDPI: Integer; ToDPI: Integer): integer;
|
||||
begin
|
||||
if ToDPI = 0 then
|
||||
ToDPI := ScreenInfo.PixelsPerInchX;
|
||||
|
||||
if (not SPK_DPI_AWARE) or (ToDPI = FromDPI) then
|
||||
Result := Size
|
||||
else
|
||||
begin
|
||||
if (ToDPI/FromDPI <= 1.5) and (Size = 1) then
|
||||
Result := 1 //maintaining 1px on 150% scale for crispness
|
||||
else
|
||||
Result := MulDiv(Size, ToDPI, FromDPI);
|
||||
end;
|
||||
|
||||
end;
|
||||
|
||||
function SpkScaleY(Size: Integer; FromDPI: Integer; ToDPI: Integer): integer;
|
||||
begin
|
||||
if ToDPI = 0 then
|
||||
ToDPI := ScreenInfo.PixelsPerInchY;
|
||||
|
||||
if (not SPK_DPI_AWARE) or (ToDPI = FromDPI) then
|
||||
Result := Size
|
||||
else
|
||||
begin
|
||||
if (ToDPI/FromDPI <= 1.5) and (Size = 1) then
|
||||
Result := 1 //maintaining 1px on 150% scale for crispness
|
||||
else
|
||||
Result := MulDiv(Size, ToDPI, FromDPI);
|
||||
end;
|
||||
|
||||
end;
|
||||
|
||||
|
||||
initialization
|
||||
|
||||
{$IFDEF DEBUG}
|
||||
// Sprawdzanie poprawnoœci
|
||||
|
||||
// £uk du¿ego przycisku
|
||||
Assert(LARGEBUTTON_RADIUS * 2 <= LARGEBUTTON_DROPDOWN_FIELD_SIZE);
|
||||
|
||||
// Tafla, wersja z jednym wierszem
|
||||
Assert(PANE_ROW_HEIGHT +
|
||||
PANE_ONE_ROW_TOPPADDING +
|
||||
PANE_ONE_ROW_BOTTOMPADDING <= MAX_ELEMENT_HEIGHT);
|
||||
|
||||
// Tafla, wersja z dwoma wierszami
|
||||
Assert(2*PANE_ROW_HEIGHT +
|
||||
PANE_TWO_ROWS_TOPPADDING +
|
||||
PANE_TWO_ROWS_VSPACER +
|
||||
PANE_TWO_ROWS_BOTTOMPADDING <= MAX_ELEMENT_HEIGHT);
|
||||
|
||||
// Tafla, wersja z trzema wierszami
|
||||
Assert(3*PANE_ROW_HEIGHT +
|
||||
PANE_THREE_ROWS_TOPPADDING +
|
||||
2*PANE_THREE_ROWS_VSPACER +
|
||||
PANE_THREE_ROWS_BOTTOMPADDING <= MAX_ELEMENT_HEIGHT);
|
||||
{$ENDIF}
|
||||
|
||||
end.
|
45
spktoolbar/SpkToolbar/spkt_Dispatch.pas
Normal file
@@ -0,0 +1,45 @@
|
||||
unit spkt_Dispatch;
|
||||
|
||||
{$mode delphi}
|
||||
|
||||
(*******************************************************************************
|
||||
* *
|
||||
* File: spkt_Dispatch.pas *
|
||||
* Description: Basic classes of intermediary dispatchers between elements *
|
||||
* of the toolbar. *
|
||||
* Copyright: (c) 2009 by Spook. *
|
||||
* License: Modified LGPL (with linking exception, like Lazarus LCL) *
|
||||
' See "license.txt" in this installation *
|
||||
* *
|
||||
*******************************************************************************)
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, Controls, Graphics,
|
||||
SpkMath;
|
||||
|
||||
type
|
||||
TSpkBaseDispatch = class abstract(TObject)
|
||||
private
|
||||
protected
|
||||
public
|
||||
end;
|
||||
|
||||
TSpkBaseAppearanceDispatch = class abstract(TSpkBaseDispatch)
|
||||
public
|
||||
procedure NotifyAppearanceChanged; virtual; abstract;
|
||||
end;
|
||||
|
||||
TSpkBaseToolbarDispatch = class abstract(TSpkBaseAppearanceDispatch)
|
||||
public
|
||||
procedure NotifyItemsChanged; virtual; abstract;
|
||||
procedure NotifyMetricsChanged; virtual; abstract;
|
||||
procedure NotifyVisualsChanged; virtual; abstract;
|
||||
function GetTempBitmap: TBitmap; virtual; abstract;
|
||||
function ClientToScreen(Point: T2DIntPoint): T2DIntPoint; virtual; abstract;
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
end.
|
28
spktoolbar/SpkToolbar/spkt_Exceptions.pas
Normal file
@@ -0,0 +1,28 @@
|
||||
unit spkt_Exceptions;
|
||||
|
||||
{$mode delphi}
|
||||
|
||||
(*******************************************************************************
|
||||
* *
|
||||
* File: spkt_Exceptions.pas *
|
||||
* Description: Exception classes of the toolbar *
|
||||
* Copyright: (c) 2009 by Spook. *
|
||||
* License: Modified LGPL (with linking exception, like Lazarus LCL) *
|
||||
' See "license.txt" in this installation *
|
||||
* *
|
||||
*******************************************************************************)
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
SysUtils;
|
||||
|
||||
type
|
||||
InternalException = class(Exception);
|
||||
AssignException = class(Exception);
|
||||
RuntimeException = class(Exception);
|
||||
ListException = class(Exception);
|
||||
|
||||
implementation
|
||||
|
||||
end.
|
218
spktoolbar/SpkToolbar/spkt_Items.pas
Normal file
@@ -0,0 +1,218 @@
|
||||
unit spkt_Items;
|
||||
|
||||
{$mode delphi}
|
||||
{.$Define EnhancedRecordSupport}
|
||||
|
||||
(*******************************************************************************
|
||||
* *
|
||||
* File: spkt_Items.pas *
|
||||
* Description: The module contains the class of panel elements collection. *
|
||||
* Copyright: (c) 2009 by Spook. *
|
||||
* License: Modified LGPL (with linking exception, like Lazarus LCL) *
|
||||
' See "license.txt" in this installation *
|
||||
* *
|
||||
*******************************************************************************)
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, Controls, SysUtils, Dialogs,
|
||||
spkt_Appearance, spkt_Dispatch, spkt_BaseItem, spkt_Types,
|
||||
spkt_Buttons, spkt_Checkboxes;
|
||||
|
||||
type
|
||||
TSpkItems = class(TSpkCollection)
|
||||
private
|
||||
FToolbarDispatch: TSpkBaseToolbarDispatch;
|
||||
FAppearance: TSpkToolbarAppearance;
|
||||
FImages: TImageList;
|
||||
FDisabledImages: TImageList;
|
||||
FLargeImages: TImageList;
|
||||
FDisabledLargeImages: TImageList;
|
||||
FImagesWidth: Integer;
|
||||
FLargeImagesWidth: Integer;
|
||||
|
||||
// *** Getters and setters ***
|
||||
procedure SetToolbarDispatch(const Value: TSpkBaseToolbarDispatch);
|
||||
function GetItems(AIndex: integer): TSpkBaseItem; reintroduce;
|
||||
procedure SetAppearance(const Value: TSpkToolbarAppearance);
|
||||
procedure SetImages(const Value: TImageList);
|
||||
procedure SetDisabledImages(const Value: TImageList);
|
||||
procedure SetLargeImages(const Value: TImageList);
|
||||
procedure SetDisabledLargeImages(const Value: TImageList);
|
||||
procedure SetImagesWidth(const Value: Integer);
|
||||
procedure SetLargeImagesWidth(const Value: Integer);
|
||||
|
||||
public
|
||||
function AddLargeButton: TSpkLargeButton;
|
||||
function AddSmallButton: TSpkSmallButton;
|
||||
function AddCheckbox: TSpkCheckbox;
|
||||
function AddRadioButton: TSpkRadioButton;
|
||||
|
||||
// *** Reaction to changes in the list ***
|
||||
procedure Notify(Item: TComponent; Operation: TOperation); override;
|
||||
procedure Update; override;
|
||||
|
||||
property Items[index: integer]: TSpkBaseItem read GetItems; default;
|
||||
property ToolbarDispatch: TSpkBaseToolbarDispatch read FToolbarDispatch write SetToolbarDispatch;
|
||||
property Appearance: TSpkToolbarAppearance read FAppearance write SetAppearance;
|
||||
property Images: TImageList read FImages write SetImages;
|
||||
property DisabledImages: TImageList read FDisabledImages write SetDisabledImages;
|
||||
property LargeImages: TImageList read FLargeImages write SetLargeImages;
|
||||
property DisabledLargeImages: TImageList read FDisabledLargeImages write SetDisabledLargeImages;
|
||||
property ImagesWidth: Integer read FImagesWidth write SetImagesWidth;
|
||||
property LargeImagesWidth: Integer read FLargeImagesWidth write SetLargeImagesWidth;
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
{ TSpkItems }
|
||||
|
||||
function TSpkItems.AddLargeButton: TSpkLargeButton;
|
||||
begin
|
||||
Result := TSpkLargeButton.Create(FRootComponent);
|
||||
Result.Parent := FRootComponent;
|
||||
AddItem(Result);
|
||||
end;
|
||||
|
||||
function TSpkItems.AddSmallButton: TSpkSmallButton;
|
||||
begin
|
||||
Result := TSpkSmallButton.Create(FRootComponent);
|
||||
Result.Parent := FRootComponent;
|
||||
AddItem(Result);
|
||||
end;
|
||||
|
||||
function TSpkItems.AddCheckbox: TSpkCheckbox;
|
||||
begin
|
||||
Result := TSpkCheckbox.Create(FRootComponent);
|
||||
Result.Parent := FRootComponent;
|
||||
AddItem(Result);
|
||||
end;
|
||||
|
||||
function TSpkItems.AddRadioButton: TSpkRadioButton;
|
||||
begin
|
||||
Result := TSpkRadioButton.Create(FRootComponent);
|
||||
Result.Parent := FRootComponent;
|
||||
AddItem(Result);
|
||||
end;
|
||||
|
||||
function TSpkItems.GetItems(AIndex: integer): TSpkBaseItem;
|
||||
begin
|
||||
Result := TSpkBaseItem(inherited Items[AIndex]);
|
||||
end;
|
||||
|
||||
procedure TSpkItems.Notify(Item: TComponent; Operation: TOperation);
|
||||
begin
|
||||
inherited Notify(Item, Operation);
|
||||
|
||||
case Operation of
|
||||
opInsert:
|
||||
begin
|
||||
// Setting the dispatcher to nil will cause that during the ownership
|
||||
// assignment, the Notify method will not be called
|
||||
TSpkBaseItem(Item).ToolbarDispatch := nil;
|
||||
TSpkBaseItem(Item).Appearance := FAppearance;
|
||||
TSpkBaseItem(Item).Images := FImages;
|
||||
TSpkBaseItem(Item).DisabledImages := FDisabledImages;
|
||||
TSpkBaseItem(Item).LargeImages := FLargeImages;
|
||||
TSpkBaseItem(Item).DisabledLargeImages := FDisabledLargeImages;
|
||||
TSpkBaseItem(Item).ImagesWidth := FImagesWidth;
|
||||
TSpkBaseItem(Item).LargeImagesWidth := FLargeImagesWidth;
|
||||
TSpkBaseItem(Item).ToolbarDispatch := FToolbarDispatch;
|
||||
end;
|
||||
|
||||
opRemove:
|
||||
if not (csDestroying in Item.ComponentState) then
|
||||
begin
|
||||
TSpkBaseItem(Item).ToolbarDispatch := nil;
|
||||
TSpkBaseItem(Item).Appearance := nil;
|
||||
TSpkBaseItem(Item).Images := nil;
|
||||
TSpkBaseItem(Item).DisabledImages := nil;
|
||||
TSpkBaseItem(Item).LargeImages := nil;
|
||||
TSpkBaseItem(Item).DisabledLargeImages := nil;
|
||||
// TSpkBaseitem(Item).ImagesWidth := 0;
|
||||
// TSpkBaseItem(Item).LargeImagesWidth := 0;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TSpkItems.SetAppearance(const Value: TSpkToolbarAppearance);
|
||||
var
|
||||
i: Integer;
|
||||
begin
|
||||
FAppearance := Value;
|
||||
for i := 0 to Count - 1 do
|
||||
Items[i].Appearance := Value;
|
||||
end;
|
||||
|
||||
procedure TSpkItems.SetDisabledImages(const Value: TImageList);
|
||||
var
|
||||
i: Integer;
|
||||
begin
|
||||
FDisabledImages := Value;
|
||||
for i := 0 to Count - 1 do
|
||||
Items[i].DisabledImages := Value;
|
||||
end;
|
||||
|
||||
procedure TSpkItems.SetDisabledLargeImages(const Value: TImageList);
|
||||
var
|
||||
i: Integer;
|
||||
begin
|
||||
FDisabledLargeImages := Value;
|
||||
for i := 0 to Count - 1 do
|
||||
Items[i].DisabledLargeImages := Value;
|
||||
end;
|
||||
|
||||
procedure TSpkItems.SetImages(const Value: TImageList);
|
||||
var
|
||||
i: Integer;
|
||||
begin
|
||||
FImages := Value;
|
||||
for i := 0 to Count - 1 do
|
||||
Items[i].Images := Value;
|
||||
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);
|
||||
var
|
||||
i: Integer;
|
||||
begin
|
||||
FLargeImages := Value;
|
||||
for i := 0 to Count - 1 do
|
||||
Items[i].LargeImages := Value;
|
||||
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);
|
||||
var
|
||||
i : integer;
|
||||
begin
|
||||
FToolbarDispatch := Value;
|
||||
for i := 0 to Count - 1 do
|
||||
Items[i].ToolbarDispatch := Value;
|
||||
end;
|
||||
|
||||
procedure TSpkItems.Update;
|
||||
begin
|
||||
inherited Update;
|
||||
if Assigned(FToolbarDispatch) then
|
||||
FToolbarDispatch.NotifyItemsChanged;
|
||||
end;
|
||||
|
||||
end.
|
1155
spktoolbar/SpkToolbar/spkt_Pane.pas
Normal file
770
spktoolbar/SpkToolbar/spkt_Tab.pas
Normal file
@@ -0,0 +1,770 @@
|
||||
unit spkt_Tab;
|
||||
|
||||
{$mode delphi}
|
||||
{.$Define EnhancedRecordSupport}
|
||||
|
||||
(*******************************************************************************
|
||||
* *
|
||||
* File: spkt_Tab.pas *
|
||||
* Description: Toolbar component tab *
|
||||
* Copyright: (c) 2009 by Spook. *
|
||||
* License: Modified LGPL (with linking exception, like Lazarus LCL) *
|
||||
' See "license.txt" in this installation *
|
||||
* *
|
||||
*******************************************************************************)
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Graphics, Controls, Classes, SysUtils,
|
||||
SpkMath,
|
||||
spkt_Appearance, spkt_Const, spkt_Dispatch, spkt_Exceptions,
|
||||
spkt_Pane, spkt_Types;
|
||||
|
||||
type
|
||||
TSpkTab = class;
|
||||
|
||||
TSpkMouseTabElementType = (etNone, etTabArea, etPane);
|
||||
|
||||
TSpkMouseTabElement = record
|
||||
ElementType: TSpkMouseTabElementType;
|
||||
ElementIndex: integer;
|
||||
end;
|
||||
|
||||
TSpkTabAppearanceDispatch = class(TSpkBaseAppearanceDispatch)
|
||||
private
|
||||
FTab: TSpkTab;
|
||||
public
|
||||
// *** Constructor ***
|
||||
constructor Create(ATab: TSpkTab);
|
||||
|
||||
// *** Implementation of methods inherited from TSpkBaseTabDispatch ***
|
||||
procedure NotifyAppearanceChanged; override;
|
||||
end;
|
||||
|
||||
TSpkTab = class(TSpkComponent)
|
||||
private
|
||||
FAppearanceDispatch: TSpkTabAppearanceDispatch;
|
||||
FAppearance: TSpkToolbarAppearance;
|
||||
FMouseHoverElement: TSpkMouseTabElement;
|
||||
FMouseActiveElement: TSpkMouseTabElement;
|
||||
FOnClick: TNotifyEvent;
|
||||
|
||||
protected
|
||||
FToolbarDispatch: TSpkBaseToolbarDispatch;
|
||||
FCaption: string;
|
||||
FVisible: boolean;
|
||||
FOverrideAppearance: boolean;
|
||||
FCustomAppearance: TSpkToolbarAppearance;
|
||||
FPanes: TSpkPanes;
|
||||
FRect: T2DIntRect;
|
||||
FImages: TImageList;
|
||||
FDisabledImages: TImageList;
|
||||
FLargeImages: TImageList;
|
||||
FDisabledLargeImages: TImageList;
|
||||
FImagesWidth: Integer;
|
||||
FLargeImagesWidth: Integer;
|
||||
|
||||
// *** Sets the appropriate appearance tiles ***
|
||||
procedure SetPaneAppearance; inline;
|
||||
|
||||
// *** Sheet search ***
|
||||
function FindPaneAt(x, y: integer): integer;
|
||||
|
||||
// *** Designtime and LFM support ***
|
||||
procedure GetChildren(Proc: TGetChildProc; Root: TComponent); override;
|
||||
procedure DefineProperties(Filer: TFiler); override;
|
||||
procedure Loaded; override;
|
||||
|
||||
// *** Getters and setters ***
|
||||
procedure SetCaption(const Value: string);
|
||||
procedure SetCustomAppearance(const Value: TSpkToolbarAppearance);
|
||||
procedure SetOverrideAppearance(const Value: boolean);
|
||||
procedure SetVisible(const Value: boolean);
|
||||
procedure SetAppearance(const Value: TSpkToolbarAppearance);
|
||||
procedure SetImages(const Value: TImageList);
|
||||
procedure SetDisabledImages(const Value: TImageList);
|
||||
procedure SetLargeImages(const Value: TImageList);
|
||||
procedure SetDisabledLargeImages(const Value: TImageList);
|
||||
procedure SetImagesWidth(const Value: Integer);
|
||||
procedure SetLargeImagesWidth(const Value: Integer);
|
||||
procedure SetRect(ARect: T2DIntRect);
|
||||
procedure SetToolbarDispatch(const Value: TSpkBaseToolbarDispatch);
|
||||
|
||||
public
|
||||
// *** Constructor, destructor ***
|
||||
constructor Create(AOwner: TComponent); override;
|
||||
destructor Destroy; override;
|
||||
|
||||
// *** Geometry, sheet service, drawing ***
|
||||
function AtLeastOnePaneVisible: boolean;
|
||||
procedure Draw(ABuffer: TBitmap; AClipRect: T2DIntRect);
|
||||
|
||||
// *** Mouse support ***
|
||||
procedure MouseLeave;
|
||||
procedure MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
|
||||
procedure MouseMove(Shift: TShiftState; X, Y: Integer);
|
||||
procedure MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
|
||||
|
||||
// *** Dispatcher event handling ***
|
||||
procedure NotifyAppearanceChanged;
|
||||
|
||||
// *** Support for elements ***
|
||||
procedure FreeingPane(APane: TSpkPane);
|
||||
|
||||
procedure ExecOnClick;
|
||||
|
||||
property ToolbarDispatch: TSpkBaseToolbarDispatch read FToolbarDispatch write SetToolbarDispatch;
|
||||
property Appearance: TSpkToolbarAppearance read FAppearance write SetAppearance;
|
||||
property Panes: TSpkPanes read FPanes;
|
||||
property Rect: T2DIntRect read FRect write SetRect;
|
||||
property Images: TImageList read FImages write SetImages;
|
||||
property DisabledImages: TImageList read FDisabledImages write SetDisabledImages;
|
||||
property LargeImages: TImageList read FLargeImages write SetLargeImages;
|
||||
property DisabledLargeImages: TImageList read FDisabledLargeImages write SetDisabledLargeImages;
|
||||
property ImagesWidth: Integer read FImagesWidth write SetImagesWidth;
|
||||
property LargeImagesWidth: Integer read FLargeImagesWidth write SetLargeImagesWidth;
|
||||
|
||||
published
|
||||
property CustomAppearance: TSpkToolbarAppearance read FCustomAppearance write SetCustomAppearance;
|
||||
property Caption: string read FCaption write SetCaption;
|
||||
property OverrideAppearance: boolean read FOverrideAppearance write SetOverrideAppearance default false;
|
||||
property Visible: boolean read FVisible write SetVisible default true;
|
||||
property OnClick: TNotifyEvent read FOnClick write FOnClick;
|
||||
end;
|
||||
|
||||
TSpkTabs = class(TSpkCollection)
|
||||
protected
|
||||
FToolbarDispatch: TSpkBaseToolbarDispatch;
|
||||
FAppearance: TSpkToolbarAppearance;
|
||||
FImages: TImageList;
|
||||
FDisabledImages: TImageList;
|
||||
FLargeImages: TImageList;
|
||||
FDisabledLargeImages: TImageList;
|
||||
FImagesWidth: Integer;
|
||||
FLargeImagesWidth: Integer;
|
||||
procedure SetToolbarDispatch(const Value: TSpkBaseToolbarDispatch);
|
||||
function GetItems(AIndex: integer): TSpkTab; reintroduce;
|
||||
procedure SetAppearance(const Value: TSpkToolbarAppearance);
|
||||
procedure SetImages(const Value: TImageList);
|
||||
procedure SetDisabledImages(const Value: TImageList);
|
||||
procedure SetLargeImages(const Value: TImageList);
|
||||
procedure SetDisabledLargeImages(const Value: TImageList);
|
||||
procedure SetImagesWidth(const Value: Integer);
|
||||
procedure SetLargeImagesWidth(const Value: Integer);
|
||||
public
|
||||
function Add: TSpkTab;
|
||||
function Insert(AIndex: integer): TSpkTab;
|
||||
procedure Notify(Item: TComponent; Operation: TOperation); override;
|
||||
procedure Update; override;
|
||||
|
||||
property Items[index: integer]: TSpkTab read GetItems; default;
|
||||
property ToolbarDispatch: TSpkBaseToolbarDispatch read FToolbarDispatch write SetToolbarDispatch;
|
||||
property Appearance: TSpkToolbarAppearance read FAppearance write SetAppearance;
|
||||
property Images: TImageList read FImages write SetImages;
|
||||
property DisabledImages: TImageList read FDisabledImages write SetDisabledImages;
|
||||
property LargeImages: TImageList read FLargeImages write SetLargeImages;
|
||||
property DisabledLargeImages: TImageList read FDisabledLargeImages write SetDisabledLargeImages;
|
||||
property ImagesWidth: Integer read FImagesWidth write SetImagesWidth;
|
||||
property LargeImagesWidth: Integer read FLargeImagesWidth write SetLargeImagesWidth;
|
||||
end;
|
||||
|
||||
|
||||
implementation
|
||||
|
||||
{ TSpkTabDispatch }
|
||||
|
||||
constructor TSpkTabAppearanceDispatch.Create(ATab: TSpkTab);
|
||||
begin
|
||||
inherited Create;
|
||||
FTab := ATab;
|
||||
end;
|
||||
|
||||
procedure TSpkTabAppearanceDispatch.NotifyAppearanceChanged;
|
||||
begin
|
||||
if Assigned(FTab) then
|
||||
FTab.NotifyAppearanceChanged;
|
||||
end;
|
||||
|
||||
|
||||
{ TSpkTab }
|
||||
|
||||
constructor TSpkTab.Create(AOwner: TComponent);
|
||||
begin
|
||||
inherited Create(AOwner);
|
||||
FAppearanceDispatch := TSpkTabAppearanceDispatch.Create(self);
|
||||
FMouseHoverElement.ElementType := etNone;
|
||||
FMouseHoverElement.ElementIndex := -1;
|
||||
FMouseActiveElement.ElementType := etNone;
|
||||
FMouseActiveElement.ElementIndex := -1;
|
||||
FCaption := 'Tab';
|
||||
FVisible := true;
|
||||
FCustomAppearance := TSpkToolbarAppearance.Create(FAppearanceDispatch);
|
||||
FPanes := TSpkPanes.Create(self);
|
||||
FPanes.ToolbarDispatch := FToolbarDispatch;
|
||||
FPanes.ImagesWidth := FImagesWidth;
|
||||
FPanes.LargeImagesWidth := FLargeImagesWidth;
|
||||
{$IFDEF EnhancedRecordSupport}
|
||||
FRect := T2DIntRect.Create(0,0,0,0);
|
||||
{$ELSE}
|
||||
FRect.Create(0,0,0,0);
|
||||
{$ENDIF}
|
||||
SetPaneAppearance;
|
||||
end;
|
||||
|
||||
destructor TSpkTab.Destroy;
|
||||
begin
|
||||
FPanes.Free;
|
||||
FCustomAppearance.Free;
|
||||
FAppearanceDispatch.Free;
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
function TSpkTab.AtLeastOnePaneVisible: boolean;
|
||||
var
|
||||
i: integer;
|
||||
PaneVisible: boolean;
|
||||
begin
|
||||
Result := (FPanes.Count > 0);
|
||||
if Result then
|
||||
begin
|
||||
PaneVisible := false;
|
||||
i := FPanes.Count - 1;
|
||||
while (i >= 0) and not PaneVisible do
|
||||
begin
|
||||
PaneVisible := FPanes[i].Visible;
|
||||
dec(i);
|
||||
end;
|
||||
Result := Result and PaneVisible;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TSpkTab.SetRect(ARect: T2DIntRect);
|
||||
var
|
||||
x, i: integer;
|
||||
tw: integer;
|
||||
tmpRect: T2DIntRect;
|
||||
begin
|
||||
FRect := ARect;
|
||||
if AtLeastOnePaneVisible then
|
||||
begin
|
||||
x := ARect.left;
|
||||
for i := 0 to FPanes.Count - 1 do
|
||||
if FPanes[i].Visible then
|
||||
begin
|
||||
tw := FPanes[i].GetWidth;
|
||||
tmpRect.Left := x;
|
||||
tmpRect.Top := ARect.Top;
|
||||
tmpRect.Right := x + tw - 1;
|
||||
tmpRect.Bottom := ARect.bottom;
|
||||
FPanes[i].Rect := tmpRect;
|
||||
x := x + tw + TabPaneHSpacing;
|
||||
end
|
||||
else
|
||||
begin
|
||||
{$IFDEF EnhancedRecordSupport}
|
||||
FPanes[i].Rect := T2DIntRect.Create(-1,-1,-1,-1);
|
||||
{$ELSE}
|
||||
FPanes[i].Rect.Create(-1,-1,-1,-1);
|
||||
{$ENDIF}
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TSpkTab.SetToolbarDispatch(const Value: TSpkBaseToolbarDispatch);
|
||||
begin
|
||||
FToolbarDispatch := Value;
|
||||
FPanes.ToolbarDispatch := FToolbarDispatch;
|
||||
end;
|
||||
|
||||
procedure TSpkTab.DefineProperties(Filer: TFiler);
|
||||
begin
|
||||
inherited DefineProperties(Filer);
|
||||
Filer.DefineProperty('Panes', FPanes.ReadNames, FPanes.WriteNames, true);
|
||||
end;
|
||||
|
||||
|
||||
procedure TSpkTab.Draw(ABuffer: TBitmap; AClipRect: T2DIntRect);
|
||||
var
|
||||
LocalClipRect: T2DIntRect;
|
||||
i: integer;
|
||||
begin
|
||||
if AtLeastOnePaneVisible then
|
||||
for i := 0 to FPanes.Count - 1 do
|
||||
if FPanes[i].visible then
|
||||
begin
|
||||
if AClipRect.IntersectsWith(FPanes[i].Rect, LocalClipRect) then
|
||||
FPanes[i].Draw(ABuffer, LocalClipRect);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TSpkTab.ExecOnClick;
|
||||
begin
|
||||
if Assigned(FOnClick) then
|
||||
FOnClick(self);
|
||||
end;
|
||||
|
||||
function TSpkTab.FindPaneAt(x, y: integer): integer;
|
||||
var
|
||||
i: integer;
|
||||
begin
|
||||
Result := -1;
|
||||
i := FPanes.Count - 1;
|
||||
while (i >= 0) and (Result = -1) do
|
||||
begin
|
||||
if FPanes[i].Visible then
|
||||
begin
|
||||
{$IFDEF EnhancedRecordSupport}
|
||||
if FPanes[i].Rect.Contains(T2DIntVector.Create(x,y)) then
|
||||
{$ELSE}
|
||||
if FPanes[i].Rect.Contains(x,y) then
|
||||
{$ENDIF}
|
||||
Result := i;
|
||||
end;
|
||||
dec(i);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TSpkTab.FreeingPane(APane: TSpkPane);
|
||||
begin
|
||||
FPanes.RemoveReference(APane);
|
||||
end;
|
||||
|
||||
procedure TSpkTab.GetChildren(Proc: TGetChildProc; Root: TComponent);
|
||||
var
|
||||
i: Integer;
|
||||
begin
|
||||
inherited;
|
||||
for i := 0 to FPanes.Count - 1 do
|
||||
Proc(FPanes.Items[i]);
|
||||
end;
|
||||
|
||||
procedure TSpkTab.Loaded;
|
||||
begin
|
||||
inherited;
|
||||
if FPanes.ListState = lsNeedsProcessing then
|
||||
FPanes.ProcessNames(self.Owner);
|
||||
end;
|
||||
|
||||
procedure TSpkTab.MouseDown(Button: TMouseButton; Shift: TShiftState;
|
||||
X, Y: Integer);
|
||||
begin
|
||||
if FMouseActiveElement.ElementType = etPane then
|
||||
begin
|
||||
if FMouseActiveElement.ElementIndex <> -1 then
|
||||
FPanes[FMouseActiveElement.ElementIndex].MouseDown(Button, Shift, X, Y);
|
||||
end else
|
||||
if FMouseActiveElement.ElementType = etTabArea then
|
||||
begin
|
||||
// Placeholder, if there is a need to handle this event.
|
||||
end else
|
||||
if FMouseActiveElement.ElementType = etNone then
|
||||
begin
|
||||
if FMouseHoverElement.ElementType = etPane then
|
||||
begin
|
||||
if FMouseHoverElement.ElementIndex <> -1 then
|
||||
begin
|
||||
FMouseActiveElement.ElementType := etPane;
|
||||
FMouseActiveElement.ElementIndex := FMouseHoverElement.ElementIndex;
|
||||
FPanes[FMouseHoverElement.ElementIndex].MouseDown(Button, Shift, X, Y);
|
||||
end
|
||||
else
|
||||
begin
|
||||
FMouseActiveElement.ElementType := etTabArea;
|
||||
FMouseActiveElement.ElementIndex := -1;
|
||||
end;
|
||||
end else
|
||||
if FMouseHoverElement.ElementType = etTabArea then
|
||||
begin
|
||||
FMouseActiveElement.ElementType := etTabArea;
|
||||
FMouseActiveElement.ElementIndex := -1;
|
||||
// Placeholder, if there is a need to handle this event.
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TSpkTab.MouseLeave;
|
||||
begin
|
||||
if FMouseActiveElement.ElementType = etNone then
|
||||
begin
|
||||
if FMouseHoverElement.ElementType = etPane then
|
||||
begin
|
||||
if FMouseHoverElement.ElementIndex <> -1 then
|
||||
FPanes[FMouseHoverElement.ElementIndex].MouseLeave;
|
||||
end else
|
||||
if FMouseHoverElement.ElementType = etTabArea then
|
||||
begin
|
||||
// Placeholder, if there is a need to handle this event.
|
||||
end;
|
||||
end;
|
||||
|
||||
FMouseHoverElement.ElementType := etNone;
|
||||
FMouseHoverElement.ElementIndex := -1;
|
||||
end;
|
||||
|
||||
procedure TSpkTab.MouseMove(Shift: TShiftState; X, Y: Integer);
|
||||
var
|
||||
i: integer;
|
||||
NewMouseHoverElement: TSpkMouseTabElement;
|
||||
begin
|
||||
// We're looking for an object under the mouse
|
||||
i := FindPaneAt(X, Y);
|
||||
if i <> -1 then
|
||||
begin
|
||||
NewMouseHoverElement.ElementType := etPane;
|
||||
NewMouseHoverElement.ElementIndex := i;
|
||||
end else
|
||||
if (X >= FRect.left) and (Y >= FRect.top) and
|
||||
(X <= FRect.right) and (Y <= FRect.bottom) then
|
||||
begin
|
||||
NewMouseHoverElement.ElementType := etTabArea;
|
||||
NewMouseHoverElement.ElementIndex := -1;
|
||||
end else
|
||||
begin
|
||||
NewMouseHoverElement.ElementType := etNone;
|
||||
NewMouseHoverElement.ElementIndex := -1;
|
||||
end;
|
||||
|
||||
if FMouseActiveElement.ElementType = etPane then
|
||||
begin
|
||||
if FMouseActiveElement.ElementIndex <> -1 then
|
||||
begin
|
||||
FPanes[FMouseActiveElement.ElementIndex].MouseMove(Shift, X, Y);
|
||||
end;
|
||||
end else
|
||||
if FMouseActiveElement.ElementType = etTabArea then
|
||||
begin
|
||||
// Placeholder, if there is a need to handle this event
|
||||
end else
|
||||
if FMouseActiveElement.ElementType = etNone then
|
||||
begin
|
||||
// If the item under the mouse changes, we inform the previous element
|
||||
// that the mouse leaves its area
|
||||
if (NewMouseHoverElement.ElementType <> FMouseHoverElement.ElementType) or
|
||||
(NewMouseHoverElement.ElementIndex <> FMouseHoverElement.ElementIndex) then
|
||||
begin
|
||||
if FMouseHoverElement.ElementType = etPane then
|
||||
begin
|
||||
if FMouseHoverElement.ElementIndex <> -1 then
|
||||
FPanes[FMouseHoverElement.ElementIndex].MouseLeave;
|
||||
end else
|
||||
if FMouseHoverElement.ElementType = etTabArea then
|
||||
begin
|
||||
// Placeholder, if there is a need to handle this event
|
||||
end;
|
||||
end;
|
||||
|
||||
if NewMouseHoverElement.ElementType = etPane then
|
||||
begin
|
||||
if NewMouseHoverElement.ElementIndex <> -1 then
|
||||
FPanes[NewMouseHoverElement.ElementIndex].MouseMove(Shift, X, Y);
|
||||
end else
|
||||
if NewMouseHoverElement.ElementType = etTabArea then
|
||||
begin
|
||||
// Placeholder, if there is a need to handle this event
|
||||
end;
|
||||
end;
|
||||
|
||||
FMouseHoverElement := NewMouseHoverElement;
|
||||
end;
|
||||
|
||||
procedure TSpkTab.MouseUp(Button: TMouseButton; Shift: TShiftState; X,
|
||||
Y: Integer);
|
||||
var
|
||||
ClearActive: boolean;
|
||||
begin
|
||||
ClearActive := not (ssLeft in Shift) and not (ssMiddle in Shift) and not (ssRight in Shift);
|
||||
|
||||
if FMouseActiveElement.ElementType = etPane then
|
||||
begin
|
||||
if FMouseActiveElement.ElementIndex <> -1 then
|
||||
FPanes[FMouseActiveElement.ElementIndex].MouseUp(Button, Shift, X, Y);
|
||||
end else
|
||||
if FMouseActiveElement.ElementType = etTabArea then
|
||||
begin
|
||||
// Placeholder, if there is a need to handle this event.
|
||||
end;
|
||||
|
||||
if ClearActive and
|
||||
(FMouseActiveElement.ElementType <> FMouseHoverElement.ElementType) or
|
||||
(FMouseActiveElement.ElementIndex <> FMouseHoverElement.ElementIndex) then
|
||||
begin
|
||||
if FMouseActiveElement.ElementType = etPane then
|
||||
begin
|
||||
if FMouseActiveElement.ElementIndex <> -1 then
|
||||
FPanes[FMouseActiveElement.ElementIndex].MouseLeave;
|
||||
end else
|
||||
if FMouseActiveElement.ElementType = etTabArea then
|
||||
begin
|
||||
// Placeholder, if there is a need to handle this event.
|
||||
end;
|
||||
|
||||
if FMouseHoverElement.ElementType = etPane then
|
||||
begin
|
||||
if FMouseHoverElement.ElementIndex <> -1 then
|
||||
FPanes[FMouseHoverElement.ElementIndex].MouseMove(Shift, X, Y);
|
||||
end else
|
||||
if FMouseHoverElement.ElementType = etTabArea then
|
||||
begin
|
||||
// Placeholder, if there is a need to handle this event.
|
||||
end;
|
||||
end;
|
||||
|
||||
if ClearActive then
|
||||
begin
|
||||
FMouseActiveElement.ElementType := etNone;
|
||||
FMouseActiveElement.ElementIndex := -1;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TSpkTab.NotifyAppearanceChanged;
|
||||
begin
|
||||
if Assigned(FToolbarDispatch) then
|
||||
FToolbarDispatch.NotifyAppearanceChanged;
|
||||
end;
|
||||
|
||||
procedure TSpkTab.SetCustomAppearance(const Value: TSpkToolbarAppearance);
|
||||
begin
|
||||
FCustomAppearance.Assign(Value);
|
||||
end;
|
||||
|
||||
procedure TSpkTab.SetDisabledImages(const Value: TImageList);
|
||||
begin
|
||||
FDisabledImages := Value;
|
||||
FPanes.DisabledImages := Value;
|
||||
end;
|
||||
|
||||
procedure TSpkTab.SetDisabledLargeImages(const Value: TImageList);
|
||||
begin
|
||||
FDisabledLargeImages := Value;
|
||||
FPanes.DisabledLargeImages := Value;
|
||||
end;
|
||||
|
||||
procedure TSpkTab.SetImages(const Value: TImageList);
|
||||
begin
|
||||
FImages := Value;
|
||||
FPanes.Images := Value;
|
||||
end;
|
||||
|
||||
procedure TSpkTab.SetImagesWidth(const Value: Integer);
|
||||
begin
|
||||
FImagesWidth := Value;
|
||||
FPanes.ImagesWidth := Value;
|
||||
end;
|
||||
|
||||
procedure TSpkTab.SetLargeImages(const Value: TImageList);
|
||||
begin
|
||||
FLargeImages := Value;
|
||||
FPanes.LargeImages := Value;
|
||||
end;
|
||||
|
||||
procedure TSpkTab.SetLargeImagesWidth(const Value: Integer);
|
||||
begin
|
||||
FLargeImagesWidth := Value;
|
||||
FPanes.LargeImagesWidth := Value;
|
||||
end;
|
||||
|
||||
procedure TSpkTab.SetAppearance(const Value: TSpkToolbarAppearance);
|
||||
begin
|
||||
FAppearance := Value;
|
||||
SetPaneAppearance;
|
||||
if FToolbarDispatch <> nil then
|
||||
FToolbarDispatch.NotifyMetricsChanged;
|
||||
end;
|
||||
|
||||
procedure TSpkTab.SetCaption(const Value: string);
|
||||
begin
|
||||
FCaption := Value;
|
||||
if Assigned(FToolbarDispatch) then
|
||||
FToolbarDispatch.NotifyMetricsChanged;
|
||||
end;
|
||||
|
||||
procedure TSpkTab.SetOverrideAppearance(const Value: boolean);
|
||||
begin
|
||||
FOverrideAppearance := Value;
|
||||
SetPaneAppearance;
|
||||
if FToolbarDispatch <> nil then
|
||||
FToolbarDispatch.NotifyMetricsChanged;
|
||||
end;
|
||||
|
||||
procedure TSpkTab.SetPaneAppearance;
|
||||
begin
|
||||
if FOverrideAppearance then
|
||||
FPanes.Appearance := FCustomAppearance
|
||||
else
|
||||
FPanes.Appearance := FAppearance;
|
||||
// The method plays the role of a macro - therefore it does not
|
||||
// notify the dispatcher about the change.
|
||||
end;
|
||||
|
||||
procedure TSpkTab.SetVisible(const Value: boolean);
|
||||
begin
|
||||
FVisible := Value;
|
||||
if FToolbarDispatch <> nil then
|
||||
FToolbarDispatch.NotifyItemsChanged;
|
||||
end;
|
||||
|
||||
|
||||
{ TSpkTabs }
|
||||
|
||||
function TSpkTabs.Add: TSpkTab;
|
||||
begin
|
||||
Result := TSpkTab.create(FRootComponent);
|
||||
Result.Parent := FRootComponent;
|
||||
AddItem(Result);
|
||||
end;
|
||||
|
||||
function TSpkTabs.GetItems(AIndex: integer): TSpkTab;
|
||||
begin
|
||||
Result := TSpkTab(inherited Items[AIndex]);
|
||||
end;
|
||||
|
||||
function TSpkTabs.Insert(AIndex: integer): TSpkTab;
|
||||
var
|
||||
lOwner, lParent: TComponent;
|
||||
i: Integer;
|
||||
begin
|
||||
if (AIndex < 0) or (AIndex >= self.Count) then
|
||||
raise InternalException.Create('TSpkTabs.Insert: Invalid index!');
|
||||
|
||||
if FRootComponent<>nil then
|
||||
begin
|
||||
lOwner := FRootComponent.Owner;
|
||||
lParent := FRootComponent;
|
||||
end
|
||||
else
|
||||
begin
|
||||
lOwner := nil;
|
||||
lParent := nil;
|
||||
end;
|
||||
|
||||
Result := TSpkTab.Create(lOwner);
|
||||
Result.Parent := lParent;
|
||||
|
||||
if FRootComponent<>nil then
|
||||
begin
|
||||
i := 0;
|
||||
while FRootComponent.Owner.FindComponent('SpkTab'+IntToStr(i)) <> nil do
|
||||
inc(i);
|
||||
|
||||
Result.Name := 'SpkTab' + IntToStr(i);
|
||||
end;
|
||||
InsertItem(AIndex, Result);
|
||||
end;
|
||||
|
||||
procedure TSpkTabs.Notify(Item: TComponent; Operation: TOperation);
|
||||
begin
|
||||
inherited Notify(Item, Operation);
|
||||
|
||||
case Operation of
|
||||
opInsert:
|
||||
begin
|
||||
// Setting the dispatcher to nil will cause that during the
|
||||
// ownership assignment, the Notify method will not be called
|
||||
TSpkTab(Item).ToolbarDispatch := nil;
|
||||
TSpkTab(Item).Appearance := self.FAppearance;
|
||||
TSpkTab(Item).Images := self.FImages;
|
||||
TSpkTab(Item).DisabledImages := self.FDisabledImages;
|
||||
TSpkTab(Item).LargeImages := self.FLargeImages;
|
||||
TSpkTab(Item).DisabledLargeImages := self.FDisabledLargeImages;
|
||||
TSpkTab(Item).ImagesWidth := self.FImagesWidth;
|
||||
TSpkTab(Item).LargeImagesWidth := self.FLargeImagesWidth;
|
||||
TSpkTab(Item).ToolbarDispatch := self.FToolbarDispatch;
|
||||
end;
|
||||
opRemove:
|
||||
if not(csDestroying in Item.ComponentState) then
|
||||
begin
|
||||
TSpkTab(Item).ToolbarDispatch := nil;
|
||||
TSpkTab(Item).Appearance := nil;
|
||||
TSpkTab(Item).Images := nil;
|
||||
TSpkTab(Item).DisabledImages := nil;
|
||||
TSpkTab(Item).LargeImages := nil;
|
||||
TSpkTab(Item).DisabledLargeImages := nil;
|
||||
// TSpkTab(Item).ImagesWidth := 0;
|
||||
// TSpkTab(Item).LargeImagesWidth := 0;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TSpkTabs.SetAppearance(const Value: TSpkToolbarAppearance);
|
||||
var
|
||||
i: Integer;
|
||||
begin
|
||||
FAppearance := Value;
|
||||
for i := 0 to self.Count - 1 do
|
||||
self.Items[i].Appearance := FAppearance;
|
||||
end;
|
||||
|
||||
procedure TSpkTabs.SetDisabledImages(const Value: TImageList);
|
||||
var
|
||||
i: Integer;
|
||||
begin
|
||||
FDisabledImages := Value;
|
||||
for i := 0 to self.Count - 1 do
|
||||
Items[i].DisabledImages := Value;
|
||||
end;
|
||||
|
||||
procedure TSpkTabs.SetDisabledLargeImages(const Value: TImageList);
|
||||
var
|
||||
i: Integer;
|
||||
begin
|
||||
FDisabledLargeImages := Value;
|
||||
for i := 0 to self.count - 1 do
|
||||
Items[i].DisabledLargeImages := Value;
|
||||
end;
|
||||
|
||||
procedure TSpkTabs.SetImages(const Value: TImageList);
|
||||
var
|
||||
i: Integer;
|
||||
begin
|
||||
FImages := Value;
|
||||
for i := 0 to self.Count - 1 do
|
||||
Items[i].Images := Value;
|
||||
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);
|
||||
var
|
||||
i: Integer;
|
||||
begin
|
||||
FLargeImages := Value;
|
||||
for i := 0 to self.Count - 1 do
|
||||
Items[i].LargeImages := Value;
|
||||
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);
|
||||
var
|
||||
i: integer;
|
||||
begin
|
||||
FToolbarDispatch := Value;
|
||||
for i := 0 to self.Count - 1 do
|
||||
self.Items[i].ToolbarDispatch := FToolbarDispatch;
|
||||
end;
|
||||
|
||||
procedure TSpkTabs.Update;
|
||||
begin
|
||||
inherited Update;
|
||||
|
||||
if Assigned(FToolbarDispatch) then
|
||||
FToolbarDispatch.NotifyItemsChanged;
|
||||
end;
|
||||
|
||||
|
||||
end.
|
251
spktoolbar/SpkToolbar/spkt_Tools.pas
Normal file
@@ -0,0 +1,251 @@
|
||||
unit spkt_Tools;
|
||||
|
||||
{$mode delphi}
|
||||
{.$Define EnhancedRecordSupport}
|
||||
|
||||
(*******************************************************************************
|
||||
* *
|
||||
* Unit: spkt_Tools.pas *
|
||||
* Description: Tool classes for easier rendering of the toolbar. *
|
||||
* Copyright: (c) 2009 by Spook. *
|
||||
* License: Modified LGPL (with linking exception, like Lazarus LCL) *
|
||||
' See "license.txt" in this installation *
|
||||
* *
|
||||
*******************************************************************************)
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Graphics, SysUtils, SpkMath, SpkGUITools;
|
||||
|
||||
type
|
||||
TButtonTools = class sealed(TObject)
|
||||
public
|
||||
class procedure DrawButton(Bitmap: TBitmap;
|
||||
Rect: T2DIntRect;
|
||||
FrameColor,
|
||||
InnerLightColor,
|
||||
InnerDarkColor,
|
||||
GradientFrom,
|
||||
GradientTo: TColor;
|
||||
GradientKind: TBackgroundKind;
|
||||
LeftEdgeOpen,
|
||||
RightEdgeOpen,
|
||||
TopEdgeOpen,
|
||||
BottomEdgeOpen: boolean;
|
||||
Radius: integer;
|
||||
ClipRect: T2DIntRect);
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
{ TButtonTools }
|
||||
|
||||
class procedure TButtonTools.DrawButton(Bitmap: TBitmap;
|
||||
Rect: T2DIntRect; FrameColor, InnerLightColor, InnerDarkColor, GradientFrom,
|
||||
GradientTo: TColor; GradientKind: TBackgroundKind; LeftEdgeOpen,
|
||||
RightEdgeOpen, TopEdgeOpen, BottomEdgeOpen: boolean; Radius: integer;
|
||||
ClipRect: T2DIntRect);
|
||||
var
|
||||
x1, x2, y1, y2: integer;
|
||||
LeftClosed, TopClosed, RightClosed, BottomClosed: byte;
|
||||
begin
|
||||
if (Rect.Width < 6) or (Rect.Height < 6) or
|
||||
(Rect.Width < 2*Radius) or (Rect.Height < 2*Radius) then exit;
|
||||
|
||||
if LeftEdgeOpen then LeftClosed := 0 else LeftClosed := 1;
|
||||
if RightEdgeOpen then RightClosed := 0 else RightClosed := 1;
|
||||
if TopEdgeOpen then TopClosed := 0 else TopClosed := 1;
|
||||
if BottomEdgeOpen then BottomClosed := 0 else BottomClosed := 1;
|
||||
|
||||
TGuiTools.DrawRoundRect(
|
||||
Bitmap.Canvas,
|
||||
Rect,
|
||||
Radius,
|
||||
GradientFrom,
|
||||
GradientTo,
|
||||
GradientKind,
|
||||
ClipRect,
|
||||
not (LeftEdgeOpen or TopEdgeOpen),
|
||||
not (RightEdgeOpen or TopEdgeOpen),
|
||||
not (LeftEdgeOpen or BottomEdgeOpen),
|
||||
not (RightEdgeOpen or BottomEdgeOpen)
|
||||
);
|
||||
|
||||
// Inner edge
|
||||
// *** Top ***
|
||||
x1 := Rect.Left + radius * TopClosed * LeftClosed + LeftClosed;
|
||||
x2 := Rect.Right - radius * TopClosed * RightClosed - RightClosed;
|
||||
y1 := Rect.Top + TopClosed;
|
||||
TGuiTools.DrawHLine(Bitmap, x1, x2, y1, InnerLightColor, ClipRect);
|
||||
|
||||
// *** Bottom ***
|
||||
x1 := Rect.Left + radius * BottomClosed * LeftClosed + LeftClosed;
|
||||
x2 := Rect.Right - radius * BottomClosed * RightClosed - RightClosed;
|
||||
y1 := Rect.Bottom - BottomClosed;
|
||||
if BottomEdgeOpen then
|
||||
TGuiTools.DrawHLine(Bitmap, x1, x2, y1, InnerDarkColor, ClipRect)
|
||||
else
|
||||
TGuiTools.DrawHLine(Bitmap, x1, x2, y1, InnerLightColor, ClipRect);
|
||||
|
||||
// *** Left ***
|
||||
y1 := Rect.Top + Radius * LeftClosed * TopClosed + TopClosed;
|
||||
y2 := Rect.Bottom - Radius * LeftClosed * BottomClosed - BottomClosed;
|
||||
x1 := Rect.Left + LeftClosed;
|
||||
TGuiTools.DrawVLine(Bitmap, x1, y1, y2, InnerLightColor, ClipRect);
|
||||
|
||||
// *** Right ***
|
||||
y1 := Rect.Top + Radius * RightClosed * TopClosed + TopClosed;
|
||||
y2 := Rect.Bottom - Radius * RightClosed * BottomClosed - BottomClosed;
|
||||
x1 := Rect.Right - RightClosed;
|
||||
if RightEdgeOpen then
|
||||
TGuiTools.DrawVLine(Bitmap, x1, y1, y2, InnerDarkColor, ClipRect)
|
||||
else
|
||||
TGuiTools.DrawVLine(Bitmap, x1, y1, y2, InnerLightColor, ClipRect);
|
||||
|
||||
// Rounded corners
|
||||
if not(LeftEdgeOpen or TopEdgeOpen) then
|
||||
TGuiTools.DrawAARoundCorner(
|
||||
Bitmap,
|
||||
{$IFDEF EnhancedRecordSupport}
|
||||
T2DIntPoint.create(Rect.left + 1, Rect.Top + 1),
|
||||
{$ELSE}
|
||||
Create2DIntPoint(Rect.left + 1, Rect.Top + 1),
|
||||
{$ENDIF}
|
||||
Radius,
|
||||
cpLeftTop,
|
||||
InnerLightColor,
|
||||
ClipRect
|
||||
);
|
||||
if not(RightEdgeOpen or TopEdgeOpen) then
|
||||
TGuiTools.DrawAARoundCorner(
|
||||
Bitmap,
|
||||
{$IFDEF EnhancedRecordSupport}
|
||||
T2DIntPoint.Create(Rect.right - radius, Rect.Top + 1),
|
||||
{$ELSE}
|
||||
Create2DIntPoint(Rect.right - radius, Rect.Top + 1),
|
||||
{$ENDIF}
|
||||
Radius,
|
||||
cpRightTop,
|
||||
InnerLightColor,
|
||||
ClipRect
|
||||
);
|
||||
if not(LeftEdgeOpen or BottomEdgeOpen) then
|
||||
TGuiTools.DrawAARoundCorner(
|
||||
Bitmap,
|
||||
{$IFDEF EnhancedRecordSupport}
|
||||
T2DIntPoint.create(Rect.left + 1, Rect.bottom - Radius),
|
||||
{$ELSE}
|
||||
Create2DIntPoint(Rect.left + 1, Rect.bottom - Radius),
|
||||
{$ENDIF}
|
||||
Radius,
|
||||
cpLeftBottom,
|
||||
InnerLightColor,
|
||||
ClipRect
|
||||
);
|
||||
if not(RightEdgeOpen or BottomEdgeOpen) then
|
||||
TGuiTools.DrawAARoundCorner(
|
||||
Bitmap,
|
||||
{$IFDEF EnhancedRecordSupport}
|
||||
T2DIntPoint.create(Rect.right - Radius, Rect.bottom - Radius),
|
||||
{$ELSE}
|
||||
Create2DIntPoint(Rect.right - Radius, Rect.bottom - Radius),
|
||||
{$ENDIF}
|
||||
Radius,
|
||||
cpRightBottom,
|
||||
InnerLightColor,
|
||||
ClipRect
|
||||
);
|
||||
|
||||
// Outer edge
|
||||
// Rounded corners
|
||||
if not TopEdgeOpen then
|
||||
begin
|
||||
x1 := Rect.Left + Radius * LeftClosed;
|
||||
x2 := Rect.Right - Radius * RightClosed;
|
||||
y1 := Rect.Top;
|
||||
TGuiTools.DrawHLine(Bitmap, x1, x2, y1, FrameColor, ClipRect);
|
||||
end;
|
||||
|
||||
if not BottomEdgeOpen then
|
||||
begin
|
||||
x1 := Rect.Left + Radius * LeftClosed;
|
||||
x2 := Rect.Right - Radius * RightClosed;
|
||||
y1 := Rect.Bottom;
|
||||
TGuiTools.DrawHLine(Bitmap, x1, x2, y1, FrameColor, ClipRect);
|
||||
end;
|
||||
|
||||
if not LeftEdgeOpen then
|
||||
begin
|
||||
y1 := Rect.Top + Radius * TopClosed;
|
||||
y2 := Rect.Bottom - Radius * BottomClosed;
|
||||
x1 := Rect.Left;
|
||||
TGuiTools.DrawVLine(Bitmap, x1, y1, y2, FrameColor, ClipRect);
|
||||
end;
|
||||
|
||||
if not(RightEdgeOpen) then
|
||||
begin
|
||||
y1 := Rect.Top + Radius * TopClosed;
|
||||
y2 := Rect.Bottom - Radius * BottomClosed;
|
||||
x1 := Rect.Right;
|
||||
TGuiTools.DrawVLine(Bitmap, x1, y1, y2, FrameColor, ClipRect);
|
||||
end;
|
||||
|
||||
if not(LeftEdgeOpen or TopEdgeOpen) then
|
||||
TGuiTools.DrawAARoundCorner(
|
||||
Bitmap,
|
||||
{$IFDEF EnhancedRecordSupport}
|
||||
T2DIntPoint.create(Rect.left, Rect.Top),
|
||||
{$ELSE}
|
||||
Create2DIntPoint(Rect.left, Rect.Top),
|
||||
{$ENDIF}
|
||||
Radius,
|
||||
cpLeftTop,
|
||||
FrameColor,
|
||||
ClipRect
|
||||
);
|
||||
|
||||
if not(RightEdgeOpen or TopEdgeOpen) then
|
||||
TGuiTools.DrawAARoundCorner(
|
||||
Bitmap,
|
||||
{$IFDEF EnhancedRecordSupport}
|
||||
T2DIntPoint.create(Rect.right - radius + 1, Rect.Top),
|
||||
{$ELSE}
|
||||
Create2DIntPoint(Rect.right - radius + 1, Rect.Top),
|
||||
{$ENDIF}
|
||||
Radius,
|
||||
cpRightTop,
|
||||
FrameColor,
|
||||
ClipRect
|
||||
);
|
||||
|
||||
if not(LeftEdgeOpen or BottomEdgeOpen) then
|
||||
TGuiTools.DrawAARoundCorner(
|
||||
Bitmap,
|
||||
{$IFDEF EnhancedRecordSupport}
|
||||
T2DIntPoint.create(Rect.left, Rect.bottom - radius + 1),
|
||||
{$ELSE}
|
||||
Create2DIntPoint(Rect.left, Rect.bottom - radius + 1),
|
||||
{$ENDIF}
|
||||
Radius,
|
||||
cpLeftBottom,
|
||||
FrameColor,
|
||||
ClipRect
|
||||
);
|
||||
|
||||
if not(RightEdgeOpen or BottomEdgeOpen) then
|
||||
TGuiTools.DrawAARoundCorner(
|
||||
Bitmap,
|
||||
{$IFDEF EnhancedRecordSupport}
|
||||
T2DIntPoint.create(Rect.right - radius + 1, Rect.bottom - radius + 1),
|
||||
{$ELSE}
|
||||
Create2DIntPoint(Rect.right - Radius + 1, Rect.bottom - radius + 1),
|
||||
{$ENDIF}
|
||||
Radius,
|
||||
cpRightBottom,
|
||||
FrameColor,
|
||||
ClipRect
|
||||
);
|
||||
end;
|
||||
|
||||
end.
|
274
spktoolbar/SpkToolbar/spkt_Types.pas
Normal file
@@ -0,0 +1,274 @@
|
||||
unit spkt_Types;
|
||||
|
||||
{$mode Delphi}
|
||||
|
||||
(*******************************************************************************
|
||||
* *
|
||||
* File: spkt_Types.pas *
|
||||
* Description: Definitions of types used during work of the toolbar *
|
||||
* Copyright: (c) 2009 by Spook. *
|
||||
* License: Modified LGPL (with linking exception, like Lazarus LCL) *
|
||||
' See "license.txt" in this installation *
|
||||
* *
|
||||
*******************************************************************************)
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Controls, Classes, ContNrs, SysUtils, Dialogs,
|
||||
spkt_Exceptions;
|
||||
|
||||
type
|
||||
TSpkListState = (lsNeedsProcessing, lsReady);
|
||||
|
||||
TSpkCollection = class(TPersistent)
|
||||
protected
|
||||
FList: TFPObjectList;
|
||||
FNames: TStringList;
|
||||
FListState: TSpkListState;
|
||||
FRootComponent: TComponent;
|
||||
|
||||
// *** Metody reakcji na zmiany w liœcie ***
|
||||
// *** Methods responding to changes in list ***
|
||||
procedure Notify({%H-}Item: TComponent; {%H-}Operation: TOperation); virtual;
|
||||
procedure Update; virtual;
|
||||
|
||||
// *** Wewnêtrzne metody dodawania i wstawiania elementów ***
|
||||
// *** Gettery i settery ***
|
||||
|
||||
// *** Internal methods for adding and inserting elements ***
|
||||
// *** Getters and setters ***
|
||||
function GetItems(AIndex: integer): TComponent; virtual;
|
||||
|
||||
public
|
||||
// *** Konstruktor, destruktor ***
|
||||
constructor Create(ARootComponent : TComponent); reintroduce; virtual;
|
||||
destructor Destroy; override;
|
||||
|
||||
// *** Obs³uga listy ***
|
||||
// *** List operations ***
|
||||
procedure AddItem(AItem: TComponent);
|
||||
procedure InsertItem(AIndex: integer; AItem: TComponent);
|
||||
procedure Clear;
|
||||
function Count: integer;
|
||||
procedure Delete(AIndex: integer); virtual;
|
||||
function IndexOf(Item: TComponent) : integer;
|
||||
procedure Remove(Item: TComponent); virtual;
|
||||
procedure RemoveReference(Item: TComponent);
|
||||
procedure Exchange(item1, item2: integer);
|
||||
procedure Move(IndexFrom, IndexTo: integer);
|
||||
|
||||
// *** Reader, writer i obs³uga designtime i DFM ***
|
||||
// *** Reader, writer and operation designtime and DFM
|
||||
procedure WriteNames(Writer: TWriter); virtual;
|
||||
procedure ReadNames(Reader: TReader); virtual;
|
||||
procedure ProcessNames(Owner: TComponent); virtual;
|
||||
|
||||
property ListState: TSpkListState read FListState;
|
||||
property Items[index: integer] : TComponent read GetItems; default;
|
||||
property RootComponent: TComponent read FRootComponent;
|
||||
end;
|
||||
|
||||
TSpkComponent = class(TComponent)
|
||||
protected
|
||||
FParent: TComponent;
|
||||
FCollection: TSpkCollection;
|
||||
public
|
||||
// *** Obs³uga parenta ***
|
||||
// *** Parent operations ***
|
||||
function HasParent: boolean; override;
|
||||
function GetParentComponent: TComponent; override;
|
||||
procedure SetParentComponent(Value: TComponent); override;
|
||||
|
||||
property Parent: TComponent read FParent write SetParentComponent;
|
||||
property Collection: TSpkCollection read FCollection;
|
||||
end;
|
||||
|
||||
|
||||
implementation
|
||||
|
||||
{ TSpkCollection }
|
||||
|
||||
constructor TSpkCollection.Create(ARootComponent: TComponent);
|
||||
begin
|
||||
inherited Create;
|
||||
FRootComponent := ARootComponent;
|
||||
FNames := TStringList.Create;
|
||||
FList := TFPObjectList.Create(False);
|
||||
FListState := lsReady;
|
||||
end;
|
||||
|
||||
destructor TSpkCollection.Destroy;
|
||||
begin
|
||||
FNames.Free;
|
||||
FList.Free;
|
||||
inherited;
|
||||
end;
|
||||
|
||||
procedure TSpkCollection.AddItem(AItem: TComponent);
|
||||
begin
|
||||
// Ta metoda mo¿e byæ wywo³ywana bez przetworzenia nazw (w szczególnoœci, metoda
|
||||
// przetwarzaj¹ca nazwy korzysta z AddItem)
|
||||
|
||||
// This method can be recalling untreated names (in particular, the method
|
||||
// that processes the name uses the AddItem)
|
||||
|
||||
Notify(AItem, opInsert);
|
||||
FList.Add(AItem);
|
||||
|
||||
if AItem is TSpkComponent then
|
||||
TSpkComponent(AItem).FCollection := self;
|
||||
|
||||
Update;
|
||||
end;
|
||||
|
||||
procedure TSpkCollection.Clear;
|
||||
begin
|
||||
FList.Clear;
|
||||
Update;
|
||||
end;
|
||||
|
||||
function TSpkCollection.Count: integer;
|
||||
begin
|
||||
Result := FList.Count;
|
||||
end;
|
||||
|
||||
procedure TSpkCollection.Delete(AIndex: integer);
|
||||
begin
|
||||
if (AIndex < 0) or (AIndex >= FList.count) then
|
||||
raise InternalException.Create('TSpkCollection.Delete: Illegal index!');
|
||||
|
||||
Notify(TComponent(FList[AIndex]), opRemove);
|
||||
FList.Delete(AIndex);
|
||||
Update;
|
||||
end;
|
||||
|
||||
procedure TSpkCollection.Exchange(item1, item2: integer);
|
||||
begin
|
||||
FList.Exchange(item1, item2);
|
||||
Update;
|
||||
end;
|
||||
|
||||
function TSpkCollection.GetItems(AIndex: integer): TComponent;
|
||||
begin
|
||||
if (AIndex < 0) or (AIndex >= FList.Count) then
|
||||
raise InternalException.Create('TSpkCollection.Delete: Illegal index!');
|
||||
|
||||
Result := TComponent(FList[AIndex]);
|
||||
end;
|
||||
|
||||
function TSpkCollection.IndexOf(Item: TComponent): integer;
|
||||
begin
|
||||
result := FList.IndexOf(Item);
|
||||
end;
|
||||
|
||||
procedure TSpkCollection.InsertItem(AIndex: integer; AItem: TComponent);
|
||||
begin
|
||||
if (AIndex < 0) or (AIndex > FList.Count) then
|
||||
raise InternalException.Create('TSpkCollection.Delete: Illegal index!');
|
||||
|
||||
Notify(AItem, opInsert);
|
||||
FList.Insert(AIndex, AItem);
|
||||
if AItem is TSpkComponent then
|
||||
TSpkComponent(AItem).FCollection := self;
|
||||
Update;
|
||||
end;
|
||||
|
||||
procedure TSpkCollection.Move(IndexFrom, IndexTo: integer);
|
||||
begin
|
||||
if (indexFrom < 0) or (indexFrom >= FList.Count) or
|
||||
(indexTo < 0) or (indexTo >= FList.Count)
|
||||
then
|
||||
raise InternalException.Create('TSpkCollection.Delete: Illegal index!');
|
||||
|
||||
FList.Move(IndexFrom, IndexTo);
|
||||
Update;
|
||||
end;
|
||||
|
||||
procedure TSpkCollection.Notify(Item: TComponent; Operation: TOperation);
|
||||
begin
|
||||
//
|
||||
end;
|
||||
|
||||
procedure TSpkCollection.ProcessNames(Owner: TComponent);
|
||||
var
|
||||
s: string;
|
||||
begin
|
||||
FList.Clear;
|
||||
if Owner <> nil then
|
||||
for s in FNames do
|
||||
AddItem(Owner.FindComponent(s));
|
||||
FNames.Clear;
|
||||
FListState := lsReady;
|
||||
end;
|
||||
|
||||
procedure TSpkCollection.ReadNames(Reader: TReader);
|
||||
begin
|
||||
Reader.ReadListBegin;
|
||||
FNames.Clear;
|
||||
while not(Reader.EndOfList) do
|
||||
FNames.Add(Reader.ReadString);
|
||||
Reader.ReadListEnd;
|
||||
FListState := lsNeedsProcessing;
|
||||
end;
|
||||
|
||||
procedure TSpkCollection.Remove(Item: TComponent);
|
||||
var
|
||||
i: integer;
|
||||
begin
|
||||
i := FList.IndexOf(Item);
|
||||
if i >= 0 then
|
||||
begin
|
||||
Notify(Item, opRemove);
|
||||
FList.Delete(i);
|
||||
Update;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TSpkCollection.RemoveReference(Item: TComponent);
|
||||
var
|
||||
i: integer;
|
||||
begin
|
||||
i := FList.IndexOf(Item);
|
||||
if i >= 0 then
|
||||
begin
|
||||
Notify(Item, opRemove);
|
||||
FList.Extract(Item);
|
||||
Update;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TSpkCollection.Update;
|
||||
begin
|
||||
//
|
||||
end;
|
||||
|
||||
procedure TSpkCollection.WriteNames(Writer: TWriter);
|
||||
var
|
||||
i: Integer;
|
||||
begin
|
||||
Writer.WriteListBegin;
|
||||
for i := 0 to FList.Count - 1 do
|
||||
Writer.WriteString(TComponent(FList[i]).Name);
|
||||
Writer.WriteListEnd;
|
||||
end;
|
||||
|
||||
|
||||
{ TSpkComponent }
|
||||
|
||||
function TSpkComponent.GetParentComponent: TComponent;
|
||||
begin
|
||||
Result := FParent;
|
||||
end;
|
||||
|
||||
function TSpkComponent.HasParent: boolean;
|
||||
begin
|
||||
Result := (FParent <> nil);
|
||||
end;
|
||||
|
||||
procedure TSpkComponent.SetParentComponent(Value: TComponent);
|
||||
begin
|
||||
FParent := Value;
|
||||
end;
|
||||
|
||||
end.
|
564
spktoolbar/SpkXML/SpkXMLIni.pas
Normal file
@@ -0,0 +1,564 @@
|
||||
unit SpkXMLIni;
|
||||
|
||||
{$mode ObjFpc}
|
||||
{$H+}
|
||||
|
||||
{$DEFINE SPKXMLINI}
|
||||
|
||||
interface
|
||||
|
||||
uses SpkXMLParser, classes, sysutils;
|
||||
|
||||
type TSpkXMLIni = class(TObject)
|
||||
private
|
||||
FParser : TSpkXMLParser;
|
||||
FAutoConvert : boolean;
|
||||
protected
|
||||
public
|
||||
constructor Create; overload;
|
||||
constructor Create(filename : string); overload;
|
||||
destructor Destroy; override;
|
||||
procedure LoadFromFile(filename : string);
|
||||
procedure SaveToFile(filename : string);
|
||||
procedure SaveToStream(AStream : TStream);
|
||||
procedure LoadFromStream(AStream : TStream);
|
||||
procedure Clear;
|
||||
procedure DeleteKey(const Section, Ident: string);
|
||||
procedure EraseSection(const Section: string);
|
||||
function ReadString(const Section, Ident, Default: string): string;
|
||||
procedure WriteString(const Section, Ident, Value: string);
|
||||
function ReadBool (const Section, Ident: String; Default: Boolean): Boolean;
|
||||
function ReadDate (const Section, Ident: string; Default: TDateTime): TDateTime;
|
||||
function ReadDateTime (const Section, Ident: String; Default: TDateTime): TDateTime;
|
||||
function ReadFloat (const Section, Ident: String; Default: Double): Double;
|
||||
function ReadInteger(const Section, Ident: String; Default: Longint): Longint;
|
||||
function ReadTime (const Section, Ident: String; Default: TDateTime): TDateTime;
|
||||
function SectionExists (const Section: String): Boolean;
|
||||
procedure WriteBool(const Section, Ident: String; Value: Boolean);
|
||||
procedure WriteDate(const Section, Ident: String; Value: TDateTime);
|
||||
procedure WriteDateTime(const Section, Ident: String; Value: TDateTime);
|
||||
procedure WriteFloat(const Section, Ident: String; Value: Double);
|
||||
procedure WriteInteger(const Section, Ident: String; Value: Longint);
|
||||
procedure WriteTime(const Section, Ident: String; Value: TDateTime);
|
||||
function ValueExists(const section, ident : string) : boolean;
|
||||
procedure WriteStrings(const Section, Ident : String; Value : TStrings);
|
||||
procedure ReadStrings(const Section, Ident : String; Target : TStrings);
|
||||
procedure ReadSection (const Section: string; Strings: TStrings);
|
||||
procedure ReadSections(Strings: TStrings);
|
||||
procedure ReadSectionValues(const Section: string; Strings: TStrings);
|
||||
|
||||
property AutoConvert : boolean read FAutoConvert write FAutoConvert;
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
{ TSpkXMLIni }
|
||||
|
||||
constructor TSpkXMLIni.create;
|
||||
|
||||
begin
|
||||
inherited create;
|
||||
FParser:=TSpkXMLParser.create;
|
||||
FAutoConvert:=true;
|
||||
end;
|
||||
|
||||
constructor TSpkXMLIni.create(filename : string);
|
||||
|
||||
begin
|
||||
inherited create;
|
||||
self.LoadFromFile(filename);
|
||||
end;
|
||||
|
||||
destructor TSpkXMLIni.destroy;
|
||||
|
||||
begin
|
||||
FParser.free;
|
||||
inherited;
|
||||
end;
|
||||
|
||||
procedure TSpkXMLIni.LoadFromFile(filename : string);
|
||||
|
||||
begin
|
||||
try
|
||||
FParser.LoadFromFile(filename);
|
||||
except
|
||||
self.clear;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TSpkXMLIni.LoadFromStream(AStream: TStream);
|
||||
begin
|
||||
FParser.LoadFromStream(AStream);
|
||||
end;
|
||||
|
||||
procedure TSpkXMLIni.SaveToFile(filename : string);
|
||||
|
||||
begin
|
||||
FParser.SaveToFile(filename);
|
||||
end;
|
||||
|
||||
procedure TSpkXMLIni.SaveToStream(AStream: TStream);
|
||||
begin
|
||||
FParser.SaveToStream(AStream);
|
||||
end;
|
||||
|
||||
procedure TSpkXMLIni.Clear;
|
||||
|
||||
begin
|
||||
FParser.Clear;
|
||||
end;
|
||||
|
||||
procedure TSpkXMLIni.DeleteKey(const Section, Ident: string);
|
||||
|
||||
var node : TSpkXMLNode;
|
||||
subnode : TSpkXMLNode;
|
||||
|
||||
begin
|
||||
node:=FParser.NodeByName[Section,false];
|
||||
if node<>nil then
|
||||
begin
|
||||
subnode:=node.NodeByName[Ident,false];
|
||||
if subnode<>nil then
|
||||
begin
|
||||
node.delete(node.IndexOf(subnode));
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TSpkXMLIni.EraseSection(const Section: string);
|
||||
|
||||
var node : TSpkXMLNode;
|
||||
|
||||
begin
|
||||
node:=FParser.NodeByName[Section,false];
|
||||
if node<>nil then
|
||||
Fparser.Delete(FParser.IndexOf(node));
|
||||
end;
|
||||
|
||||
function TSpkXMLIni.ReadString(const Section, Ident, Default: string): string;
|
||||
|
||||
var node, subnode : TSpkXMLNode;
|
||||
|
||||
begin
|
||||
node:=FParser.NodeByName[Section,false];
|
||||
if node=nil then result:=Default else
|
||||
begin
|
||||
subnode:=node.NodeByName[Ident,false];
|
||||
if subnode=nil then result:=Default else
|
||||
begin
|
||||
if subnode.Parameters.ParamByName['type',false]<>nil then
|
||||
begin
|
||||
if uppercase(subnode.Parameters.ParamByName['type',false].Value)='STRING' then
|
||||
result:=subnode.text else
|
||||
begin
|
||||
if FAutoConvert then
|
||||
try
|
||||
result:=subnode.text;
|
||||
except
|
||||
result:=Default;
|
||||
end else raise exception.create('Invalid object type!');
|
||||
end;
|
||||
end else result:=subnode.Text;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TSpkXMLIni.WriteString(const Section, Ident, Value: string);
|
||||
|
||||
begin
|
||||
self.DeleteKey(Section,Ident);
|
||||
FParser.NodeByName[Section,true].NodeByName[Ident,true].Parameters.ParamByName['type',true].value:='string';
|
||||
FParser.NodeByName[Section,true].NodeByName[Ident,true].Text:=Value;
|
||||
end;
|
||||
|
||||
function TSpkXMLIni.ReadBool (const Section, Ident: String; Default: Boolean): Boolean;
|
||||
|
||||
var node, subnode : TSpkXMLNode;
|
||||
|
||||
begin
|
||||
node:=FParser.NodeByName[Section,false];
|
||||
if node=nil then result:=Default else
|
||||
begin
|
||||
subnode:=node.NodeByName[Ident,false];
|
||||
if subnode=nil then result:=Default else
|
||||
begin
|
||||
if subnode.Parameters.ParamByName['type',false]<>nil then
|
||||
begin
|
||||
if uppercase(subnode.Parameters.ParamByName['type',false].Value)='BOOLEAN' then
|
||||
begin
|
||||
if (uppercase(subnode.text)='TRUE') or (subnode.text='1') then result:=true else result:=false;
|
||||
end else
|
||||
begin
|
||||
if FAutoConvert then
|
||||
try
|
||||
if (uppercase(subnode.text)='TRUE') or (subnode.text='1') then result:=true else result:=false;
|
||||
except
|
||||
result:=Default;
|
||||
end else raise exception.create('Invalid object type!');
|
||||
end;
|
||||
end else
|
||||
try
|
||||
if (uppercase(subnode.text)='TRUE') or (subnode.text='1') then result:=true else result:=false;
|
||||
except
|
||||
result:=Default;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
function TSpkXMLIni.ReadDate (const Section, Ident: string; Default: TDateTime): TDateTime;
|
||||
|
||||
var node, subnode : TSpkXMLNode;
|
||||
|
||||
begin
|
||||
node:=FParser.NodeByName[Section,false];
|
||||
if node=nil then result:=Default else
|
||||
begin
|
||||
subnode:=node.NodeByName[Ident,false];
|
||||
if subnode=nil then result:=Default else
|
||||
begin
|
||||
if subnode.Parameters.ParamByName['type',false]<>nil then
|
||||
begin
|
||||
if uppercase(subnode.Parameters.ParamByName['type',false].Value)='DATE' then
|
||||
begin
|
||||
try
|
||||
result:=StrToDate(subnode.text);
|
||||
except
|
||||
result:=Default;
|
||||
end;
|
||||
end else
|
||||
begin
|
||||
if FAutoConvert then
|
||||
try
|
||||
result:=StrToDate(subnode.text);
|
||||
except
|
||||
result:=Default;
|
||||
end else raise exception.create('Invalid object type!');
|
||||
end;
|
||||
end else
|
||||
try
|
||||
result:=StrToDate(subnode.text);
|
||||
except
|
||||
result:=Default;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
function TSpkXMLIni.ReadDateTime (const Section, Ident: String; Default: TDateTime): TDateTime;
|
||||
|
||||
var node, subnode : TSpkXMLNode;
|
||||
|
||||
begin
|
||||
node:=FParser.NodeByName[Section,false];
|
||||
if node=nil then result:=Default else
|
||||
begin
|
||||
subnode:=node.NodeByName[Ident,false];
|
||||
if subnode=nil then result:=Default else
|
||||
begin
|
||||
if subnode.Parameters.ParamByName['type',false]<>nil then
|
||||
begin
|
||||
if uppercase(subnode.Parameters.ParamByName['type',false].Value)='DATETIME' then
|
||||
begin
|
||||
try
|
||||
result:=StrToDateTime(subnode.text);
|
||||
except
|
||||
result:=Default;
|
||||
end;
|
||||
end else
|
||||
begin
|
||||
if FAutoConvert then
|
||||
try
|
||||
result:=StrToDateTime(subnode.text);
|
||||
except
|
||||
result:=Default;
|
||||
end else raise exception.create('Invalid object type!');
|
||||
end;
|
||||
end else
|
||||
try
|
||||
result:=StrToDateTime(subnode.text);
|
||||
except
|
||||
result:=Default;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
function TSpkXMLIni.ReadFloat (const Section, Ident: String; Default: Double): Double;
|
||||
|
||||
var node, subnode : TSpkXMLNode;
|
||||
|
||||
begin
|
||||
node:=FParser.NodeByName[Section,false];
|
||||
if node=nil then result:=Default else
|
||||
begin
|
||||
subnode:=node.NodeByName[Ident,false];
|
||||
if subnode=nil then result:=Default else
|
||||
begin
|
||||
if subnode.Parameters.ParamByName['type',false]<>nil then
|
||||
begin
|
||||
if uppercase(subnode.Parameters.ParamByName['type',false].Value)='FLOAT' then
|
||||
begin
|
||||
try
|
||||
result:=StrToFloat(subnode.text);
|
||||
except
|
||||
result:=Default;
|
||||
end;
|
||||
end else
|
||||
begin
|
||||
if FAutoConvert then
|
||||
try
|
||||
result:=StrToFloat(subnode.text);
|
||||
except
|
||||
result:=Default;
|
||||
end else raise exception.create('Invalid object type!');
|
||||
end;
|
||||
end else
|
||||
try
|
||||
result:=StrToFloat(subnode.text);
|
||||
except
|
||||
result:=Default;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
function TSpkXMLIni.ReadInteger(const Section, Ident: String; Default: Longint): Longint;
|
||||
|
||||
var node, subnode : TSpkXMLNode;
|
||||
|
||||
begin
|
||||
node:=FParser.NodeByName[Section,false];
|
||||
if node=nil then result:=Default else
|
||||
begin
|
||||
subnode:=node.NodeByName[Ident,false];
|
||||
if subnode=nil then result:=Default else
|
||||
begin
|
||||
if subnode.Parameters.ParamByName['type',false]<>nil then
|
||||
begin
|
||||
if uppercase(subnode.Parameters.ParamByName['type',false].Value)='FLOAT' then
|
||||
begin
|
||||
try
|
||||
result:=StrToInt(subnode.text);
|
||||
except
|
||||
result:=Default;
|
||||
end;
|
||||
end else
|
||||
begin
|
||||
if FAutoConvert then
|
||||
try
|
||||
result:=StrToInt(subnode.text);
|
||||
except
|
||||
result:=Default;
|
||||
end else raise exception.create('Invalid object type!');
|
||||
end;
|
||||
end else
|
||||
try
|
||||
result:=StrToInt(subnode.text);
|
||||
except
|
||||
result:=Default;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
function TSpkXMLIni.ReadTime (const Section, Ident: String; Default: TDateTime): TDateTime;
|
||||
|
||||
var node, subnode : TSpkXMLNode;
|
||||
|
||||
begin
|
||||
node:=FParser.NodeByName[Section,false];
|
||||
if node=nil then result:=Default else
|
||||
begin
|
||||
subnode:=node.NodeByName[Ident,false];
|
||||
if subnode=nil then result:=Default else
|
||||
begin
|
||||
if subnode.Parameters.ParamByName['type',false]<>nil then
|
||||
begin
|
||||
if uppercase(subnode.Parameters.ParamByName['type',false].Value)='TIME' then
|
||||
begin
|
||||
try
|
||||
result:=StrToTime(subnode.text);
|
||||
except
|
||||
result:=Default;
|
||||
end;
|
||||
end else
|
||||
begin
|
||||
if FAutoConvert then
|
||||
try
|
||||
result:=StrToTime(subnode.text);
|
||||
except
|
||||
result:=Default;
|
||||
end else raise exception.create('Invalid object type!');
|
||||
end;
|
||||
end else
|
||||
try
|
||||
result:=StrToTime(subnode.text);
|
||||
except
|
||||
result:=Default;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
function TSpkXMLIni.SectionExists (const Section: String): Boolean;
|
||||
|
||||
begin
|
||||
result:=FParser.NodeByName[Section,false]<>nil;
|
||||
end;
|
||||
|
||||
procedure TSpkXMLIni.WriteBool(const Section, Ident: String; Value: Boolean);
|
||||
|
||||
begin
|
||||
self.DeleteKey(Section,Ident);
|
||||
FParser.NodeByName[Section,true].NodeByName[Ident,true].Parameters.ParamByName['type',true].Value:='boolean';
|
||||
if Value then FParser.NodeByName[Section,true].NodeByName[Ident,true].Text:='true' else
|
||||
FParser.NodeByName[Section,true].NodeByName[Ident,true].text:='false';
|
||||
end;
|
||||
|
||||
procedure TSpkXMLIni.WriteDate(const Section, Ident: String; Value: TDateTime);
|
||||
|
||||
begin
|
||||
self.DeleteKey(Section,Ident);
|
||||
FParser.NodeByName[Section,true].NodeByName[Ident,true].Parameters.ParamByName['type',true].Value:='date';
|
||||
FParser.NodeByName[Section,true].NodeByName[Ident,true].Text:=DateToStr(Value);
|
||||
end;
|
||||
|
||||
procedure TSpkXMLIni.WriteDateTime(const Section, Ident: String; Value: TDateTime);
|
||||
|
||||
begin
|
||||
self.DeleteKey(Section,Ident);
|
||||
FParser.NodeByName[Section,true].NodeByName[Ident,true].Parameters.ParamByName['type',true].Value:='datetime';
|
||||
FParser.NodeByName[Section,true].NodeByName[Ident,true].Text:=DateTimeToStr(Value);
|
||||
end;
|
||||
|
||||
procedure TSpkXMLIni.WriteFloat(const Section, Ident: String; Value: Double);
|
||||
|
||||
begin
|
||||
self.DeleteKey(Section,Ident);
|
||||
FParser.NodeByName[Section,true].NodeByName[Ident,true].Parameters.ParamByName['type',true].Value:='float';
|
||||
FParser.NodeByName[Section,true].NodeByName[Ident,true].Text:=FloatToStr(Value);
|
||||
end;
|
||||
|
||||
procedure TSpkXMLIni.WriteInteger(const Section, Ident: String; Value: Longint);
|
||||
|
||||
begin
|
||||
self.DeleteKey(Section,Ident);
|
||||
FParser.NodeByName[Section,true].NodeByName[Ident,true].Parameters.ParamByName['type',true].Value:='integer';
|
||||
FParser.NodeByName[Section,true].NodeByName[Ident,true].Text:=IntToStr(Value);
|
||||
end;
|
||||
|
||||
procedure TSpkXMLIni.WriteTime(const Section, Ident: String; Value: TDateTime);
|
||||
|
||||
begin
|
||||
self.DeleteKey(Section,Ident);
|
||||
FParser.NodeByName[Section,true].NodeByName[Ident,true].Parameters.ParamByName['type',true].Value:='time';
|
||||
FParser.NodeByName[Section,true].NodeByName[Ident,true].Text:=TimeToStr(Value);
|
||||
end;
|
||||
|
||||
function TSpkXMLIni.ValueExists(const section, ident : string) : boolean;
|
||||
|
||||
begin
|
||||
result:=FParser.NodeByName[section,false]<>nil;
|
||||
if result then
|
||||
result:=result and (FParser.NodeByName[section,false].NodeByName[ident,false]<>nil);
|
||||
end;
|
||||
|
||||
procedure TSpkXMLIni.WriteStrings(const Section, Ident : String; Value : TStrings);
|
||||
|
||||
var node,subnode : TSpkXMLNode;
|
||||
i : integer;
|
||||
|
||||
begin
|
||||
self.DeleteKey(Section,Ident);
|
||||
node:=FParser.NodeByName[Section,true];
|
||||
subnode:=node.NodeByName[ident,true];
|
||||
subnode.Parameters.ParamByName['type',true].value:='strings';
|
||||
subnode.parameters.parambyname['count',true].value:=IntToStr(Value.count);
|
||||
for i:=0 to value.count-1 do
|
||||
begin
|
||||
subnode.NodeByName['line'+IntToStr(i),true].text:=Value[i];
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TSpkXMLIni.ReadStrings(const Section, Ident : String; Target : TStrings);
|
||||
|
||||
var node, subnode, line : TSpkXMLNode;
|
||||
i,count : integer;
|
||||
|
||||
begin
|
||||
target.clear;
|
||||
|
||||
node:=FParser.NodeByName[Section,false];
|
||||
if node=nil then exit;
|
||||
|
||||
subnode:=node.NodeByName[ident,false];
|
||||
if subnode=nil then exit;
|
||||
|
||||
if subnode.Parameters.ParamByName['type',false]=nil then exit;
|
||||
if uppercase(subnode.Parameters.ParamByName['type',false].value)<>'STRINGS' then exit;
|
||||
|
||||
if subnode.parameters.parambyname['count',false]=nil then exit;
|
||||
|
||||
try
|
||||
count:=StrToInt(subnode.parameters.parambyname['count',false].Value);
|
||||
except
|
||||
exit
|
||||
end;
|
||||
|
||||
for i:=0 to count-1 do
|
||||
begin
|
||||
line:=subnode.NodeByName['line'+IntToStr(i),false];
|
||||
if line=nil then
|
||||
begin
|
||||
target.Clear;
|
||||
exit;
|
||||
end;
|
||||
target.Add(line.Text);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TSpkXMLIni.ReadSection(const Section: string; Strings: TStrings);
|
||||
|
||||
var i : integer;
|
||||
node : TSpkXMLNode;
|
||||
|
||||
begin
|
||||
if FParser.NodeByName[Section,false]=nil then exit;
|
||||
node:=FParser.NodeByName[Section,false];
|
||||
if node.Count=0 then exit;
|
||||
for i:=0 to node.Count-1 do
|
||||
Strings.Add(node.NodeByIndex[i].Name);
|
||||
end;
|
||||
|
||||
procedure TSpkXMLIni.ReadSections(Strings: TStrings);
|
||||
|
||||
var i : integer;
|
||||
|
||||
begin
|
||||
if FParser.count=0 then exit;
|
||||
for i:=0 to FParser.count-1 do
|
||||
Strings.add(FParser.NodeByIndex[i].Name);
|
||||
end;
|
||||
|
||||
procedure TSpkXMLIni.ReadSectionValues(const Section: string; Strings: TStrings);
|
||||
|
||||
var i : integer;
|
||||
node : TSpkXMLNode;
|
||||
|
||||
begin
|
||||
if FParser.NodeByName[Section,false]=nil then exit;
|
||||
node:=FParser.NodeByName[Section,false];
|
||||
if node.Count=0 then exit;
|
||||
for i:=0 to node.count-1 do
|
||||
begin
|
||||
{$I-}
|
||||
if (node.NodeByIndex[i].Parameters.ParamByName['type',false]<>nil) and
|
||||
(uppercase(node.NodeByIndex[i].Parameters.ParamByName['type',false].Value)='STRINGS') then
|
||||
Strings.add('[TStrings]')
|
||||
else
|
||||
Strings.add(node.NodeByIndex[i].Text);
|
||||
end;
|
||||
end;
|
||||
|
||||
end.
|
2034
spktoolbar/SpkXML/SpkXMLParser.pas
Normal file
119
spktoolbar/SpkXML/SpkXMLTools.pas
Normal file
@@ -0,0 +1,119 @@
|
||||
unit SpkXMLTools;
|
||||
|
||||
{$mode ObjFpc}
|
||||
{$H+}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Graphics, SysUtils, SpkXMLParser;
|
||||
|
||||
type TSpkXMLTools = class
|
||||
private
|
||||
protected
|
||||
public
|
||||
class procedure Save(Node : TSpkXMLNode; Font : TFont); overload;
|
||||
class procedure Load(Node : TSpkXMLNode; Font : TFont); overload;
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
{ TXMLTools }
|
||||
|
||||
class procedure TSpkXMLTools.Load(Node: TSpkXMLNode; Font: TFont);
|
||||
|
||||
var Subnode, Subnode2 : TSpkXMLNode;
|
||||
|
||||
begin
|
||||
if not(assigned(Node)) then
|
||||
raise exception.create('TSpkXMLTools.Load: Nieprawid<69>owa ga<67><61><EFBFBD> XML!');
|
||||
if not(assigned(Font)) then
|
||||
raise exception.create('TSpkXMLTools.Load: Brak obiektu czcionki do wczytania!');
|
||||
|
||||
Subnode:=Node['Charset',false];
|
||||
if assigned(Subnode) then
|
||||
Font.Charset:=TFontCharset(Subnode.TextAsInteger);
|
||||
|
||||
Subnode:=Node['Color',false];
|
||||
if assigned(Subnode) then
|
||||
Font.Color:=Subnode.TextAsInteger;
|
||||
|
||||
Subnode:=Node['Name',false];
|
||||
if assigned(Subnode) then
|
||||
Font.Name:=Subnode.Text;
|
||||
|
||||
Subnode:=Node['Orientation',false];
|
||||
if assigned(Subnode) then
|
||||
Font.Orientation:=Subnode.TextAsInteger;
|
||||
|
||||
Subnode:=Node['Pitch',false];
|
||||
if assigned(Subnode) then
|
||||
Font.Pitch:=TFontPitch(Subnode.TextAsInteger);
|
||||
|
||||
Subnode:=Node['Size',false];
|
||||
if assigned(Subnode) then
|
||||
Font.Size:=Subnode.TextAsInteger;
|
||||
|
||||
Subnode:=Node['Style',false];
|
||||
if assigned(Subnode) then
|
||||
begin
|
||||
Subnode2:=Subnode['Bold',false];
|
||||
if assigned(Subnode2) then
|
||||
if Subnode2.TextAsBoolean then
|
||||
Font.Style:=Font.Style + [fsBold] else
|
||||
Font.Style:=Font.Style - [fsBold];
|
||||
|
||||
Subnode2:=Subnode['Italic',false];
|
||||
if assigned(Subnode2) then
|
||||
if Subnode2.TextAsBoolean then
|
||||
Font.Style:=Font.Style + [fsItalic] else
|
||||
Font.Style:=Font.Style - [fsItalic];
|
||||
|
||||
Subnode2:=Subnode['Underline',false];
|
||||
if assigned(Subnode2) then
|
||||
if Subnode2.TextAsBoolean then
|
||||
Font.Style:=Font.Style + [fsUnderline] else
|
||||
Font.Style:=Font.Style - [fsUnderline];
|
||||
end;
|
||||
end;
|
||||
|
||||
class procedure TSpkXMLTools.Save(Node: TSpkXMLNode; Font: TFont);
|
||||
|
||||
var Subnode, Subnode2 : TSpkXMLNode;
|
||||
|
||||
begin
|
||||
if not(assigned(Node)) then
|
||||
raise exception.create('TSpkXMLTools.Save: Nieprawid<69>owa ga<67><61><EFBFBD> XML!');
|
||||
if not(assigned(Font)) then
|
||||
raise exception.create('TSpkXMLTools.Save: Brak obiektu czcionki do zapisania!');
|
||||
|
||||
Subnode:=Node['Charset',true];
|
||||
Subnode.TextAsInteger:=Font.Charset;
|
||||
|
||||
Subnode:=Node['Color',true];
|
||||
Subnode.TextAsInteger:=Font.Color;
|
||||
|
||||
Subnode:=Node['Name',true];
|
||||
Subnode.Text:=Font.Name;
|
||||
|
||||
Subnode:=Node['Orientation',true];
|
||||
Subnode.TextAsInteger:=Font.Orientation;
|
||||
|
||||
Subnode:=Node['Pitch',true];
|
||||
Subnode.TextAsInteger:=ord(Font.Pitch);
|
||||
|
||||
Subnode:=Node['Size',true];
|
||||
Subnode.TextAsInteger:=Font.Size;
|
||||
|
||||
Subnode:=Node['Style',true];
|
||||
Subnode2:=Subnode['Bold',true];
|
||||
Subnode2.TextAsBoolean:=fsBold in Font.Style;
|
||||
|
||||
Subnode2:=Subnode['Italic',true];
|
||||
Subnode2.TextAsBoolean:=fsItalic in Font.Style;
|
||||
|
||||
Subnode2:=Subnode['Underline',true];
|
||||
Subnode2.TextAsBoolean:=fsUnderline in Font.Style;
|
||||
end;
|
||||
|
||||
end.
|
103
spktoolbar/demos/actions/project1.lpi
Normal file
@@ -0,0 +1,103 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<CONFIG>
|
||||
<ProjectOptions>
|
||||
<Version Value="11"/>
|
||||
<PathDelim Value="\"/>
|
||||
<General>
|
||||
<SessionStorage Value="InProjectDir"/>
|
||||
<MainUnit Value="0"/>
|
||||
<Title Value="project1"/>
|
||||
<Scaled Value="True"/>
|
||||
<ResourceType Value="res"/>
|
||||
<UseXPManifest Value="True"/>
|
||||
<XPManifest>
|
||||
<DpiAware Value="True"/>
|
||||
</XPManifest>
|
||||
</General>
|
||||
<i18n>
|
||||
<EnableI18N LFM="False"/>
|
||||
</i18n>
|
||||
<BuildModes Count="1">
|
||||
<Item1 Name="Default" Default="True"/>
|
||||
</BuildModes>
|
||||
<PublishOptions>
|
||||
<Version Value="2"/>
|
||||
<IncludeFileFilter Value="*.(pas|pp|inc|lfm|lpr|lrs|lpi|lpk|sh|xml)"/>
|
||||
<ExcludeFileFilter Value="*.(bak|ppu|o|so);*~;backup"/>
|
||||
</PublishOptions>
|
||||
<RunParams>
|
||||
<FormatVersion Value="2"/>
|
||||
<Modes Count="1">
|
||||
<Mode0 Name="default"/>
|
||||
</Modes>
|
||||
</RunParams>
|
||||
<RequiredPackages Count="2">
|
||||
<Item1>
|
||||
<PackageName Value="SpkToolbarPackage"/>
|
||||
</Item1>
|
||||
<Item2>
|
||||
<PackageName Value="LCL"/>
|
||||
</Item2>
|
||||
</RequiredPackages>
|
||||
<Units Count="3">
|
||||
<Unit0>
|
||||
<Filename Value="project1.lpr"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
</Unit0>
|
||||
<Unit1>
|
||||
<Filename Value="unit1.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<ComponentName Value="Form1"/>
|
||||
<HasResources Value="True"/>
|
||||
<ResourceBaseClass Value="Form"/>
|
||||
<UnitName Value="Unit1"/>
|
||||
</Unit1>
|
||||
<Unit2>
|
||||
<Filename Value="unit2.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<ComponentName Value="AboutForm"/>
|
||||
<HasResources Value="True"/>
|
||||
<ResourceBaseClass Value="Form"/>
|
||||
<UnitName Value="Unit2"/>
|
||||
</Unit2>
|
||||
</Units>
|
||||
</ProjectOptions>
|
||||
<CompilerOptions>
|
||||
<Version Value="11"/>
|
||||
<PathDelim Value="\"/>
|
||||
<Target>
|
||||
<Filename Value="bin\project1"/>
|
||||
</Target>
|
||||
<SearchPaths>
|
||||
<IncludeFiles Value="$(ProjOutDir)"/>
|
||||
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
|
||||
</SearchPaths>
|
||||
<CodeGeneration>
|
||||
<SmartLinkUnit Value="True"/>
|
||||
</CodeGeneration>
|
||||
<Linking>
|
||||
<Debugging>
|
||||
<UseExternalDbgSyms Value="True"/>
|
||||
</Debugging>
|
||||
<LinkSmart Value="True"/>
|
||||
<Options>
|
||||
<Win32>
|
||||
<GraphicApplication Value="True"/>
|
||||
</Win32>
|
||||
</Options>
|
||||
</Linking>
|
||||
</CompilerOptions>
|
||||
<Debugging>
|
||||
<Exceptions Count="3">
|
||||
<Item1>
|
||||
<Name Value="EAbort"/>
|
||||
</Item1>
|
||||
<Item2>
|
||||
<Name Value="ECodetoolError"/>
|
||||
</Item2>
|
||||
<Item3>
|
||||
<Name Value="EFOpenError"/>
|
||||
</Item3>
|
||||
</Exceptions>
|
||||
</Debugging>
|
||||
</CONFIG>
|
24
spktoolbar/demos/actions/project1.lpr
Normal file
@@ -0,0 +1,24 @@
|
||||
program project1;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
uses
|
||||
{$IFDEF UNIX}{$IFDEF UseCThreads}
|
||||
cthreads,
|
||||
{$ENDIF}{$ENDIF}
|
||||
Interfaces, // this includes the LCL widgetset
|
||||
LCLVersion, Forms, Unit1, Unit2
|
||||
{ you can add units after this };
|
||||
|
||||
{$R *.res}
|
||||
|
||||
begin
|
||||
{$IF LCL_FullVersion >= 1080000}
|
||||
Application.Scaled:=True;
|
||||
{$ENDIF}
|
||||
RequireDerivedFormResource := True;
|
||||
Application.Initialize;
|
||||
Application.CreateForm(TForm1, Form1);
|
||||
Application.Run;
|
||||
end.
|
||||
|
2251
spktoolbar/demos/actions/unit1.lfm
Normal file
337
spktoolbar/demos/actions/unit1.pas
Normal file
@@ -0,0 +1,337 @@
|
||||
unit Unit1;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ActnList,
|
||||
StdActns, StdCtrls, Menus, ComCtrls, ExtCtrls,
|
||||
SpkToolbar, spkt_Buttons, spkt_Checkboxes, spkt_Pane, spkt_Tab, spkt_Appearance;
|
||||
|
||||
type
|
||||
|
||||
{ TForm1 }
|
||||
|
||||
TForm1 = class(TForm)
|
||||
AcOpen: TAction;
|
||||
AcClassicalGUI: TAction;
|
||||
AcRibbonGUI: TAction;
|
||||
AcSave: TAction;
|
||||
AcQuit: TAction;
|
||||
AcAutoSave: TAction;
|
||||
AcSaveNow: TAction;
|
||||
AcBold: TAction;
|
||||
AcItalic: TAction;
|
||||
AcLeftJustify: TAction;
|
||||
AcCenter: TAction;
|
||||
AcRightJustify: TAction;
|
||||
AcAbout: TAction;
|
||||
AcUnderline: TAction;
|
||||
ActionList: TActionList;
|
||||
AcEditCopy: TEditCopy;
|
||||
AcEditCut: TEditCut;
|
||||
AcEditPaste: TEditPaste;
|
||||
ImageList: TImageList;
|
||||
Label1: TLabel;
|
||||
LargeImageList: TImageList;
|
||||
MainMenu: TMainMenu;
|
||||
MenuItem1: TMenuItem;
|
||||
MenuItem10: TMenuItem;
|
||||
MenuItem11: TMenuItem;
|
||||
MenuItem12: TMenuItem;
|
||||
MenuItem13: TMenuItem;
|
||||
MenuItem14: TMenuItem;
|
||||
MenuItem15: TMenuItem;
|
||||
MenuItem16: TMenuItem;
|
||||
MenuItem17: TMenuItem;
|
||||
MenuItem18: TMenuItem;
|
||||
MenuItem19: TMenuItem;
|
||||
MenuItem2: TMenuItem;
|
||||
MenuItem20: TMenuItem;
|
||||
MenuItem21: TMenuItem;
|
||||
MenuItem22: TMenuItem;
|
||||
MenuItem23: TMenuItem;
|
||||
MenuItem24: TMenuItem;
|
||||
MenuItem25: TMenuItem;
|
||||
MenuItem26: TMenuItem;
|
||||
MenuItem27: TMenuItem;
|
||||
MenuItem28: TMenuItem;
|
||||
MenuItem29: TMenuItem;
|
||||
MenuItem3: TMenuItem;
|
||||
MenuItem30: TMenuItem;
|
||||
MenuItem31: TMenuItem;
|
||||
MenuItem4: TMenuItem;
|
||||
MenuItem5: TMenuItem;
|
||||
MenuItem6: TMenuItem;
|
||||
MenuItem7: TMenuItem;
|
||||
MenuItem8: TMenuItem;
|
||||
MenuItem9: TMenuItem;
|
||||
Panel1: TPanel;
|
||||
SpkLargeButton4: TSpkLargeButton;
|
||||
SpkPane2: TSpkPane;
|
||||
SpkPane4: TSpkPane;
|
||||
SpkSmallButton10: TSpkSmallButton;
|
||||
SpkSmallButton11: TSpkSmallButton;
|
||||
SpkSmallButton4: TSpkSmallButton;
|
||||
SpkSmallButton6: TSpkSmallButton;
|
||||
SpkSmallButton8: TSpkSmallButton;
|
||||
SpkSmallButton9: TSpkSmallButton;
|
||||
SpkTab4: TSpkTab;
|
||||
SpkTab5: TSpkTab;
|
||||
StyleMenu: TPopupMenu;
|
||||
SpkCheckbox1: TSpkCheckbox;
|
||||
SpkLargeButton1: TSpkLargeButton;
|
||||
SpkLargeButton2: TSpkLargeButton;
|
||||
SpkLargeButton3: TSpkLargeButton;
|
||||
SpkPane1: TSpkPane;
|
||||
SpkPane3: TSpkPane;
|
||||
SpkPane5: TSpkPane;
|
||||
SpkPane6: TSpkPane;
|
||||
SpkRadioButton1: TSpkRadioButton;
|
||||
SpkRadioButton2: TSpkRadioButton;
|
||||
SpkSmallButton1: TSpkSmallButton;
|
||||
SpkSmallButton2: TSpkSmallButton;
|
||||
SpkSmallButton3: TSpkSmallButton;
|
||||
SpkSmallButton5: TSpkSmallButton;
|
||||
SpkSmallButton7: TSpkSmallButton;
|
||||
SpkTab1: TSpkTab;
|
||||
SpkTab2: TSpkTab;
|
||||
SpkTab3: TSpkTab;
|
||||
SpkToolbar1: TSpkToolbar;
|
||||
ToolBar1: TToolBar;
|
||||
ToolButton1: TToolButton;
|
||||
ToolButton10: TToolButton;
|
||||
ToolButton11: TToolButton;
|
||||
ToolButton12: TToolButton;
|
||||
ToolButton13: TToolButton;
|
||||
ToolButton14: TToolButton;
|
||||
ToolButton15: TToolButton;
|
||||
ToolButton2: TToolButton;
|
||||
ToolButton3: TToolButton;
|
||||
ToolButton4: TToolButton;
|
||||
ToolButton5: TToolButton;
|
||||
ToolButton6: TToolButton;
|
||||
ToolButton7: TToolButton;
|
||||
ToolButton8: TToolButton;
|
||||
ToolButton9: TToolButton;
|
||||
procedure AcAboutExecute(Sender: TObject);
|
||||
procedure AcAutoSaveExecute(Sender: TObject);
|
||||
procedure AcBoldExecute(Sender: TObject);
|
||||
procedure AcCenterExecute(Sender: TObject);
|
||||
procedure AcClassicalGUIExecute(Sender: TObject);
|
||||
procedure AcEditCopyExecute(Sender: TObject);
|
||||
procedure AcEditCutExecute(Sender: TObject);
|
||||
procedure AcEditPasteExecute(Sender: TObject);
|
||||
procedure AcItalicExecute(Sender: TObject);
|
||||
procedure AcLeftJustifyExecute(Sender: TObject);
|
||||
procedure AcOpenExecute(Sender: TObject);
|
||||
procedure AcQuitExecute(Sender: TObject);
|
||||
procedure AcRibbonGUIExecute(Sender: TObject);
|
||||
procedure AcRightJustifyExecute(Sender: TObject);
|
||||
procedure AcSaveExecute(Sender: TObject);
|
||||
procedure AcSaveNowExecute(Sender: TObject);
|
||||
procedure AcUnderlineExecute(Sender: TObject);
|
||||
procedure FormCloseQuery(Sender: TObject; var CanClose: boolean);
|
||||
procedure FormCreate(Sender: TObject);
|
||||
procedure StyleMenuClick(Sender: TObject);
|
||||
private
|
||||
{ private declarations }
|
||||
procedure LoadFromIni;
|
||||
procedure SaveToIni;
|
||||
procedure SetStyle(AStyle: TSpkStyle);
|
||||
procedure SetUserInterface(Ribbon:boolean);
|
||||
public
|
||||
{ public declarations }
|
||||
end;
|
||||
|
||||
var
|
||||
Form1: TForm1;
|
||||
|
||||
implementation
|
||||
|
||||
{$R *.lfm}
|
||||
|
||||
uses
|
||||
inifiles, unit2;
|
||||
|
||||
|
||||
{ TForm1 }
|
||||
|
||||
procedure TForm1.AcClassicalGUIExecute(Sender: TObject);
|
||||
begin
|
||||
SetUserInterface(false);
|
||||
end;
|
||||
|
||||
procedure TForm1.AcAboutExecute(Sender: TObject);
|
||||
var
|
||||
F: TAboutForm;
|
||||
begin
|
||||
F := TAboutForm.Create(nil);
|
||||
try
|
||||
F.ShowModal;
|
||||
finally
|
||||
F.Free;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TForm1.AcAutoSaveExecute(Sender: TObject);
|
||||
begin
|
||||
// Checked is handled by "AutoCheck". Need this method to have the action enabled.
|
||||
end;
|
||||
|
||||
procedure TForm1.AcBoldExecute(Sender: TObject);
|
||||
begin
|
||||
Label1.Caption := '"Bold" clicked';
|
||||
end;
|
||||
|
||||
procedure TForm1.AcCenterExecute(Sender: TObject);
|
||||
begin
|
||||
Label1.Caption := '"Center" clicked';
|
||||
end;
|
||||
|
||||
procedure TForm1.AcEditCopyExecute(Sender: TObject);
|
||||
begin
|
||||
Label1.Caption := '"Copy" clicked';
|
||||
end;
|
||||
|
||||
procedure TForm1.AcEditCutExecute(Sender: TObject);
|
||||
begin
|
||||
Label1.Caption := '"Cut" clicked';
|
||||
end;
|
||||
|
||||
procedure TForm1.AcEditPasteExecute(Sender: TObject);
|
||||
begin
|
||||
Label1.Caption := '"Paste" clicked';
|
||||
end;
|
||||
|
||||
procedure TForm1.AcItalicExecute(Sender: TObject);
|
||||
begin
|
||||
Label1.Caption := '"Italic" clicked';
|
||||
end;
|
||||
|
||||
procedure TForm1.AcLeftJustifyExecute(Sender: TObject);
|
||||
begin
|
||||
Label1.Caption := '"Left-justify" clicked';
|
||||
end;
|
||||
|
||||
procedure TForm1.AcOpenExecute(Sender: TObject);
|
||||
begin
|
||||
Label1.Caption := '"Open" clicked';
|
||||
end;
|
||||
|
||||
procedure TForm1.AcQuitExecute(Sender: TObject);
|
||||
begin
|
||||
Close;
|
||||
end;
|
||||
|
||||
procedure TForm1.AcRibbonGUIExecute(Sender: TObject);
|
||||
begin
|
||||
SetUserInterface(true);
|
||||
end;
|
||||
|
||||
procedure TForm1.AcRightJustifyExecute(Sender: TObject);
|
||||
begin
|
||||
Label1.Caption := '"Right-justify" clicked';
|
||||
end;
|
||||
|
||||
procedure TForm1.AcSaveExecute(Sender: TObject);
|
||||
begin
|
||||
Label1.Caption := '"Save" clicked';
|
||||
end;
|
||||
|
||||
procedure TForm1.AcSaveNowExecute(Sender: TObject);
|
||||
begin
|
||||
SaveToIni;
|
||||
end;
|
||||
|
||||
procedure TForm1.AcUnderlineExecute(Sender: TObject);
|
||||
begin
|
||||
Label1.Caption := '"Underline" clicked';
|
||||
end;
|
||||
|
||||
procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose: boolean);
|
||||
begin
|
||||
if CanClose then
|
||||
if MessageDlg('Do you really want to close this application?', mtConfirmation,
|
||||
[mbYes, mbNo], 0) <> mrYes
|
||||
then
|
||||
CanClose := false;
|
||||
if CanClose then
|
||||
if AcAutoSave.Checked then
|
||||
SaveToIni;
|
||||
end;
|
||||
|
||||
procedure TForm1.FormCreate(Sender: TObject);
|
||||
begin
|
||||
SetUserInterface(true);
|
||||
Label1.Caption := '';
|
||||
LoadFromIni;
|
||||
end;
|
||||
|
||||
procedure TForm1.LoadFromIni;
|
||||
var
|
||||
ini: TCustomIniFile;
|
||||
begin
|
||||
ini := TMemIniFile.Create(ChangeFileExt(ParamStr(0), '.ini'));
|
||||
try
|
||||
SetUserInterface(ini.ReadBool('MainForm', 'RibbonInterface', AcRibbonGUI.Checked));
|
||||
SpkToolbar1.Style := TSpkStyle(ini.ReadInteger('MainForm', 'RibbonStyle', 0));
|
||||
SetStyle(SpkToolbar1.Style);
|
||||
finally
|
||||
ini.Free;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TForm1.StyleMenuClick(Sender: TObject);
|
||||
var
|
||||
i: Integer;
|
||||
begin
|
||||
// SpkToolbar1.Style := TSpkStyle((Sender as TMenuItem).Tag);
|
||||
for i:=0 to StyleMenu.Items.Count-1 do
|
||||
StyleMenu.Items[i].Checked := StyleMenu.Items[i] = TMenuItem(Sender);
|
||||
SetStyle(TSpkStyle((Sender as TMenuItem).Tag));
|
||||
end;
|
||||
|
||||
procedure TForm1.SetStyle(AStyle: TSpkStyle);
|
||||
begin
|
||||
SpkToolbar1.Style := AStyle;
|
||||
case SpkToolbar1.Style of
|
||||
spkOffice2007Blue : SpkToolbar1.Color := clSkyBlue;
|
||||
spkOffice2007Silver : SpkToolbar1.Color := clWhite;
|
||||
spkOffice2007SilverTurquoise : SpkToolbar1.Color := clWhite;
|
||||
spkMetroLight : SpkToolbar1.Color := clSilver;
|
||||
spkMetroDark : SpkToolbar1.Color := $080808;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TForm1.SaveToIni;
|
||||
var
|
||||
ini: TCustomIniFile;
|
||||
begin
|
||||
ini := TMemIniFile.Create(ChangeFileExt(ParamStr(0), '.ini'));
|
||||
try
|
||||
ini.WriteBool('MainForm', 'RibbonInterface', AcRibbonGUI.Checked);
|
||||
ini.WriteInteger('MainForm', 'RibbonStyle', ord(SpkToolbar1.Style));
|
||||
finally
|
||||
ini.Free;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TForm1.SetUserInterface(Ribbon: boolean);
|
||||
begin
|
||||
if Ribbon then begin
|
||||
Menu := nil;
|
||||
Toolbar1.Hide;
|
||||
SpkToolbar1.Show;
|
||||
AcRibbonGUI.Checked := true;
|
||||
end else begin
|
||||
SpkToolbar1.Hide;
|
||||
Menu := MainMenu;
|
||||
Toolbar1.Show;
|
||||
AcClassicalGUI.Checked := true;
|
||||
end;
|
||||
end;
|
||||
|
||||
end.
|
||||
|
63
spktoolbar/demos/actions/unit2.lfm
Normal file
@@ -0,0 +1,63 @@
|
||||
object AboutForm: TAboutForm
|
||||
Left = 419
|
||||
Height = 185
|
||||
Top = 225
|
||||
Width = 320
|
||||
Caption = 'About...'
|
||||
ClientHeight = 185
|
||||
ClientWidth = 320
|
||||
Position = poMainFormCenter
|
||||
LCLVersion = '1.9.0.0'
|
||||
object Label1: TLabel
|
||||
Left = 0
|
||||
Height = 30
|
||||
Top = 24
|
||||
Width = 320
|
||||
Align = alTop
|
||||
Alignment = taCenter
|
||||
BorderSpacing.Top = 24
|
||||
Caption = 'SpkToolbar Demo'
|
||||
Font.Height = -21
|
||||
Font.Style = [fsBold]
|
||||
ParentColor = False
|
||||
ParentFont = False
|
||||
end
|
||||
object Label2: TLabel
|
||||
Left = 0
|
||||
Height = 15
|
||||
Top = 70
|
||||
Width = 320
|
||||
Align = alTop
|
||||
Alignment = taCenter
|
||||
BorderSpacing.Top = 16
|
||||
Caption = 'Icons kindly provided by'
|
||||
ParentColor = False
|
||||
end
|
||||
object Label3: TLabel
|
||||
Left = 0
|
||||
Height = 15
|
||||
Top = 89
|
||||
Width = 320
|
||||
Align = alTop
|
||||
Alignment = taCenter
|
||||
BorderSpacing.Top = 4
|
||||
Caption = 'http://www.fatcow.com/free-icons'
|
||||
Font.Color = clBlue
|
||||
ParentColor = False
|
||||
ParentFont = False
|
||||
OnClick = Label3Click
|
||||
OnMouseEnter = Label3MouseEnter
|
||||
OnMouseLeave = Label3MouseLeave
|
||||
end
|
||||
object BtnClose: TButton
|
||||
Left = 128
|
||||
Height = 25
|
||||
Top = 136
|
||||
Width = 75
|
||||
Cancel = True
|
||||
Caption = 'Close'
|
||||
Default = True
|
||||
ModalResult = 1
|
||||
TabOrder = 0
|
||||
end
|
||||
end
|
56
spktoolbar/demos/actions/unit2.pas
Normal file
@@ -0,0 +1,56 @@
|
||||
unit Unit2;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls;
|
||||
|
||||
type
|
||||
|
||||
{ TAboutForm }
|
||||
|
||||
TAboutForm = class(TForm)
|
||||
BtnClose: TButton;
|
||||
Label1: TLabel;
|
||||
Label2: TLabel;
|
||||
Label3: TLabel;
|
||||
procedure Label3Click(Sender: TObject);
|
||||
procedure Label3MouseEnter(Sender: TObject);
|
||||
procedure Label3MouseLeave(Sender: TObject);
|
||||
private
|
||||
|
||||
public
|
||||
|
||||
end;
|
||||
|
||||
var
|
||||
AboutForm: TAboutForm;
|
||||
|
||||
implementation
|
||||
|
||||
{$R *.lfm}
|
||||
|
||||
uses
|
||||
LCLIntf;
|
||||
|
||||
{ TAboutForm }
|
||||
|
||||
procedure TAboutForm.Label3Click(Sender: TObject);
|
||||
begin
|
||||
OpenURL(TLabel(Sender).Caption);
|
||||
end;
|
||||
|
||||
procedure TAboutForm.Label3MouseEnter(Sender: TObject);
|
||||
begin
|
||||
Label3.Font.Style := [fsUnderline];
|
||||
end;
|
||||
|
||||
procedure TAboutForm.Label3MouseLeave(Sender: TObject);
|
||||
begin
|
||||
Label3.Font.Style := [];
|
||||
end;
|
||||
|
||||
end.
|
||||
|
103
spktoolbar/demos/actions_hidpi/project1.lpi
Normal file
@@ -0,0 +1,103 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<CONFIG>
|
||||
<ProjectOptions>
|
||||
<Version Value="11"/>
|
||||
<PathDelim Value="\"/>
|
||||
<General>
|
||||
<SessionStorage Value="InProjectDir"/>
|
||||
<MainUnit Value="0"/>
|
||||
<Title Value="project1"/>
|
||||
<Scaled Value="True"/>
|
||||
<ResourceType Value="res"/>
|
||||
<UseXPManifest Value="True"/>
|
||||
<XPManifest>
|
||||
<DpiAware Value="True"/>
|
||||
</XPManifest>
|
||||
</General>
|
||||
<i18n>
|
||||
<EnableI18N LFM="False"/>
|
||||
</i18n>
|
||||
<BuildModes Count="1">
|
||||
<Item1 Name="Default" Default="True"/>
|
||||
</BuildModes>
|
||||
<PublishOptions>
|
||||
<Version Value="2"/>
|
||||
<IncludeFileFilter Value="*.(pas|pp|inc|lfm|lpr|lrs|lpi|lpk|sh|xml)"/>
|
||||
<ExcludeFileFilter Value="*.(bak|ppu|o|so);*~;backup"/>
|
||||
</PublishOptions>
|
||||
<RunParams>
|
||||
<FormatVersion Value="2"/>
|
||||
<Modes Count="1">
|
||||
<Mode0 Name="default"/>
|
||||
</Modes>
|
||||
</RunParams>
|
||||
<RequiredPackages Count="2">
|
||||
<Item1>
|
||||
<PackageName Value="SpkToolbarPackage"/>
|
||||
</Item1>
|
||||
<Item2>
|
||||
<PackageName Value="LCL"/>
|
||||
</Item2>
|
||||
</RequiredPackages>
|
||||
<Units Count="3">
|
||||
<Unit0>
|
||||
<Filename Value="project1.lpr"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
</Unit0>
|
||||
<Unit1>
|
||||
<Filename Value="unit1.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<ComponentName Value="Form1"/>
|
||||
<HasResources Value="True"/>
|
||||
<ResourceBaseClass Value="Form"/>
|
||||
<UnitName Value="Unit1"/>
|
||||
</Unit1>
|
||||
<Unit2>
|
||||
<Filename Value="unit2.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<ComponentName Value="AboutForm"/>
|
||||
<HasResources Value="True"/>
|
||||
<ResourceBaseClass Value="Form"/>
|
||||
<UnitName Value="Unit2"/>
|
||||
</Unit2>
|
||||
</Units>
|
||||
</ProjectOptions>
|
||||
<CompilerOptions>
|
||||
<Version Value="11"/>
|
||||
<PathDelim Value="\"/>
|
||||
<Target>
|
||||
<Filename Value="bin\project1"/>
|
||||
</Target>
|
||||
<SearchPaths>
|
||||
<IncludeFiles Value="$(ProjOutDir)"/>
|
||||
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
|
||||
</SearchPaths>
|
||||
<CodeGeneration>
|
||||
<SmartLinkUnit Value="True"/>
|
||||
</CodeGeneration>
|
||||
<Linking>
|
||||
<Debugging>
|
||||
<UseExternalDbgSyms Value="True"/>
|
||||
</Debugging>
|
||||
<LinkSmart Value="True"/>
|
||||
<Options>
|
||||
<Win32>
|
||||
<GraphicApplication Value="True"/>
|
||||
</Win32>
|
||||
</Options>
|
||||
</Linking>
|
||||
</CompilerOptions>
|
||||
<Debugging>
|
||||
<Exceptions Count="3">
|
||||
<Item1>
|
||||
<Name Value="EAbort"/>
|
||||
</Item1>
|
||||
<Item2>
|
||||
<Name Value="ECodetoolError"/>
|
||||
</Item2>
|
||||
<Item3>
|
||||
<Name Value="EFOpenError"/>
|
||||
</Item3>
|
||||
</Exceptions>
|
||||
</Debugging>
|
||||
</CONFIG>
|
25
spktoolbar/demos/actions_hidpi/project1.lpr
Normal file
@@ -0,0 +1,25 @@
|
||||
program project1;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
uses
|
||||
{$IFDEF UNIX}{$IFDEF UseCThreads}
|
||||
cthreads,
|
||||
{$ENDIF}{$ENDIF}
|
||||
Interfaces, // this includes the LCL widgetset
|
||||
LCLVersion, Forms, Unit1, Unit2
|
||||
{ you can add units after this };
|
||||
|
||||
{$R *.res}
|
||||
|
||||
begin
|
||||
{$IF LCL_FullVersion < 1090000}
|
||||
*** This demo requires Laz version >= 1.9 ***
|
||||
{$ENDIF}
|
||||
Application.Scaled:=True;
|
||||
RequireDerivedFormResource := True;
|
||||
Application.Initialize;
|
||||
Application.CreateForm(TForm1, Form1);
|
||||
Application.Run;
|
||||
end.
|
||||
|
5162
spktoolbar/demos/actions_hidpi/unit1.lfm
Normal file
338
spktoolbar/demos/actions_hidpi/unit1.pas
Normal file
@@ -0,0 +1,338 @@
|
||||
unit Unit1;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ActnList,
|
||||
StdActns, StdCtrls, Menus, ComCtrls, ExtCtrls,
|
||||
SpkToolbar, spkt_Buttons, spkt_Checkboxes, spkt_Pane, spkt_Tab, spkt_Appearance;
|
||||
|
||||
type
|
||||
|
||||
{ TForm1 }
|
||||
|
||||
TForm1 = class(TForm)
|
||||
AcOpen: TAction;
|
||||
AcClassicalGUI: TAction;
|
||||
AcRibbonGUI: TAction;
|
||||
AcSave: TAction;
|
||||
AcQuit: TAction;
|
||||
AcAutoSave: TAction;
|
||||
AcSaveNow: TAction;
|
||||
AcBold: TAction;
|
||||
AcItalic: TAction;
|
||||
AcLeftJustify: TAction;
|
||||
AcCenter: TAction;
|
||||
AcRightJustify: TAction;
|
||||
AcAbout: TAction;
|
||||
AcUnderline: TAction;
|
||||
ActionList: TActionList;
|
||||
AcEditCopy: TEditCopy;
|
||||
AcEditCut: TEditCut;
|
||||
AcEditPaste: TEditPaste;
|
||||
ImageList: TImageList;
|
||||
HiResImages: TImageList;
|
||||
Label1: TLabel;
|
||||
LargeImageList: TImageList;
|
||||
MainMenu: TMainMenu;
|
||||
MenuItem1: TMenuItem;
|
||||
MenuItem10: TMenuItem;
|
||||
MenuItem11: TMenuItem;
|
||||
MenuItem12: TMenuItem;
|
||||
MenuItem13: TMenuItem;
|
||||
MenuItem14: TMenuItem;
|
||||
MenuItem15: TMenuItem;
|
||||
MenuItem16: TMenuItem;
|
||||
MenuItem17: TMenuItem;
|
||||
MenuItem18: TMenuItem;
|
||||
MenuItem19: TMenuItem;
|
||||
MenuItem2: TMenuItem;
|
||||
MenuItem20: TMenuItem;
|
||||
MenuItem21: TMenuItem;
|
||||
MenuItem22: TMenuItem;
|
||||
MenuItem23: TMenuItem;
|
||||
MenuItem24: TMenuItem;
|
||||
MenuItem25: TMenuItem;
|
||||
MenuItem26: TMenuItem;
|
||||
MenuItem27: TMenuItem;
|
||||
MenuItem28: TMenuItem;
|
||||
MenuItem29: TMenuItem;
|
||||
MenuItem3: TMenuItem;
|
||||
MenuItem30: TMenuItem;
|
||||
MenuItem31: TMenuItem;
|
||||
MenuItem4: TMenuItem;
|
||||
MenuItem5: TMenuItem;
|
||||
MenuItem6: TMenuItem;
|
||||
MenuItem7: TMenuItem;
|
||||
MenuItem8: TMenuItem;
|
||||
MenuItem9: TMenuItem;
|
||||
Panel1: TPanel;
|
||||
SpkLargeButton4: TSpkLargeButton;
|
||||
SpkPane2: TSpkPane;
|
||||
SpkPane4: TSpkPane;
|
||||
SpkSmallButton10: TSpkSmallButton;
|
||||
SpkSmallButton11: TSpkSmallButton;
|
||||
SpkSmallButton4: TSpkSmallButton;
|
||||
SpkSmallButton6: TSpkSmallButton;
|
||||
SpkSmallButton8: TSpkSmallButton;
|
||||
SpkSmallButton9: TSpkSmallButton;
|
||||
SpkTab4: TSpkTab;
|
||||
SpkTab5: TSpkTab;
|
||||
StyleMenu: TPopupMenu;
|
||||
SpkCheckbox1: TSpkCheckbox;
|
||||
SpkLargeButton1: TSpkLargeButton;
|
||||
SpkLargeButton2: TSpkLargeButton;
|
||||
SpkLargeButton3: TSpkLargeButton;
|
||||
SpkPane1: TSpkPane;
|
||||
SpkPane3: TSpkPane;
|
||||
SpkPane5: TSpkPane;
|
||||
SpkPane6: TSpkPane;
|
||||
SpkRadioButton1: TSpkRadioButton;
|
||||
SpkRadioButton2: TSpkRadioButton;
|
||||
SpkSmallButton1: TSpkSmallButton;
|
||||
SpkSmallButton2: TSpkSmallButton;
|
||||
SpkSmallButton3: TSpkSmallButton;
|
||||
SpkSmallButton5: TSpkSmallButton;
|
||||
SpkSmallButton7: TSpkSmallButton;
|
||||
SpkTab1: TSpkTab;
|
||||
SpkTab2: TSpkTab;
|
||||
SpkTab3: TSpkTab;
|
||||
SpkToolbar1: TSpkToolbar;
|
||||
ToolBar1: TToolBar;
|
||||
ToolButton1: TToolButton;
|
||||
ToolButton10: TToolButton;
|
||||
ToolButton11: TToolButton;
|
||||
ToolButton12: TToolButton;
|
||||
ToolButton13: TToolButton;
|
||||
ToolButton14: TToolButton;
|
||||
ToolButton15: TToolButton;
|
||||
ToolButton2: TToolButton;
|
||||
ToolButton3: TToolButton;
|
||||
ToolButton4: TToolButton;
|
||||
ToolButton5: TToolButton;
|
||||
ToolButton6: TToolButton;
|
||||
ToolButton7: TToolButton;
|
||||
ToolButton8: TToolButton;
|
||||
ToolButton9: TToolButton;
|
||||
procedure AcAboutExecute(Sender: TObject);
|
||||
procedure AcAutoSaveExecute(Sender: TObject);
|
||||
procedure AcBoldExecute(Sender: TObject);
|
||||
procedure AcCenterExecute(Sender: TObject);
|
||||
procedure AcClassicalGUIExecute(Sender: TObject);
|
||||
procedure AcEditCopyExecute(Sender: TObject);
|
||||
procedure AcEditCutExecute(Sender: TObject);
|
||||
procedure AcEditPasteExecute(Sender: TObject);
|
||||
procedure AcItalicExecute(Sender: TObject);
|
||||
procedure AcLeftJustifyExecute(Sender: TObject);
|
||||
procedure AcOpenExecute(Sender: TObject);
|
||||
procedure AcQuitExecute(Sender: TObject);
|
||||
procedure AcRibbonGUIExecute(Sender: TObject);
|
||||
procedure AcRightJustifyExecute(Sender: TObject);
|
||||
procedure AcSaveExecute(Sender: TObject);
|
||||
procedure AcSaveNowExecute(Sender: TObject);
|
||||
procedure AcUnderlineExecute(Sender: TObject);
|
||||
procedure FormCloseQuery(Sender: TObject; var CanClose: boolean);
|
||||
procedure FormCreate(Sender: TObject);
|
||||
procedure StyleMenuClick(Sender: TObject);
|
||||
private
|
||||
{ private declarations }
|
||||
procedure LoadFromIni;
|
||||
procedure SaveToIni;
|
||||
procedure SetStyle(AStyle: TSpkStyle);
|
||||
procedure SetUserInterface(Ribbon:boolean);
|
||||
public
|
||||
{ public declarations }
|
||||
end;
|
||||
|
||||
var
|
||||
Form1: TForm1;
|
||||
|
||||
implementation
|
||||
|
||||
{$R *.lfm}
|
||||
|
||||
uses
|
||||
inifiles, unit2;
|
||||
|
||||
|
||||
{ TForm1 }
|
||||
|
||||
procedure TForm1.AcClassicalGUIExecute(Sender: TObject);
|
||||
begin
|
||||
SetUserInterface(false);
|
||||
end;
|
||||
|
||||
procedure TForm1.AcAboutExecute(Sender: TObject);
|
||||
var
|
||||
F: TAboutForm;
|
||||
begin
|
||||
F := TAboutForm.Create(nil);
|
||||
try
|
||||
F.ShowModal;
|
||||
finally
|
||||
F.Free;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TForm1.AcAutoSaveExecute(Sender: TObject);
|
||||
begin
|
||||
// Checked is handled by "AutoCheck". Need this method to have the action enabled.
|
||||
end;
|
||||
|
||||
procedure TForm1.AcBoldExecute(Sender: TObject);
|
||||
begin
|
||||
Label1.Caption := '"Bold" clicked';
|
||||
end;
|
||||
|
||||
procedure TForm1.AcCenterExecute(Sender: TObject);
|
||||
begin
|
||||
Label1.Caption := '"Center" clicked';
|
||||
end;
|
||||
|
||||
procedure TForm1.AcEditCopyExecute(Sender: TObject);
|
||||
begin
|
||||
Label1.Caption := '"Copy" clicked';
|
||||
end;
|
||||
|
||||
procedure TForm1.AcEditCutExecute(Sender: TObject);
|
||||
begin
|
||||
Label1.Caption := '"Cut" clicked';
|
||||
end;
|
||||
|
||||
procedure TForm1.AcEditPasteExecute(Sender: TObject);
|
||||
begin
|
||||
Label1.Caption := '"Paste" clicked';
|
||||
end;
|
||||
|
||||
procedure TForm1.AcItalicExecute(Sender: TObject);
|
||||
begin
|
||||
Label1.Caption := '"Italic" clicked';
|
||||
end;
|
||||
|
||||
procedure TForm1.AcLeftJustifyExecute(Sender: TObject);
|
||||
begin
|
||||
Label1.Caption := '"Left-justify" clicked';
|
||||
end;
|
||||
|
||||
procedure TForm1.AcOpenExecute(Sender: TObject);
|
||||
begin
|
||||
Label1.Caption := '"Open" clicked';
|
||||
end;
|
||||
|
||||
procedure TForm1.AcQuitExecute(Sender: TObject);
|
||||
begin
|
||||
Close;
|
||||
end;
|
||||
|
||||
procedure TForm1.AcRibbonGUIExecute(Sender: TObject);
|
||||
begin
|
||||
SetUserInterface(true);
|
||||
end;
|
||||
|
||||
procedure TForm1.AcRightJustifyExecute(Sender: TObject);
|
||||
begin
|
||||
Label1.Caption := '"Right-justify" clicked';
|
||||
end;
|
||||
|
||||
procedure TForm1.AcSaveExecute(Sender: TObject);
|
||||
begin
|
||||
Label1.Caption := '"Save" clicked';
|
||||
end;
|
||||
|
||||
procedure TForm1.AcSaveNowExecute(Sender: TObject);
|
||||
begin
|
||||
SaveToIni;
|
||||
end;
|
||||
|
||||
procedure TForm1.AcUnderlineExecute(Sender: TObject);
|
||||
begin
|
||||
Label1.Caption := '"Underline" clicked';
|
||||
end;
|
||||
|
||||
procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose: boolean);
|
||||
begin
|
||||
if CanClose then
|
||||
if MessageDlg('Do you really want to close this application?', mtConfirmation,
|
||||
[mbYes, mbNo], 0) <> mrYes
|
||||
then
|
||||
CanClose := false;
|
||||
if CanClose then
|
||||
if AcAutoSave.Checked then
|
||||
SaveToIni;
|
||||
end;
|
||||
|
||||
procedure TForm1.FormCreate(Sender: TObject);
|
||||
begin
|
||||
SetUserInterface(true);
|
||||
Label1.Caption := '';
|
||||
LoadFromIni;
|
||||
end;
|
||||
|
||||
procedure TForm1.LoadFromIni;
|
||||
var
|
||||
ini: TCustomIniFile;
|
||||
begin
|
||||
ini := TMemIniFile.Create(ChangeFileExt(ParamStr(0), '.ini'));
|
||||
try
|
||||
SetUserInterface(ini.ReadBool('MainForm', 'RibbonInterface', AcRibbonGUI.Checked));
|
||||
SpkToolbar1.Style := TSpkStyle(ini.ReadInteger('MainForm', 'RibbonStyle', 0));
|
||||
SetStyle(SpkToolbar1.Style);
|
||||
finally
|
||||
ini.Free;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TForm1.StyleMenuClick(Sender: TObject);
|
||||
var
|
||||
i: Integer;
|
||||
begin
|
||||
// SpkToolbar1.Style := TSpkStyle((Sender as TMenuItem).Tag);
|
||||
for i:=0 to StyleMenu.Items.Count-1 do
|
||||
StyleMenu.Items[i].Checked := StyleMenu.Items[i] = TMenuItem(Sender);
|
||||
SetStyle(TSpkStyle((Sender as TMenuItem).Tag));
|
||||
end;
|
||||
|
||||
procedure TForm1.SetStyle(AStyle: TSpkStyle);
|
||||
begin
|
||||
SpkToolbar1.Style := AStyle;
|
||||
case SpkToolbar1.Style of
|
||||
spkOffice2007Blue : SpkToolbar1.Color := clSkyBlue;
|
||||
spkOffice2007Silver : SpkToolbar1.Color := clWhite;
|
||||
spkOffice2007SilverTurquoise : SpkToolbar1.Color := clWhite;
|
||||
spkMetroLight : SpkToolbar1.Color := clSilver;
|
||||
spkMetroDark : SpkToolbar1.Color := $080808;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TForm1.SaveToIni;
|
||||
var
|
||||
ini: TCustomIniFile;
|
||||
begin
|
||||
ini := TMemIniFile.Create(ChangeFileExt(ParamStr(0), '.ini'));
|
||||
try
|
||||
ini.WriteBool('MainForm', 'RibbonInterface', AcRibbonGUI.Checked);
|
||||
ini.WriteInteger('MainForm', 'RibbonStyle', ord(SpkToolbar1.Style));
|
||||
finally
|
||||
ini.Free;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TForm1.SetUserInterface(Ribbon: boolean);
|
||||
begin
|
||||
if Ribbon then begin
|
||||
Menu := nil;
|
||||
Toolbar1.Hide;
|
||||
SpkToolbar1.Show;
|
||||
AcRibbonGUI.Checked := true;
|
||||
end else begin
|
||||
SpkToolbar1.Hide;
|
||||
Menu := MainMenu;
|
||||
Toolbar1.Show;
|
||||
AcClassicalGUI.Checked := true;
|
||||
end;
|
||||
end;
|
||||
|
||||
end.
|
||||
|
64
spktoolbar/demos/actions_hidpi/unit2.lfm
Normal file
@@ -0,0 +1,64 @@
|
||||
object AboutForm: TAboutForm
|
||||
Left = 419
|
||||
Height = 185
|
||||
Top = 225
|
||||
Width = 320
|
||||
Caption = 'About...'
|
||||
ClientHeight = 185
|
||||
ClientWidth = 320
|
||||
Position = poMainFormCenter
|
||||
LCLVersion = '1.9.0.0'
|
||||
object Label1: TLabel
|
||||
Left = 0
|
||||
Height = 30
|
||||
Top = 24
|
||||
Width = 320
|
||||
Align = alTop
|
||||
Alignment = taCenter
|
||||
BorderSpacing.Top = 24
|
||||
Caption = 'SpkToolbar Demo'
|
||||
Font.Height = -21
|
||||
Font.Style = [fsBold]
|
||||
ParentColor = False
|
||||
ParentFont = False
|
||||
end
|
||||
object Label2: TLabel
|
||||
Left = 0
|
||||
Height = 15
|
||||
Top = 70
|
||||
Width = 320
|
||||
Align = alTop
|
||||
Alignment = taCenter
|
||||
BorderSpacing.Top = 16
|
||||
Caption = 'Icons kindly provided by'
|
||||
ParentColor = False
|
||||
end
|
||||
object Label3: TLabel
|
||||
Cursor = crHandPoint
|
||||
Left = 0
|
||||
Height = 15
|
||||
Top = 89
|
||||
Width = 320
|
||||
Align = alTop
|
||||
Alignment = taCenter
|
||||
BorderSpacing.Top = 4
|
||||
Caption = 'https://icons8.com/'
|
||||
Font.Color = clBlue
|
||||
ParentColor = False
|
||||
ParentFont = False
|
||||
OnClick = Label3Click
|
||||
OnMouseEnter = Label3MouseEnter
|
||||
OnMouseLeave = Label3MouseLeave
|
||||
end
|
||||
object BtnClose: TButton
|
||||
Left = 128
|
||||
Height = 25
|
||||
Top = 136
|
||||
Width = 75
|
||||
Cancel = True
|
||||
Caption = 'Close'
|
||||
Default = True
|
||||
ModalResult = 1
|
||||
TabOrder = 0
|
||||
end
|
||||
end
|
56
spktoolbar/demos/actions_hidpi/unit2.pas
Normal file
@@ -0,0 +1,56 @@
|
||||
unit Unit2;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls;
|
||||
|
||||
type
|
||||
|
||||
{ TAboutForm }
|
||||
|
||||
TAboutForm = class(TForm)
|
||||
BtnClose: TButton;
|
||||
Label1: TLabel;
|
||||
Label2: TLabel;
|
||||
Label3: TLabel;
|
||||
procedure Label3Click(Sender: TObject);
|
||||
procedure Label3MouseEnter(Sender: TObject);
|
||||
procedure Label3MouseLeave(Sender: TObject);
|
||||
private
|
||||
|
||||
public
|
||||
|
||||
end;
|
||||
|
||||
var
|
||||
AboutForm: TAboutForm;
|
||||
|
||||
implementation
|
||||
|
||||
{$R *.lfm}
|
||||
|
||||
uses
|
||||
LCLIntf;
|
||||
|
||||
{ TAboutForm }
|
||||
|
||||
procedure TAboutForm.Label3Click(Sender: TObject);
|
||||
begin
|
||||
OpenURL(TLabel(Sender).Caption);
|
||||
end;
|
||||
|
||||
procedure TAboutForm.Label3MouseEnter(Sender: TObject);
|
||||
begin
|
||||
Label3.Font.Style := [fsUnderline];
|
||||
end;
|
||||
|
||||
procedure TAboutForm.Label3MouseLeave(Sender: TObject);
|
||||
begin
|
||||
Label3.Font.Style := [];
|
||||
end;
|
||||
|
||||
end.
|
||||
|
98
spktoolbar/demos/basic/Project1.lpi
Normal file
@@ -0,0 +1,98 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<CONFIG>
|
||||
<ProjectOptions>
|
||||
<Version Value="10"/>
|
||||
<PathDelim Value="\"/>
|
||||
<General>
|
||||
<Flags>
|
||||
<MainUnitHasUsesSectionForAllUnits Value="False"/>
|
||||
<MainUnitHasCreateFormStatements Value="False"/>
|
||||
<MainUnitHasTitleStatement Value="False"/>
|
||||
</Flags>
|
||||
<SessionStorage Value="InProjectDir"/>
|
||||
<MainUnit Value="0"/>
|
||||
<ResourceType Value="res"/>
|
||||
<UseXPManifest Value="True"/>
|
||||
<Icon Value="0"/>
|
||||
</General>
|
||||
<i18n>
|
||||
<EnableI18N LFM="False"/>
|
||||
</i18n>
|
||||
<BuildModes Count="1">
|
||||
<Item1 Name="Default" Default="True"/>
|
||||
</BuildModes>
|
||||
<PublishOptions>
|
||||
<Version Value="2"/>
|
||||
<IncludeFileFilter Value="*.(pas|pp|inc|lfm|lpr|lrs|lpi|lpk|sh|xml)"/>
|
||||
<ExcludeFileFilter Value="*.(bak|ppu|o|so);*~;backup"/>
|
||||
</PublishOptions>
|
||||
<RunParams>
|
||||
<local>
|
||||
<FormatVersion Value="1"/>
|
||||
</local>
|
||||
</RunParams>
|
||||
<RequiredPackages Count="2">
|
||||
<Item1>
|
||||
<PackageName Value="SpkToolbarPackage"/>
|
||||
</Item1>
|
||||
<Item2>
|
||||
<PackageName Value="LCL"/>
|
||||
</Item2>
|
||||
</RequiredPackages>
|
||||
<Units Count="2">
|
||||
<Unit0>
|
||||
<Filename Value="Project1.lpr"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
</Unit0>
|
||||
<Unit1>
|
||||
<Filename Value="Unit1.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<ComponentName Value="Form2"/>
|
||||
<HasResources Value="True"/>
|
||||
<ResourceBaseClass Value="Form"/>
|
||||
</Unit1>
|
||||
</Units>
|
||||
</ProjectOptions>
|
||||
<CompilerOptions>
|
||||
<Version Value="11"/>
|
||||
<PathDelim Value="\"/>
|
||||
<Target>
|
||||
<Filename Value="bin\project1"/>
|
||||
</Target>
|
||||
<SearchPaths>
|
||||
<IncludeFiles Value="$(ProjOutDir)"/>
|
||||
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
|
||||
</SearchPaths>
|
||||
<CodeGeneration>
|
||||
<SmartLinkUnit Value="True"/>
|
||||
<Optimizations>
|
||||
<OptimizationLevel Value="2"/>
|
||||
</Optimizations>
|
||||
</CodeGeneration>
|
||||
<Linking>
|
||||
<Debugging>
|
||||
<DebugInfoType Value="dsDwarf2"/>
|
||||
<UseExternalDbgSyms Value="True"/>
|
||||
</Debugging>
|
||||
<LinkSmart Value="True"/>
|
||||
<Options>
|
||||
<Win32>
|
||||
<GraphicApplication Value="True"/>
|
||||
</Win32>
|
||||
</Options>
|
||||
</Linking>
|
||||
</CompilerOptions>
|
||||
<Debugging>
|
||||
<Exceptions Count="3">
|
||||
<Item1>
|
||||
<Name Value="EAbort"/>
|
||||
</Item1>
|
||||
<Item2>
|
||||
<Name Value="ECodetoolError"/>
|
||||
</Item2>
|
||||
<Item3>
|
||||
<Name Value="EFOpenError"/>
|
||||
</Item3>
|
||||
</Exceptions>
|
||||
</Debugging>
|
||||
</CONFIG>
|
16
spktoolbar/demos/basic/Project1.lpr
Normal file
@@ -0,0 +1,16 @@
|
||||
program Project1;
|
||||
|
||||
{$MODE Delphi}
|
||||
|
||||
uses
|
||||
Forms, Interfaces,
|
||||
Unit1 in 'Unit1.pas' {Form2};
|
||||
|
||||
{$R *.res}
|
||||
|
||||
begin
|
||||
Application.Initialize;
|
||||
// Application.MainFormOnTaskbar := True;
|
||||
Application.CreateForm(TForm2, Form2);
|
||||
Application.Run;
|
||||
end.
|
2979
spktoolbar/demos/basic/Unit1.lfm
Normal file
116
spktoolbar/demos/basic/Unit1.pas
Normal file
@@ -0,0 +1,116 @@
|
||||
unit Unit1;
|
||||
|
||||
{$MODE Delphi}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
LCLIntf, LCLType, LMessages, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
||||
Dialogs, SpkToolbar, StdCtrls, ExtCtrls, SpkGUITools, SpkMath, SpkGraphTools,
|
||||
Spin, spkt_Tab, spkt_Pane, ActnList, {ButtonGroup,} Menus, spkt_Types,
|
||||
spkt_Tools, ImgList, spkt_BaseItem, spkt_Buttons;
|
||||
|
||||
type
|
||||
TForm2 = class(TForm)
|
||||
ActionList1: TActionList;
|
||||
Action1: TAction;
|
||||
PopupMenu1: TPopupMenu;
|
||||
LargeImages: TImageList;
|
||||
Images: TImageList;
|
||||
SpkToolbar1: TSpkToolbar;
|
||||
SpkTab1: TSpkTab;
|
||||
CUsersSpookDokumenty1: TMenuItem;
|
||||
DDokumenty1: TMenuItem;
|
||||
SpkPane2: TSpkPane;
|
||||
SpkSmallButton2: TSpkSmallButton;
|
||||
SpkSmallButton3: TSpkSmallButton;
|
||||
SpkSmallButton4: TSpkSmallButton;
|
||||
SpkLargeButton4: TSpkLargeButton;
|
||||
SpkPane3: TSpkPane;
|
||||
SpkSmallButton1: TSpkSmallButton;
|
||||
SpkSmallButton5: TSpkSmallButton;
|
||||
SpkSmallButton6: TSpkSmallButton;
|
||||
SpkSmallButton7: TSpkSmallButton;
|
||||
SpkSmallButton8: TSpkSmallButton;
|
||||
SpkPane4: TSpkPane;
|
||||
SpkSmallButton10: TSpkSmallButton;
|
||||
SpkLargeButton5: TSpkLargeButton;
|
||||
SpkSmallButton9: TSpkSmallButton;
|
||||
SpkTab2: TSpkTab;
|
||||
SpkPane5: TSpkPane;
|
||||
SpkLargeButton6: TSpkLargeButton;
|
||||
SpkLargeButton7: TSpkLargeButton;
|
||||
SpkLargeButton8: TSpkLargeButton;
|
||||
PopupMenu2: TPopupMenu;
|
||||
Recent11: TMenuItem;
|
||||
Recent21: TMenuItem;
|
||||
Recent31: TMenuItem;
|
||||
SpkPane1: TSpkPane;
|
||||
SpkLargeButton1: TSpkLargeButton;
|
||||
SpkLargeButton2: TSpkLargeButton;
|
||||
SpkLargeButton3: TSpkLargeButton;
|
||||
SpkPane6: TSpkPane;
|
||||
SpkSmallButton11: TSpkSmallButton;
|
||||
SpkSmallButton12: TSpkSmallButton;
|
||||
SpkSmallButton13: TSpkSmallButton;
|
||||
procedure Button2Click(Sender: TObject);
|
||||
private
|
||||
{ Private declarations }
|
||||
public
|
||||
{ Public declarations }
|
||||
end;
|
||||
|
||||
var
|
||||
Form2: TForm2;
|
||||
|
||||
implementation
|
||||
|
||||
{$R *.lfm}
|
||||
|
||||
procedure TForm2.Button2Click(Sender: TObject);
|
||||
|
||||
var i,j,k : integer;
|
||||
Item : TSpkSmallButton;
|
||||
Pane : TSpkPane;
|
||||
Tab : TSpkTab;
|
||||
|
||||
begin
|
||||
SpkToolbar1.BeginUpdate;
|
||||
|
||||
for i := 0 to 20 do
|
||||
Tab:=SpkToolbar1.Tabs.add;
|
||||
|
||||
for k := 0 to 6 do
|
||||
begin
|
||||
Pane:=SpkTab1.Panes.Add;
|
||||
for j := 0 to 2 do
|
||||
begin
|
||||
Item:=Pane.Items.AddSmallButton;
|
||||
Item.TableBehaviour:=tbBeginsRow;
|
||||
//Item.GroupBehaviour:=gbBeginsGroup;
|
||||
Item.ShowCaption:=false;
|
||||
Item.ImageIndex:=random(50);
|
||||
//Item.DropdownMenu:=PopupMenu1;
|
||||
|
||||
for i := 0 to 4 do
|
||||
begin
|
||||
Item:=Pane.Items.AddSmallButton;
|
||||
Item.ShowCaption:=false;
|
||||
Item.ImageIndex:=random(50);
|
||||
//Item.GroupBehaviour:=gbContinuesGroup;
|
||||
//Item.DropdownMenu:=PopupMenu1;
|
||||
end;
|
||||
|
||||
Item:=Pane.Items.AddSmallButton;
|
||||
Item.TableBehaviour:=tbContinuesRow;
|
||||
//Item.GroupBehaviour:=gbEndsGroup;
|
||||
Item.ShowCaption:=false;
|
||||
Item.ImageIndex:=random(50);
|
||||
//Item.DropdownMenu:=PopupMenu1;
|
||||
end;
|
||||
end;
|
||||
|
||||
SpkToolbar1.EndUpdate;
|
||||
end;
|
||||
|
||||
end.
|
92
spktoolbar/demos/runtime/project1.lpi
Normal file
@@ -0,0 +1,92 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<CONFIG>
|
||||
<ProjectOptions>
|
||||
<Version Value="10"/>
|
||||
<PathDelim Value="\"/>
|
||||
<General>
|
||||
<SessionStorage Value="InProjectDir"/>
|
||||
<MainUnit Value="0"/>
|
||||
<Title Value="project1"/>
|
||||
<ResourceType Value="res"/>
|
||||
<UseXPManifest Value="True"/>
|
||||
</General>
|
||||
<i18n>
|
||||
<EnableI18N LFM="False"/>
|
||||
</i18n>
|
||||
<BuildModes Count="1">
|
||||
<Item1 Name="Default" Default="True"/>
|
||||
</BuildModes>
|
||||
<PublishOptions>
|
||||
<Version Value="2"/>
|
||||
<IncludeFileFilter Value="*.(pas|pp|inc|lfm|lpr|lrs|lpi|lpk|sh|xml)"/>
|
||||
<ExcludeFileFilter Value="*.(bak|ppu|o|so);*~;backup"/>
|
||||
</PublishOptions>
|
||||
<RunParams>
|
||||
<local>
|
||||
<FormatVersion Value="1"/>
|
||||
</local>
|
||||
</RunParams>
|
||||
<RequiredPackages Count="2">
|
||||
<Item1>
|
||||
<PackageName Value="SpkToolbarPackage"/>
|
||||
</Item1>
|
||||
<Item2>
|
||||
<PackageName Value="LCL"/>
|
||||
</Item2>
|
||||
</RequiredPackages>
|
||||
<Units Count="2">
|
||||
<Unit0>
|
||||
<Filename Value="project1.lpr"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
</Unit0>
|
||||
<Unit1>
|
||||
<Filename Value="unit1.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<ComponentName Value="Form1"/>
|
||||
<HasResources Value="True"/>
|
||||
<ResourceBaseClass Value="Form"/>
|
||||
<UnitName Value="Unit1"/>
|
||||
</Unit1>
|
||||
</Units>
|
||||
</ProjectOptions>
|
||||
<CompilerOptions>
|
||||
<Version Value="11"/>
|
||||
<PathDelim Value="\"/>
|
||||
<Target>
|
||||
<Filename Value="bin\project1"/>
|
||||
</Target>
|
||||
<SearchPaths>
|
||||
<IncludeFiles Value="$(ProjOutDir)"/>
|
||||
<OtherUnitFiles Value="..\..\SpkToolbar"/>
|
||||
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
|
||||
</SearchPaths>
|
||||
<CodeGeneration>
|
||||
<SmartLinkUnit Value="True"/>
|
||||
</CodeGeneration>
|
||||
<Linking>
|
||||
<Debugging>
|
||||
<DebugInfoType Value="dsDwarf2"/>
|
||||
<UseExternalDbgSyms Value="True"/>
|
||||
</Debugging>
|
||||
<LinkSmart Value="True"/>
|
||||
<Options>
|
||||
<Win32>
|
||||
<GraphicApplication Value="True"/>
|
||||
</Win32>
|
||||
</Options>
|
||||
</Linking>
|
||||
</CompilerOptions>
|
||||
<Debugging>
|
||||
<Exceptions Count="3">
|
||||
<Item1>
|
||||
<Name Value="EAbort"/>
|
||||
</Item1>
|
||||
<Item2>
|
||||
<Name Value="ECodetoolError"/>
|
||||
</Item2>
|
||||
<Item3>
|
||||
<Name Value="EFOpenError"/>
|
||||
</Item3>
|
||||
</Exceptions>
|
||||
</Debugging>
|
||||
</CONFIG>
|
21
spktoolbar/demos/runtime/project1.lpr
Normal file
@@ -0,0 +1,21 @@
|
||||
program project1;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
uses
|
||||
{$IFDEF UNIX}{$IFDEF UseCThreads}
|
||||
cthreads,
|
||||
{$ENDIF}{$ENDIF}
|
||||
Interfaces, // this includes the LCL widgetset
|
||||
Forms, Unit1
|
||||
{ you can add units after this };
|
||||
|
||||
{$R *.res}
|
||||
|
||||
begin
|
||||
RequireDerivedFormResource := True;
|
||||
Application.Initialize;
|
||||
Application.CreateForm(TForm1, Form1);
|
||||
Application.Run;
|
||||
end.
|
||||
|
1680
spktoolbar/demos/runtime/unit1.lfm
Normal file
463
spktoolbar/demos/runtime/unit1.pas
Normal file
@@ -0,0 +1,463 @@
|
||||
unit Unit1;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, SpkToolbar,
|
||||
SpkGUITools, SpkMath, SpkGraphTools, spkt_Tab, spkt_Pane, spkt_Types,
|
||||
spkt_Tools, ImgList, ComCtrls, Menus, Grids, ExtCtrls, StdCtrls,
|
||||
spkt_BaseItem, spkt_Buttons, spkt_Checkboxes;
|
||||
|
||||
type
|
||||
|
||||
{ TForm1 }
|
||||
|
||||
TForm1 = class(TForm)
|
||||
ImageList: TImageList;
|
||||
LargeImageList: TImageList;
|
||||
MenuItem1: TMenuItem;
|
||||
MenuItem2: TMenuItem;
|
||||
MenuItem3: TMenuItem;
|
||||
MnuOffice2007Blue: TMenuItem;
|
||||
MnuOffice2007Silver1: TMenuItem;
|
||||
MnuOffice2007Silver2: TMenuItem;
|
||||
MnuMetroLight: TMenuItem;
|
||||
MnuMetroDark: TMenuItem;
|
||||
Panel1: TPanel;
|
||||
SpkLargeButton1: TSpkLargeButton;
|
||||
SpkLargeButton2: TSpkLargeButton;
|
||||
SpkPane2: TSpkPane;
|
||||
StylePopupMenu: TPopupMenu;
|
||||
RecentFilesPopupMenu: TPopupMenu;
|
||||
SpkPane1: TSpkPane;
|
||||
SpkSmallButton1: TSpkSmallButton;
|
||||
SpkSmallButton2: TSpkSmallButton;
|
||||
SpkSmallButton3: TSpkSmallButton;
|
||||
SpkTab1: TSpkTab;
|
||||
StatusBar1: TStatusBar;
|
||||
StringGrid1: TStringGrid;
|
||||
procedure FormCreate(Sender: TObject);
|
||||
procedure StyleChangeHandler(Sender: TObject);
|
||||
private
|
||||
{ private declarations }
|
||||
SpkToolbar : TSpkToolbar;
|
||||
CbHorizGrid : TSpkCheckbox;
|
||||
CbVertGrid: TSpkCheckbox;
|
||||
CbRowSelect: TSpkCheckbox;
|
||||
procedure AboutHandler(Sender: TObject);
|
||||
procedure FileOpenHandler(Sender: TObject);
|
||||
procedure FileSaveHandler(Sender: TObject);
|
||||
procedure FileQuitHandler(Sender: TObject);
|
||||
procedure HorizontalGridLinesHandler(Sender: TObject);
|
||||
procedure VerticalGridLinesHandler(Sender: TObject);
|
||||
procedure RowSelectHandler(Sender: TObject);
|
||||
public
|
||||
{ public declarations }
|
||||
end;
|
||||
|
||||
var
|
||||
Form1: TForm1;
|
||||
|
||||
implementation
|
||||
|
||||
{$R *.lfm}
|
||||
|
||||
uses
|
||||
LCLIntf, spkt_Appearance;
|
||||
|
||||
{ TAboutForm }
|
||||
type
|
||||
TAboutForm = class(TForm)
|
||||
private
|
||||
FIconLink: TLabel;
|
||||
procedure LinkClickHandler(Sender: TObject);
|
||||
procedure LinkMouseEnterHandler(Sender: TObject);
|
||||
procedure LinkMouseLeaveHandler(Sender: TObject);
|
||||
public
|
||||
constructor CreateNew(AOwner: TComponent; Num: Integer = 0); override;
|
||||
end;
|
||||
|
||||
constructor TAboutForm.CreateNew(AOwner: TComponent; Num: Integer = 0);
|
||||
begin
|
||||
inherited;
|
||||
Width := 300;
|
||||
Height := 180;
|
||||
Caption := 'About';
|
||||
Position := poMainFormCenter;
|
||||
with TLabel.Create(self) do begin
|
||||
Caption := 'SpkToolbar demo';
|
||||
Parent := self;
|
||||
Align := alTop;
|
||||
BorderSpacing.Top := 16;
|
||||
Font.Size := 16;
|
||||
Alignment := taCenter;
|
||||
end;
|
||||
with TLabel.Create(self) do begin
|
||||
Caption := 'Icons kindly provided by';
|
||||
Parent := self;
|
||||
Align := alTop;
|
||||
Alignment := taCenter;
|
||||
BorderSpacing.Top := 16;
|
||||
Left := 16;
|
||||
Top := 999;
|
||||
end;
|
||||
FIconLink := TLabel.Create(self);
|
||||
with FIconLink do begin
|
||||
Caption := 'http://www.fatcow.com/free-icons';
|
||||
Font.Color := clBlue;
|
||||
//Font.Style := [fsUnderline];
|
||||
Parent := self;
|
||||
Align := alTop;
|
||||
Alignment := taCenter;
|
||||
Top := 9999;
|
||||
OnClick := @LinkClickHandler;
|
||||
OnMouseEnter := @LinkMouseEnterHandler;
|
||||
OnMouseLeave := @LinkMouseLeaveHandler;
|
||||
end;
|
||||
with TButton.Create(self) do begin
|
||||
Caption := 'Close';
|
||||
Parent := Self;
|
||||
Left := (Self.Width - Width) div 2;
|
||||
Top := Self.Height - 16 - Height;
|
||||
ModalResult := mrOK;
|
||||
Default := true;
|
||||
Cancel := true;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TAboutForm.LinkClickHandler(Sender: TObject);
|
||||
begin
|
||||
OpenURL((Sender as TLabel).Caption);
|
||||
end;
|
||||
|
||||
procedure TAboutForm.LinkMouseEnterHandler(Sender: TObject);
|
||||
begin
|
||||
FIconLink.Font.Style := [fsUnderline];
|
||||
end;
|
||||
|
||||
procedure TAboutForm.LinkMouseLeaveHandler(Sender: TObject);
|
||||
begin
|
||||
FIconLink.Font.Style := [];
|
||||
end;
|
||||
|
||||
|
||||
{ TForm1 }
|
||||
|
||||
procedure TForm1.AboutHandler(Sender: TObject);
|
||||
var
|
||||
F: TForm;
|
||||
begin
|
||||
F := TAboutForm.CreateNew(nil);
|
||||
try
|
||||
F.ShowModal;
|
||||
finally
|
||||
F.Free;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TForm1.FileOpenHandler(Sender: TObject);
|
||||
begin
|
||||
Statusbar1.SimpleText := '"File" / "Open" clicked';
|
||||
end;
|
||||
|
||||
procedure TForm1.FileSaveHandler(Sender: TObject);
|
||||
begin
|
||||
Statusbar1.SimpleText := '"File" / "Save" clicked';
|
||||
end;
|
||||
|
||||
procedure TForm1.FileQuitHandler(Sender: TObject);
|
||||
begin
|
||||
Close;
|
||||
end;
|
||||
|
||||
procedure TForm1.HorizontalGridLinesHandler(Sender: TObject);
|
||||
begin
|
||||
if CbHorizGrid.Checked then
|
||||
StringGrid1.Options := StringGrid1.Options + [goHorzLine]
|
||||
else
|
||||
StringGrid1.Options := StringGrid1.Options - [goHorzLine];
|
||||
end;
|
||||
|
||||
procedure TForm1.VerticalGridLinesHandler(Sender: TObject);
|
||||
begin
|
||||
if CbVertGrid.Checked then
|
||||
StringGrid1.Options := StringGrid1.Options + [goVertLine]
|
||||
else
|
||||
StringGrid1.Options := StringGrid1.Options - [goVertLine];
|
||||
end;
|
||||
|
||||
procedure TForm1.RowSelectHandler(Sender: TObject);
|
||||
begin
|
||||
if CbRowSelect.Checked then
|
||||
StringGrid1.Options := StringGrid1.Options + [goRowSelect]
|
||||
else
|
||||
StringGrid1.Options := StringGrid1.Options - [goRowSelect];
|
||||
end;
|
||||
|
||||
procedure TForm1.FormCreate(Sender: TObject);
|
||||
begin
|
||||
SpkToolbar := TSpkToolbar.Create(self);
|
||||
|
||||
with SpkToolbar do begin
|
||||
Parent := self;
|
||||
Appearance.Pane.CaptionFont.Style := [fsBold, fsItalic];
|
||||
Color := clSkyBlue;
|
||||
Images := ImageList;
|
||||
LargeImages := LargeImageList;
|
||||
ShowHint := true;
|
||||
|
||||
with Tabs.Add do begin
|
||||
Caption := 'File';
|
||||
with Panes.Add do begin
|
||||
Caption := 'File commands';
|
||||
with Items.AddLargeButton do begin
|
||||
Caption := 'Open file';
|
||||
ButtonKind := bkButtonDropdown;
|
||||
DropdownMenu := RecentFilesPopupMenu;
|
||||
LargeImageIndex := 1;
|
||||
Hint := 'Open a file';
|
||||
OnClick := @FileOpenHandler;
|
||||
end;
|
||||
with Items.AddLargeButton do begin
|
||||
Caption := 'Save file';
|
||||
LargeImageIndex := 2;
|
||||
Hint := 'Save file';
|
||||
OnClick := @FileSaveHandler;
|
||||
end;
|
||||
with Items.AddLargeButton do begin
|
||||
Caption := 'Quit program';
|
||||
LargeImageIndex := 0;
|
||||
Hint := 'Close application';
|
||||
OnClick := @FileQuitHandler;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
with Tabs.Add do begin
|
||||
Caption := 'Edit';
|
||||
with Panes.Add do begin
|
||||
Caption := 'Edit commands';
|
||||
with Items.AddSmallButton do begin
|
||||
Caption := 'Cut';
|
||||
HideFrameWhenIdle := true;
|
||||
TableBehaviour := tbBeginsRow;
|
||||
ImageIndex := 3;
|
||||
Hint := 'Cut to clipboard';
|
||||
end;
|
||||
with Items.AddSmallButton do begin
|
||||
Caption := 'Copy';
|
||||
HideFrameWhenIdle := true;
|
||||
TableBehaviour := tbBeginsRow;
|
||||
ImageIndex := 4;
|
||||
Hint := 'Copy to clipboard';
|
||||
end;
|
||||
with Items.AddSmallButton do begin
|
||||
Caption := 'Paste';
|
||||
HideFrameWhenIdle := true;
|
||||
TableBehaviour := tbBeginsColumn;
|
||||
ImageIndex := 5;
|
||||
Hint := 'Paste from clipboard';
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
with Tabs.Add do begin
|
||||
Caption := 'Format';
|
||||
with Panes.Add do begin
|
||||
Caption := 'Format Settings';
|
||||
with Items.AddSmallButton do begin
|
||||
Caption := 'Bold';
|
||||
ButtonKind := bkToggle;
|
||||
GroupBehaviour := gbBeginsGroup;
|
||||
TableBehaviour := tbBeginsRow;
|
||||
ImageIndex := 6;
|
||||
ShowCaption := false;
|
||||
AllowAllUp := true;
|
||||
Hint := 'Bold';
|
||||
end;
|
||||
with Items.AddSmallButton do begin
|
||||
Caption := 'Italic';
|
||||
ButtonKind := bkToggle;
|
||||
TableBehaviour := tbContinuesRow;
|
||||
GroupBehaviour := gbContinuesGroup;
|
||||
ImageIndex := 7;
|
||||
ShowCaption := false;
|
||||
AllowAllUp := true;
|
||||
Hint := 'Italic';
|
||||
end;
|
||||
with Items.AddSmallButton do begin
|
||||
Caption := 'Underline';
|
||||
ButtonKind := bkToggle;
|
||||
TableBehaviour := tbContinuesRow;
|
||||
GroupBehaviour := gbEndsGroup;
|
||||
ImageIndex := 8;
|
||||
ShowCaption := false;
|
||||
AllowAllUp := true;
|
||||
Hint := 'Underlined';
|
||||
end;
|
||||
|
||||
with Items.AddSmallButton do begin
|
||||
Caption := 'Left-aligned';
|
||||
ButtonKind := bkToggle;
|
||||
GroupBehaviour := gbBeginsGroup;
|
||||
TableBehaviour := tbBeginsRow;
|
||||
ImageIndex := 11;
|
||||
ShowCaption := false;
|
||||
GroupIndex := 2;
|
||||
Checked := true;
|
||||
Hint := 'Left-aligned';
|
||||
end;
|
||||
with Items.AddSmallButton do begin
|
||||
Caption := 'Centered';
|
||||
ButtonKind := bkToggle;
|
||||
TableBehaviour := tbContinuesRow;
|
||||
GroupBehaviour := gbContinuesGroup;
|
||||
ImageIndex := 12;
|
||||
ShowCaption := false;
|
||||
GroupIndex := 2;
|
||||
Checked := false;
|
||||
Hint := 'Centered';
|
||||
end;
|
||||
with Items.AddSmallButton do begin
|
||||
Caption := 'Right-aligned';
|
||||
ButtonKind := bkToggle;
|
||||
TableBehaviour := tbContinuesRow;
|
||||
GroupBehaviour := gbContinuesGroup;
|
||||
ImageIndex := 13;
|
||||
ShowCaption := false;
|
||||
GroupIndex := 2;
|
||||
Hint := 'Right-aligned';
|
||||
end;
|
||||
with Items.AddSmallButton do begin
|
||||
Caption := 'Block';
|
||||
ButtonKind := bkToggle;
|
||||
TableBehaviour := tbContinuesRow;
|
||||
GroupBehaviour := gbEndsGroup;
|
||||
ImageIndex := 14;
|
||||
ShowCaption := false;
|
||||
GroupIndex := 2;
|
||||
Hint := 'Block';
|
||||
end;
|
||||
|
||||
with Items.AddSmallButton do begin
|
||||
Caption := 'Subscript';
|
||||
ButtonKind := bkToggle;
|
||||
TableBehaviour := tbBeginsColumn;
|
||||
GroupBehaviour := gbBeginsGroup;
|
||||
ImageIndex := 9;
|
||||
ShowCaption := false;
|
||||
AllowAllUp := true;
|
||||
GroupIndex := 1;
|
||||
Hint := 'Subscript';
|
||||
end;
|
||||
with Items.AddSmallButton do begin
|
||||
Caption := 'Superscript';
|
||||
ButtonKind := bkToggle;
|
||||
TableBehaviour := tbContinuesRow;
|
||||
GroupBehaviour := gbEndsGroup;
|
||||
ImageIndex := 10;
|
||||
ShowCaption := false;
|
||||
AllowAllUp := true;
|
||||
GroupIndex := 1;
|
||||
Hint := 'Superscript';
|
||||
end;
|
||||
|
||||
With Items.AddSmallButton do begin
|
||||
Enabled := false;
|
||||
TableBehaviour := tbBeginsRow;
|
||||
HideFrameWhenIdle := true;
|
||||
Caption := '';
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
with Tabs.Add do begin
|
||||
Caption := 'Options';
|
||||
with Panes.Add do begin
|
||||
Caption := 'Grid settings';
|
||||
CbHorizGrid := Items.AddCheckbox;
|
||||
with CbHorizGrid do begin
|
||||
Caption := 'Horizontal grid lines';
|
||||
TableBehaviour := tbBeginsRow;
|
||||
Checked := true;
|
||||
Hint := 'Show/hide horizontal grid lines';
|
||||
OnClick := @HorizontalGridLinesHandler;
|
||||
end;
|
||||
CbVertGrid := Items.AddCheckbox;
|
||||
with CbVertGrid do begin
|
||||
Caption := 'Vertical grid lines';
|
||||
Hint := 'Show/hide vertical grid lines';
|
||||
TableBehaviour := tbBeginsRow;
|
||||
Checked := true;
|
||||
OnClick := @VerticalGridLinesHandler;
|
||||
end;
|
||||
CbRowSelect := Items.AddCheckbox;
|
||||
with CbRowSelect do begin
|
||||
Caption := 'Row select';
|
||||
TableBehaviour := tbBeginsRow;
|
||||
Checked := false;
|
||||
Hint := 'Select entire row';
|
||||
OnClick := @RowSelectHandler;
|
||||
end;
|
||||
end;
|
||||
with Panes.Add do begin
|
||||
Caption := 'Themes';
|
||||
with Items.AddLargeButton do begin
|
||||
Caption := 'Change style';
|
||||
Hint := 'Change theme';
|
||||
ButtonKind := bkDropdown;
|
||||
DropdownMenu := StylePopupMenu;
|
||||
LargeImageIndex := 7;
|
||||
end;
|
||||
end;
|
||||
with Panes.Add do begin
|
||||
Caption := 'Save settings';
|
||||
with Items.AddSmallButton do begin
|
||||
Caption := 'Save now';
|
||||
Hint := 'Save settings now';
|
||||
ImageIndex := 2;
|
||||
end;
|
||||
with Items.AddCheckbox do begin
|
||||
Caption := 'Auto-save settings';
|
||||
Checked := true;
|
||||
Hint := 'Automatically save settings when program closes';
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
with Tabs.Add do begin
|
||||
Caption := 'Help';
|
||||
with Panes.Add do begin
|
||||
Caption := 'Help commands';
|
||||
with Items.AddLargeButton do begin
|
||||
Caption := 'About...';
|
||||
LargeImageIndex := 6;
|
||||
Hint := 'About this program';
|
||||
OnClick := @AboutHandler;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TForm1.StyleChangeHandler(Sender: TObject);
|
||||
var
|
||||
i: Integer;
|
||||
begin
|
||||
for i:=0 to StylePopupMenu.Items.Count-1 do
|
||||
StylePopupMenu.Items[i].Checked := StylePopupMenu.Items[i] = TMenuItem(Sender);
|
||||
SpkToolbar.Style := TSpkStyle((Sender as TMenuItem).Tag);
|
||||
case SpkToolbar.Style of
|
||||
spkOffice2007Blue : SpkToolbar.Color := clSkyBlue;
|
||||
spkOffice2007Silver : SpkToolbar.Color := clWhite;
|
||||
spkOffice2007SilverTurquoise : SpkToolbar.Color := clWhite;
|
||||
spkMetroLight : SpkToolbar.Color := clSilver;
|
||||
spkMetroDark : SpkToolbar.Color := $080808;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
end.
|
||||
|
82
spktoolbar/demos/styles/project1.lpi
Normal file
@@ -0,0 +1,82 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<CONFIG>
|
||||
<ProjectOptions>
|
||||
<Version Value="10"/>
|
||||
<PathDelim Value="\"/>
|
||||
<General>
|
||||
<SessionStorage Value="InProjectDir"/>
|
||||
<MainUnit Value="0"/>
|
||||
<Title Value="project1"/>
|
||||
<Scaled Value="True"/>
|
||||
<ResourceType Value="res"/>
|
||||
<UseXPManifest Value="True"/>
|
||||
</General>
|
||||
<BuildModes Count="1">
|
||||
<Item1 Name="Default" Default="True"/>
|
||||
</BuildModes>
|
||||
<PublishOptions>
|
||||
<Version Value="2"/>
|
||||
</PublishOptions>
|
||||
<RunParams>
|
||||
<local>
|
||||
<FormatVersion Value="1"/>
|
||||
</local>
|
||||
</RunParams>
|
||||
<RequiredPackages Count="2">
|
||||
<Item1>
|
||||
<PackageName Value="SpkToolbarPackage"/>
|
||||
</Item1>
|
||||
<Item2>
|
||||
<PackageName Value="LCL"/>
|
||||
</Item2>
|
||||
</RequiredPackages>
|
||||
<Units Count="2">
|
||||
<Unit0>
|
||||
<Filename Value="project1.lpr"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
</Unit0>
|
||||
<Unit1>
|
||||
<Filename Value="unit1.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<ComponentName Value="Form1"/>
|
||||
<HasResources Value="True"/>
|
||||
<ResourceBaseClass Value="Form"/>
|
||||
<UnitName Value="Unit1"/>
|
||||
</Unit1>
|
||||
</Units>
|
||||
</ProjectOptions>
|
||||
<CompilerOptions>
|
||||
<Version Value="11"/>
|
||||
<PathDelim Value="\"/>
|
||||
<Target>
|
||||
<Filename Value="project1"/>
|
||||
</Target>
|
||||
<SearchPaths>
|
||||
<IncludeFiles Value="$(ProjOutDir)"/>
|
||||
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
|
||||
</SearchPaths>
|
||||
<Linking>
|
||||
<Debugging>
|
||||
<UseExternalDbgSyms Value="True"/>
|
||||
</Debugging>
|
||||
<Options>
|
||||
<Win32>
|
||||
<GraphicApplication Value="True"/>
|
||||
</Win32>
|
||||
</Options>
|
||||
</Linking>
|
||||
</CompilerOptions>
|
||||
<Debugging>
|
||||
<Exceptions Count="3">
|
||||
<Item1>
|
||||
<Name Value="EAbort"/>
|
||||
</Item1>
|
||||
<Item2>
|
||||
<Name Value="ECodetoolError"/>
|
||||
</Item2>
|
||||
<Item3>
|
||||
<Name Value="EFOpenError"/>
|
||||
</Item3>
|
||||
</Exceptions>
|
||||
</Debugging>
|
||||
</CONFIG>
|
24
spktoolbar/demos/styles/project1.lpr
Normal file
@@ -0,0 +1,24 @@
|
||||
program project1;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
uses
|
||||
{$IFDEF UNIX}{$IFDEF UseCThreads}
|
||||
cthreads,
|
||||
{$ENDIF}{$ENDIF}
|
||||
Interfaces, // this includes the LCL widgetset
|
||||
LCLVersion, Forms, Unit1
|
||||
{ you can add units after this };
|
||||
|
||||
{$R *.res}
|
||||
|
||||
begin
|
||||
{$IF lcl_fullversion >= 1080000}
|
||||
Application.Scaled := True;
|
||||
{$ENDIF}
|
||||
RequireDerivedFormResource := True;
|
||||
Application.Initialize;
|
||||
Application.CreateForm(TForm1, Form1);
|
||||
Application.Run;
|
||||
end.
|
||||
|
2217
spktoolbar/demos/styles/unit1.lfm
Normal file
162
spktoolbar/demos/styles/unit1.pas
Normal file
@@ -0,0 +1,162 @@
|
||||
unit Unit1;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ExtCtrls,
|
||||
spktoolbar, spkt_Tab, spkt_Pane, spkt_Buttons, spkt_Checkboxes;
|
||||
|
||||
type
|
||||
|
||||
{ TForm1 }
|
||||
|
||||
TForm1 = class(TForm)
|
||||
LargeImages: TImageList;
|
||||
Panel1: TPanel;
|
||||
Panel2: TPanel;
|
||||
Panel3: TPanel;
|
||||
Panel4: TPanel;
|
||||
ScrollBox1: TScrollBox;
|
||||
SmallImages: TImageList;
|
||||
SpkCheckbox1: TSpkCheckbox;
|
||||
SpkCheckbox2: TSpkCheckbox;
|
||||
SpkCheckbox3: TSpkCheckbox;
|
||||
SpkCheckbox4: TSpkCheckbox;
|
||||
SpkCheckbox5: TSpkCheckbox;
|
||||
SpkLargeButton1: TSpkLargeButton;
|
||||
SpkLargeButton10: TSpkLargeButton;
|
||||
SpkLargeButton11: TSpkLargeButton;
|
||||
SpkLargeButton12: TSpkLargeButton;
|
||||
SpkLargeButton13: TSpkLargeButton;
|
||||
SpkLargeButton14: TSpkLargeButton;
|
||||
SpkLargeButton15: TSpkLargeButton;
|
||||
SpkLargeButton2: TSpkLargeButton;
|
||||
SpkLargeButton3: TSpkLargeButton;
|
||||
SpkLargeButton4: TSpkLargeButton;
|
||||
SpkLargeButton5: TSpkLargeButton;
|
||||
SpkLargeButton6: TSpkLargeButton;
|
||||
SpkLargeButton7: TSpkLargeButton;
|
||||
SpkLargeButton8: TSpkLargeButton;
|
||||
SpkLargeButton9: TSpkLargeButton;
|
||||
SpkPane1: TSpkPane;
|
||||
SpkPane10: TSpkPane;
|
||||
SpkPane11: TSpkPane;
|
||||
SpkPane12: TSpkPane;
|
||||
SpkPane13: TSpkPane;
|
||||
SpkPane14: TSpkPane;
|
||||
SpkPane15: TSpkPane;
|
||||
SpkPane16: TSpkPane;
|
||||
SpkPane17: TSpkPane;
|
||||
SpkPane18: TSpkPane;
|
||||
SpkPane19: TSpkPane;
|
||||
SpkPane2: TSpkPane;
|
||||
SpkPane20: TSpkPane;
|
||||
SpkPane3: TSpkPane;
|
||||
SpkPane4: TSpkPane;
|
||||
SpkPane5: TSpkPane;
|
||||
SpkPane6: TSpkPane;
|
||||
SpkPane7: TSpkPane;
|
||||
SpkPane8: TSpkPane;
|
||||
SpkPane9: TSpkPane;
|
||||
SpkSmallButton1: TSpkSmallButton;
|
||||
SpkSmallButton10: TSpkSmallButton;
|
||||
SpkSmallButton11: TSpkSmallButton;
|
||||
SpkSmallButton12: TSpkSmallButton;
|
||||
SpkSmallButton13: TSpkSmallButton;
|
||||
SpkSmallButton14: TSpkSmallButton;
|
||||
SpkSmallButton15: TSpkSmallButton;
|
||||
SpkSmallButton16: TSpkSmallButton;
|
||||
SpkSmallButton17: TSpkSmallButton;
|
||||
SpkSmallButton18: TSpkSmallButton;
|
||||
SpkSmallButton19: TSpkSmallButton;
|
||||
SpkSmallButton2: TSpkSmallButton;
|
||||
SpkSmallButton20: TSpkSmallButton;
|
||||
SpkSmallButton21: TSpkSmallButton;
|
||||
SpkSmallButton22: TSpkSmallButton;
|
||||
SpkSmallButton23: TSpkSmallButton;
|
||||
SpkSmallButton24: TSpkSmallButton;
|
||||
SpkSmallButton25: TSpkSmallButton;
|
||||
SpkSmallButton26: TSpkSmallButton;
|
||||
SpkSmallButton27: TSpkSmallButton;
|
||||
SpkSmallButton28: TSpkSmallButton;
|
||||
SpkSmallButton29: TSpkSmallButton;
|
||||
SpkSmallButton3: TSpkSmallButton;
|
||||
SpkSmallButton30: TSpkSmallButton;
|
||||
SpkSmallButton31: TSpkSmallButton;
|
||||
SpkSmallButton32: TSpkSmallButton;
|
||||
SpkSmallButton33: TSpkSmallButton;
|
||||
SpkSmallButton34: TSpkSmallButton;
|
||||
SpkSmallButton35: TSpkSmallButton;
|
||||
SpkSmallButton36: TSpkSmallButton;
|
||||
SpkSmallButton37: TSpkSmallButton;
|
||||
SpkSmallButton38: TSpkSmallButton;
|
||||
SpkSmallButton39: TSpkSmallButton;
|
||||
SpkSmallButton4: TSpkSmallButton;
|
||||
SpkSmallButton40: TSpkSmallButton;
|
||||
SpkSmallButton41: TSpkSmallButton;
|
||||
SpkSmallButton42: TSpkSmallButton;
|
||||
SpkSmallButton43: TSpkSmallButton;
|
||||
SpkSmallButton44: TSpkSmallButton;
|
||||
SpkSmallButton45: TSpkSmallButton;
|
||||
SpkSmallButton46: TSpkSmallButton;
|
||||
SpkSmallButton47: TSpkSmallButton;
|
||||
SpkSmallButton48: TSpkSmallButton;
|
||||
SpkSmallButton49: TSpkSmallButton;
|
||||
SpkSmallButton5: TSpkSmallButton;
|
||||
SpkSmallButton50: TSpkSmallButton;
|
||||
SpkSmallButton51: TSpkSmallButton;
|
||||
SpkSmallButton52: TSpkSmallButton;
|
||||
SpkSmallButton53: TSpkSmallButton;
|
||||
SpkSmallButton54: TSpkSmallButton;
|
||||
SpkSmallButton55: TSpkSmallButton;
|
||||
SpkSmallButton56: TSpkSmallButton;
|
||||
SpkSmallButton57: TSpkSmallButton;
|
||||
SpkSmallButton58: TSpkSmallButton;
|
||||
SpkSmallButton59: TSpkSmallButton;
|
||||
SpkSmallButton6: TSpkSmallButton;
|
||||
SpkSmallButton60: TSpkSmallButton;
|
||||
SpkSmallButton61: TSpkSmallButton;
|
||||
SpkSmallButton62: TSpkSmallButton;
|
||||
SpkSmallButton63: TSpkSmallButton;
|
||||
SpkSmallButton64: TSpkSmallButton;
|
||||
SpkSmallButton65: TSpkSmallButton;
|
||||
SpkSmallButton66: TSpkSmallButton;
|
||||
SpkSmallButton67: TSpkSmallButton;
|
||||
SpkSmallButton68: TSpkSmallButton;
|
||||
SpkSmallButton69: TSpkSmallButton;
|
||||
SpkSmallButton7: TSpkSmallButton;
|
||||
SpkSmallButton70: TSpkSmallButton;
|
||||
SpkSmallButton71: TSpkSmallButton;
|
||||
SpkSmallButton72: TSpkSmallButton;
|
||||
SpkSmallButton73: TSpkSmallButton;
|
||||
SpkSmallButton74: TSpkSmallButton;
|
||||
SpkSmallButton75: TSpkSmallButton;
|
||||
SpkSmallButton8: TSpkSmallButton;
|
||||
SpkSmallButton9: TSpkSmallButton;
|
||||
SpkTab1: TSpkTab;
|
||||
SpkTab2: TSpkTab;
|
||||
SpkTab4: TSpkTab;
|
||||
SpkTab5: TSpkTab;
|
||||
SpkTab6: TSpkTab;
|
||||
SpkToolbar1: TSpkToolbar;
|
||||
SpkToolbar2: TSpkToolbar;
|
||||
SpkToolbar3: TSpkToolbar;
|
||||
SpkToolbar4: TSpkToolbar;
|
||||
SpkToolbar5: TSpkToolbar;
|
||||
private
|
||||
|
||||
public
|
||||
|
||||
end;
|
||||
|
||||
var
|
||||
Form1: TForm1;
|
||||
|
||||
implementation
|
||||
|
||||
{$R *.lfm}
|
||||
|
||||
end.
|
||||
|
BIN
spktoolbar/designtime/GFX/Button-add.bmp
Normal file
After Width: | Height: | Size: 822 B |
BIN
spktoolbar/designtime/GFX/Button-remove.bmp
Normal file
After Width: | Height: | Size: 822 B |
BIN
spktoolbar/designtime/GFX/Button.bmp
Normal file
After Width: | Height: | Size: 822 B |
BIN
spktoolbar/designtime/GFX/Move-down.bmp
Normal file
After Width: | Height: | Size: 822 B |
BIN
spktoolbar/designtime/GFX/Move-up.bmp
Normal file
After Width: | Height: | Size: 822 B |
BIN
spktoolbar/designtime/GFX/Pane-add.bmp
Normal file
After Width: | Height: | Size: 822 B |
BIN
spktoolbar/designtime/GFX/Pane-remove.bmp
Normal file
After Width: | Height: | Size: 822 B |
BIN
spktoolbar/designtime/GFX/Pane.bmp
Normal file
After Width: | Height: | Size: 822 B |
BIN
spktoolbar/designtime/GFX/Tab-add.bmp
Normal file
After Width: | Height: | Size: 822 B |
BIN
spktoolbar/designtime/GFX/Tab-remove.bmp
Normal file
After Width: | Height: | Size: 822 B |
BIN
spktoolbar/designtime/GFX/Tab.bmp
Normal file
After Width: | Height: | Size: 822 B |
BIN
spktoolbar/designtime/GFX/Template.xcf
Normal file
380
spktoolbar/designtime/SpkToolbarEditor.pas
Normal file
@@ -0,0 +1,380 @@
|
||||
unit SpkToolbarEditor;
|
||||
|
||||
{$mode Delphi}
|
||||
|
||||
interface
|
||||
|
||||
uses Forms, Controls, Classes, ComponentEditors, PropEdits, LazarusPackageIntf, LazIdeIntf, TypInfo, Dialogs,
|
||||
SysUtils, ImgList, GraphPropEdits,
|
||||
spkToolbar, spkt_Tab, spkt_Buttons,
|
||||
spkte_EditWindow, spkte_AppearanceEditor;
|
||||
|
||||
const PROPERTY_CONTENTS_NAME = 'Contents';
|
||||
PROPERTY_CONTENTS_VALUE = 'Open editor...';
|
||||
|
||||
//type
|
||||
//
|
||||
// TAddContentsFilter = class(TSelectionEditor, ISelectionPropertyFilter)
|
||||
// public
|
||||
// procedure FilterProperties(const ASelection: IDesignerSelections; const ASelectionProperties: IInterfaceList);
|
||||
// end;
|
||||
//
|
||||
//TSpkToolbarContentsEditor = class(TBasePropertyEditor, IProperty, IPropertyKind)
|
||||
// private
|
||||
// protected
|
||||
// FPropList : PInstPropList;
|
||||
// FPropCount : integer;
|
||||
// FDesigner : IDesigner;
|
||||
// FToolbar : TSpkToolbar;
|
||||
//
|
||||
// procedure SetPropEntry(Index: Integer; AInstance: TPersistent;
|
||||
// APropInfo: PPropInfo); override;
|
||||
// procedure Initialize; override;
|
||||
// public
|
||||
// constructor Create(const ADesigner: IDesigner; APropCount: Integer); override;
|
||||
// destructor Destroy; override;
|
||||
//
|
||||
// procedure Activate;
|
||||
// function AllEqual: Boolean;
|
||||
// function AutoFill: Boolean;
|
||||
// procedure Edit;
|
||||
// function HasInstance(Instance: TPersistent): Boolean;
|
||||
// function GetAttributes: TPropertyAttributes;
|
||||
// function GetEditLimit: Integer;
|
||||
// function GetEditValue(out Value: string): Boolean;
|
||||
// function GetName: string;
|
||||
// procedure GetProperties(Proc: TGetPropProc);
|
||||
// function GetPropInfo: PPropInfo;
|
||||
// function GetPropType: PTypeInfo;
|
||||
// function GetValue: string;
|
||||
// procedure GetValues(Proc: TGetStrProc);
|
||||
// procedure Revert;
|
||||
// procedure SetValue(const Value: string);
|
||||
// function ValueAvailable: Boolean;
|
||||
//
|
||||
// function GetKind: TTypeKind;
|
||||
//
|
||||
// property PropCount : integer read FPropCount;
|
||||
// property Designer : IDesigner read FDesigner;
|
||||
// property Toolbar : TSpkToolbar read FToolbar write FToolbar;
|
||||
// end;
|
||||
|
||||
type TSpkToolbarCaptionEditor = class(TStringProperty)
|
||||
private
|
||||
protected
|
||||
public
|
||||
procedure SetValue(const Value: string); override;
|
||||
end;
|
||||
|
||||
type TSpkToolbarAppearanceEditor = class(TClassProperty)
|
||||
private
|
||||
protected
|
||||
public
|
||||
function GetAttributes: TPropertyAttributes; override;
|
||||
procedure Edit; override;
|
||||
end;
|
||||
|
||||
type TSpkToolbarEditor = class(TComponentEditor)
|
||||
protected
|
||||
procedure DoOpenContentsEditor;
|
||||
public
|
||||
procedure Edit; override;
|
||||
procedure ExecuteVerb(Index: Integer); override;
|
||||
function GetVerb(Index: Integer): string; override;
|
||||
function GetVerbCount: Integer; override;
|
||||
end;
|
||||
|
||||
type TSpkImageIndexPropertyEditor = class(TImageIndexPropertyEditor)
|
||||
protected
|
||||
function GetImageList: TCustomImageList; override;
|
||||
end;
|
||||
|
||||
var EditWindow : TfrmEditWindow;
|
||||
|
||||
implementation
|
||||
|
||||
{ TSpkToolbarEditor }
|
||||
|
||||
//procedure TSpkToolbarContentsEditor.Activate;
|
||||
//begin
|
||||
////
|
||||
//end;
|
||||
//
|
||||
//function TSpkToolbarContentsEditor.AllEqual: Boolean;
|
||||
//begin
|
||||
//result:=FPropCount = 1;
|
||||
//end;
|
||||
//
|
||||
//function TSpkToolbarContentsEditor.AutoFill: Boolean;
|
||||
//begin
|
||||
//result:=false;
|
||||
//end;
|
||||
//
|
||||
//constructor TSpkToolbarContentsEditor.Create(const ADesigner: IDesigner;
|
||||
// APropCount: Integer);
|
||||
//begin
|
||||
// inherited Create(ADesigner, APropCount);
|
||||
// FDesigner:=ADesigner;
|
||||
// FPropCount:=APropCount;
|
||||
// FToolbar:=nil;
|
||||
// GetMem(FPropList, APropCount * SizeOf(TInstProp));
|
||||
// FillChar(FPropList^, APropCount * SizeOf(TInstProp), 0);
|
||||
//end;
|
||||
//
|
||||
//destructor TSpkToolbarContentsEditor.Destroy;
|
||||
//begin
|
||||
// if FPropList <> nil then
|
||||
// FreeMem(FPropList, FPropCount * SizeOf(TInstProp));
|
||||
// inherited;
|
||||
//end;
|
||||
//
|
||||
//procedure TSpkToolbarContentsEditor.Edit;
|
||||
//begin
|
||||
// EditWindow.SetData(FToolbar,self.Designer);
|
||||
// EditWindow.Show;
|
||||
//end;
|
||||
//
|
||||
//function TSpkToolbarContentsEditor.GetAttributes: TPropertyAttributes;
|
||||
//begin
|
||||
//result:=[paDialog, paReadOnly];
|
||||
//end;
|
||||
//
|
||||
//function TSpkToolbarContentsEditor.GetEditLimit: Integer;
|
||||
//begin
|
||||
//result:=0;
|
||||
//end;
|
||||
//
|
||||
//function TSpkToolbarContentsEditor.GetEditValue(out Value: string): Boolean;
|
||||
//begin
|
||||
//Value:=GetValue;
|
||||
//result:=true;
|
||||
//end;
|
||||
//
|
||||
//function TSpkToolbarContentsEditor.GetKind: TTypeKind;
|
||||
//begin
|
||||
//result:=tkClass;
|
||||
//end;
|
||||
//
|
||||
//function TSpkToolbarContentsEditor.GetName: string;
|
||||
//begin
|
||||
//result:=PROPERTY_CONTENTS_NAME;
|
||||
//end;
|
||||
//
|
||||
//procedure TSpkToolbarContentsEditor.GetProperties(Proc: TGetPropProc);
|
||||
//begin
|
||||
////
|
||||
//end;
|
||||
//
|
||||
//function TSpkToolbarContentsEditor.GetPropInfo: PPropInfo;
|
||||
//begin
|
||||
//Result:=nil;
|
||||
//end;
|
||||
//
|
||||
//function TSpkToolbarContentsEditor.GetPropType: PTypeInfo;
|
||||
//begin
|
||||
//Result:=nil;
|
||||
//end;
|
||||
//
|
||||
//function TSpkToolbarContentsEditor.GetValue: string;
|
||||
//begin
|
||||
//result:=PROPERTY_CONTENTS_VALUE;
|
||||
//end;
|
||||
//
|
||||
//procedure TSpkToolbarContentsEditor.GetValues(Proc: TGetStrProc);
|
||||
//begin
|
||||
////
|
||||
//end;
|
||||
//
|
||||
//function TSpkToolbarContentsEditor.HasInstance(Instance: TPersistent): Boolean;
|
||||
//begin
|
||||
// result:=EditWindow.Toolbar = Instance;
|
||||
//end;
|
||||
//
|
||||
//procedure TSpkToolbarContentsEditor.Initialize;
|
||||
//begin
|
||||
// inherited;
|
||||
//end;
|
||||
//
|
||||
//procedure TSpkToolbarContentsEditor.Revert;
|
||||
//begin
|
||||
////
|
||||
//end;
|
||||
//
|
||||
//procedure TSpkToolbarContentsEditor.SetPropEntry(Index: Integer; AInstance: TPersistent;
|
||||
// APropInfo: PPropInfo);
|
||||
//begin
|
||||
//with FPropList^[Index] do
|
||||
// begin
|
||||
// Instance := AInstance;
|
||||
// PropInfo := APropInfo;
|
||||
// end;
|
||||
//end;
|
||||
//
|
||||
//procedure TSpkToolbarContentsEditor.SetValue(const Value: string);
|
||||
//begin
|
||||
////
|
||||
//end;
|
||||
//
|
||||
//function TSpkToolbarContentsEditor.ValueAvailable: Boolean;
|
||||
//begin
|
||||
//result:=true;
|
||||
//end;
|
||||
|
||||
{ TSelectionFilter }
|
||||
|
||||
//procedure TAddContentsFilter.FilterProperties(
|
||||
// const ASelection: IDesignerSelections;
|
||||
// const ASelectionProperties: IInterfaceList);
|
||||
//
|
||||
//var ContentsEditor : TSpkToolbarContentsEditor;
|
||||
// Prop : IProperty;
|
||||
// i : integer;
|
||||
// Added : boolean;
|
||||
//
|
||||
//begin
|
||||
//if ASelection.Count<>1 then
|
||||
// exit;
|
||||
//
|
||||
//if ASelection[0] is TSpkToolbar then
|
||||
// begin
|
||||
// ContentsEditor:=TSpkToolbarContentsEditor.Create(inherited Designer, 1);
|
||||
// ContentsEditor.Toolbar:=ASelection[0] as TSpkToolbar;
|
||||
//
|
||||
// i:=0;
|
||||
// Added:=false;
|
||||
// while (i<ASelectionProperties.Count) and not Added do
|
||||
// begin
|
||||
// ASelectionProperties.Items[i].QueryInterface(IProperty, Prop);
|
||||
// if (assigned(Prop)) and (Prop.GetName>PROPERTY_CONTENTS_NAME) then
|
||||
// begin
|
||||
// ASelectionProperties.Insert(i, ContentsEditor);
|
||||
// Added:=true;
|
||||
// end;
|
||||
// inc(i);
|
||||
// end;
|
||||
//
|
||||
// if not(Added) then
|
||||
// ASelectionProperties.Add(ContentsEditor as IProperty);
|
||||
// end;
|
||||
//end;
|
||||
|
||||
{ TSpkToolbarEditor }
|
||||
|
||||
procedure TSpkToolbarEditor.DoOpenContentsEditor;
|
||||
var
|
||||
Component: TComponent;
|
||||
begin
|
||||
Component:=self.GetComponent;
|
||||
if not(Component is TSpkToolbar) then
|
||||
exit;
|
||||
|
||||
if EditWindow = nil then
|
||||
EditWindow := TfrmEditWindow.Create(nil);
|
||||
EditWindow.SetData(TSpkToolbar(Component),Self.GetDesigner);
|
||||
EditWindow.Show;
|
||||
end;
|
||||
|
||||
procedure TSpkToolbarEditor.Edit;
|
||||
begin
|
||||
DoOpenContentsEditor;
|
||||
end;
|
||||
|
||||
procedure TSpkToolbarEditor.ExecuteVerb(Index: Integer);
|
||||
begin
|
||||
case Index of
|
||||
0 : DoOpenContentsEditor;
|
||||
end;
|
||||
end;
|
||||
|
||||
function TSpkToolbarEditor.GetVerb(Index: Integer): string;
|
||||
begin
|
||||
case Index of
|
||||
0 : result:='Contents editor...';
|
||||
end;
|
||||
end;
|
||||
|
||||
function TSpkToolbarEditor.GetVerbCount: Integer;
|
||||
begin
|
||||
Result := 1;
|
||||
end;
|
||||
|
||||
{ TSpkToolbarCaptionEditor }
|
||||
|
||||
procedure TSpkToolbarCaptionEditor.SetValue(const Value: string);
|
||||
begin
|
||||
inherited;
|
||||
EditWindow.RefreshNames;
|
||||
end;
|
||||
|
||||
{ TSpkImageIndexPropertyEditor }
|
||||
|
||||
function TSpkImageIndexPropertyEditor.GetImagelist: TCustomImageList;
|
||||
var
|
||||
Instance: TPersistent;
|
||||
begin
|
||||
Result := nil;
|
||||
Instance := GetComponent(0);
|
||||
if (Instance is TSpkLargeButton) then
|
||||
Result := TSpkLargeButton(Instance).Images
|
||||
else if (Instance is TSpkSmallButton) then
|
||||
Result := TSpkSmallButton(Instance).Images;
|
||||
end;
|
||||
|
||||
{ TSpkToolbarAppearanceEditor }
|
||||
|
||||
procedure TSpkToolbarAppearanceEditor.Edit;
|
||||
var
|
||||
Obj: TObject;
|
||||
Toolbar: TSpkToolbar;
|
||||
Tab: TSpkTab;
|
||||
AppearanceEditor: tfrmAppearanceEditWindow;
|
||||
begin
|
||||
Obj:=GetComponent(0);
|
||||
if Obj is TSpkToolbar then
|
||||
begin
|
||||
Toolbar := TSpkToolbar(Obj);
|
||||
|
||||
AppearanceEditor:=TfrmAppearanceEditWindow.Create(nil);
|
||||
try
|
||||
AppearanceEditor.Appearance.Assign(Toolbar.Appearance);
|
||||
if AppearanceEditor.ShowModal = mrOK then
|
||||
begin
|
||||
Toolbar.Appearance.Assign(AppearanceEditor.Appearance);
|
||||
Modified;
|
||||
end;
|
||||
finally
|
||||
AppearanceEditor.Free;
|
||||
end;
|
||||
|
||||
end else
|
||||
if Obj is TSpkTab then
|
||||
begin
|
||||
Tab:=TSpkTab(Obj);
|
||||
|
||||
AppearanceEditor:=TfrmAppearanceEditWindow.Create(nil);
|
||||
try
|
||||
AppearanceEditor.Appearance.Assign(Tab.CustomAppearance);
|
||||
if AppearanceEditor.ShowModal = mrOK then
|
||||
begin
|
||||
Tab.CustomAppearance.Assign(AppearanceEditor.Appearance);
|
||||
Modified;
|
||||
end;
|
||||
finally
|
||||
AppearanceEditor.Free;
|
||||
end;
|
||||
|
||||
end;
|
||||
end;
|
||||
|
||||
function TSpkToolbarAppearanceEditor.GetAttributes: TPropertyAttributes;
|
||||
begin
|
||||
result:=inherited GetAttributes + [paDialog] - [paMultiSelect];
|
||||
end;
|
||||
|
||||
initialization
|
||||
//EditWindow:=TfrmEditWindow.create(nil);
|
||||
|
||||
finalization
|
||||
EditWindow.Free;
|
||||
|
||||
end.
|
1
spktoolbar/designtime/icons/make_res.bat
Normal file
@@ -0,0 +1 @@
|
||||
lazres ..\SpkToolbar.lrs tspktoolbar.png tspktoolbar_150.png tspktoolbar_200.png
|
BIN
spktoolbar/designtime/icons/tspktoolbar.png
Normal file
After Width: | Height: | Size: 411 B |
BIN
spktoolbar/designtime/icons/tspktoolbar_150.png
Normal file
After Width: | Height: | Size: 551 B |
BIN
spktoolbar/designtime/icons/tspktoolbar_200.png
Normal file
After Width: | Height: | Size: 520 B |
2723
spktoolbar/designtime/spkte_AppearanceEditor.lfm
Normal file
1498
spktoolbar/designtime/spkte_AppearanceEditor.pas
Normal file
4249
spktoolbar/designtime/spkte_EditWindow.lfm
Normal file
1193
spktoolbar/designtime/spkte_EditWindow.pas
Normal file
24
spktoolbar/license.txt
Normal file
@@ -0,0 +1,24 @@
|
||||
This library is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU Library General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or (at your
|
||||
option) any later version with the following modification:
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent modules,and
|
||||
to copy and distribute the resulting executable under terms of your choice,
|
||||
provided that you also meet, for each linked independent module, the terms
|
||||
and conditions of the license of that module. An independent module is a
|
||||
module which is not derived from or based on this library. If you modify
|
||||
this library, you may extend this exception to your version of the library,
|
||||
but you are not obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version.
|
||||
|
||||
This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public License
|
||||
along with this library; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
27
spktoolbar/readme.txt
Normal file
@@ -0,0 +1,27 @@
|
||||
--------------------------------------------------------------------------------
|
||||
SpkToolbar
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
SpkToolbar is a ribbon-like toolbar.
|
||||
|
||||
Usage:
|
||||
Drop a TSpkToolbar component onto the form
|
||||
Double-click it and use the editor window to add tabs, panes and buttons.
|
||||
|
||||
Original author: Spook.
|
||||
Ported to Lazarus/LCL by Luiz Am<41>rico and Werner Pamler
|
||||
|
||||
License:
|
||||
Modified LGPL (with linking exception, like Lazarus LCL)
|
||||
See "license.txt" in this installation
|
||||
|
||||
Images and icons used
|
||||
The icons are taken from the FatCow icon set
|
||||
(http://www.fatcow.com/free-icons, license Creative Commons Attribution 3.0).
|
||||
Some images are combinations of individual images.
|
||||
|
||||
The component palette icon is drawn by Roland Hahn (free, no restrictions
|
||||
in usage).
|
||||
|
||||
|
||||
|
78
spktoolbar/registerspktoolbar.pas
Normal file
@@ -0,0 +1,78 @@
|
||||
unit RegisterSpkToolbar;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, LazarusPackageIntf, SpkToolbar, PropEdits, ComponentEditors,
|
||||
SpkToolbarEditor, spkt_Buttons, spkt_Checkboxes, spkt_Pane, spkt_Tab, spkt_Appearance,
|
||||
LResources;
|
||||
|
||||
procedure Register;
|
||||
|
||||
implementation
|
||||
|
||||
uses
|
||||
ImgList;
|
||||
|
||||
procedure RegisterUnitSpkToolbar;
|
||||
begin
|
||||
RegisterComponents('SpkToolbar', [TSpkToolbar]);
|
||||
end;
|
||||
|
||||
procedure RegisterUnitSpkt_Buttons;
|
||||
begin
|
||||
RegisterNoIcon([TSpkLargeButton, TSpkSmallButton]);
|
||||
end;
|
||||
|
||||
procedure RegisterUnitSpkt_Checkboxes;
|
||||
begin
|
||||
RegisterNoIcon([TSpkCheckbox, TSpkRadioButton]);
|
||||
end;
|
||||
|
||||
procedure RegisterUnitSpkt_Pane;
|
||||
begin
|
||||
RegisterNoIcon([TSpkPane]);
|
||||
end;
|
||||
|
||||
procedure RegisterUnitSpkt_Tab;
|
||||
begin
|
||||
RegisterNoIcon([TSpkTab]);
|
||||
end;
|
||||
|
||||
procedure Register;
|
||||
begin
|
||||
RegisterUnit('SpkToolbar', @RegisterUnitSpkToolbar);
|
||||
RegisterUnit('spkt_Buttons', @RegisterUnitSpkt_Buttons);
|
||||
RegisterUnit('spkt_Checkboxes', @RegisterUnitSpkt_Checkboxes);
|
||||
RegisterUnit('spkt_Pane', @RegisterUnitSpkt_Pane);
|
||||
RegisterUnit('spkt_Tab', @RegisterUnitSpkt_Tab);
|
||||
|
||||
RegisterComponentEditor(TSpkToolbar, TSpkToolbarEditor);
|
||||
RegisterPropertyEditor(TypeInfo(TSpkToolbarAppearance), TSpkToolbar,
|
||||
'Appearance', TSpkToolbarAppearanceEditor);
|
||||
RegisterPropertyEditor(TypeInfo(TImageIndex), TSpkLargeButton, '',
|
||||
TSpkImageIndexPropertyEditor);
|
||||
RegisterPropertyEditor(TypeInfo(TImageIndex), TSpkSmallButton, '',
|
||||
TSpkImageIndexPropertyEditor);
|
||||
//todo: register Caption Editor
|
||||
end;
|
||||
|
||||
procedure SkipObsoleteProperties;
|
||||
const
|
||||
GROUPBEHAVIOUR_NOTE = 'GroupBehaviour is not needed.';
|
||||
begin
|
||||
RegisterPropertyToSkip(TSpkCheckbox, 'Groupbehaviour', GROUPBEHAVIOUR_NOTE, '');
|
||||
RegisterPropertyToSkip(TSpkRadioButton, 'GroupBehaviour', GROUPBEHAVIOUR_NOTE, '');
|
||||
end;
|
||||
|
||||
|
||||
initialization
|
||||
{$I SpkToolbar.lrs}
|
||||
|
||||
SkipObsoleteProperties;
|
||||
|
||||
end.
|
||||
|
||||
|
145
spktoolbar/spktoolbarpackage.lpk
Normal file
@@ -0,0 +1,145 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<CONFIG>
|
||||
<Package Version="4">
|
||||
<PathDelim Value="\"/>
|
||||
<Name Value="SpkToolbarPackage"/>
|
||||
<Type Value="RunAndDesignTime"/>
|
||||
<Author Value="Spook. Ported to Lazarus/LCL by Luiz Américo and Werner Pamler"/>
|
||||
<CompilerOptions>
|
||||
<Version Value="11"/>
|
||||
<PathDelim Value="\"/>
|
||||
<SearchPaths>
|
||||
<IncludeFiles Value="SpkToolbar;designtime"/>
|
||||
<OtherUnitFiles Value="SpkToolbar;SpkMath;SpkGUITools;SpkGraphTools;SpkXML;designtime"/>
|
||||
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
|
||||
</SearchPaths>
|
||||
</CompilerOptions>
|
||||
<Description Value="Ribbon-like toolbar"/>
|
||||
<License Value="Modified LGPL (like Lazarus)"/>
|
||||
<Version Minor="1" Release="6"/>
|
||||
<Files Count="26">
|
||||
<Item1>
|
||||
<Filename Value="SpkToolbar\spkt_Appearance.pas"/>
|
||||
<UnitName Value="spkt_Appearance"/>
|
||||
</Item1>
|
||||
<Item2>
|
||||
<Filename Value="SpkToolbar\spkt_BaseItem.pas"/>
|
||||
<UnitName Value="spkt_BaseItem"/>
|
||||
</Item2>
|
||||
<Item3>
|
||||
<Filename Value="SpkToolbar\spkt_Buttons.pas"/>
|
||||
<UnitName Value="spkt_Buttons"/>
|
||||
</Item3>
|
||||
<Item4>
|
||||
<Filename Value="SpkToolbar\spkt_Const.pas"/>
|
||||
<UnitName Value="spkt_Const"/>
|
||||
</Item4>
|
||||
<Item5>
|
||||
<Filename Value="SpkToolbar\spkt_Dispatch.pas"/>
|
||||
<UnitName Value="spkt_Dispatch"/>
|
||||
</Item5>
|
||||
<Item6>
|
||||
<Filename Value="SpkToolbar\spkt_Exceptions.pas"/>
|
||||
<UnitName Value="spkt_Exceptions"/>
|
||||
</Item6>
|
||||
<Item7>
|
||||
<Filename Value="SpkToolbar\spkt_Items.pas"/>
|
||||
<UnitName Value="spkt_Items"/>
|
||||
</Item7>
|
||||
<Item8>
|
||||
<Filename Value="SpkToolbar\spkt_Pane.pas"/>
|
||||
<UnitName Value="spkt_Pane"/>
|
||||
</Item8>
|
||||
<Item9>
|
||||
<Filename Value="SpkToolbar\spkt_Tab.pas"/>
|
||||
<UnitName Value="spkt_Tab"/>
|
||||
</Item9>
|
||||
<Item10>
|
||||
<Filename Value="SpkToolbar\spkt_Tools.pas"/>
|
||||
<UnitName Value="spkt_Tools"/>
|
||||
</Item10>
|
||||
<Item11>
|
||||
<Filename Value="SpkToolbar\spkt_Types.pas"/>
|
||||
<UnitName Value="spkt_Types"/>
|
||||
</Item11>
|
||||
<Item12>
|
||||
<Filename Value="SpkToolbar\SpkToolbar.pas"/>
|
||||
<UnitName Value="SpkToolbar"/>
|
||||
</Item12>
|
||||
<Item13>
|
||||
<Filename Value="SpkMath\SpkMath.pas"/>
|
||||
<UnitName Value="SpkMath"/>
|
||||
</Item13>
|
||||
<Item14>
|
||||
<Filename Value="SpkGUITools\SpkGUITools.pas"/>
|
||||
<UnitName Value="SpkGUITools"/>
|
||||
</Item14>
|
||||
<Item15>
|
||||
<Filename Value="SpkGraphTools\SpkGraphTools.pas"/>
|
||||
<UnitName Value="SpkGraphTools"/>
|
||||
</Item15>
|
||||
<Item16>
|
||||
<Filename Value="SpkXML\SpkXMLIni.pas"/>
|
||||
<UnitName Value="SpkXMLIni"/>
|
||||
</Item16>
|
||||
<Item17>
|
||||
<Filename Value="SpkXML\SpkXMLParser.pas"/>
|
||||
<UnitName Value="SpkXMLParser"/>
|
||||
</Item17>
|
||||
<Item18>
|
||||
<Filename Value="SpkXML\SpkXMLTools.pas"/>
|
||||
<UnitName Value="SpkXMLTools"/>
|
||||
</Item18>
|
||||
<Item19>
|
||||
<Filename Value="registerspktoolbar.pas"/>
|
||||
<HasRegisterProc Value="True"/>
|
||||
<UnitName Value="RegisterSpkToolbar"/>
|
||||
</Item19>
|
||||
<Item20>
|
||||
<Filename Value="designtime\SpkToolbarEditor.pas"/>
|
||||
<UnitName Value="SpkToolbarEditor"/>
|
||||
</Item20>
|
||||
<Item21>
|
||||
<Filename Value="designtime\spkte_AppearanceEditor.lfm"/>
|
||||
<Type Value="LFM"/>
|
||||
</Item21>
|
||||
<Item22>
|
||||
<Filename Value="designtime\spkte_AppearanceEditor.pas"/>
|
||||
<UnitName Value="spkte_AppearanceEditor"/>
|
||||
</Item22>
|
||||
<Item23>
|
||||
<Filename Value="designtime\spkte_EditWindow.lfm"/>
|
||||
<Type Value="LFM"/>
|
||||
</Item23>
|
||||
<Item24>
|
||||
<Filename Value="designtime\spkte_EditWindow.pas"/>
|
||||
<UnitName Value="spkte_EditWindow"/>
|
||||
</Item24>
|
||||
<Item25>
|
||||
<Filename Value="SpkToolbar\spkt_Checkboxes.pas"/>
|
||||
<UnitName Value="spkt_Checkboxes"/>
|
||||
</Item25>
|
||||
<Item26>
|
||||
<Filename Value="designtime\SpkToolbar.lrs"/>
|
||||
<Type Value="LRS"/>
|
||||
</Item26>
|
||||
</Files>
|
||||
<RequiredPkgs Count="2">
|
||||
<Item1>
|
||||
<PackageName Value="IDEIntf"/>
|
||||
</Item1>
|
||||
<Item2>
|
||||
<PackageName Value="LCL"/>
|
||||
</Item2>
|
||||
</RequiredPkgs>
|
||||
<UsageOptions>
|
||||
<UnitPath Value="$(PkgOutDir)"/>
|
||||
</UsageOptions>
|
||||
<PublishOptions>
|
||||
<Version Value="2"/>
|
||||
</PublishOptions>
|
||||
<CustomOptions Items="ExternHelp" Version="2">
|
||||
<_ExternHelp Items="Count"/>
|
||||
</CustomOptions>
|
||||
</Package>
|
||||
</CONFIG>
|
25
spktoolbar/spktoolbarpackage.pas
Normal file
@@ -0,0 +1,25 @@
|
||||
{ This file was automatically created by Lazarus. Do not edit!
|
||||
This source is only used to compile and install the package.
|
||||
}
|
||||
|
||||
unit SpkToolbarPackage;
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
spkt_Appearance, spkt_BaseItem, spkt_Buttons, spkt_Const, spkt_Dispatch,
|
||||
spkt_Exceptions, spkt_Items, spkt_Pane, spkt_Tab, spkt_Tools, spkt_Types,
|
||||
SpkToolbar, SpkMath, SpkGUITools, SpkGraphTools, SpkXMLIni, SpkXMLParser,
|
||||
SpkXMLTools, RegisterSpkToolbar, SpkToolbarEditor, spkte_AppearanceEditor,
|
||||
spkte_EditWindow, spkt_Checkboxes, LazarusPackageIntf;
|
||||
|
||||
implementation
|
||||
|
||||
procedure Register;
|
||||
begin
|
||||
RegisterUnit('RegisterSpkToolbar', @RegisterSpkToolbar.Register);
|
||||
end;
|
||||
|
||||
initialization
|
||||
RegisterPackage('SpkToolbarPackage', @Register);
|
||||
end.
|