2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
6 * These libraries and programs are free software; you can
7 * redistribute them and/or modify them under the terms of the GNU
8 * Lesser General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
12 * These libraries and programs are distributed in the hope that
13 * they will be useful, but WITHOUT ANY WARRANTY; without even the
14 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU Lesser General Public License for more
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these librararies and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
24 * $XConsortium: NodeListAgentMotif.C /main/8 1996/10/15 17:37:13 cde-hal $
26 * Copyright (c) 1991 HaL Computer Systems, Inc. All rights reserved.
27 * UNPUBLISHED -- rights reserved under the Copyright Laws of the United
28 * States. Use of a copyright notice is precautionary only and does not
29 * imply publication or disclosure.
31 * This software contains confidential information and trade secrets of HaL
32 * Computer Systems, Inc. Use, disclosure, or reproduction is prohibited
33 * without the prior express written permission of HaL Computer Systems, Inc.
35 * RESTRICTED RIGHTS LEGEND
36 * Use, duplication, or disclosure by the Government is subject to
37 * restrictions as set forth in subparagraph (c)(l)(ii) of the Rights in
38 * Technical Data and Computer Software clause at DFARS 252.227-7013.
39 * HaL Computer Systems, Inc.
40 * 1315 Dell Avenue, Campbell, CA 95008
47 #define C_NodeListAgent
53 #include "Other/XmStringLocalized.hh"
54 #include "Managers/CatMgr.hh"
58 #include "Registration.hh"
60 #include <WWL/WTopLevelShell.h>
61 #include <WWL/WXmMenu.h>
62 #include <WWL/WXmFrame.h>
63 #include <WWL/WXmTextField.h>
64 #include <WWL/WXmForm.h>
65 #include <WWL/WXmPushButton.h>
66 #include <WWL/WXmSeparator.h>
67 #include <WWL/WXmLabel.h>
68 #include <WWL/WXmList.h>
69 #include <WWL/WXmPanedWindow.h>
71 Cardinal NodeListAgent::f_pane_insert_position = 0;
73 // /////////////////////////////////////////////////////////////////
75 // /////////////////////////////////////////////////////////////////
77 NodeListAgent::~NodeListAgent()
79 // NOTE: Maybe this variable should be in the agent!
80 delete f_wm_delete_callback;
81 // NOTE: How about deleting the widget hierarchy!! djb
85 // /////////////////////////////////////////////////////////////////
86 // init - let's get started
87 // /////////////////////////////////////////////////////////////////
98 // /////////////////////////////////////////////////////////////////
100 // /////////////////////////////////////////////////////////////////
103 NodeListAgent::display()
111 /* -------- Create Motif ui if necessary. -------- */
112 Xassert (f_shell != NULL);
113 // Call to create_window should be in subclass
116 f_shell->DeIconify();
117 setStatus (eSuccess);
120 // /////////////////////////////////////////////////////////////////
121 // create_base_window
122 // /////////////////////////////////////////////////////////////////
124 /* This should be called from subclasses create_window method. */
127 NodeListAgent::create_base_window (char *name)
129 f_shell = new WTopLevelShell (toplevel(), WPopup, name);
130 window_system().register_shell (f_shell);
131 #define AM WAutoManage
132 //Widget Class Var Name Parent Widget Name
133 //------------------ --------------- ---------------- ----------------
134 f_form = new WXmForm (*f_shell, "form");
135 f_menu_bar = new WXmMenuBar (*f_form, "menu_bar" /* , WAutoManage */);
137 WXmCascadeButton file_cascade (*f_menu_bar, "file", AM);
138 WXmPulldownMenu file_menu (*f_menu_bar, "file_menu" );
139 WXmPushButton close (file_menu, "close", AM);
140 WXmCascadeButton edit_cascade (*f_menu_bar, "edit", AM);
141 WXmPulldownMenu edit_menu (*f_menu_bar, "edit_menu" );
142 WXmPushButton undo (edit_menu, "undo", AM);
144 WXmCascadeButton view_cascade (*f_menu_bar, "view", AM);
145 WXmPulldownMenu view_menu (*f_menu_bar, "view_menu" );
146 WXmCascadeButton sort_cascade (view_menu, "sort", AM);
147 WXmPulldownMenu sort_menu (*f_menu_bar, "sort_menu" );
148 WXmPushButton ooo (sort_menu, "ooo", AM);
151 WXmCascadeButton help_cascade (*f_menu_bar, "help", AM);
152 WXmPulldownMenu help_menu (*f_menu_bar, "help_menu" );
153 WXmPushButton context (help_menu, "context", AM);
154 WXmPushButton window (help_menu, "window", AM);
156 XmStringLocalized mtfstring;
158 f_display = WXmPushButton (*f_form, "display", AM);
159 f_help = WXmPushButton (*f_form, "help", AM);
160 WXmPushButton closeb (*f_form, "close", AM);
162 mtfstring = CATGETS(Set_AgentLabel, 165, "Display");
163 XtVaSetValues((Widget)f_display, XmNlabelString, (XmString)mtfstring, NULL);
164 mtfstring = CATGETS(Set_AgentLabel, 12, "Close");
165 XtVaSetValues((Widget)closeb, XmNlabelString, (XmString)mtfstring, NULL);
166 mtfstring = CATGETS(Set_AgentLabel, 48, "Help");
167 XtVaSetValues((Widget)f_help, XmNlabelString, (XmString)mtfstring, NULL);
169 WXmSeparator separator (*f_form, "separator", AM);
171 f_pane = (WXmPanedWindow*)(Widget)WXmPanedWindow (*f_form, "pane");
172 f_pane->InsertPosition (&NodeListAgent::pane_insert_position);
174 f_list_form = (WXmForm*)(Widget)WXmForm(*f_pane, "listform", AM);
176 Widget scrolled_list = XmCreateScrolledList (*f_list_form, "list", NULL, 0);
178 f_list = (WXmList*)scrolled_list ;
181 XmFontList defaultList;
184 XtVaGetValues(scrolled_list, XmNfontList, &font, NULL);
185 defaultList = XmFontListCopy(font);
188 if (window_system().dtinfo_font())
189 defaultList = XmFontListAppendEntry(defaultList,
190 window_system().dtinfo_font());
191 if (window_system().dtinfo_space_font())
192 defaultList = XmFontListAppendEntry(defaultList,
193 window_system().dtinfo_space_font());
194 XtVaSetValues(scrolled_list, XmNfontList, defaultList, NULL);
198 // NOTE: error checking
200 /* -------- attach menus -------- */
201 file_cascade.SubMenuId (file_menu);
202 edit_cascade.SubMenuId (edit_menu);
203 help_cascade.SubMenuId (help_menu);
204 f_menu_bar->MenuHelpWidget (help_cascade);
206 close.SetActivateCallback (this, (WWL_FUN)&NodeListAgent::close_window);
207 closeb.SetActivateCallback (this, (WWL_FUN)&NodeListAgent::close_window);
208 f_wm_delete_callback =
209 new WCallback (*f_shell, window_system().WM_DELETE_WINDOW(),
210 this, (WWL_FUN) &NodeListAgent::close_window);
212 f_form->ShadowThickness (0); // gets rid of border turds
213 f_form->DefaultButton (f_display);
216 // /////////////////////////////////////////////////////////////////
218 // /////////////////////////////////////////////////////////////////
221 NodeListAgent::pane_insert_position (Widget w)
223 extern WidgetClass xmSashWidgetClass, xmSeparatorGadgetClass;
225 if (XtIsSubclass (w, xmSashWidgetClass) ||
226 XtIsSubclass (w, xmSeparatorGadgetClass))
228 WComposite cw (XtParent(w));
229 position = cw.NumChildren();
232 position = NodeListAgent::f_pane_insert_position;
234 /* Code can set this var to determine the insert position of widgets. */
236 // NodeListAgent::f_pane_insert_position = 0;
240 // /////////////////////////////////////////////////////////////////
242 // /////////////////////////////////////////////////////////////////
245 NodeListAgent::close_window (WCallback *)