initial commit
[rofl0r-TntUnicode.git] / Design / TntComCtrls_Design.pas
blobaada4826b56ae356309925653d79372dc25c8b02
2 {*****************************************************************************}
3 { }
4 { Tnt Delphi Unicode Controls }
5 { http://www.tntware.com/delphicontrols/unicode/ }
6 { Version: 2.3.0 }
7 { }
8 { Copyright (c) 2002-2007, Troy Wolbrink (troy.wolbrink@tntware.com) }
9 { }
10 {*****************************************************************************}
12 unit TntComCtrls_Design;
14 {$INCLUDE ..\Source\TntCompilers.inc}
16 interface
18 uses
19 DesignIntf, DesignMenus, DesignEditors, Classes, ComCtrls;
21 type
22 IPrepareMenuItem = IMenuItem;
24 TTntListViewEditor = class(TComponentEditor)
25 public
26 procedure ExecuteVerb(Index: Integer); override;
27 function GetVerb(Index: Integer): string{TNT-ALLOW string}; override;
28 function GetVerbCount: Integer; override;
29 end;
31 TTntPageControlEditor = class(TDefaultEditor)
32 private
33 function PageControl: TPageControl{TNT-ALLOW TPageControl};
34 public
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;
39 end;
41 TTntStatusBarEditor = class(TComponentEditor)
42 public
43 procedure ExecuteVerb(Index: Integer); override;
44 function GetVerb(Index: Integer): string{TNT-ALLOW string}; override;
45 function GetVerbCount: Integer; override;
46 end;
48 TTntToolBarEditor = class(TComponentEditor)
49 public
50 procedure ExecuteVerb(Index: Integer); override;
51 function GetVerb(Index: Integer): string{TNT-ALLOW string}; override;
52 function GetVerbCount: Integer; override;
53 end;
55 procedure Register;
57 implementation
59 uses
60 SysUtils, DsnConst, TntComCtrls, TntDesignEditors_Design;
62 procedure Register;
63 begin
64 RegisterComponentEditor(TTntListView, TTntListViewEditor);
65 RegisterComponentEditor(TTntPageControl, TTntPageControlEditor);
66 RegisterComponentEditor(TTntTabSheet, TTntPageControlEditor);
67 RegisterComponentEditor(TTntStatusBar, TTntStatusBarEditor);
68 RegisterComponentEditor(TTntToolBar, TTntToolBarEditor);
69 RegisterComponentEditor(TTntToolButton, TTntToolBarEditor);
70 end;
72 { TTntListViewEditor }
74 function TTntListViewEditor.GetVerbCount: Integer;
75 begin
76 Result := 2;
77 end;
79 function TTntListViewEditor.GetVerb(Index: Integer): string{TNT-ALLOW string};
80 begin
81 case Index of
82 0: Result := SListColumnsEditor;
83 1: Result := SListItemsEditor;
84 end;
85 end;
87 procedure TTntListViewEditor.ExecuteVerb(Index: Integer);
88 begin
89 case Index of
90 0: EditPropertyWithDialog(Component, 'Columns', Designer);
91 1: EditPropertyWithDialog(Component, 'Items', Designer);
92 end;
93 end;
95 { TTntPageControlEditor }
97 function TTntPageControlEditor.PageControl: TPageControl{TNT-ALLOW TPageControl};
98 begin
99 if Component is TTabSheet{TNT-ALLOW TTabSheet} then
100 Result := TTabSheet{TNT-ALLOW TTabSheet}(Component).PageControl
101 else
102 Result := Component as TPageControl{TNT-ALLOW TPageControl};
103 end;
105 function TTntPageControlEditor.GetVerbCount: Integer;
106 begin
107 Result := 4;
108 end;
110 function TTntPageControlEditor.GetVerb(Index: Integer): string{TNT-ALLOW string};
111 begin
112 case Index of
113 0: Result := SNewPage;
114 1: Result := SNextPage;
115 2: Result := SPrevPage;
116 3: Result := SDeletePage;
117 end;
118 end;
120 procedure TTntPageControlEditor.PrepareItem(Index: Integer; const AItem: IPrepareMenuItem);
121 begin
122 AItem.Enabled := (Index <> 3) or (PageControl.PageCount > 0);
123 end;
125 type TAccessPageControl = class(TPageControl{TNT-ALLOW TPageControl});
127 procedure TTntPageControlEditor.ExecuteVerb(Index: Integer);
129 procedure CreateNewTabSheet;
131 NewTabsheet: TTntTabSheet;
132 begin
133 NewTabSheet := TTntTabSheet.Create(PageControl.Owner);
134 NewTabSheet.PageControl := Self.PageControl;
135 with NewTabSheet do begin
136 Name := Designer.UniqueName(ClassName);
137 Caption := Name;
138 Visible := True;
139 end;
140 PageControl.ActivePage := NewTabSheet;
141 end;
143 begin
144 case Index of
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;
150 end;
151 end;
153 { TTntStatusBarEditor }
155 function TTntStatusBarEditor.GetVerbCount: Integer;
156 begin
157 Result := 1;
158 end;
160 function TTntStatusBarEditor.GetVerb(Index: Integer): string{TNT-ALLOW string};
161 begin
162 case Index of
163 0: Result := SStatusBarPanelEdit;
164 end;
165 end;
167 procedure TTntStatusBarEditor.ExecuteVerb(Index: Integer);
168 begin
169 case Index of
170 0: EditPropertyWithDialog(Component, 'Panels', Designer);
171 end;
172 end;
174 { TTntToolBarEditor }
176 procedure TTntToolBarEditor.ExecuteVerb(Index: Integer);
178 ToolBar: TTntToolBar;
179 ToolButton: TTntToolButton;
180 I, J: Integer;
181 NewName: WideString;
182 begin
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)
189 else
190 Exit;
192 ToolButton := TTntToolButton.Create(Component.Owner);
194 I := 1;
195 repeat
196 NewName := 'TntToolButton' + IntToStr(I);
197 for J := 0 to ToolBar.ControlCount - 1 do
198 if WideSameText(ToolBar.Controls[J].Name, NewName) then
199 NewName := '';
200 Inc(I);
201 until NewName <> '';
202 ToolButton.Name := NewName;
204 if Index = 1 then begin
205 ToolButton.Style := tbsSeparator;
206 ToolButton.Width := 8;
207 end;
209 for I := 0 to ToolBar.ControlCount - 1 do
210 ToolButton.Left := ToolButton.Left + ToolBar.Controls[I].Width;
212 ToolButton.Parent := ToolBar;
213 end;
215 function TTntToolBarEditor.GetVerb(Index: Integer): string{TNT-ALLOW string};
216 begin
217 case Index of
218 0: Result := SNewToolButton;
219 1: Result := SNewToolSeparator;
220 end;
221 end;
223 function TTntToolBarEditor.GetVerbCount: Integer;
224 begin
225 Result := 2;
226 end;
228 end.