Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members

FXDial.h

00001 /******************************************************************************** 00002 * * 00003 * D i a l W i d g e t * 00004 * * 00005 ********************************************************************************* 00006 * Copyright (C) 1998,2005 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.30 2005/01/16 16:06:06 fox Exp $ * 00023 ********************************************************************************/ 00024 #ifndef FXDIAL_H 00025 #define FXDIAL_H 00026 00027 #ifndef FXFRAME_H 00028 #include "FXFrame.h" 00029 #endif 00030 00031 namespace FX { 00032 00033 00034 // Dial style options 00035 enum { 00036 DIAL_VERTICAL = 0, // Vertically oriented 00037 DIAL_HORIZONTAL = 0x00008000, // Horizontal oriented 00038 DIAL_CYCLIC = 0x00010000, // Value wraps around 00039 DIAL_HAS_NOTCH = 0x00020000, // Dial has a Center Notch 00040 DIAL_NORMAL = DIAL_VERTICAL 00041 }; 00042 00043 00044 /** 00045 * The Dial widget is a valuator widget which is able to provide a cyclic 00046 * value range when the DIAL_CYCLIC is passed, or a simple linear value range. 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. The options 00050 * DIAL_VERTICAL and DIAL_HORIZONTAL control the orientation of the dial. 00051 * An optional notch can be used to indicate the zero-position of 00052 * the dial; display of the notch is controlled by the DIAL_HAS_NOTCH option. 00053 */ 00054 class FXAPI FXDial : public FXFrame { 00055 FXDECLARE(FXDial) 00056 protected: 00057 FXint range[2]; // Reported data range 00058 FXColor notchColor; // Main notch color 00059 FXint notchangle; // Angle of main notch 00060 FXint notchspacing; // Angle between notches 00061 FXint notchoffset; // Notch offset 00062 FXint dragpoint; // Place where clicked 00063 FXint dragpos; // Value where clicked 00064 FXint incr; // Rate of change/revolution 00065 FXint pos; // Reported data position 00066 FXString help; // Help string 00067 FXString tip; // Tip string 00068 protected: 00069 FXDial(){} 00070 private: 00071 FXDial(const FXDial&); 00072 FXDial &operator=(const FXDial&); 00073 public: 00074 long onPaint(FXObject*,FXSelector,void*); 00075 long onMotion(FXObject*,FXSelector,void*); 00076 long onMouseWheel(FXObject*,FXSelector,void*); 00077 long onLeftBtnPress(FXObject*,FXSelector,void* ); 00078 long onLeftBtnRelease(FXObject*,FXSelector,void*); 00079 long onUngrabbed(FXObject*,FXSelector,void*); 00080 long onCmdSetValue(FXObject*,FXSelector,void*); 00081 long onCmdSetIntValue(FXObject*,FXSelector,void*); 00082 long onCmdGetIntValue(FXObject*,FXSelector,void*); 00083 long onCmdSetRealValue(FXObject*,FXSelector,void*); 00084 long onCmdGetRealValue(FXObject*,FXSelector,void*); 00085 long onCmdSetIntRange(FXObject*,FXSelector,void*); 00086 long onCmdGetIntRange(FXObject*,FXSelector,void*); 00087 long onCmdSetRealRange(FXObject*,FXSelector,void*); 00088 long onCmdGetRealRange(FXObject*,FXSelector,void*); 00089 long onCmdSetHelp(FXObject*,FXSelector,void*); 00090 long onCmdGetHelp(FXObject*,FXSelector,void*); 00091 long onCmdSetTip(FXObject*,FXSelector,void*); 00092 long onCmdGetTip(FXObject*,FXSelector,void*); 00093 long onQueryHelp(FXObject*,FXSelector,void*); 00094 long onQueryTip(FXObject*,FXSelector,void*); 00095 public: 00096 00097 /// Construct a dial widget 00098 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); 00099 00100 /// Return default width 00101 virtual FXint getDefaultWidth(); 00102 00103 /// Return default height 00104 virtual FXint getDefaultHeight(); 00105 00106 /// Set the dial value 00107 void setValue(FXint value); 00108 00109 /// Return the dial value 00110 FXint getValue() const { return pos; } 00111 00112 /// Change the dial's range 00113 void setRange(FXint lo,FXint hi); 00114 00115 /// Obtain the current range of the dial 00116 void getRange(FXint& lo,FXint& hi) const { lo=range[0]; hi=range[1]; } 00117 00118 /** 00119 * Set the revolution increment, which is the amount of change 00120 * in the position for revolution of the dial; the dial may go 00121 * through multiple revolutions to go through its whole range 00122 */ 00123 void setRevolutionIncrement(FXint i); 00124 00125 /// Get the current value of the revolution increment 00126 FXint getRevolutionIncrement() const { return incr; } 00127 00128 /** 00129 * Change the spacing for the small notches; this should be set 00130 * in tenths of degrees in the range [1,3600], and the value should 00131 * be a divisor of 3600, so as to make the notches come out evenly 00132 */ 00133 void setNotchSpacing(FXint spacing); 00134 00135 /// Get the current notch spacing 00136 FXint getNotchSpacing() const { return notchspacing; } 00137 00138 /** 00139 * Change the notch offset, which is the position of the 00140 * center notch; the value should be tenths of degrees 00141 * in the range [-3600,3600] 00142 */ 00143 void setNotchOffset(FXint offset); 00144 00145 /// Get the current center notch offset 00146 FXint getNotchOffset() const { return notchoffset; } 00147 00148 /// Changes the dial style. 00149 void setDialStyle(FXuint opts); 00150 00151 /// Get the current dial style. 00152 FXuint getDialStyle() const; 00153 00154 /// Change the center notch color 00155 void setNotchColor(FXColor clr); 00156 00157 /// Get the current center notch color 00158 FXColor getNotchColor() const { return notchColor; } 00159 00160 /// Set the help text to be displayed on the status line 00161 void setHelpText(const FXString& text); 00162 00163 /// Get the current help text 00164 const FXString& getHelpText() const { return help; } 00165 00166 /// Set the tip text to be displayed in the tooltip 00167 void setTipText(const FXString& text); 00168 00169 /// Get the current tooltip text value 00170 const FXString& getTipText() const { return tip; } 00171 00172 /// Save to stream 00173 virtual void save(FXStream& store) const; 00174 00175 /// Load from stream 00176 virtual void load(FXStream& store); 00177 }; 00178 00179 } 00180 00181 #endif

Copyright © 1997-2005 Jeroen van der Zijp