1
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2
/* ***** BEGIN LICENSE BLOCK *****
3
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
5
* The contents of this file are subject to the Netscape Public License
6
* Version 1.1 (the "License"); you may not use this file except in
7
* compliance with the License. You may obtain a copy of the License at
8
* http://www.mozilla.org/NPL/
10
* Software distributed under the License is distributed on an "AS IS" basis,
11
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12
* for the specific language governing rights and limitations under the
15
* The Original Code is mozilla.org code.
17
* The Initial Developer of the Original Code is
18
* Netscape Communications Corporation.
19
* Portions created by the Initial Developer are Copyright (C) 1998
20
* the Initial Developer. All Rights Reserved.
24
* Alternatively, the contents of this file may be used under the terms of
25
* either the GNU General Public License Version 2 or later (the "GPL"), or
26
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27
* in which case the provisions of the GPL or the LGPL are applicable instead
28
* of those above. If you wish to allow use of your version of this file only
29
* under the terms of either the GPL or the LGPL, and not to allow others to
30
* use your version of this file under the terms of the NPL, indicate your
31
* decision by deleting the provisions above and replace them with the notice
32
* and other provisions required by the GPL or the LGPL. If you do not delete
33
* the provisions above, a recipient may use your version of this file under
34
* the terms of any one of the NPL, the GPL or the LGPL.
36
* ***** END LICENSE BLOCK ***** */
40
#include "nsBrowserWindow.h"
41
#include "resources.h"
47
int MenuItemActivate (PtWidget_t *widget, void *command, PtCallbackInfo_t *cbinfo)
52
PtWidget_t *nativeWindow = PtGetParent( widget, PtWindow );
56
PtSetArg( &arg, Pt_ARG_USER_DATA, &data, 0 );
57
if( PtGetResources( nativeWindow, 1, &arg ) == 0 )
61
nsIWidget *xpWindow = (nsIWidget *) *data;
62
nsBrowserWindow* bw = nsBrowserWindow::FindBrowserFor( xpWindow, FIND_WINDOW );
66
bw->DispatchMenuItem( (int) command );
76
int TopLevelMenuItemArm (PtWidget_t *widget, void *Menu, PtCallbackInfo_t *cbinfo)
78
// printf("TopLevelMenuItemArm Menu=<%p>\n", Menu);
80
PtPositionMenu ( (PtWidget_t *) Menu, NULL);
81
PtRealizeWidget( (PtWidget_t *) Menu);
84
PtWidget_t *CreateTopLevelMenu(PtWidget_t *aParent, char *Label)
87
PtWidget_t *menu, *menubutton;
89
PtSetArg(&arg[0], Pt_ARG_BUTTON_TYPE, Pt_MENU_DOWN, 0);
90
PtSetArg(&arg[1], Pt_ARG_TEXT_STRING, Label, 0);
91
menubutton = PtCreateWidget(PtMenuButton, aParent, 2, arg);
93
/* Now Create the Photon Menu that is attached to the mMenuButton */
94
PtSetArg(&arg[0], Pt_ARG_MENU_FLAGS, Pt_MENU_AUTO, 0xFFFFFFFF);
95
menu = PtCreateWidget (PtMenu, menubutton, 1, arg);
97
/* Set the Call back on this top level menu button */
98
PtAddCallback(menubutton, Pt_CB_ARM, TopLevelMenuItemArm, menu);
100
PtRealizeWidget(menubutton);
102
// printf("CreateTopLevelMenu: Label=<%s> menubutton=<%p> menu=<%p>\n", Label, menubutton, menu);
107
PtWidget_t *CreateSubMenu(PtWidget_t *aParent, char *Label)
110
PtWidget_t *menu, *menubutton;
112
PtSetArg(&arg[0], Pt_ARG_BUTTON_TYPE, Pt_MENU_RIGHT, 0);
113
PtSetArg(&arg[1], Pt_ARG_TEXT_STRING, Label, 0);
114
menubutton = PtCreateWidget(PtMenuButton, aParent, 2, arg);
116
PtSetArg(&arg[0], Pt_ARG_MENU_FLAGS, Pt_MENU_CHILD | Pt_MENU_AUTO, 0xFFFFFFFF);
117
menu = PtCreateWidget (PtMenu, menubutton, 1, arg);
122
PtWidget_t *CreateMenuItem(PtWidget_t *aParent, char *Label, int command)
125
PtWidget_t *menuitem;
127
//printf("CreateMenuItem: aParent=<%p>, Label=<%s> command=<%d>\n", aParent, Label, command);
129
PtSetArg ( &arg[0], Pt_ARG_BUTTON_TYPE, Pt_MENU_TEXT, 0);
130
PtSetArg ( &arg[1], Pt_ARG_USER_DATA, &command, sizeof(void *) );
133
PtSetArg ( &arg[2], Pt_ARG_SEP_TYPE, Pt_ETCHED_IN, 0);
134
menuitem = PtCreateWidget (PtSeparator, aParent, 3, arg);
138
PtSetArg ( &arg[2], Pt_ARG_TEXT_STRING, Label, 0);
139
menuitem = PtCreateWidget (PtMenuButton, aParent, 3, arg);
140
PtAddCallback(menuitem, Pt_CB_ACTIVATE, MenuItemActivate , (void *) command);
146
void CreateViewerMenus(PtWidget_t *menubar, void *data)
149
PtWidget_t *menu, *submenu, *submenu2;
151
//printf("Entering CreateViewerMenus menubar=<%p>\n", menubar);
153
menu = CreateTopLevelMenu(menubar, "File");
154
CreateMenuItem(menu, "New Window",VIEWER_WINDOW_OPEN);
155
CreateMenuItem(menu, "Open",VIEWER_FILE_OPEN);
156
CreateMenuItem(menu, "View Source",VIEW_SOURCE);
158
submenu=CreateSubMenu(menu, "Samples");
165
struct MenuList_s DemoList[18] =
167
{"#0 Basic Styles", VIEWER_DEMO0},
168
{"#1 CSS Styles", VIEWER_DEMO1},
169
{"#2 Images", VIEWER_DEMO2},
170
{"#3 Basic Tables", VIEWER_DEMO3},
171
{"#4 Sample Tables", VIEWER_DEMO4},
172
{"#5 More Styles", VIEWER_DEMO5},
173
{"#6 Deeply Nested Tables", VIEWER_DEMO6},
174
{"#7 Scaled Anim Image", VIEWER_DEMO7},
175
{"#8 Form", VIEWER_DEMO8},
176
{"#9 Frames", VIEWER_DEMO9},
177
{"#10 Anim Images", VIEWER_DEMO10},
178
{"#11 Fixed Positioning", VIEWER_DEMO11},
179
{"#12 More Fixed Pos", VIEWER_DEMO12},
180
{"#13 DHTML", VIEWER_DEMO13},
181
{"#14 XML Sorting", VIEWER_DEMO14},
182
{"#15 XML IRS", VIEWER_DEMO15},
183
{"#16 Gfx Widgets", VIEWER_DEMO16},
184
{"#17 <Empty>", VIEWER_DEMO17}
187
for(int i=0; i<=17; i++)
189
CreateMenuItem(submenu, DemoList[i].Label,DemoList[i].Command);
192
CreateMenuItem(menu, "Test Sites", VIEWER_TOP100);
193
submenu=CreateSubMenu(menu, "XPToolkit Tests");
194
CreateMenuItem(submenu, "Toolbar Test 1", VIEWER_XPTOOLKITTOOLBAR1);
195
CreateMenuItem(submenu, "Tree Test 2", VIEWER_XPTOOLKITTREE1);
196
CreateMenuItem(menu, NULL, 0);
197
CreateMenuItem(menu, "Print Preview", VIEWER_ONE_COLUMN);
198
CreateMenuItem(menu, "Print", VIEWER_PRINT);
199
CreateMenuItem(menu, "Print Setup", VIEWER_PRINT_SETUP);
200
CreateMenuItem(menu, NULL, 0);
201
CreateMenuItem(menu, "Exit", VIEWER_EXIT);
203
menu = CreateTopLevelMenu(menubar, "Edit");
204
CreateMenuItem(menu, "Cut", VIEWER_EDIT_CUT);
205
CreateMenuItem(menu, "Copy", VIEWER_EDIT_COPY);
206
CreateMenuItem(menu, "Paste", VIEWER_EDIT_PASTE);
207
CreateMenuItem(menu, NULL, 0);
208
CreateMenuItem(menu, "Select All", VIEWER_EDIT_SELECTALL);
209
CreateMenuItem(menu, NULL, 0);
210
CreateMenuItem(menu, "Find in Page", VIEWER_EDIT_FINDINPAGE);
213
menu = CreateTopLevelMenu(menubar, "Debug");
214
CreateMenuItem(menu, "Visual Debugging", VIEWER_VISUAL_DEBUGGING);
215
CreateMenuItem(menu, NULL, 0);
216
submenu=CreateSubMenu(menu, "Event Debugging");
217
CreateMenuItem(submenu, "Toggle Paint Flashing", VIEWER_TOGGLE_PAINT_FLASHING);
218
CreateMenuItem(submenu, "Toggle Paint Dumpinging", VIEWER_TOGGLE_PAINT_DUMPING);
219
CreateMenuItem(submenu, "Toggle Invalidate Dumping", VIEWER_TOGGLE_INVALIDATE_DUMPING);
220
CreateMenuItem(submenu, "Toggle Event Dumping", VIEWER_TOGGLE_EVENT_DUMPING);
221
CreateMenuItem(submenu, NULL, 0);
222
CreateMenuItem(submenu, "Toggle Motion Event Dumping", VIEWER_TOGGLE_MOTION_EVENT_DUMPING);
223
CreateMenuItem(submenu, "Toggle Crossing Event Dumpinging", VIEWER_TOGGLE_CROSSING_EVENT_DUMPING);
224
CreateMenuItem(menu, NULL, 0);
225
CreateMenuItem(menu, "Reflow Test", VIEWER_REFLOW_TEST);
226
CreateMenuItem(menu, NULL, 0);
227
CreateMenuItem(menu, "Dump Content", VIEWER_DUMP_CONTENT);
228
CreateMenuItem(menu, "Dump Frames", VIEWER_DUMP_FRAMES);
229
CreateMenuItem(menu, "Dump Views", VIEWER_DUMP_VIEWS);
230
CreateMenuItem(menu, NULL, 0);
231
CreateMenuItem(menu, "Dump Style Sheets", VIEWER_DUMP_STYLE_SHEETS);
232
CreateMenuItem(menu, "Dump Style Contexts", VIEWER_DUMP_STYLE_CONTEXTS);
233
CreateMenuItem(menu, NULL, 0);
234
CreateMenuItem(menu, "Debug Save", VIEWER_DEBUGSAVE);
235
CreateMenuItem(menu, "Debug Output Text", VIEWER_DISPLAYTEXT);
236
CreateMenuItem(menu, "Debug Output HTML", VIEWER_DISPLAYHTML);
237
CreateMenuItem(menu, "Debug Toggle Selection", VIEWER_TOGGLE_SELECTION);
238
CreateMenuItem(menu, NULL, 0);
239
CreateMenuItem(menu, "Debug Robot", VIEWER_DEBUGROBOT);
240
CreateMenuItem(menu, NULL, 0);
241
submenu=CreateSubMenu(menu, "Style");
242
submenu2=CreateSubMenu(submenu, "Select Style Sheet");
243
CreateMenuItem(submenu2, "List Available Sheets", VIEWER_SELECT_STYLE_LIST);
244
CreateMenuItem(submenu2, NULL, 0);
245
CreateMenuItem(submenu2, "Select Default", VIEWER_SELECT_STYLE_DEFAULT);
246
CreateMenuItem(submenu2, NULL, 0);
247
CreateMenuItem(submenu2, "Select Alternative 1", VIEWER_SELECT_STYLE_ONE);
248
CreateMenuItem(submenu2, "Select Alternative 2", VIEWER_SELECT_STYLE_TWO);
249
CreateMenuItem(submenu2, "Select Alternative 3", VIEWER_SELECT_STYLE_THREE);
250
CreateMenuItem(submenu2, "Select Alternative 4", VIEWER_SELECT_STYLE_FOUR);
251
submenu2=CreateSubMenu(submenu, "Compatibility Mode");
252
CreateMenuItem(submenu2, "Use DTD", VIEWER_USE_DTD_MODE);
253
CreateMenuItem(submenu2, "Nav Quirks", VIEWER_NAV_QUIRKS_MODE);
254
CreateMenuItem(submenu2, "Standard", VIEWER_STANDARD_MODE);
255
submenu2=CreateSubMenu(submenu, "Widget Render Mode");
256
CreateMenuItem(submenu2, "Native", VIEWER_NATIVE_WIDGET_MODE);
257
CreateMenuItem(submenu2, "Gfx", VIEWER_GFX_WIDGET_MODE);
260
menu = CreateTopLevelMenu(menubar, "Tools");
261
CreateMenuItem(menu, "JavaScript Console", JS_CONSOLE);
262
CreateMenuItem(menu, "Editor Mode", EDITOR_MODE);