4
** Example showing the basic usage of the menu system with a window.
5
** Menu layout is done with GadTools, as is recommended for applications.
10
Changed to use TAGS and pas2c.
13
Updated for systemvartags.
16
nils.sjoholm@mailbox.swipnet.se
19
uses Exec, Intuition, Utility, GadTools, systemvartags;
25
mynewmenu : array[0..15] of tNewMenu = (
26
(nm_Type: NM_TITLE; nm_Label:'Project'; nm_CommKey: NIL; nm_Flags:0;
27
nm_MutualExclude:0; nm_UserData:NIL),
28
(nm_Type: NM_ITEM; nm_Label:'Open...'; nm_CommKey:'O'; nm_Flags:0;
29
nm_MutualExclude:0; nm_UserData:NIL),
30
(nm_Type: NM_ITEM; nm_Label:'Save'; nm_CommKey:'S'; nm_Flags:0;
31
nm_MutualExclude:0; nm_UserData:NIL),
32
(nm_Type: NM_ITEM; nm_Label:nil; nm_CommKey: NIL; nm_Flags:0;
33
nm_MutualExclude:0; nm_UserData:NIL),
35
(nm_Type: NM_ITEM; nm_Label:'Print'; nm_CommKey: NIL; nm_Flags:0;
36
nm_MutualExclude:0; nm_UserData:NIL),
37
(nm_Type: NM_SUB; nm_Label:'Draft'; nm_CommKey: NIL; nm_Flags:0;
38
nm_MutualExclude:0; nm_UserData:NIL),
39
(nm_Type: NM_SUB; nm_Label:'NLQ'; nm_CommKey: NIL; nm_Flags:0;
40
nm_MutualExclude:0; nm_UserData:NIL),
41
(nm_Type: NM_ITEM; nm_Label:nil; nm_CommKey: NIL; nm_Flags:0;
42
nm_MutualExclude:0; nm_UserData:NIL),
44
(nm_Type: NM_ITEM; nm_Label:'Quit...'; nm_CommKey:'Q'; nm_Flags:0;
45
nm_MutualExclude:0; nm_UserData:NIL),
47
(nm_Type: NM_TITLE; nm_Label:'Edit'; nm_CommKey: NIL; nm_Flags:0;
48
nm_MutualExclude:0; nm_UserData:NIL),
49
(nm_Type: NM_ITEM; nm_Label:'Cut'; nm_CommKey:'X'; nm_Flags:0;
50
nm_MutualExclude:0; nm_UserData:NIL),
51
(nm_Type: NM_ITEM; nm_Label:'Copy'; nm_CommKey:'C'; nm_Flags:0;
52
nm_MutualExclude:0; nm_UserData:NIL),
53
(nm_Type: NM_ITEM; nm_Label:'Paste'; nm_CommKey:'V'; nm_Flags:0;
54
nm_MutualExclude:0; nm_UserData:NIL),
55
(nm_Type: NM_ITEM; nm_Label:nil; nm_CommKey: NIL; nm_Flags:0;
56
nm_MutualExclude:0; nm_UserData:NIL),
58
(nm_Type: NM_ITEM; nm_Label:'Undo'; nm_CommKey:'Z'; nm_Flags:0;
59
nm_MutualExclude:0; nm_UserData:NIL),
61
(nm_Type: NM_END; nm_Label:NIL; nm_CommKey:NIL; nm_Flags:0;
62
nm_MutualExclude:0; nm_UserData:NIL));
66
myVisualInfo : Pointer;
73
if assigned(MenuStrip) then begin
77
if assigned(myVisualInfo) then FreeVisualInfo(myVisualInfo);
78
if assigned(win) then CloseWindow(win);
86
** Watch the menus and wait for the user to select the close gadget
87
** or quit from the menus.
89
PROCEDURE ProcessIDCMP;
91
IMessage : tIntuiMessage;
94
Procedure ProcessMenu;
101
if IMessage.Code = MENUNULL then
104
MenuNumber := MenuNum(IMessage.Code);
105
ItemNumber := ItemNum(IMessage.Code);
106
SubItemNumber := SubNum(IMessage.Code);
108
if (MenuNumber = 0) and (ItemNumber = 5) then done := true;
112
IPtr := pIntuiMessage(Msg);
116
case IMessage.IClass of
117
IDCMP_MENUPICK : ProcessMenu;
118
IDCMP_CLOSEWINDOW : done := True;
123
** Open all of the required libraries and set-up the menus.
128
win := OpenWindowTags(NIL, [
132
WA_CloseGadget, ltrue,
133
WA_Title, 'Menu Test Window',
134
WA_IDCMP, IDCMP_CLOSEWINDOW or IDCMP_MENUPICK,
137
if win = nil then die;
139
myVisualInfo := GetVisualInfoA(win^.WScreen,nil);
140
if myVisualInfo = nil then die;
145
mynewmenu[3].nm_Label := PChar(NM_BARLABEL);
146
mynewmenu[7].nm_Label := PChar(NM_BARLABEL);
147
mynewmenu[13].nm_Label := PChar(NM_BARLABEL);
149
if pExecBase(_ExecBase)^.LibNode.Lib_Version >= 39 then begin
150
MenuStrip := CreateMenus(@mynewmenu, [
153
end else MenuStrip := CreateMenusA(@mynewmenu,NIL);
155
if menuStrip = nil then die;
157
if not LayoutMenusA(menuStrip, myVisualInfo,nil) then die;
159
if not SetMenuStrip(win,menuStrip) then die;
162
Msg := WaitPort(win^.UserPort);
163
Msg := GetMsg(win^.UserPort);
171
Revision 1.3 2003/01/19 14:57:12 nils
172
* removed mode objfpc
174
Revision 1.2 2002/11/28 19:40:45 nils