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
23 /* Copyright (c) 1995,1996 FUJITSU LIMITED */
24 /* All Rights Reserved */
27 * $XConsortium: ListViewMotif.C /main/9 1996/10/15 17:35:55 cde-hal $
29 * Copyright (c) 1992 HaL Computer Systems, Inc. All rights reserved.
30 * UNPUBLISHED -- rights reserved under the Copyright Laws of the United
31 * States. Use of a copyright notice is precautionary only and does not
32 * imply publication or disclosure.
34 * This software contains confidential information and trade secrets of HaL
35 * Computer Systems, Inc. Use, disclosure, or reproduction is prohibited
36 * without the prior express written permission of HaL Computer Systems, Inc.
38 * RESTRICTED RIGHTS LEGEND
39 * Use, duplication, or disclosure by the Government is subject to
40 * restrictions as set forth in subparagraph (c)(l)(ii) of the Rights in
41 * Technical Data and Computer Software clause at DFARS 252.227-7013.
42 * HaL Computer Systems, Inc.
43 * 1315 Dell Avenue, Campbell, CA 95008
47 #include <WWL/WTopLevelShell.h>
48 #include <WWL/WXmPushButton.h>
49 #include <WWL/WXmList.h>
50 #include <WWL/WXmForm.h>
51 #include <WWL/WXmLabelGadget.h>
52 #include <WWL/WXmSeparator.h>
56 #define C_WindowSystem
70 #include "Other/XmStringLocalized.hh"
71 #include "Managers/CatMgr.hh"
73 #include "Registration.hh"
75 // /////////////////////////////////////////////////////////////////
77 // /////////////////////////////////////////////////////////////////
86 delete f_wm_delete_callback;
91 // /////////////////////////////////////////////////////////////////
92 // list - set/get the list
93 // /////////////////////////////////////////////////////////////////
96 ListView::list (List *list)
98 if (f_the_list != NULL)
100 RemoveDependent ((notify_handler_t) &ListView::list_changed,
103 f_the_list->AddDependent ((notify_handler_t) &ListView::list_changed,
114 // /////////////////////////////////////////////////////////////////
115 // display - display it on the screen
116 // /////////////////////////////////////////////////////////////////
128 f_shell->DeIconify();
132 // /////////////////////////////////////////////////////////////////
134 // /////////////////////////////////////////////////////////////////
137 ListView::create_ui_objects()
139 /* -------- Create ui components. -------- */
140 f_shell = new WTopLevelShell (toplevel(), WPopup, f_name);
141 window_system().register_shell (f_shell);
142 WXmForm form (*f_shell, "form");
144 /* -------- allow child to be creative -------- */
145 child_create_ui_pre(form);
148 WXmPushButton close (form, "close", WAutoManage);
149 WXmPushButton help (form, "help", WAutoManage);
151 XtVaSetValues(close, XmNlabelString,
152 (XmString)XmStringLocalized(CATGETS(Set_AgentLabel, 12, "Close")), NULL);
153 XtVaSetValues(help, XmNlabelString,
154 (XmString)XmStringLocalized(CATGETS(Set_AgentLabel, 48, "Help")), NULL);
156 // 7/30/93 rtp - bear with this hack, it's a little bogus
157 char *help_name = new char[strlen(f_name) + strlen("_help") + 1];
158 sprintf(help_name, "%s%s", f_name, "_help");
159 // What i've done is appended '_help' to the widget name and added
160 // a help callback to the help button that will reference this name
161 help_agent().add_activate_help (help, help_name);
163 f_activate = WXmPushButton (form, "activate", WAutoManage);
164 XtVaSetValues(f_activate, XmNlabelString,
165 (XmString)XmStringLocalized(CATGETS(Set_AgentLabel, 165, "Display")), NULL);
166 // WXmLabelGadget label (form, "label", WAutoManage);
167 WXmSeparator separator (form, "separator", WAutoManage);
168 // NOTE: Fix WWL to have a scrolled list object!
169 Widget scrolled_list = XmCreateScrolledList (form, (char*)"list", NULL, 0);
170 f_list = new WXmList (scrolled_list);
173 XmFontList defaultList;
176 XtVaGetValues(scrolled_list, XmNfontList, &font, NULL);
177 defaultList = XmFontListCopy(font);
179 if (window_system().dtinfo_space_font())
180 defaultList = XmFontListAppendEntry(defaultList,
181 window_system().dtinfo_space_font());
182 XtVaSetValues(scrolled_list, XmNfontList, defaultList, NULL);
184 /* -------- let child add anything else -------- */
185 child_create_ui_post(form);
187 /* -------- Callbacks -------- */
188 f_wm_delete_callback =
189 new WCallback (*f_shell, window_system().WM_DELETE_WINDOW(),
190 this, (WWL_FUN) &ListView::close_window);
191 close.SetActivateCallback (this, (WWL_FUN) &ListView::close_window);
192 f_list->SetSingleSelectionCallback (this, (WWL_FUN) &ListView::select);
193 f_list->SetBrowseSelectionCallback (this, (WWL_FUN) &ListView::select);
194 f_list->SetDefaultActionCallback (this, (WWL_FUN) &ListView::activate);
195 f_activate.SetActivateCallback (this, (WWL_FUN) &ListView::activate);
197 /* -------- Finalize -------- */
198 form.DefaultButton (f_activate);
199 form.ShadowThickness (0); // get rid of border turds (motif bug)
204 // /////////////////////////////////////////////////////////////////
205 // display_list - put the list in the Motif list widget
206 // /////////////////////////////////////////////////////////////////
209 ListView::display_list()
211 // NOTE: What does it mean to display a NULL list? 6/22/92 djb
212 if (f_shell == NULL || f_the_list == NULL)
217 // NOTE: There should be a wwl object for string tables!! 6/19/92 djb
218 XmStringTable st = (XmStringTable)
219 malloc (sizeof (XmStringTable) * f_the_list->length());
221 for (i = 0; i < f_the_list->length(); i++)
222 st[i] = display_value((*f_the_list)[i]);
224 // Basically bogus, but best fix for now. 18:32 10-May-94 DJB
225 f_list->DeselectAllItems();
227 f_list->Items (st, args);
228 f_list->ItemCount (f_the_list->length(), args);
231 for (i = 0; i < f_the_list->length(); i++)
238 // /////////////////////////////////////////////////////////////////
240 // /////////////////////////////////////////////////////////////////
243 ListView::select (WCallback *wcb)
245 XmListCallbackStruct *lcs = (XmListCallbackStruct *) wcb->CallData();
247 f_activate.SetSensitive (True);
248 f_selected_item = lcs->item_position - 1;
252 // /////////////////////////////////////////////////////////////////
254 // /////////////////////////////////////////////////////////////////
257 ListView::activate (WCallback *)
259 notify (ENTRY_ACTIVATE, (void *)(size_t) f_selected_item);
263 // /////////////////////////////////////////////////////////////////
265 // /////////////////////////////////////////////////////////////////
268 ListView::close_window (WCallback *)
274 // /////////////////////////////////////////////////////////////////
275 // list_changed - the list was altered somehow
276 // /////////////////////////////////////////////////////////////////
279 ListView::list_changed (FolioObject *, u_int, void *, void *)
281 // NOTE: simplistic for now 6/23/92 djb
286 ListView::display_value(FolioObject *object)
288 return XmStringCreateLocalized((char*)object->display_as());
292 ListView::child_create_ui_pre(WXmForm &)
294 /* -------- empty -------- */
298 ListView::child_create_ui_post(WXmForm &)
300 /* -------- empty -------- */