-
Notifications
You must be signed in to change notification settings - Fork 0
/
uPSC_menus.pas
214 lines (203 loc) · 9.49 KB
/
uPSC_menus.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
{ Menus Import Unit }
Unit uPSC_menus;
{$I PascalScript.inc}
Interface
Uses uPSCompiler;
procedure SIRegisterTMENUITEMSTACK(CL: TPSPascalCompiler);
procedure SIRegisterTPOPUPLIST(CL: TPSPascalCompiler);
procedure SIRegisterTPOPUPMENU(CL: TPSPascalCompiler);
procedure SIRegisterTMAINMENU(CL: TPSPascalCompiler);
procedure SIRegisterTMENU(CL: TPSPascalCompiler);
procedure SIRegisterTMENUITEM(CL: TPSPascalCompiler);
procedure SIRegister_Menus(Cl: TPSPascalCompiler);
implementation
procedure SIRegisterTMENUITEMSTACK(CL: TPSPascalCompiler);
begin
With cl.AddClassN(Cl.FindClass('TSTACK'),'TMENUITEMSTACK') do
begin
RegisterMethod('Procedure CLEARITEM( AITEM : TMENUITEM)');
end;
end;
procedure SIRegisterTPOPUPLIST(CL: TPSPascalCompiler);
begin
With cl.AddClassN(Cl.FindClass('TLIST'),'TPOPUPLIST') do
begin
RegisterProperty('WINDOW', 'HWND', iptr);
RegisterMethod('Procedure ADD( POPUP : TPOPUPMENU)');
RegisterMethod('Procedure REMOVE( POPUP : TPOPUPMENU)');
end;
end;
procedure SIRegisterTPOPUPMENU(CL: TPSPascalCompiler);
var
cc: TPSCompileTimeClass;
begin
With cl.AddClassN(Cl.FindClass('TMENU'),'TPOPUPMENU') do
begin
cc := Cl.FindClass('TLabel');
if cc <> nil then
RegisterProperty('POPUPMENU', 'TPOPUPMENU', iptRW);
with Cl.FindClass('TForm') do
begin
RegisterProperty('POPUPMENU', 'TPOPUPMENU', iptRW);
end;
RegisterMethod('Constructor CREATE( AOWNER : TCOMPONENT)');
RegisterMethod('Procedure POPUP( X, Y : INTEGER)');
RegisterProperty('POPUPCOMPONENT', 'TCOMPONENT', iptrw);
RegisterProperty('ALIGNMENT', 'TPOPUPALIGNMENT', iptrw);
RegisterProperty('AUTOPOPUP', 'BOOLEAN', iptrw);
RegisterProperty('HELPCONTEXT', 'THELPCONTEXT', iptrw);
RegisterProperty('MENUANIMATION', 'TMENUANIMATION', iptrw);
RegisterProperty('TRACKBUTTON', 'TTRACKBUTTON', iptrw);
RegisterProperty('ONPOPUP', 'TNOTIFYEVENT', iptrw);
end;
end;
procedure SIRegisterTMAINMENU(CL: TPSPascalCompiler);
begin
With cl.AddClassN(Cl.FindClass('TMENU'),'TMAINMENU') do
begin
RegisterMethod('Procedure MERGE( MENU : TMAINMENU)');
RegisterMethod('Procedure UNMERGE( MENU : TMAINMENU)');
RegisterMethod('Procedure POPULATEOLE2MENU( SHAREDMENU : HMENU; GROUPS : array of INTEGER; var WIDTHS : array of LONGINT)');
RegisterMethod('Procedure GETOLE2ACCELERATORTABLE( var ACCELTABLE : HACCEL; var ACCELCOUNT : INTEGER; GROUPS : array of INTEGER)');
RegisterMethod('Procedure SETOLE2MENUHANDLE( HANDLE : HMENU)');
RegisterProperty('AUTOMERGE', 'BOOLEAN', iptrw);
end;
end;
procedure SIRegisterTMENU(CL: TPSPascalCompiler);
begin
With cl.AddClassN(Cl.FindClass('TCOMPONENT'),'TMENU') do
begin
RegisterMethod('Constructor CREATE( AOWNER : TCOMPONENT)');
RegisterMethod('Function DISPATCHCOMMAND( ACOMMAND : WORD) : BOOLEAN');
RegisterMethod('Function DISPATCHPOPUP( AHANDLE : HMENU) : BOOLEAN');
RegisterMethod('Function FINDITEM( VALUE : INTEGER; KIND : TFINDITEMKIND) : TMENUITEM');
RegisterMethod('Function GETHELPCONTEXT( VALUE : INTEGER; BYCOMMAND : BOOLEAN) : THELPCONTEXT');
RegisterProperty('IMAGES', 'TCUSTOMIMAGELIST', iptrw);
RegisterMethod('Function ISRIGHTTOLEFT : BOOLEAN');
RegisterMethod('Procedure PARENTBIDIMODECHANGED( ACONTROL : TOBJECT)');
RegisterMethod('Procedure PROCESSMENUCHAR( var MESSAGE : TWMMENUCHAR)');
RegisterProperty('AUTOHOTKEYS', 'TMENUAUTOFLAG', iptrw);
RegisterProperty('AUTOLINEREDUCTION', 'TMENUAUTOFLAG', iptrw);
RegisterProperty('BIDIMODE', 'TBIDIMODE', iptrw);
RegisterProperty('HANDLE', 'HMENU', iptr);
RegisterProperty('OWNERDRAW', 'BOOLEAN', iptrw);
RegisterProperty('PARENTBIDIMODE', 'BOOLEAN', iptrw);
RegisterProperty('WINDOWHANDLE', 'HWND', iptrw);
RegisterProperty('ITEMS', 'TMENUITEM', iptr);
end;
end;
procedure SIRegisterTMENUITEM(CL: TPSPascalCompiler);
begin
With cl.AddClassN(Cl.FindClass('TCOMPONENT'),'TMENUITEM') do
begin
RegisterMethod('Constructor CREATE( AOWNER : TCOMPONENT)');
RegisterMethod('Procedure INITIATEACTION');
RegisterMethod('Procedure INSERT( INDEX : INTEGER; ITEM : TMENUITEM)');
RegisterMethod('Procedure DELETE( INDEX : INTEGER)');
RegisterMethod('Procedure CLEAR');
RegisterMethod('Procedure CLICK');
RegisterMethod('Function FIND( ACAPTION : String) : TMENUITEM');
RegisterMethod('Function INDEXOF( ITEM : TMENUITEM) : INTEGER');
RegisterMethod('Function ISLINE : BOOLEAN');
RegisterMethod('Function GETIMAGELIST : TCUSTOMIMAGELIST');
RegisterMethod('Function GETPARENTCOMPONENT : TCOMPONENT');
RegisterMethod('Function GETPARENTMENU : TMENU');
RegisterMethod('Function HASPARENT : BOOLEAN');
RegisterMethod('Function NEWTOPLINE : INTEGER');
RegisterMethod('Function NEWBOTTOMLINE : INTEGER');
RegisterMethod('Function INSERTNEWLINEBEFORE( AITEM : TMENUITEM) : INTEGER');
RegisterMethod('Function INSERTNEWLINEAFTER( AITEM : TMENUITEM) : INTEGER');
RegisterMethod('Procedure ADD( ITEM : TMENUITEM)');
RegisterMethod('Procedure REMOVE( ITEM : TMENUITEM)');
RegisterMethod('Function RETHINKHOTKEYS : BOOLEAN');
RegisterMethod('Function RETHINKLINES : BOOLEAN');
RegisterProperty('COMMAND', 'WORD', iptr);
RegisterProperty('HANDLE', 'HMENU', iptr);
RegisterProperty('COUNT', 'INTEGER', iptr);
RegisterProperty('ITEMS', 'TMENUITEM INTEGER', iptr);
RegisterProperty('MENUINDEX', 'INTEGER', iptrw);
RegisterProperty('PARENT', 'TMENUITEM', iptr);
{$IFDEF DELPHI5UP}
RegisterProperty('ACTION', 'TBASICACTION', iptrw);
{$ENDIF}
RegisterProperty('AUTOHOTKEYS', 'TMENUITEMAUTOFLAG', iptrw);
RegisterProperty('AUTOLINEREDUCTION', 'TMENUITEMAUTOFLAG', iptrw);
RegisterProperty('BITMAP', 'TBITMAP', iptrw);
RegisterProperty('CAPTION', 'String', iptrw);
RegisterProperty('CHECKED', 'BOOLEAN', iptrw);
RegisterProperty('SUBMENUIMAGES', 'TCUSTOMIMAGELIST', iptrw);
RegisterProperty('DEFAULT', 'BOOLEAN', iptrw);
RegisterProperty('ENABLED', 'BOOLEAN', iptrw);
RegisterProperty('GROUPINDEX', 'BYTE', iptrw);
RegisterProperty('HELPCONTEXT', 'THELPCONTEXT', iptrw);
RegisterProperty('HINT', 'String', iptrw);
RegisterProperty('IMAGEINDEX', 'TIMAGEINDEX', iptrw);
RegisterProperty('RADIOITEM', 'BOOLEAN', iptrw);
RegisterProperty('SHORTCUT', 'TSHORTCUT', iptrw);
RegisterProperty('VISIBLE', 'BOOLEAN', iptrw);
RegisterProperty('ONCLICK', 'TNOTIFYEVENT', iptrw);
{$IFNDEF FPC} RegisterProperty('ONDRAWITEM', 'TMENUDRAWITEMEVENT', iptrw);
RegisterProperty('ONADVANCEDDRAWITEM', 'TADVANCEDMENUDRAWITEMEVENT', iptrw);
RegisterProperty('ONMEASUREITEM', 'TMENUMEASUREITEMEVENT', iptrw);{$ENDIF}
end;
end;
procedure SIRegister_Menus(Cl: TPSPascalCompiler);
begin
Cl.AddTypeS('HMenu', 'Cardinal');
Cl.AddTypeS('HACCEL', 'Cardinal');
cl.addClassN(cl.FindClass('EXCEPTION'),'EMENUERROR');
Cl.addTypeS('TMENUBREAK', '( MBNONE, MBBREAK, MBBARBREAK )');
{$IFNDEF FPC}
Cl.addTypeS('TMENUDRAWITEMEVENT', 'Procedure ( SENDER : TOBJECT; ACANVAS : TC'
+'ANVAS; ARECT : TRECT; SELECTED : BOOLEAN)');
Cl.addTypeS('TADVANCEDMENUDRAWITEMEVENT', 'Procedure ( SENDER : TOBJECT; ACAN'
+'VAS : TCANVAS; ARECT : TRECT; STATE : TOWNERDRAWSTATE)');
Cl.addTypeS('TMENUMEASUREITEMEVENT', 'Procedure ( SENDER : TOBJECT; ACANVAS :'
+' TCANVAS; var WIDTH, HEIGHT : INTEGER)');
{$ENDIF}
Cl.addTypeS('TMENUITEMAUTOFLAG', '( MAAUTOMATIC, MAMANUAL, MAPARENT )');
Cl.AddTypeS('TMenuAutoFlag', 'TMENUITEMAUTOFLAG');
Cl.addTypeS('TSHORTCUT', 'WORD');
cl.addClassN(cl.FindClass('TACTIONLINK'),'TMENUACTIONLINK');
SIRegisterTMENUITEM(Cl);
Cl.addTypeS('TMENUCHANGEEVENT', 'Procedure ( SENDER : TOBJECT; SOURCE : TMENU'
+'ITEM; REBUILD : BOOLEAN)');
Cl.addTypeS('TFINDITEMKIND', '( FKCOMMAND, FKHANDLE, FKSHORTCUT )');
SIRegisterTMENU(Cl);
SIRegisterTMAINMENU(Cl);
Cl.addTypeS('TPOPUPALIGNMENT', '( PALEFT, PARIGHT, PACENTER )');
Cl.addTypeS('TTRACKBUTTON', '( TBRIGHTBUTTON, TBLEFTBUTTON )');
Cl.addTypeS('TMENUANIMATIONS', '( MALEFTTORIGHT, MARIGHTTOLEFT, MATOPTOBOTTOM'
+', MABOTTOMTOTOP, MANONE )');
Cl.addTypeS('TMENUANIMATION', 'set of TMENUANIMATIONS');
SIRegisterTPOPUPMENU(Cl);
SIRegisterTPOPUPLIST(Cl);
SIRegisterTMENUITEMSTACK(Cl);
Cl.addTypeS('TCMENUITEM', 'TMENUITEM');
{$IFNDEF FPC}
//TODO: it should work,but somehow TShiftState is not defined
Cl.AddDelphiFunction('Function SHORTCUT( KEY : WORD; SHIFT : TSHIFTSTATE) : T'
+'SHORTCUT');
Cl.AddDelphiFunction('Procedure SHORTCUTTOKEY( SHORTCUT : TSHORTCUT; var KEY '
+': WORD; var SHIFT : TSHIFTSTATE)');
{$ENDIF}
Cl.AddDelphiFunction('Function SHORTCUTTOTEXT( SHORTCUT : TSHORTCUT) : String'
+'');
Cl.AddDelphiFunction('Function TEXTTOSHORTCUT( TEXT : String) : TSHORTCUT');
Cl.AddDelphiFunction('Function NEWMENU( OWNER : TCOMPONENT; const ANAME : STR'
+'ING; ITEMS : array of TMenuItem) : TMAINMENU');
Cl.AddDelphiFunction('Function NEWPOPUPMENU( OWNER : TCOMPONENT; const ANAME '
+': String; ALIGNMENT : TPOPUPALIGNMENT; AUTOPOPUP : BOOLEAN; const ITEMS : array of '
+'TCMENUITEM) : TPOPUPMENU');
Cl.AddDelphiFunction('Function NEWSUBMENU( const ACAPTION : String; HCTX : WO'
+'RD; const ANAME : String; ITEMS : array of TMenuItem; AENABLED : BOOLEAN) : TMENUITEM');
Cl.AddDelphiFunction('Function NEWITEM( const ACAPTION : String; ASHORTCUT : '
+'TSHORTCUT; ACHECKED, AENABLED : BOOLEAN; AONCLICK : TNOTIFYEVENT; HCTX : W'
+'ORD; const ANAME : String) : TMENUITEM');
Cl.AddDelphiFunction('Function NEWLINE : TMENUITEM');
{$IFNDEF FPC}
Cl.AddDelphiFunction('Procedure DRAWMENUITEM( MENUITEM : TMENUITEM; ACANVAS :'
+' TCANVAS; ARECT : TRECT; STATE : TOWNERDRAWSTATE)');
{$ENDIF}
end;
end.