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 libraries and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
23 /* Copyright (c) 1994,1995,1996 FUJITSU LIMITED */
24 /* All Rights Reserved */
27 * $XConsortium: MarkChooser.cc /main/8 1996/06/14 14:10:02 cde-hal $
29 * Copyright (c) 1993 HAL Computer Systems International, Ltd.
30 * All rights reserved. Unpublished -- rights reserved under
31 * the Copyright Laws of the United States. USE OF A COPYRIGHT
32 * NOTICE IS PRECAUTIONARY ONLY AND DOES NOT IMPLY PUBLICATION
35 * THIS SOFTWARE CONTAINS CONFIDENTIAL INFORMATION AND TRADE
36 * SECRETS OF HAL COMPUTER SYSTEMS INTERNATIONAL, LTD. USE,
37 * DISCLOSURE, OR REPRODUCTION IS PROHIBITED WITHOUT THE
38 * PRIOR EXPRESS WRITTEN PERMISSION OF HAL COMPUTER SYSTEMS
41 * RESTRICTED RIGHTS LEGEND
42 * Use, duplication, or disclosure by the Government is subject
43 * to the restrictions as set forth in subparagraph (c)(l)(ii)
44 * of the Rights in Technical Data and Computer Software clause
45 * at DFARS 252.227-7013.
47 * HAL COMPUTER SYSTEMS INTERNATIONAL, LTD.
56 #define C_WindowSystem
69 #include "Managers/CatMgr.hh"
70 #include "Other/XmStringLocalized.hh"
72 #include "Registration.hh"
74 #define CLASS MarkChooser
75 #include "create_macros.hh"
77 #include <WWL/WXmDialogShell.h>
78 #include <WWL/WXmSeparator.h>
80 // /////////////////////////////////////////////////////////////////
82 // /////////////////////////////////////////////////////////////////
84 MarkChooser::MarkChooser (Widget parent, xList<MarkCanvas *> &marks,
85 const char *title_key, const char *ok_key)
86 : f_selected_item (-1),
90 create_ui (parent, title_key, ok_key);
95 MarkChooser::~MarkChooser()
99 have to remove the callbacks first, otherwise the
100 XtDestroyWidget() call will remove the callbacks from
101 the widgets, then our destructor will have memory violations
102 trying to remove them again - brad
105 XtDestroyWidget (XtParent (f_form));
109 // /////////////////////////////////////////////////////////////////
110 // create_ui - create the user interface
111 // /////////////////////////////////////////////////////////////////
114 MarkChooser::create_ui (Widget parent,
115 const char *title_key, const char *ok_key)
117 XmStringLocalized mtfstring;
119 WXmDialogShell shell (parent, True, "mark_chooser");
120 window_system().register_full_modal_shell (&shell);
122 ASSN (WXmForm, f_form, shell, "form");
123 ASSNM (WXmPushButton, f_ok, f_form, "ok");
124 DECLM (WXmPushButton, cancel, f_form, "cancel");
126 // do not provide help on full-modal window - 10/27/94 kamiya
127 DECLM (WXmPushButton, help, f_form, "help");
129 DECLM (WXmSeparator, sep, f_form, "separator");
131 Widget list = XmCreateScrolledList (f_form, (char*)"list", NULL, 0);
132 f_list = WXmList (list);
135 XtVaSetValues(f_form, XmNdialogTitle, (XmString)XmStringLocalized((char*)title_key), NULL);
136 XtVaSetValues(f_ok, XmNlabelString, (XmString)XmStringLocalized((char*)ok_key), NULL);
138 mtfstring = CATGETS(Set_AgentLabel, 162, "Cancel");
139 XtVaSetValues(cancel, XmNlabelString, (XmString)mtfstring, NULL);
141 SET_CALLBACK (f_list,SingleSelection,select);
142 SET_CALLBACK (f_list,BrowseSelection,select);
143 SET_CALLBACK (f_list,DefaultAction,ok);
144 ON_ACTIVATE (f_ok,ok);
145 ON_ACTIVATE (cancel,cancel);
147 // do not provide help on full-modal window - 10/27/94 kamiya
148 help_agent().add_activate_help (help, "mark_chooser");
151 f_form.DefaultButton (f_ok);
152 f_form.ShadowThickness (0);
155 // Set the min size based on the current size.
157 shell.MinWidth (shell.Width());
158 shell.MinHeight (shell.Height());
162 // /////////////////////////////////////////////////////////////////
163 // update_list - fill in the list with mark items
164 // /////////////////////////////////////////////////////////////////
167 MarkChooser::update_list()
169 int length = f_mark_list->length();
170 ON_DEBUG (printf ("Chooser list length = %d\n", length));
171 XmStringTable table = new XmString [length];
173 List_Iterator<MarkCanvas *> m (f_mark_list);
178 Xassert (i < length);
179 table[i] = XmStringCreateLocalized((String)m.item()->mark_ptr()->name());
182 Xassert (i == length);
184 f_list.Set (WArgList (XmNitemCount, (XtArgVal) i,
188 for (i = 0; i < length; i++)
189 XmStringFree (table[i]);
194 // /////////////////////////////////////////////////////////////////
195 // get_choice - return the user's choice from the list
196 // /////////////////////////////////////////////////////////////////
198 extern int g_blew_away_marks_too_bad_you_lose_dts_14590;
201 MarkChooser::get_choice()
203 g_blew_away_marks_too_bad_you_lose_dts_14590 = 0 ;
208 XtAppContext app_context = window_system().app_context();
213 XtAppNextEvent (app_context, &event);
214 XtDispatchEvent (&event);
217 if (g_blew_away_marks_too_bad_you_lose_dts_14590)
219 ON_DEBUG(cerr << "blew away marks" << endl);
223 if (f_selected_item > 0)
225 List_Iterator<MarkCanvas *> m (f_mark_list);
227 while (i < f_selected_item)
237 // /////////////////////////////////////////////////////////////////
238 // select - process a list item selection
239 // /////////////////////////////////////////////////////////////////
242 MarkChooser::select (WCallback *wcb)
244 CALL_DATA (XmListCallbackStruct, lcs);
246 f_ok.SetSensitive (True);
247 f_selected_item = lcs->item_position;
251 // /////////////////////////////////////////////////////////////////
252 // ok, cancel, help - other callbacks
253 // /////////////////////////////////////////////////////////////////
263 MarkChooser::cancel()
265 f_selected_item = -1;