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 /* $XConsortium: UI.c /main/7 1996/11/07 16:35:08 rswiston $ */
24 /*****************************************************************************
30 * Description: This file contains the user interface creation and
31 * processing code for the CDE front panel
33 * (c) Copyright 1993, 1994 Hewlett-Packard Company
34 * (c) Copyright 1993, 1994 International Business Machines Corp.
35 * (c) Copyright 1993, 1994 Sun Microsystems, Inc.
36 * (c) Copyright 1993, 1994 Novell, Inc.
38 ****************************************************************************/
42 #include <Dt/DbReader.h>
45 #include <Dt/Control.h>
47 #include <Dt/ControlP.h>
48 #include <Dt/IconFile.h>
51 #include <Dt/GetDispRes.h>
54 #include <Xm/ToggleBG.h>
55 #include <Xm/MwmUtil.h>
56 #include <Xm/AtomMgr.h>
57 #include <Xm/DrawingA.h>
58 #include <Xm/RowColumn.h>
59 #include <Xm/SeparatoG.h>
60 #include <Xm/DialogS.h>
61 #include <Xm/ColorObjP.h>
64 #include <X11/Xatom.h>
65 #include <X11/keysymdef.h>
69 #define MWM_NEED_TIME16
73 #include "DataBaseLoad.h"
74 #include "PopupMenu.h"
79 /************************************************************************
81 * External and static function declarations.
83 ************************************************************************/
86 extern void PushCB (Widget, XtPointer, XtPointer);
87 extern void ArrowCB (Widget, XtPointer, XtPointer);
88 extern XtTranslations HandleInputTranslations (void);
89 extern void HandleInputCB (Widget, XtPointer, XtPointer);
90 extern void MinimizeInputCB (Widget, XtPointer, XtPointer);
91 extern void MenuInputCB (Widget, XtPointer, XtPointer);
92 extern void SwitchButtonCB (Widget, XtPointer, XtPointer);
93 extern void SubpanelUnmapCB (Widget, XtPointer, XtPointer);
94 extern void SubpanelTornEventHandler (Widget, XtPointer, XEvent *, Boolean *);
95 extern void PushRecallRegister (ControlData *, Boolean);
96 extern void EmbeddedClientRegister (ControlData *, Boolean);
97 extern void EmbeddedClientReposition (Widget, Position, Dimension);
98 extern void DropCB (Widget, XtPointer, XtPointer);
99 extern void TransferDropCB (Widget, XtPointer, XtPointer);
100 extern void CustomizeDropCB (Widget, XtPointer, XtPointer);
101 extern void CustomizeTransferDropCB (Widget, XtPointer, XtPointer);
102 extern void FrontPanelCreate (Widget);
103 extern void EmbeddedClientReparent (char *, Widget);
104 extern void DeleteControlActionList (ControlData *);
105 extern Boolean CheckOtherMonitorsOn (SubpanelData *);
107 static void Initialize (DtPanelShellWidget);
108 static void BoxCreate ();
109 static Widget PanelControlCreate (Widget, char *, String);
110 static void MainControlCreate (int);
111 static void SwitchCreate (BoxData *);
112 static void SubpanelCreate (ControlData *, SubpanelData *);
113 static void ControlCreate (Widget, ControlData **, int);
114 static void ArrowCreate (Widget, ControlData **, int, Boolean, Boolean);
115 static void SetupPushAnimation(ControlData *);
116 static void SetupDropAnimation(ControlData *);
118 void SubpanelControlCreate (SubpanelData *, ControlData *, ControlData *,
119 Widget, Boolean, Boolean);
120 void SwitchButtonCreate (SwitchData *, Boolean);
121 void DeleteSubpanelControl (SubpanelData *, ControlData *);
125 static char DTFP_CLASS_NAME[] = "Frontpanel";
126 static char DTFP_APP_NAME[] = "frontpanel";
128 static XtCallbackRec dropCB[] = { {DropCB, NULL}, {NULL, NULL} };
129 static XtCallbackRec transferDropCB[] = { {TransferDropCB, NULL},{NULL, NULL} };
130 static XtCallbackRec customizeDropCB[] = { {CustomizeDropCB, NULL}, {NULL, NULL} };
131 static XtCallbackRec customizeTransferDropCB[] = { {CustomizeTransferDropCB, NULL},{NULL, NULL} };
134 /************************************************************************
136 * File local globals.
138 ************************************************************************/
140 String post_arrow_image = NULL;
141 String unpost_arrow_image = NULL;
142 String post_monitor_arrow_image = NULL;
143 String unpost_monitor_arrow_image = NULL;
144 String blank_arrow_image = NULL;
145 String dropzone_image = NULL;
146 String indicator_on_image = NULL;
147 String indicator_off_image = NULL;
148 String minimize_normal_image = NULL;
149 String minimize_selected_image = NULL;
150 String menu_normal_image = NULL;
151 String menu_selected_image = NULL;
152 String handle_image = NULL;
154 Pixmap minimize_normal_pixmap;
155 Pixmap minimize_selected_pixmap;
156 Pixmap menu_normal_pixmap;
157 Pixmap menu_selected_pixmap;
159 #define HARD_CODED_PRIMARY 3
160 #define _WS_HIGH_COLOR_COUNT 4
162 static int _ws_high_color_map[] = { 3, 5, 6, 7 };
163 static Dimension switch_height = 0;
165 /************************************************************************
169 ************************************************************************/
172 FrontPanelCreate (Widget toplevel)
176 DtPanelShellWidget panel_shell;
177 char * panel_name = (char *) panel.element_values[PANEL_NAME].parsed_value;
178 unsigned int display_height;
184 display_height = DisplayHeight (XtDisplay (toplevel),
185 DefaultScreen (XtDisplay (toplevel)));
187 /* Create panel shell. */
190 XtSetArg (al[ac], XmNallowShellResize, True); ac++;
191 XtSetArg (al[ac], XmNiconY, display_height); ac++;
192 XtSetArg (al[ac], XmNmwmDecorations, MWM_DECOR_BORDER); ac++;
193 panel.shell = XtCreatePopupShell (panel_name, dtPanelShellWidgetClass,
196 panel_shell = (DtPanelShellWidget) panel.shell;
199 /* Initialize the general data into the panel structure */
201 Initialize (panel_shell);
204 /* Set pixel resources. */
207 XtSetArg (al[ac], XmNforeground, panel.inactive_pixel_set->fg); ac++;
208 XtSetArg (al[ac], XmNbackground, panel.inactive_pixel_set->bg); ac++;
209 XtSetArg (al[ac], XmNtopShadowColor, panel.inactive_pixel_set->ts); ac++;
210 XtSetArg (al[ac], XmNbottomShadowColor, panel.inactive_pixel_set->bs); ac++;
211 XtSetArg (al[ac], XmNselectColor, panel.inactive_pixel_set->sc); ac++;
214 /* Remove all of the tab groups */
216 XtSetArg (al[ac], XmNnavigationType, XmNONE); ac++;
218 /* Create the outer form widget that will contain the entire panel */
220 panel.form = XmCreateForm (panel.shell, panel_name, al, ac);
221 XtManageChild (panel.form);
223 /* Create the handles, menu and iconify */
225 if ((Boolean) panel.element_values[PANEL_DISPLAY_HANDLES].parsed_value)
227 XtTranslations handle_translations = HandleInputTranslations();
229 panel.left_handle = PanelControlCreate (panel.form, "handle", handle_image);
230 panel.right_handle = PanelControlCreate (panel.form, "handle", handle_image);
232 XtOverrideTranslations(panel.left_handle, handle_translations);
233 XtAddCallback (panel.left_handle, XmNinputCallback,
234 (XtCallbackProc) HandleInputCB, NULL);
235 XtAddCallback (panel.left_handle, XmNhelpCallback,
236 (XtCallbackProc) GeneralTopicHelpCB, PANEL_HANDLE);
238 XtOverrideTranslations(panel.right_handle, handle_translations);
239 XtAddCallback (panel.right_handle, XmNinputCallback,
240 (XtCallbackProc) HandleInputCB, NULL);
241 XtAddCallback (panel.right_handle, XmNhelpCallback,
242 (XtCallbackProc) GeneralTopicHelpCB, PANEL_HANDLE);
244 if ((Boolean) panel.element_values[PANEL_DISPLAY_MENU].parsed_value)
246 panel.menu = PanelControlCreate (panel.form, "menu", menu_normal_image);
248 XtAddCallback (panel.menu, XmNinputCallback,
249 (XtCallbackProc) MenuInputCB, NULL);
250 XtAddCallback (panel.menu, XmNhelpCallback,
251 (XtCallbackProc) GeneralTopicHelpCB, PANEL_MENU);
254 XtSetArg (al[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
255 XtSetArg (al[ac], XmNtopOffset, 1); ac++;
256 XtSetArg (al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
257 XtSetArg (al[ac], XmNleftOffset, 1); ac++;
258 if (panel.resolution == HIGH || panel.resolution == MEDIUM) {
259 XtSetArg (al[ac], XmNwidth, 21); ac++;
260 XtSetArg (al[ac], XmNheight, 15); ac++;
262 XtSetArg (al[ac], XmNwidth, 17); ac++;
263 XtSetArg (al[ac], XmNheight, 13); ac++;
265 XtSetValues (panel.menu, al, ac);
268 XtSetArg (al[ac], XmNtopAttachment, XmATTACH_WIDGET); ac++;
269 XtSetArg (al[ac], XmNtopWidget, panel.menu); ac++;
270 XtSetArg (al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
271 XtSetArg (al[ac], XmNleftOffset, 1); ac++;
272 XtSetArg (al[ac], XmNbottomAttachment, XmATTACH_FORM); ac++;
273 XtSetArg (al[ac], XmNbottomOffset, 1); ac++;
274 if (panel.resolution == HIGH || panel.resolution == MEDIUM) {
275 XtSetArg (al[ac], XmNwidth, 20); ac++;
277 XtSetArg (al[ac], XmNwidth, 16); ac++;
279 XtSetValues (panel.left_handle, al, ac);
286 XtSetArg (al[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
287 XtSetArg (al[ac], XmNtopOffset, 1); ac++;
288 XtSetArg (al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
289 XtSetArg (al[ac], XmNleftOffset, 1); ac++;
290 XtSetArg (al[ac], XmNbottomAttachment, XmATTACH_FORM); ac++;
291 XtSetArg (al[ac], XmNbottomOffset, 1); ac++;
292 if (panel.resolution == HIGH || panel.resolution == MEDIUM) {
293 XtSetArg (al[ac], XmNwidth, 20); ac++;
295 XtSetArg (al[ac], XmNwidth, 16); ac++;
297 XtSetValues (panel.left_handle, al, ac);
300 if ((Boolean) panel.element_values[PANEL_DISPLAY_MINIMIZE].parsed_value)
303 PanelControlCreate (panel.form, "minimize", minimize_normal_image);
305 XtAddCallback (panel.iconify, XmNinputCallback,
306 (XtCallbackProc) MinimizeInputCB, NULL);
307 XtAddCallback (panel.iconify, XmNhelpCallback,
308 (XtCallbackProc) GeneralTopicHelpCB, PANEL_ICONIFY);
311 XtSetArg (al[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
312 XtSetArg (al[ac], XmNtopOffset, 1); ac++;
313 XtSetArg (al[ac], XmNrightAttachment, XmATTACH_FORM); ac++;
314 XtSetArg (al[ac], XmNrightOffset, 1); ac++;
315 if (panel.resolution == HIGH || panel.resolution == MEDIUM) {
316 XtSetArg (al[ac], XmNwidth, 21); ac++;
317 XtSetArg (al[ac], XmNheight, 15); ac++;
319 XtSetArg (al[ac], XmNwidth, 17); ac++;
320 XtSetArg (al[ac], XmNheight, 13); ac++;
322 XtSetValues (panel.iconify, al, ac);
325 XtSetArg (al[ac], XmNtopAttachment, XmATTACH_WIDGET); ac++;
326 XtSetArg (al[ac], XmNtopWidget, panel.iconify); ac++;
327 XtSetArg (al[ac], XmNrightAttachment, XmATTACH_FORM); ac++;
328 XtSetArg (al[ac], XmNrightOffset, 1); ac++;
329 XtSetArg (al[ac], XmNbottomAttachment, XmATTACH_FORM); ac++;
330 XtSetArg (al[ac], XmNbottomOffset, 1); ac++;
331 if (panel.resolution == HIGH || panel.resolution == MEDIUM) {
332 XtSetArg (al[ac], XmNwidth, 20); ac++;
334 XtSetArg (al[ac], XmNwidth, 16); ac++;
336 XtSetValues (panel.right_handle, al, ac);
340 panel.iconify = NULL;
343 XtSetArg (al[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
344 XtSetArg (al[ac], XmNtopOffset, 1); ac++;
345 XtSetArg (al[ac], XmNrightAttachment, XmATTACH_FORM); ac++;
346 XtSetArg (al[ac], XmNrightOffset, 1); ac++;
347 XtSetArg (al[ac], XmNbottomAttachment, XmATTACH_FORM); ac++;
348 XtSetArg (al[ac], XmNbottomOffset, 1); ac++;
349 if (panel.resolution == HIGH || panel.resolution == MEDIUM) {
350 XtSetArg (al[ac], XmNwidth, 20); ac++;
352 XtSetArg (al[ac], XmNwidth, 16); ac++;
354 XtSetValues (panel.right_handle, al, ac);
359 panel.left_handle = NULL;
360 panel.right_handle = NULL;
364 /* Create all of the boxes. This function, in turn, creates */
365 /* all of the controls, switch, subpanels. */
370 /* Manage the front panel to get it created and layed out */
372 XtSetMappedWhenManaged (panel.shell, False);
373 XtManageChild (panel.shell);
379 /************************************************************************
382 * Get all of the default data needed for the panel and put it into
383 * the panel structure.
385 ************************************************************************/
388 Initialize (DtPanelShellWidget panel_shell)
392 Screen * screen = XtScreen (panel_shell);
393 Display * display = XtDisplay (panel_shell);
396 Pixmap busy_pixmap_mask;
399 Pixel black_pixel = BlackPixelOfScreen (screen);
400 Pixel white_pixel = WhitePixelOfScreen (screen);
402 Boolean use_mask_return;
403 Boolean use_icon_file_cache_return;
405 short active, inactive, primary, secondary;
407 int color_use, resolution;
411 /* Create busy cursor. */
413 xcolors[0].pixel = black_pixel;
414 xcolors[1].pixel = white_pixel;
416 XQueryColors (display, DefaultColormapOfScreen (screen), xcolors, 2);
418 XCreateBitmapFromData (display, RootWindowOfScreen (screen),
419 (char *)time16_bits, time16_width, time16_height);
421 XCreateBitmapFromData (display, RootWindowOfScreen (screen),
422 (char *)time16m_bits, time16_width, time16_height);
425 XCreatePixmapCursor (display, busy_pixmap, busy_pixmap_mask,
426 &(xcolors[0]), &(xcolors[1]),
427 time16_x_hot, time16_y_hot);
429 XFreePixmap (display, busy_pixmap);
430 XFreePixmap (display, busy_pixmap_mask);
433 panel.resolution = (int) panel.element_values[PANEL_RESOLUTION].parsed_value;
435 /* Extract and validate resolution. */
437 if (panel.resolution == MATCH_DISPLAY ||
438 (panel.resolution != HIGH &&
439 panel.resolution != MEDIUM &&
440 panel.resolution != LOW))
443 _DtGetDisplayResolution (display, XScreenNumberOfScreen(screen));
447 case HIGH_RES_DISPLAY:
448 panel.resolution = HIGH;
451 case MED_RES_DISPLAY:
452 panel.resolution = MEDIUM;
455 case LOW_RES_DISPLAY:
457 panel.resolution = LOW;
462 if (panel.resolution == HIGH || panel.resolution == MEDIUM)
464 panel.main_icon_size = DtLARGE;
465 panel.sub_icon_size = DtMEDIUM;
466 panel.switch_icon_size = DtSMALL;
470 panel.main_icon_size = DtMEDIUM;
471 panel.sub_icon_size = DtTINY;
472 panel.switch_icon_size = DtTINY;
476 /* Set the font list based on the screen resolution */
478 switch(panel.resolution) {
480 panel.font_list = S_HighResFontList (panel_shell);
481 panel.date_font_list = S_MediumResFontList (panel_shell);
485 panel.font_list = S_MediumResFontList (panel_shell);
486 panel.date_font_list = S_MediumResFontList (panel_shell);
490 panel.font_list = S_LowResFontList (panel_shell);
491 panel.date_font_list = S_LowResFontList (panel_shell);
495 /* initialize popup_data to NULL */
496 panel.popup_data = NULL;
498 /* See if using bitonal or multicolor icons. If bitonal, set the */
499 /* pixel set to black and white based on the colors of the parent */
500 /* If color, use the color obj to get the color pixel set. */
502 XmeGetIconControlInfo (screen,
503 &use_mask_return, &panel.use_color_icons,
504 &use_icon_file_cache_return);
506 panel.pixel_set = (XmPixelSet *)
507 XtMalloc (sizeof(XmPixelSet) * XmCO_NUM_COLORS);
509 if (XmeGetPixelData (XScreenNumberOfScreen (screen),
510 &color_use, panel.pixel_set,
511 &active, &inactive, &primary, &secondary))
513 panel.color_use = color_use;
514 panel.active_pixel_set = &(panel.pixel_set[active]);
515 panel.inactive_pixel_set = &(panel.pixel_set[inactive]);
516 panel.primary_pixel_set = &(panel.pixel_set[primary]);
517 panel.secondary_pixel_set = &(panel.pixel_set[secondary]);
521 XtFree ((char *) panel.pixel_set);
523 panel.pixel_set = (XmPixelSet *) XtMalloc (sizeof (XmPixelSet));
524 panel.active_pixel_set = &(panel.pixel_set[0]);
525 panel.pixel_set_count = 1;
527 panel.active_pixel_set->bg = panel_shell->core.background_pixel;
529 if (panel.active_pixel_set->bg == black_pixel)
531 panel.active_pixel_set->fg = white_pixel;
532 panel.active_pixel_set->bg = black_pixel;
533 panel.active_pixel_set->ts = white_pixel;
534 panel.active_pixel_set->bs = white_pixel;
535 panel.active_pixel_set->sc = black_pixel;
536 panel.color_use = XmCO_BLACK_WHITE;
540 if (panel.active_pixel_set->bg == white_pixel)
542 panel.active_pixel_set->fg = black_pixel;
543 panel.active_pixel_set->bg = white_pixel;
544 panel.active_pixel_set->ts = black_pixel;
545 panel.active_pixel_set->bs = black_pixel;
546 panel.active_pixel_set->sc = white_pixel;
547 panel.color_use = XmCO_BLACK_WHITE;
551 /* Get the Motif defaults and assign into a single allocated */
552 /* pixel set which is then referenced throught the other 3 */
553 /* pixel set datas. */
555 XmGetColors (screen, DefaultColormapOfScreen (screen),
556 panel.active_pixel_set->bg,
557 &(panel.active_pixel_set->fg),
558 &(panel.active_pixel_set->ts),
559 &(panel.active_pixel_set->bs),
560 &(panel.active_pixel_set->sc));
562 panel.color_use = XmCO_LOW_COLOR;
566 panel.inactive_pixel_set = panel.active_pixel_set;
567 panel.primary_pixel_set = panel.active_pixel_set;
568 panel.secondary_pixel_set = panel.active_pixel_set;
572 /* Initialize other panel specific information */
574 panel.busy_light_data = NULL;
576 panel.push_recall_list = NULL;
577 panel.push_recall_count = 0;
578 panel.max_push_recall_count = 0;
580 panel.embedded_client_list = NULL;
581 panel.embedded_client_count = 0;
582 panel.max_embedded_client_count = 0;
584 panel.dynamic_data_list = NULL;
585 panel.dynamic_data_count = 0;
586 panel.max_dynamic_data_count = 0;
589 /* Get the names of the predefined images */
594 /* main panel icons */
595 size = panel.main_icon_size;
597 post_arrow_image = GetIconName (UP_ARROW_IMAGE_NAME, size);
598 unpost_arrow_image = GetIconName (DOWN_ARROW_IMAGE_NAME, size);
599 post_monitor_arrow_image = GetIconName (UP_MONITOR_ARROW_IMAGE_NAME, size);
600 unpost_monitor_arrow_image= GetIconName(DOWN_MONITOR_ARROW_IMAGE_NAME, size);
601 blank_arrow_image = GetIconName (BLANK_ARROW_IMAGE_NAME, size);
602 minimize_normal_image = GetIconName (MINIMIZE_NORMAL_IMAGE_NAME, size);
603 minimize_selected_image = GetIconName (MINIMIZE_SELECTED_IMAGE_NAME, size);
604 menu_normal_image = GetIconName (MENU_NORMAL_IMAGE_NAME, size);
605 menu_selected_image = GetIconName (MENU_SELECTED_IMAGE_NAME, size);
606 handle_image = GetIconName (HANDLE_IMAGE_NAME, DtLARGE);
609 size = panel.sub_icon_size;
611 indicator_off_image = GetIconName (INDICATOR_OFF_IMAGE_NAME, size);
612 indicator_on_image = GetIconName (INDICATOR_ON_IMAGE_NAME, size);
613 dropzone_image = GetIconName (DROPZONE_IMAGE_NAME, size);
619 /************************************************************************
622 * Create the handles, menu or iconify buttons attached to the panel.
624 ************************************************************************/
627 PanelControlCreate (Widget parent,
641 if (panel.color_use != XmCO_BLACK_WHITE)
643 /* Use background for color set matching.
644 * Use top shadow for clock hand color.
646 fg = panel.inactive_pixel_set->ts;
647 bg = panel.inactive_pixel_set->bg;
651 fg = BlackPixelOfScreen (XtScreen (panel.form));
652 bg = WhitePixelOfScreen (XtScreen (panel.form));
655 pixmap = XmGetPixmap (XtScreen (parent), image_name, fg, bg);
657 if (strcmp (control_name, "minimize") == 0)
659 minimize_normal_pixmap = pixmap;
660 minimize_selected_pixmap =
661 XmGetPixmap (XtScreen (parent), minimize_selected_image, fg, bg);
663 else if (strcmp (control_name, "menu") == 0)
665 menu_normal_pixmap = pixmap;
666 menu_selected_pixmap =
667 XmGetPixmap (XtScreen (parent), menu_selected_image, fg, bg);
672 XtSetArg (al[ac], XmNforeground, fg); ac++;
673 XtSetArg (al[ac], XmNbackground, bg); ac++;
674 XtSetArg (al[ac], XmNwidth, 11); ac++;
675 XtSetArg (al[ac], XmNshadowThickness, 0); ac++;
676 XtSetArg (al[ac], XmNborderWidth, 0); ac++;
677 XtSetArg (al[ac], XmNbackgroundPixmap, pixmap); ac++;
678 XtSetArg (al[ac], XmNtraversalOn, False); ac++;
679 XtSetArg (al[ac], XmNnavigationType, XmNONE); ac++;
682 w = XmCreateDrawingArea (parent, control_name, al, ac);
691 /************************************************************************
694 * Create all of the boxes defined within the panel data structure.
696 ************************************************************************/
705 BoxData * switch_box_data = NULL;
707 int switch_position = POSITION_FIRST;
715 /* Loop through the panels boxes, creating the set outer forms */
716 /* necessary to hold the inner forms for the controls, arrows... */
720 for (i = 0; i < panel.box_data_count; i++)
722 box_data = panel.box_data[i];
725 /* Create the outer box form which will contain the inner box set */
728 XtSetArg (al[ac], XmNshadowThickness, 0); ac++;
730 if (panel.left_handle != NULL)
732 XtSetArg (al[ac], XmNrightAttachment, XmATTACH_WIDGET); ac++;
733 XtSetArg (al[ac], XmNrightWidget, panel.right_handle); ac++;
734 XtSetArg (al[ac], XmNleftAttachment, XmATTACH_WIDGET); ac++;
735 XtSetArg (al[ac], XmNleftWidget, panel.left_handle); ac++;
739 XtSetArg (al[ac], XmNrightAttachment, XmATTACH_FORM); ac++;
740 XtSetArg (al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
743 if (prev_form != NULL)
745 XtSetArg (al[ac], XmNtopAttachment, XmATTACH_WIDGET); ac++;
746 XtSetArg (al[ac], XmNtopWidget, prev_form); ac++;
750 XtSetArg (al[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
751 XtSetArg (al[ac], XmNtopOffset, 1); ac++;
754 if (i == panel.box_data_count - 1)
756 XtSetArg (al[ac], XmNbottomAttachment, XmATTACH_FORM); ac++;
757 XtSetArg (al[ac], XmNbottomOffset, 1); ac++;
760 if (panel.color_use == XmCO_BLACK_WHITE)
762 XtSetArg (al[ac], XmNbottomShadowColor,
763 BlackPixelOfScreen (XtScreen (panel.shell))); ac++;
766 /* Remove all of the tab groups */
768 XtSetArg (al[ac], XmNnavigationType, XmNONE); ac++;
771 XtSetArg (al[ac], XmNbackground, panel.primary_pixel_set->bg); ac++;
772 XtSetArg (al[ac], XmNforeground, panel.primary_pixel_set->fg); ac++;
774 /* Create the outer form widget that will contain the entire panel */
777 XmCreateForm (panel.form,
778 (char *) box_data->element_values[BOX_NAME].parsed_value,
780 XtManageChild (box_data->form);
782 prev_form = box_data->form;
786 /* Loop through the panels boxes, creating the set of forms needed */
787 /* to contain the controls, arrows, or switch within the front panel */
789 for (i = 0; i < panel.box_data_count; i++)
791 box_data = panel.box_data[i];
793 if (box_data->switch_data != NULL)
795 switch_box_data = box_data;
798 XtSetArg (al[ac], XmNshadowThickness, 1); ac++;
799 XtSetArg (al[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
800 XtSetArg (al[ac], XmNtopOffset, 0); ac++;
801 XtSetArg (al[ac], XmNbottomAttachment, XmATTACH_FORM); ac++;
802 XtSetArg (al[ac], XmNbottomOffset, 0); ac++;
805 (int) box_data->switch_data->element_values[SWITCH_POSITION_HINTS].parsed_value;
808 /* Determine if the defined switch position is actually the */
809 /* first or last position. */
811 if (switch_position != POSITION_FIRST || switch_position != POSITION_LAST)
813 for (j = 0; j < box_data->control_data_count; j++)
815 if (switch_position < (int) ((box_data->control_data[j])->element_values[CONTROL_POSITION_HINTS].parsed_value))
820 switch_position = POSITION_FIRST;
821 else if (j == box_data->control_data_count)
822 switch_position = POSITION_LAST;
825 if (switch_position == POSITION_FIRST)
827 XtSetArg (al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
828 XtSetArg (al[ac], XmNleftOffset, 0); ac++;
831 if (switch_position == POSITION_LAST ||
832 box_data->control_data_count == 0)
834 XtSetArg (al[ac], XmNrightAttachment, XmATTACH_FORM); ac++;
835 XtSetArg (al[ac], XmNrightOffset, 0); ac++;
838 XtSetArg (al[ac], XmNuserData, SWITCH); ac++;
841 /* Remove all of the tab groups */
843 XtSetArg (al[ac], XmNnavigationType, XmNONE); ac++;
845 if (panel.color_use == XmCO_BLACK_WHITE)
847 XtSetArg (al[ac], XmNbottomShadowColor,
848 BlackPixelOfScreen (XtScreen (panel.form))); ac++;
850 pixmap = XmGetPixmap (XtScreen (panel.form), "50_foreground",
851 panel.inactive_pixel_set->fg,
852 panel.inactive_pixel_set->bg);
854 XtSetArg (al[ac], XmNbackgroundPixmap, pixmap); ac++;
857 XtSetArg (al[ac], XmNbackground, panel.primary_pixel_set->bg); ac++;
858 XtSetArg (al[ac], XmNforeground, panel.primary_pixel_set->fg); ac++;
860 box_data->switch_form =
861 XmCreateForm (box_data->form, "switch", al, ac);
862 XtManageChild (box_data->switch_form);
864 XtAddCallback (box_data->switch_form, XmNhelpCallback,
865 (XtCallbackProc) SwitchTopicHelpCB,
866 box_data->switch_data);
868 if (box_data->control_data_count == 0)
873 /* Create the arrow boxes */
875 if (box_data->switch_form != NULL)
877 if (switch_position == POSITION_FIRST)
880 XtSetArg (al[ac], XmNleftAttachment, XmATTACH_WIDGET); ac++;
881 XtSetArg (al[ac], XmNleftWidget, box_data->switch_form); ac++;
882 XtSetArg (al[ac], XmNleftOffset, -4); ac++;
883 XtSetArg (al[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
884 XtSetArg (al[ac], XmNtopOffset, 0); ac++;
885 XtSetArg (al[ac], XmNrightAttachment, XmATTACH_FORM); ac++;
886 XtSetArg (al[ac], XmNrightOffset, 0); ac++;
889 else if (switch_position == POSITION_LAST)
892 XtSetArg (al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
893 XtSetArg (al[ac], XmNleftOffset, 0); ac++;
894 XtSetArg (al[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
895 XtSetArg (al[ac], XmNtopOffset, 0); ac++;
896 XtSetArg (al[ac], XmNrightAttachment, XmATTACH_WIDGET); ac++;
897 XtSetArg (al[ac], XmNrightWidget, box_data->switch_form); ac++;
898 XtSetArg (al[ac], XmNrightOffset, 0); ac++;
904 XtSetArg (al[ac], XmNleftAttachment, XmATTACH_WIDGET); ac++;
905 XtSetArg (al[ac], XmNleftWidget, box_data->switch_form); ac++;
906 XtSetArg (al[ac], XmNleftOffset, -6); ac++;
907 XtSetArg (al[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
908 XtSetArg (al[ac], XmNtopOffset, 0); ac++;
909 XtSetArg (al[ac], XmNrightAttachment, XmATTACH_FORM); ac++;
910 XtSetArg (al[ac], XmNrightOffset, 0); ac++;
912 XtSetArg (al[ac], XmNbackground, panel.inactive_pixel_set->bg); ac++;
913 XtSetArg (al[ac], XmNforeground, panel.inactive_pixel_set->fg); ac++;
914 XtSetArg (al[ac], XmNtopShadowColor, panel.inactive_pixel_set->ts); ac++;
915 XtSetArg (al[ac], XmNselectColor, panel.inactive_pixel_set->sc); ac++;
917 if (panel.color_use == XmCO_BLACK_WHITE)
919 XtSetArg (al[ac], XmNbottomShadowColor,
920 BlackPixelOfScreen (XtScreen (panel.form))); ac++;
922 pixmap = XmGetPixmap (XtScreen (panel.form), "50_foreground",
923 panel.inactive_pixel_set->fg,
924 panel.inactive_pixel_set->bg);
926 XtSetArg (al[ac], XmNbackgroundPixmap, pixmap); ac++;
930 XtSetArg (al[ac], XmNbottomShadowColor,
931 panel.inactive_pixel_set->bs); ac++;
935 /* Remove all of the tab groups */
937 XtSetArg (al[ac], XmNnavigationType, XmNONE); ac++;
942 XtSetArg (al[ac], XmNshadowThickness, 0); ac++;
946 XtSetArg (al[ac], XmNshadowThickness, 1); ac++;
949 box_data->right_arrow_form =
950 XmCreateForm (box_data->form, "right_arrow_form", al, ac);
952 if (box_data->subpanel_count != 0)
953 XtManageChild (box_data->right_arrow_form);
955 XtAddCallback (box_data->right_arrow_form, XmNhelpCallback,
956 (XtCallbackProc) GeneralTopicHelpCB,
957 SUBPANEL_ACCESS_AREA);
960 XtSetArg (al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
961 XtSetArg (al[ac], XmNleftOffset, 0); ac++;
962 XtSetArg (al[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
963 XtSetArg (al[ac], XmNtopOffset, 0); ac++;
964 XtSetArg (al[ac], XmNrightAttachment, XmATTACH_FORM); ac++;
965 XtSetArg (al[ac], XmNrightOffset, -2); ac++;
971 XtSetArg (al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
972 XtSetArg (al[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
973 XtSetArg (al[ac], XmNrightAttachment, XmATTACH_FORM); ac++;
977 XtSetArg (al[ac], XmNtopOffset, 1); ac++;
978 XtSetArg (al[ac], XmNleftOffset, 1); ac++;
979 XtSetArg (al[ac], XmNrightOffset, 1); ac++;
983 XtSetArg (al[ac], XmNtopOffset, 0); ac++;
984 XtSetArg (al[ac], XmNleftOffset, 0); ac++;
985 XtSetArg (al[ac], XmNrightOffset, 0); ac++;
989 XtSetArg(al[ac], XmNbackground, panel.inactive_pixel_set->bg); ac++;
990 XtSetArg(al[ac], XmNforeground, panel.inactive_pixel_set->fg); ac++;
991 XtSetArg(al[ac], XmNtopShadowColor, panel.inactive_pixel_set->ts);ac++;
992 XtSetArg(al[ac], XmNselectColor, panel.inactive_pixel_set->sc); ac++;
994 if (panel.color_use == XmCO_BLACK_WHITE)
996 XtSetArg (al[ac], XmNbottomShadowColor,
997 BlackPixelOfScreen (XtScreen (panel.form))); ac++;
999 pixmap = XmGetPixmap (XtScreen (panel.form), "50_foreground",
1000 panel.inactive_pixel_set->fg,
1001 panel.inactive_pixel_set->bg);
1003 XtSetArg (al[ac], XmNbackgroundPixmap, pixmap); ac++;
1007 XtSetArg (al[ac], XmNbottomShadowColor,
1008 panel.inactive_pixel_set->bs); ac++;
1012 /* Remove all of the tab groups */
1014 XtSetArg (al[ac], XmNnavigationType, XmNONE); ac++;
1018 XtSetArg (al[ac], XmNshadowThickness, 0); ac++;
1022 XtSetArg (al[ac], XmNshadowThickness, 1); ac++;
1026 box_data->left_arrow_form =
1027 XmCreateForm (box_data->form, "left_arrow_form", al, ac);
1029 if (box_data->subpanel_count != 0)
1030 XtManageChild (box_data->left_arrow_form);
1032 XtAddCallback (box_data->left_arrow_form, XmNhelpCallback,
1033 (XtCallbackProc) GeneralTopicHelpCB,
1034 SUBPANEL_ACCESS_AREA);
1037 /* Now create the control boxes */
1039 if (box_data->switch_form != NULL)
1041 if (switch_position == POSITION_FIRST ||
1042 switch_position == POSITION_LAST)
1045 XtSetArg (al[ac], XmNshadowThickness, 1); ac++;
1047 if (switch_position == POSITION_FIRST)
1049 XtSetArg (al[ac], XmNleftAttachment, XmATTACH_WIDGET); ac++;
1050 XtSetArg (al[ac], XmNleftWidget, box_data->switch_form); ac++;
1051 XtSetArg (al[ac], XmNleftOffset, -4); ac++;
1052 XtSetArg (al[ac], XmNrightAttachment, XmATTACH_FORM); ac++;
1053 XtSetArg (al[ac], XmNrightOffset, 0); ac++;
1057 XtSetArg (al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
1058 XtSetArg (al[ac], XmNleftOffset, 0); ac++;
1059 XtSetArg (al[ac], XmNrightAttachment, XmATTACH_WIDGET); ac++;
1060 XtSetArg (al[ac], XmNrightWidget, box_data->switch_form); ac++;
1061 XtSetArg (al[ac], XmNrightOffset, 0); ac++;
1064 if (XtIsManaged(box_data->left_arrow_form))
1066 XtSetArg (al[ac], XmNtopAttachment, XmATTACH_WIDGET); ac++;
1067 XtSetArg (al[ac], XmNtopWidget, box_data->left_arrow_form); ac++;
1071 XtSetArg (al[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
1072 XtSetArg (al[ac], XmNtopOffset, 0); ac++;
1075 XtSetArg (al[ac], XmNbottomAttachment, XmATTACH_FORM); ac++;
1076 XtSetArg (al[ac], XmNbottomOffset, 0); ac++;
1078 XtSetArg (al[ac], XmNuserData, CONTROL); ac++;
1081 /* Remove all of the tab groups */
1083 XtSetArg (al[ac], XmNnavigationType, XmNONE); ac++;
1085 if (panel.color_use == XmCO_BLACK_WHITE)
1087 pixmap = XmGetPixmap (XtScreen (panel.form), "50_foreground",
1088 panel.inactive_pixel_set->fg,
1089 panel.inactive_pixel_set->bg);
1091 XtSetArg (al[ac], XmNbackgroundPixmap, pixmap); ac++;
1094 XtSetArg (al[ac], XmNbackground, panel.primary_pixel_set->bg); ac++;
1095 XtSetArg (al[ac], XmNforeground, panel.primary_pixel_set->fg); ac++;
1097 box_data->left_control_form =
1098 XmCreateForm (box_data->form, "left_control_form", al, ac);
1099 XtManageChild (box_data->left_control_form);
1104 XtSetArg (al[ac], XmNshadowThickness, 1); ac++;
1105 XtSetArg (al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
1106 XtSetArg (al[ac], XmNleftOffset, 0); ac++;
1108 if (XtIsManaged (box_data->left_arrow_form))
1110 XtSetArg (al[ac], XmNtopAttachment, XmATTACH_WIDGET); ac++;
1111 XtSetArg (al[ac], XmNtopWidget, box_data->left_arrow_form); ac++;
1115 XtSetArg (al[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
1116 XtSetArg (al[ac], XmNtopOffset, 0); ac++;
1119 XtSetArg (al[ac], XmNbottomAttachment, XmATTACH_FORM); ac++;
1120 XtSetArg (al[ac], XmNbottomOffset, 0); ac++;
1122 XtSetArg (al[ac], XmNuserData, CONTROL); ac++;
1125 /* Remove all of the tab groups */
1127 XtSetArg (al[ac], XmNnavigationType, XmNONE); ac++;
1129 if (panel.color_use == XmCO_BLACK_WHITE)
1131 pixmap = XmGetPixmap (XtScreen (panel.form), "50_foreground",
1132 panel.inactive_pixel_set->fg,
1133 panel.inactive_pixel_set->bg);
1135 XtSetArg (al[ac], XmNbackgroundPixmap, pixmap); ac++;
1138 XtSetArg (al[ac], XmNbackground, panel.primary_pixel_set->bg); ac++;
1139 XtSetArg (al[ac], XmNforeground, panel.primary_pixel_set->fg); ac++;
1141 box_data->left_control_form =
1142 XmCreateForm (box_data->form, "left_control_form", al, ac);
1143 XtManageChild (box_data->left_control_form);
1146 XtSetArg (al[ac], XmNleftAttachment, XmATTACH_WIDGET); ac++;
1147 XtSetArg (al[ac], XmNleftWidget, box_data->left_control_form); ac++;
1148 XtSetArg (al[ac], XmNleftOffset, -3); ac++;
1149 XtSetValues (box_data->switch_form, al, ac);
1153 XtSetArg (al[ac], XmNshadowThickness, 1); ac++;
1154 XtSetArg (al[ac], XmNleftAttachment, XmATTACH_WIDGET); ac++;
1155 XtSetArg (al[ac], XmNleftWidget, box_data->switch_form); ac++;
1156 XtSetArg (al[ac], XmNleftOffset, -4); ac++;
1157 XtSetArg (al[ac], XmNrightAttachment, XmATTACH_FORM); ac++;
1158 XtSetArg (al[ac], XmNrightOffset, 0); ac++;
1160 if (XtIsManaged(box_data->right_arrow_form))
1162 XtSetArg (al[ac], XmNtopAttachment, XmATTACH_WIDGET); ac++;
1163 XtSetArg (al[ac], XmNtopWidget, box_data->right_arrow_form); ac++;
1167 XtSetArg (al[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
1168 XtSetArg (al[ac], XmNtopOffset, 0); ac++;
1171 XtSetArg (al[ac], XmNbottomAttachment, XmATTACH_FORM); ac++;
1172 XtSetArg (al[ac], XmNbottomOffset, 0); ac++;
1174 XtSetArg (al[ac], XmNuserData, CONTROL); ac++;
1177 /* Remove all of the tab groups */
1179 XtSetArg (al[ac], XmNnavigationType, XmNONE); ac++;
1181 if (panel.color_use == XmCO_BLACK_WHITE)
1183 pixmap = XmGetPixmap (XtScreen (panel.form), "50_foreground",
1184 panel.inactive_pixel_set->fg,
1185 panel.inactive_pixel_set->bg);
1187 XtSetArg (al[ac], XmNbackgroundPixmap, pixmap); ac++;
1190 XtSetArg (al[ac], XmNbackground, panel.primary_pixel_set->bg); ac++;
1191 XtSetArg (al[ac], XmNforeground, panel.primary_pixel_set->fg); ac++;
1193 box_data->right_control_form =
1194 XmCreateForm (box_data->form, "right_control_form", al, ac);
1195 XtManageChild (box_data->right_control_form);
1201 XtSetArg (al[ac], XmNshadowThickness, 1); ac++;
1202 XtSetArg (al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
1203 XtSetArg (al[ac], XmNleftOffset, 0); ac++;
1204 XtSetArg (al[ac], XmNrightAttachment, XmATTACH_FORM); ac++;
1205 XtSetArg (al[ac], XmNrightOffset, 0); ac++;
1206 XtSetArg (al[ac], XmNbottomAttachment, XmATTACH_FORM); ac++;
1207 XtSetArg (al[ac], XmNbottomOffset, 0); ac++;
1209 if (XtIsManaged(box_data->left_arrow_form))
1211 XtSetArg (al[ac], XmNtopAttachment, XmATTACH_WIDGET); ac++;
1212 XtSetArg (al[ac], XmNtopWidget, box_data->left_arrow_form); ac++;
1216 XtSetArg (al[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
1217 XtSetArg (al[ac], XmNtopOffset, 0); ac++;
1220 XtSetArg (al[ac], XmNuserData, CONTROL); ac++;
1223 /* Remove all of the tab groups */
1225 XtSetArg (al[ac], XmNnavigationType, XmNONE); ac++;
1227 if (panel.color_use == XmCO_BLACK_WHITE)
1229 pixmap = XmGetPixmap (XtScreen (panel.form), "50_foreground",
1230 panel.inactive_pixel_set->fg,
1231 panel.inactive_pixel_set->bg);
1233 XtSetArg (al[ac], XmNbackgroundPixmap, pixmap); ac++;
1236 XtSetArg (al[ac], XmNbackground, panel.primary_pixel_set->bg); ac++;
1237 XtSetArg (al[ac], XmNforeground, panel.primary_pixel_set->fg); ac++;
1239 box_data->left_control_form =
1240 XmCreateForm (box_data->form, "left_control_form", al, ac);
1241 XtManageChild (box_data->left_control_form);
1244 if (box_data->left_control_form != NULL)
1246 if (panel.popup_data == NULL || panel.popup_data->popup == NULL)
1247 CreatePopupMenu(box_data->left_control_form);
1249 XmAddToPostFromList(panel.popup_data->popup,
1250 box_data->left_control_form);
1253 /* Event handler for posting popup menu */
1255 XtAddEventHandler(box_data->left_control_form, ButtonPressMask, False,
1256 (XtEventHandler) PostPopupMenu, (XtPointer) NULL);
1259 if (box_data->right_control_form != NULL)
1261 if (panel.popup_data == NULL || panel.popup_data->popup == NULL)
1262 CreatePopupMenu(box_data->right_control_form);
1264 XmAddToPostFromList(panel.popup_data->popup,
1265 box_data->right_control_form);
1268 /* Event handler for posting popup menu */
1270 XtAddEventHandler(box_data->right_control_form, ButtonPressMask,False,
1271 (XtEventHandler) PostPopupMenu, (XtPointer) NULL);
1276 /* Once all of the boxes and switch form have been created within */
1277 /* the main panel, call the function to create the main panel */
1278 /* controls. This function also creates the arrows. */
1280 MainControlCreate (switch_position);
1283 /* Call a function to create the control and button set for the switch */
1285 if (switch_box_data != NULL)
1286 SwitchCreate (switch_box_data);
1288 for (i = 0; i < panel.box_data_count; i++)
1290 box_data = panel.box_data[i];
1292 if (box_data->switch_data != NULL)
1294 if (box_data->switch_form != NULL)
1296 if (box_data->switch_data->popup_data == NULL ||
1297 box_data->switch_data->popup_data->popup == NULL)
1298 CreateWorkspacePopupMenu (box_data->switch_form,
1299 box_data->switch_data);
1301 XmAddToPostFromList (box_data->switch_data->popup_data->popup,
1302 box_data->switch_form);
1304 /* Event handler for posting popup menu */
1306 XtAddEventHandler (box_data->switch_form, ButtonPressMask,
1308 (XtEventHandler) PostWorkspacePopupMenu,
1318 /************************************************************************
1322 ************************************************************************/
1325 MainControlCreate (int switch_position)
1335 /* Set up a loop to go through each box and create the set of controls */
1336 /* subpanel arrows, and subpanels for each box. */
1338 for (i = 0; i < panel.box_data_count; i++)
1340 box_data = panel.box_data[i];
1341 if (i == 0) first_box = True;
1342 else first_box = False;
1344 if (box_data->control_data_count == 0)
1348 /* See if we need to split the control create for the box */
1349 /* because the switch is centered between the controls. */
1351 if (switch_position == POSITION_FIRST ||
1352 switch_position == POSITION_LAST ||
1353 box_data->switch_form == NULL)
1355 ControlCreate (box_data->left_control_form, box_data->control_data,
1356 box_data->control_data_count);
1358 ArrowCreate (box_data->left_arrow_form, box_data->control_data,
1359 box_data->control_data_count, False, first_box);
1366 /* Find the position within the control list that is less than */
1367 /* the switch position. */
1369 for (j = 0; j < box_data->control_data_count; j++)
1371 if (switch_position <
1372 (int) ((box_data->control_data[j])->element_values[CONTROL_POSITION_HINTS].parsed_value))
1374 ControlCreate (box_data->left_control_form,
1375 &box_data->control_data[0], j);
1377 ControlCreate (box_data->right_control_form,
1378 &box_data->control_data[j],
1379 box_data->control_data_count - j);
1381 ArrowCreate (box_data->left_arrow_form,
1382 &box_data->control_data[0], j, False, first_box);
1384 ArrowCreate (box_data->right_arrow_form,
1385 &box_data->control_data[j],
1386 box_data->control_data_count - j, True, first_box);
1397 /************************************************************************
1399 * ControlSetVisualData
1400 * Set up the arg list elements for a controls color and font
1403 * Inputs: control_data - a pointer to the control to be created
1404 * al - a pointer to the arg list to contain the resource data
1405 * ac - a pointer to the arg list count
1407 ************************************************************************/
1410 ControlSetVisualData (ControlData * control_data,
1416 XtSetArg (al[*ac], XmNbackground, panel.primary_pixel_set->bg); (*ac)++;
1417 XtSetArg (al[*ac], XmNforeground, panel.primary_pixel_set->fg); (*ac)++;
1419 if (panel.color_use == XmCO_BLACK_WHITE)
1421 XtSetArg (al[*ac], XmNuseEmbossedText, False); (*ac)++;
1422 XtSetArg (al[*ac], XmNarmColor, panel.primary_pixel_set->bg); (*ac)++;
1426 XtSetArg (al[*ac], XmNarmColor, panel.primary_pixel_set->sc); (*ac)++;
1429 if (panel.use_color_icons)
1431 /* Use background for color set matching.
1432 * Use top shadow for clock hand color.
1434 XtSetArg (al[*ac], XmNpixmapBackground, panel.primary_pixel_set->bg);
1436 XtSetArg (al[*ac], XmNpixmapForeground, panel.primary_pixel_set->ts);
1441 if (control_data != NULL &&
1442 (char) control_data->element_values[CONTROL_TYPE].parsed_value ==
1445 if (panel.color_use != XmCO_BLACK_WHITE)
1447 XtSetArg (al[*ac], XmNpixmapForeground, panel.primary_pixel_set->fg);
1449 XtSetArg(al[*ac], XmNpixmapBackground, panel.primary_pixel_set->bg);
1454 XtSetArg (al[*ac], XmNpixmapForeground,
1455 BlackPixelOfScreen (XtScreen (panel.form))); (*ac)++;
1456 XtSetArg (al[*ac], XmNpixmapBackground,
1457 WhitePixelOfScreen (XtScreen (panel.form))); (*ac)++;
1462 XtSetArg (al[*ac], XmNpixmapBackground,
1463 WhitePixelOfScreen (XtScreen (panel.form))); (*ac)++;
1464 XtSetArg (al[*ac], XmNpixmapForeground,
1465 BlackPixelOfScreen (XtScreen (panel.form))); (*ac)++;
1469 XtSetArg (al[*ac], XmNtopShadowColor, panel.primary_pixel_set->ts); (*ac)++;
1470 XtSetArg (al[*ac], XmNbottomShadowColor, panel.primary_pixel_set->bs);(*ac)++;
1471 XtSetArg (al[*ac], XmNselectColor, panel.primary_pixel_set->sc); (*ac)++;
1473 if ((char) control_data->element_values[CONTROL_TYPE].parsed_value ==
1477 XtSetArg (al[*ac], XmNfontList, panel.date_font_list); (*ac)++;
1478 XtSetArg (al[*ac], XmNuseEmbossedText, False); (*ac)++;
1479 XtSetArg (al[*ac], XmNforeground,
1480 BlackPixelOfScreen (XtScreen (panel.form))); (*ac)++;
1482 if (panel.color_use == XmCO_BLACK_WHITE)
1484 XtSetArg (al[*ac], XmNbackground,
1485 WhitePixelOfScreen (XtScreen (panel.form))); (*ac)++;
1490 XtSetArg (al[*ac], XmNfontList, panel.font_list); (*ac)++;
1493 XtSetArg (al[*ac], XmNbehavior, XmICON_DRAG); (*ac)++;
1499 /************************************************************************
1501 * ControlSetIconData
1502 * Set up the arg list elements for a controls icon and label
1505 * Inputs: parent - the widget to be the parent of the control
1506 * control_data - a pointer to the control to be created
1507 * icon_label - a return for an XmString for the control's label
1508 * container_type - the type of parent the control is going into
1509 * al - a pointer to the arg list to contain the resource data
1510 * ac - a pointer to the arg list count
1511 * icon_name - a pointer to the icon name (free after widget
1513 * alternate_icon_name - a pointer to the icon name (free after widget
1516 ************************************************************************/
1519 ControlSetIconData (Widget parent,
1520 ControlData * control_data,
1521 XmString * icon_label,
1526 char ** alternate_icon_name)
1530 char * control_label;
1534 /* Set up the icon and alternate icon resources for the control */
1536 if (container_type == BOX)
1537 icon_size = panel.main_icon_size;
1538 else if (container_type == SUBPANEL)
1539 icon_size = panel.sub_icon_size;
1541 icon_size = panel.switch_icon_size;
1545 (char *) control_data->element_values[CONTROL_NORMAL_ICON].parsed_value;
1547 if (*icon_name != NULL)
1549 *icon_name = GetIconName (*icon_name, icon_size);
1550 XtSetArg (al[*ac], XmNimageName, *icon_name); (*ac)++;
1554 *alternate_icon_name =
1555 (char *) control_data->element_values[CONTROL_ALTERNATE_ICON].parsed_value;
1557 if (*alternate_icon_name != NULL)
1559 *alternate_icon_name = GetIconName (*alternate_icon_name, icon_size);
1560 XtSetArg (al[*ac], XmNalternateImage, *alternate_icon_name); (*ac)++;
1564 /* If this is not a subpanel control and the keyword is is set so that */
1565 /* labels are not to be displayed, set the string resource to NULL. */
1567 if (container_type != SUBPANEL && (Boolean)
1568 panel.element_values[PANEL_DISPLAY_CONTROL_LABELS].parsed_value == False)
1570 XtSetArg (al[*ac], XmNstring, NULL); (*ac)++;
1575 (char *) control_data->element_values[CONTROL_LABEL].parsed_value;
1578 if ((int) control_data->element_values[CONTROL_TYPE].parsed_value
1581 if (control_label != NULL)
1583 *icon_label = XmStringCreateLocalized (control_label);
1584 XtSetArg (al[*ac], XmNstring, *icon_label); (*ac)++;
1586 else if (icon_name == NULL)
1589 (char *) control_data->element_values[CONTROL_NAME].parsed_value;
1591 *icon_label = XmStringCreateLocalized (control_label);
1592 XtSetArg (al[*ac], XmNstring, *icon_label); (*ac)++;
1597 *icon_label = XmStringCreateLocalized ("");
1598 XtSetArg (al[*ac], XmNstring, *icon_label); (*ac)++;
1606 /************************************************************************
1608 * ControlSetBehavior
1609 * Use the control type value to set the behavior and some visual
1610 * arg list data to be used to create or set values on a control.
1612 * Inputs: control_data - a pointer to the control to be created
1613 * al - the arg list to be set
1614 * ac - a pointer to the count of the arg list elements
1615 * in_subpanel - a boolean denoting the parent type of the control
1617 ************************************************************************/
1620 ControlSetBehavior (ControlData * control_data,
1623 Boolean in_subpanel,
1624 String * expanded_file_name)
1628 Dimension shadow_thickness;
1629 Dimension highlight_thickness;
1630 Dimension margin_width;
1633 /* Set local shadow thickness and sensitive values to be used */
1634 /* to set the resources for the various control types. */
1636 if (control_data->element_values[CONTROL_DROP_ACTION].parsed_value != NULL)
1638 if (panel.resolution == LOW)
1639 shadow_thickness = 1;
1641 shadow_thickness = 2;
1644 shadow_thickness = 1;
1646 if (control_data->element_values[CONTROL_PUSH_ACTION].parsed_value != NULL)
1649 highlight_thickness = 1;
1654 highlight_thickness = 0;
1657 if (panel.resolution == HIGH &&
1658 (char) control_data->element_values[CONTROL_CONTAINER_TYPE].parsed_value == BOX &&
1659 in_subpanel == False)
1666 /* All controls get their user data set to their control data */
1667 /* to be used out of callback functions. */
1669 XtSetArg (al[*ac], XmNuserData, control_data); (*ac)++;
1672 /* Switch on the controls control type to set the behaviors */
1673 /* specific to the individual control types. */
1675 switch ((char) control_data->element_values[CONTROL_TYPE].parsed_value)
1679 XtSetArg (al[*ac], XmNshadowThickness, 0); (*ac)++;
1680 XtSetArg (al[*ac], XmNhighlightThickness, 0); (*ac)++;
1681 XtSetArg (al[*ac], XmNcontrolType, XmCONTROL_BLANK); (*ac)++;
1682 XtSetArg (al[*ac], XmNbehavior, XmICON_LABEL); (*ac)++;
1683 XtSetArg (al[*ac], XmNsensitive, False); (*ac)++;
1689 XtSetArg (al[*ac], XmNshadowThickness, 0); (*ac)++;
1690 XtSetArg (al[*ac], XmNcontrolType, XmCONTROL_BUSY); (*ac)++;
1691 XtSetArg (al[*ac], XmNhighlightThickness, 0); (*ac)++;
1692 XtSetArg (al[*ac], XmNsensitive, False); (*ac)++;
1693 XtSetArg (al[*ac], XmNmarginWidth, margin_width); (*ac)++;
1694 panel.busy_light_data = control_data;
1701 XtSetArg (al[*ac], XmNshadowThickness, shadow_thickness); (*ac)++;
1702 XtSetArg (al[*ac], XmNsensitive, sensitive); (*ac)++;
1703 XtSetArg (al[*ac], XmNhighlightThickness,highlight_thickness); (*ac)++;
1704 XtSetArg (al[*ac], XmNmarginWidth, margin_width); (*ac)++;
1707 if ((char) control_data->element_values[CONTROL_MONITOR_TYPE].parsed_value == MONITOR_NONE)
1709 XtSetArg (al[*ac], XmNcontrolType, XmCONTROL_BUTTON); (*ac)++;
1711 else if ((char) control_data->element_values[CONTROL_MONITOR_TYPE].parsed_value == MONITOR_FILE)
1715 file_name = (String) control_data->element_values[CONTROL_FILE_NAME].parsed_value;
1716 *expanded_file_name = (String) _DtWmParseFilenameExpand ((unsigned char*) file_name);
1718 XtSetArg (al[*ac], XmNfileName, *expanded_file_name); (*ac)++;
1719 XtSetArg (al[*ac], XmNcontrolType, XmCONTROL_MONITOR); (*ac)++;
1721 else if ((char) control_data->element_values[CONTROL_MONITOR_TYPE].parsed_value == MONITOR_MAIL)
1725 file_name = (String) control_data->element_values[CONTROL_FILE_NAME].parsed_value;
1728 * Set fileName resource if specified; otherwise, leave
1729 * unset and it will default to the user's mail file.
1731 if ((file_name != (String)NULL) &&
1732 (*file_name != '\0'))
1734 *expanded_file_name = (String)
1735 _DtWmParseFilenameExpand ((unsigned char*) file_name);
1736 XtSetArg (al[*ac], XmNfileName, *expanded_file_name); (*ac)++;
1739 XtSetArg (al[*ac], XmNcontrolType, XmCONTROL_MAIL); (*ac)++;
1744 case CONTROL_CLIENT:
1746 GeometryData * geometry_data;
1748 XtSetArg (al[*ac], XmNcontrolType, XmCONTROL_CLIENT); (*ac)++;
1749 XtSetArg (al[*ac], XmNshadowThickness, shadow_thickness); (*ac)++;
1750 XtSetArg (al[*ac], XmNsensitive, sensitive); (*ac)++;
1751 XtSetArg (al[*ac], XmNhighlightThickness,highlight_thickness); (*ac)++;
1754 geometry_data = (GeometryData *) control_data->
1755 element_values[CONTROL_CLIENT_GEOMETRY].parsed_value;
1759 if (geometry_data->flags & WidthValue && geometry_data->width > 0)
1761 XtSetArg (al[*ac], XmNwidth, geometry_data->width + 6); (*ac)++;
1764 if (geometry_data->flags & HeightValue && geometry_data->height > 0)
1766 XtSetArg (al[*ac], XmNheight, geometry_data->height + 6);(*ac)++;
1777 XtSetArg (al[*ac], XmNshadowThickness, shadow_thickness); (*ac)++;
1778 XtSetArg (al[*ac], XmNsensitive, sensitive); (*ac)++;
1779 XtSetArg (al[*ac], XmNhighlightThickness,highlight_thickness); (*ac)++;
1780 XtSetArg (al[*ac], XmNmarginWidth, margin_width); (*ac)++;
1783 /* Adjust the size of the clock hands to match the resolution */
1785 if ((panel.resolution == HIGH || panel.resolution == MEDIUM) &&
1786 in_subpanel == False)
1791 XtSetArg (al[*ac], XmNleftInset, inset); (*ac)++;
1792 XtSetArg (al[*ac], XmNrightInset, inset); (*ac)++;
1793 XtSetArg (al[*ac], XmNtopInset, inset); (*ac)++;
1794 XtSetArg (al[*ac], XmNbottomInset, inset); (*ac)++;
1802 XtSetArg (al[*ac], XmNcontrolType, XmCONTROL_DATE); (*ac)++;
1803 XtSetArg (al[*ac], XmNshadowThickness, shadow_thickness); (*ac)++;
1804 XtSetArg (al[*ac], XmNsensitive, sensitive); (*ac)++;
1805 XtSetArg (al[*ac], XmNhighlightThickness,highlight_thickness); (*ac)++;
1806 XtSetArg (al[*ac], XmNmarginWidth, margin_width); (*ac)++;
1807 XtSetArg (al[*ac], XmNuseLabelAdjustment, False); (*ac)++;
1810 if (!control_data->element_values[CONTROL_DATE_FORMAT].use_default)
1812 XtSetArg (al[*ac], XmNformat,
1813 control_data->element_values[CONTROL_DATE_FORMAT].parsed_value);
1820 XtSetArg (al[*ac], XmNpixmapPosition, XmPIXMAP_MIDDLE); (*ac)++;
1821 XtSetArg (al[*ac], XmNfontList, panel.date_font_list); (*ac)++;
1822 XtSetArg (al[*ac], XmNuseEmbossedText, False); (*ac)++;
1823 XtSetArg (al[*ac], XmNforeground,
1824 BlackPixelOfScreen (XtScreen (panel.form))); (*ac)++;
1828 XtSetArg (al[*ac], XmNuseEmbossedText, True); (*ac)++;
1838 /************************************************************************
1840 * ControlCreateAndRegister
1841 * Create the control, add it callbacks, register it, as needed,
1842 * as dropable, as an embedded client, as a push recall client, its
1845 * Inputs: parent - the widget to be the parent of the control
1846 * control_data - a pointer to the control to be created
1847 * main_copy - this is a boolean indicating that the control
1848 * being created is a copy of the main panel control
1849 * that will be contained within a subpanel
1850 * al - a pointer to the arg list to contain the resource data
1851 * ac - the arg list count
1853 ************************************************************************/
1856 ControlCreateAndRegister (Widget parent,
1857 ControlData * control_data,
1865 unsigned char operations = NULL;
1866 char *format, * next_seg;
1870 /* Create either a normal control or a clock */
1872 if ((int) control_data->element_values[CONTROL_TYPE].parsed_value
1874 icon = DtCreateClock (parent, "icon", al, ac);
1876 icon = _DtCreateControl (parent, "icon", al, ac);
1878 if ((int)control_data->element_values[CONTROL_TYPE].parsed_value
1880 (control_data->subpanel_data == NULL || main_copy) &&
1882 (int)control_data->element_values[CONTROL_CONTAINER_TYPE].parsed_value
1885 format = nl_langinfo(D_FMT);
1886 XtSetArg (al2[0], XmNformat, format);
1887 XtSetValues(icon, al2, 1);
1890 XtManageChild (icon);
1891 XtAddCallback (icon, XmNcallback, (XtCallbackProc) PushCB, control_data);
1893 XtAddCallback (icon, XmNhelpCallback,
1894 (XtCallbackProc) ControlTopicHelpCB, control_data);
1897 control_data->icon = icon;
1900 /* Register the animations */
1904 SetupPushAnimation (control_data);
1905 SetupDropAnimation (control_data);
1909 /* Set the drop zone for the icon */
1911 /* Since all file controls have CONTROL_DROP_ACTIONS by default, only */
1912 /* register the ones that are either a data type that is an action or */
1913 /* a file type the has either move, copy or link actions associated with */
1914 /* it. Also register non-file controls that have drop actions as copy. */
1916 if (control_data->element_values[CONTROL_DROP_ACTION].parsed_value
1919 if ((int)control_data->element_values[CONTROL_TYPE].parsed_value ==
1922 if (control_data->is_action)
1924 operations = XmDROP_COPY;
1928 if (control_data->move_action != NULL)
1929 operations |= XmDROP_MOVE;
1930 if (control_data->copy_action != NULL)
1931 operations |= XmDROP_COPY;
1932 if (control_data->link_action != NULL)
1933 operations |= XmDROP_LINK;
1938 operations = XmDROP_COPY;
1941 if (operations != NULL)
1943 XtSetArg (al2[0], DtNdropAnimateCallback, dropCB);
1944 XtSetArg (al2[1], DtNtextIsBuffer, True);
1945 XtSetArg (al2[2], XmNanimationStyle, XmDRAG_UNDER_SHADOW_IN);
1946 XtSetArg (al2[3], DtNpreserveRegistration, True);
1948 /* Temporarily hard-coded to reject buffer drops on the trash
1949 until the desktop clients have trash actions which can
1950 take appropriate action on calendar appointments, mail
1951 attachments, selected text, etc. File Manager is also
1952 hard-coded to reject buffer drops on the trash window.
1953 Any changes here should be coordinated with File Manager.
1955 if (strcmp(control_data->element_values[CONTROL_NAME].parsed_value,
1957 DtDndDropRegister(icon,
1958 DtDND_FILENAME_TRANSFER,
1959 operations, transferDropCB, al2, 4);
1961 DtDndDropRegister(icon,
1962 DtDND_FILENAME_TRANSFER|DtDND_BUFFER_TRANSFER,
1963 operations, transferDropCB, al2, 4);
1968 /* Install the control into the push recall and embedded client list. */
1972 if ((Boolean) control_data->element_values[CONTROL_PUSH_RECALL].parsed_value)
1973 PushRecallRegister (control_data, True);
1975 if ((char) control_data->element_values[CONTROL_TYPE].parsed_value == CONTROL_CLIENT)
1976 EmbeddedClientRegister (control_data, True);
1985 /************************************************************************
1988 * Create the workspace switch area. This consists of three steps.
1989 * First, call the window manager to get the set of workspace names.
1990 * Next, create a row column and switch button set for the workspace
1991 * switch functionality. Last, create the set of controls that
1992 * surround the switch buttons.
1994 ************************************************************************/
1997 SwitchCreate (BoxData * box_data)
2001 SwitchData * switch_data = box_data->switch_data;
2003 int switch_count = 1;
2005 Atom current_workspace_atom;
2006 int current_workspace;
2008 Widget switch_button;
2010 XmString label_string;
2012 XmPixelSet * pixel_set;
2016 Widget prev_left = NULL;
2017 Widget prev_right = NULL;
2019 char * icon_name = NULL;
2020 char * alt_icon_name = NULL;
2022 String exp_file_name = NULL;
2030 /* Pre create the text field to be used for renaming the workspaces. */
2032 box_data->switch_edit =
2033 (Widget) XmCreateTextField (box_data->switch_form, "switch_edit", al, 0);
2036 /* Get current workspace from the window manager. */
2038 DtWsmGetCurrentWorkspace (XtDisplay (box_data->switch_form),
2039 RootWindowOfScreen (XtScreen (box_data->switch_form)),
2040 ¤t_workspace_atom);
2043 /* Get current workspace list from the window manager. */
2045 if (DtWsmGetWorkspaceList (XtDisplay (box_data->switch_form),
2046 RootWindowOfScreen (XtScreen (box_data->switch_form)),
2047 &atom_names, &switch_count) == 0)
2049 switch_data->atom_names = atom_names;
2050 switch_data->switch_count = switch_count;
2052 switch_data->switch_names =
2053 (char **) XtMalloc (sizeof(char *) * switch_count);
2055 for (i = 0; i < switch_count; i++)
2057 DtWsmWorkspaceInfo * workspace_info;
2059 DtWsmGetWorkspaceInfo (XtDisplay (box_data->switch_form),
2060 RootWindowOfScreen (XtScreen (box_data->switch_form)),
2061 atom_names[i], &workspace_info);
2063 switch_data->switch_names[i] = XtNewString (workspace_info->pchTitle);
2065 DtWsmFreeWorkspaceInfo (workspace_info);
2067 if (atom_names[i] == current_workspace_atom)
2068 current_workspace = i;
2073 switch_data->switch_names = NULL;
2074 switch_data->switch_count = 0;
2077 panel.switch_row_count =
2078 (int) (switch_data->element_values[SWITCH_NUMBER_OF_ROWS].parsed_value);
2079 switch_data->buttons =
2080 (Widget *) XtMalloc (sizeof (Widget *) * switch_count);
2082 switch_data->popup_data = NULL;
2085 /* Create the row column within the switch form to contain the */
2086 /* workspace buttons. */
2089 XtSetArg (al[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
2090 XtSetArg (al[ac], XmNtopOffset, 1); ac++;
2091 XtSetArg (al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
2092 XtSetArg (al[ac], XmNleftOffset, 1); ac++;
2093 XtSetArg (al[ac], XmNrightAttachment, XmATTACH_FORM); ac++;
2094 XtSetArg (al[ac], XmNrightOffset, 1); ac++;
2095 XtSetArg (al[ac], XmNbottomAttachment, XmATTACH_FORM); ac++;
2096 XtSetArg (al[ac], XmNbottomOffset, 1); ac++;
2098 XtSetArg (al[ac], XmNnumColumns, panel.switch_row_count); ac++;
2099 XtSetArg (al[ac], XmNpacking, XmPACK_COLUMN); ac++;
2100 XtSetArg (al[ac], XmNorientation, XmHORIZONTAL); ac++;
2101 XtSetArg (al[ac], XmNadjustLast, False); ac++;
2104 /* Remove all of the tab groups */
2106 XtSetArg (al[ac], XmNnavigationType, XmNONE); ac++;
2108 if (panel.color_use == XmCO_BLACK_WHITE)
2110 pixmap = XmGetPixmap (XtScreen (panel.form), "50_foreground",
2111 panel.inactive_pixel_set->bg,
2112 panel.inactive_pixel_set->fg);
2113 XtSetArg (al[ac], XmNbackgroundPixmap, pixmap); ac++;
2117 XmCreateRowColumn (box_data->switch_form, "switch_rc", al, ac);
2118 XtManageChild (switch_data->rc);
2121 /* Create the switch buttons */
2123 SwitchButtonCreate (switch_data, False);
2126 /* Set the active switch button to the active workspace */
2128 XtSetArg (al[0], XmNset, True);
2129 switch_data->active_switch = current_workspace;
2130 XtSetValues (switch_data->buttons[current_workspace], al, 1);
2133 /* Initialize time stamp for catching multi-click events */
2135 switch_data->time_stamp = 0;
2138 /* Create each of the switch controls and adjust the switch_rc's */
2139 /* constraints to position it properly. */
2141 /* Set up a loop and create each control within the switch */
2143 for (i = 0; i < switch_data->control_data_count; i++)
2145 ControlData * control_data = switch_data->control_data[i];
2146 XmString icon_label = NULL;
2149 ControlSetVisualData (control_data, al, &ac);
2151 XtSetArg (al[ac], XmNpixmapPosition, XmPIXMAP_TOP); ac++;
2155 if (prev_right == NULL)
2157 XtSetArg (al[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
2158 XtSetArg (al[ac], XmNtopOffset, 1); ac++;
2162 XtSetArg (al[ac], XmNtopAttachment, XmATTACH_WIDGET); ac++;
2163 XtSetArg (al[ac], XmNtopWidget, prev_right); ac++;
2166 XtSetArg (al[ac], XmNleftAttachment, XmATTACH_WIDGET); ac++;
2167 XtSetArg (al[ac], XmNleftWidget, switch_data->rc); ac++;
2168 XtSetArg (al[ac], XmNrightAttachment, XmATTACH_FORM); ac++;
2169 XtSetArg (al[ac], XmNrightOffset, 1); ac++;
2173 if (prev_left == NULL)
2175 XtSetArg (al[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
2176 XtSetArg (al[ac], XmNtopOffset, 1); ac++;
2180 XtSetArg (al[ac], XmNtopAttachment, XmATTACH_WIDGET); ac++;
2181 XtSetArg (al[ac], XmNtopWidget, prev_left); ac++;
2184 XtSetArg (al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
2185 XtSetArg (al[ac], XmNleftOffset, 1); ac++;
2188 if (i >= switch_data->control_data_count - 2)
2190 XtSetArg (al[ac], XmNbottomAttachment, XmATTACH_FORM); ac++;
2191 XtSetArg (al[ac], XmNbottomOffset, 1); ac++;
2195 /* Call the function used to set the control's icon and label data */
2197 ControlSetIconData (box_data->switch_form, control_data,
2198 &icon_label, SWITCH, al, &ac, &icon_name,
2202 /* Call the function used to set the control's behavioral aspects */
2204 ControlSetBehavior (control_data, al, &ac, False, &exp_file_name);
2207 /* Call the function used to create and register the control */
2209 control_data->icon =
2210 ControlCreateAndRegister (box_data->switch_form,
2211 control_data, False, al, ac);
2213 if (icon_label != NULL)
2214 XmStringFree (icon_label);
2216 if (icon_name != NULL)
2219 if (alt_icon_name != NULL)
2220 XtFree(alt_icon_name);
2222 if (exp_file_name != NULL)
2223 XtFree(exp_file_name);
2226 prev_right = control_data->icon;
2228 prev_left = control_data->icon;
2232 XtSetArg (al2[0], XmNleftAttachment, XmATTACH_WIDGET);
2233 XtSetArg (al2[1], XmNleftWidget, prev_left);
2234 XtSetArg (al2[2], XmNrightAttachment, XmATTACH_NONE);
2235 XtSetValues (switch_data->rc, al2, 3);
2243 /************************************************************************
2245 * SwitchButtonCreate
2246 * Create either the full set of switch button or one new one.
2248 *************************************************************************/
2251 SwitchButtonCreate (SwitchData * switch_data,
2257 XmPixelSet * pixel_set;
2259 XmString label_string;
2268 /* Find the box data which contains the switch. This is needed */
2269 /* for the switch callback processing. */
2271 box_data = switch_data->box_data;
2273 /* Calculate switch height */
2274 if (!switch_height) {
2275 Dimension ignore_width;
2277 label_string = XmStringCreateLocalized (switch_data->switch_names[0]);
2278 XmStringExtent(panel.font_list,label_string,
2279 &ignore_width,&switch_height);
2280 XmStringFree(label_string);
2281 if (panel.resolution == HIGH || panel.resolution == MEDIUM) {
2282 switch_height += 14;
2283 if (switch_height < SWITCH_HIGH_BUTTON_HEIGHT) {
2284 switch_height = SWITCH_HIGH_BUTTON_HEIGHT;
2288 if (switch_height < SWITCH_LOW_BUTTON_HEIGHT) {
2289 switch_height = SWITCH_LOW_BUTTON_HEIGHT;
2294 /* Create Switch Toggles */
2298 XtSetArg (al[ac], XmNfillOnArm, False); ac++;
2300 if (panel.resolution == HIGH || panel.resolution == MEDIUM)
2302 XtSetArg (al[ac], XmNwidth, SWITCH_HIGH_BUTTON_WIDTH); ac++;
2303 XtSetArg (al[ac], XmNshadowThickness, 3); ac++;
2304 XtSetArg (al[ac], XmNmarginWidth, 4); ac++;
2309 XtSetArg (al[ac], XmNwidth, SWITCH_LOW_BUTTON_WIDTH); ac++;
2310 XtSetArg (al[ac], XmNshadowThickness, 2); ac++;
2311 XtSetArg (al[ac], XmNmarginWidth, 2); ac++;
2315 XtSetArg (al[ac], XmNheight, switch_height); ac++;
2316 XtSetArg (al[ac], XmNbehavior, XmICON_TOGGLE); ac++;
2317 XtSetArg (al[ac], XmNfillMode, XmFILL_SELF); ac++;
2318 XtSetArg (al[ac], XmNalignment, XmALIGNMENT_BEGINNING); ac++;
2319 XtSetArg (al[ac], XmNpixmapPosition, XmPIXMAP_BOTTOM); ac++;
2320 XtSetArg (al[ac], XmNhighlightThickness, 1); ac++;
2321 XtSetArg (al[ac], XmNmarginHeight, 0); ac++;
2322 XtSetArg (al[ac], XmNspacing, 0); ac++;
2323 XtSetArg (al[ac], XmNcontrolType, XmCONTROL_SWITCH); ac++;
2324 XtSetArg (al[ac], XmNfontList, panel.font_list); ac++;
2325 XtSetArg (al[ac], XmNrecomputeSize, False); ac++;
2326 XtSetArg (al[ac], XmNuserData, box_data); ac++;
2330 /* Set up a loop to either create a full set of switch buttons */
2331 /* or just one, depending on the input parameters. */
2333 switch_count = switch_data->switch_count;
2335 for (i = 0; i < switch_count; i++)
2337 int pixel_set_index, map_index;
2340 i = switch_count - 1;
2345 /* Set pixel resources. */
2346 switch (panel.color_use)
2348 case XmCO_BLACK_WHITE:
2349 case XmCO_LOW_COLOR:
2350 pixel_set_index = 1;
2353 case XmCO_MEDIUM_COLOR:
2354 pixel_set_index = HARD_CODED_PRIMARY;
2357 case XmCO_HIGH_COLOR:
2358 map_index = i % _WS_HIGH_COLOR_COUNT;
2359 pixel_set_index = _ws_high_color_map[map_index];
2363 pixel_set = &panel.pixel_set[pixel_set_index - 1];
2365 XtSetArg (al[ac], XmNforeground, pixel_set->fg); ac++;
2366 XtSetArg (al[ac], XmNbackground, pixel_set->bg); ac++;
2367 XtSetArg (al[ac], XmNarmColor, pixel_set->bg); ac++;
2368 XtSetArg (al[ac], XmNfillOnArm, False); ac++;
2370 if (panel.color_use == XmCO_BLACK_WHITE)
2372 XtSetArg (al[ac], XmNuseEmbossedText, False); ac++;
2373 XtSetArg (al[ac], XmNpixmapBackground,
2374 WhitePixelOfScreen (XtScreen (panel.form))); ac++;
2375 XtSetArg (al[ac], XmNpixmapForeground,
2376 BlackPixelOfScreen (XtScreen (panel.form))); ac++;
2380 XtSetArg (al[ac], XmNpixmapBackground, pixel_set->ts); ac++;
2381 XtSetArg (al[ac], XmNpixmapForeground, pixel_set->bs); ac++;
2387 label_string = XmStringCreateLocalized (switch_data->switch_names[i]);
2388 XtSetArg (al[ac], XmNstring, label_string); ac++;
2391 switch_data->buttons[i] =
2392 _DtCreateControl (switch_data->rc, "toggle", al, ac);
2394 XtManageChild (switch_data->buttons[i]);
2396 XtAddCallback (switch_data->buttons[i], XmNcallback,
2397 (XtCallbackProc) SwitchButtonCB, NULL);
2399 XtAddCallback (switch_data->buttons[i], XmNhelpCallback,
2400 (XtCallbackProc) GeneralTopicHelpCB, SWITCH_BUTTON);
2402 XmStringFree (label_string);
2409 /************************************************************************
2413 ************************************************************************/
2416 ControlCreate (Widget parent,
2417 ControlData ** control_data,
2425 Widget prev_icon = NULL;
2427 char * icon_name = NULL;
2428 char * alt_icon_name = NULL;
2429 String exp_file_name = NULL;
2430 XmString icon_label = NULL;
2433 /* Set up a loop and create each control within the box */
2435 for (i = 0; i < control_count; i++)
2438 ControlSetVisualData (control_data[i], al, &ac);
2440 XtSetArg (al[ac], XmNpixmapPosition, XmPIXMAP_TOP); ac++;
2442 XtSetArg (al[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
2443 XtSetArg (al[ac], XmNtopOffset, 1); ac++;
2444 XtSetArg (al[ac], XmNbottomAttachment, XmATTACH_FORM); ac++;
2445 XtSetArg (al[ac], XmNbottomOffset, 1); ac++;
2447 if (prev_icon == NULL)
2449 XtSetArg (al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
2450 XtSetArg (al[ac], XmNleftOffset, 1); ac++;
2454 XtSetArg (al[ac], XmNleftAttachment, XmATTACH_WIDGET); ac++;
2455 XtSetArg (al[ac], XmNleftWidget, prev_icon); ac++;
2458 if (i == control_count - 1)
2460 XtSetArg (al[ac], XmNrightAttachment, XmATTACH_FORM); ac++;
2461 XtSetArg (al[ac], XmNrightOffset, 1); ac++;
2465 /* Call the function used to set the control's icon and label data */
2467 ControlSetIconData (parent, control_data[i], &icon_label, BOX, al, &ac,
2468 &icon_name, &alt_icon_name);
2471 /* Call the function used to set the control's behavioral aspects */
2473 ControlSetBehavior (control_data[i], al, &ac, False, &exp_file_name);
2476 /* Call the function used to create and register the control */
2478 control_data[i]->icon =
2479 ControlCreateAndRegister (parent, control_data[i], False, al, ac);
2481 if (icon_label != NULL)
2483 XmStringFree (icon_label);
2487 if (icon_name != NULL)
2493 if (alt_icon_name != NULL)
2495 XtFree(alt_icon_name);
2496 alt_icon_name = NULL;
2499 if (exp_file_name != NULL)
2501 XtFree(exp_file_name);
2502 exp_file_name = NULL;
2505 prev_icon = control_data[i]->icon;
2507 if (control_data[i]->subpanel_data != NULL)
2508 SubpanelCreate (control_data[i], control_data[i]->subpanel_data);
2515 /************************************************************************
2519 ************************************************************************/
2522 ArrowCreate (Widget parent,
2523 ControlData ** control_data,
2531 Widget prev_separator = NULL;
2539 Dimension control_width;
2543 /* If there is no arrow form (there are no subpanels for the controls) */
2544 /* then the parent widget will be null so just return. */
2552 XtSetArg (al[ac], XmNtopOffset, 0); ac++;
2553 XtSetArg (al[ac], XmNbottomOffset, 0); ac++;
2557 XtSetArg (al[ac], XmNtopOffset, 1); ac++;
2558 XtSetArg (al[ac], XmNbottomOffset, 1); ac++;
2562 XtSetArg (al[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
2563 XtSetArg (al[ac], XmNbottomAttachment, XmATTACH_FORM); ac++;
2564 XtSetArg (al[ac], XmNbackground, panel.inactive_pixel_set->bg); ac++;
2565 XtSetArg (al[ac], XmNforeground, panel.inactive_pixel_set->fg); ac++;
2566 XtSetArg (al[ac], XmNtopShadowColor, panel.inactive_pixel_set->ts); ac++;
2567 XtSetArg (al[ac], XmNbottomShadowColor, panel.inactive_pixel_set->bs); ac++;
2568 XtSetArg (al[ac], XmNselectColor, panel.inactive_pixel_set->sc); ac++;
2569 XtSetArg (al[ac], XmNhighlightThickness, 1); ac++;
2570 XtSetArg (al[ac], XmNshadowThickness, 0); ac++;
2572 if (panel.color_use == XmCO_BLACK_WHITE)
2574 pixmap = XmGetPixmap (XtScreen (panel.form), "50_foreground",
2575 panel.inactive_pixel_set->fg,
2576 panel.inactive_pixel_set->bg);
2578 XtSetArg (al[ac], XmNbackgroundPixmap, pixmap); ac++;
2584 XtSetArg (al2[ac2], XmNtopAttachment, XmATTACH_FORM); ac2++;
2585 XtSetArg (al2[ac2], XmNtopOffset, 0); ac2++;
2586 XtSetArg (al2[ac2], XmNbottomAttachment, XmATTACH_FORM); ac2++;
2587 XtSetArg (al2[ac2], XmNbottomOffset, 0); ac2++;
2588 XtSetArg (al2[ac2], XmNbackground, panel.inactive_pixel_set->bg); ac2++;
2589 XtSetArg (al2[ac2], XmNforeground, panel.inactive_pixel_set->fg); ac2++;
2590 XtSetArg (al2[ac2], XmNtopShadowColor, panel.inactive_pixel_set->ts);ac2++;
2591 XtSetArg (al2[ac2], XmNbottomShadowColor, panel.inactive_pixel_set->bs); ac2++;
2592 XtSetArg (al2[ac2], XmNshadowThickness, 2); ac2++;
2593 XtSetArg (al2[ac2], XmNorientation, XmVERTICAL); ac2++;
2597 for (i = 0; i < arrow_count; i++)
2602 if (prev_separator == NULL)
2604 XtSetArg (al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
2607 XtSetArg (al[ac], XmNleftOffset, 0); ac++;
2611 XtSetArg (al[ac], XmNleftOffset, 1); ac++;
2616 XtSetArg (al[ac], XmNleftAttachment, XmATTACH_WIDGET); ac++;
2617 XtSetArg (al[ac], XmNleftWidget, prev_separator); ac++;
2620 control_width = XtWidth (control_data[i]->icon);
2623 if (i == 0 && right_side == True)
2625 else if (i == 0 && right_side == False)
2630 if (i == 0 && first_box == False)
2633 XtSetArg (al[ac], XmNwidth, control_width); ac++;
2635 if (control_data[i]->subpanel_data == NULL)
2637 XtSetArg (al[ac], XmNimageName, blank_arrow_image); ac++;
2641 if ((int) (control_data[i]->
2642 element_values[CONTROL_MONITOR_TYPE].parsed_value) != MONITOR_NONE)
2644 if (CheckOtherMonitorsOn(control_data[i]->subpanel_data))
2646 XtSetArg (al[ac], XmNimageName, post_monitor_arrow_image); ac++;
2650 XtSetArg (al[ac], XmNimageName, post_arrow_image); ac++;
2655 XtSetArg (al[ac], XmNimageName, post_arrow_image); ac++;
2659 XtSetArg (al[ac], XmNmultiClick, XmMULTICLICK_DISCARD); ac++;
2661 control_data[i]->arrow =
2662 DtCreateButtonGadget (parent, "arrow", al, ac);
2664 XtManageChild (control_data[i]->arrow);
2666 if (control_data[i]->subpanel_data == NULL)
2667 XtSetSensitive (control_data[i]->arrow, False);
2669 XtAddCallback (control_data[i]->arrow, XmNcallback,
2671 (XtPointer) control_data[i]);
2673 if (i < arrow_count - 1)
2675 XtSetArg (al2[ac2], XmNleftAttachment, XmATTACH_WIDGET); ac2++;
2676 XtSetArg (al2[ac2], XmNleftWidget, control_data[i]->arrow); ac2++;
2678 if (i == 0 && right_side == False)
2680 XtSetArg (al2[ac2], XmNleftOffset, 1); ac2++;
2682 else if (i == 0 && right_side == True)
2684 XtSetArg (al2[ac2], XmNleftOffset, 3); ac2++;
2688 XtSetArg (al2[ac2], XmNleftOffset, 0); ac2++;
2691 control_data[i]->arrow_separator =
2692 XmCreateSeparatorGadget (parent, "arrow_separator", al2, ac2);
2693 XtManageChild (control_data[i]->arrow_separator);
2695 prev_separator = control_data[i]->arrow_separator;
2703 /************************************************************************
2707 ************************************************************************/
2710 SubpanelCreate (ControlData * main_control_data,
2711 SubpanelData * subpanel_data)
2715 DtPanelShellWidget subpanel_shell;
2716 char * subpanel_name = (char *) subpanel_data->element_values[SUBPANEL_TITLE].parsed_value;
2717 XmString icon_label;
2719 ControlData * control_data;
2720 Widget attach_widget;
2721 Boolean control_install;
2722 Boolean monitor = False;
2723 Boolean main = False;
2735 /* Create the subpanel shell. */
2738 XtSetArg (al[ac], XmNallowShellResize, True); ac++;
2739 XtSetArg (al[ac], XmNmwmDecorations, MWM_DECOR_MENU | MWM_DECOR_TITLE); ac++;
2740 XtSetArg (al[ac], XmNtitle, subpanel_name); ac++;
2742 subpanel_data->shell =
2743 XtCreatePopupShell (subpanel_name, xmDialogShellWidgetClass,
2744 panel.shell, al, ac);
2746 XtSetMappedWhenManaged (subpanel_data->shell, False);
2749 /* Set pixel resources. */
2752 XtSetArg (al[ac], XmNforeground, panel.primary_pixel_set->fg); ac++;
2753 XtSetArg (al[ac], XmNbackground, panel.primary_pixel_set->bg); ac++;
2754 XtSetArg (al[ac], XmNtopShadowColor, panel.primary_pixel_set->ts); ac++;
2755 XtSetArg (al[ac], XmNbottomShadowColor, panel.primary_pixel_set->bs);ac++;
2756 XtSetArg (al[ac], XmNselectColor, panel.primary_pixel_set->sc); ac++;
2758 if (panel.color_use == XmCO_BLACK_WHITE)
2760 XtSetArg (al[ac], XmNuseEmbossedText, False); ac++;
2761 XtSetArg (al[ac], XmNarmColor, panel.primary_pixel_set->bg); ac++;
2762 XtSetArg (al[ac], XmNpixmapBackground,
2763 WhitePixelOfScreen (XtScreen (panel.form))); ac++;
2764 XtSetArg (al[ac], XmNpixmapForeground,
2765 BlackPixelOfScreen (XtScreen (panel.form))); ac++;
2768 if (panel.color_use == XmCO_LOW_COLOR)
2770 XtSetArg (al[ac], XmNpixmapBackground,
2771 WhitePixelOfScreen (XtScreen (panel.form))); ac++;
2772 XtSetArg (al[ac], XmNpixmapForeground, panel.primary_pixel_set->bg); ac++;
2773 XtSetArg (al[ac], XmNpixmapForeground, panel.primary_pixel_set->bg); ac++;
2778 XtSetArg (al[ac], XmNshadowThickness, 1); ac++;
2781 /* Create the outer form widget that will contain the entire panel */
2783 XtSetArg (al[ac], XmNuserData, SUBPANEL); ac++;
2785 if (panel.color_use == XmCO_BLACK_WHITE)
2787 pixmap = XmGetPixmap (XtScreen (panel.form), "50_foreground",
2788 panel.inactive_pixel_set->fg,
2789 panel.inactive_pixel_set->bg);
2791 XtSetArg (al[ac], XmNbackgroundPixmap, pixmap); ac++;
2794 subpanel_data->form =
2795 XmCreateForm (subpanel_data->shell, subpanel_name, al, ac);
2797 XtManageChild (subpanel_data->form);
2799 XtAddCallback (subpanel_data->form, XmNhelpCallback,
2800 (XtCallbackProc) SubpanelTopicHelpCB, subpanel_data);
2802 if (panel.popup_data == NULL || panel.popup_data->popup == NULL)
2803 CreatePopupMenu (subpanel_data->form);
2805 XmAddToPostFromList (panel.popup_data->popup, subpanel_data->form);
2808 /* Event handler for posting popup menu */
2810 XtAddEventHandler (subpanel_data->form, ButtonPressMask, False,
2811 (XtEventHandler) PostPopupMenu, (XtPointer) NULL);
2814 /* If the value for subpanel control install is true, create */
2815 /* the drop zone as the top child of the form */
2818 (Boolean) subpanel_data->element_values[SUBPANEL_CONTROL_INSTALL].parsed_value;
2820 if (control_install)
2822 icon_label = XmStringCreateLocalized (GETMESSAGE (84, 1, "Install Icon"));
2825 XtSetArg (al[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
2826 XtSetArg (al[ac], XmNtopOffset, 5); ac++;
2827 XtSetArg (al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
2828 XtSetArg (al[ac], XmNleftOffset, 5); ac++;
2829 XtSetArg (al[ac], XmNrightAttachment, XmATTACH_FORM); ac++;
2830 XtSetArg (al[ac], XmNrightOffset, 5); ac++;
2831 XtSetArg (al[ac], XmNshadowThickness, 2); ac++;
2832 XtSetArg (al[ac], XmNhighlightThickness, 1); ac++;
2833 XtSetArg (al[ac], XmNmarginWidth, 1); ac++;
2834 XtSetArg (al[ac], XmNmarginHeight, 1); ac++;
2835 XtSetArg (al[ac], XmNstring, icon_label); ac++;
2836 XtSetArg (al[ac], XmNpixmapPosition, XmPIXMAP_LEFT); ac++;
2837 XtSetArg (al[ac], XmNbehavior, XmICON_LABEL); ac++;
2838 XtSetArg (al[ac], XmNimageName, dropzone_image); ac++;
2839 XtSetArg (al[ac], XmNuserData, subpanel_data); ac++;
2840 XtSetArg (al[ac], XmNfontList, panel.font_list); ac++;
2841 XtSetArg (al[ac], XmNtraversalOn, False); ac++;
2843 if (panel.color_use == XmCO_BLACK_WHITE)
2845 pixmap = XmGetPixmap (XtScreen (panel.form), "50_foreground",
2846 panel.inactive_pixel_set->fg,
2847 panel.inactive_pixel_set->bg);
2849 XtSetArg (al[ac], XmNbackgroundPixmap, pixmap); ac++;
2852 subpanel_data->dropzone =
2853 _DtCreateControl (subpanel_data->form, "dropzone", al, ac);
2854 XtManageChild (subpanel_data->dropzone);
2855 XmStringFree (icon_label);
2857 XtAddCallback (subpanel_data->dropzone, XmNhelpCallback,
2858 (XtCallbackProc) GeneralTopicHelpCB, INSTALL_ZONE);
2861 /* Set the drop zone for the install area. */
2863 XtSetArg (al2[0], DtNdropAnimateCallback, customizeDropCB);
2864 XtSetArg (al2[1], XmNanimationStyle, XmDRAG_UNDER_SHADOW_IN);
2865 XtSetArg (al2[2], DtNpreserveRegistration, True);
2867 DtDndDropRegister (subpanel_data->dropzone, DtDND_FILENAME_TRANSFER,
2868 XmDROP_COPY, customizeTransferDropCB, al2, 3);
2871 /* Create the separator that goes between the dropzone and controls */
2874 XtSetArg (al[ac], XmNtopAttachment, XmATTACH_WIDGET); ac++;
2875 XtSetArg (al[ac], XmNtopWidget, subpanel_data->dropzone); ac++;
2876 XtSetArg (al[ac], XmNtopOffset, 5); ac++;
2877 XtSetArg (al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
2878 XtSetArg (al[ac], XmNleftOffset, 1); ac++;
2879 XtSetArg (al[ac], XmNrightAttachment, XmATTACH_FORM); ac++;
2880 XtSetArg (al[ac], XmNrightOffset, 1); ac++;
2881 XtSetArg (al[ac], XmNshadowThickness, 2); ac++;
2882 XtSetArg (al[ac], XmNorientation, XmHORIZONTAL); ac++;
2884 subpanel_data->separator =
2885 XmCreateSeparatorGadget (subpanel_data->form,
2886 "subpanel_separator", al, ac);
2887 XtManageChild (subpanel_data->separator);
2891 /* Loop through the control set and see if any of the controls */
2892 /* have monitor files attached to them. If so, the constraints */
2893 /* for the form need to be set appropriately. */
2895 if ((int) (main_control_data->
2896 element_values[CONTROL_MONITOR_TYPE].parsed_value) != MONITOR_NONE)
2899 if (monitor == False)
2901 for (i = 0; i < subpanel_data->control_data_count; i++)
2903 if ((int) (subpanel_data->control_data[i]->
2904 element_values[CONTROL_MONITOR_TYPE].parsed_value) != MONITOR_NONE)
2913 if (control_install)
2914 attach_widget = subpanel_data->separator;
2916 attach_widget = subpanel_data->form;
2919 /* Set up a loop and create each control within the subpanel */
2921 for (i = -1; i < subpanel_data->control_data_count; i++)
2925 control_data = main_control_data;
2930 control_data = subpanel_data->control_data[i];
2934 SubpanelControlCreate (subpanel_data, main_control_data, control_data,
2935 attach_widget, main, monitor);
2938 attach_widget = subpanel_data->main_panel_icon_copy;
2940 attach_widget = control_data->icon;
2944 /* Pad the bottom of the last control in the subpanel */
2947 XtSetArg (al[ac], XmNbottomAttachment, XmATTACH_FORM); ac++;
2948 XtSetArg (al[ac], XmNbottomOffset, 5); ac++;
2949 XtSetValues (attach_widget, al, ac);
2952 XtUnmanageChild (subpanel_data->form);
2953 XtSetMappedWhenManaged (subpanel_data->shell, True);
2956 /* Add the callback for handling subpanel unmaps from the system menu */
2958 XtAddCallback (subpanel_data->form, XmNunmapCallback,
2959 (XtCallbackProc) SubpanelUnmapCB,
2960 (XtPointer) main_control_data);
2963 /* Set subpanel posting state variables */
2965 subpanel_data->torn = False;
2968 /* Initialize the subpanels default control setting to the main */
2969 /* panel control. */
2971 subpanel_data->default_control = main_control_data;
2973 /* Set the initial XmNcancelButton resource to the default control */
2974 /* within the subpanel. */
2976 if (subpanel_data->control_data)
2977 XtSetArg (al[0], XmNcancelButton, subpanel_data->control_data[0]->icon);
2979 XtSetArg (al[0], XmNcancelButton, subpanel_data->main_panel_icon_copy);
2981 XtSetValues (subpanel_data->form, al, 1);
2988 /************************************************************************
2990 * SubpanelControlCreate
2991 * Create a control within the subpanel
2993 ************************************************************************/
2996 SubpanelControlCreate (SubpanelData * subpanel_data,
2997 ControlData * main_control_data,
2998 ControlData * control_data,
2999 Widget attach_widget,
3004 XmString icon_label = NULL;
3005 Widget control_icon;
3013 char * icon_name = NULL;
3014 char * alt_icon_name = NULL;
3015 String exp_file_name = NULL;
3018 /* Call the function used to set the control's pixel and font data */
3020 ControlSetVisualData (control_data, al, &ac);
3024 /* Set the control's positioning resources */
3028 XtSetArg (al[ac], XmNleftOffset, 20); ac++;
3032 XtSetArg (al[ac], XmNleftOffset, 5); ac++;
3036 XtSetArg (al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
3037 XtSetArg (al[ac], XmNtopAttachment, XmATTACH_WIDGET); ac++;
3038 XtSetArg (al[ac], XmNtopWidget, attach_widget); ac++;
3039 XtSetArg (al[ac], XmNtopOffset, 5); ac++;
3040 XtSetArg (al[ac], XmNrightAttachment, XmATTACH_FORM); ac++;
3041 XtSetArg (al[ac], XmNrightOffset, 5); ac++;
3042 XtSetArg (al[ac], XmNmarginWidth, 1); ac++;
3043 XtSetArg (al[ac], XmNmarginHeight, 1); ac++;
3046 /* Call the function used to set the control's icon and label data */
3048 ControlSetIconData (subpanel_data->form, control_data,
3049 &icon_label, SUBPANEL, al, &ac,
3050 &icon_name, &alt_icon_name);
3053 /* Call the function used to set the control's behavioral aspects */
3055 ControlSetBehavior (control_data, al, &ac, True, &exp_file_name);
3058 /* Call the function used to create and register the control */
3061 ControlCreateAndRegister(subpanel_data->form, control_data, main, al, ac);
3064 subpanel_data->main_panel_icon_copy = control_icon;
3066 control_data->icon = control_icon;
3069 if (icon_label != NULL)
3070 XmStringFree (icon_label);
3072 if (icon_name != NULL)
3075 if (alt_icon_name != NULL)
3076 XtFree(alt_icon_name);
3078 if (exp_file_name != NULL)
3079 XtFree(exp_file_name);
3081 /* If there is a monitor file, create the indicator */
3083 if ((int) (control_data->
3084 element_values[CONTROL_MONITOR_TYPE].parsed_value) != MONITOR_NONE)
3088 m_state = _DtControlGetMonitorState(control_icon);
3090 XtSetArg (al[ac], XmNleftOffset, 3); ac++;
3091 XtSetArg (al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
3092 XtSetArg (al[ac], XmNtopOffset, 6); ac++;
3093 XtSetArg (al[ac], XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET); ac++;
3094 XtSetArg (al[ac], XmNtopWidget, control_icon); ac++;
3095 XtSetArg (al[ac], XmNhighlightThickness, 0); ac++;
3096 XtSetArg (al[ac], XmNmarginWidth, 1); ac++;
3097 XtSetArg (al[ac], XmNmarginHeight, 1); ac++;
3098 XtSetArg (al[ac], XmNstring, NULL); ac++;
3100 if (m_state == DtMONITOR_ON)
3102 XtSetArg (al[ac], XmNimageName, indicator_on_image); ac++;
3104 else /* DtMONITOR_OFF */
3106 XtSetArg (al[ac], XmNimageName, indicator_off_image); ac++;
3109 control_data->indicator =
3110 _DtCreateControl (subpanel_data->form, "indicator", al, ac);
3111 XtManageChild (control_data->indicator);
3113 XtAddCallback (control_data->indicator, XmNhelpCallback,
3114 (XtCallbackProc) GeneralTopicHelpCB, MONITOR_INDICATOR);
3116 XtSetSensitive (control_data->indicator, False);
3123 /************************************************************************
3125 * UpdateSwitchGeometry
3126 * Updates the geometry of the switch area to layout the switch
3127 * buttons and switch controls appropriately.
3130 * box_data: The box that contains the switch.
3132 ************************************************************************/
3136 UpdateSwitchGeometry (BoxData * box_data)
3141 Dimension switch_rc_height, switch_button_height;
3144 if (box_data->switch_data == NULL) return;
3146 XtSetArg (al[0], XmNheight, &switch_rc_height);
3147 XtGetValues (box_data->switch_data->rc, al, 1);
3149 XtSetArg (al[0], XmNheight, &switch_button_height);
3150 XtGetValues (box_data->switch_data->buttons[0], al, 1);
3152 new_margin = ((int)switch_rc_height -
3153 (int)switch_button_height * panel.switch_row_count) /
3154 (panel.switch_row_count + 1);
3156 if (new_margin < 1) new_margin = 1;
3158 XtSetArg (al[0], XmNmarginHeight, new_margin);
3159 XtSetArg (al[1], XmNspacing, new_margin);
3160 XtSetValues (box_data->switch_data->rc, al, 2);
3166 /************************************************************************
3169 * Create and initialize a new subpanel and attach it to control_data
3172 * control_data: The main panel control to which the subpanel
3175 ************************************************************************/
3178 AddSubpanel (ControlData * control_data)
3182 ElementValue * element_values;
3183 SubpanelData * subpanel_data;
3184 BoxData * box_data = (BoxData *)control_data->parent_data;
3192 if (control_data->subpanel_data == NULL)
3194 control_data->subpanel_data =
3195 (SubpanelData *) XtMalloc (sizeof (SubpanelData));
3197 subpanel_data = control_data->subpanel_data;
3199 element_values = (ElementValue *) XtMalloc (sizeof(ElementValue) *
3200 SUBPANEL_KEYWORD_COUNT);
3202 for (i = 0; i < SUBPANEL_KEYWORD_COUNT; i++)
3204 (element_values)[i].use_default = True;
3205 (element_values)[i].string_value = NULL;
3206 (element_values)[i].parsed_value = NULL;
3209 element_values[SUBPANEL_NAME].string_value = XtNewString(
3210 control_data->element_values[CONTROL_NAME].parsed_value);
3211 element_values[SUBPANEL_CONTAINER_NAME].string_value = XtNewString(
3212 control_data->element_values[CONTROL_NAME].parsed_value);
3213 if (control_data->element_values[CONTROL_LABEL].parsed_value != NULL)
3214 element_values[SUBPANEL_TITLE].string_value = XtNewString(
3215 control_data->element_values[CONTROL_LABEL].parsed_value);
3217 element_values[SUBPANEL_TITLE].string_value = XtNewString(
3218 control_data->element_values[CONTROL_NAME].parsed_value);
3220 subpanel_data->control_data = NULL;
3221 subpanel_data->control_data_count = 0;
3222 subpanel_data->parent_control_data = control_data;
3224 InitializeSubpanelFields (element_values);
3226 subpanel_data->element_values = element_values;
3229 if (!XtIsManaged(XtParent(control_data->arrow)))
3232 if (box_data->left_arrow_form)
3234 XtSetArg (al[0], XmNtopAttachment, XmATTACH_WIDGET);
3235 XtSetArg (al[1], XmNtopWidget, box_data->left_arrow_form);
3236 XtSetValues(box_data->left_control_form, al, 2);
3238 XtManageChild(box_data->left_arrow_form);
3241 if (box_data->right_arrow_form)
3243 XtManageChild(box_data->right_arrow_form);
3245 XtSetArg (al[0], XmNtopAttachment, XmATTACH_WIDGET);
3246 XtSetArg (al[1], XmNtopWidget, box_data->right_arrow_form);
3247 XtSetValues(box_data->right_control_form, al, 2);
3250 UpdateSwitchGeometry(box_data);
3254 box_data->subpanel_count++;
3256 SubpanelCreate (control_data, subpanel_data);
3259 XtSetArg (al[0], XmNimageName, post_arrow_image);
3260 XtSetArg (al[1], XmNsensitive, True);
3261 XtSetValues (control_data->arrow, al, 2);
3263 /* Set the subpanels hint and transient behavior */
3265 vHints.flags = DtWM_HINTS_BEHAVIORS | DtWM_HINTS_ATTACH_WINDOW;
3266 vHints.behaviors = DtWM_BEHAVIOR_PANEL | DtWM_BEHAVIOR_SUBPANEL;
3267 vHints.attachWindow = XtWindow (panel.shell);
3269 XtSetArg (al[0], XmNtransientFor, panel.shell);
3270 XtSetValues (subpanel_data->shell, al, 1);
3272 XtRealizeWidget (subpanel_data->form);
3273 _DtWsmSetDtWmHints (XtDisplay (panel.shell),
3274 XtWindow (subpanel_data->shell), &vHints);
3276 WriteSubpanelComponentFile(control_data->subpanel_data);
3282 /************************************************************************
3285 * Remove a control upon a menu request for deletion.
3287 * Inputs: control_data - a pointer to the control to be deleted.
3289 ************************************************************************/
3293 DeleteControl (ControlData * control_data)
3300 /* Remove the control from the push recall and embedded client list. */
3302 PushRecallRegister (control_data, False);
3304 EmbeddedClientRegister (control_data, False);
3307 /* Destroy the widgets allocated by the control */
3309 if (control_data->indicator)
3310 XtDestroyWidget (control_data->indicator);
3312 if (control_data->icon)
3314 if (control_data->element_values[CONTROL_DROP_ACTION].parsed_value
3316 DtDndDropUnregister(control_data->icon);
3317 XtDestroyWidget (control_data->icon);
3321 /* Remove the copy of the action set and delete the element values */
3323 DeleteControlActionList (control_data);
3325 RemoveEntry (control_data, CONTROL);
3331 /************************************************************************
3334 * Delete the subpanel attached to the control pointed to by
3337 * Inputs: control_data - a pointer to the main panel control that the
3338 * subpanel is attached to.
3340 ************************************************************************/
3344 DeleteSubpanel (ControlData * control_data)
3348 SubpanelData * subpanel_data = control_data->subpanel_data;
3349 BoxData * box_data = (BoxData *) control_data->parent_data;
3354 /* If the current main control is not within the main panel, call */
3355 /* the DeleteSubpanelControl function to delete the main control */
3356 /* This will cause the current subpanel control within the main */
3357 /* panel to be promoted to a main panel control. */
3359 if (subpanel_data->parent_control_data != control_data)
3361 subpanel_data->torn = True;
3362 DeleteSubpanelControl (subpanel_data, subpanel_data->parent_control_data);
3363 subpanel_data->parent_control_data->subpanel_data = NULL;
3367 /* Set the main panel control's arrow to blank and insensitive */
3369 XtSetArg (al[0], XmNimageName, blank_arrow_image);
3370 XtSetValues (subpanel_data->parent_control_data->arrow, al, 1);
3371 XtSetSensitive (subpanel_data->parent_control_data->arrow, False);
3374 /* Either remove a dynamic .fp or write out the subpanel's .fp */
3375 /* with the DELETE keyword set */
3377 RemoveSubpanelComponentFile (subpanel_data);
3380 /* Delete the controls within the subpanel, destroy the remaining */
3381 /* widgets and free up the remaining data. */
3383 for (i = 0; i < subpanel_data->control_data_count; i++)
3385 RemoveControlComponentFile (subpanel_data->control_data[i]);
3386 DeleteControl (subpanel_data->control_data[i]);
3387 XtFree ((char *) subpanel_data->control_data[i]);
3390 /* Remove install zones */
3391 if (subpanel_data->element_values[SUBPANEL_CONTROL_INSTALL].parsed_value)
3393 DtDndDropUnregister (subpanel_data->dropzone);
3394 XtDestroyWidget (subpanel_data->dropzone);
3397 XtDestroyWidget (subpanel_data->shell);
3398 XtFree ((char *) subpanel_data->control_data);
3400 RemoveEntry (subpanel_data, SUBPANEL);
3402 XtFree ((char *) subpanel_data);
3403 control_data->subpanel_data = NULL;
3405 box_data->subpanel_count--;
3407 if (box_data->subpanel_count == 0)
3409 if (box_data->left_arrow_form)
3411 XtSetArg (al[0], XmNtopAttachment, XmATTACH_FORM);
3412 XtSetArg (al[1], XmNtopOffset, 0);
3413 XtSetValues(box_data->left_control_form, al, 2);
3415 XtUnmanageChild(box_data->left_arrow_form);
3418 if (box_data->right_arrow_form)
3420 XtUnmanageChild(box_data->right_arrow_form);
3422 XtSetArg (al[0], XmNtopAttachment, XmATTACH_FORM);
3423 XtSetArg (al[1], XmNtopOffset, 0);
3424 XtSetValues(box_data->right_control_form, al, 2);
3427 UpdateSwitchGeometry(box_data);
3434 /************************************************************************
3437 * Exchange the values between two element value structures.
3439 * Inputs: to_value, from_value - pointer to the two element value
3440 * structures in which to exchange the values.
3442 ************************************************************************/
3446 SwapElementValue (ElementValue * to_value,
3447 ElementValue * from_value)
3451 Boolean use_default;
3452 char * string_value;
3453 void * parsed_value;
3455 use_default = from_value->use_default;
3456 string_value = from_value->string_value;
3457 parsed_value = from_value->parsed_value;
3459 from_value->use_default = to_value->use_default;
3460 from_value->string_value = to_value->string_value;
3461 from_value->parsed_value = to_value->parsed_value;
3463 to_value->use_default = use_default;
3464 to_value->string_value = string_value;
3465 to_value->parsed_value = parsed_value;
3471 /************************************************************************
3473 * DeleteSubpanelControl
3474 * This function removes a control contained in control_data from
3478 * subpanel_data: The subpanel the control is being deleted from
3479 * control_data: The control to be deleted
3481 ************************************************************************/
3485 DeleteSubpanelControl (SubpanelData * subpanel_data,
3486 ControlData * control_data)
3490 ControlData * main_control_data = subpanel_data->parent_control_data;
3491 int control_data_count;
3493 Widget * child_list;
3495 Widget attach_widget = NULL;
3496 Widget target_widget = NULL;
3497 Boolean last = False;
3500 Boolean control_monitor;
3506 /* Put the subpanel down before mucking with the widget hierarchy */
3508 if (subpanel_data->torn == False)
3509 XtUnmanageChild (subpanel_data->shell);
3512 /* There are 3 deletion cases. */
3513 /* 1. Deletion of the main panel copy when there are 0 subpanel */
3514 /* controls. This involves destroying the copy and deleting */
3517 /* 2. Deletion of the main panel copy when there is subpanel */
3518 /* controls. This involves the full deletion of the main */
3519 /* panel control and the promotion of a subpanel control to */
3520 /* a full main panel control. */
3522 /* 3. Deletion of a subpanel control. This involves the full */
3523 /* deletion of the subpanel control and if it has been */
3524 /* toggled to the main panel another control is selected */
3526 control_data_count = subpanel_data->control_data_count;
3528 if (main_control_data == control_data && control_data_count == 0)
3530 DeleteSubpanel (main_control_data);
3535 /* Look through the controls parent (form) child list to get */
3536 /* the position of the control to be deleted and the previous */
3537 /* and next control. This is needed for resetting constraints */
3539 if (main_control_data == control_data)
3541 height = XtHeight (subpanel_data->main_panel_icon_copy);
3542 XtSetArg (al[0], XmNtopWidget, &target_widget);
3543 XtGetValues (subpanel_data->main_panel_icon_copy, al, 1);
3547 height = XtHeight (control_data->icon);
3548 XtSetArg (al[0], XmNtopWidget, &target_widget);
3549 XtGetValues (control_data->icon, al, 1);
3552 XtSetArg (al[0], XmNchildren, &child_list);
3553 XtSetArg (al[1], XmNnumChildren, &num_children);
3554 XtGetValues (subpanel_data->form, al, 2);
3556 for (i = 0; i < num_children; i++)
3558 XtSetArg (al[0], XmNtopWidget, &attach_widget);
3559 XtGetValues (child_list[i], al, 1);
3561 if ((main_control_data == control_data &&
3562 attach_widget == subpanel_data->main_panel_icon_copy) ||
3563 (main_control_data != control_data &&
3564 attach_widget == control_data->icon))
3566 attach_widget = child_list[i];
3571 if (i == num_children)
3573 attach_widget = NULL;
3578 if (main_control_data == control_data)
3580 ControlData * subpanel_control_data;
3581 int subpanel_control_position;
3584 if (main_control_data == subpanel_data->default_control)
3585 ToggleDefaultControl (main_control_data, subpanel_data,
3586 subpanel_data->control_data[0]);
3588 subpanel_control_data = subpanel_data->default_control;
3591 /* Remove the .fp or write a Delete .fp for both the main panel */
3592 /* control and subpanel control. The subpanel data will then */
3593 /* be moved the the main panel data and the new control will be */
3596 /* For the main panel control, if a dynamic .fp exists, remove */
3597 /* it otherwize, do nothing since a new one will be written. */
3599 if (SessionFileNameLookup ((char *) main_control_data->element_values[CONTROL_NAME].parsed_value,
3601 (char *) main_control_data->element_values[CONTROL_CONTAINER_NAME].parsed_value,
3603 RemoveControlComponentFile (main_control_data);
3605 RemoveControlComponentFile (subpanel_control_data);
3608 /* Find the position of the subpanel control data */
3609 /* within their parent list, for latter processing */
3611 for (subpanel_control_position = 0;
3612 subpanel_control_position < subpanel_data->control_data_count;
3613 subpanel_control_position++)
3615 if (subpanel_data->control_data[subpanel_control_position] == subpanel_control_data)
3620 /* Reset the subpanel values that were switch from the deleted */
3621 /* main control when ToggleDefaultControl was called above. */
3623 XtDestroyWidget (subpanel_data->main_panel_icon_copy);
3624 subpanel_data->main_panel_icon_copy = subpanel_control_data->icon;
3625 subpanel_data->default_control = main_control_data;
3628 /* Move the necessary data from the MP control to the SP control */
3629 /* and write out the new control file. */
3631 SwapElementValue (&subpanel_control_data->element_values[CONTROL_NAME],
3632 &main_control_data->element_values[CONTROL_NAME]);
3633 SwapElementValue (&subpanel_control_data->element_values[CONTROL_CONTAINER_NAME],
3634 &main_control_data->element_values[CONTROL_CONTAINER_NAME]);
3635 SwapElementValue (&subpanel_control_data->element_values[CONTROL_CONTAINER_TYPE],
3636 &main_control_data->element_values[CONTROL_CONTAINER_TYPE]);
3637 SwapElementValue (&subpanel_control_data->element_values[CONTROL_POSITION_HINTS],
3638 &main_control_data->element_values[CONTROL_POSITION_HINTS]);
3640 WriteControlComponentFile (subpanel_control_data);
3643 /* Delete the main panel control. Null out the icon field */
3644 /* since it is being used within the subpanel_control_data. */
3646 subpanel_control_data->icon = main_control_data->icon;
3647 main_control_data->icon = NULL;
3648 DeleteControl (main_control_data);
3651 /* Set the main control to the subpanel control values */
3653 main_control_data->element_values = subpanel_control_data->element_values;
3654 main_control_data->icon = subpanel_control_data->icon;
3655 main_control_data->indicator = subpanel_control_data->indicator;
3656 main_control_data->actions = subpanel_control_data->actions;
3659 /* Remove and readd the callbacks from the main control and */
3660 /* the main panel icon copy. */
3662 XtRemoveCallback (main_control_data->icon, XmNcallback,
3663 (XtCallbackProc) PushCB, subpanel_control_data);
3665 XtRemoveCallback (main_control_data->icon, XmNhelpCallback,
3666 (XtCallbackProc) ControlTopicHelpCB, subpanel_control_data);
3668 XtAddCallback (main_control_data->icon, XmNcallback,
3669 (XtCallbackProc) PushCB, main_control_data);
3671 XtAddCallback (main_control_data->icon, XmNhelpCallback,
3672 (XtCallbackProc) ControlTopicHelpCB, main_control_data);
3675 XtRemoveCallback (subpanel_data->main_panel_icon_copy, XmNcallback,
3676 (XtCallbackProc) PushCB, subpanel_control_data);
3678 XtRemoveCallback (subpanel_data->main_panel_icon_copy, XmNhelpCallback,
3679 (XtCallbackProc) ControlTopicHelpCB, subpanel_control_data);
3681 XtAddCallback (subpanel_data->main_panel_icon_copy, XmNcallback,
3682 (XtCallbackProc) PushCB, main_control_data);
3684 XtAddCallback (subpanel_data->main_panel_icon_copy, XmNhelpCallback,
3685 (XtCallbackProc) ControlTopicHelpCB, main_control_data);
3689 /* Move the subpanel control data's up one position within the */
3690 /* subpanel's list to denote the removal of the subpanel control */
3691 /* and free up the remaining subpanel data. */
3693 for (i = subpanel_control_position; i < subpanel_data->control_data_count - 1; i++)
3694 subpanel_data->control_data[i] = subpanel_data->control_data[i + 1];
3696 subpanel_data->control_data_count--;
3698 XtFree ((char *) subpanel_control_data);
3701 if (subpanel_data->control_data_count == 0)
3703 XtFree ((char *) subpanel_data->control_data);
3704 subpanel_data->control_data = NULL;
3709 /* Call a function which either unlinks the dynamic .fp file or */
3710 /* writes a Delete = True dynamic .fp file. The function also */
3711 /* updates the session tables. */
3713 RemoveControlComponentFile (control_data);
3716 for (i = 0; i < subpanel_data->control_data_count; i++)
3718 if (control_data == subpanel_data->control_data[i]) break;
3721 if (subpanel_data->default_control == control_data)
3723 if (i < subpanel_data->control_data_count - 1)
3725 ToggleDefaultControl (main_control_data, subpanel_data,
3726 subpanel_data->control_data[i + 1]);
3731 ToggleDefaultControl (main_control_data, subpanel_data,
3732 subpanel_data->control_data[i - 1]);
3733 else if (subpanel_data->main_panel_icon_copy != NULL)
3734 ToggleDefaultControl (main_control_data, subpanel_data,
3739 DeleteControl (control_data);
3741 /* Loop through the control list and move the controls down */
3744 for (j = i + 1 ; j < subpanel_data->control_data_count; j++)
3746 subpanel_data->control_data[j - 1] = subpanel_data->control_data[j];
3749 subpanel_data->control_data_count--;
3753 /* If the subpanel is empty, delete it. */
3755 if (subpanel_data->main_panel_icon_copy == NULL &&
3756 subpanel_data->control_data_count == 0)
3758 DeleteSubpanel (subpanel_data->parent_control_data);
3763 /* Get the control positioning constraints reset */
3765 if (attach_widget != NULL && target_widget != NULL)
3767 XtSetArg (al[0], XmNtopWidget, target_widget);
3768 XtSetValues (attach_widget, al, 1);
3773 XtSetArg (al[0], XmNbottomAttachment, XmATTACH_FORM);
3774 XtSetArg (al[1], XmNbottomOffset, 5);
3775 XtSetValues (target_widget, al, 2);
3777 XtSetArg (al[0], XmNheight, XtHeight (subpanel_data->form) -
3778 (XtHeight (target_widget) - height));
3779 XtSetValues (subpanel_data->form, al, 1);
3783 /* Loop through the remaining controls and see if any left are */
3784 /* monitors. If not, adjust the left pad of the controls */
3786 control_monitor = False;
3788 for (j = 0; j < subpanel_data->control_data_count; j++)
3790 if ((int) subpanel_data->control_data[j]->
3791 element_values[CONTROL_MONITOR_TYPE].parsed_value != MONITOR_NONE)
3793 control_monitor = True;
3798 if ((int) main_control_data->
3799 element_values[CONTROL_MONITOR_TYPE].parsed_value != MONITOR_NONE)
3801 control_monitor = True;
3804 if (control_monitor == False)
3806 XtSetArg (al[0], XmNleftOffset, 5);
3808 for (j = 0; j < subpanel_data->control_data_count; j++)
3809 XtSetValues (subpanel_data->control_data[j]->icon, al, 1);
3811 if (subpanel_data->main_panel_icon_copy != NULL)
3812 XtSetValues (subpanel_data->main_panel_icon_copy, al, 1);
3816 /* Pop the subpanel back up and resume processing */
3818 if (subpanel_data->torn == False)
3819 ArrowCB (main_control_data->arrow,
3820 (XtPointer)main_control_data, (XtPointer)NULL);
3822 /* Set the XmNcancelButton resource to the default control */
3823 /* within the subpanel. */
3825 if (subpanel_data->control_data)
3826 XtSetArg (al[0], XmNcancelButton, subpanel_data->control_data[0]->icon);
3828 XtSetArg (al[0], XmNcancelButton, subpanel_data->main_panel_icon_copy);
3830 XtSetValues (subpanel_data->form, al, 1);
3837 /************************************************************************
3839 * ToggleDefaultControl
3840 * This is used to switch the main panel control to the control
3841 * attached to the selected toggle.
3844 * main_control_data - a pointer to the main panel's control data.
3845 * subpanel_data - a pointer to the subpanel where the control to
3846 * be put in the main panel is coming from.
3847 * control_data - a pointer to the control in the subpanel to be
3848 * toggled into the main panel.
3850 ************************************************************************/
3854 ToggleDefaultControl (ControlData * main_control_data,
3855 SubpanelData * subpanel_data,
3856 ControlData * control_data)
3862 Widget prev_icon = NULL;
3863 Widget next_icon = NULL;
3864 Widget old_main_icon = main_control_data->icon;
3865 Widget main_subpanel_icon;
3866 Widget parent = XtParent (old_main_icon);
3867 Widget control_icon;
3869 char * icon_name = NULL;
3870 char * alt_icon_name = NULL;
3871 String exp_file_name = NULL;
3874 XmString icon_label = NULL;
3877 Dimension new_width;
3884 /* If the selection occured on the currently selected toggle */
3887 if (subpanel_data->default_control == control_data)
3891 /* Update the main panel control's push recall and embedded client */
3892 /* lists, and reparent the embedded client if necessary. */
3894 if (main_control_data == subpanel_data->default_control)
3896 control_icon = main_control_data->icon;
3897 main_control_data->icon = subpanel_data->main_panel_icon_copy;
3899 if ((Boolean) main_control_data->element_values[CONTROL_PUSH_RECALL].parsed_value)
3900 PushRecallRegister (main_control_data, True);
3902 if ((char) main_control_data->element_values[CONTROL_TYPE].parsed_value == CONTROL_CLIENT)
3903 EmbeddedClientRegister (main_control_data, True);
3905 main_control_data->icon = control_icon;
3907 if ((char) main_control_data->
3908 element_values[CONTROL_TYPE].parsed_value == CONTROL_CLIENT)
3910 EmbeddedClientReparent ((char *) main_control_data->
3911 element_values[CONTROL_CLIENT_NAME].parsed_value,
3912 subpanel_data->main_panel_icon_copy);
3917 if ((Boolean) subpanel_data->default_control->element_values[CONTROL_PUSH_RECALL].parsed_value)
3918 PushRecallRegister (subpanel_data->default_control, True);
3920 if ((char) subpanel_data->default_control->element_values[CONTROL_TYPE].parsed_value == CONTROL_CLIENT)
3921 EmbeddedClientRegister (subpanel_data->default_control, True);
3923 if ((char) subpanel_data->default_control->
3924 element_values[CONTROL_TYPE].parsed_value == CONTROL_CLIENT)
3926 EmbeddedClientReparent ((char *) subpanel_data->default_control->
3927 element_values[CONTROL_CLIENT_NAME].parsed_value,
3928 subpanel_data->default_control->icon);
3933 subpanel_data->default_control = control_data;
3934 control_data->subpanel_data = subpanel_data;
3935 main_control_data->is_action = control_data->is_action;
3938 /* Get the width of the current main control to be used to */
3939 /* possible adjust the new control when it is created. */
3941 width = XtWidth (main_control_data->icon);
3944 /* Disallow geometry changes of the main control's parent until */
3945 /* after the controls have been destroyed and created */
3947 XtSetArg (al[0], XmNresizePolicy, XmRESIZE_NONE);
3948 XtSetValues (parent, al, 1);
3951 /* Create the new control using the control data from the */
3952 /* control within the subpanel */
3954 /* Loop through the main controls parent data (box_data) to */
3955 /* find its position relative to controls around it */
3957 box_data = (BoxData *) main_control_data->parent_data;
3959 for (i = 0; i < box_data->control_data_count; i++)
3961 if (box_data->control_data[i] == main_control_data)
3964 prev_icon = box_data->control_data[i - 1]->icon;
3966 if (i != box_data->control_data_count - 1)
3967 next_icon = box_data->control_data[i + 1]->icon;
3974 /* Call the function used to set the control's pixel and font data */
3977 ControlSetVisualData (control_data, al, &ac);
3979 XtSetArg (al[ac], XmNpixmapPosition, XmPIXMAP_TOP); ac++;
3982 /* Set up the attachment constraints for the control */
3984 XtSetArg (al[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
3985 XtSetArg (al[ac], XmNtopOffset, 1); ac++;
3986 XtSetArg (al[ac], XmNbottomAttachment, XmATTACH_FORM); ac++;
3987 XtSetArg (al[ac], XmNbottomOffset, 1); ac++;
3989 if (prev_icon == NULL)
3991 XtSetArg (al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
3992 XtSetArg (al[ac], XmNleftOffset, 1); ac++;
3996 XtSetArg (al[ac], XmNleftAttachment, XmATTACH_WIDGET); ac++;
3997 XtSetArg (al[ac], XmNleftWidget, prev_icon); ac++;
4000 if (next_icon == NULL)
4002 XtSetArg (al[ac], XmNrightAttachment, XmATTACH_FORM); ac++;
4003 XtSetArg (al[ac], XmNrightOffset, 1); ac++;
4007 /* Call the function used to set the control's icon and label data */
4009 ControlSetIconData (parent, control_data, &icon_label, BOX, al, &ac,
4010 &icon_name, &alt_icon_name);
4013 /* Call the function used to set the control's behavioral aspects */
4015 ControlSetBehavior (control_data, al, &ac, False, &exp_file_name);
4018 /* Call the function used to create and register the control */
4020 control_icon = control_data->icon;
4022 main_control_data->icon =
4023 ControlCreateAndRegister (parent, control_data, False, al, ac);
4026 /* If this in not the main control copy then restore the subpanel icon */
4028 if (main_control_data != control_data)
4029 control_data->icon = control_icon;
4032 /* If this is a toggle of a client control from the subpanel to */
4033 /* the main panel, call the reparenting function. */
4035 if ((char) control_data->
4036 element_values[CONTROL_TYPE].parsed_value == CONTROL_CLIENT)
4038 EmbeddedClientReparent ((char *) control_data->
4039 element_values[CONTROL_CLIENT_NAME].parsed_value,
4040 main_control_data->icon);
4044 if (icon_label != NULL)
4045 XmStringFree (icon_label);
4047 if (icon_name != NULL)
4050 if (alt_icon_name != NULL)
4051 XtFree(alt_icon_name);
4053 if (exp_file_name != NULL)
4054 XtFree(exp_file_name);
4056 /* If this is not the right most control within its parent, */
4057 /* reset the poistioning constraints of the control to the */
4058 /* right of this one. */
4060 if (next_icon != NULL)
4063 XtSetArg (al[ac], XmNleftAttachment, XmATTACH_WIDGET); ac++;
4064 XtSetArg (al[ac], XmNleftWidget, main_control_data->icon); ac++;
4065 XtSetValues (next_icon, al, ac);
4069 /* Now destroy the original main panel icon */
4071 XtDestroyWidget (old_main_icon);
4074 /* Get the width of the new icon and increase its size to minimize */
4075 /* the degree of resizing of the main panel. */
4077 new_width = XtWidth (main_control_data->icon);
4079 if (new_width < width)
4081 Dimension normal_size;
4082 Dimension margin_width;
4084 if (panel.resolution == HIGH)
4085 normal_size = ICON_HIGH_WIDTH;
4086 else if (panel.resolution == MEDIUM)
4087 normal_size = ICON_MEDIUM_WIDTH;
4089 normal_size = ICON_LOW_WIDTH;
4091 if (new_width < normal_size)
4093 XtSetArg (al[0], XmNwidth, normal_size);
4094 XtSetArg (al[1], XmNmarginWidth, (Dimension)(normal_size-new_width)/2);
4095 XtSetValues (main_control_data->icon, al, 2);
4100 /* Get the width of the icon again for arrow and embedded client */
4103 new_width = XtWidth (main_control_data->icon);
4106 /* Call a function to reposition embedded clients to the right */
4107 /* of the main panel control. */
4109 if (new_width != width)
4110 EmbeddedClientReposition (main_control_data->icon,
4111 XtX (main_control_data->icon) + 3,
4115 /* Reset the geometry policy for the main control parent */
4117 XtSetArg (al[0], XmNresizePolicy, XmRESIZE_ANY);
4118 XtSetValues (parent, al, 1);
4121 /* Set the width of the arrow */
4124 if (prev_icon != NULL) new_width -= 2;
4125 if (next_icon != NULL) new_width -= 2;
4127 XtSetArg (al[0], XmNwidth, new_width);
4128 XtSetValues (main_control_data->arrow, al, 1);
4134 /************************************************************************
4136 * SetupPushAnimation
4137 * Add the sequence of images that make up a push animation for a
4140 * Inputs: control_data - a pointer to the control to which to add
4143 ************************************************************************/
4147 SetupPushAnimation (ControlData * control_data)
4151 char * animation_name = control_data->
4152 element_values[CONTROL_PUSH_ANIMATION].parsed_value;
4160 count = panel.animation_count;
4162 if (animation_name == NULL) return;
4164 for (i = 0; i < count; i++)
4166 if (!strcmp (panel.animation_data[i].name, animation_name))
4172 for (j = 0; j < panel.animation_data[i].item_count; j++)
4174 image_name = GetIconName (panel.animation_data[i].items[j].image_name,
4175 panel.main_icon_size);
4177 delay = panel.animation_data[i].items[j].delay;
4179 _DtControlAddPushAnimationImage (control_data->icon, image_name, delay);
4188 /************************************************************************
4190 * SetupDropAnimation
4191 * Add the sequence of images that make up a drop animation for a
4194 * Inputs: control_data - a pointer to the control to which to add
4197 ************************************************************************/
4201 SetupDropAnimation (ControlData * control_data)
4205 char * animation_name = control_data->
4206 element_values[CONTROL_DROP_ANIMATION].parsed_value;
4214 count = panel.animation_count;
4216 if (animation_name == NULL) return;
4218 for (i = 0; i < count; i++)
4220 if (!strcmp (panel.animation_data[i].name, animation_name))
4226 for (j = 0; j < panel.animation_data[i].item_count; j++)
4228 image_name = GetIconName (panel.animation_data[i].items[j].image_name,
4229 panel.main_icon_size);
4231 delay = panel.animation_data[i].items[j].delay;
4233 _DtControlAddDropAnimationImage (control_data->icon, image_name, delay);
4243 /************************************************************************
4246 * Get the file name for an icon by extracting the panel resolution
4247 * and then looking up the image name.
4249 * Inputs: image_name - the base name of the image to be found
4250 * icon_size - the size requested (t, s, m, l) for the
4253 ************************************************************************/
4257 GetIconName (String image_name,
4258 unsigned int icon_size)
4263 String return_name = NULL;
4264 Screen * screen = XtScreen (panel.shell);
4265 unsigned int next_size;
4270 next_size = icon_size;
4273 /* Loop through until all sizes are exhausted */
4275 while (return_name == NULL)
4278 _DtGetIconFileName (screen, image_name, NULL, NULL, next_size);
4280 if (next_size == DtLARGE)
4281 next_size = DtMEDIUM;
4282 else if (next_size == DtMEDIUM)
4283 next_size = DtSMALL;
4284 else if (next_size == DtSMALL)
4287 break; /* tried all sizes, exit loop */
4291 if (return_name == NULL)
4293 _DtGetIconFileName (screen, image_name, NULL, NULL, DtUNSPECIFIED);
4295 if (return_name == NULL)
4297 _DtGetIconFileName (screen, DEFAULT_IMAGE_NAME, NULL, NULL, icon_size);
4299 if (return_name == NULL)
4300 return_name = XtNewString (image_name);
4303 /* Return value to be freed by caller. */
4305 return (return_name);