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 __FXTextParamValue_H__
22 #define __FXTextParamValue_H__
23 
24 #include "../../config/common.h"
25 #include "fox_compat.h"
26 
27 #include <string>
28 
29 class CNestedDataFile;
30 
31 class FXTextParamValue : public FXHorizontalFrame
32 {
33 	FXDECLARE(FXTextParamValue);
34 public:
35 	FXTextParamValue(FXComposite *p,int opts,const char *name,const double initialValue,const double minValue,const double maxValue); // make it behave as a numeric entry
36 	FXTextParamValue(FXComposite *p,int opts,const char *name,const string initialValue); // make it behave like a text entry
37 	virtual ~FXTextParamValue();
38 
39 	long onValueTextBoxChange(FXObject *sender,FXSelector sel,void *ptr);
40 
41 	long onValueSpinnerChange(FXObject *sender,FXSelector sel,void *ptr);
42 
43 	void setUnits(const FXString units,const FXString tipText="");
44 
45 	const double getValue();
46 	void setValue(const double value);
47 
48 	const string getText();
49 	void setText(const string text);
50 
51 	void setRange(const double minValue,const double maxValue);
52 
53 	const string getName() const;
54 
55 	void setTipText(const FXString &text);
56 	FXString getTipText() const;
57 
58 	void readFromFile(const string &prefix,CNestedDataFile *f);
59 	void writeToFile(const string &prefix,CNestedDataFile *f);
60 
61 	enum
62 	{
63 		ID_VALUE_SPINNER=FXHorizontalFrame::ID_LAST,
64 		ID_VALUE_TEXTBOX,
65 
66 		ID_LAST
67 	};
68 
69 
70 protected:
FXTextParamValue()71 	FXTextParamValue() : isNumeric(false) {}
72 
73 private:
74 	const string name;
75 
76 	const bool isNumeric;
77 
78 	const string initialValue;
79 
80 	double minValue,maxValue;
81 
82 	FXHorizontalFrame *panel;
83 		FXLabel *titleLabel;
84 		FXTextField *valueTextBox;
85 		FXSpinner *valueSpinner;
86 		FXLabel *unitsLabel;
87 
88 	void validateRange();
89 
90 	FXFont *textFont;
91 
92 	void changed();
93 };
94 
95 #endif
96