mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-10-24 09:11:44 +02:00
customdrawn: Large rewrite of the drawers structure
git-svn-id: trunk@33252 -
This commit is contained in:
parent
07eb980906
commit
bfec5acd5f
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -647,6 +647,7 @@ components/customdrawn/customdrawn_win2000.pas svneol=native#text/plain
|
||||
components/customdrawn/customdrawn_wince.pas svneol=native#text/plain
|
||||
components/customdrawn/customdrawn_winxp.pas svneol=native#text/plain
|
||||
components/customdrawn/customdrawncontrols.pas svneol=native#text/pascal
|
||||
components/customdrawn/customdrawndrawers.pas svneol=native#text/plain
|
||||
components/customdrawn/customdrawnextras.pas svneol=native#text/plain
|
||||
components/customdrawn/customdrawnutils.pas svneol=native#text/pascal
|
||||
components/customform/custforms.pp svneol=native#text/plain
|
||||
|
||||
@ -17,7 +17,7 @@
|
||||
<CompilerPath Value="$(CompPath)"/>
|
||||
</Other>
|
||||
</CompilerOptions>
|
||||
<Files Count="11">
|
||||
<Files Count="12">
|
||||
<Item1>
|
||||
<Filename Value="customdrawnextras.pas"/>
|
||||
<HasRegisterProc Value="True"/>
|
||||
@ -63,6 +63,10 @@
|
||||
<Filename Value="customdrawn_common.pas"/>
|
||||
<UnitName Value="customdrawn_common"/>
|
||||
</Item11>
|
||||
<Item12>
|
||||
<Filename Value="customdrawndrawers.pas"/>
|
||||
<UnitName Value="customdrawndrawers"/>
|
||||
</Item12>
|
||||
</Files>
|
||||
<Type Value="RunAndDesignTime"/>
|
||||
<RequiredPkgs Count="3">
|
||||
|
||||
@ -10,7 +10,7 @@ uses
|
||||
customdrawnextras, customdrawnutils, customdrawncontrols, customdrawn_wince,
|
||||
customdrawn_win2000, customdrawn_winxp, customdrawn_android,
|
||||
customdrawn_extra1, customdrawn_kde, customdrawn_gnome, customdrawn_common,
|
||||
LazarusPackageIntf;
|
||||
customdrawndrawers, LazarusPackageIntf;
|
||||
|
||||
implementation
|
||||
|
||||
|
||||
@ -14,16 +14,16 @@ uses
|
||||
//
|
||||
customdrawncontrols, customdrawnutils;
|
||||
|
||||
type
|
||||
{type
|
||||
TCDButtonDrawerAndroid = class(TCDButtonDrawer)
|
||||
public
|
||||
procedure DrawToIntfImage(ADest: TFPImageCanvas; CDButton: TCDButton); override;
|
||||
procedure DrawToCanvas(ADest: TCanvas; CDButton: TCDButton); override;
|
||||
end;
|
||||
end;}
|
||||
|
||||
implementation
|
||||
|
||||
procedure TCDButtonDrawerAndroid.DrawToIntfImage(ADest: TFPImageCanvas;
|
||||
{procedure TCDButtonDrawerAndroid.DrawToIntfImage(ADest: TFPImageCanvas;
|
||||
CDButton: TCDButton);
|
||||
begin
|
||||
|
||||
@ -66,6 +66,6 @@ begin
|
||||
end;
|
||||
|
||||
initialization
|
||||
RegisterButtonDrawer(TCDButtonDrawerAndroid.Create, dsAndroid);
|
||||
RegisterButtonDrawer(TCDButtonDrawerAndroid.Create, dsAndroid);}
|
||||
end.
|
||||
|
||||
|
||||
@ -6,69 +6,67 @@ interface
|
||||
|
||||
uses
|
||||
// RTL
|
||||
Classes, SysUtils,
|
||||
Classes, SysUtils, Types,
|
||||
// fpimage
|
||||
fpcanvas, fpimgcanv, fpimage,
|
||||
// LCL -> Use only TForm, TWinControl, TCanvas and TLazIntfImage
|
||||
Graphics, Controls, LCLType, LCLIntf, IntfGraphics,
|
||||
Graphics, Controls, LCLType, LCLIntf, //IntfGraphics,
|
||||
// Others only for types
|
||||
StdCtrls,
|
||||
//
|
||||
customdrawncontrols, customdrawnutils;
|
||||
customdrawndrawers;
|
||||
|
||||
type
|
||||
TCDButtonDrawerCommon = class(TCDButtonDrawer)
|
||||
public
|
||||
procedure DrawToIntfImage(ADest: TFPImageCanvas; CDButton: TCDButton); override;
|
||||
procedure DrawToCanvas(ADest: TCanvas; CDButton: TCDButton); override;
|
||||
end;
|
||||
|
||||
{ TCDEditDrawerCommon }
|
||||
{ TCDDrawerCommon }
|
||||
|
||||
TCDEditDrawerCommon = class(TCDEditDrawer)
|
||||
TCDDrawerCommon = class(TCDDrawer)
|
||||
public
|
||||
// General
|
||||
function GetMeasures(AMeasureID: Integer): Integer; override;
|
||||
function GetMeasuresEx(ADest: TCanvas; AMeasureID: Integer;
|
||||
AState: TCDControlState; AStateEx: TCDControlStateEx): Integer; override;
|
||||
function GetColor(AColorID: Integer): TColor; override;
|
||||
procedure DrawToIntfImage(ADest: TFPImageCanvas; CDControl: TCDControl); override;
|
||||
procedure DrawBackground(ADest: TCanvas; AControl: TCDControl); override;
|
||||
procedure DrawToCanvas(ADest: TCanvas; CDControl: TCDControl); override;
|
||||
end;
|
||||
|
||||
{ TCDCheckBoxDrawerCommon }
|
||||
|
||||
TCDCheckBoxDrawerCommon = class(TCDCheckBoxDrawer)
|
||||
public
|
||||
function GetCaptionWidth(CDCheckBox: TCDCheckBox): Integer;
|
||||
function GetCaptionHeight(CDCheckBox: TCDCheckBox): Integer;
|
||||
procedure CalculatePreferredSize(CDCheckBox: TCDCheckBox; var PreferredWidth,
|
||||
PreferredHeight: integer; WithThemeSpace: Boolean); override;
|
||||
procedure DrawToIntfImage(ADest: TFPImageCanvas; CDCheckBox: TCDCheckBox); override;
|
||||
procedure DrawToCanvas(ADest: TCanvas; CDCheckBox: TCDCheckBox); override;
|
||||
end;
|
||||
|
||||
TCDGroupBoxDrawerCommon = class(TCDGroupBoxDrawer)
|
||||
public
|
||||
FCaptionMiddle: integer;
|
||||
procedure SetClientRectPos(CDGroupBox: TCDGroupBox); override;
|
||||
procedure DrawToIntfImage(ADest: TFPImageCanvas; CDGroupBox: TCDGroupBox); override;
|
||||
procedure DrawToCanvas(ADest: TCanvas; CDGroupBox: TCDGroupBox); override;
|
||||
end;
|
||||
|
||||
// ===================================
|
||||
// Common Controls Tab
|
||||
// ===================================
|
||||
|
||||
{ TCDListViewDrawerCommon }
|
||||
|
||||
TCDListViewDrawerCommon = class(TCDListViewDrawer)
|
||||
public
|
||||
procedure DrawToIntfImage(ADest: TFPImageCanvas; CDListView: TCDListView); override;
|
||||
procedure DrawToCanvas(ADest: TCanvas; CDListView: TCDListView); override;
|
||||
procedure DrawControl(ADest: TCanvas; ADestPos: TPoint; ASize: TSize;
|
||||
AControl: TCDControlID; AState: TCDControlState; AStateEx: TCDControlStateEx); override;
|
||||
// ===================================
|
||||
// Standard Tab
|
||||
// ===================================
|
||||
// TCDButton
|
||||
procedure DrawButton(ADest: TCanvas; ADestPos: TPoint; ASize: TSize;
|
||||
AState: TCDControlState; AStateEx: TCDControlStateEx); override;
|
||||
// TCDEdit
|
||||
procedure CreateEditBackgroundBitmap(ADest: TCanvas; ADestPos: TPoint; ASize: TSize;
|
||||
AState: TCDControlState; AStateEx: TCDEditStateEx); override;
|
||||
procedure DrawEdit(ADest: TCanvas; ADestPos: TPoint; ASize: TSize;
|
||||
AState: TCDControlState; AStateEx: TCDEditStateEx); override;
|
||||
// TCDCheckBox
|
||||
procedure CalculateCheckBoxPreferredSize(ADest: TCanvas;
|
||||
AState: TCDControlState; AStateEx: TCDControlStateEx;
|
||||
var PreferredWidth, PreferredHeight: integer; WithThemeSpace: Boolean); override;
|
||||
procedure DrawCheckBox(ADest: TCanvas; ADestPos: TPoint; ASize: TSize;
|
||||
AState: TCDControlState; AStateEx: TCDControlStateEx); override;
|
||||
// TCDGroupBox
|
||||
procedure DrawGroupBox(ADest: TCanvas; ADestPos: TPoint; ASize: TSize;
|
||||
AState: TCDControlState; AStateEx: TCDControlStateEx); override;
|
||||
// ===================================
|
||||
// Common Controls Tab
|
||||
// ===================================
|
||||
// TCDCustomTabControl
|
||||
procedure DrawCTabControl(ADest: TCanvas; ADestPos: TPoint; ASize: TSize;
|
||||
AState: TCDControlState; AStateEx: TCDCTabControlStateEx); override;
|
||||
procedure DrawTabSheet(ADest: TCanvas; ADestPos: TPoint; ASize: TSize;
|
||||
AState: TCDControlState; AStateEx: TCDCTabControlStateEx); override;
|
||||
procedure DrawTabs(ADest: TCanvas; ADestPos: TPoint; ASize: TSize;
|
||||
AState: TCDControlState; AStateEx: TCDCTabControlStateEx); override;
|
||||
procedure DrawTab(ADest: TCanvas; ADestPos: TPoint; ASize: TSize;
|
||||
AState: TCDControlState; AStateEx: TCDCTabControlStateEx); override;
|
||||
function GetPageIndexFromXY(x, y: integer): integer; override;
|
||||
end;
|
||||
|
||||
{ TCDCustomTabControlDrawerCommon }
|
||||
|
||||
TCDCustomTabControlDrawerCommon = class(TCDCustomTabControlDrawer)
|
||||
{ TCDCustomTabControlDrawerCommon = class(TCDCustomTabControlDrawer)
|
||||
private
|
||||
StartIndex: integer; //FEndIndex
|
||||
LeftmostTabVisibleIndex: Integer;
|
||||
@ -79,7 +77,6 @@ type
|
||||
function GetPageIndexFromXY(x, y: integer): integer; override;
|
||||
function GetTabHeight(AIndex: Integer; CDTabControl: TCDCustomTabControl): Integer; override;
|
||||
function GetTabWidth(ADest: TCanvas; AIndex: Integer; CDTabControl: TCDCustomTabControl): Integer; override;
|
||||
//function GetClientRect(AControl: TCDControl): TRect; override;
|
||||
procedure DrawToIntfImage(ADest: TFPImageCanvas; FPImg: TLazIntfImage;
|
||||
CDTabControl: TCDCustomTabControl); override;
|
||||
procedure DrawToCanvas(ADest: TCanvas; CDTabControl: TCDCustomTabControl); override;
|
||||
@ -88,13 +85,285 @@ type
|
||||
X, Y: integer; CDTabControl: TCDCustomTabControl); override;
|
||||
procedure MouseUp(Button: TMouseButton; Shift: TShiftState;
|
||||
X, Y: integer; CDTabControl: TCDCustomTabControl); override;
|
||||
end;
|
||||
end;}
|
||||
|
||||
implementation
|
||||
|
||||
{ TCDDrawerCommon }
|
||||
|
||||
function TCDDrawerCommon.GetMeasures(AMeasureID: Integer): Integer;
|
||||
begin
|
||||
case AMeasureID of
|
||||
TCDEDIT_LEFT_TEXT_SPACING: Result := 4;
|
||||
TCDEDIT_RIGHT_TEXT_SPACING: Result := 3;
|
||||
else
|
||||
Result := 0;
|
||||
end;
|
||||
end;
|
||||
|
||||
function TCDDrawerCommon.GetMeasuresEx(ADest: TCanvas; AMeasureID: Integer;
|
||||
AState: TCDControlState; AStateEx: TCDControlStateEx): Integer;
|
||||
const
|
||||
TCDTabControl_Common_TabCaptionExtraWidth = 20;
|
||||
var
|
||||
ATabsStateEx: TCDCTabControlStateEx absolute AStateEx;
|
||||
lCaption: String;
|
||||
begin
|
||||
case AMeasureID of
|
||||
TCDCONTROL_CAPTION_WIDTH: Result := ADest.TextWidth(AStateEx.Caption);
|
||||
TCDCONTROL_CAPTION_HEIGHT: Result := ADest.TextHeight('ŹÇ')+3;
|
||||
TCDCTABCONTROL_TAB_HEIGHT:
|
||||
begin
|
||||
if AStateEx.Font.Size = 0 then Result := 32
|
||||
else Result := AStateEx.Font.Size + 22;
|
||||
end;
|
||||
TCDCTABCONTROL_TAB_WIDTH:
|
||||
begin
|
||||
lCaption := ATabsStateEx.Tabs.Strings[ATabsStateEx.TabIndex];
|
||||
Result := ADest.TextWidth(lCaption) + TCDTabControl_Common_TabCaptionExtraWidth;
|
||||
end
|
||||
else
|
||||
Result := 0;
|
||||
end;
|
||||
end;
|
||||
|
||||
function TCDDrawerCommon.GetColor(AColorID: Integer): TColor;
|
||||
begin
|
||||
case AColorId of
|
||||
TCDEDIT_BACKGROUND_COLOR: Result := clWhite;
|
||||
TCDEDIT_TEXT_COLOR: Result := clBlack;
|
||||
TCDEDIT_SELECTED_BACKGROUND_COLOR: Result := clBlue;
|
||||
TCDEDIT_SELECTED_TEXT_COLOR: Result := clWhite;
|
||||
else
|
||||
Result := clBlack;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TCDDrawerCommon.DrawControl(ADest: TCanvas; ADestPos: TPoint;
|
||||
ASize: TSize; AControl: TCDControlID; AState: TCDControlState;
|
||||
AStateEx: TCDControlStateEx);
|
||||
begin
|
||||
case AControl of
|
||||
cidButton: DrawButton(ADest, ADestPos, ASize, AState, AStateEx);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TCDDrawerCommon.DrawButton(ADest: TCanvas; ADestPos: TPoint;
|
||||
ASize: TSize; AState: TCDControlState; AStateEx: TCDControlStateEx);
|
||||
var
|
||||
TmpB: TBitmap;
|
||||
Str: string;
|
||||
begin
|
||||
// Button shape -> This crashes in Gtk2
|
||||
TmpB := TBitmap.Create;
|
||||
TmpB.Width := ASize.cx;
|
||||
TmpB.Height := ASize.cy;
|
||||
TmpB.Canvas.Brush.Color := AStateEx.RGBColor;
|
||||
TmpB.Canvas.Brush.Style := bsSolid;
|
||||
TmpB.Canvas.RoundRect(0, 0, TmpB.Width, TmpB.Height, 8, 8);
|
||||
// CDButton.SetShape(TmpB);
|
||||
|
||||
// Button image
|
||||
if csfSunken in AState then
|
||||
begin
|
||||
TmpB.Canvas.Brush.Style := bsSolid;
|
||||
TmpB.Canvas.Brush.Color := RGBToColor(230, 230, 230);
|
||||
TmpB.Canvas.Pen.Color := clBlack;
|
||||
TmpB.Canvas.Pen.Style := psSolid;
|
||||
TmpB.Canvas.Rectangle(0, 0, TmpB.Canvas.Width, TmpB.Canvas.Height);
|
||||
end
|
||||
else if csfHasFocus in AState then
|
||||
begin
|
||||
with TmpB.Canvas do
|
||||
begin
|
||||
Brush.Style := bsSolid;
|
||||
Brush.Color := RGBToColor($FD, $FD, $FD);
|
||||
Pen.Color := clBlack;
|
||||
Pen.Style := psSolid;
|
||||
Rectangle(0, 0, Width, Height);
|
||||
Rectangle(1, 1, Width - 1, Height - 1); // The border is thicken when focused
|
||||
end;
|
||||
end
|
||||
else
|
||||
begin
|
||||
with TmpB.Canvas do
|
||||
begin
|
||||
Brush.Style := bsSolid;
|
||||
Brush.Color := AStateEx.RGBColor;
|
||||
Pen.Color := clBlack;
|
||||
Pen.Style := psSolid;
|
||||
Rectangle(0, 0, Width, Height);
|
||||
end;
|
||||
end;
|
||||
|
||||
ADest.Draw(0, 0, TmpB);
|
||||
|
||||
TmpB.Free;
|
||||
|
||||
// Button text
|
||||
ADest.Font.Assign(AStateEx.Font);
|
||||
ADest.Brush.Style := bsClear;
|
||||
ADest.Pen.Style := psSolid;
|
||||
Str := AStateEx.Caption;
|
||||
ADest.TextOut((ASize.cx - ADest.TextWidth(Str)) div 2,
|
||||
(ASize.cy - ADest.TextHeight(Str)) div 2, Str);
|
||||
end;
|
||||
|
||||
procedure TCDDrawerCommon.CreateEditBackgroundBitmap(ADest: TCanvas;
|
||||
ADestPos: TPoint; ASize: TSize; AState: TCDControlState;
|
||||
AStateEx: TCDEditStateEx);
|
||||
begin
|
||||
// The background
|
||||
ADest.Brush.Color := clWhite;
|
||||
ADest.Brush.Style := bsSolid;
|
||||
ADest.Pen.Color := clBlack;
|
||||
ADest.Pen.Style := psSolid;
|
||||
ADest.Rectangle(0, 0, ASize.cx, ASize.cy);
|
||||
end;
|
||||
|
||||
procedure TCDDrawerCommon.DrawEdit(ADest: TCanvas; ADestPos: TPoint;
|
||||
ASize: TSize; AState: TCDControlState; AStateEx: TCDEditStateEx);
|
||||
begin
|
||||
|
||||
end;
|
||||
|
||||
procedure TCDDrawerCommon.CalculateCheckBoxPreferredSize(ADest: TCanvas;
|
||||
AState: TCDControlState; AStateEx: TCDControlStateEx; var PreferredWidth,
|
||||
PreferredHeight: integer; WithThemeSpace: Boolean);
|
||||
begin
|
||||
PreferredWidth := 0;
|
||||
|
||||
if AStateEx.AutoSize then
|
||||
PreferredWidth := 21 + GetMeasuresEx(ADest, TCDCONTROL_CAPTION_WIDTH, AState, AStateEx);
|
||||
|
||||
PreferredHeight := GetMeasuresEx(ADest, TCDCONTROL_CAPTION_HEIGHT, AState, AStateEx);
|
||||
end;
|
||||
|
||||
procedure TCDDrawerCommon.DrawCheckBox(ADest: TCanvas; ADestPos: TPoint;
|
||||
ASize: TSize; AState: TCDControlState; AStateEx: TCDControlStateEx);
|
||||
const
|
||||
CDCheckBoxCommon_Half_Height = 7;
|
||||
CDCheckBoxCommon_Height = 15;
|
||||
var
|
||||
lHalf: Integer;
|
||||
lColor: TColor;
|
||||
i: Integer;
|
||||
begin
|
||||
lHalf := ASize.cy div 2;
|
||||
|
||||
// Background
|
||||
lColor := AStateEx.ParentRGBColor;
|
||||
ADest.Brush.Color := lColor;
|
||||
ADest.Brush.Style := bsSolid;
|
||||
ADest.Pen.Style := psClear;
|
||||
ADest.FillRect(0, 0, ASize.cx, ASize.cy);
|
||||
|
||||
// The checkbox item itself
|
||||
ADest.Brush.Color := clWhite;
|
||||
ADest.Pen.Style := psSolid;
|
||||
if csfSunken in AState then ADest.Pen.Color := clGray
|
||||
else ADest.Pen.Color := clBlack;
|
||||
ADest.Rectangle(
|
||||
1,
|
||||
lHalf - CDCheckBoxCommon_Half_Height,
|
||||
CDCheckBoxCommon_Height+1,
|
||||
lHalf + CDCheckBoxCommon_Half_Height);
|
||||
|
||||
// The Tickmark
|
||||
if csfOn in AState then
|
||||
begin
|
||||
// 4 lines going down and to the right
|
||||
for i := 0 to 3 do
|
||||
ADest.Line(5+i, lHalf - CDCheckBoxCommon_Half_Height+5+i, 5+i, lHalf - CDCheckBoxCommon_Half_Height+8+i);
|
||||
// Now 5 lines going up and to the right
|
||||
for i := 4 to 8 do
|
||||
ADest.Line(5+i, lHalf - CDCheckBoxCommon_Half_Height+5+6-i, 5+i, lHalf - CDCheckBoxCommon_Half_Height+8+6-i);
|
||||
end;
|
||||
|
||||
// The selection
|
||||
ADest.Brush.Style := bsClear;
|
||||
ADest.Pen.Color := RGBToColor($31, $C6, $D6);
|
||||
ADest.Pen.Style := psSolid;
|
||||
if csfHasFocus in AState then
|
||||
begin
|
||||
// The selection inside the square
|
||||
ADest.Rectangle(
|
||||
2,
|
||||
lHalf - CDCheckBoxCommon_Half_Height+1,
|
||||
CDCheckBoxCommon_Height,
|
||||
lHalf + CDCheckBoxCommon_Half_Height-1);
|
||||
|
||||
// Selection around the text
|
||||
ADest.Rectangle(
|
||||
CDCheckBoxCommon_Height+4, 0,
|
||||
ASize.cx, ASize.cy);
|
||||
end;
|
||||
|
||||
// Now the text
|
||||
ADest.Font.Assign(AStateEx.Font);
|
||||
ADest.TextOut(CDCheckBoxCommon_Height+5, 0, AStateEx.Caption);
|
||||
end;
|
||||
|
||||
procedure TCDDrawerCommon.DrawGroupBox(ADest: TCanvas; ADestPos: TPoint;
|
||||
ASize: TSize; AState: TCDControlState; AStateEx: TCDControlStateEx);
|
||||
var
|
||||
FCaptionMiddle: integer;
|
||||
begin
|
||||
FCaptionMiddle := ADest.TextHeight('Ź') div 2;
|
||||
if FCaptionMiddle = 0 then FCaptionMiddle := AStateEx.Font.Size div 2;
|
||||
if FCaptionMiddle = 0 then FCaptionMiddle := 5;
|
||||
|
||||
// Background
|
||||
ADest.Brush.Color := AStateEx.ParentRGBColor;
|
||||
ADest.Brush.Style := bsSolid;
|
||||
ADest.Pen.Style := psClear;
|
||||
ADest.Rectangle(0, 0, ASize.cx, ASize.cy);
|
||||
|
||||
// frame
|
||||
ADest.Pen.FPColor := colBlack;
|
||||
ADest.Pen.Style := psSolid;
|
||||
ADest.Brush.Style := bsClear;
|
||||
ADest.Rectangle(0, FCaptionMiddle, ASize.cx - 1, ASize.cy - 1);
|
||||
|
||||
// paint text
|
||||
ADest.Pen.Style := psSolid;
|
||||
ADest.Brush.Style := bsSolid; // This will fill the text background
|
||||
ADest.Font.Size := 10;
|
||||
ADest.TextOut(FCaptionMiddle, 0, AStateEx.Caption);
|
||||
end;
|
||||
|
||||
procedure TCDDrawerCommon.DrawCTabControl(ADest: TCanvas; ADestPos: TPoint;
|
||||
ASize: TSize; AState: TCDControlState; AStateEx: TCDCTabControlStateEx);
|
||||
begin
|
||||
|
||||
end;
|
||||
|
||||
procedure TCDDrawerCommon.DrawTabSheet(ADest: TCanvas; ADestPos: TPoint;
|
||||
ASize: TSize; AState: TCDControlState; AStateEx: TCDCTabControlStateEx);
|
||||
begin
|
||||
|
||||
end;
|
||||
|
||||
procedure TCDDrawerCommon.DrawTabs(ADest: TCanvas; ADestPos: TPoint;
|
||||
ASize: TSize; AState: TCDControlState; AStateEx: TCDCTabControlStateEx);
|
||||
begin
|
||||
|
||||
end;
|
||||
|
||||
procedure TCDDrawerCommon.DrawTab(ADest: TCanvas; ADestPos: TPoint;
|
||||
ASize: TSize; AState: TCDControlState; AStateEx: TCDCTabControlStateEx);
|
||||
begin
|
||||
|
||||
end;
|
||||
|
||||
function TCDDrawerCommon.GetPageIndexFromXY(x, y: integer): integer;
|
||||
begin
|
||||
|
||||
end;
|
||||
|
||||
{ TCDListViewDrawerCommon }
|
||||
|
||||
procedure TCDListViewDrawerCommon.DrawToIntfImage(ADest: TFPImageCanvas;
|
||||
(*procedure TCDListViewDrawerCommon.DrawToIntfImage(ADest: TFPImageCanvas;
|
||||
CDListView: TCDListView);
|
||||
begin
|
||||
|
||||
@ -106,47 +375,6 @@ begin
|
||||
|
||||
end;
|
||||
|
||||
{ TCDEditDrawerCommon }
|
||||
|
||||
function TCDEditDrawerCommon.GetMeasures(AMeasureID: Integer): Integer;
|
||||
begin
|
||||
case AMeasureID of
|
||||
TCDEDIT_LEFT_TEXT_SPACING: Result := 4;
|
||||
TCDEDIT_RIGHT_TEXT_SPACING: Result := 3;
|
||||
else
|
||||
Result := inherited GetMeasures(AMeasureID);
|
||||
end;
|
||||
end;
|
||||
|
||||
function TCDEditDrawerCommon.GetColor(AColorID: Integer): TColor;
|
||||
begin
|
||||
case AColorId of
|
||||
TCDEDIT_BACKGROUND_COLOR: Result := clWhite;
|
||||
TCDEDIT_TEXT_COLOR: Result := clBlack;
|
||||
TCDEDIT_SELECTED_BACKGROUND_COLOR: Result := clBlue;
|
||||
TCDEDIT_SELECTED_TEXT_COLOR: Result := clWhite;
|
||||
else
|
||||
Result := inherited GetColor(AColorId);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TCDEditDrawerCommon.DrawToIntfImage(ADest: TFPImageCanvas;
|
||||
CDControl: TCDControl);
|
||||
begin
|
||||
|
||||
end;
|
||||
|
||||
procedure TCDEditDrawerCommon.DrawBackground(ADest: TCanvas;
|
||||
AControl: TCDControl);
|
||||
begin
|
||||
// The background
|
||||
ADest.Brush.Color := clWhite;
|
||||
ADest.Brush.Style := bsSolid;
|
||||
ADest.Pen.Color := clBlack;
|
||||
ADest.Pen.Style := psSolid;
|
||||
ADest.Rectangle(0, 0, AControl.Width, AControl.Height);
|
||||
end;
|
||||
|
||||
procedure TCDEditDrawerCommon.DrawToCanvas(ADest: TCanvas; CDControl: TCDControl);
|
||||
var
|
||||
CDEdit: TCDEdit absolute CDControl;
|
||||
@ -214,175 +442,6 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
{ TCDCheckBoxDrawerCommon }
|
||||
|
||||
function TCDCheckBoxDrawerCommon.GetCaptionWidth(CDCheckBox: TCDCheckBox
|
||||
): Integer;
|
||||
begin
|
||||
CDCheckBox.Canvas.Font.Assign(CDCheckBox.Font);
|
||||
Result := CDCheckBox.Canvas.TextWidth(CDCheckBox.Caption);
|
||||
end;
|
||||
|
||||
function TCDCheckBoxDrawerCommon.GetCaptionHeight(CDCheckBox: TCDCheckBox
|
||||
): Integer;
|
||||
begin
|
||||
CDCheckBox.Canvas.Font.Assign(CDCheckBox.Font);
|
||||
Result := CDCheckBox.Canvas.TextHeight('ŹÇ')+3;
|
||||
end;
|
||||
|
||||
procedure TCDCheckBoxDrawerCommon.CalculatePreferredSize(
|
||||
CDCheckBox: TCDCheckBox; var PreferredWidth, PreferredHeight: integer;
|
||||
WithThemeSpace: Boolean);
|
||||
begin
|
||||
PreferredWidth := 0;
|
||||
|
||||
if CDCheckBox.AutoSize then
|
||||
PreferredWidth := 21 + GetCaptionWidth(CDCheckBox);
|
||||
|
||||
PreferredHeight := GetCaptionHeight(CDCheckBox);
|
||||
end;
|
||||
|
||||
procedure TCDCheckBoxDrawerCommon.DrawToIntfImage(ADest: TFPImageCanvas;
|
||||
CDCheckBox: TCDCheckBox);
|
||||
begin
|
||||
|
||||
end;
|
||||
|
||||
procedure TCDCheckBoxDrawerCommon.DrawToCanvas(ADest: TCanvas;
|
||||
CDCheckBox: TCDCheckBox);
|
||||
const
|
||||
CDCheckBoxCommon_Half_Height = 7;
|
||||
CDCheckBoxCommon_Height = 15;
|
||||
var
|
||||
lHalf: Integer;
|
||||
lColor: TColor;
|
||||
i: Integer;
|
||||
begin
|
||||
lHalf := CDCheckBox.Height div 2;
|
||||
|
||||
// Background
|
||||
lColor := CDCheckBox.GetRGBBackgroundColor();
|
||||
ADest.Brush.Color := lColor;
|
||||
ADest.Brush.Style := bsSolid;
|
||||
ADest.Pen.Style := psClear;
|
||||
ADest.FillRect(0, 0, CDCheckBox.Width, CDCheckBox.Height);
|
||||
|
||||
// The checkbox item itself
|
||||
ADest.Brush.Color := clWhite;
|
||||
ADest.Pen.Style := psSolid;
|
||||
if CDCheckBox.IsDown then ADest.Pen.Color := clGray
|
||||
else ADest.Pen.Color := clBlack;
|
||||
ADest.Rectangle(
|
||||
1,
|
||||
lHalf - CDCheckBoxCommon_Half_Height,
|
||||
CDCheckBoxCommon_Height+1,
|
||||
lHalf + CDCheckBoxCommon_Half_Height);
|
||||
|
||||
// The Tickmark
|
||||
if CDCheckBox.State = cbChecked then
|
||||
begin
|
||||
// 4 lines going down and to the right
|
||||
for i := 0 to 3 do
|
||||
ADest.Line(5+i, lHalf - CDCheckBoxCommon_Half_Height+5+i, 5+i, lHalf - CDCheckBoxCommon_Half_Height+8+i);
|
||||
// Now 5 lines going up and to the right
|
||||
for i := 4 to 8 do
|
||||
ADest.Line(5+i, lHalf - CDCheckBoxCommon_Half_Height+5+6-i, 5+i, lHalf - CDCheckBoxCommon_Half_Height+8+6-i);
|
||||
end;
|
||||
|
||||
// The selection
|
||||
ADest.Brush.Style := bsClear;
|
||||
ADest.Pen.Color := RGBToColor($31, $C6, $D6);
|
||||
ADest.Pen.Style := psSolid;
|
||||
if CDCheckBox.Focused then
|
||||
begin
|
||||
// The selection inside the square
|
||||
ADest.Rectangle(
|
||||
2,
|
||||
lHalf - CDCheckBoxCommon_Half_Height+1,
|
||||
CDCheckBoxCommon_Height,
|
||||
lHalf + CDCheckBoxCommon_Half_Height-1);
|
||||
|
||||
// Selection around the text
|
||||
ADest.Rectangle(
|
||||
CDCheckBoxCommon_Height+4, 0,
|
||||
CDCheckBox.Width, CDCheckBox.Height);
|
||||
end;
|
||||
|
||||
// Now the text
|
||||
ADest.Font.Assign(CDCheckBox.Font);
|
||||
ADest.TextOut(CDCheckBoxCommon_Height+5, 0, CDCheckBox.Caption);
|
||||
end;
|
||||
|
||||
{ TCDButtonDrawerCommon }
|
||||
|
||||
procedure TCDButtonDrawerCommon.DrawToIntfImage(ADest: TFPImageCanvas;
|
||||
CDButton: TCDButton);
|
||||
begin
|
||||
|
||||
end;
|
||||
|
||||
procedure TCDButtonDrawerCommon.DrawToCanvas(ADest: TCanvas; CDButton: TCDButton);
|
||||
var
|
||||
TmpB: TBitmap;
|
||||
Str: string;
|
||||
begin
|
||||
// Button shape -> This crashes in Gtk2
|
||||
TmpB := TBitmap.Create;
|
||||
TmpB.Width := CDButton.Width;
|
||||
TmpB.Height := CDButton.Height;
|
||||
TmpB.Canvas.Brush.Color := CDButton.Color;
|
||||
TmpB.Canvas.Brush.Style := bsSolid;
|
||||
TmpB.Canvas.RoundRect(0, 0, TmpB.Width, TmpB.Height, 8, 8);
|
||||
// CDButton.SetShape(TmpB);
|
||||
|
||||
// Button image
|
||||
if CDButton.IsDown then
|
||||
begin
|
||||
TmpB.Canvas.Brush.Style := bsSolid;
|
||||
TmpB.Canvas.Brush.Color := GetAColor(CDButton.Color, 90);
|
||||
TmpB.Canvas.Pen.Color := clBlack;
|
||||
TmpB.Canvas.Pen.Style := psSolid;
|
||||
TmpB.Canvas.Rectangle(0, 0, TmpB.Canvas.Width, TmpB.Canvas.Height);
|
||||
end
|
||||
else if CDButton.Focused then
|
||||
begin
|
||||
with TmpB.Canvas do
|
||||
begin
|
||||
Brush.Style := bsSolid;
|
||||
Brush.Color := GetAColor(CDButton.Color, 99);
|
||||
Pen.Color := clBlack;
|
||||
Pen.Style := psSolid;
|
||||
Rectangle(0, 0, Width, Height);
|
||||
Rectangle(1, 1, Width - 1, Height - 1); // The border is thicken when focused
|
||||
end;
|
||||
end
|
||||
else
|
||||
begin
|
||||
with TmpB.Canvas do
|
||||
begin
|
||||
Brush.Style := bsSolid;
|
||||
Brush.Color := CDButton.Color;
|
||||
Pen.Color := clBlack;
|
||||
Pen.Style := psSolid;
|
||||
Rectangle(0, 0, Width, Height);
|
||||
end;
|
||||
end;
|
||||
|
||||
ADest.Draw(0, 0, TmpB);
|
||||
|
||||
TmpB.Free;
|
||||
|
||||
// Button text
|
||||
{$ifndef CUSTOMDRAWN_USE_FREETYPE}
|
||||
ADest.Font.Assign(CDButton.Font);
|
||||
ADest.Brush.Style := bsClear;
|
||||
ADest.Pen.Style := psSolid;
|
||||
Str := CDButton.Caption;
|
||||
ADest.TextOut((CDButton.Width - ADest.TextWidth(Str)) div 2,
|
||||
(CDButton.Height - ADest.TextHeight(Str)) div 2, Str);
|
||||
{$endif}
|
||||
end;
|
||||
|
||||
{ TCDCustomTabControlDrawerCommon }
|
||||
|
||||
procedure TCDCustomTabControlDrawerCommon.DrawTabs(ADest: TCanvas; CDTabControl: TCDCustomTabControl);
|
||||
@ -472,26 +531,6 @@ begin
|
||||
Result := 1;
|
||||
end;
|
||||
|
||||
function TCDCustomTabControlDrawerCommon.GetTabHeight(AIndex: Integer; CDTabControl: TCDCustomTabControl): Integer;
|
||||
begin
|
||||
if CDTabControl.Font.Size = 0 then
|
||||
Result := 32
|
||||
else
|
||||
Result := CDTabControl.Font.Size + 22;
|
||||
end;
|
||||
|
||||
function TCDCustomTabControlDrawerCommon.GetTabWidth(ADest: TCanvas;
|
||||
AIndex: Integer; CDTabControl: TCDCustomTabControl): Integer;
|
||||
const
|
||||
TCDTabControl_Common_TabCaptionExtraWidth = 20;
|
||||
var
|
||||
lCaption: string;
|
||||
begin
|
||||
lCaption := CDTabControl.Tabs.Strings[AIndex];
|
||||
|
||||
Result := ADest.TextWidth(lCaption) + TCDTabControl_Common_TabCaptionExtraWidth;
|
||||
end;
|
||||
|
||||
{function TCDCustomTabControlDrawerCommon.GetClientRect(AControl: TCDControl
|
||||
): TRect;
|
||||
var
|
||||
@ -553,133 +592,9 @@ begin
|
||||
ADest.Brush.Style := bsSolid;
|
||||
ADest.Pen.Style := psClear;
|
||||
ADest.Rectangle(0, 0, CDTabControl.Width, CDTabControl.Height);
|
||||
end;
|
||||
|
||||
procedure TCDCustomTabControlDrawerCommon.MouseDown(Button: TMouseButton;
|
||||
Shift: TShiftState; X, Y: integer; CDTabControl: TCDCustomTabControl);
|
||||
var
|
||||
i: Integer;
|
||||
CurPage: TCDTabSheet;
|
||||
CurStartLeftPos: Integer = 0;
|
||||
VisiblePagesStarted: Boolean = False;
|
||||
lTabWidth: Integer;
|
||||
begin
|
||||
for i := 0 to CDTabControl.Tabs.Count - 1 do
|
||||
begin
|
||||
if i = LeftmostTabVisibleIndex then
|
||||
VisiblePagesStarted := True;
|
||||
|
||||
if VisiblePagesStarted then
|
||||
begin
|
||||
lTabWidth := GetTabWidth(CDTabControl.Canvas, i, CDTabControl);
|
||||
if (X > CurStartLeftPos) and
|
||||
(X < CurStartLeftPos + lTabWidth) and
|
||||
(Y < GetTabHeight(i, CDTabControl)) then
|
||||
begin
|
||||
if CDTabControl is TCDPageControl then
|
||||
(CDTabControl as TCDPageControl).PageIndex := i
|
||||
else
|
||||
CDTabControl.TabIndex := i;
|
||||
|
||||
Exit;
|
||||
end;
|
||||
CurStartLeftPos := CurStartLeftPos + lTabWidth;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TCDCustomTabControlDrawerCommon.MouseUp(Button: TMouseButton;
|
||||
Shift: TShiftState; X, Y: integer; CDTabControl: TCDCustomTabControl);
|
||||
begin
|
||||
|
||||
end;
|
||||
|
||||
procedure TCDGroupBoxDrawerCommon.SetClientRectPos(CDGroupBox: TCDGroupBox);
|
||||
var
|
||||
lRect: TRect;
|
||||
lCaptionHeight: integer;
|
||||
begin
|
||||
lCaptionHeight := 10;
|
||||
lRect := Rect(1, lCaptionHeight, CDGroupBox.Width - 1, CDGroupBox.Height - 1);
|
||||
//CDGroupBox.AdjustClientRect(lRect);
|
||||
end;
|
||||
|
||||
procedure TCDGroupBoxDrawerCommon.DrawToIntfImage(ADest: TFPImageCanvas;
|
||||
CDGroupBox: TCDGroupBox);
|
||||
{$ifdef CUSTOMDRAWN_USE_FREETYPE}
|
||||
var
|
||||
AFont: TFreeTypeFont = nil;
|
||||
{$endif}
|
||||
begin
|
||||
FCaptionMiddle := CDGroupBox.Canvas.TextHeight('Ź') div 2;
|
||||
if FCaptionMiddle = 0 then FCaptionMiddle := CDGroupBox.Canvas.Font.Size div 2;
|
||||
if FCaptionMiddle = 0 then FCaptionMiddle := 5;
|
||||
|
||||
// Background
|
||||
if CDGroupBox.Parent = nil then
|
||||
ADest.Brush.FPColor := colLtGray
|
||||
else if CDGroupBox.Parent.Color = clDefault then
|
||||
ADest.Brush.FPColor := TColorToFPColor(ColorToRGB(clForm))
|
||||
else
|
||||
ADest.Brush.FPColor := TColorToFPColor(ColorToRGB(CDGroupBox.Parent.Color));
|
||||
ADest.Brush.Style := bsSolid;
|
||||
ADest.Pen.Style := psClear;
|
||||
ADest.Rectangle(0, 0, CDGroupBox.Width, CDGroupBox.Height);
|
||||
|
||||
// frame
|
||||
ADest.Pen.FPColor := colBlack;
|
||||
ADest.Pen.Style := psSolid;
|
||||
ADest.Brush.Style := bsClear;
|
||||
ADest.Rectangle(0, FCaptionMiddle, CDGroupBox.Width - 1, CDGroupBox.Height - 1);
|
||||
|
||||
{$ifdef CUSTOMDRAWN_USE_FREETYPE}
|
||||
// Caption background and caption
|
||||
|
||||
// initialize free type font manager
|
||||
opcftfont.InitEngine;
|
||||
// FontMgr.SearchPath:='/usr/share/fonts/truetype/';
|
||||
AFont := TFreeTypeFont.Create;
|
||||
try
|
||||
// Text background
|
||||
ADest.Pen.Style := psClear;
|
||||
ADest.Brush.Style := bsSolid;
|
||||
// The brush color was already set previously and is already correct
|
||||
// ADest.Rectangle(5, 0, AFont.GetTextWidth(CDGroupBox.Caption) + 5, 10);
|
||||
|
||||
// paint text
|
||||
ADest.Pen.Style := psSolid;
|
||||
ADest.Brush.Style := bsClear;
|
||||
ADest.Font := AFont;
|
||||
ADest.Font.Name := 'Arial';
|
||||
ADest.Font.Size := 10;
|
||||
ADest.TextOut(5, 10, CDGroupBox.Caption);
|
||||
finally
|
||||
AFont.Free;
|
||||
end;
|
||||
{$endif}
|
||||
end;
|
||||
|
||||
procedure TCDGroupBoxDrawerCommon.DrawToCanvas(ADest: TCanvas; CDGroupBox: TCDGroupBox);
|
||||
begin
|
||||
if CDGroupBox.Parent = nil then
|
||||
ADest.Brush.Color := clLtGray
|
||||
else if CDGroupBox.Parent.Color = clDefault then
|
||||
ADest.Brush.Color := ColorToRGB(clForm)
|
||||
else
|
||||
ADest.Brush.Color := ColorToRGB(CDGroupBox.Parent.Color);
|
||||
|
||||
// paint text
|
||||
ADest.Pen.Style := psSolid;
|
||||
ADest.Brush.Style := bsSolid; // This will fill the text background
|
||||
ADest.Font.Size := 10;
|
||||
ADest.TextOut(FCaptionMiddle, 0, CDGroupBox.Caption);
|
||||
end;
|
||||
end;*)
|
||||
|
||||
initialization
|
||||
RegisterButtonDrawer(TCDButtonDrawerCommon.Create, dsCommon);
|
||||
RegisterEditDrawer(TCDEditDrawerCommon.Create, dsCommon);
|
||||
RegisterGroupBoxDrawer(TCDGroupBoxDrawerCommon.Create, dsCommon);
|
||||
RegisterCheckBoxDrawer(TCDCheckBoxDrawerCommon.Create, dsCommon);
|
||||
RegisterCustomTabControlDrawer(TCDCustomTabControlDrawerCommon.Create, dsCommon);
|
||||
RegisterDrawer(TCDDrawerCommon.Create, dsCommon);
|
||||
end.
|
||||
|
||||
|
||||
@ -14,7 +14,7 @@ uses
|
||||
//
|
||||
customdrawncontrols, customdrawnutils;
|
||||
|
||||
type
|
||||
{type
|
||||
TCDButtonDrawerGrad = class(TCDButtonDrawer)
|
||||
public
|
||||
procedure DrawToIntfImage(ADest: TFPImageCanvas; CDButton: TCDButton); override;
|
||||
@ -26,11 +26,11 @@ type
|
||||
procedure DrawToIntfImage(ADest: TFPImageCanvas; FPImg: TLazIntfImage;
|
||||
CDTrackBar: TCDTrackBar); override;
|
||||
procedure GetGeometry(var ALeftBorder, ARightBorder: Integer); override;
|
||||
end;
|
||||
end;}
|
||||
|
||||
implementation
|
||||
|
||||
procedure TCDButtonDrawerGrad.DrawToIntfImage(ADest: TFPImageCanvas;
|
||||
{procedure TCDButtonDrawerGrad.DrawToIntfImage(ADest: TFPImageCanvas;
|
||||
CDButton: TCDButton);
|
||||
begin
|
||||
|
||||
@ -197,6 +197,6 @@ end;
|
||||
|
||||
initialization
|
||||
RegisterButtonDrawer(TCDButtonDrawerGrad.Create, dsExtra1);
|
||||
RegisterTrackBarDrawer(TCDTrackBarDrawerGraph.Create, dsExtra1);
|
||||
RegisterTrackBarDrawer(TCDTrackBarDrawerGraph.Create, dsExtra1);}
|
||||
end.
|
||||
|
||||
|
||||
@ -14,366 +14,9 @@ uses
|
||||
// Others only for types
|
||||
StdCtrls,
|
||||
//
|
||||
customdrawncontrols, customdrawnutils;
|
||||
|
||||
type
|
||||
|
||||
{ TCDCustomTabControlDrawerKDE }
|
||||
|
||||
TCDCustomTabControlDrawerKDE = class(TCDCustomTabControlDrawer)
|
||||
private
|
||||
StartIndex: integer; //FEndIndex
|
||||
LeftmostTabVisibleIndex: Integer;
|
||||
procedure DrawCaptionBar(ADest: TCanvas; lRect: TRect; CL: TColor);
|
||||
procedure DrawTabs(ADest: TCanvas; CDTabControl: TCDCustomTabControl);
|
||||
procedure DrawTab(ADest: TCanvas; AIndex: Integer; ACurStartLeftPos: Integer;
|
||||
CDTabControl: TCDCustomTabControl);
|
||||
public
|
||||
function GetPageIndexFromXY(x, y: integer): integer; override;
|
||||
function GetTabHeight(AIndex: Integer; CDTabControl: TCDCustomTabControl): Integer; override;
|
||||
function GetTabWidth(ADest: TCanvas; AIndex: Integer; CDTabControl: TCDCustomTabControl): Integer; override;
|
||||
//function GetClientRect(AControl: TCDControl): TRect; override;
|
||||
procedure DrawToIntfImage(ADest: TFPImageCanvas; FPImg: TLazIntfImage;
|
||||
CDTabControl: TCDCustomTabControl); override;
|
||||
procedure DrawToCanvas(ADest: TCanvas; CDTabControl: TCDCustomTabControl); override;
|
||||
procedure DrawTabSheet(ADest: TCanvas; CDTabControl: TCDCustomTabControl); override;
|
||||
procedure MouseDown(Button: TMouseButton; Shift: TShiftState;
|
||||
X, Y: integer; CDTabControl: TCDCustomTabControl); override;
|
||||
procedure MouseUp(Button: TMouseButton; Shift: TShiftState;
|
||||
X, Y: integer; CDTabControl: TCDCustomTabControl); override;
|
||||
end;
|
||||
customdrawndrawers, customdrawn_common;
|
||||
|
||||
implementation
|
||||
|
||||
{ TCDCustomTabControlDrawerKDE }
|
||||
|
||||
procedure TCDCustomTabControlDrawerKDE.DrawCaptionBar(ADest: TCanvas;
|
||||
lRect: TRect; CL: TColor);
|
||||
begin
|
||||
{ CaptionHeight := GetTabHeight(CDPageControl.PageIndex, CDPageControl) - 4;
|
||||
RButtHeight := GetTabHeight(CDPageControl.PageIndex, CDPageControl);
|
||||
aRect := lRect;
|
||||
ADest.Pen.Style := psSolid;
|
||||
ADest.Brush.Style := bsSolid;
|
||||
ADest.Pen.FPColor := TColorToFPColor(ColorToRGB(CL));
|
||||
//TColorToFPColor(ColorToRGB($009C9B91));
|
||||
ADest.Brush.FPColor := TColorToFPColor(ColorToRGB(CL));
|
||||
aRect.Left := lRect.Left;
|
||||
aRect.Top := lRect.Top;
|
||||
aRect.Bottom := lRect.Bottom;
|
||||
aRect.Right := lRect.Right;
|
||||
ADest.RecTangle(lRect);
|
||||
if CDPageControl.FPages.Count = 0 then
|
||||
begin
|
||||
ADest.Brush.Color := clWhite;
|
||||
ADest.Pen.Color := $009C9B91;
|
||||
ADest.RecTangle(Rect(aRect.Left, aRect.Top, aRect.Right + 1, aRect.Bottom + 2));
|
||||
ADest.Pen.Color := clWhite;
|
||||
ADest.Line(aRect.Left + 1, aRect.Bottom + 1, aRect.Right, aRect.Bottom + 1);
|
||||
Exit;
|
||||
end;
|
||||
aRect.Left := lRect.Left + 2;
|
||||
aRect.Top := lRect.Top + 3;
|
||||
//ADest.TextStyle.Opaque :=false;
|
||||
//SetBkMode(ADest.Handle, TRANSPARENT);
|
||||
if ADest.Brush.Style = bsSolid then
|
||||
SetBkMode(ADest.Handle, OPAQUE)
|
||||
else
|
||||
SetBkMode(ADest.Handle, TRANSPARENT);
|
||||
|
||||
for i := StartIndex to CDPageControl.FPages.Count - 1 do
|
||||
begin
|
||||
aText := CDPageControl.FPages[i].TabPage.Caption;
|
||||
rWidth := (CaptionHeight - ADest.TextHeight(aText)) + ADest.TextWidth(aText);
|
||||
CDPageControl.FPages[i].Width := rWidth;
|
||||
if aRect.Left + rWidth > lRect.Right - 6 then
|
||||
Break
|
||||
else
|
||||
aRect.Right := aRect.Left + rWidth;
|
||||
if CDPageControl.PageIndex = i then
|
||||
begin
|
||||
cRect := aRect;
|
||||
if i = StartIndex then
|
||||
cRect.Left := aRect.Left - 2
|
||||
else
|
||||
cRect.Left := aRect.Left - 4;
|
||||
cRect.Right := aRect.Right + 4;
|
||||
cRect.Top := cRect.Top - 2;
|
||||
bText := CDPageControl.FPages[i].TabPage.Caption;
|
||||
end
|
||||
else
|
||||
DrawTabHead(aDest, aRect, CDPageControl.Color, False);
|
||||
MaskColor := MaskBaseColor + i - StartIndex;
|
||||
//DrawTabHeadMask(MaskHeadBmp.Canvas, aRect, MaskColor, False);
|
||||
ADest.TextOut(aRect.Left + (aRect.Right - aRect.Left - ADest.TextWidth(aText)) div 2,
|
||||
aRect.Top + (aRect.Bottom - aRect.Top - ADest.TextHeight(aText)) div 2, aText);
|
||||
aRect.Left := aRect.Right + 3;
|
||||
end;
|
||||
ADest.Line(lRect.Left, lRect.Bottom - 1, cRect.Left, lRect.Bottom - 1);
|
||||
ADest.Line(cRect.Right, lRect.Bottom - 1, lRect.Right, lRect.Bottom - 1);
|
||||
DrawTabHead(aDest, cRect, clWhite, True);
|
||||
ADest.TextOut(cRect.Left + (cRect.Right - cRect.Left - ADest.TextWidth(bText)) div 2,
|
||||
cRect.Top + (cRect.Bottom - cRect.Top - ADest.TextHeight(bText)) div 2, bText);
|
||||
if not CheckTabButton(lRect.Right - lRect.Left, CDPageControl.FPages) then
|
||||
Exit;
|
||||
aRect.Left := lRect.Right - RButtHeight * 2 - 3;
|
||||
aRect.Top := 1;
|
||||
aRect.Bottom := RButtHeight + 1;
|
||||
aRect.Right := lRect.Right - RButtHeight;
|
||||
//if FMDownL then
|
||||
// GradFill(ADest, aRect, $00F1A079, $00EFAF9B)
|
||||
//else
|
||||
GradFill(ADest, aRect, $00FDD9CB, $00F2C9B8);
|
||||
aRect.Left := lRect.Right - RButtHeight - 1;
|
||||
aRect.Top := 1;
|
||||
aRect.Bottom := RButtHeight + 1;
|
||||
aRect.Right := lRect.Right;
|
||||
|
||||
GradFill(ADest, aRect, $00FDD9CB, $00F2C9B8);
|
||||
|
||||
ADest.Pen.FPColor := TColorToFPColor(ColorToRGB($0085614D));
|
||||
bRect.Top := 1;
|
||||
bRect.Left := lRect.Right - RButtHeight * 2 - 3;
|
||||
bRect.Right := lRect.Right;
|
||||
bRect.Bottom := RButtHeight + 1;
|
||||
DrawArrow(ADest, bRect, True);
|
||||
DrawArrow(ADest, bRect, False);
|
||||
ADest.Pen.FPColor := TColorToFPColor(ColorToRGB(clWhite));
|
||||
ADest.Line(lRect.Right - RButtHeight * 2 - 3, 1, lRect.Right, 1);
|
||||
ADest.Line(lRect.Right, 1, lRect.Right, RButtHeight + 1);
|
||||
ADest.Line(lRect.Right, RButtHeight + 1, lRect.Right - RButtHeight *
|
||||
2 - 3, RButtHeight + 1);
|
||||
ADest.Line(lRect.Right - RButtHeight * 2 - 3, RButtHeight + 1,
|
||||
lRect.Right - RButtHeight * 2 - 3, 1);
|
||||
ADest.Pen.FPColor := TColorToFPColor(ColorToRGB($00E5BAA7));
|
||||
ADest.Brush.Style := bsClear;
|
||||
ADest.Rectangle(lRect.Right - RButtHeight * 2 - 2, 2, lRect.Right -
|
||||
1, RButtHeight + 1);
|
||||
CornerColor := TColorToFPColor(ColorToRGB($00F6E3D9));
|
||||
ADest.Colors[lRect.Right - RButtHeight * 2 - 2, 2] := CornerColor;
|
||||
ADest.Colors[lRect.Right - RButtHeight * 2 - 2, RButtHeight] := CornerColor;
|
||||
ADest.Colors[lRect.Right - 1, 2] := CornerColor;
|
||||
ADest.Colors[lRect.Right - 1, RButtHeight] := CornerColor;
|
||||
ADest.Pen.FPColor := TColorToFPColor(ColorToRGB(clWhite));
|
||||
ADest.Line(lRect.Right - 51, 1, lRect.Right, 1);
|
||||
ADest.Line(lRect.Right, 1, lRect.Right, 25);
|
||||
ADest.Line(lRect.Right, 25, lRect.Right - 51, 25);
|
||||
ADest.Line(lRect.Right - 51, 25, lRect.Right - 51, 1);
|
||||
ADest.Pen.FPColor := TColorToFPColor(ColorToRGB($00FFFFFF));}
|
||||
end;
|
||||
|
||||
procedure TCDCustomTabControlDrawerKDE.DrawTabs(ADest: TCanvas; CDTabControl: TCDCustomTabControl);
|
||||
var
|
||||
IsPainting: Boolean = False;
|
||||
CurStartLeftPos: Integer = 0;
|
||||
i: Integer;
|
||||
begin
|
||||
for i := 0 to CDTabControl.Tabs.Count - 1 do
|
||||
begin
|
||||
if i = LeftmostTabVisibleIndex then
|
||||
IsPainting := True;
|
||||
|
||||
if IsPainting then
|
||||
begin
|
||||
DrawTab(ADest, i, CurStartLeftPos, CDTabControl);
|
||||
CurStartLeftPos := CurStartLeftPos + GetTabWidth(ADest, i, CDTabControl);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TCDCustomTabControlDrawerKDE.DrawTab(ADest: TCanvas;
|
||||
AIndex: Integer; ACurStartLeftPos: Integer; CDTabControl: TCDCustomTabControl);
|
||||
var
|
||||
IsSelected: Boolean;
|
||||
lTabWidth, lTabHeight, lTabTopPos: Integer;
|
||||
Points: array of TPoint;
|
||||
lCaption: String;
|
||||
begin
|
||||
IsSelected := CDTabControl.TabIndex = AIndex;
|
||||
|
||||
if IsSelected then
|
||||
begin
|
||||
lTabTopPos := 0;
|
||||
lTabHeight := GetTabHeight(AIndex, CDTabControl);
|
||||
end
|
||||
else
|
||||
begin
|
||||
lTabTopPos := 5;
|
||||
lTabHeight := GetTabHeight(AIndex, CDTabControl)-5;
|
||||
end;
|
||||
|
||||
lTabWidth := GetTabWidth(ADest, AIndex, CDTabControl);
|
||||
|
||||
// Fill the area inside the outer border
|
||||
ADest.Pen.Style := psClear;
|
||||
ADest.Brush.Style := bsSolid;
|
||||
ADest.Brush.Color := clWhite;
|
||||
SetLength(Points, 5);
|
||||
Points[0] := Point(ACurStartLeftPos, lTabTopPos);
|
||||
Points[1] := Point(ACurStartLeftPos+lTabWidth-5, lTabTopPos);
|
||||
Points[2] := Point(ACurStartLeftPos+lTabWidth, lTabTopPos+5);
|
||||
Points[3] := Point(ACurStartLeftPos+lTabWidth, lTabTopPos+lTabHeight);
|
||||
Points[4] := Point(ACurStartLeftPos, lTabTopPos+lTabHeight);
|
||||
ADest.Polygon(Points);
|
||||
|
||||
// Draw the outer border only in the top and right sides,
|
||||
// and bottom if unselected
|
||||
ADest.Pen.Style := psSolid;
|
||||
ADest.Brush.Style := bsClear;
|
||||
ADest.Pen.Color := ColorToRGB($009C9B91);
|
||||
ADest.MoveTo(ACurStartLeftPos+1, lTabTopPos);
|
||||
ADest.LineTo(ACurStartLeftPos+lTabWidth-5, lTabTopPos);
|
||||
ADest.LineTo(ACurStartLeftPos+lTabWidth, lTabTopPos+5);
|
||||
ADest.LineTo(ACurStartLeftPos+lTabWidth, lTabTopPos+lTabHeight);
|
||||
|
||||
// If it is selected, add a selection frame
|
||||
if IsSelected then
|
||||
begin
|
||||
ADest.Pen.Color := ColorToRGB($00D6C731);
|
||||
ADest.Pen.Style := psSolid;
|
||||
ADest.Brush.Style := bsClear;
|
||||
ADest.Rectangle(
|
||||
ACurStartLeftPos+3, lTabTopPos+3,
|
||||
ACurStartLeftPos+lTabWidth-5, lTabTopPos+lTabHeight-5
|
||||
);
|
||||
end;
|
||||
|
||||
// Now the text
|
||||
lCaption := CDTabControl.Tabs.Strings[AIndex];
|
||||
ADest.TextOut(ACurStartLeftPos+5, lTabTopPos+5, lCaption);
|
||||
end;
|
||||
|
||||
function TCDCustomTabControlDrawerKDE.GetPageIndexFromXY(x, y: integer
|
||||
): integer;
|
||||
begin
|
||||
Result := 1;
|
||||
end;
|
||||
|
||||
function TCDCustomTabControlDrawerKDE.GetTabHeight(AIndex: Integer; CDTabControl: TCDCustomTabControl): Integer;
|
||||
begin
|
||||
if CDTabControl.Font.Size = 0 then
|
||||
Result := 32
|
||||
else
|
||||
Result := CDTabControl.Font.Size + 22;
|
||||
end;
|
||||
|
||||
function TCDCustomTabControlDrawerKDE.GetTabWidth(ADest: TCanvas;
|
||||
AIndex: Integer; CDTabControl: TCDCustomTabControl): Integer;
|
||||
const
|
||||
TCDTabControl_KDE_TabCaptionExtraWidth = 20;
|
||||
var
|
||||
lCaption: string;
|
||||
begin
|
||||
lCaption := CDTabControl.Tabs.Strings[AIndex];
|
||||
|
||||
Result := ADest.TextWidth(lCaption) + TCDTabControl_KDE_TabCaptionExtraWidth;
|
||||
end;
|
||||
|
||||
{function TCDCustomTabControlDrawerKDE.GetClientRect(AControl: TCDControl
|
||||
): TRect;
|
||||
var
|
||||
lCaptionHeight: Integer;
|
||||
begin
|
||||
lCaptionHeight := GetTabHeight(CDTabControl.FTabIndex) - 4;
|
||||
|
||||
Result := Rect(5, lCaptionHeight + 1, CDTabControl.Width - 10,
|
||||
CDTabControl.Height - lCaptionHeight - 5);
|
||||
end;}
|
||||
|
||||
procedure TCDCustomTabControlDrawerKDE.DrawToIntfImage(ADest: TFPImageCanvas;
|
||||
FPImg: TLazIntfImage; CDTabControl: TCDCustomTabControl);
|
||||
var
|
||||
lColor: TColor;
|
||||
lFPColor: TFPColor;
|
||||
x, y: Integer;
|
||||
begin
|
||||
lColor := CDTabControl.GetRGBBackgroundColor();
|
||||
|
||||
// Background
|
||||
lFPColor := TColorToFPColor(lColor);
|
||||
FPImg.FillPixels(lFPColor);
|
||||
end;
|
||||
|
||||
procedure TCDCustomTabControlDrawerKDE.DrawToCanvas(ADest: TCanvas; CDTabControl: TCDCustomTabControl);
|
||||
var
|
||||
CaptionHeight: Integer;
|
||||
begin
|
||||
CaptionHeight := GetTabHeight(CDTabControl.TabIndex, CDTabControl);
|
||||
|
||||
// frame
|
||||
ADest.Pen.Style := psSolid;
|
||||
ADest.Brush.Style := bsClear;
|
||||
ADest.Pen.Color := ColorToRGB($009C9B91);
|
||||
|
||||
if CDTabControl.GetTabCount = 0 then
|
||||
ADest.Rectangle(0, 0, CDTabControl.Width - 2, CDTabControl.Height - 2)
|
||||
else
|
||||
ADest.Rectangle(0, CaptionHeight, CDTabControl.Width - 2, CDTabControl.Height - 2);
|
||||
|
||||
ADest.Pen.Color := ColorToRGB($00BFCED0);
|
||||
ADest.Line(CDTabControl.Width - 1, CaptionHeight + 1,
|
||||
CDTabControl.Width - 1, CDTabControl.Height - 1);
|
||||
ADest.Line(CDTabControl.Width - 1, CDTabControl.Height - 1, 1,
|
||||
CDTabControl.Height - 1);
|
||||
|
||||
// Tabs
|
||||
ADest.Font.Name := CDTabControl.Font.Name;
|
||||
ADest.Font.Size := CDTabControl.Font.Size;
|
||||
// DrawCaptionBar(ADest, Rect(0, 0, CDPageControl.Width -
|
||||
// 2, CaptionHeight + 1), CDPageControl.Color, CDPageControl);
|
||||
DrawTabs(ADest, CDTabControl);
|
||||
end;
|
||||
|
||||
procedure TCDCustomTabControlDrawerKDE.DrawTabSheet(ADest: TCanvas; CDTabControl: TCDCustomTabControl);
|
||||
begin
|
||||
ADest.Brush.Color := CDTabControl.Color;
|
||||
ADest.Brush.Style := bsSolid;
|
||||
ADest.Pen.Style := psClear;
|
||||
ADest.Rectangle(0, 0, CDTabControl.Width, CDTabControl.Height);
|
||||
end;
|
||||
|
||||
procedure TCDCustomTabControlDrawerKDE.MouseDown(Button: TMouseButton;
|
||||
Shift: TShiftState; X, Y: integer; CDTabControl: TCDCustomTabControl);
|
||||
var
|
||||
i: Integer;
|
||||
CurPage: TCDTabSheet;
|
||||
CurStartLeftPos: Integer = 0;
|
||||
VisiblePagesStarted: Boolean = False;
|
||||
lTabWidth: Integer;
|
||||
begin
|
||||
for i := 0 to CDTabControl.Tabs.Count - 1 do
|
||||
begin
|
||||
if i = LeftmostTabVisibleIndex then
|
||||
VisiblePagesStarted := True;
|
||||
|
||||
if VisiblePagesStarted then
|
||||
begin
|
||||
lTabWidth := GetTabWidth(CDTabControl.Canvas, i, CDTabControl);
|
||||
if (X > CurStartLeftPos) and
|
||||
(X < CurStartLeftPos + lTabWidth) and
|
||||
(Y < GetTabHeight(i, CDTabControl)) then
|
||||
begin
|
||||
if CDTabControl is TCDPageControl then
|
||||
(CDTabControl as TCDPageControl).PageIndex := i
|
||||
else
|
||||
CDTabControl.TabIndex := i;
|
||||
|
||||
Exit;
|
||||
end;
|
||||
CurStartLeftPos := CurStartLeftPos + lTabWidth;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TCDCustomTabControlDrawerKDE.MouseUp(Button: TMouseButton;
|
||||
Shift: TShiftState; X, Y: integer; CDTabControl: TCDCustomTabControl);
|
||||
begin
|
||||
|
||||
end;
|
||||
|
||||
initialization
|
||||
|
||||
RegisterCustomTabControlDrawer(TCDCustomTabControlDrawerKDE.Create, dsKDE);
|
||||
|
||||
end.
|
||||
|
||||
|
||||
@ -12,18 +12,16 @@ uses
|
||||
// LCL -> Use only TForm, TWinControl, TCanvas and TLazIntfImage
|
||||
Graphics, Controls, LCLType, LCLIntf, IntfGraphics,
|
||||
//
|
||||
customdrawncontrols, customdrawnutils;
|
||||
customdrawndrawers, customdrawn_common;
|
||||
|
||||
type
|
||||
TCDButtonDrawerWin2k = class(TCDButtonDrawer)
|
||||
TCDDrawerWin2k = class(TCDDrawerCommon)
|
||||
public
|
||||
procedure DrawToIntfImage(ADest: TFPImageCanvas; CDButton: TCDButton); override;
|
||||
procedure DrawToCanvas(ADest: TCanvas; CDButton: TCDButton); override;
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
procedure TCDButtonDrawerWin2k.DrawToIntfImage(ADest: TFPImageCanvas;
|
||||
{procedure TCDButtonDrawerWin2k.DrawToIntfImage(ADest: TFPImageCanvas;
|
||||
CDButton: TCDButton);
|
||||
begin
|
||||
|
||||
@ -108,9 +106,9 @@ begin
|
||||
else
|
||||
ADest.TextOut((CDButton.Width - ADest.TextWidth(Str)) div 2,
|
||||
(CDButton.Height - ADest.TextHeight(Str)) div 2, Str);
|
||||
end;
|
||||
end;}
|
||||
|
||||
initialization
|
||||
RegisterButtonDrawer(TCDButtonDrawerWin2k.Create, dsWin2000);
|
||||
RegisterDrawer(TCDDrawerWin2k.Create, dsWin2000);
|
||||
end.
|
||||
|
||||
|
||||
@ -14,83 +14,16 @@ uses
|
||||
// Others only for types
|
||||
StdCtrls,
|
||||
//
|
||||
customdrawncontrols, customdrawnutils, customdrawn_common;
|
||||
customdrawndrawers, customdrawn_common;
|
||||
|
||||
type
|
||||
TCDButtonDrawerWinCE = class(TCDButtonDrawer)
|
||||
TCDDrawerWinCE = class(TCDDrawerCommon)
|
||||
public
|
||||
procedure DrawToIntfImage(ADest: TFPImageCanvas; CDButton: TCDButton); override;
|
||||
procedure DrawToCanvas(ADest: TCanvas; CDButton: TCDButton); override;
|
||||
end;
|
||||
|
||||
{ TCDEditDrawerWinCE }
|
||||
|
||||
TCDEditDrawerWinCE = class(TCDEditDrawerCommon)
|
||||
public
|
||||
function GetMeasures(AMeasureID: Integer): Integer; override;
|
||||
procedure DrawBackground(ADest: TCanvas; CDControl: TCDControl); override;
|
||||
end;
|
||||
|
||||
{ TCDCheckBoxDrawerWinCE }
|
||||
|
||||
TCDCheckBoxDrawerWinCE = class(TCDCheckBoxDrawer)
|
||||
public
|
||||
function GetCaptionWidth(CDCheckBox: TCDCheckBox): Integer;
|
||||
function GetCaptionHeight(CDCheckBox: TCDCheckBox): Integer;
|
||||
procedure CalculatePreferredSize(CDCheckBox: TCDCheckBox; var PreferredWidth,
|
||||
PreferredHeight: integer; WithThemeSpace: Boolean); override;
|
||||
procedure DrawToIntfImage(ADest: TFPImageCanvas; CDCheckBox: TCDCheckBox); override;
|
||||
procedure DrawToCanvas(ADest: TCanvas; CDCheckBox: TCDCheckBox); override;
|
||||
end;
|
||||
|
||||
TCDGroupBoxDrawerWinCE = class(TCDGroupBoxDrawer)
|
||||
public
|
||||
FCaptionMiddle: integer;
|
||||
procedure SetClientRectPos(CDGroupBox: TCDGroupBox); override;
|
||||
procedure DrawToIntfImage(ADest: TFPImageCanvas; CDGroupBox: TCDGroupBox); override;
|
||||
procedure DrawToCanvas(ADest: TCanvas; CDGroupBox: TCDGroupBox); override;
|
||||
end;
|
||||
|
||||
// ===================================
|
||||
// Common Controls Tab
|
||||
// ===================================
|
||||
|
||||
{ TCDListViewDrawerWinCE }
|
||||
|
||||
TCDListViewDrawerWinCE = class(TCDListViewDrawer)
|
||||
public
|
||||
procedure DrawToIntfImage(ADest: TFPImageCanvas; CDListView: TCDListView); override;
|
||||
procedure DrawToCanvas(ADest: TCanvas; CDListView: TCDListView); override;
|
||||
end;
|
||||
|
||||
{ TCDCustomTabControlDrawerWinCE }
|
||||
|
||||
TCDCustomTabControlDrawerWinCE = class(TCDCustomTabControlDrawer)
|
||||
private
|
||||
StartIndex: integer; //FEndIndex
|
||||
LeftmostTabVisibleIndex: Integer;
|
||||
procedure DrawCaptionBar(ADest: TCanvas; lRect: TRect; CL: TColor);
|
||||
procedure DrawTabs(ADest: TCanvas; CDTabControl: TCDCustomTabControl);
|
||||
procedure DrawTab(ADest: TCanvas; AIndex: Integer; ACurStartLeftPos: Integer;
|
||||
CDTabControl: TCDCustomTabControl);
|
||||
public
|
||||
function GetPageIndexFromXY(x, y: integer): integer; override;
|
||||
function GetTabHeight(AIndex: Integer; CDTabControl: TCDCustomTabControl): Integer; override;
|
||||
function GetTabWidth(ADest: TCanvas; AIndex: Integer; CDTabControl: TCDCustomTabControl): Integer; override;
|
||||
//function GetClientRect(AControl: TCDControl): TRect; override;
|
||||
procedure DrawToIntfImage(ADest: TFPImageCanvas; FPImg: TLazIntfImage;
|
||||
CDTabControl: TCDCustomTabControl); override;
|
||||
procedure DrawToCanvas(ADest: TCanvas; CDTabControl: TCDCustomTabControl); override;
|
||||
procedure DrawTabSheet(ADest: TCanvas; CDTabControl: TCDCustomTabControl); override;
|
||||
procedure MouseDown(Button: TMouseButton; Shift: TShiftState;
|
||||
X, Y: integer; CDTabControl: TCDCustomTabControl); override;
|
||||
procedure MouseUp(Button: TMouseButton; Shift: TShiftState;
|
||||
X, Y: integer; CDTabControl: TCDCustomTabControl); override;
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
{ TCDListViewDrawerWinCE }
|
||||
(*{ TCDListViewDrawerWinCE }
|
||||
|
||||
procedure TCDListViewDrawerWinCE.DrawToIntfImage(ADest: TFPImageCanvas;
|
||||
CDListView: TCDListView);
|
||||
@ -701,13 +634,9 @@ begin
|
||||
ADest.Brush.Style := bsSolid; // This will fill the text background
|
||||
ADest.Font.Size := 10;
|
||||
ADest.TextOut(FCaptionMiddle, 0, CDGroupBox.Caption);
|
||||
end;
|
||||
end;*)
|
||||
|
||||
initialization
|
||||
RegisterButtonDrawer(TCDButtonDrawerWinCE.Create, dsWinCE);
|
||||
RegisterEditDrawer(TCDEditDrawerWinCE.Create, dsWinCE);
|
||||
RegisterGroupBoxDrawer(TCDGroupBoxDrawerWinCE.Create, dsWinCE);
|
||||
RegisterCheckBoxDrawer(TCDCheckBoxDrawerWinCE.Create, dsWinCE);
|
||||
RegisterCustomTabControlDrawer(TCDCustomTabControlDrawerWinCE.Create, dsWinCE);
|
||||
RegisterDrawer(TCDDrawerWinCE.Create, dsWinCE);
|
||||
end.
|
||||
|
||||
|
||||
@ -14,16 +14,16 @@ uses
|
||||
//
|
||||
customdrawncontrols, customdrawnutils;
|
||||
|
||||
type
|
||||
{type
|
||||
TCDButtonDrawerXPTB = class(TCDButtonDrawer)
|
||||
public
|
||||
procedure DrawToIntfImage(ADest: TFPImageCanvas; CDButton: TCDButton); override;
|
||||
procedure DrawToCanvas(ADest: TCanvas; CDButton: TCDButton); override;
|
||||
end;
|
||||
end;}
|
||||
|
||||
implementation
|
||||
|
||||
procedure TCDButtonDrawerXPTB.DrawToIntfImage(ADest: TFPImageCanvas;
|
||||
{procedure TCDButtonDrawerXPTB.DrawToIntfImage(ADest: TFPImageCanvas;
|
||||
CDButton: TCDButton);
|
||||
begin
|
||||
|
||||
@ -50,6 +50,6 @@ begin
|
||||
end;
|
||||
|
||||
initialization
|
||||
RegisterButtonDrawer(TCDButtonDrawerXPTB.Create, dsWinXP);
|
||||
RegisterButtonDrawer(TCDButtonDrawerXPTB.Create, dsWinXP);}
|
||||
end.
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
238
components/customdrawn/customdrawndrawers.pas
Normal file
238
components/customdrawn/customdrawndrawers.pas
Normal file
@ -0,0 +1,238 @@
|
||||
unit customdrawndrawers;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, Types,
|
||||
// LCL for types
|
||||
Graphics;
|
||||
|
||||
const
|
||||
CDDRAWSTYLE_COUNT = 19;
|
||||
|
||||
// Measures
|
||||
TCDEDIT_LEFT_TEXT_SPACING = $400; // The space between the start of the text and the left end of the control
|
||||
TCDEDIT_RIGHT_TEXT_SPACING = $401; // The space between the end of the text and the right end of the control
|
||||
|
||||
// Measures Ex
|
||||
TCDCONTROL_CAPTION_WIDTH = $100;
|
||||
TCDCONTROL_CAPTION_HEIGHT = $101;
|
||||
|
||||
TCDCTABCONTROL_TAB_HEIGHT = $1000;
|
||||
TCDCTABCONTROL_TAB_WIDTH = $1001;
|
||||
|
||||
// Colors
|
||||
TCDEDIT_BACKGROUND_COLOR = $400;
|
||||
TCDEDIT_TEXT_COLOR = $401;
|
||||
TCDEDIT_SELECTED_BACKGROUND_COLOR = $402;
|
||||
TCDEDIT_SELECTED_TEXT_COLOR = $403;
|
||||
|
||||
type
|
||||
|
||||
TCDDrawStyle = (
|
||||
// The default is given by the DefaultStyle global variable
|
||||
// Don't implement anything for this drawer
|
||||
dsDefault = 0,
|
||||
// This is a common drawer, with a minimal implementation on which other
|
||||
// drawers base on
|
||||
dsCommon,
|
||||
// Operating system styles
|
||||
dsWinCE, dsWin2000, dsWinXP,
|
||||
dsKDE, dsGNOME, dsMacOSX,
|
||||
dsAndroid,
|
||||
// Other special styles for the user
|
||||
dsExtra1, dsExtra2, dsExtra3, dsExtra4, dsExtra5,
|
||||
dsExtra6, dsExtra7, dsExtra8, dsExtra9, dsExtra10
|
||||
);
|
||||
|
||||
// Inspired by http://doc.qt.nokia.com/stable/qstyle.html#StateFlag-enum
|
||||
TCDControlStateFlag = (
|
||||
// Basic state flags
|
||||
csfEnabled,
|
||||
csfRaised, // Raised beyond the normal state, unlike Qt for buttons
|
||||
csfSunken,
|
||||
csfHasFocus,
|
||||
csfReadOnly,
|
||||
csfMouseOver,
|
||||
// for TCDCheckBox
|
||||
csfOn,
|
||||
csfOff,
|
||||
csfPartiallyOn
|
||||
{ // for TCDPageControl
|
||||
csfDownArrow,
|
||||
// for tool button
|
||||
csfAutoRaise,
|
||||
csfHorizontal,
|
||||
csfTop,
|
||||
csfBottom,
|
||||
csfFocusAtBorder,
|
||||
csfUpArrow,
|
||||
csfSelected,
|
||||
csfActive,
|
||||
csfWindow,
|
||||
csfOpen,
|
||||
csfChildren,
|
||||
csfItem,
|
||||
csfSibling,
|
||||
csfEditing,
|
||||
csfKeyboardFocusChange,
|
||||
// For Mac OS X
|
||||
csfSmall,
|
||||
csfMini}
|
||||
);
|
||||
|
||||
TCDControlState = set of TCDControlStateFlag;
|
||||
|
||||
TCDControlStateEx = class
|
||||
public
|
||||
ParentRGBColor: TColor;
|
||||
RGBColor: TColor;
|
||||
Caption: string;
|
||||
Font: TFont; // Just a reference, never Free
|
||||
AutoSize: Boolean;
|
||||
end;
|
||||
|
||||
TCDEditStateEx = class(TCDControlStateEx)
|
||||
public
|
||||
CaretIsVisible: Boolean;
|
||||
CaretPos: Integer; // zero-based position
|
||||
SelStart: Integer; // zero-based position
|
||||
SelLength: Integer; // zero means no selection. Negative numbers selection to the left from the start and positive ones to the right
|
||||
VisibleTextStart: Integer; // 1-based
|
||||
end;
|
||||
|
||||
TCDTrackBarStateEx = class(TCDControlStateEx)
|
||||
public
|
||||
Min: integer;
|
||||
Max: integer;
|
||||
Position: integer;
|
||||
end;
|
||||
|
||||
TCDCTabControlStateEx = class(TCDControlStateEx)
|
||||
public
|
||||
LeftmostTabVisibleIndex: Integer;
|
||||
Tabs: TStringList; // Just a reference, don't Free
|
||||
TabIndex: Integer; // For Tab routines, obtain the index
|
||||
end;
|
||||
|
||||
TCDControlID = (
|
||||
cidControl,
|
||||
cidButton,
|
||||
cidEdit,
|
||||
cidCheckBox,
|
||||
cidGroupBox,
|
||||
cidTrackBar,
|
||||
cidCustomTabControl
|
||||
);
|
||||
|
||||
{ TCDDrawer }
|
||||
|
||||
TCDDrawer = class
|
||||
public
|
||||
function GetControlColor(AControlId: TCDControlID): TColor;
|
||||
// General
|
||||
function GetMeasures(AMeasureID: Integer): Integer; virtual; abstract;
|
||||
function GetMeasuresEx(ADest: TCanvas; AMeasureID: Integer;
|
||||
AState: TCDControlState; AStateEx: TCDControlStateEx): Integer; virtual; abstract;
|
||||
function GetColor(AColorID: Integer): TColor; virtual; abstract;
|
||||
procedure DrawControl(ADest: TCanvas; ADestPos: TPoint; ASize: TSize;
|
||||
AControl: TCDControlID; AState: TCDControlState; AStateEx: TCDControlStateEx); virtual; abstract;
|
||||
// TCDButton
|
||||
procedure DrawButton(ADest: TCanvas; ADestPos: TPoint; ASize: TSize;
|
||||
AState: TCDControlState; AStateEx: TCDControlStateEx); virtual; abstract;
|
||||
// TCDEdit
|
||||
procedure CreateEditBackgroundBitmap(ADest: TCanvas; ADestPos: TPoint; ASize: TSize;
|
||||
AState: TCDControlState; AStateEx: TCDEditStateEx); virtual; abstract;
|
||||
procedure DrawEdit(ADest: TCanvas; ADestPos: TPoint; ASize: TSize;
|
||||
AState: TCDControlState; AStateEx: TCDEditStateEx); virtual; abstract;
|
||||
// TCDCheckBox
|
||||
procedure CalculateCheckBoxPreferredSize(ADest: TCanvas;
|
||||
AState: TCDControlState; AStateEx: TCDControlStateEx;
|
||||
var PreferredWidth, PreferredHeight: integer; WithThemeSpace: Boolean); virtual; abstract;
|
||||
procedure DrawCheckBox(ADest: TCanvas; ADestPos: TPoint; ASize: TSize;
|
||||
AState: TCDControlState; AStateEx: TCDControlStateEx); virtual; abstract;
|
||||
// TCDGroupBox
|
||||
procedure DrawGroupBox(ADest: TCanvas; ADestPos: TPoint; ASize: TSize;
|
||||
AState: TCDControlState; AStateEx: TCDControlStateEx); virtual; abstract;
|
||||
// ===================================
|
||||
// Common Controls Tab
|
||||
// ===================================
|
||||
// TCDCustomTabControl
|
||||
procedure DrawCTabControl(ADest: TCanvas; ADestPos: TPoint; ASize: TSize;
|
||||
AState: TCDControlState; AStateEx: TCDCTabControlStateEx); virtual; abstract;
|
||||
procedure DrawTabSheet(ADest: TCanvas; ADestPos: TPoint; ASize: TSize;
|
||||
AState: TCDControlState; AStateEx: TCDCTabControlStateEx); virtual; abstract;
|
||||
procedure DrawTabs(ADest: TCanvas; ADestPos: TPoint; ASize: TSize;
|
||||
AState: TCDControlState; AStateEx: TCDCTabControlStateEx); virtual; abstract;
|
||||
procedure DrawTab(ADest: TCanvas; ADestPos: TPoint; ASize: TSize;
|
||||
AState: TCDControlState; AStateEx: TCDCTabControlStateEx); virtual; abstract;
|
||||
function GetPageIndexFromXY(x, y: integer): integer; virtual; abstract;
|
||||
end;
|
||||
|
||||
procedure RegisterDrawer(ADrawer: TCDDrawer; AStyle: TCDDrawStyle);
|
||||
function GetDefaultDrawer: TCDDrawer;
|
||||
function GetDrawer(AStyle: TCDDrawStyle): TCDDrawer;
|
||||
|
||||
var
|
||||
DefaultStyle: TCDDrawStyle = dsWinCE; // For now default to the most complete one, later per platform
|
||||
|
||||
implementation
|
||||
|
||||
var
|
||||
RegisteredDrawers: array[TCDDrawStyle] of TCDDrawer
|
||||
= (nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil);
|
||||
|
||||
procedure RegisterDrawer(ADrawer: TCDDrawer; AStyle: TCDDrawStyle);
|
||||
begin
|
||||
if RegisteredDrawers[AStyle] <> nil then RegisteredDrawers[AStyle].Free;
|
||||
RegisteredDrawers[AStyle] := ADrawer;
|
||||
end;
|
||||
|
||||
function GetDefaultDrawer: TCDDrawer;
|
||||
begin
|
||||
Result := GetDrawer(dsDefault);
|
||||
end;
|
||||
|
||||
function GetDrawer(AStyle: TCDDrawStyle): TCDDrawer;
|
||||
var
|
||||
lDrawStyle: TCDDrawStyle;
|
||||
begin
|
||||
if AStyle = dsDefault then lDrawStyle := DefaultStyle
|
||||
else lDrawStyle := AStyle;
|
||||
Result := RegisteredDrawers[lDrawStyle];
|
||||
end;
|
||||
|
||||
var
|
||||
i: Integer;
|
||||
|
||||
{ TCDDrawer }
|
||||
|
||||
function TCDDrawer.GetControlColor(AControlId: TCDControlID): TColor;
|
||||
begin
|
||||
case AControlId of
|
||||
cidControl: Result := clSilver;
|
||||
cidButton: Result := clSilver;
|
||||
cidEdit: Result := clSilver;
|
||||
cidCheckBox: Result := clSilver;
|
||||
cidGroupBox: Result := clSilver;
|
||||
cidTrackBar: Result := clSilver;
|
||||
cidCustomTabControl: Result := clSilver;
|
||||
else
|
||||
Result := clSilver;
|
||||
end;
|
||||
end;
|
||||
|
||||
finalization
|
||||
// Free all drawers
|
||||
for i := 0 to CDDRAWSTYLE_COUNT-1 do
|
||||
begin
|
||||
if RegisteredDrawers[TCDDrawStyle(i)] <> nil then
|
||||
begin
|
||||
RegisteredDrawers[TCDDrawStyle(i)].Free;
|
||||
RegisteredDrawers[TCDDrawStyle(i)] := nil;
|
||||
end;
|
||||
end;
|
||||
end.
|
||||
|
||||
@ -182,8 +182,11 @@ resourcestring
|
||||
|
||||
procedure Register;
|
||||
begin
|
||||
RegisterComponents('Custom Drawn', [TCDButton, TCDTrackBar, TCDTabControl,
|
||||
TCDPageControl, TCDGroupBox]);
|
||||
RegisterComponents('Custom Drawn', [
|
||||
// Standard tab
|
||||
TCDButton, TCDEdit, TCDGroupBox,
|
||||
// Common Controls
|
||||
TCDTrackBar, TCDPageControl, TCDTabControl]);
|
||||
RegisterComponentEditor(TCDPageControl, TCDPageControlEditor);
|
||||
RegisterComponentEditor(TCDTabSheet, TCDPageControlEditor);
|
||||
RegisterNoIcon([TCDTabSheet]);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user