source: cprs/branches/tmg-cprs/TMG_Extra/tntUniCode/Design/TntActions_Design.pas@ 861

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

Adding source to tntControls for compilation

File size: 6.4 KB
RevLine 
[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
12unit TntActions_Design;
13
14{$INCLUDE ..\Source\TntCompilers.inc}
15
16interface
17
18procedure Register;
19
20implementation
21
22uses
23 Classes, ActnList, TntActnList, StdActns, TntStdActns,
24 ExtActns, TntExtActns, ListActns, TntListActns, BandActn, TntBandActn,
25 DBActns, TntDBActns, TntDesignEditors_Design;
26
27procedure Register;
28begin
29 RegisterClass(TTntAction);
30 // StdActns
31 RegisterClass(TTntEditAction);
32 RegisterClass(TTntEditCut);
33 RegisterClass(TTntEditCopy);
34 RegisterClass(TTntEditPaste);
35 RegisterClass(TTntEditSelectAll);
36 RegisterClass(TTntEditUndo);
37 RegisterClass(TTntEditDelete);
38 RegisterClass(TTntWindowAction);
39 RegisterClass(TTntWindowClose);
40 RegisterClass(TTntWindowCascade);
41 RegisterClass(TTntWindowTileHorizontal);
42 RegisterClass(TTntWindowTileVertical);
43 RegisterClass(TTntWindowMinimizeAll);
44 RegisterClass(TTntWindowArrange);
45 RegisterClass(TTntHelpAction);
46 RegisterClass(TTntHelpContents);
47 RegisterClass(TTntHelpTopicSearch);
48 RegisterClass(TTntHelpOnHelp);
49 RegisterClass(TTntHelpContextAction);
50 RegisterClass(TTntFileOpen);
51 RegisterClass(TTntFileOpenWith);
52 RegisterClass(TTntFileSaveAs);
53 RegisterClass(TTntFilePrintSetup);
54 RegisterClass(TTntFileExit);
55 RegisterClass(TTntSearchFind);
56 RegisterClass(TTntSearchReplace);
57 RegisterClass(TTntSearchFindFirst);
58 RegisterClass(TTntSearchFindNext);
59 RegisterClass(TTntFontEdit);
60 RegisterClass(TTntColorSelect);
61 RegisterClass(TTntPrintDlg);
62 // ExtActns
63 RegisterClass(TTntFileRun);
64 RegisterClass(TTntRichEditAction);
65 RegisterClass(TTntRichEditBold);
66 RegisterClass(TTntRichEditItalic);
67 RegisterClass(TTntRichEditUnderline);
68 RegisterClass(TTntRichEditStrikeOut);
69 RegisterClass(TTntRichEditBullets);
70 RegisterClass(TTntRichEditAlignLeft);
71 RegisterClass(TTntRichEditAlignRight);
72 RegisterClass(TTntRichEditAlignCenter);
73 RegisterClass(TTntPreviousTab);
74 RegisterClass(TTntNextTab);
75 RegisterClass(TTntOpenPicture);
76 RegisterClass(TTntSavePicture);
77 RegisterClass(TTntURLAction);
78 RegisterClass(TTntBrowseURL);
79 RegisterClass(TTntDownLoadURL);
80 RegisterClass(TTntSendMail);
81 RegisterClass(TTntListControlCopySelection);
82 RegisterClass(TTntListControlDeleteSelection);
83 RegisterClass(TTntListControlSelectAll);
84 RegisterClass(TTntListControlClearSelection);
85 RegisterClass(TTntListControlMoveSelection);
86 // ListActns
87 RegisterClass(TTntStaticListAction);
88 RegisterClass(TTntVirtualListAction);
89 {$IFDEF COMPILER_7_UP}
90 RegisterClass(TTntFilePageSetup);
91 {$ENDIF}
92 // DBActns
93 RegisterClass(TTntDataSetAction);
94 RegisterClass(TTntDataSetFirst);
95 RegisterClass(TTntDataSetPrior);
96 RegisterClass(TTntDataSetNext);
97 RegisterClass(TTntDataSetLast);
98 RegisterClass(TTntDataSetInsert);
99 RegisterClass(TTntDataSetDelete);
100 RegisterClass(TTntDataSetEdit);
101 RegisterClass(TTntDataSetPost);
102 RegisterClass(TTntDataSetCancel);
103 RegisterClass(TTntDataSetRefresh);
104 // BandActn
105 RegisterClass(TTntCustomizeActionBars);
106end;
107
108//------------------------
109
110function GetTntActionClass(OldActionClass: TContainedActionClass): TContainedActionClass;
111begin
112 Result := TContainedActionClass(GetClass('TTnt' + Copy(OldActionClass.ClassName, 2, Length(OldActionClass.ClassName))));
113end;
114
115type
116 TAccessContainedAction = class(TContainedAction);
117
118function UpgradeAction(ActionList: TTntActionList; OldAction: TContainedAction): TContainedAction;
119var
120 Name: TComponentName;
121 i: integer;
122 NewActionClass: TContainedActionClass;
123begin
124 Result := nil;
125 if (OldAction = nil) or (OldAction.Owner = nil) or (OldAction.Name = '') then
126 Exit;
127
128 NewActionClass := GetTntActionClass(TContainedActionClass(OldAction.ClassType));
129 if NewActionClass <> nil then begin
130 // create new action
131 Result := NewActionClass.Create(OldAction.Owner) as TContainedAction;
132 Include(TAccessContainedAction(Result).FComponentStyle, csTransient);
133 // copy base class info
134 Result.ActionComponent := OldAction.ActionComponent;
135 Result.Category := OldAction.Category; { Assign Category before ActionList/Index to avoid flicker. }
136 Result.ActionList := ActionList;
137 Result.Index := OldAction.Index;
138 // assign props
139 Result.Assign(OldAction);
140 // point all links to this new action
141 for i := TAccessContainedAction(OldAction).FClients.Count - 1 downto 0 do
142 TBasicActionLink(TAccessContainedAction(OldAction).FClients[i]).Action := Result;
143 // free old object, preserve name...
144 Name := OldAction.Name;
145 OldAction.Free;
146 Result.Name := Name; { link up to old name }
147 Exclude(TAccessContainedAction(Result).FComponentStyle, csTransient);
148 end;
149end;
150
151procedure TntActionList_UpgradeActionListItems(ActionList: TTntActionList);
152var
153 DesignerNotify: IDesignerNotify;
154 Designer: ITntDesigner;
155 TntSelections: TTntDesignerSelections;
156 i: integer;
157 OldAction, NewAction: TContainedAction;
158begin
159 DesignerNotify := FindRootDesigner(ActionList);
160 if (DesignerNotify <> nil) then begin
161 DesignerNotify.QueryInterface(ITntDesigner, Designer);
162 if (Designer <> nil) then begin
163 TntSelections := TTntDesignerSelections.Create;
164 try
165 Designer.GetSelections(TntSelections);
166 for i := ActionList.ActionCount - 1 downto 0 do begin
167 OldAction := ActionList.Actions[i];
168 NewAction := UpgradeAction(ActionList, OldAction);
169 if (NewAction <> nil) then
170 TntSelections.ReplaceSelection(OldAction, NewAction);
171 end;
172 Designer.SetSelections(TntSelections);
173 finally
174 TntSelections.Free;
175 end;
176 end;
177 end;
178end;
179
180initialization
181 UpgradeActionListItemsProc := TntActionList_UpgradeActionListItems;
182
183end.
Note: See TracBrowser for help on using the repository browser.