[672] | 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 |
|
---|
| 12 | unit TntComCtrls_Design;
|
---|
| 13 |
|
---|
| 14 | {$INCLUDE ..\Source\TntCompilers.inc}
|
---|
| 15 |
|
---|
| 16 | interface
|
---|
| 17 |
|
---|
| 18 | uses
|
---|
| 19 | DesignIntf, DesignMenus, DesignEditors, Classes, ComCtrls;
|
---|
| 20 |
|
---|
| 21 | type
|
---|
| 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 |
|
---|
| 55 | procedure Register;
|
---|
| 56 |
|
---|
| 57 | implementation
|
---|
| 58 |
|
---|
| 59 | uses
|
---|
| 60 | SysUtils, DsnConst, TntComCtrls, TntDesignEditors_Design;
|
---|
| 61 |
|
---|
| 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;
|
---|
| 71 |
|
---|
| 72 | { TTntListViewEditor }
|
---|
| 73 |
|
---|
| 74 | function TTntListViewEditor.GetVerbCount: Integer;
|
---|
| 75 | begin
|
---|
| 76 | Result := 2;
|
---|
| 77 | end;
|
---|
| 78 |
|
---|
| 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;
|
---|
| 86 |
|
---|
| 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;
|
---|
| 94 |
|
---|
| 95 | { TTntPageControlEditor }
|
---|
| 96 |
|
---|
| 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;
|
---|
| 104 |
|
---|
| 105 | function TTntPageControlEditor.GetVerbCount: Integer;
|
---|
| 106 | begin
|
---|
| 107 | Result := 4;
|
---|
| 108 | end;
|
---|
| 109 |
|
---|
| 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;
|
---|
| 119 |
|
---|
| 120 | procedure TTntPageControlEditor.PrepareItem(Index: Integer; const AItem: IPrepareMenuItem);
|
---|
| 121 | begin
|
---|
| 122 | AItem.Enabled := (Index <> 3) or (PageControl.PageCount > 0);
|
---|
| 123 | end;
|
---|
| 124 |
|
---|
| 125 | type TAccessPageControl = class(TPageControl{TNT-ALLOW TPageControl});
|
---|
| 126 |
|
---|
| 127 | procedure 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 |
|
---|
| 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;
|
---|
| 152 |
|
---|
| 153 | { TTntStatusBarEditor }
|
---|
| 154 |
|
---|
| 155 | function TTntStatusBarEditor.GetVerbCount: Integer;
|
---|
| 156 | begin
|
---|
| 157 | Result := 1;
|
---|
| 158 | end;
|
---|
| 159 |
|
---|
| 160 | function TTntStatusBarEditor.GetVerb(Index: Integer): string{TNT-ALLOW string};
|
---|
| 161 | begin
|
---|
| 162 | case Index of
|
---|
| 163 | 0: Result := SStatusBarPanelEdit;
|
---|
| 164 | end;
|
---|
| 165 | end;
|
---|
| 166 |
|
---|
| 167 | procedure TTntStatusBarEditor.ExecuteVerb(Index: Integer);
|
---|
| 168 | begin
|
---|
| 169 | case Index of
|
---|
| 170 | 0: EditPropertyWithDialog(Component, 'Panels', Designer);
|
---|
| 171 | end;
|
---|
| 172 | end;
|
---|
| 173 |
|
---|
| 174 | { TTntToolBarEditor }
|
---|
| 175 |
|
---|
| 176 | procedure TTntToolBarEditor.ExecuteVerb(Index: Integer);
|
---|
| 177 | var
|
---|
| 178 | ToolBar: TTntToolBar;
|
---|
| 179 | ToolButton: TTntToolButton;
|
---|
| 180 | I, J: Integer;
|
---|
| 181 | NewName: WideString;
|
---|
| 182 | begin
|
---|
| 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;
|
---|
| 213 | end;
|
---|
| 214 |
|
---|
| 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;
|
---|
| 222 |
|
---|
| 223 | function TTntToolBarEditor.GetVerbCount: Integer;
|
---|
| 224 | begin
|
---|
| 225 | Result := 2;
|
---|
| 226 | end;
|
---|
| 227 |
|
---|
| 228 | end.
|
---|