| 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 |
| SoXtMMSliderMin is a component that expands the functionality of the |
| 47 |
| standard motif slider (they call it 'scale') widget. |
| 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 |
|
| 57 |
#include <inttypes.h> |
| 58 |
#include "SoXtSliderTool.h" |
| 59 |
#include "SoXtMMSliderMin.h" |
| 60 |
#include <X11/StringDefs.h> |
| 61 |
#include <Xm/PushB.h> |
| 62 |
|
| 63 |
/***************************************************************************/ |
| 64 |
/* static variables used by XtGetApplicationResources to get values of */ |
| 65 |
/* user-settable parameters. The defaults values are used if the user */ |
| 66 |
/* does not override them. */ |
| 67 |
/***************************************************************************/ |
| 68 |
static XtResource _minLabelResources[] = { |
| 69 |
{ XmNlabelString, XmCLabelString, XmRXmString, sizeof( char *), |
| 70 |
0, |
| 71 |
XtRString, (XtPointer) DEFAULT_SLIDER_TOOL_MIN_LABEL } |
| 72 |
}; |
| 73 |
|
| 74 |
SoXtMMSliderMin::SoXtMMSliderMin( |
| 75 |
Widget parent, |
| 76 |
const char *name, |
| 77 |
SbBool buildInsideParent) |
| 78 |
: SoXtSliderSetBase( |
| 79 |
parent, |
| 80 |
name, |
| 81 |
buildInsideParent, |
| 82 |
NULL) |
| 83 |
{ |
| 84 |
_sliderTool = NULL; |
| 85 |
|
| 86 |
_layoutWidth = 75; |
| 87 |
_layoutHeight = 40; |
| 88 |
|
| 89 |
// Build the widget! |
| 90 |
Widget w = buildWidget(getParentWidget()); |
| 91 |
setBaseWidget(w); |
| 92 |
} |
| 93 |
|
| 94 |
SoXtMMSliderMin::~SoXtMMSliderMin() {} |
| 95 |
|
| 96 |
Widget |
| 97 |
SoXtMMSliderMin::buildWidget( Widget parent ) |
| 98 |
{ |
| 99 |
Arg wargs[10]; |
| 100 |
XmString minString; |
| 101 |
|
| 102 |
widget = XtCreateManagedWidget(getWidgetName(),xmPushButtonWidgetClass, |
| 103 |
parent,NULL, 0); |
| 104 |
|
| 105 |
/* establish all the callbacks */ |
| 106 |
XtAddCallback( widget, XmNactivateCallback, |
| 107 |
(XtCallbackProc) &SoXtMMSliderMin::minCallback, |
| 108 |
(XtPointer) this ); |
| 109 |
|
| 110 |
/* give the button a title string */ |
| 111 |
XtGetApplicationResources( widget, (XtPointer) &minString, |
| 112 |
_minLabelResources, XtNumber( _minLabelResources), |
| 113 |
NULL, 0 ); |
| 114 |
XtSetArg(wargs[0],XmNlabelString, minString ); |
| 115 |
XtSetValues( widget, wargs, 1 ); |
| 116 |
return widget; |
| 117 |
} |
| 118 |
|
| 119 |
void |
| 120 |
SoXtMMSliderMin::minCallback( Widget, void *client_data, void * ) |
| 121 |
{ |
| 122 |
float theVal; |
| 123 |
SoXtMinMaxSlider *theSlider; |
| 124 |
SoXtMMSliderMin *obj = (SoXtMMSliderMin *) client_data; |
| 125 |
|
| 126 |
if (obj->_sliderTool) |
| 127 |
theSlider = obj->_sliderTool->getSlider(); |
| 128 |
|
| 129 |
/* Get the value from the slider */ |
| 130 |
if (theSlider) |
| 131 |
theVal = theSlider->getSliderValue(); |
| 132 |
|
| 133 |
/* Set this to be the new MINIMUM value throughout the SliderTool */ |
| 134 |
if (obj->_sliderTool) |
| 135 |
obj->_sliderTool->toolSetMin( theVal ); |
| 136 |
} |