Debian Codegraph @

libSoXt/src/motif/SoXtMtlSSet.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 material nodes
47 | SoXtMaterialSliderSet
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
56 //--------------------------------Include------------------------------
57 #include <inttypes.h>
58 #include "SoXtSliderModules.h"
59 #include <Inventor/Xt/SoXtMaterialSliderSet.h>
60 #include <X11/StringDefs.h>
61 #include <Xm/Form.h>
62
63 static XtResource _borderWidthResource[] = {
64 { XtNborderWidth, XtCBorderWidth, XtRDimension, sizeof( unsigned short),
65 0, XtRImmediate, (XtPointer) SLIDER_SET_DEFAULT_BORDER_WIDTH }
66 };
67
68 ////////////////////////////////////////////////////////////////////////
69 //
70 // Public constructor - build the widget right now
71 //
72 SoXtMaterialSliderSet::SoXtMaterialSliderSet(
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 SoXtMaterialSliderSet::~SoXtMaterialSliderSet() {}
90
91 ////////////////////////////////////////////////////////////////////////
92 //
93 // SoEXTENDER constructor - the subclass tells us whether to build or not
94 //
95 SoXtMaterialSliderSet::SoXtMaterialSliderSet(
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 // Constructor for the SoXtMaterialSliderSet. Creates the 6 slider modules
119 // that make up the editor. The base class constructor will create
120 // the container widget, etc.
121 // This constructor gives a default name.
122 // Use: public
123 void
124 SoXtMaterialSliderSet::constructorCommon(SbBool buildNow)
125 //
126 //////////////////////////////////////////////////////////////////////
127 {
128 // Create the five modules used by a Transform editor.
129 _numSubComponents = 6;
130 _subComponentArray = new SoXtSliderSetBase* [ _numSubComponents ];
131
132 _subComponentArray[0] = NULL;
133 _subComponentArray[1] = NULL;
134 _subComponentArray[2] = NULL;
135 _subComponentArray[3] = NULL;
136 _subComponentArray[4] = NULL;
137 _subComponentArray[5] = NULL;
138
139 // Build the widget tree, and let SoXtComponent know about our base widget.
140 if (buildNow) {
141 Widget w = buildWidget(getParentWidget());
142 setBaseWidget(w);
143 }
144 }
145
146 Widget
147 SoXtMaterialSliderSet::buildWidget(Widget parent)
148 {
149 Arg wargs[10];
150 Dimension newBorderWidth;
151 Widget theWidget;
152
153 _parentShellWidget = parent;
154
155 widget = XtCreateManagedWidget(getWidgetName(),xmFormWidgetClass, parent,NULL, 0);
156
157 _subComponentArray[0] = new SoXtAmbientColorSliderModule(widget);
158 _subComponentArray[1] = new SoXtDiffuseColorSliderModule(widget);
159 _subComponentArray[2] = new SoXtSpecularColorSliderModule(widget);
160 _subComponentArray[3] = new SoXtEmissiveColorSliderModule(widget);
161 _subComponentArray[4] = new SoXtShininessSliderModule(widget);
162 _subComponentArray[5] = new SoXtTransparencySliderModule(widget);
163
164 for (int i = 0; i < _numSubComponents; i++ ) {
165 (( SoXtSliderModule *) _subComponentArray[i])->setEditor( this );
166 theWidget = _subComponentArray[i]->getWidget();
167 XtGetApplicationResources( theWidget, (XtPointer) &newBorderWidth,
168 _borderWidthResource, XtNumber( _borderWidthResource ),NULL, 0); XtSetArg( wargs[0], XmNborderWidth, newBorderWidth );
169 XtSetValues( theWidget, wargs, 1 );
170 }
171
172 updateLayout();
173
174 return widget;
175 }