![]() |
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,2009 by Jeroen van der Zijp. All Rights Reserved. * 00007 ********************************************************************************* 00008 * This library is free software; you can redistribute it and/or modify * 00009 * it under the terms of the GNU Lesser General Public License as published by * 00010 * the Free Software Foundation; either version 3 of the License, or * 00011 * (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 * 00016 * GNU Lesser General Public License for more details. * 00017 * * 00018 * You should have received a copy of the GNU Lesser General Public License * 00019 * along with this program. If not, see <http://www.gnu.org/licenses/> * 00020 ********************************************************************************* 00021 * $Id: FXDial.h,v 1.43 2009/01/06 13:07:22 fox Exp $ * 00022 ********************************************************************************/ 00023 #ifndef FXDIAL_H 00024 #define FXDIAL_H 00025 00026 #ifndef FXFRAME_H 00027 #include "FXFrame.h" 00028 #endif 00029 00030 namespace FX { 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 when the DIAL_CYCLIC is passed, or a simple linear value range. 00046 * While being turned, the dial sends a SEL_CHANGED message to its target; 00047 * at the end of the interaction, a SEL_COMMAND message is sent. 00048 * The message data represents the current value, of type FXint. The options 00049 * DIAL_VERTICAL and DIAL_HORIZONTAL control the orientation of the dial. 00050 * An optional notch can be used to indicate the zero-position of 00051 * the dial; display of the notch is controlled by the DIAL_HAS_NOTCH option. 00052 */ 00053 class FXAPI FXDial : public FXFrame { 00054 FXDECLARE(FXDial) 00055 protected: 00056 FXint notchAngle; // Angle of main notch 00057 FXint notchSpacing; // Angle between notches 00058 FXint notchOffset; // Notch offset 00059 FXColor notchColor; // Main notch color 00060 FXint dragPoint; // Place where clicked 00061 FXint dragPos; // Value where clicked 00062 FXint range[2]; // Reported data range 00063 FXint incr; // Rate of change/revolution 00064 FXint pos; // Reported data position 00065 FXString help; // Help string 00066 FXString tip; // Tip string 00067 protected: 00068 FXDial(); 00069 private: 00070 FXDial(const FXDial&); 00071 FXDial &operator=(const FXDial&); 00072 public: 00073 long onPaint(FXObject*,FXSelector,void*); 00074 long onMotion(FXObject*,FXSelector,void*); 00075 long onMouseWheel(FXObject*,FXSelector,void*); 00076 long onLeftBtnPress(FXObject*,FXSelector,void* ); 00077 long onLeftBtnRelease(FXObject*,FXSelector,void*); 00078 long onKeyPress(FXObject*,FXSelector,void*); 00079 long onKeyRelease(FXObject*,FXSelector,void*); 00080 long onUngrabbed(FXObject*,FXSelector,void*); 00081 long onCmdSetValue(FXObject*,FXSelector,void*); 00082 long onCmdSetIntValue(FXObject*,FXSelector,void*); 00083 long onCmdGetIntValue(FXObject*,FXSelector,void*); 00084 long onCmdSetLongValue(FXObject*,FXSelector,void*); 00085 long onCmdGetLongValue(FXObject*,FXSelector,void*); 00086 long onCmdSetRealValue(FXObject*,FXSelector,void*); 00087 long onCmdGetRealValue(FXObject*,FXSelector,void*); 00088 long onCmdSetIntRange(FXObject*,FXSelector,void*); 00089 long onCmdGetIntRange(FXObject*,FXSelector,void*); 00090 long onCmdSetRealRange(FXObject*,FXSelector,void*); 00091 long onCmdGetRealRange(FXObject*,FXSelector,void*); 00092 long onCmdSetHelp(FXObject*,FXSelector,void*); 00093 long onCmdGetHelp(FXObject*,FXSelector,void*); 00094 long onCmdSetTip(FXObject*,FXSelector,void*); 00095 long onCmdGetTip(FXObject*,FXSelector,void*); 00096 long onQueryHelp(FXObject*,FXSelector,void*); 00097 long onQueryTip(FXObject*,FXSelector,void*); 00098 public: 00099 00100 /// Construct a dial widget 00101 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); 00102 00103 /// Return default width 00104 virtual FXint getDefaultWidth(); 00105 00106 /// Return default height 00107 virtual FXint getDefaultHeight(); 00108 00109 /// Returns true because a dial can receive focus 00110 virtual FXbool canFocus() const; 00111 00112 /// Set the dial value 00113 void setValue(FXint value,FXbool notify=false); 00114 00115 /// Return the dial value 00116 FXint getValue() const { return pos; } 00117 00118 /// Change the dial's range 00119 void setRange(FXint lo,FXint hi,FXbool notify=false); 00120 00121 /// Obtain the current range of the dial 00122 void getRange(FXint& lo,FXint& hi) const { lo=range[0]; hi=range[1]; } 00123 00124 /** 00125 * Set the revolution increment, which is the amount of change 00126 * in the position for revolution of the dial; the dial may go 00127 * through multiple revolutions to go through its whole range; 00128 * by default it takes one 360 degree turn of the dial to go 00129 * from the lower to the upper range. 00130 */ 00131 void setRevolutionIncrement(FXint i); 00132 00133 /// Get the current value of the revolution increment 00134 FXint getRevolutionIncrement() const { return incr; } 00135 00136 /** 00137 * Change the spacing for the small notches; this should be set 00138 * in tenths of degrees in the range [1,3600], and the value should 00139 * be a divisor of 3600, so as to make the notches come out evenly 00140 */ 00141 void setNotchSpacing(FXint spacing); 00142 00143 /// Get the current notch spacing 00144 FXint getNotchSpacing() const { return notchSpacing; } 00145 00146 /** 00147 * Change the notch offset, which is the position of the 00148 * center notch; the value should be tenths of degrees 00149 * in the range [-3600,3600] 00150 */ 00151 void setNotchOffset(FXint offset); 00152 00153 /// Get the current center notch offset 00154 FXint getNotchOffset() const { return notchOffset; } 00155 00156 /// Changes the dial style. 00157 void setDialStyle(FXuint opts); 00158 00159 /// Get the current dial style. 00160 FXuint getDialStyle() const; 00161 00162 /// Change the center notch color 00163 void setNotchColor(FXColor clr); 00164 00165 /// Get the current center notch color 00166 FXColor getNotchColor() const { return notchColor; } 00167 00168 /// Set the help text to be displayed on the status line 00169 void setHelpText(const FXString& text); 00170 00171 /// Get the current help text 00172 const FXString& getHelpText() const { return help; } 00173 00174 /// Set the tip text to be displayed in the tooltip 00175 void setTipText(const FXString& text); 00176 00177 /// Get the current tooltip text value 00178 const FXString& getTipText() const { return tip; } 00179 00180 /// Save to stream 00181 virtual void save(FXStream& store) const; 00182 00183 /// Load from stream 00184 virtual void load(FXStream& store); 00185 }; 00186 00187 } 00188 00189 #endif
![]() |