source: cprs/branches/tmg-cprs/TMG_Extra/tntUniCode/Design/TntComCtrls_Design.pas@ 1582

Last change on this file since 1582 was 672, checked in by Kevin Toppenberg, 15 years ago

Adding source to tntControls for compilation

File size: 6.3 KB
Line 
1
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{*****************************************************************************}
11
12unit TntComCtrls_Design;
13
14{$INCLUDE ..\Source\TntCompilers.inc}
15
16interface
17
18uses
19 DesignIntf, DesignMenus, DesignEditors, Classes, ComCtrls;
20
21type
22 IPrepareMenuItem = IMenuItem;
23
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;
30
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;
40
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;
47
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;
54
55procedure Register;
56
57implementation
58
59uses
60 SysUtils, DsnConst, TntComCtrls, TntDesignEditors_Design;
61
62procedure Register;
63begin
64 RegisterComponentEditor(TTntListView, TTntListViewEditor);
65 RegisterComponentEditor(TTntPageControl, TTntPageControlEditor);
66 RegisterComponentEditor(TTntTabSheet, TTntPageControlEditor);
67 RegisterComponentEditor(TTntStatusBar, TTntStatusBarEditor);
68 RegisterComponentEditor(TTntToolBar, TTntToolBarEditor);
69 RegisterComponentEditor(TTntToolButton, TTntToolBarEditor);
70end;
71
72{ TTntListViewEditor }
73
74function TTntListViewEditor.GetVerbCount: Integer;
75begin
76 Result := 2;
77end;
78
79function TTntListViewEditor.GetVerb(Index: Integer): string{TNT-ALLOW string};
80begin
81 case Index of
82 0: Result := SListColumnsEditor;
83 1: Result := SListItemsEditor;
84 end;
85end;
86
87procedure TTntListViewEditor.ExecuteVerb(Index: Integer);
88begin
89 case Index of
90 0: EditPropertyWithDialog(Component, 'Columns', Designer);
91 1: EditPropertyWithDialog(Component, 'Items', Designer);
92 end;
93end;
94
95{ TTntPageControlEditor }
96
97function TTntPageControlEditor.PageControl: TPageControl{TNT-ALLOW TPageControl};
98begin
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};
103end;
104
105function TTntPageControlEditor.GetVerbCount: Integer;
106begin
107 Result := 4;
108end;
109
110function TTntPageControlEditor.GetVerb(Index: Integer): string{TNT-ALLOW string};
111begin
112 case Index of
113 0: Result := SNewPage;
114 1: Result := SNextPage;
115 2: Result := SPrevPage;
116 3: Result := SDeletePage;
117 end;
118end;
119
120procedure TTntPageControlEditor.PrepareItem(Index: Integer; const AItem: IPrepareMenuItem);
121begin
122 AItem.Enabled := (Index <> 3) or (PageControl.PageCount > 0);
123end;
124
125type TAccessPageControl = class(TPageControl{TNT-ALLOW TPageControl});
126
127procedure TTntPageControlEditor.ExecuteVerb(Index: Integer);
128
129 procedure CreateNewTabSheet;
130 var
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;
142
143begin
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;
151end;
152
153{ TTntStatusBarEditor }
154
155function TTntStatusBarEditor.GetVerbCount: Integer;
156begin
157 Result := 1;
158end;
159
160function TTntStatusBarEditor.GetVerb(Index: Integer): string{TNT-ALLOW string};
161begin
162 case Index of
163 0: Result := SStatusBarPanelEdit;
164 end;
165end;
166
167procedure TTntStatusBarEditor.ExecuteVerb(Index: Integer);
168begin
169 case Index of
170 0: EditPropertyWithDialog(Component, 'Panels', Designer);
171 end;
172end;
173
174{ TTntToolBarEditor }
175
176procedure TTntToolBarEditor.ExecuteVerb(Index: Integer);
177var
178 ToolBar: TTntToolBar;
179 ToolButton: TTntToolButton;
180 I, J: Integer;
181 NewName: WideString;
182begin
183 Assert(Index in [0, 1]);
184
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;
191
192 ToolButton := TTntToolButton.Create(Component.Owner);
193
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;
203
204 if Index = 1 then begin
205 ToolButton.Style := tbsSeparator;
206 ToolButton.Width := 8;
207 end;
208
209 for I := 0 to ToolBar.ControlCount - 1 do
210 ToolButton.Left := ToolButton.Left + ToolBar.Controls[I].Width;
211
212 ToolButton.Parent := ToolBar;
213end;
214
215function TTntToolBarEditor.GetVerb(Index: Integer): string{TNT-ALLOW string};
216begin
217 case Index of
218 0: Result := SNewToolButton;
219 1: Result := SNewToolSeparator;
220 end;
221end;
222
223function TTntToolBarEditor.GetVerbCount: Integer;
224begin
225 Result := 2;
226end;
227
228end.
Note: See TracBrowser for help on using the repository browser.