Debian Codegraph @

libSoXt/src/motif/SoXtLtSldrSet.c++

raw
1 /*
2 *
3 * Copyright (C) 2000 Silicon Graphics, Inc. All Rights Reserved.
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * Further, this software is distributed without any warranty that it is
16 * free of the rightful claim of any third person regarding infringement
17 * or the like. Any license provided herein, whether implied or
18 * otherwise, applies only to this software file. Patent licenses, if
19 * any, provided herein do not apply to combinations of this program with
20 * other software, or any other product whatsoever.
21 *
22 * You should have received a copy of the GNU Lesser General Public
23 * License along with this library; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 *
26 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
27 * Mountain View, CA 94043, or:
28 *
29 * http://www.sgi.com
30 *
31 * For further information regarding this notice, see:
32 *
33 * http://oss.sgi.com/projects/GenInfo/NoticeExplan/
34 *
35 */
36
37 /*
38 * Copyright (C) 1990-93 Silicon Graphics, Inc.
39 *
40 _______________________________________________________________________
41 ______________ S I L I C O N G R A P H I C S I N C . ____________
42 |
43 | $Revision: 1.2 $
44 |
45 | Classes:
46 | Subclass of SoXtSliderSet that acts on a light node
47 | SoXtLightSliderSet
48 |
49 | Author(s) : Paul Isaacs
50 |
51 ______________ S I L I C O N G R A P H I C S I N C . ____________
52 _______________________________________________________________________
53 */
54
55 //--------------------------------Include------------------------------
56 #include <inttypes.h>
57 #include "SoXtSliderModules.h"
58 #include <Inventor/Xt/SoXtLightSliderSet.h>
59 #include <X11/StringDefs.h>
60 #include <Xm/Form.h>
61
62 static XtResource _borderWidthResource[] = {
63 { XtNborderWidth, XtCBorderWidth, XtRDimension, sizeof( unsigned short),
64 0, XtRImmediate, (XtPointer) SLIDER_SET_DEFAULT_BORDER_WIDTH }
65 };
66
67
68 ////////////////////////////////////////////////////////////////////////
69 //
70 // Public constructor - build the widget right now
71 //
72 SoXtLightSliderSet::SoXtLightSliderSet(
73 Widget parent,
74 const char *name,
75 SbBool buildInsideParent,
76 SoNode *newEditNode)
77 : SoXtSliderSet(
78 parent,
79 name,
80 buildInsideParent,
81 newEditNode)
82 //
83 ////////////////////////////////////////////////////////////////////////
84 {
85 // In this case, this component is what the app wants, so buildNow = TRUE
86 constructorCommon(TRUE);
87 }
88
89 SoXtLightSliderSet::~SoXtLightSliderSet() {}
90
91 ////////////////////////////////////////////////////////////////////////
92 //
93 // SoEXTENDER constructor - the subclass tells us whether to build or not
94 //
95 SoXtLightSliderSet::SoXtLightSliderSet(
96 Widget parent,
97 const char *name,
98 SbBool buildInsideParent,
99 SoNode *newEditNode,
100 SbBool buildNow)
101 : SoXtSliderSet(
102 parent,
103 name,
104 buildInsideParent,
105 newEditNode)
106 //
107 ////////////////////////////////////////////////////////////////////////
108 {
109 // In this case, this component may be what the app wants,
110 // or it may want a subclass of this component. Pass along buildNow
111 // as it was passed to us.
112 constructorCommon(buildNow);
113 }
114
115 ///////////////////////////////////////////////////////////////////////
116 //
117 // Description:
118 // Called by the constructors.
119 // Constructor for the SoXtLightSliderSet. Creates the 5 slider modules
120 // that make up the editor. The base class constructor will create
121 // the container widget, etc.
122 // This constructor gives a default name.
123 // Use: public
124 void
125 SoXtLightSliderSet::constructorCommon(SbBool buildNow)
126 //
127 //////////////////////////////////////////////////////////////////////
128 {
129 // Create the two modules used by this editor.
130 _numSubComponents = 2;
131 _subComponentArray = new SoXtSliderSetBase* [ _numSubComponents ];
132
133 _subComponentArray[0] = NULL;
134 _subComponentArray[1] = NULL;
135
136 // Build the widget tree, and let SoXtComponent know about our base widget.
137 if (buildNow) {
138 Widget w = buildWidget(getParentWidget());
139 setBaseWidget(w);
140 }
141 }
142
143 Widget
144 SoXtLightSliderSet::buildWidget( Widget parent)
145 {
146 Arg wargs[10];
147 Dimension newBorderWidth;
148 Widget theWidget;
149
150 _parentShellWidget = parent;
151
152 widget = XtCreateManagedWidget(getWidgetName(),xmFormWidgetClass, parent,NULL, 0);
153
154 _subComponentArray[0] = new SoXtLightIntensitySliderModule( widget, "lightIntensityEditor" );
155 _subComponentArray[1] = new SoXtLightColorSliderModule( widget, "lightColorEditor" );
156
157 for (int i = 0; i < _numSubComponents; i++ ) {
158 (( SoXtSliderModule *) _subComponentArray[i])->setEditor( this );
159 theWidget = _subComponentArray[i]->getWidget();
160 XtGetApplicationResources( theWidget, (XtPointer) &newBorderWidth,
161 _borderWidthResource, XtNumber( _borderWidthResource ),NULL, 0); XtSetArg( wargs[0], XmNborderWidth, newBorderWidth );
162 XtSetValues( theWidget, wargs, 1 );
163 }
164
165 updateLayout();
166
167 return widget;
168 }