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: TCanvas; ARect: TRect; Selected: Boolean)');
Cl.addTypeS('TAdvancedMenuDrawItemEvent', 'procedure (Sender: TObject; ACanvas: 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: TMenuItem; 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): TShortCut');
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: string; 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: Word; 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: Word; 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.
|