![]() |
Main Page Class Hierarchy Alphabetical List Compound List File List Compound Members
![]() |
00001 /******************************************************************************** 00002 * * 00003 * D i a l W i d g e t * 00004 * * 00005 ********************************************************************************* 00006 * Copyright (C) 1998,2002 by Jeroen van der Zijp. All Rights Reserved. * 00007 ********************************************************************************* 00008 * This library is free software; you can redistribute it and/or * 00009 * modify it under the terms of the GNU Lesser General Public * 00010 * License as published by the Free Software Foundation; either * 00011 * version 2.1 of the License, or (at your option) any later version. * 00012 * * 00013 * This library is distributed in the hope that it will be useful, * 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 00016 * Lesser General Public License for more details. * 00017 * * 00018 * You should have received a copy of the GNU Lesser General Public * 00019 * License along with this library; if not, write to the Free Software * 00020 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * 00021 ********************************************************************************* 00022 * $Id: FXDial.h,v 1.20 2002/01/18 22:42:52 jeroen Exp $ * 00023 ********************************************************************************/ 00024 #ifndef FXDIAL_H 00025 #define FXDIAL_H 00026 00027 #ifndef FXFRAME_H 00028 #include "FXFrame.h" 00029 #endif 00030 00031 00032 00033 // Dial style options 00034 enum { 00035 DIAL_VERTICAL = 0, // Vertically oriented 00036 DIAL_HORIZONTAL = 0x00008000, // Horizontal oriented 00037 DIAL_CYCLIC = 0x00010000, // Value wraps around 00038 DIAL_HAS_NOTCH = 0x00020000, // Dial has a Center Notch 00039 DIAL_NORMAL = DIAL_VERTICAL 00040 }; 00041 00042 00043 /** 00044 * The dial widget is a valuator widget which is able to provide a cyclic 00045 * value range, or a simple linear value range. Optionally, the zero point 00046 * may be displayed by means of a colored notch. 00047 * While being turned, the dial sends a SEL_CHANGED message to its target; 00048 * at the end of the interaction, a SEL_COMMAND message is sent. 00049 * The message data represents the current value, of type FXint. 00050 */ 00051 class FXAPI FXDial : public FXFrame { 00052 FXDECLARE(FXDial) 00053 protected: 00054 FXint range[2]; // Reported data range 00055 FXColor notchColor; // Main notch color 00056 FXint notchangle; // Angle of main notch 00057 FXint notchspacing; // Angle between notches 00058 FXint notchoffset; // Notch offset 00059 FXint dragpoint; // Place where clicked 00060 FXint dragpos; // Value where clicked 00061 FXint incr; // Rate of change/revolution 00062 FXint pos; // Reported data position 00063 FXString help; // Help string 00064 FXString tip; // Tip string 00065 protected: 00066 FXDial(){} 00067 private: 00068 FXDial(const FXDial&); 00069 FXDial &operator=(const FXDial&); 00070 public: 00071 long onPaint(FXObject*,FXSelector,void*); 00072 long onMotion(FXObject*,FXSelector,void*); 00073 long onMouseWheel(FXObject*,FXSelector,void*); 00074 long onLeftBtnPress(FXObject*,FXSelector,void* ); 00075 long onLeftBtnRelease(FXObject*,FXSelector,void*); 00076 long onUngrabbed(FXObject*,FXSelector,void*); 00077 long onCmdSetValue(FXObject*,FXSelector,void*); 00078 long onCmdSetIntValue(FXObject*,FXSelector,void*); 00079 long onCmdGetIntValue(FXObject*,FXSelector,void*); 00080 long onCmdSetRealValue(FXObject*,FXSelector,void*); 00081 long onCmdGetRealValue(FXObject*,FXSelector,void*); 00082 long onCmdSetIntRange(FXObject*,FXSelector,void*); 00083 long onCmdGetIntRange(FXObject*,FXSelector,void*); 00084 long onCmdSetRealRange(FXObject*,FXSelector,void*); 00085 long onCmdGetRealRange(FXObject*,FXSelector,void*); 00086 long onQueryHelp(FXObject*,FXSelector,void*); 00087 long onQueryTip(FXObject*,FXSelector,void*); 00088 public: 00089 00090 /// Construct a dial widget 00091 FXDial(FXComposite *p,FXObject* tgt=NULL,FXSelector sel=0,FXuint opts=DIAL_NORMAL,FXint x=0,FXint y=0,FXint w=0,FXint h=0,FXint pl=DEFAULT_PAD,FXint pr=DEFAULT_PAD,FXint pt=DEFAULT_PAD,FXint pb=DEFAULT_PAD); 00092 00093 /// Return default width 00094 virtual FXint getDefaultWidth(); 00095 00096 /// Return default height 00097 virtual FXint getDefaultHeight(); 00098 00099 /// Set the dial value 00100 void setValue(FXint value); 00101 00102 /// Return the dial value 00103 FXint getValue() const { return pos; } 00104 00105 /// Change the dial's range 00106 void setRange(FXint lo,FXint hi); 00107 00108 /// Obtain the current range of the dial 00109 void getRange(FXint& lo,FXint& hi) const { lo=range[0]; hi=range[1]; } 00110 00111 /** 00112 * Set the revolution increment, which is the amount of change 00113 * in the position for revolution of the dial; the dial may go 00114 * through multiple revolutions to go through its whole range 00115 */ 00116 void setRevolutionIncrement(FXint i); 00117 00118 /// Get the current value of the revolution increment 00119 FXint getRevolutionIncrement() const { return incr; } 00120 00121 /** 00122 * Change the spacing for the small notches; this should be set 00123 * in tenths of degrees in the range [1,3600], and the value should 00124 * be a divisor of 3600, so as to make the notches come out evenly 00125 */ 00126 void setNotchSpacing(FXint spacing); 00127 00128 /// Get the current notch spacing 00129 FXint getNotchSpacing() const { return notchspacing; } 00130 00131 /** 00132 * Change the notch offset, which is the position of the 00133 * center notch; the value should be tenths of degrees 00134 * in the range [-3600,3600] 00135 */ 00136 void setNotchOffset(FXint offset); 00137 00138 /// Get the current center notch offset 00139 FXint getNotchOffset() const { return notchoffset; } 00140 00141 /// Changes the dial style. 00142 void setDialStyle(FXuint opts); 00143 00144 /// Get the current dial style. 00145 FXuint getDialStyle() const; 00146 00147 /// Change the center notch color 00148 void setNotchColor(FXColor clr); 00149 00150 /// Get the current center notch color 00151 FXColor getNotchColor() const { return notchColor; } 00152 00153 /// Set the help text to be displayed on the status line 00154 void setHelpText(const FXString& text); 00155 00156 /// Get the current help text 00157 FXString getHelpText() const { return help; } 00158 00159 /// Set the tip text to be displayed in the tooltip 00160 void setTipText(const FXString& text); 00161 00162 /// Get the current tooltip text value 00163 FXString getTipText() const { return tip; } 00164 00165 /// Save to stream 00166 virtual void save(FXStream& store) const; 00167 00168 /// Load from stream 00169 virtual void load(FXStream& store); 00170 }; 00171 00172 #endif