1 /* 2 * Copyright (C) 2002 - David W. Durham 3 * 4 * This file is part of ReZound, an audio editing application. 5 * 6 * ReZound is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published 8 * by the Free Software Foundation; either version 2 of the License, 9 * or (at your option) any later version. 10 * 11 * ReZound is distributed in the hope that it will be useful, but 12 * WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 19 */ 20 21 #ifndef __FXConstantParamValue_H__ 22 #define __FXConstantParamValue_H__ 23 24 #include "../../config/common.h" 25 #include "fox_compat.h" 26 27 #include <string> 28 29 #include "../backend/CSound_defs.h" 30 31 #include "../backend/AActionParamMapper.h" 32 33 class CNestedDataFile; 34 35 class FXConstantParamValue : public FXVerticalFrame 36 { 37 FXDECLARE(FXConstantParamValue); 38 public: 39 // display as a slider and a value entry (with optional scalar control) 40 // interpretValue should return the value of the slider at the given x where 0<=x<=1 and uninterpretValue should do the inverse 41 // minScalar and maxScalar are the min and max values of the scalar spinner, if they are equal, the scalar spinner will not be shown 42 FXConstantParamValue(AActionParamMapper *valueMapper,bool showInverseButton,FXComposite *p,int opts,const char *name); 43 virtual ~FXConstantParamValue(); 44 45 FXint getDefaultWidth(); 46 FXint getDefaultHeight(); 47 void setMinSize(FXint minWidth,FXint minHeight); 48 49 long onSliderChange(FXObject *sender,FXSelector sel,void *ptr); 50 51 long onValueTextBoxChange(FXObject *sender,FXSelector sel,void *ptr); 52 53 long onScalarSpinnerChange(FXObject *sender,FXSelector sel,void *ptr); 54 55 long onInverseButton(FXObject *sender,FXSelector sel,void *ptr); 56 57 long onMiddleLabelClick(FXObject *sender,FXSelector sel,void *ptr); 58 59 // call if the tick labels, slider position, or edit box value need to be reevaluated 60 void updateNumbers(); 61 62 void setUnits(const FXString units); 63 64 const double getValue() const; 65 void setValue(const double value); 66 67 const int getScalar() const; 68 void setScalar(const int scalar); 69 70 const int getMinScalar() const; 71 const int getMaxScalar() const; 72 73 const string getName() const; 74 75 void setTipText(const FXString &text); 76 FXString getTipText() const; 77 78 void enable(); 79 void disable(); 80 81 void readFromFile(const string &prefix,CNestedDataFile *f); 82 void writeToFile(const string &prefix,CNestedDataFile *f) const; 83 84 enum 85 { 86 ID_SLIDER=FXVerticalFrame::ID_LAST, 87 88 ID_VALUE_TEXTBOX, 89 ID_SCALAR_SPINNER, 90 91 ID_INVERSE_BUTTON, 92 93 ID_MIDDLE_LABEL, 94 95 ID_LAST 96 }; 97 98 99 protected: FXConstantParamValue()100 FXConstantParamValue() {} 101 102 private: 103 const string name; 104 105 FXString units; 106 107 // 108 // ------------------------------------------- <---- this 109 // | ----------------------------------------- | 110 // | | titleLabel | | 111 // | ----------------------------------------- | 112 // | ----------------------------------------- | 113 // || (optional) middleFrame || 114 // || ----- -------------- --------------- || 115 // ||| || || ------------- | || 116 // ||| || || | maxLabel | | || 117 // ||| || || ------------- | || 118 // ||| || || <----|-||---- tickLabelFrame 119 // ||| --- || slider || ------------- | || 120 // ||||Inv||| || | halfLabel | | || 121 // ||| --- || || ------------- | || 122 // ||| <---|----------------------------------|---- inverseButtonFrame (optional) 123 // ||| || || ------------- | || 124 // ||| || || | minLabel | | || 125 // ||| || || ------------- | || 126 // || ----- -------------- --------------- || 127 // | ----------------------------------------- | 128 // | ----------------------------------------- | 129 // | | valuePanel | | 130 // | ----------------------------------------- | 131 // | ----------------------------------------- | 132 // | | (optional) scalarPanel | | 133 // | ----------------------------------------- | 134 // ------------------------------------------- 135 // 136 137 FXLabel *titleLabel; 138 FXHorizontalSeparator *horzSep; 139 FXHorizontalFrame *middleFrame; 140 FXPacker *inverseButtonFrame; 141 FXButton *inverseButton; 142 FXSlider *slider; 143 FXVerticalFrame *tickLabelFrame; 144 FXLabel *maxLabel; 145 FXPacker *middleTickLabelFrame; 146 FXLabel *halfLabel; 147 FXLabel *minLabel; 148 FXHorizontalFrame *valuePanel; 149 FXTextField *valueTextBox; 150 FXLabel *unitsLabel; 151 FXHorizontalFrame *scalarPanel; 152 FXLabel *scalarLabel; 153 FXSpinner *scalarSpinner; 154 155 AActionParamMapper *valueMapper; 156 157 mutable double retValue; 158 159 void prvSetValue(const double value); 160 double defaultValue; 161 162 FXFont *textFont; 163 164 FXint minWidth,minHeight; 165 }; 166 167 #endif 168