1 /***********************************************************************/
2 /* Open Visualization Data Explorer */
3 /* (C) Copyright IBM Corp. 1989,1999 */
4 /* ALL RIGHTS RESERVED */
5 /* This code licensed under the */
6 /* "IBM PUBLIC LICENSE - Open Visualization Data Explorer" */
7 /***********************************************************************/
8
9 #include <dxconfig.h>
10 #include <defines.h>
11
12
13
14
15 #include <Xm/Xm.h>
16 #include <Xm/PushB.h>
17
18 #include "DXStrings.h"
19 #include "Tab.h"
20 #include "Application.h"
21 #include "StandIn.h"
22
Tab(StandIn * standIn)23 Tab::Tab(StandIn *standIn):
24 UIComponent("tab")
25 {
26 this->standIn = standIn;
27
28 this->lineWidget = NULL;
29
30 x = y = 0;
31 }
32
33 static XmString nullXmString = NULL;
34
createTab(Widget parent,boolean createManaged)35 void Tab::createTab(Widget parent, boolean createManaged)
36 {
37 Arg arg[10];
38 int n = 0;
39 Widget w;
40
41 if (!nullXmString)
42 nullXmString = XmStringCreateLtoR("", "canvas");
43
44 XtSetArg(arg[n], XmNlabelString, nullXmString); n++;
45 XtSetArg(arg[n], XmNwidth, standIn->getIOWidth()); n++;
46 XtSetArg(arg[n], XmNheight, standIn->getIOHeight()); n++;
47 XtSetArg(arg[n], XmNborderWidth, 0); n++;
48 XtSetArg(arg[n], XmNfillOnArm, FALSE); n++;
49
50 this->x = 0;
51 this->y = 0;
52
53 if (createManaged)
54 w = XtCreateManagedWidget ("nodeTab",
55 xmPushButtonWidgetClass,
56 parent,
57 arg,
58 n);
59 else
60 w = XtCreateWidget ("nodeTab",
61 xmPushButtonWidgetClass,
62 parent,
63 arg,
64 n);
65
66 this->setRootWidget(w);
67 }
68
setBackground(Pixel background)69 void Tab::setBackground(Pixel background)
70 {
71 /*
72 * If the tab has not been initialized...
73 */
74 if(!this->getRootWidget()) return;
75
76 /*
77 * If the background value is invalid, go no further...
78 */
79 if (background == ((Pixel) -1))
80 return;
81
82 /*
83 * Set the widget to the new background color.
84 * Set the armColor also because Motif does strange drawing if the
85 * colormap fills up.
86 */
87 XtVaSetValues(this->getRootWidget(),
88 XmNbackground, background,
89 XmNarmColor, background,
90 NULL);
91 }
moveTabX(Position x,boolean update)92 void Tab::moveTabX(Position x, boolean update)
93 {
94
95 /*
96 * If the tab has not been initialized...
97 */
98 if(!this->getRootWidget()) return;
99
100 XtVaSetValues(this->getRootWidget(), XmNx, x, NULL);
101
102 if(update)
103 this->x = x;
104 }
moveTabY(Position y,boolean update)105 void Tab::moveTabY(Position y, boolean update)
106 {
107 /*
108 * If the tab has not been initialized...
109 */
110 if(!this->getRootWidget()) return;
111
112 XtVaSetValues(this->getRootWidget(), XmNy, y, NULL);
113
114 if(update)
115 this->y = y;
116 }
moveTabXY(Position x,Position y,boolean update)117 void Tab::moveTabXY(Position x, Position y, boolean update)
118 {
119 /*
120 * If the tab has not been initialized...
121 */
122 if(!this->getRootWidget()) return;
123
124 XtVaSetValues(this->getRootWidget(), XmNx, x, XmNy, y, NULL);
125
126 if(update){
127 this->x = x;
128 this->y = y;
129 }
130 }
131
~Tab()132 Tab::~Tab()
133 {
134 if (this->lineWidget != NULL)
135 XtDestroyWidget(this->lineWidget);
136 }
137
138