2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
6 * These libraries and programs are free software; you can
7 * redistribute them and/or modify them under the terms of the GNU
8 * Lesser General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
12 * These libraries and programs are distributed in the hope that
13 * they will be useful, but WITHOUT ANY WARRANTY; without even the
14 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU Lesser General Public License for more
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these libraries and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
23 /*****************************************************************************
29 * Description: This file contains the user interface creation and
30 * processing code for the CDE front panel
32 * (c) Copyright 1993, 1994 Hewlett-Packard Company
33 * (c) Copyright 1993, 1994 International Business Machines Corp.
34 * (c) Copyright 1993, 1994 Sun Microsystems, Inc.
35 * (c) Copyright 1993, 1994 Novell, Inc.
37 ****************************************************************************/
41 #include <Dt/DbReader.h>
44 #include <Dt/Control.h>
46 #include <Dt/ControlP.h>
47 #include <Dt/IconFile.h>
50 #include <Dt/GetDispRes.h>
53 #include <Xm/ToggleBG.h>
54 #include <Xm/MwmUtil.h>
55 #include <Xm/AtomMgr.h>
56 #include <Xm/DrawingA.h>
57 #include <Xm/RowColumn.h>
58 #include <Xm/SeparatoG.h>
59 #include <Xm/DialogS.h>
60 #include <Xm/ColorObjP.h>
63 #include <X11/Xatom.h>
64 #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 ((intptr_t) 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 ((intptr_t) 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 ((intptr_t) 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) (intptr_t) 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 ************************************************************************/
703 BoxData * switch_box_data = NULL;
705 int switch_position = POSITION_FIRST;
713 /* Loop through the panels boxes, creating the set outer forms */
714 /* necessary to hold the inner forms for the controls, arrows... */
718 for (i = 0; i < panel.box_data_count; i++)
720 box_data = panel.box_data[i];
723 /* Create the outer box form which will contain the inner box set */
726 XtSetArg (al[ac], XmNshadowThickness, 0); ac++;
728 if (panel.left_handle != NULL)
730 XtSetArg (al[ac], XmNrightAttachment, XmATTACH_WIDGET); ac++;
731 XtSetArg (al[ac], XmNrightWidget, panel.right_handle); ac++;
732 XtSetArg (al[ac], XmNleftAttachment, XmATTACH_WIDGET); ac++;
733 XtSetArg (al[ac], XmNleftWidget, panel.left_handle); ac++;
737 XtSetArg (al[ac], XmNrightAttachment, XmATTACH_FORM); ac++;
738 XtSetArg (al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
741 if (prev_form != NULL)
743 XtSetArg (al[ac], XmNtopAttachment, XmATTACH_WIDGET); ac++;
744 XtSetArg (al[ac], XmNtopWidget, prev_form); ac++;
748 XtSetArg (al[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
749 XtSetArg (al[ac], XmNtopOffset, 1); ac++;
752 if (i == panel.box_data_count - 1)
754 XtSetArg (al[ac], XmNbottomAttachment, XmATTACH_FORM); ac++;
755 XtSetArg (al[ac], XmNbottomOffset, 1); ac++;
758 if (panel.color_use == XmCO_BLACK_WHITE)
760 XtSetArg (al[ac], XmNbottomShadowColor,
761 BlackPixelOfScreen (XtScreen (panel.shell))); ac++;
764 /* Remove all of the tab groups */
766 XtSetArg (al[ac], XmNnavigationType, XmNONE); ac++;
769 XtSetArg (al[ac], XmNbackground, panel.primary_pixel_set->bg); ac++;
770 XtSetArg (al[ac], XmNforeground, panel.primary_pixel_set->fg); ac++;
772 /* Create the outer form widget that will contain the entire panel */
775 XmCreateForm (panel.form,
776 (char *) box_data->element_values[BOX_NAME].parsed_value,
778 XtManageChild (box_data->form);
780 prev_form = box_data->form;
784 /* Loop through the panels boxes, creating the set of forms needed */
785 /* to contain the controls, arrows, or switch within the front panel */
787 for (i = 0; i < panel.box_data_count; i++)
789 box_data = panel.box_data[i];
791 if (box_data->switch_data != NULL)
793 switch_box_data = box_data;
796 XtSetArg (al[ac], XmNshadowThickness, 1); ac++;
797 XtSetArg (al[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
798 XtSetArg (al[ac], XmNtopOffset, 0); ac++;
799 XtSetArg (al[ac], XmNbottomAttachment, XmATTACH_FORM); ac++;
800 XtSetArg (al[ac], XmNbottomOffset, 0); ac++;
803 (intptr_t) box_data->switch_data->element_values[SWITCH_POSITION_HINTS].parsed_value;
806 /* Determine if the defined switch position is actually the */
807 /* first or last position. */
809 if (switch_position != POSITION_FIRST || switch_position != POSITION_LAST)
811 for (j = 0; j < box_data->control_data_count; j++)
813 if (switch_position < (intptr_t) ((box_data->control_data[j])->element_values[CONTROL_POSITION_HINTS].parsed_value))
818 switch_position = POSITION_FIRST;
819 else if (j == box_data->control_data_count)
820 switch_position = POSITION_LAST;
823 if (switch_position == POSITION_FIRST)
825 XtSetArg (al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
826 XtSetArg (al[ac], XmNleftOffset, 0); ac++;
829 if (switch_position == POSITION_LAST ||
830 box_data->control_data_count == 0)
832 XtSetArg (al[ac], XmNrightAttachment, XmATTACH_FORM); ac++;
833 XtSetArg (al[ac], XmNrightOffset, 0); ac++;
836 XtSetArg (al[ac], XmNuserData, SWITCH); ac++;
839 /* Remove all of the tab groups */
841 XtSetArg (al[ac], XmNnavigationType, XmNONE); ac++;
843 if (panel.color_use == XmCO_BLACK_WHITE)
845 XtSetArg (al[ac], XmNbottomShadowColor,
846 BlackPixelOfScreen (XtScreen (panel.form))); ac++;
848 pixmap = XmGetPixmap (XtScreen (panel.form), "50_foreground",
849 panel.inactive_pixel_set->fg,
850 panel.inactive_pixel_set->bg);
852 XtSetArg (al[ac], XmNbackgroundPixmap, pixmap); ac++;
855 XtSetArg (al[ac], XmNbackground, panel.primary_pixel_set->bg); ac++;
856 XtSetArg (al[ac], XmNforeground, panel.primary_pixel_set->fg); ac++;
858 box_data->switch_form =
859 XmCreateForm (box_data->form, "switch", al, ac);
860 XtManageChild (box_data->switch_form);
862 XtAddCallback (box_data->switch_form, XmNhelpCallback,
863 (XtCallbackProc) SwitchTopicHelpCB,
864 box_data->switch_data);
866 if (box_data->control_data_count == 0)
871 /* Create the arrow boxes */
873 if (box_data->switch_form != NULL)
875 if (switch_position == POSITION_FIRST)
878 XtSetArg (al[ac], XmNleftAttachment, XmATTACH_WIDGET); ac++;
879 XtSetArg (al[ac], XmNleftWidget, box_data->switch_form); ac++;
880 XtSetArg (al[ac], XmNleftOffset, -4); ac++;
881 XtSetArg (al[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
882 XtSetArg (al[ac], XmNtopOffset, 0); ac++;
883 XtSetArg (al[ac], XmNrightAttachment, XmATTACH_FORM); ac++;
884 XtSetArg (al[ac], XmNrightOffset, 0); ac++;
887 else if (switch_position == POSITION_LAST)
890 XtSetArg (al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
891 XtSetArg (al[ac], XmNleftOffset, 0); ac++;
892 XtSetArg (al[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
893 XtSetArg (al[ac], XmNtopOffset, 0); ac++;
894 XtSetArg (al[ac], XmNrightAttachment, XmATTACH_WIDGET); ac++;
895 XtSetArg (al[ac], XmNrightWidget, box_data->switch_form); ac++;
896 XtSetArg (al[ac], XmNrightOffset, 0); ac++;
902 XtSetArg (al[ac], XmNleftAttachment, XmATTACH_WIDGET); ac++;
903 XtSetArg (al[ac], XmNleftWidget, box_data->switch_form); ac++;
904 XtSetArg (al[ac], XmNleftOffset, -6); ac++;
905 XtSetArg (al[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
906 XtSetArg (al[ac], XmNtopOffset, 0); ac++;
907 XtSetArg (al[ac], XmNrightAttachment, XmATTACH_FORM); ac++;
908 XtSetArg (al[ac], XmNrightOffset, 0); ac++;
910 XtSetArg (al[ac], XmNbackground, panel.inactive_pixel_set->bg); ac++;
911 XtSetArg (al[ac], XmNforeground, panel.inactive_pixel_set->fg); ac++;
912 XtSetArg (al[ac], XmNtopShadowColor, panel.inactive_pixel_set->ts); ac++;
913 XtSetArg (al[ac], XmNselectColor, panel.inactive_pixel_set->sc); ac++;
915 if (panel.color_use == XmCO_BLACK_WHITE)
917 XtSetArg (al[ac], XmNbottomShadowColor,
918 BlackPixelOfScreen (XtScreen (panel.form))); ac++;
920 pixmap = XmGetPixmap (XtScreen (panel.form), "50_foreground",
921 panel.inactive_pixel_set->fg,
922 panel.inactive_pixel_set->bg);
924 XtSetArg (al[ac], XmNbackgroundPixmap, pixmap); ac++;
928 XtSetArg (al[ac], XmNbottomShadowColor,
929 panel.inactive_pixel_set->bs); ac++;
933 /* Remove all of the tab groups */
935 XtSetArg (al[ac], XmNnavigationType, XmNONE); ac++;
940 XtSetArg (al[ac], XmNshadowThickness, 0); ac++;
944 XtSetArg (al[ac], XmNshadowThickness, 1); ac++;
947 box_data->right_arrow_form =
948 XmCreateForm (box_data->form, "right_arrow_form", al, ac);
950 if (box_data->subpanel_count != 0)
951 XtManageChild (box_data->right_arrow_form);
953 XtAddCallback (box_data->right_arrow_form, XmNhelpCallback,
954 (XtCallbackProc) GeneralTopicHelpCB,
955 SUBPANEL_ACCESS_AREA);
958 XtSetArg (al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
959 XtSetArg (al[ac], XmNleftOffset, 0); ac++;
960 XtSetArg (al[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
961 XtSetArg (al[ac], XmNtopOffset, 0); ac++;
962 XtSetArg (al[ac], XmNrightAttachment, XmATTACH_FORM); ac++;
963 XtSetArg (al[ac], XmNrightOffset, -2); ac++;
969 XtSetArg (al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
970 XtSetArg (al[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
971 XtSetArg (al[ac], XmNrightAttachment, XmATTACH_FORM); ac++;
975 XtSetArg (al[ac], XmNtopOffset, 1); ac++;
976 XtSetArg (al[ac], XmNleftOffset, 1); ac++;
977 XtSetArg (al[ac], XmNrightOffset, 1); ac++;
981 XtSetArg (al[ac], XmNtopOffset, 0); ac++;
982 XtSetArg (al[ac], XmNleftOffset, 0); ac++;
983 XtSetArg (al[ac], XmNrightOffset, 0); ac++;
987 XtSetArg(al[ac], XmNbackground, panel.inactive_pixel_set->bg); ac++;
988 XtSetArg(al[ac], XmNforeground, panel.inactive_pixel_set->fg); ac++;
989 XtSetArg(al[ac], XmNtopShadowColor, panel.inactive_pixel_set->ts);ac++;
990 XtSetArg(al[ac], XmNselectColor, panel.inactive_pixel_set->sc); ac++;
992 if (panel.color_use == XmCO_BLACK_WHITE)
994 XtSetArg (al[ac], XmNbottomShadowColor,
995 BlackPixelOfScreen (XtScreen (panel.form))); ac++;
997 pixmap = XmGetPixmap (XtScreen (panel.form), "50_foreground",
998 panel.inactive_pixel_set->fg,
999 panel.inactive_pixel_set->bg);
1001 XtSetArg (al[ac], XmNbackgroundPixmap, pixmap); ac++;
1005 XtSetArg (al[ac], XmNbottomShadowColor,
1006 panel.inactive_pixel_set->bs); ac++;
1010 /* Remove all of the tab groups */
1012 XtSetArg (al[ac], XmNnavigationType, XmNONE); ac++;
1016 XtSetArg (al[ac], XmNshadowThickness, 0); ac++;
1020 XtSetArg (al[ac], XmNshadowThickness, 1); ac++;
1024 box_data->left_arrow_form =
1025 XmCreateForm (box_data->form, "left_arrow_form", al, ac);
1027 if (box_data->subpanel_count != 0)
1028 XtManageChild (box_data->left_arrow_form);
1030 XtAddCallback (box_data->left_arrow_form, XmNhelpCallback,
1031 (XtCallbackProc) GeneralTopicHelpCB,
1032 SUBPANEL_ACCESS_AREA);
1035 /* Now create the control boxes */
1037 if (box_data->switch_form != NULL)
1039 if (switch_position == POSITION_FIRST ||
1040 switch_position == POSITION_LAST)
1043 XtSetArg (al[ac], XmNshadowThickness, 1); ac++;
1045 if (switch_position == POSITION_FIRST)
1047 XtSetArg (al[ac], XmNleftAttachment, XmATTACH_WIDGET); ac++;
1048 XtSetArg (al[ac], XmNleftWidget, box_data->switch_form); ac++;
1049 XtSetArg (al[ac], XmNleftOffset, -4); ac++;
1050 XtSetArg (al[ac], XmNrightAttachment, XmATTACH_FORM); ac++;
1051 XtSetArg (al[ac], XmNrightOffset, 0); ac++;
1055 XtSetArg (al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
1056 XtSetArg (al[ac], XmNleftOffset, 0); ac++;
1057 XtSetArg (al[ac], XmNrightAttachment, XmATTACH_WIDGET); ac++;
1058 XtSetArg (al[ac], XmNrightWidget, box_data->switch_form); ac++;
1059 XtSetArg (al[ac], XmNrightOffset, 0); ac++;
1062 if (XtIsManaged(box_data->left_arrow_form))
1064 XtSetArg (al[ac], XmNtopAttachment, XmATTACH_WIDGET); ac++;
1065 XtSetArg (al[ac], XmNtopWidget, box_data->left_arrow_form); ac++;
1069 XtSetArg (al[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
1070 XtSetArg (al[ac], XmNtopOffset, 0); ac++;
1073 XtSetArg (al[ac], XmNbottomAttachment, XmATTACH_FORM); ac++;
1074 XtSetArg (al[ac], XmNbottomOffset, 0); ac++;
1076 XtSetArg (al[ac], XmNuserData, CONTROL); ac++;
1079 /* Remove all of the tab groups */
1081 XtSetArg (al[ac], XmNnavigationType, XmNONE); ac++;
1083 if (panel.color_use == XmCO_BLACK_WHITE)
1085 pixmap = XmGetPixmap (XtScreen (panel.form), "50_foreground",
1086 panel.inactive_pixel_set->fg,
1087 panel.inactive_pixel_set->bg);
1089 XtSetArg (al[ac], XmNbackgroundPixmap, pixmap); ac++;
1092 XtSetArg (al[ac], XmNbackground, panel.primary_pixel_set->bg); ac++;
1093 XtSetArg (al[ac], XmNforeground, panel.primary_pixel_set->fg); ac++;
1095 box_data->left_control_form =
1096 XmCreateForm (box_data->form, "left_control_form", al, ac);
1097 XtManageChild (box_data->left_control_form);
1102 XtSetArg (al[ac], XmNshadowThickness, 1); ac++;
1103 XtSetArg (al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
1104 XtSetArg (al[ac], XmNleftOffset, 0); ac++;
1106 if (XtIsManaged (box_data->left_arrow_form))
1108 XtSetArg (al[ac], XmNtopAttachment, XmATTACH_WIDGET); ac++;
1109 XtSetArg (al[ac], XmNtopWidget, box_data->left_arrow_form); ac++;
1113 XtSetArg (al[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
1114 XtSetArg (al[ac], XmNtopOffset, 0); ac++;
1117 XtSetArg (al[ac], XmNbottomAttachment, XmATTACH_FORM); ac++;
1118 XtSetArg (al[ac], XmNbottomOffset, 0); ac++;
1120 XtSetArg (al[ac], XmNuserData, CONTROL); ac++;
1123 /* Remove all of the tab groups */
1125 XtSetArg (al[ac], XmNnavigationType, XmNONE); ac++;
1127 if (panel.color_use == XmCO_BLACK_WHITE)
1129 pixmap = XmGetPixmap (XtScreen (panel.form), "50_foreground",
1130 panel.inactive_pixel_set->fg,
1131 panel.inactive_pixel_set->bg);
1133 XtSetArg (al[ac], XmNbackgroundPixmap, pixmap); ac++;
1136 XtSetArg (al[ac], XmNbackground, panel.primary_pixel_set->bg); ac++;
1137 XtSetArg (al[ac], XmNforeground, panel.primary_pixel_set->fg); ac++;
1139 box_data->left_control_form =
1140 XmCreateForm (box_data->form, "left_control_form", al, ac);
1141 XtManageChild (box_data->left_control_form);
1144 XtSetArg (al[ac], XmNleftAttachment, XmATTACH_WIDGET); ac++;
1145 XtSetArg (al[ac], XmNleftWidget, box_data->left_control_form); ac++;
1146 XtSetArg (al[ac], XmNleftOffset, -3); ac++;
1147 XtSetValues (box_data->switch_form, al, ac);
1151 XtSetArg (al[ac], XmNshadowThickness, 1); ac++;
1152 XtSetArg (al[ac], XmNleftAttachment, XmATTACH_WIDGET); ac++;
1153 XtSetArg (al[ac], XmNleftWidget, box_data->switch_form); ac++;
1154 XtSetArg (al[ac], XmNleftOffset, -4); ac++;
1155 XtSetArg (al[ac], XmNrightAttachment, XmATTACH_FORM); ac++;
1156 XtSetArg (al[ac], XmNrightOffset, 0); ac++;
1158 if (XtIsManaged(box_data->right_arrow_form))
1160 XtSetArg (al[ac], XmNtopAttachment, XmATTACH_WIDGET); ac++;
1161 XtSetArg (al[ac], XmNtopWidget, box_data->right_arrow_form); ac++;
1165 XtSetArg (al[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
1166 XtSetArg (al[ac], XmNtopOffset, 0); ac++;
1169 XtSetArg (al[ac], XmNbottomAttachment, XmATTACH_FORM); ac++;
1170 XtSetArg (al[ac], XmNbottomOffset, 0); ac++;
1172 XtSetArg (al[ac], XmNuserData, CONTROL); ac++;
1175 /* Remove all of the tab groups */
1177 XtSetArg (al[ac], XmNnavigationType, XmNONE); ac++;
1179 if (panel.color_use == XmCO_BLACK_WHITE)
1181 pixmap = XmGetPixmap (XtScreen (panel.form), "50_foreground",
1182 panel.inactive_pixel_set->fg,
1183 panel.inactive_pixel_set->bg);
1185 XtSetArg (al[ac], XmNbackgroundPixmap, pixmap); ac++;
1188 XtSetArg (al[ac], XmNbackground, panel.primary_pixel_set->bg); ac++;
1189 XtSetArg (al[ac], XmNforeground, panel.primary_pixel_set->fg); ac++;
1191 box_data->right_control_form =
1192 XmCreateForm (box_data->form, "right_control_form", al, ac);
1193 XtManageChild (box_data->right_control_form);
1199 XtSetArg (al[ac], XmNshadowThickness, 1); ac++;
1200 XtSetArg (al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
1201 XtSetArg (al[ac], XmNleftOffset, 0); ac++;
1202 XtSetArg (al[ac], XmNrightAttachment, XmATTACH_FORM); ac++;
1203 XtSetArg (al[ac], XmNrightOffset, 0); ac++;
1204 XtSetArg (al[ac], XmNbottomAttachment, XmATTACH_FORM); ac++;
1205 XtSetArg (al[ac], XmNbottomOffset, 0); ac++;
1207 if (XtIsManaged(box_data->left_arrow_form))
1209 XtSetArg (al[ac], XmNtopAttachment, XmATTACH_WIDGET); ac++;
1210 XtSetArg (al[ac], XmNtopWidget, box_data->left_arrow_form); ac++;
1214 XtSetArg (al[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
1215 XtSetArg (al[ac], XmNtopOffset, 0); ac++;
1218 XtSetArg (al[ac], XmNuserData, CONTROL); ac++;
1221 /* Remove all of the tab groups */
1223 XtSetArg (al[ac], XmNnavigationType, XmNONE); ac++;
1225 if (panel.color_use == XmCO_BLACK_WHITE)
1227 pixmap = XmGetPixmap (XtScreen (panel.form), "50_foreground",
1228 panel.inactive_pixel_set->fg,
1229 panel.inactive_pixel_set->bg);
1231 XtSetArg (al[ac], XmNbackgroundPixmap, pixmap); ac++;
1234 XtSetArg (al[ac], XmNbackground, panel.primary_pixel_set->bg); ac++;
1235 XtSetArg (al[ac], XmNforeground, panel.primary_pixel_set->fg); ac++;
1237 box_data->left_control_form =
1238 XmCreateForm (box_data->form, "left_control_form", al, ac);
1239 XtManageChild (box_data->left_control_form);
1242 if (box_data->left_control_form != NULL)
1244 if (panel.popup_data == NULL || panel.popup_data->popup == NULL)
1245 CreatePopupMenu(box_data->left_control_form);
1247 XmAddToPostFromList(panel.popup_data->popup,
1248 box_data->left_control_form);
1251 /* Event handler for posting popup menu */
1253 XtAddEventHandler(box_data->left_control_form, ButtonPressMask, False,
1254 (XtEventHandler) PostPopupMenu, (XtPointer) NULL);
1257 if (box_data->right_control_form != NULL)
1259 if (panel.popup_data == NULL || panel.popup_data->popup == NULL)
1260 CreatePopupMenu(box_data->right_control_form);
1262 XmAddToPostFromList(panel.popup_data->popup,
1263 box_data->right_control_form);
1266 /* Event handler for posting popup menu */
1268 XtAddEventHandler(box_data->right_control_form, ButtonPressMask,False,
1269 (XtEventHandler) PostPopupMenu, (XtPointer) NULL);
1274 /* Once all of the boxes and switch form have been created within */
1275 /* the main panel, call the function to create the main panel */
1276 /* controls. This function also creates the arrows. */
1278 MainControlCreate (switch_position);
1281 /* Call a function to create the control and button set for the switch */
1283 if (switch_box_data != NULL)
1284 SwitchCreate (switch_box_data);
1286 for (i = 0; i < panel.box_data_count; i++)
1288 box_data = panel.box_data[i];
1290 if (box_data->switch_data != NULL)
1292 if (box_data->switch_form != NULL)
1294 if (box_data->switch_data->popup_data == NULL ||
1295 box_data->switch_data->popup_data->popup == NULL)
1296 CreateWorkspacePopupMenu (box_data->switch_form,
1297 box_data->switch_data);
1299 XmAddToPostFromList (box_data->switch_data->popup_data->popup,
1300 box_data->switch_form);
1302 /* Event handler for posting popup menu */
1304 XtAddEventHandler (box_data->switch_form, ButtonPressMask,
1306 (XtEventHandler) PostWorkspacePopupMenu,
1316 /************************************************************************
1320 ************************************************************************/
1323 MainControlCreate (int switch_position)
1333 /* Set up a loop to go through each box and create the set of controls */
1334 /* subpanel arrows, and subpanels for each box. */
1336 for (i = 0; i < panel.box_data_count; i++)
1338 box_data = panel.box_data[i];
1339 if (i == 0) first_box = True;
1340 else first_box = False;
1342 if (box_data->control_data_count == 0)
1346 /* See if we need to split the control create for the box */
1347 /* because the switch is centered between the controls. */
1349 if (switch_position == POSITION_FIRST ||
1350 switch_position == POSITION_LAST ||
1351 box_data->switch_form == NULL)
1353 ControlCreate (box_data->left_control_form, box_data->control_data,
1354 box_data->control_data_count);
1356 ArrowCreate (box_data->left_arrow_form, box_data->control_data,
1357 box_data->control_data_count, False, first_box);
1364 /* Find the position within the control list that is less than */
1365 /* the switch position. */
1367 for (j = 0; j < box_data->control_data_count; j++)
1369 if (switch_position <
1370 (intptr_t) ((box_data->control_data[j])->element_values[CONTROL_POSITION_HINTS].parsed_value))
1372 ControlCreate (box_data->left_control_form,
1373 &box_data->control_data[0], j);
1375 ControlCreate (box_data->right_control_form,
1376 &box_data->control_data[j],
1377 box_data->control_data_count - j);
1379 ArrowCreate (box_data->left_arrow_form,
1380 &box_data->control_data[0], j, False, first_box);
1382 ArrowCreate (box_data->right_arrow_form,
1383 &box_data->control_data[j],
1384 box_data->control_data_count - j, True, first_box);
1395 /************************************************************************
1397 * ControlSetVisualData
1398 * Set up the arg list elements for a controls color and font
1401 * Inputs: control_data - a pointer to the control to be created
1402 * al - a pointer to the arg list to contain the resource data
1403 * ac - a pointer to the arg list count
1405 ************************************************************************/
1408 ControlSetVisualData (ControlData * control_data,
1414 XtSetArg (al[*ac], XmNbackground, panel.primary_pixel_set->bg); (*ac)++;
1415 XtSetArg (al[*ac], XmNforeground, panel.primary_pixel_set->fg); (*ac)++;
1417 if (panel.color_use == XmCO_BLACK_WHITE)
1419 XtSetArg (al[*ac], XmNuseEmbossedText, False); (*ac)++;
1420 XtSetArg (al[*ac], XmNarmColor, panel.primary_pixel_set->bg); (*ac)++;
1424 XtSetArg (al[*ac], XmNarmColor, panel.primary_pixel_set->sc); (*ac)++;
1427 if (panel.use_color_icons)
1429 /* Use background for color set matching.
1430 * Use top shadow for clock hand color.
1432 XtSetArg (al[*ac], XmNpixmapBackground, panel.primary_pixel_set->bg);
1434 XtSetArg (al[*ac], XmNpixmapForeground, panel.primary_pixel_set->ts);
1439 if (control_data != NULL &&
1440 (intptr_t) control_data->element_values[CONTROL_TYPE].parsed_value ==
1443 if (panel.color_use != XmCO_BLACK_WHITE)
1445 XtSetArg (al[*ac], XmNpixmapForeground, panel.primary_pixel_set->fg);
1447 XtSetArg(al[*ac], XmNpixmapBackground, panel.primary_pixel_set->bg);
1452 XtSetArg (al[*ac], XmNpixmapForeground,
1453 BlackPixelOfScreen (XtScreen (panel.form))); (*ac)++;
1454 XtSetArg (al[*ac], XmNpixmapBackground,
1455 WhitePixelOfScreen (XtScreen (panel.form))); (*ac)++;
1460 XtSetArg (al[*ac], XmNpixmapBackground,
1461 WhitePixelOfScreen (XtScreen (panel.form))); (*ac)++;
1462 XtSetArg (al[*ac], XmNpixmapForeground,
1463 BlackPixelOfScreen (XtScreen (panel.form))); (*ac)++;
1467 XtSetArg (al[*ac], XmNtopShadowColor, panel.primary_pixel_set->ts); (*ac)++;
1468 XtSetArg (al[*ac], XmNbottomShadowColor, panel.primary_pixel_set->bs);(*ac)++;
1469 XtSetArg (al[*ac], XmNselectColor, panel.primary_pixel_set->sc); (*ac)++;
1471 if ((intptr_t) control_data->element_values[CONTROL_TYPE].parsed_value ==
1475 XtSetArg (al[*ac], XmNfontList, panel.date_font_list); (*ac)++;
1476 XtSetArg (al[*ac], XmNuseEmbossedText, False); (*ac)++;
1477 XtSetArg (al[*ac], XmNforeground,
1478 BlackPixelOfScreen (XtScreen (panel.form))); (*ac)++;
1480 if (panel.color_use == XmCO_BLACK_WHITE)
1482 XtSetArg (al[*ac], XmNbackground,
1483 WhitePixelOfScreen (XtScreen (panel.form))); (*ac)++;
1488 XtSetArg (al[*ac], XmNfontList, panel.font_list); (*ac)++;
1491 XtSetArg (al[*ac], XmNbehavior, XmICON_DRAG); (*ac)++;
1497 /************************************************************************
1499 * ControlSetIconData
1500 * Set up the arg list elements for a controls icon and label
1503 * Inputs: parent - the widget to be the parent of the control
1504 * control_data - a pointer to the control to be created
1505 * icon_label - a return for an XmString for the control's label
1506 * container_type - the type of parent the control is going into
1507 * al - a pointer to the arg list to contain the resource data
1508 * ac - a pointer to the arg list count
1509 * icon_name - a pointer to the icon name (free after widget
1511 * alternate_icon_name - a pointer to the icon name (free after widget
1514 ************************************************************************/
1517 ControlSetIconData (Widget parent,
1518 ControlData * control_data,
1519 XmString * icon_label,
1524 char ** alternate_icon_name)
1528 char * control_label;
1532 /* Set up the icon and alternate icon resources for the control */
1534 if (container_type == BOX)
1535 icon_size = panel.main_icon_size;
1536 else if (container_type == SUBPANEL)
1537 icon_size = panel.sub_icon_size;
1539 icon_size = panel.switch_icon_size;
1543 (char *) control_data->element_values[CONTROL_NORMAL_ICON].parsed_value;
1545 if (*icon_name != NULL)
1547 *icon_name = GetIconName (*icon_name, icon_size);
1548 XtSetArg (al[*ac], XmNimageName, *icon_name); (*ac)++;
1552 *alternate_icon_name =
1553 (char *) control_data->element_values[CONTROL_ALTERNATE_ICON].parsed_value;
1555 if (*alternate_icon_name != NULL)
1557 *alternate_icon_name = GetIconName (*alternate_icon_name, icon_size);
1558 XtSetArg (al[*ac], XmNalternateImage, *alternate_icon_name); (*ac)++;
1562 /* If this is not a subpanel control and the keyword is is set so that */
1563 /* labels are not to be displayed, set the string resource to NULL. */
1565 if (container_type != SUBPANEL && (intptr_t)
1566 panel.element_values[PANEL_DISPLAY_CONTROL_LABELS].parsed_value == False)
1568 XtSetArg (al[*ac], XmNstring, NULL); (*ac)++;
1573 (char *) control_data->element_values[CONTROL_LABEL].parsed_value;
1576 if ((intptr_t) control_data->element_values[CONTROL_TYPE].parsed_value
1579 if (control_label != NULL)
1581 *icon_label = XmStringCreateLocalized (control_label);
1582 XtSetArg (al[*ac], XmNstring, *icon_label); (*ac)++;
1584 else if (icon_name == NULL)
1587 (char *) control_data->element_values[CONTROL_NAME].parsed_value;
1589 *icon_label = XmStringCreateLocalized (control_label);
1590 XtSetArg (al[*ac], XmNstring, *icon_label); (*ac)++;
1595 *icon_label = XmStringCreateLocalized ("");
1596 XtSetArg (al[*ac], XmNstring, *icon_label); (*ac)++;
1604 /************************************************************************
1606 * ControlSetBehavior
1607 * Use the control type value to set the behavior and some visual
1608 * arg list data to be used to create or set values on a control.
1610 * Inputs: control_data - a pointer to the control to be created
1611 * al - the arg list to be set
1612 * ac - a pointer to the count of the arg list elements
1613 * in_subpanel - a boolean denoting the parent type of the control
1615 ************************************************************************/
1618 ControlSetBehavior (ControlData * control_data,
1621 Boolean in_subpanel,
1622 String * expanded_file_name)
1626 Dimension shadow_thickness;
1627 Dimension highlight_thickness;
1628 Dimension margin_width;
1631 /* Set local shadow thickness and sensitive values to be used */
1632 /* to set the resources for the various control types. */
1634 if (control_data->element_values[CONTROL_DROP_ACTION].parsed_value != NULL)
1636 if (panel.resolution == LOW)
1637 shadow_thickness = 1;
1639 shadow_thickness = 2;
1642 shadow_thickness = 1;
1644 if (control_data->element_values[CONTROL_PUSH_ACTION].parsed_value != NULL)
1647 highlight_thickness = 1;
1652 highlight_thickness = 0;
1655 if (panel.resolution == HIGH &&
1656 (intptr_t) control_data->element_values[CONTROL_CONTAINER_TYPE].parsed_value == BOX &&
1657 in_subpanel == False)
1664 /* All controls get their user data set to their control data */
1665 /* to be used out of callback functions. */
1667 XtSetArg (al[*ac], XmNuserData, control_data); (*ac)++;
1670 /* Switch on the controls control type to set the behaviors */
1671 /* specific to the individual control types. */
1673 switch ((intptr_t) control_data->element_values[CONTROL_TYPE].parsed_value)
1677 XtSetArg (al[*ac], XmNshadowThickness, 0); (*ac)++;
1678 XtSetArg (al[*ac], XmNhighlightThickness, 0); (*ac)++;
1679 XtSetArg (al[*ac], XmNcontrolType, XmCONTROL_BLANK); (*ac)++;
1680 XtSetArg (al[*ac], XmNbehavior, XmICON_LABEL); (*ac)++;
1681 XtSetArg (al[*ac], XmNsensitive, False); (*ac)++;
1687 XtSetArg (al[*ac], XmNshadowThickness, 0); (*ac)++;
1688 XtSetArg (al[*ac], XmNcontrolType, XmCONTROL_BUSY); (*ac)++;
1689 XtSetArg (al[*ac], XmNhighlightThickness, 0); (*ac)++;
1690 XtSetArg (al[*ac], XmNsensitive, False); (*ac)++;
1691 XtSetArg (al[*ac], XmNmarginWidth, margin_width); (*ac)++;
1692 panel.busy_light_data = control_data;
1699 XtSetArg (al[*ac], XmNshadowThickness, shadow_thickness); (*ac)++;
1700 XtSetArg (al[*ac], XmNsensitive, sensitive); (*ac)++;
1701 XtSetArg (al[*ac], XmNhighlightThickness,highlight_thickness); (*ac)++;
1702 XtSetArg (al[*ac], XmNmarginWidth, margin_width); (*ac)++;
1705 if ((intptr_t) control_data->element_values[CONTROL_MONITOR_TYPE].parsed_value == MONITOR_NONE)
1707 XtSetArg (al[*ac], XmNcontrolType, XmCONTROL_BUTTON); (*ac)++;
1709 else if ((intptr_t) control_data->element_values[CONTROL_MONITOR_TYPE].parsed_value == MONITOR_FILE)
1713 file_name = (String) control_data->element_values[CONTROL_FILE_NAME].parsed_value;
1714 *expanded_file_name = (String) _DtWmParseFilenameExpand ((unsigned char*) file_name);
1716 XtSetArg (al[*ac], XmNfileName, *expanded_file_name); (*ac)++;
1717 XtSetArg (al[*ac], XmNcontrolType, XmCONTROL_MONITOR); (*ac)++;
1719 else if ((intptr_t) control_data->element_values[CONTROL_MONITOR_TYPE].parsed_value == MONITOR_MAIL)
1723 file_name = (String) control_data->element_values[CONTROL_FILE_NAME].parsed_value;
1726 * Set fileName resource if specified; otherwise, leave
1727 * unset and it will default to the user's mail file.
1729 if ((file_name != (String)NULL) &&
1730 (*file_name != '\0'))
1732 *expanded_file_name = (String)
1733 _DtWmParseFilenameExpand ((unsigned char*) file_name);
1734 XtSetArg (al[*ac], XmNfileName, *expanded_file_name); (*ac)++;
1737 XtSetArg (al[*ac], XmNcontrolType, XmCONTROL_MAIL); (*ac)++;
1742 case CONTROL_CLIENT:
1744 GeometryData * geometry_data;
1746 XtSetArg (al[*ac], XmNcontrolType, XmCONTROL_CLIENT); (*ac)++;
1747 XtSetArg (al[*ac], XmNshadowThickness, shadow_thickness); (*ac)++;
1748 XtSetArg (al[*ac], XmNsensitive, sensitive); (*ac)++;
1749 XtSetArg (al[*ac], XmNhighlightThickness,highlight_thickness); (*ac)++;
1752 geometry_data = (GeometryData *) control_data->
1753 element_values[CONTROL_CLIENT_GEOMETRY].parsed_value;
1757 if (geometry_data->flags & WidthValue && geometry_data->width > 0)
1759 XtSetArg (al[*ac], XmNwidth, geometry_data->width + 6); (*ac)++;
1762 if (geometry_data->flags & HeightValue && geometry_data->height > 0)
1764 XtSetArg (al[*ac], XmNheight, geometry_data->height + 6);(*ac)++;
1775 XtSetArg (al[*ac], XmNshadowThickness, shadow_thickness); (*ac)++;
1776 XtSetArg (al[*ac], XmNsensitive, sensitive); (*ac)++;
1777 XtSetArg (al[*ac], XmNhighlightThickness,highlight_thickness); (*ac)++;
1778 XtSetArg (al[*ac], XmNmarginWidth, margin_width); (*ac)++;
1781 /* Adjust the size of the clock hands to match the resolution */
1783 if ((panel.resolution == HIGH || panel.resolution == MEDIUM) &&
1784 in_subpanel == False)
1789 XtSetArg (al[*ac], XmNleftInset, inset); (*ac)++;
1790 XtSetArg (al[*ac], XmNrightInset, inset); (*ac)++;
1791 XtSetArg (al[*ac], XmNtopInset, inset); (*ac)++;
1792 XtSetArg (al[*ac], XmNbottomInset, inset); (*ac)++;
1800 XtSetArg (al[*ac], XmNcontrolType, XmCONTROL_DATE); (*ac)++;
1801 XtSetArg (al[*ac], XmNshadowThickness, shadow_thickness); (*ac)++;
1802 XtSetArg (al[*ac], XmNsensitive, sensitive); (*ac)++;
1803 XtSetArg (al[*ac], XmNhighlightThickness,highlight_thickness); (*ac)++;
1804 XtSetArg (al[*ac], XmNmarginWidth, margin_width); (*ac)++;
1805 XtSetArg (al[*ac], XmNuseLabelAdjustment, False); (*ac)++;
1808 if (!control_data->element_values[CONTROL_DATE_FORMAT].use_default)
1810 XtSetArg (al[*ac], XmNformat,
1811 control_data->element_values[CONTROL_DATE_FORMAT].parsed_value);
1818 XtSetArg (al[*ac], XmNpixmapPosition, XmPIXMAP_MIDDLE); (*ac)++;
1819 XtSetArg (al[*ac], XmNfontList, panel.date_font_list); (*ac)++;
1820 XtSetArg (al[*ac], XmNuseEmbossedText, False); (*ac)++;
1821 XtSetArg (al[*ac], XmNforeground,
1822 BlackPixelOfScreen (XtScreen (panel.form))); (*ac)++;
1826 XtSetArg (al[*ac], XmNuseEmbossedText, True); (*ac)++;
1836 /************************************************************************
1838 * ControlCreateAndRegister
1839 * Create the control, add it callbacks, register it, as needed,
1840 * as dropable, as an embedded client, as a push recall client, its
1843 * Inputs: parent - the widget to be the parent of the control
1844 * control_data - a pointer to the control to be created
1845 * main_copy - this is a boolean indicating that the control
1846 * being created is a copy of the main panel control
1847 * that will be contained within a subpanel
1848 * al - a pointer to the arg list to contain the resource data
1849 * ac - the arg list count
1851 ************************************************************************/
1854 ControlCreateAndRegister (Widget parent,
1855 ControlData * control_data,
1863 unsigned char operations = 0;
1864 char *format, * next_seg;
1868 /* Create either a normal control or a clock */
1870 if ((intptr_t) control_data->element_values[CONTROL_TYPE].parsed_value
1872 icon = DtCreateClock (parent, "icon", al, ac);
1874 icon = _DtCreateControl (parent, "icon", al, ac);
1876 if ((intptr_t)control_data->element_values[CONTROL_TYPE].parsed_value
1878 (control_data->subpanel_data == NULL || main_copy) &&
1880 (intptr_t)control_data->element_values[CONTROL_CONTAINER_TYPE].parsed_value
1883 format = nl_langinfo(D_FMT);
1884 XtSetArg (al2[0], XmNformat, format);
1885 XtSetValues(icon, al2, 1);
1888 XtManageChild (icon);
1889 XtAddCallback (icon, XmNcallback, (XtCallbackProc) PushCB, control_data);
1891 XtAddCallback (icon, XmNhelpCallback,
1892 (XtCallbackProc) ControlTopicHelpCB, control_data);
1895 control_data->icon = icon;
1898 /* Register the animations */
1902 SetupPushAnimation (control_data);
1903 SetupDropAnimation (control_data);
1907 /* Set the drop zone for the icon */
1909 /* Since all file controls have CONTROL_DROP_ACTIONS by default, only */
1910 /* register the ones that are either a data type that is an action or */
1911 /* a file type the has either move, copy or link actions associated with */
1912 /* it. Also register non-file controls that have drop actions as copy. */
1914 if (control_data->element_values[CONTROL_DROP_ACTION].parsed_value
1917 if ((intptr_t)control_data->element_values[CONTROL_TYPE].parsed_value ==
1920 if (control_data->is_action)
1922 operations = XmDROP_COPY;
1926 if (control_data->move_action != NULL)
1927 operations |= XmDROP_MOVE;
1928 if (control_data->copy_action != NULL)
1929 operations |= XmDROP_COPY;
1930 if (control_data->link_action != NULL)
1931 operations |= XmDROP_LINK;
1936 operations = XmDROP_COPY;
1939 if (operations != 0)
1941 XtSetArg (al2[0], DtNdropAnimateCallback, dropCB);
1942 XtSetArg (al2[1], DtNtextIsBuffer, True);
1943 XtSetArg (al2[2], XmNanimationStyle, XmDRAG_UNDER_SHADOW_IN);
1944 XtSetArg (al2[3], DtNpreserveRegistration, True);
1946 /* Temporarily hard-coded to reject buffer drops on the trash
1947 until the desktop clients have trash actions which can
1948 take appropriate action on calendar appointments, mail
1949 attachments, selected text, etc. File Manager is also
1950 hard-coded to reject buffer drops on the trash window.
1951 Any changes here should be coordinated with File Manager.
1953 if (strcmp(control_data->element_values[CONTROL_NAME].parsed_value,
1955 DtDndDropRegister(icon,
1956 DtDND_FILENAME_TRANSFER,
1957 operations, transferDropCB, al2, 4);
1959 DtDndDropRegister(icon,
1960 DtDND_FILENAME_TRANSFER|DtDND_BUFFER_TRANSFER,
1961 operations, transferDropCB, al2, 4);
1966 /* Install the control into the push recall and embedded client list. */
1970 if ((intptr_t) control_data->element_values[CONTROL_PUSH_RECALL].parsed_value)
1971 PushRecallRegister (control_data, True);
1973 if ((intptr_t) control_data->element_values[CONTROL_TYPE].parsed_value == CONTROL_CLIENT)
1974 EmbeddedClientRegister (control_data, True);
1983 /************************************************************************
1986 * Create the workspace switch area. This consists of three steps.
1987 * First, call the window manager to get the set of workspace names.
1988 * Next, create a row column and switch button set for the workspace
1989 * switch functionality. Last, create the set of controls that
1990 * surround the switch buttons.
1992 ************************************************************************/
1995 SwitchCreate (BoxData * box_data)
1999 SwitchData * switch_data = box_data->switch_data;
2001 int switch_count = 1;
2003 Atom current_workspace_atom;
2004 int current_workspace = 0;
2006 Widget switch_button;
2008 XmString label_string;
2010 XmPixelSet * pixel_set;
2014 Widget prev_left = NULL;
2015 Widget prev_right = NULL;
2017 char * icon_name = NULL;
2018 char * alt_icon_name = NULL;
2020 String exp_file_name = NULL;
2028 /* Pre create the text field to be used for renaming the workspaces. */
2030 box_data->switch_edit =
2031 (Widget) XmCreateTextField (box_data->switch_form, "switch_edit", al, 0);
2034 /* Get current workspace from the window manager. */
2036 DtWsmGetCurrentWorkspace (XtDisplay (box_data->switch_form),
2037 RootWindowOfScreen (XtScreen (box_data->switch_form)),
2038 ¤t_workspace_atom);
2041 /* Get current workspace list from the window manager. */
2043 if (DtWsmGetWorkspaceList (XtDisplay (box_data->switch_form),
2044 RootWindowOfScreen (XtScreen (box_data->switch_form)),
2045 &atom_names, &switch_count) == 0)
2047 switch_data->atom_names = atom_names;
2048 switch_data->switch_count = switch_count;
2050 switch_data->switch_names =
2051 (char **) XtMalloc (sizeof(char *) * switch_count);
2053 for (i = 0; i < switch_count; i++)
2055 DtWsmWorkspaceInfo * workspace_info;
2057 DtWsmGetWorkspaceInfo (XtDisplay (box_data->switch_form),
2058 RootWindowOfScreen (XtScreen (box_data->switch_form)),
2059 atom_names[i], &workspace_info);
2061 switch_data->switch_names[i] = XtNewString (workspace_info->pchTitle);
2063 DtWsmFreeWorkspaceInfo (workspace_info);
2065 if (atom_names[i] == current_workspace_atom)
2066 current_workspace = i;
2071 switch_data->switch_names = NULL;
2072 switch_data->switch_count = 0;
2075 panel.switch_row_count =
2076 (int) (intptr_t) (switch_data->element_values[SWITCH_NUMBER_OF_ROWS].parsed_value);
2077 switch_data->buttons =
2078 (Widget *) XtMalloc (sizeof (Widget) * switch_count);
2080 switch_data->popup_data = NULL;
2083 /* Create the row column within the switch form to contain the */
2084 /* workspace buttons. */
2087 XtSetArg (al[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
2088 XtSetArg (al[ac], XmNtopOffset, 1); ac++;
2089 XtSetArg (al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
2090 XtSetArg (al[ac], XmNleftOffset, 1); ac++;
2091 XtSetArg (al[ac], XmNrightAttachment, XmATTACH_FORM); ac++;
2092 XtSetArg (al[ac], XmNrightOffset, 1); ac++;
2093 XtSetArg (al[ac], XmNbottomAttachment, XmATTACH_FORM); ac++;
2094 XtSetArg (al[ac], XmNbottomOffset, 1); ac++;
2096 XtSetArg (al[ac], XmNnumColumns, panel.switch_row_count); ac++;
2097 XtSetArg (al[ac], XmNpacking, XmPACK_COLUMN); ac++;
2098 XtSetArg (al[ac], XmNorientation, XmHORIZONTAL); ac++;
2099 XtSetArg (al[ac], XmNadjustLast, False); ac++;
2102 /* Remove all of the tab groups */
2104 XtSetArg (al[ac], XmNnavigationType, XmNONE); ac++;
2106 if (panel.color_use == XmCO_BLACK_WHITE)
2108 pixmap = XmGetPixmap (XtScreen (panel.form), "50_foreground",
2109 panel.inactive_pixel_set->bg,
2110 panel.inactive_pixel_set->fg);
2111 XtSetArg (al[ac], XmNbackgroundPixmap, pixmap); ac++;
2115 XtSetArg (al[ac], XmNbackground, panel.primary_pixel_set->bg); ac++;
2116 XtSetArg (al[ac], XmNforeground, panel.primary_pixel_set->fg); ac++;
2120 XmCreateRowColumn (box_data->switch_form, "switch_rc", al, ac);
2121 XtManageChild (switch_data->rc);
2124 /* Create the switch buttons */
2126 SwitchButtonCreate (switch_data, False);
2129 /* Set the active switch button to the active workspace */
2131 XtSetArg (al[0], XmNset, True);
2132 switch_data->active_switch = current_workspace;
2133 XtSetValues (switch_data->buttons[current_workspace], al, 1);
2136 /* Initialize time stamp for catching multi-click events */
2138 switch_data->time_stamp = 0;
2141 /* Create each of the switch controls and adjust the switch_rc's */
2142 /* constraints to position it properly. */
2144 /* Set up a loop and create each control within the switch */
2146 for (i = 0; i < switch_data->control_data_count; i++)
2148 ControlData * control_data = switch_data->control_data[i];
2149 XmString icon_label = NULL;
2152 ControlSetVisualData (control_data, al, &ac);
2154 XtSetArg (al[ac], XmNpixmapPosition, XmPIXMAP_TOP); ac++;
2158 if (prev_right == NULL)
2160 XtSetArg (al[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
2161 XtSetArg (al[ac], XmNtopOffset, 1); ac++;
2165 XtSetArg (al[ac], XmNtopAttachment, XmATTACH_WIDGET); ac++;
2166 XtSetArg (al[ac], XmNtopWidget, prev_right); ac++;
2169 XtSetArg (al[ac], XmNleftAttachment, XmATTACH_WIDGET); ac++;
2170 XtSetArg (al[ac], XmNleftWidget, switch_data->rc); ac++;
2171 XtSetArg (al[ac], XmNrightAttachment, XmATTACH_FORM); ac++;
2172 XtSetArg (al[ac], XmNrightOffset, 1); ac++;
2176 if (prev_left == NULL)
2178 XtSetArg (al[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
2179 XtSetArg (al[ac], XmNtopOffset, 1); ac++;
2183 XtSetArg (al[ac], XmNtopAttachment, XmATTACH_WIDGET); ac++;
2184 XtSetArg (al[ac], XmNtopWidget, prev_left); ac++;
2187 XtSetArg (al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
2188 XtSetArg (al[ac], XmNleftOffset, 1); ac++;
2191 if (i >= switch_data->control_data_count - 2)
2193 XtSetArg (al[ac], XmNbottomAttachment, XmATTACH_FORM); ac++;
2194 XtSetArg (al[ac], XmNbottomOffset, 1); ac++;
2198 /* Call the function used to set the control's icon and label data */
2200 ControlSetIconData (box_data->switch_form, control_data,
2201 &icon_label, SWITCH, al, &ac, &icon_name,
2205 /* Call the function used to set the control's behavioral aspects */
2207 ControlSetBehavior (control_data, al, &ac, False, &exp_file_name);
2210 /* Call the function used to create and register the control */
2212 control_data->icon =
2213 ControlCreateAndRegister (box_data->switch_form,
2214 control_data, False, al, ac);
2216 if (icon_label != NULL)
2217 XmStringFree (icon_label);
2219 if (icon_name != NULL)
2222 if (alt_icon_name != NULL)
2223 XtFree(alt_icon_name);
2225 if (exp_file_name != NULL)
2226 XtFree(exp_file_name);
2229 prev_right = control_data->icon;
2231 prev_left = control_data->icon;
2235 XtSetArg (al2[0], XmNleftAttachment, XmATTACH_WIDGET);
2236 XtSetArg (al2[1], XmNleftWidget, prev_left);
2237 XtSetArg (al2[2], XmNrightAttachment, XmATTACH_NONE);
2238 XtSetValues (switch_data->rc, al2, 3);
2246 /************************************************************************
2248 * SwitchButtonCreate
2249 * Create either the full set of switch button or one new one.
2251 *************************************************************************/
2254 SwitchButtonCreate (SwitchData * switch_data,
2260 XmPixelSet * pixel_set;
2262 XmString label_string;
2271 /* Find the box data which contains the switch. This is needed */
2272 /* for the switch callback processing. */
2274 box_data = switch_data->box_data;
2276 /* Calculate switch height */
2277 if (!switch_height) {
2278 Dimension ignore_width;
2280 label_string = XmStringCreateLocalized (switch_data->switch_names[0]);
2281 XmStringExtent(panel.font_list,label_string,
2282 &ignore_width,&switch_height);
2283 XmStringFree(label_string);
2284 if (panel.resolution == HIGH || panel.resolution == MEDIUM) {
2285 switch_height += 14;
2286 if (switch_height < SWITCH_HIGH_BUTTON_HEIGHT) {
2287 switch_height = SWITCH_HIGH_BUTTON_HEIGHT;
2291 if (switch_height < SWITCH_LOW_BUTTON_HEIGHT) {
2292 switch_height = SWITCH_LOW_BUTTON_HEIGHT;
2297 /* Create Switch Toggles */
2301 XtSetArg (al[ac], XmNfillOnArm, False); ac++;
2303 if (panel.resolution == HIGH || panel.resolution == MEDIUM)
2305 XtSetArg (al[ac], XmNwidth, SWITCH_HIGH_BUTTON_WIDTH); ac++;
2306 XtSetArg (al[ac], XmNshadowThickness, 3); ac++;
2307 XtSetArg (al[ac], XmNmarginWidth, 4); ac++;
2312 XtSetArg (al[ac], XmNwidth, SWITCH_LOW_BUTTON_WIDTH); ac++;
2313 XtSetArg (al[ac], XmNshadowThickness, 2); ac++;
2314 XtSetArg (al[ac], XmNmarginWidth, 2); ac++;
2318 XtSetArg (al[ac], XmNheight, switch_height); ac++;
2319 XtSetArg (al[ac], XmNbehavior, XmICON_TOGGLE); ac++;
2320 XtSetArg (al[ac], XmNfillMode, XmFILL_SELF); ac++;
2321 XtSetArg (al[ac], XmNalignment, XmALIGNMENT_BEGINNING); ac++;
2322 XtSetArg (al[ac], XmNpixmapPosition, XmPIXMAP_BOTTOM); ac++;
2323 XtSetArg (al[ac], XmNhighlightThickness, 1); ac++;
2324 XtSetArg (al[ac], XmNmarginHeight, 0); ac++;
2325 XtSetArg (al[ac], XmNspacing, 0); ac++;
2326 XtSetArg (al[ac], XmNcontrolType, XmCONTROL_SWITCH); ac++;
2327 XtSetArg (al[ac], XmNfontList, panel.font_list); ac++;
2328 XtSetArg (al[ac], XmNrecomputeSize, False); ac++;
2329 XtSetArg (al[ac], XmNuserData, box_data); ac++;
2333 /* Set up a loop to either create a full set of switch buttons */
2334 /* or just one, depending on the input parameters. */
2336 switch_count = switch_data->switch_count;
2338 for (i = 0; i < switch_count; i++)
2340 int pixel_set_index, map_index;
2343 i = switch_count - 1;
2348 /* Set pixel resources. */
2349 switch (panel.color_use)
2351 case XmCO_BLACK_WHITE:
2352 case XmCO_LOW_COLOR:
2353 pixel_set_index = 1;
2356 case XmCO_MEDIUM_COLOR:
2357 pixel_set_index = HARD_CODED_PRIMARY;
2360 case XmCO_HIGH_COLOR:
2361 map_index = i % _WS_HIGH_COLOR_COUNT;
2362 pixel_set_index = _ws_high_color_map[map_index];
2366 pixel_set = &panel.pixel_set[pixel_set_index - 1];
2368 XtSetArg (al[ac], XmNforeground, pixel_set->fg); ac++;
2369 XtSetArg (al[ac], XmNbackground, pixel_set->bg); ac++;
2370 XtSetArg (al[ac], XmNarmColor, pixel_set->bg); ac++;
2371 XtSetArg (al[ac], XmNfillOnArm, False); ac++;
2373 if (panel.color_use == XmCO_BLACK_WHITE)
2375 XtSetArg (al[ac], XmNuseEmbossedText, False); ac++;
2376 XtSetArg (al[ac], XmNpixmapBackground,
2377 WhitePixelOfScreen (XtScreen (panel.form))); ac++;
2378 XtSetArg (al[ac], XmNpixmapForeground,
2379 BlackPixelOfScreen (XtScreen (panel.form))); ac++;
2383 XtSetArg (al[ac], XmNpixmapBackground, pixel_set->ts); ac++;
2384 XtSetArg (al[ac], XmNpixmapForeground, pixel_set->bs); ac++;
2390 label_string = XmStringCreateLocalized (switch_data->switch_names[i]);
2391 XtSetArg (al[ac], XmNstring, label_string); ac++;
2394 switch_data->buttons[i] =
2395 _DtCreateControl (switch_data->rc, "toggle", al, ac);
2397 XtManageChild (switch_data->buttons[i]);
2399 XtAddCallback (switch_data->buttons[i], XmNcallback,
2400 (XtCallbackProc) SwitchButtonCB, NULL);
2402 XtAddCallback (switch_data->buttons[i], XmNhelpCallback,
2403 (XtCallbackProc) GeneralTopicHelpCB, SWITCH_BUTTON);
2405 XmStringFree (label_string);
2412 /************************************************************************
2416 ************************************************************************/
2419 ControlCreate (Widget parent,
2420 ControlData ** control_data,
2428 Widget prev_icon = NULL;
2430 char * icon_name = NULL;
2431 char * alt_icon_name = NULL;
2432 String exp_file_name = NULL;
2433 XmString icon_label = NULL;
2436 /* Set up a loop and create each control within the box */
2438 for (i = 0; i < control_count; i++)
2441 ControlSetVisualData (control_data[i], al, &ac);
2443 XtSetArg (al[ac], XmNpixmapPosition, XmPIXMAP_TOP); ac++;
2445 XtSetArg (al[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
2446 XtSetArg (al[ac], XmNtopOffset, 1); ac++;
2447 XtSetArg (al[ac], XmNbottomAttachment, XmATTACH_FORM); ac++;
2448 XtSetArg (al[ac], XmNbottomOffset, 1); ac++;
2450 if (prev_icon == NULL)
2452 XtSetArg (al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
2453 XtSetArg (al[ac], XmNleftOffset, 1); ac++;
2457 XtSetArg (al[ac], XmNleftAttachment, XmATTACH_WIDGET); ac++;
2458 XtSetArg (al[ac], XmNleftWidget, prev_icon); ac++;
2461 if (i == control_count - 1)
2463 XtSetArg (al[ac], XmNrightAttachment, XmATTACH_FORM); ac++;
2464 XtSetArg (al[ac], XmNrightOffset, 1); ac++;
2468 /* Call the function used to set the control's icon and label data */
2470 ControlSetIconData (parent, control_data[i], &icon_label, BOX, al, &ac,
2471 &icon_name, &alt_icon_name);
2474 /* Call the function used to set the control's behavioral aspects */
2476 ControlSetBehavior (control_data[i], al, &ac, False, &exp_file_name);
2479 /* Call the function used to create and register the control */
2481 control_data[i]->icon =
2482 ControlCreateAndRegister (parent, control_data[i], False, al, ac);
2484 if (icon_label != NULL)
2486 XmStringFree (icon_label);
2490 if (icon_name != NULL)
2496 if (alt_icon_name != NULL)
2498 XtFree(alt_icon_name);
2499 alt_icon_name = NULL;
2502 if (exp_file_name != NULL)
2504 XtFree(exp_file_name);
2505 exp_file_name = NULL;
2508 prev_icon = control_data[i]->icon;
2510 if (control_data[i]->subpanel_data != NULL)
2511 SubpanelCreate (control_data[i], control_data[i]->subpanel_data);
2518 /************************************************************************
2522 ************************************************************************/
2525 ArrowCreate (Widget parent,
2526 ControlData ** control_data,
2534 Widget prev_separator = NULL;
2542 Dimension control_width;
2546 /* If there is no arrow form (there are no subpanels for the controls) */
2547 /* then the parent widget will be null so just return. */
2555 XtSetArg (al[ac], XmNtopOffset, 0); ac++;
2556 XtSetArg (al[ac], XmNbottomOffset, 0); ac++;
2560 XtSetArg (al[ac], XmNtopOffset, 1); ac++;
2561 XtSetArg (al[ac], XmNbottomOffset, 1); ac++;
2565 XtSetArg (al[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
2566 XtSetArg (al[ac], XmNbottomAttachment, XmATTACH_FORM); ac++;
2567 XtSetArg (al[ac], XmNbackground, panel.inactive_pixel_set->bg); ac++;
2568 XtSetArg (al[ac], XmNforeground, panel.inactive_pixel_set->fg); ac++;
2569 XtSetArg (al[ac], XmNtopShadowColor, panel.inactive_pixel_set->ts); ac++;
2570 XtSetArg (al[ac], XmNbottomShadowColor, panel.inactive_pixel_set->bs); ac++;
2571 XtSetArg (al[ac], XmNselectColor, panel.inactive_pixel_set->sc); ac++;
2572 XtSetArg (al[ac], XmNhighlightThickness, 1); ac++;
2573 XtSetArg (al[ac], XmNshadowThickness, 0); ac++;
2575 if (panel.color_use == XmCO_BLACK_WHITE)
2577 pixmap = XmGetPixmap (XtScreen (panel.form), "50_foreground",
2578 panel.inactive_pixel_set->fg,
2579 panel.inactive_pixel_set->bg);
2581 XtSetArg (al[ac], XmNbackgroundPixmap, pixmap); ac++;
2587 XtSetArg (al2[ac2], XmNtopAttachment, XmATTACH_FORM); ac2++;
2588 XtSetArg (al2[ac2], XmNtopOffset, 0); ac2++;
2589 XtSetArg (al2[ac2], XmNbottomAttachment, XmATTACH_FORM); ac2++;
2590 XtSetArg (al2[ac2], XmNbottomOffset, 0); ac2++;
2591 XtSetArg (al2[ac2], XmNbackground, panel.inactive_pixel_set->bg); ac2++;
2592 XtSetArg (al2[ac2], XmNforeground, panel.inactive_pixel_set->fg); ac2++;
2593 XtSetArg (al2[ac2], XmNtopShadowColor, panel.inactive_pixel_set->ts);ac2++;
2594 XtSetArg (al2[ac2], XmNbottomShadowColor, panel.inactive_pixel_set->bs); ac2++;
2595 XtSetArg (al2[ac2], XmNshadowThickness, 2); ac2++;
2596 XtSetArg (al2[ac2], XmNorientation, XmVERTICAL); ac2++;
2600 for (i = 0; i < arrow_count; i++)
2605 if (prev_separator == NULL)
2607 XtSetArg (al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
2610 XtSetArg (al[ac], XmNleftOffset, 0); ac++;
2614 XtSetArg (al[ac], XmNleftOffset, 1); ac++;
2619 XtSetArg (al[ac], XmNleftAttachment, XmATTACH_WIDGET); ac++;
2620 XtSetArg (al[ac], XmNleftWidget, prev_separator); ac++;
2623 control_width = XtWidth (control_data[i]->icon);
2626 if (i == 0 && right_side == True)
2628 else if (i == 0 && right_side == False)
2633 if (i == 0 && first_box == False)
2636 XtSetArg (al[ac], XmNwidth, control_width); ac++;
2638 if (control_data[i]->subpanel_data == NULL)
2640 XtSetArg (al[ac], XmNimageName, blank_arrow_image); ac++;
2644 if ((intptr_t) (control_data[i]->
2645 element_values[CONTROL_MONITOR_TYPE].parsed_value) != MONITOR_NONE)
2647 if (CheckOtherMonitorsOn(control_data[i]->subpanel_data))
2649 XtSetArg (al[ac], XmNimageName, post_monitor_arrow_image); ac++;
2653 XtSetArg (al[ac], XmNimageName, post_arrow_image); ac++;
2658 XtSetArg (al[ac], XmNimageName, post_arrow_image); ac++;
2662 XtSetArg (al[ac], XmNmultiClick, XmMULTICLICK_DISCARD); ac++;
2664 control_data[i]->arrow =
2665 DtCreateButtonGadget (parent, "arrow", al, ac);
2667 XtManageChild (control_data[i]->arrow);
2669 if (control_data[i]->subpanel_data == NULL)
2670 XtSetSensitive (control_data[i]->arrow, False);
2672 XtAddCallback (control_data[i]->arrow, XmNcallback,
2674 (XtPointer) control_data[i]);
2676 if (i < arrow_count - 1)
2678 XtSetArg (al2[ac2], XmNleftAttachment, XmATTACH_WIDGET); ac2++;
2679 XtSetArg (al2[ac2], XmNleftWidget, control_data[i]->arrow); ac2++;
2681 if (i == 0 && right_side == False)
2683 XtSetArg (al2[ac2], XmNleftOffset, 1); ac2++;
2685 else if (i == 0 && right_side == True)
2687 XtSetArg (al2[ac2], XmNleftOffset, 3); ac2++;
2691 XtSetArg (al2[ac2], XmNleftOffset, 0); ac2++;
2694 control_data[i]->arrow_separator =
2695 XmCreateSeparatorGadget (parent, "arrow_separator", al2, ac2);
2696 XtManageChild (control_data[i]->arrow_separator);
2698 prev_separator = control_data[i]->arrow_separator;
2706 /************************************************************************
2710 ************************************************************************/
2713 SubpanelCreate (ControlData * main_control_data,
2714 SubpanelData * subpanel_data)
2718 DtPanelShellWidget subpanel_shell;
2719 char * subpanel_name = (char *) subpanel_data->element_values[SUBPANEL_TITLE].parsed_value;
2720 XmString icon_label;
2722 ControlData * control_data;
2723 Widget attach_widget;
2724 Boolean control_install;
2725 Boolean monitor = False;
2726 Boolean main = False;
2738 /* Create the subpanel shell. */
2741 XtSetArg (al[ac], XmNallowShellResize, True); ac++;
2742 XtSetArg (al[ac], XmNmwmDecorations, MWM_DECOR_MENU | MWM_DECOR_TITLE); ac++;
2743 XtSetArg (al[ac], XmNtitle, subpanel_name); ac++;
2745 subpanel_data->shell =
2746 XtCreatePopupShell (subpanel_name, xmDialogShellWidgetClass,
2747 panel.shell, al, ac);
2749 XtSetMappedWhenManaged (subpanel_data->shell, False);
2752 /* Set pixel resources. */
2755 XtSetArg (al[ac], XmNforeground, panel.primary_pixel_set->fg); ac++;
2756 XtSetArg (al[ac], XmNbackground, panel.primary_pixel_set->bg); ac++;
2757 XtSetArg (al[ac], XmNtopShadowColor, panel.primary_pixel_set->ts); ac++;
2758 XtSetArg (al[ac], XmNbottomShadowColor, panel.primary_pixel_set->bs);ac++;
2759 XtSetArg (al[ac], XmNselectColor, panel.primary_pixel_set->sc); ac++;
2761 if (panel.color_use == XmCO_BLACK_WHITE)
2763 XtSetArg (al[ac], XmNuseEmbossedText, False); ac++;
2764 XtSetArg (al[ac], XmNarmColor, panel.primary_pixel_set->bg); ac++;
2765 XtSetArg (al[ac], XmNpixmapBackground,
2766 WhitePixelOfScreen (XtScreen (panel.form))); ac++;
2767 XtSetArg (al[ac], XmNpixmapForeground,
2768 BlackPixelOfScreen (XtScreen (panel.form))); ac++;
2771 if (panel.color_use == XmCO_LOW_COLOR)
2773 XtSetArg (al[ac], XmNpixmapBackground,
2774 WhitePixelOfScreen (XtScreen (panel.form))); ac++;
2775 XtSetArg (al[ac], XmNpixmapForeground, panel.primary_pixel_set->bg); ac++;
2776 XtSetArg (al[ac], XmNpixmapForeground, panel.primary_pixel_set->bg); ac++;
2781 XtSetArg (al[ac], XmNshadowThickness, 1); ac++;
2784 /* Create the outer form widget that will contain the entire panel */
2786 XtSetArg (al[ac], XmNuserData, SUBPANEL); ac++;
2788 if (panel.color_use == XmCO_BLACK_WHITE)
2790 pixmap = XmGetPixmap (XtScreen (panel.form), "50_foreground",
2791 panel.inactive_pixel_set->fg,
2792 panel.inactive_pixel_set->bg);
2794 XtSetArg (al[ac], XmNbackgroundPixmap, pixmap); ac++;
2797 subpanel_data->form =
2798 XmCreateForm (subpanel_data->shell, subpanel_name, al, ac);
2800 XtManageChild (subpanel_data->form);
2802 XtAddCallback (subpanel_data->form, XmNhelpCallback,
2803 (XtCallbackProc) SubpanelTopicHelpCB, subpanel_data);
2805 if (panel.popup_data == NULL || panel.popup_data->popup == NULL)
2806 CreatePopupMenu (subpanel_data->form);
2808 XmAddToPostFromList (panel.popup_data->popup, subpanel_data->form);
2811 /* Event handler for posting popup menu */
2813 XtAddEventHandler (subpanel_data->form, ButtonPressMask, False,
2814 (XtEventHandler) PostPopupMenu, (XtPointer) NULL);
2817 /* If the value for subpanel control install is true, create */
2818 /* the drop zone as the top child of the form */
2821 (Boolean) (intptr_t) subpanel_data->element_values[SUBPANEL_CONTROL_INSTALL].parsed_value;
2823 if (control_install)
2825 icon_label = XmStringCreateLocalized (GETMESSAGE (84, 1, "Install Icon"));
2828 XtSetArg (al[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
2829 XtSetArg (al[ac], XmNtopOffset, 5); ac++;
2830 XtSetArg (al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
2831 XtSetArg (al[ac], XmNleftOffset, 5); ac++;
2832 XtSetArg (al[ac], XmNrightAttachment, XmATTACH_FORM); ac++;
2833 XtSetArg (al[ac], XmNrightOffset, 5); ac++;
2834 XtSetArg (al[ac], XmNshadowThickness, 2); ac++;
2835 XtSetArg (al[ac], XmNhighlightThickness, 1); ac++;
2836 XtSetArg (al[ac], XmNmarginWidth, 1); ac++;
2837 XtSetArg (al[ac], XmNmarginHeight, 1); ac++;
2838 XtSetArg (al[ac], XmNstring, icon_label); ac++;
2839 XtSetArg (al[ac], XmNpixmapPosition, XmPIXMAP_LEFT); ac++;
2840 XtSetArg (al[ac], XmNbehavior, XmICON_LABEL); ac++;
2841 XtSetArg (al[ac], XmNimageName, dropzone_image); ac++;
2842 XtSetArg (al[ac], XmNuserData, subpanel_data); ac++;
2843 XtSetArg (al[ac], XmNfontList, panel.font_list); ac++;
2844 XtSetArg (al[ac], XmNtraversalOn, False); ac++;
2846 if (panel.color_use == XmCO_BLACK_WHITE)
2848 pixmap = XmGetPixmap (XtScreen (panel.form), "50_foreground",
2849 panel.inactive_pixel_set->fg,
2850 panel.inactive_pixel_set->bg);
2852 XtSetArg (al[ac], XmNbackgroundPixmap, pixmap); ac++;
2855 subpanel_data->dropzone =
2856 _DtCreateControl (subpanel_data->form, "dropzone", al, ac);
2857 XtManageChild (subpanel_data->dropzone);
2858 XmStringFree (icon_label);
2860 XtAddCallback (subpanel_data->dropzone, XmNhelpCallback,
2861 (XtCallbackProc) GeneralTopicHelpCB, INSTALL_ZONE);
2864 /* Set the drop zone for the install area. */
2866 XtSetArg (al2[0], DtNdropAnimateCallback, customizeDropCB);
2867 XtSetArg (al2[1], XmNanimationStyle, XmDRAG_UNDER_SHADOW_IN);
2868 XtSetArg (al2[2], DtNpreserveRegistration, True);
2870 DtDndDropRegister (subpanel_data->dropzone, DtDND_FILENAME_TRANSFER,
2871 XmDROP_COPY, customizeTransferDropCB, al2, 3);
2874 /* Create the separator that goes between the dropzone and controls */
2877 XtSetArg (al[ac], XmNtopAttachment, XmATTACH_WIDGET); ac++;
2878 XtSetArg (al[ac], XmNtopWidget, subpanel_data->dropzone); ac++;
2879 XtSetArg (al[ac], XmNtopOffset, 5); ac++;
2880 XtSetArg (al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
2881 XtSetArg (al[ac], XmNleftOffset, 1); ac++;
2882 XtSetArg (al[ac], XmNrightAttachment, XmATTACH_FORM); ac++;
2883 XtSetArg (al[ac], XmNrightOffset, 1); ac++;
2884 XtSetArg (al[ac], XmNshadowThickness, 2); ac++;
2885 XtSetArg (al[ac], XmNorientation, XmHORIZONTAL); ac++;
2887 subpanel_data->separator =
2888 XmCreateSeparatorGadget (subpanel_data->form,
2889 "subpanel_separator", al, ac);
2890 XtManageChild (subpanel_data->separator);
2894 /* Loop through the control set and see if any of the controls */
2895 /* have monitor files attached to them. If so, the constraints */
2896 /* for the form need to be set appropriately. */
2898 if ((intptr_t) (main_control_data->
2899 element_values[CONTROL_MONITOR_TYPE].parsed_value) != MONITOR_NONE)
2902 if (monitor == False)
2904 for (i = 0; i < subpanel_data->control_data_count; i++)
2906 if ((intptr_t) (subpanel_data->control_data[i]->
2907 element_values[CONTROL_MONITOR_TYPE].parsed_value) != MONITOR_NONE)
2916 if (control_install)
2917 attach_widget = subpanel_data->separator;
2919 attach_widget = subpanel_data->form;
2922 /* Set up a loop and create each control within the subpanel */
2924 for (i = -1; i < subpanel_data->control_data_count; i++)
2928 control_data = main_control_data;
2933 control_data = subpanel_data->control_data[i];
2937 SubpanelControlCreate (subpanel_data, main_control_data, control_data,
2938 attach_widget, main, monitor);
2941 attach_widget = subpanel_data->main_panel_icon_copy;
2943 attach_widget = control_data->icon;
2947 /* Pad the bottom of the last control in the subpanel */
2950 XtSetArg (al[ac], XmNbottomAttachment, XmATTACH_FORM); ac++;
2951 XtSetArg (al[ac], XmNbottomOffset, 5); ac++;
2952 XtSetValues (attach_widget, al, ac);
2955 XtUnmanageChild (subpanel_data->form);
2956 XtSetMappedWhenManaged (subpanel_data->shell, True);
2959 /* Add the callback for handling subpanel unmaps from the system menu */
2961 XtAddCallback (subpanel_data->form, XmNunmapCallback,
2962 (XtCallbackProc) SubpanelUnmapCB,
2963 (XtPointer) main_control_data);
2966 /* Set subpanel posting state variables */
2968 subpanel_data->torn = False;
2971 /* Initialize the subpanels default control setting to the main */
2972 /* panel control. */
2974 subpanel_data->default_control = main_control_data;
2976 /* Set the initial XmNcancelButton resource to the default control */
2977 /* within the subpanel. */
2979 if (subpanel_data->control_data)
2980 XtSetArg (al[0], XmNcancelButton, subpanel_data->control_data[0]->icon);
2982 XtSetArg (al[0], XmNcancelButton, subpanel_data->main_panel_icon_copy);
2984 XtSetValues (subpanel_data->form, al, 1);
2991 /************************************************************************
2993 * SubpanelControlCreate
2994 * Create a control within the subpanel
2996 ************************************************************************/
2999 SubpanelControlCreate (SubpanelData * subpanel_data,
3000 ControlData * main_control_data,
3001 ControlData * control_data,
3002 Widget attach_widget,
3007 XmString icon_label = NULL;
3008 Widget control_icon;
3016 char * icon_name = NULL;
3017 char * alt_icon_name = NULL;
3018 String exp_file_name = NULL;
3021 /* Call the function used to set the control's pixel and font data */
3023 ControlSetVisualData (control_data, al, &ac);
3027 /* Set the control's positioning resources */
3031 XtSetArg (al[ac], XmNleftOffset, 20); ac++;
3035 XtSetArg (al[ac], XmNleftOffset, 5); ac++;
3039 XtSetArg (al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
3040 XtSetArg (al[ac], XmNtopAttachment, XmATTACH_WIDGET); ac++;
3041 XtSetArg (al[ac], XmNtopWidget, attach_widget); ac++;
3042 XtSetArg (al[ac], XmNtopOffset, 5); ac++;
3043 XtSetArg (al[ac], XmNrightAttachment, XmATTACH_FORM); ac++;
3044 XtSetArg (al[ac], XmNrightOffset, 5); ac++;
3045 XtSetArg (al[ac], XmNmarginWidth, 1); ac++;
3046 XtSetArg (al[ac], XmNmarginHeight, 1); ac++;
3049 /* Call the function used to set the control's icon and label data */
3051 ControlSetIconData (subpanel_data->form, control_data,
3052 &icon_label, SUBPANEL, al, &ac,
3053 &icon_name, &alt_icon_name);
3056 /* Call the function used to set the control's behavioral aspects */
3058 ControlSetBehavior (control_data, al, &ac, True, &exp_file_name);
3061 /* Call the function used to create and register the control */
3064 ControlCreateAndRegister(subpanel_data->form, control_data, main, al, ac);
3067 subpanel_data->main_panel_icon_copy = control_icon;
3069 control_data->icon = control_icon;
3072 if (icon_label != NULL)
3073 XmStringFree (icon_label);
3075 if (icon_name != NULL)
3078 if (alt_icon_name != NULL)
3079 XtFree(alt_icon_name);
3081 if (exp_file_name != NULL)
3082 XtFree(exp_file_name);
3084 /* If there is a monitor file, create the indicator */
3086 if ((intptr_t) (control_data->
3087 element_values[CONTROL_MONITOR_TYPE].parsed_value) != MONITOR_NONE)
3091 m_state = _DtControlGetMonitorState(control_icon);
3093 XtSetArg (al[ac], XmNleftOffset, 3); ac++;
3094 XtSetArg (al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
3095 XtSetArg (al[ac], XmNtopOffset, 6); ac++;
3096 XtSetArg (al[ac], XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET); ac++;
3097 XtSetArg (al[ac], XmNtopWidget, control_icon); ac++;
3098 XtSetArg (al[ac], XmNhighlightThickness, 0); ac++;
3099 XtSetArg (al[ac], XmNmarginWidth, 1); ac++;
3100 XtSetArg (al[ac], XmNmarginHeight, 1); ac++;
3101 XtSetArg (al[ac], XmNstring, NULL); ac++;
3103 if (m_state == DtMONITOR_ON)
3105 XtSetArg (al[ac], XmNimageName, indicator_on_image); ac++;
3107 else /* DtMONITOR_OFF */
3109 XtSetArg (al[ac], XmNimageName, indicator_off_image); ac++;
3112 control_data->indicator =
3113 _DtCreateControl (subpanel_data->form, "indicator", al, ac);
3114 XtManageChild (control_data->indicator);
3116 XtAddCallback (control_data->indicator, XmNhelpCallback,
3117 (XtCallbackProc) GeneralTopicHelpCB, MONITOR_INDICATOR);
3119 XtSetSensitive (control_data->indicator, False);
3126 /************************************************************************
3128 * UpdateSwitchGeometry
3129 * Updates the geometry of the switch area to layout the switch
3130 * buttons and switch controls appropriately.
3133 * box_data: The box that contains the switch.
3135 ************************************************************************/
3139 UpdateSwitchGeometry (BoxData * box_data)
3144 Dimension switch_rc_height, switch_button_height;
3147 if (box_data->switch_data == NULL) return;
3149 XtSetArg (al[0], XmNheight, &switch_rc_height);
3150 XtGetValues (box_data->switch_data->rc, al, 1);
3152 XtSetArg (al[0], XmNheight, &switch_button_height);
3153 XtGetValues (box_data->switch_data->buttons[0], al, 1);
3155 new_margin = ((int)switch_rc_height -
3156 (int)switch_button_height * panel.switch_row_count) /
3157 (panel.switch_row_count + 1);
3159 if (new_margin < 1) new_margin = 1;
3161 XtSetArg (al[0], XmNmarginHeight, new_margin);
3162 XtSetArg (al[1], XmNspacing, new_margin);
3163 XtSetValues (box_data->switch_data->rc, al, 2);
3169 /************************************************************************
3172 * Create and initialize a new subpanel and attach it to control_data
3175 * control_data: The main panel control to which the subpanel
3178 ************************************************************************/
3181 AddSubpanel (ControlData * control_data)
3185 ElementValue * element_values;
3186 SubpanelData * subpanel_data = NULL;
3187 BoxData * box_data = (BoxData *)control_data->parent_data;
3195 if (control_data->subpanel_data == NULL)
3197 control_data->subpanel_data =
3198 (SubpanelData *) XtMalloc (sizeof (SubpanelData));
3200 subpanel_data = control_data->subpanel_data;
3202 element_values = (ElementValue *) XtMalloc (sizeof(ElementValue) *
3203 SUBPANEL_KEYWORD_COUNT);
3205 for (i = 0; i < SUBPANEL_KEYWORD_COUNT; i++)
3207 (element_values)[i].use_default = True;
3208 (element_values)[i].string_value = NULL;
3209 (element_values)[i].parsed_value = NULL;
3212 element_values[SUBPANEL_NAME].string_value = XtNewString(
3213 control_data->element_values[CONTROL_NAME].parsed_value);
3214 element_values[SUBPANEL_CONTAINER_NAME].string_value = XtNewString(
3215 control_data->element_values[CONTROL_NAME].parsed_value);
3216 if (control_data->element_values[CONTROL_LABEL].parsed_value != NULL)
3217 element_values[SUBPANEL_TITLE].string_value = XtNewString(
3218 control_data->element_values[CONTROL_LABEL].parsed_value);
3220 element_values[SUBPANEL_TITLE].string_value = XtNewString(
3221 control_data->element_values[CONTROL_NAME].parsed_value);
3223 subpanel_data->control_data = NULL;
3224 subpanel_data->control_data_count = 0;
3225 subpanel_data->parent_control_data = control_data;
3227 InitializeSubpanelFields (element_values);
3229 subpanel_data->element_values = element_values;
3232 if (!XtIsManaged(XtParent(control_data->arrow)))
3235 if (box_data->left_arrow_form)
3237 XtSetArg (al[0], XmNtopAttachment, XmATTACH_WIDGET);
3238 XtSetArg (al[1], XmNtopWidget, box_data->left_arrow_form);
3239 XtSetValues(box_data->left_control_form, al, 2);
3241 XtManageChild(box_data->left_arrow_form);
3244 if (box_data->right_arrow_form)
3246 XtManageChild(box_data->right_arrow_form);
3248 XtSetArg (al[0], XmNtopAttachment, XmATTACH_WIDGET);
3249 XtSetArg (al[1], XmNtopWidget, box_data->right_arrow_form);
3250 XtSetValues(box_data->right_control_form, al, 2);
3253 UpdateSwitchGeometry(box_data);
3257 box_data->subpanel_count++;
3260 SubpanelCreate (control_data, subpanel_data);
3264 XtSetArg (al[0], XmNimageName, post_arrow_image);
3265 XtSetArg (al[1], XmNsensitive, True);
3266 XtSetValues (control_data->arrow, al, 2);
3268 /* Set the subpanels hint and transient behavior */
3270 vHints.flags = DtWM_HINTS_BEHAVIORS | DtWM_HINTS_ATTACH_WINDOW;
3271 vHints.behaviors = DtWM_BEHAVIOR_PANEL | DtWM_BEHAVIOR_SUBPANEL;
3272 vHints.attachWindow = XtWindow (panel.shell);
3274 XtSetArg (al[0], XmNtransientFor, panel.shell);
3275 XtSetValues (subpanel_data->shell, al, 1);
3277 XtRealizeWidget (subpanel_data->form);
3278 _DtWsmSetDtWmHints (XtDisplay (panel.shell),
3279 XtWindow (subpanel_data->shell), &vHints);
3281 WriteSubpanelComponentFile(control_data->subpanel_data);
3287 /************************************************************************
3290 * Remove a control upon a menu request for deletion.
3292 * Inputs: control_data - a pointer to the control to be deleted.
3294 ************************************************************************/
3298 DeleteControl (ControlData * control_data)
3305 /* Remove the control from the push recall and embedded client list. */
3307 PushRecallRegister (control_data, False);
3309 EmbeddedClientRegister (control_data, False);
3312 /* Destroy the widgets allocated by the control */
3314 if (control_data->indicator)
3315 XtDestroyWidget (control_data->indicator);
3317 if (control_data->icon)
3319 if (control_data->element_values[CONTROL_DROP_ACTION].parsed_value
3321 DtDndDropUnregister(control_data->icon);
3322 XtDestroyWidget (control_data->icon);
3326 /* Remove the copy of the action set and delete the element values */
3328 DeleteControlActionList (control_data);
3330 RemoveEntry ((RecordData *)control_data, CONTROL);
3336 /************************************************************************
3339 * Delete the subpanel attached to the control pointed to by
3342 * Inputs: control_data - a pointer to the main panel control that the
3343 * subpanel is attached to.
3345 ************************************************************************/
3349 DeleteSubpanel (ControlData * control_data)
3353 SubpanelData * subpanel_data = control_data->subpanel_data;
3354 BoxData * box_data = (BoxData *) control_data->parent_data;
3359 /* If the current main control is not within the main panel, call */
3360 /* the DeleteSubpanelControl function to delete the main control */
3361 /* This will cause the current subpanel control within the main */
3362 /* panel to be promoted to a main panel control. */
3364 if (subpanel_data->parent_control_data != control_data)
3366 subpanel_data->torn = True;
3367 DeleteSubpanelControl (subpanel_data, subpanel_data->parent_control_data);
3368 subpanel_data->parent_control_data->subpanel_data = NULL;
3372 /* Set the main panel control's arrow to blank and insensitive */
3374 XtSetArg (al[0], XmNimageName, blank_arrow_image);
3375 XtSetValues (subpanel_data->parent_control_data->arrow, al, 1);
3376 XtSetSensitive (subpanel_data->parent_control_data->arrow, False);
3379 /* Either remove a dynamic .fp or write out the subpanel's .fp */
3380 /* with the DELETE keyword set */
3382 RemoveSubpanelComponentFile (subpanel_data);
3385 /* Delete the controls within the subpanel, destroy the remaining */
3386 /* widgets and free up the remaining data. */
3388 for (i = 0; i < subpanel_data->control_data_count; i++)
3390 RemoveControlComponentFile (subpanel_data->control_data[i]);
3391 DeleteControl (subpanel_data->control_data[i]);
3392 XtFree ((char *) subpanel_data->control_data[i]);
3395 /* Remove install zones */
3396 if (subpanel_data->element_values[SUBPANEL_CONTROL_INSTALL].parsed_value)
3398 DtDndDropUnregister (subpanel_data->dropzone);
3399 XtDestroyWidget (subpanel_data->dropzone);
3402 XtDestroyWidget (subpanel_data->shell);
3403 XtFree ((char *) subpanel_data->control_data);
3405 RemoveEntry ((RecordData *)subpanel_data, SUBPANEL);
3407 XtFree ((char *) subpanel_data);
3408 control_data->subpanel_data = NULL;
3410 box_data->subpanel_count--;
3412 if (box_data->subpanel_count == 0)
3414 if (box_data->left_arrow_form)
3416 XtSetArg (al[0], XmNtopAttachment, XmATTACH_FORM);
3417 XtSetArg (al[1], XmNtopOffset, 0);
3418 XtSetValues(box_data->left_control_form, al, 2);
3420 XtUnmanageChild(box_data->left_arrow_form);
3423 if (box_data->right_arrow_form)
3425 XtUnmanageChild(box_data->right_arrow_form);
3427 XtSetArg (al[0], XmNtopAttachment, XmATTACH_FORM);
3428 XtSetArg (al[1], XmNtopOffset, 0);
3429 XtSetValues(box_data->right_control_form, al, 2);
3432 UpdateSwitchGeometry(box_data);
3439 /************************************************************************
3442 * Exchange the values between two element value structures.
3444 * Inputs: to_value, from_value - pointer to the two element value
3445 * structures in which to exchange the values.
3447 ************************************************************************/
3451 SwapElementValue (ElementValue * to_value,
3452 ElementValue * from_value)
3456 Boolean use_default;
3457 char * string_value;
3458 void * parsed_value;
3460 use_default = from_value->use_default;
3461 string_value = from_value->string_value;
3462 parsed_value = from_value->parsed_value;
3464 from_value->use_default = to_value->use_default;
3465 from_value->string_value = to_value->string_value;
3466 from_value->parsed_value = to_value->parsed_value;
3468 to_value->use_default = use_default;
3469 to_value->string_value = string_value;
3470 to_value->parsed_value = parsed_value;
3476 /************************************************************************
3478 * DeleteSubpanelControl
3479 * This function removes a control contained in control_data from
3483 * subpanel_data: The subpanel the control is being deleted from
3484 * control_data: The control to be deleted
3486 ************************************************************************/
3490 DeleteSubpanelControl (SubpanelData * subpanel_data,
3491 ControlData * control_data)
3495 ControlData * main_control_data = subpanel_data->parent_control_data;
3496 int control_data_count;
3498 Widget * child_list;
3500 Widget attach_widget = NULL;
3501 Widget target_widget = NULL;
3502 Boolean last = False;
3505 Boolean control_monitor;
3511 /* Put the subpanel down before mucking with the widget hierarchy */
3513 if (subpanel_data->torn == False)
3514 XtUnmanageChild (subpanel_data->shell);
3517 /* There are 3 deletion cases. */
3518 /* 1. Deletion of the main panel copy when there are 0 subpanel */
3519 /* controls. This involves destroying the copy and deleting */
3522 /* 2. Deletion of the main panel copy when there is subpanel */
3523 /* controls. This involves the full deletion of the main */
3524 /* panel control and the promotion of a subpanel control to */
3525 /* a full main panel control. */
3527 /* 3. Deletion of a subpanel control. This involves the full */
3528 /* deletion of the subpanel control and if it has been */
3529 /* toggled to the main panel another control is selected */
3531 control_data_count = subpanel_data->control_data_count;
3533 if (main_control_data == control_data && control_data_count == 0)
3535 DeleteSubpanel (main_control_data);
3540 /* Look through the controls parent (form) child list to get */
3541 /* the position of the control to be deleted and the previous */
3542 /* and next control. This is needed for resetting constraints */
3544 if (main_control_data == control_data)
3546 height = XtHeight (subpanel_data->main_panel_icon_copy);
3547 XtSetArg (al[0], XmNtopWidget, &target_widget);
3548 XtGetValues (subpanel_data->main_panel_icon_copy, al, 1);
3552 height = XtHeight (control_data->icon);
3553 XtSetArg (al[0], XmNtopWidget, &target_widget);
3554 XtGetValues (control_data->icon, al, 1);
3557 XtSetArg (al[0], XmNchildren, &child_list);
3558 XtSetArg (al[1], XmNnumChildren, &num_children);
3559 XtGetValues (subpanel_data->form, al, 2);
3561 for (i = 0; i < num_children; i++)
3563 XtSetArg (al[0], XmNtopWidget, &attach_widget);
3564 XtGetValues (child_list[i], al, 1);
3566 if ((main_control_data == control_data &&
3567 attach_widget == subpanel_data->main_panel_icon_copy) ||
3568 (main_control_data != control_data &&
3569 attach_widget == control_data->icon))
3571 attach_widget = child_list[i];
3576 if (i == num_children)
3578 attach_widget = NULL;
3583 if (main_control_data == control_data)
3585 ControlData * subpanel_control_data;
3586 int subpanel_control_position;
3589 if (main_control_data == subpanel_data->default_control)
3590 ToggleDefaultControl (main_control_data, subpanel_data,
3591 subpanel_data->control_data[0]);
3593 subpanel_control_data = subpanel_data->default_control;
3596 /* Remove the .fp or write a Delete .fp for both the main panel */
3597 /* control and subpanel control. The subpanel data will then */
3598 /* be moved the the main panel data and the new control will be */
3601 /* For the main panel control, if a dynamic .fp exists, remove */
3602 /* it otherwize, do nothing since a new one will be written. */
3604 if (SessionFileNameLookup ((char *) main_control_data->element_values[CONTROL_NAME].parsed_value,
3606 (char *) main_control_data->element_values[CONTROL_CONTAINER_NAME].parsed_value,
3608 RemoveControlComponentFile (main_control_data);
3610 RemoveControlComponentFile (subpanel_control_data);
3613 /* Find the position of the subpanel control data */
3614 /* within their parent list, for latter processing */
3616 for (subpanel_control_position = 0;
3617 subpanel_control_position < subpanel_data->control_data_count;
3618 subpanel_control_position++)
3620 if (subpanel_data->control_data[subpanel_control_position] == subpanel_control_data)
3625 /* Reset the subpanel values that were switch from the deleted */
3626 /* main control when ToggleDefaultControl was called above. */
3628 XtDestroyWidget (subpanel_data->main_panel_icon_copy);
3629 subpanel_data->main_panel_icon_copy = subpanel_control_data->icon;
3630 subpanel_data->default_control = main_control_data;
3633 /* Move the necessary data from the MP control to the SP control */
3634 /* and write out the new control file. */
3636 SwapElementValue (&subpanel_control_data->element_values[CONTROL_NAME],
3637 &main_control_data->element_values[CONTROL_NAME]);
3638 SwapElementValue (&subpanel_control_data->element_values[CONTROL_CONTAINER_NAME],
3639 &main_control_data->element_values[CONTROL_CONTAINER_NAME]);
3640 SwapElementValue (&subpanel_control_data->element_values[CONTROL_CONTAINER_TYPE],
3641 &main_control_data->element_values[CONTROL_CONTAINER_TYPE]);
3642 SwapElementValue (&subpanel_control_data->element_values[CONTROL_POSITION_HINTS],
3643 &main_control_data->element_values[CONTROL_POSITION_HINTS]);
3645 WriteControlComponentFile (subpanel_control_data);
3648 /* Delete the main panel control. Null out the icon field */
3649 /* since it is being used within the subpanel_control_data. */
3651 subpanel_control_data->icon = main_control_data->icon;
3652 main_control_data->icon = NULL;
3653 DeleteControl (main_control_data);
3656 /* Set the main control to the subpanel control values */
3658 main_control_data->element_values = subpanel_control_data->element_values;
3659 main_control_data->icon = subpanel_control_data->icon;
3660 main_control_data->indicator = subpanel_control_data->indicator;
3661 main_control_data->actions = subpanel_control_data->actions;
3664 /* Remove and readd the callbacks from the main control and */
3665 /* the main panel icon copy. */
3667 XtRemoveCallback (main_control_data->icon, XmNcallback,
3668 (XtCallbackProc) PushCB, subpanel_control_data);
3670 XtRemoveCallback (main_control_data->icon, XmNhelpCallback,
3671 (XtCallbackProc) ControlTopicHelpCB, subpanel_control_data);
3673 XtAddCallback (main_control_data->icon, XmNcallback,
3674 (XtCallbackProc) PushCB, main_control_data);
3676 XtAddCallback (main_control_data->icon, XmNhelpCallback,
3677 (XtCallbackProc) ControlTopicHelpCB, main_control_data);
3680 XtRemoveCallback (subpanel_data->main_panel_icon_copy, XmNcallback,
3681 (XtCallbackProc) PushCB, subpanel_control_data);
3683 XtRemoveCallback (subpanel_data->main_panel_icon_copy, XmNhelpCallback,
3684 (XtCallbackProc) ControlTopicHelpCB, subpanel_control_data);
3686 XtAddCallback (subpanel_data->main_panel_icon_copy, XmNcallback,
3687 (XtCallbackProc) PushCB, main_control_data);
3689 XtAddCallback (subpanel_data->main_panel_icon_copy, XmNhelpCallback,
3690 (XtCallbackProc) ControlTopicHelpCB, main_control_data);
3694 /* Move the subpanel control data's up one position within the */
3695 /* subpanel's list to denote the removal of the subpanel control */
3696 /* and free up the remaining subpanel data. */
3698 for (i = subpanel_control_position; i < subpanel_data->control_data_count - 1; i++)
3699 subpanel_data->control_data[i] = subpanel_data->control_data[i + 1];
3701 subpanel_data->control_data_count--;
3703 XtFree ((char *) subpanel_control_data);
3706 if (subpanel_data->control_data_count == 0)
3708 XtFree ((char *) subpanel_data->control_data);
3709 subpanel_data->control_data = NULL;
3714 /* Call a function which either unlinks the dynamic .fp file or */
3715 /* writes a Delete = True dynamic .fp file. The function also */
3716 /* updates the session tables. */
3718 RemoveControlComponentFile (control_data);
3721 for (i = 0; i < subpanel_data->control_data_count; i++)
3723 if (control_data == subpanel_data->control_data[i]) break;
3726 if (subpanel_data->default_control == control_data)
3728 if (i < subpanel_data->control_data_count - 1)
3730 ToggleDefaultControl (main_control_data, subpanel_data,
3731 subpanel_data->control_data[i + 1]);
3736 ToggleDefaultControl (main_control_data, subpanel_data,
3737 subpanel_data->control_data[i - 1]);
3738 else if (subpanel_data->main_panel_icon_copy != NULL)
3739 ToggleDefaultControl (main_control_data, subpanel_data,
3744 DeleteControl (control_data);
3746 /* Loop through the control list and move the controls down */
3749 for (j = i + 1 ; j < subpanel_data->control_data_count; j++)
3751 subpanel_data->control_data[j - 1] = subpanel_data->control_data[j];
3754 subpanel_data->control_data_count--;
3758 /* If the subpanel is empty, delete it. */
3760 if (subpanel_data->main_panel_icon_copy == NULL &&
3761 subpanel_data->control_data_count == 0)
3763 DeleteSubpanel (subpanel_data->parent_control_data);
3768 /* Get the control positioning constraints reset */
3770 if (attach_widget != NULL && target_widget != NULL)
3772 XtSetArg (al[0], XmNtopWidget, target_widget);
3773 XtSetValues (attach_widget, al, 1);
3778 XtSetArg (al[0], XmNbottomAttachment, XmATTACH_FORM);
3779 XtSetArg (al[1], XmNbottomOffset, 5);
3780 XtSetValues (target_widget, al, 2);
3782 XtSetArg (al[0], XmNheight, XtHeight (subpanel_data->form) -
3783 (XtHeight (target_widget) - height));
3784 XtSetValues (subpanel_data->form, al, 1);
3788 /* Loop through the remaining controls and see if any left are */
3789 /* monitors. If not, adjust the left pad of the controls */
3791 control_monitor = False;
3793 for (j = 0; j < subpanel_data->control_data_count; j++)
3795 if ((intptr_t) subpanel_data->control_data[j]->
3796 element_values[CONTROL_MONITOR_TYPE].parsed_value != MONITOR_NONE)
3798 control_monitor = True;
3803 if ((intptr_t) main_control_data->
3804 element_values[CONTROL_MONITOR_TYPE].parsed_value != MONITOR_NONE)
3806 control_monitor = True;
3809 if (control_monitor == False)
3811 XtSetArg (al[0], XmNleftOffset, 5);
3813 for (j = 0; j < subpanel_data->control_data_count; j++)
3814 XtSetValues (subpanel_data->control_data[j]->icon, al, 1);
3816 if (subpanel_data->main_panel_icon_copy != NULL)
3817 XtSetValues (subpanel_data->main_panel_icon_copy, al, 1);
3821 /* Pop the subpanel back up and resume processing */
3823 if (subpanel_data->torn == False)
3824 ArrowCB (main_control_data->arrow,
3825 (XtPointer)main_control_data, (XtPointer)NULL);
3827 /* Set the XmNcancelButton resource to the default control */
3828 /* within the subpanel. */
3830 if (subpanel_data->control_data)
3831 XtSetArg (al[0], XmNcancelButton, subpanel_data->control_data[0]->icon);
3833 XtSetArg (al[0], XmNcancelButton, subpanel_data->main_panel_icon_copy);
3835 XtSetValues (subpanel_data->form, al, 1);
3842 /************************************************************************
3844 * ToggleDefaultControl
3845 * This is used to switch the main panel control to the control
3846 * attached to the selected toggle.
3849 * main_control_data - a pointer to the main panel's control data.
3850 * subpanel_data - a pointer to the subpanel where the control to
3851 * be put in the main panel is coming from.
3852 * control_data - a pointer to the control in the subpanel to be
3853 * toggled into the main panel.
3855 ************************************************************************/
3859 ToggleDefaultControl (ControlData * main_control_data,
3860 SubpanelData * subpanel_data,
3861 ControlData * control_data)
3867 Widget prev_icon = NULL;
3868 Widget next_icon = NULL;
3869 Widget old_main_icon = main_control_data->icon;
3870 Widget main_subpanel_icon;
3871 Widget parent = XtParent (old_main_icon);
3872 Widget control_icon;
3874 char * icon_name = NULL;
3875 char * alt_icon_name = NULL;
3876 String exp_file_name = NULL;
3879 XmString icon_label = NULL;
3882 Dimension new_width;
3889 /* If the selection occurred on the currently selected toggle */
3892 if (subpanel_data->default_control == control_data)
3896 /* Update the main panel control's push recall and embedded client */
3897 /* lists, and reparent the embedded client if necessary. */
3899 if (main_control_data == subpanel_data->default_control)
3901 control_icon = main_control_data->icon;
3902 main_control_data->icon = subpanel_data->main_panel_icon_copy;
3904 if ((intptr_t) main_control_data->element_values[CONTROL_PUSH_RECALL].parsed_value)
3905 PushRecallRegister (main_control_data, True);
3907 if ((intptr_t) main_control_data->element_values[CONTROL_TYPE].parsed_value == CONTROL_CLIENT)
3908 EmbeddedClientRegister (main_control_data, True);
3910 main_control_data->icon = control_icon;
3912 if ((intptr_t) main_control_data->
3913 element_values[CONTROL_TYPE].parsed_value == CONTROL_CLIENT)
3915 EmbeddedClientReparent ((char *) main_control_data->
3916 element_values[CONTROL_CLIENT_NAME].parsed_value,
3917 subpanel_data->main_panel_icon_copy);
3922 if ((intptr_t) subpanel_data->default_control->element_values[CONTROL_PUSH_RECALL].parsed_value)
3923 PushRecallRegister (subpanel_data->default_control, True);
3925 if ((intptr_t) subpanel_data->default_control->element_values[CONTROL_TYPE].parsed_value == CONTROL_CLIENT)
3926 EmbeddedClientRegister (subpanel_data->default_control, True);
3928 if ((intptr_t) subpanel_data->default_control->
3929 element_values[CONTROL_TYPE].parsed_value == CONTROL_CLIENT)
3931 EmbeddedClientReparent ((char *) subpanel_data->default_control->
3932 element_values[CONTROL_CLIENT_NAME].parsed_value,
3933 subpanel_data->default_control->icon);
3938 subpanel_data->default_control = control_data;
3939 control_data->subpanel_data = subpanel_data;
3940 main_control_data->is_action = control_data->is_action;
3943 /* Get the width of the current main control to be used to */
3944 /* possible adjust the new control when it is created. */
3946 width = XtWidth (main_control_data->icon);
3949 /* Disallow geometry changes of the main control's parent until */
3950 /* after the controls have been destroyed and created */
3952 XtSetArg (al[0], XmNresizePolicy, XmRESIZE_NONE);
3953 XtSetValues (parent, al, 1);
3956 /* Create the new control using the control data from the */
3957 /* control within the subpanel */
3959 /* Loop through the main controls parent data (box_data) to */
3960 /* find its position relative to controls around it */
3962 box_data = (BoxData *) main_control_data->parent_data;
3964 for (i = 0; i < box_data->control_data_count; i++)
3966 if (box_data->control_data[i] == main_control_data)
3969 prev_icon = box_data->control_data[i - 1]->icon;
3971 if (i != box_data->control_data_count - 1)
3972 next_icon = box_data->control_data[i + 1]->icon;
3979 /* Call the function used to set the control's pixel and font data */
3982 ControlSetVisualData (control_data, al, &ac);
3984 XtSetArg (al[ac], XmNpixmapPosition, XmPIXMAP_TOP); ac++;
3987 /* Set up the attachment constraints for the control */
3989 XtSetArg (al[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
3990 XtSetArg (al[ac], XmNtopOffset, 1); ac++;
3991 XtSetArg (al[ac], XmNbottomAttachment, XmATTACH_FORM); ac++;
3992 XtSetArg (al[ac], XmNbottomOffset, 1); ac++;
3994 if (prev_icon == NULL)
3996 XtSetArg (al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
3997 XtSetArg (al[ac], XmNleftOffset, 1); ac++;
4001 XtSetArg (al[ac], XmNleftAttachment, XmATTACH_WIDGET); ac++;
4002 XtSetArg (al[ac], XmNleftWidget, prev_icon); ac++;
4005 if (next_icon == NULL)
4007 XtSetArg (al[ac], XmNrightAttachment, XmATTACH_FORM); ac++;
4008 XtSetArg (al[ac], XmNrightOffset, 1); ac++;
4012 /* Call the function used to set the control's icon and label data */
4014 ControlSetIconData (parent, control_data, &icon_label, BOX, al, &ac,
4015 &icon_name, &alt_icon_name);
4018 /* Call the function used to set the control's behavioral aspects */
4020 ControlSetBehavior (control_data, al, &ac, False, &exp_file_name);
4023 /* Call the function used to create and register the control */
4025 control_icon = control_data->icon;
4027 main_control_data->icon =
4028 ControlCreateAndRegister (parent, control_data, False, al, ac);
4031 /* If this in not the main control copy then restore the subpanel icon */
4033 if (main_control_data != control_data)
4034 control_data->icon = control_icon;
4037 /* If this is a toggle of a client control from the subpanel to */
4038 /* the main panel, call the reparenting function. */
4040 if ((intptr_t) control_data->
4041 element_values[CONTROL_TYPE].parsed_value == CONTROL_CLIENT)
4043 EmbeddedClientReparent ((char *) control_data->
4044 element_values[CONTROL_CLIENT_NAME].parsed_value,
4045 main_control_data->icon);
4049 if (icon_label != NULL)
4050 XmStringFree (icon_label);
4052 if (icon_name != NULL)
4055 if (alt_icon_name != NULL)
4056 XtFree(alt_icon_name);
4058 if (exp_file_name != NULL)
4059 XtFree(exp_file_name);
4061 /* If this is not the right most control within its parent, */
4062 /* reset the poistioning constraints of the control to the */
4063 /* right of this one. */
4065 if (next_icon != NULL)
4068 XtSetArg (al[ac], XmNleftAttachment, XmATTACH_WIDGET); ac++;
4069 XtSetArg (al[ac], XmNleftWidget, main_control_data->icon); ac++;
4070 XtSetValues (next_icon, al, ac);
4074 /* Now destroy the original main panel icon */
4076 XtDestroyWidget (old_main_icon);
4079 /* Get the width of the new icon and increase its size to minimize */
4080 /* the degree of resizing of the main panel. */
4082 new_width = XtWidth (main_control_data->icon);
4084 if (new_width < width)
4086 Dimension normal_size;
4087 Dimension margin_width;
4089 if (panel.resolution == HIGH)
4090 normal_size = ICON_HIGH_WIDTH;
4091 else if (panel.resolution == MEDIUM)
4092 normal_size = ICON_MEDIUM_WIDTH;
4094 normal_size = ICON_LOW_WIDTH;
4096 if (new_width < normal_size)
4098 XtSetArg (al[0], XmNwidth, normal_size);
4099 XtSetArg (al[1], XmNmarginWidth, (Dimension)(normal_size-new_width)/2);
4100 XtSetValues (main_control_data->icon, al, 2);
4105 /* Get the width of the icon again for arrow and embedded client */
4108 new_width = XtWidth (main_control_data->icon);
4111 /* Call a function to reposition embedded clients to the right */
4112 /* of the main panel control. */
4114 if (new_width != width)
4115 EmbeddedClientReposition (main_control_data->icon,
4116 XtX (main_control_data->icon) + 3,
4120 /* Reset the geometry policy for the main control parent */
4122 XtSetArg (al[0], XmNresizePolicy, XmRESIZE_ANY);
4123 XtSetValues (parent, al, 1);
4126 /* Set the width of the arrow */
4129 if (prev_icon != NULL) new_width -= 2;
4130 if (next_icon != NULL) new_width -= 2;
4132 XtSetArg (al[0], XmNwidth, new_width);
4133 XtSetValues (main_control_data->arrow, al, 1);
4139 /************************************************************************
4141 * SetupPushAnimation
4142 * Add the sequence of images that make up a push animation for a
4145 * Inputs: control_data - a pointer to the control to which to add
4148 ************************************************************************/
4152 SetupPushAnimation (ControlData * control_data)
4156 char * animation_name = control_data->
4157 element_values[CONTROL_PUSH_ANIMATION].parsed_value;
4165 count = panel.animation_count;
4167 if (animation_name == NULL) return;
4169 for (i = 0; i < count; i++)
4171 if (!strcmp (panel.animation_data[i].name, animation_name))
4177 for (j = 0; j < panel.animation_data[i].item_count; j++)
4179 image_name = GetIconName (panel.animation_data[i].items[j].image_name,
4180 panel.main_icon_size);
4182 delay = panel.animation_data[i].items[j].delay;
4184 _DtControlAddPushAnimationImage (control_data->icon, image_name, delay);
4193 /************************************************************************
4195 * SetupDropAnimation
4196 * Add the sequence of images that make up a drop animation for a
4199 * Inputs: control_data - a pointer to the control to which to add
4202 ************************************************************************/
4206 SetupDropAnimation (ControlData * control_data)
4210 char * animation_name = control_data->
4211 element_values[CONTROL_DROP_ANIMATION].parsed_value;
4219 count = panel.animation_count;
4221 if (animation_name == NULL) return;
4223 for (i = 0; i < count; i++)
4225 if (!strcmp (panel.animation_data[i].name, animation_name))
4231 for (j = 0; j < panel.animation_data[i].item_count; j++)
4233 image_name = GetIconName (panel.animation_data[i].items[j].image_name,
4234 panel.main_icon_size);
4236 delay = panel.animation_data[i].items[j].delay;
4238 _DtControlAddDropAnimationImage (control_data->icon, image_name, delay);
4248 /************************************************************************
4251 * Get the file name for an icon by extracting the panel resolution
4252 * and then looking up the image name.
4254 * Inputs: image_name - the base name of the image to be found
4255 * icon_size - the size requested (t, s, m, l) for the
4258 ************************************************************************/
4262 GetIconName (String image_name,
4263 unsigned int icon_size)
4268 String return_name = NULL;
4269 Screen * screen = XtScreen (panel.shell);
4270 unsigned int next_size;
4275 next_size = icon_size;
4278 /* Loop through until all sizes are exhausted */
4280 while (return_name == NULL)
4283 _DtGetIconFileName (screen, image_name, NULL, NULL, next_size);
4285 if (next_size == DtLARGE)
4286 next_size = DtMEDIUM;
4287 else if (next_size == DtMEDIUM)
4288 next_size = DtSMALL;
4289 else if (next_size == DtSMALL)
4292 break; /* tried all sizes, exit loop */
4296 if (return_name == NULL)
4298 _DtGetIconFileName (screen, image_name, NULL, NULL, DtUNSPECIFIED);
4300 if (return_name == NULL)
4302 _DtGetIconFileName (screen, DEFAULT_IMAGE_NAME, NULL, NULL, icon_size);
4304 if (return_name == NULL)
4305 return_name = XtNewString (image_name);
4308 /* Return value to be freed by caller. */
4310 return (return_name);