1 /* $TOG: ToggleButtonInterface.C /main/6 1998/09/21 18:50:08 mgreess $ */
5 * RESTRICTED CONFIDENTIAL INFORMATION:
7 * The information in this document is subject to special
8 * restrictions in a confidential disclosure agreement bertween
9 * HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
10 * document outside HP, IBM, Sun, USL, SCO, or Univel wihtout
11 * Sun's specific written approval. This documment and all copies
12 * and derivative works thereof must be returned or destroyed at
15 * Copyright 1993 Sun Microsystems, Inc. All rights reserved.
19 //////////////////////////////////////////////////////////////
20 // ToggleButtonInterface.C: A toggle button interface to a Cmd object
21 ///////////////////////////////////////////////////////////////
25 #include "MotifCmds.h"
26 #include "ToggleButtonInterface.h"
27 #include <Xm/ToggleB.h>
30 ToggleButtonInterface::ToggleButtonInterface (
33 ) : CmdInterface ( cmd )
36 // We need to generate a button name that doesn't have illegal characters.
38 char *w_name = new char[200];
39 strcpy(w_name, _name);
40 for (char * cur = w_name; *cur; cur++) {
41 if (isspace(*cur) || *cur == ',') {
52 XmString label = XmStringCreateLocalized(cmd->getLabel());
54 if (0 == strcmp(cmd->className(),"ToggleButtonCmd"))
56 ToggleButtonCmd *tbc = (ToggleButtonCmd*) cmd;
57 Boolean visible_when_off = tbc->visibleWhenOff();
58 unsigned char indicator_type = tbc->indicatorType();
60 _w = XtVaCreateWidget (w_name,
61 xmToggleButtonWidgetClass,
63 XmNlabelString, label,
64 XmNvisibleWhenOff, visible_when_off,
65 XmNindicatorType, indicator_type,
69 _w = XtVaCreateWidget (w_name,
70 xmToggleButtonWidgetClass,
72 XmNlabelString, label,
73 XmNvisibleWhenOff, TRUE,
78 printHelpId("_w", _w);
80 // XtAddCallback(_w, XmNhelpCallback, HelpCB, helpId);
83 installDestroyHandler();
85 // The _active member is set when each instance is registered
86 // with an associated Cmd object. Now that a widget exists,
87 // set the widget's sensitivity according to its active state.
94 #ifdef GNU_CC // No idea what the right ifdef is for automatically recognizing g++
96 // G++ reportedly doesn't like the form expected by cfront. I'm
97 // told this will work, but I haven't tested it myself.
100 XmNvalueChangedCallback,
106 XmNvalueChangedCallback,
107 &CmdInterface::executeCmdCallback,
113 #ifndef CAN_INLINE_VIRTUALS
114 ToggleButtonInterface::~ToggleButtonInterface (void)
117 #endif /* ! CAN_INLINE_VIRTUALS */