Add GNU LGPL headers to all .c .C and .h files
[oweals/cde.git] / cde / programs / dtinfo / dtinfo / wwl / src / WXmMenu.C
1 /*
2  * CDE - Common Desktop Environment
3  *
4  * Copyright (c) 1993-2012, The Open Group. All rights reserved.
5  *
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)
10  * any later version.
11  *
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
16  * details.
17  *
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
22  */
23 /* $XConsortium: WXmMenu.cc /main/3 1996/06/11 17:03:45 cde-hal $ */
24
25 #ifndef STREAMH
26 #include <stream.h>
27 #endif
28
29 #ifndef _WXmMenu_h
30 #include <WWL/WXmMenu.h>
31 #endif
32
33 // The class WXmPopupMenu encapsulates a standard Motif popup menu.
34
35 WXmPopupMenu::WXmPopupMenu (WComposite& father, char* name, ArgList args,
36                             Cardinal card)
37 : WXmRowColumn (XmCreatePopupMenu (Widget(father), name, args, card))
38 {
39 #ifdef STUPID
40    if (name != NULL) {
41        WXmLabelGadget label(widget, "title");
42        label.LabelString(name);
43    }
44 #endif
45 }
46
47 WXmPopupMenu::WXmPopupMenu (WComposite& father, char* name, WArgList args)
48 : WXmRowColumn (XmCreatePopupMenu (Widget(father), name, args.Args(),
49                                    args.NumArgs()))
50 {
51 #ifdef STUPID
52    if (name != NULL) {
53        WXmLabelGadget label(widget, "title");
54        label.LabelString(name);
55    }
56 #endif
57 }
58
59 WXmPopupMenu::WXmPopupMenu (WComposite& father, char* name, int automanage,
60                             WArgList args)
61 : WXmRowColumn (XmCreatePopupMenu (Widget(father), name, args.Args(),
62                                    args.NumArgs()))
63 {
64    automanage = 1;
65 #ifdef STUPID
66    if (name != NULL) {
67        WXmLabelGadget label(widget, "title");
68        label.LabelString(name);
69    }
70 #endif
71    Manage();
72 }
73
74 /*?
75 Adds a push button to the popup menu and associates a callback function
76 to this button if the \var{proc} is not NULL. An arglist can be passed
77 to initialize some resources.
78 ?*/
79 WXmPushButtonGadget
80 WXmPopupMenu :: AddPushButton (char* name, XtCallbackProc proc, caddr_t closure, ArgList args, Cardinal card)
81 {
82         WXmPushButtonGadget pb(widget, name, args, card);
83
84         if (proc)
85                 pb.AddActivateCallback(proc, closure);
86
87         return pb;
88 }
89
90
91 /*?
92 Adds a push button to the popup menu and associates a callback method
93 to this button. The method is called with the object \var{wwl}. An
94 arglist can be passed to initialize some resources.
95 ?*/
96 WXmPushButtonGadget
97 WXmPopupMenu :: AddPushButton (char* name, WWL* wwl, WWL_FUN fun, ArgList args, Cardinal card)
98 {
99         WXmPushButtonGadget pb(widget, name, args, card);
100
101         pb.SetActivateCallback(wwl, fun);
102
103         return pb;
104 }
105   
106 /*?class WXmPulldownMenu
107
108 The class \typ{WXmPulldownMenu} encapsulates a standard Motif pulldown menu.
109 ?*/
110
111
112 /*?
113 Adds a push button to the pulldown menu and associates a callback function
114 to this button if the \var{proc} is not NULL. An arglist can be passed
115 to initialize some resources.
116 ?*/
117 WXmPushButtonGadget
118 WXmPulldownMenu :: AddPushButton (char* name, XtCallbackProc proc, caddr_t closure, ArgList args, Cardinal card)
119 {
120         WXmPushButtonGadget pb(widget, name, args, card);
121
122         if (proc)
123                 pb.AddActivateCallback(proc, closure);
124
125         return pb;
126 }
127
128
129 /*?
130 Adds a push button to the pulldown menu and associates a callback method
131 to this button. The method is called with the object \var{wwl}. An
132 arglist can be passed to initialize some resources.
133 ?*/
134 WXmPushButtonGadget
135 WXmPulldownMenu :: AddPushButton (char* name, WWL* wwl, WWL_FUN fun, ArgList args, Cardinal card)
136 {
137         WXmPushButtonGadget pb(widget, name, args, card);
138
139         pb.SetActivateCallback(wwl, fun);
140
141         return pb;
142 }
143
144 /*?class WXmOptionMenu
145
146 The class \typ{WXmOptionMenu} encapsulates a standard Motif option menu.
147 ?*/
148
149 WXmOptionMenu :: WXmOptionMenu(
150                                 WComposite& father, 
151                                 char* name)
152 : WXmRowColumn (XmCreateOptionMenu(Widget(father), name, NULL, 0))
153 {
154    WXmPulldownMenu pd(father, name); // create the pulldown
155    SubMenuId(pd);  // Set the subMenuId to the new pulldown
156 }
157
158
159 /*
160 WXmOptionMenu :: AddPulldownMenu (
161 WComposite&      parent,
162 char*           name )
163 { // 15mar92 need to add pulldown to option menu
164    WXmPulldownMenu pd(parent, name); // create the pulldown
165    SubMenuId(pd);  // Set the subMenuId to the new pulldown
166    return pd;
167 } // Add a pulldown to the option menu
168 */
169
170 /*?
171 Adds a push button to the option menu and associates a callback function
172 to this button if the \var{proc} is not NULL. An arglist can be passed
173 to initialize some resources.
174 ?*/
175 WXmPushButtonGadget
176 WXmOptionMenu :: AddPushButton (
177 char*           name,
178 XtCallbackProc  proc,
179 caddr_t         closure,
180 ArgList         args,
181 Cardinal        card)
182 { // 15mar92 modified to add PushButton to pulldown of option menu
183    WXmPushButtonGadget pb(SubMenuId(), name, args, card);
184
185    if (proc) {
186       pb.AddActivateCallback(proc, closure);
187    }
188
189    return pb;
190 }
191
192
193 /*?
194 Adds a push button to the option menu and associates a callback method
195 to this button. The method is called with the object \var{wwl}. An
196 arglist can be passed to initialize some resources.
197 ?*/
198 WXmPushButtonGadget
199 WXmOptionMenu :: AddPushButton (
200 char*           name,
201 WWL*            wwl,
202 WWL_FUN         fun,
203 ArgList         args,
204 Cardinal        card)
205 { // 15mar92 modified to add PushButton to pulldown of option menu
206
207    WXmPushButtonGadget pb(SubMenuId(), name, args, card);
208
209    pb.SetActivateCallback(wwl, fun);
210
211    return pb;
212 }
213
214 /*?
215 Returns the cascade button gadget associated with the option menu.
216 ?*/
217 WXmCascadeButtonGadget
218 WXmOptionMenu :: OptionButtonGadget ()
219 {
220    WXmCascadeButtonGadget cb(XmOptionButtonGadget(widget));
221
222    return cb;
223 }
224
225 /*?
226 Returns the label gadget associated with the option menu.
227 ?*/
228 WXmLabelGadget
229 WXmOptionMenu :: OptionLabelGadget ()
230 {
231    WXmLabelGadget cb(XmOptionLabelGadget(widget));
232
233    return cb;
234 }
235
236 /*?class WXmMenuBar
237
238 This class encapsulates a standard menu bar.
239 ?*/
240
241
242 /*?
243 Adds a cascade button to the menu bar. A mnemonic character can also
244 be added.
245 ?*/
246 WXmCascadeButton
247 WXmMenuBar :: AddCascadeButton (char* name, char mnemonic)
248 {
249         WXmCascadeButton cb(widget, name);
250         if (mnemonic) {
251                 cb.Mnemonic(mnemonic);
252         }
253         return cb;
254 }
255
256 #ifdef DOC
257 /*?
258 Add a cascade menu to the menu bar.
259 ?*/
260 void
261 WXmMenuBar :: AddCascadeMenu (char* name, char mnemonic, WXmPulldownMenu& menu)
262 {
263 }
264
265 #endif
266
267