2 {*****************************************************************************}
4 { Tnt Delphi Unicode Controls }
5 { http://www.tntware.com/delphicontrols/unicode/ }
8 { Copyright (c) 2002-2007, Troy Wolbrink (troy.wolbrink@tntware.com) }
10 {*****************************************************************************}
12 unit TntComCtrls_Design
;
14 {$INCLUDE ..\Source\TntCompilers.inc}
19 DesignIntf
, DesignMenus
, DesignEditors
, Classes
, ComCtrls
;
22 IPrepareMenuItem
= IMenuItem
;
24 TTntListViewEditor
= class(TComponentEditor
)
26 procedure ExecuteVerb(Index
: Integer); override;
27 function GetVerb(Index
: Integer): string{TNT-ALLOW string}; override;
28 function GetVerbCount
: Integer; override;
31 TTntPageControlEditor
= class(TDefaultEditor
)
33 function PageControl
: TPageControl
{TNT-ALLOW TPageControl};
35 procedure ExecuteVerb(Index
: Integer); override;
36 function GetVerb(Index
: Integer): string{TNT-ALLOW string}; override;
37 function GetVerbCount
: Integer; override;
38 procedure PrepareItem(Index
: Integer; const AItem
: IPrepareMenuItem
); override;
41 TTntStatusBarEditor
= class(TComponentEditor
)
43 procedure ExecuteVerb(Index
: Integer); override;
44 function GetVerb(Index
: Integer): string{TNT-ALLOW string}; override;
45 function GetVerbCount
: Integer; override;
48 TTntToolBarEditor
= class(TComponentEditor
)
50 procedure ExecuteVerb(Index
: Integer); override;
51 function GetVerb(Index
: Integer): string{TNT-ALLOW string}; override;
52 function GetVerbCount
: Integer; override;
60 SysUtils
, DsnConst
, TntComCtrls
, TntDesignEditors_Design
;
64 RegisterComponentEditor(TTntListView
, TTntListViewEditor
);
65 RegisterComponentEditor(TTntPageControl
, TTntPageControlEditor
);
66 RegisterComponentEditor(TTntTabSheet
, TTntPageControlEditor
);
67 RegisterComponentEditor(TTntStatusBar
, TTntStatusBarEditor
);
68 RegisterComponentEditor(TTntToolBar
, TTntToolBarEditor
);
69 RegisterComponentEditor(TTntToolButton
, TTntToolBarEditor
);
72 { TTntListViewEditor }
74 function TTntListViewEditor
.GetVerbCount
: Integer;
79 function TTntListViewEditor
.GetVerb(Index
: Integer): string{TNT-ALLOW string};
82 0: Result
:= SListColumnsEditor
;
83 1: Result
:= SListItemsEditor
;
87 procedure TTntListViewEditor
.ExecuteVerb(Index
: Integer);
90 0: EditPropertyWithDialog(Component
, 'Columns', Designer
);
91 1: EditPropertyWithDialog(Component
, 'Items', Designer
);
95 { TTntPageControlEditor }
97 function TTntPageControlEditor
.PageControl
: TPageControl
{TNT-ALLOW TPageControl};
99 if Component
is TTabSheet
{TNT-ALLOW TTabSheet} then
100 Result
:= TTabSheet
{TNT-ALLOW TTabSheet}(Component
).PageControl
102 Result
:= Component
as TPageControl
{TNT-ALLOW TPageControl};
105 function TTntPageControlEditor
.GetVerbCount
: Integer;
110 function TTntPageControlEditor
.GetVerb(Index
: Integer): string{TNT-ALLOW string};
113 0: Result
:= SNewPage
;
114 1: Result
:= SNextPage
;
115 2: Result
:= SPrevPage
;
116 3: Result
:= SDeletePage
;
120 procedure TTntPageControlEditor
.PrepareItem(Index
: Integer; const AItem
: IPrepareMenuItem
);
122 AItem
.Enabled
:= (Index
<> 3) or (PageControl
.PageCount
> 0);
125 type TAccessPageControl
= class(TPageControl
{TNT-ALLOW TPageControl});
127 procedure TTntPageControlEditor
.ExecuteVerb(Index
: Integer);
129 procedure CreateNewTabSheet
;
131 NewTabsheet
: TTntTabSheet
;
133 NewTabSheet
:= TTntTabSheet
.Create(PageControl
.Owner
);
134 NewTabSheet
.PageControl
:= Self
.PageControl
;
135 with NewTabSheet
do begin
136 Name
:= Designer
.UniqueName(ClassName
);
140 PageControl
.ActivePage
:= NewTabSheet
;
145 0: CreateNewTabSheet
;
146 1: PageControl
.SelectNextPage(True, False);
147 2: PageControl
.SelectNextPage(False, False);
148 3: if PageControl
.ActivePage
<> nil then
149 PageControl
.ActivePage
.Free
;
153 { TTntStatusBarEditor }
155 function TTntStatusBarEditor
.GetVerbCount
: Integer;
160 function TTntStatusBarEditor
.GetVerb(Index
: Integer): string{TNT-ALLOW string};
163 0: Result
:= SStatusBarPanelEdit
;
167 procedure TTntStatusBarEditor
.ExecuteVerb(Index
: Integer);
170 0: EditPropertyWithDialog(Component
, 'Panels', Designer
);
174 { TTntToolBarEditor }
176 procedure TTntToolBarEditor
.ExecuteVerb(Index
: Integer);
178 ToolBar
: TTntToolBar
;
179 ToolButton
: TTntToolButton
;
183 Assert(Index
in [0, 1]);
185 if Component
is TTntToolBar
then
186 ToolBar
:= TTntToolBar(Component
)
187 else if (Component
is TTntToolButton
) and (TTntToolButton(Component
).Parent
is TTntToolBar
) then
188 ToolBar
:= TTntToolBar(TTntToolButton(Component
).Parent
)
192 ToolButton
:= TTntToolButton
.Create(Component
.Owner
);
196 NewName
:= 'TntToolButton' + IntToStr(I
);
197 for J
:= 0 to ToolBar
.ControlCount
- 1 do
198 if WideSameText(ToolBar
.Controls
[J
].Name
, NewName
) then
202 ToolButton
.Name
:= NewName
;
204 if Index
= 1 then begin
205 ToolButton
.Style
:= tbsSeparator
;
206 ToolButton
.Width
:= 8;
209 for I
:= 0 to ToolBar
.ControlCount
- 1 do
210 ToolButton
.Left
:= ToolButton
.Left
+ ToolBar
.Controls
[I
].Width
;
212 ToolButton
.Parent
:= ToolBar
;
215 function TTntToolBarEditor
.GetVerb(Index
: Integer): string{TNT-ALLOW string};
218 0: Result
:= SNewToolButton
;
219 1: Result
:= SNewToolSeparator
;
223 function TTntToolBarEditor
.GetVerbCount
: Integer;