Main Page Class Hierarchy Alphabetical List Compound List File List Compound Members
|
00001 /******************************************************************************** 00002 * * 00003 * K n o b W i d g e t * 00004 * * 00005 ********************************************************************************* 00006 * Copyright (C) 2005,2006 by Leandro Nini. 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: FXKnob.h,v 1.7 2006/01/22 17:58:05 fox Exp $ * 00023 ********************************************************************************/ 00024 #ifndef FXKNOB_H 00025 #define FXKNOB_H 00026 00027 #ifndef FXFRAME_H 00028 #include "FXFrame.h" 00029 #endif 00030 00031 namespace FX { 00032 00033 00034 /// Knob Control styles 00035 enum { 00036 KNOB_NEEDLE = 0, /// Use a needle as indicator 00037 KNOB_DOT = 0x00008000, /// Use a dot as indicator 00038 KNOB_TICKS = 0x00010000, /// Show ticks around the knob 00039 KNOB_INDICATOR = 0x00020000, /// Show only the indicator (like a speedometer) 00040 KNOB_NORMAL = (KNOB_NEEDLE|KNOB_TICKS) /// Normal knob looks 00041 }; 00042 00043 00044 00045 /** 00046 * The knob widget is a valuator widget which provides simple linear value range. 00047 * While being moved, the knob sends SEL_CHANGED messages to its target; 00048 * at the end of the interaction, a final SEL_COMMAND message is sent. 00049 * The message data represents the current knob value, of type FXint. 00050 */ 00051 class FXAPI FXKnob : public FXFrame { 00052 FXDECLARE(FXKnob) 00053 protected: 00054 FXint range[2]; // Reported data range 00055 FXdouble limits[2]; // Starting and ending positions 00056 FXColor lineColor; // Color of indicator needle 00057 FXint pos; // Reported data position 00058 FXint incr; // Increment when auto-sliding 00059 FXint delta; // Interval between ticks 00060 FXString help; // Help string 00061 FXString tip; // Tip string 00062 protected: 00063 FXKnob(); 00064 FXint calcValue(FXint x,FXint y); 00065 private: 00066 FXKnob(const FXKnob&); 00067 FXKnob &operator=(const FXKnob&); 00068 public: 00069 long onPaint(FXObject*,FXSelector,void*); 00070 long onLeftBtnPress(FXObject*,FXSelector,void*); 00071 long onLeftBtnRelease(FXObject*,FXSelector,void*); 00072 long onMiddleBtnPress(FXObject*,FXSelector,void*); 00073 long onMiddleBtnRelease(FXObject*,FXSelector,void*); 00074 long onMouseWheel(FXObject*,FXSelector,void*); 00075 long onUngrabbed(FXObject*,FXSelector,void*); 00076 long onMotion(FXObject*,FXSelector,void*); 00077 long onFocusIn(FXObject*,FXSelector,void*); 00078 long onFocusOut(FXObject*,FXSelector,void*); 00079 long onKeyPress(FXObject*,FXSelector,void*); 00080 long onKeyRelease(FXObject*,FXSelector,void*); 00081 long onAutoSlide(FXObject*,FXSelector,void*); 00082 long onCmdSetValue(FXObject*,FXSelector,void*); 00083 long onCmdSetIntValue(FXObject*,FXSelector,void*); 00084 long onCmdGetIntValue(FXObject*,FXSelector,void*); 00085 long onCmdSetRealValue(FXObject*,FXSelector,void*); 00086 long onCmdGetRealValue(FXObject*,FXSelector,void*); 00087 long onCmdSetIntRange(FXObject*,FXSelector,void*); 00088 long onCmdGetIntRange(FXObject*,FXSelector,void*); 00089 long onCmdSetRealRange(FXObject*,FXSelector,void*); 00090 long onCmdGetRealRange(FXObject*,FXSelector,void*); 00091 long onCmdSetHelp(FXObject*,FXSelector,void*); 00092 long onCmdGetHelp(FXObject*,FXSelector,void*); 00093 long onCmdSetTip(FXObject*,FXSelector,void*); 00094 long onCmdGetTip(FXObject*,FXSelector,void*); 00095 long onQueryHelp(FXObject*,FXSelector,void*); 00096 long onQueryTip(FXObject*,FXSelector,void*); 00097 public: 00098 enum{ 00099 ID_AUTOSLIDE=FXFrame::ID_LAST, 00100 ID_LAST 00101 }; 00102 public: 00103 00104 /// Construct a knob widget 00105 FXKnob(FXComposite* p,FXObject* tgt=NULL,FXSelector sel=0,FXuint opts=KNOB_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); 00106 00107 /// Returns true because a knob can receive focus 00108 virtual bool canFocus() const; 00109 00110 /// Return default width 00111 virtual FXint getDefaultWidth(); 00112 00113 /// Return default height 00114 virtual FXint getDefaultHeight(); 00115 00116 /// Perform layout 00117 virtual void layout(); 00118 00119 /// Enable the knob 00120 virtual void enable(); 00121 00122 /// Disable the knob 00123 virtual void disable(); 00124 00125 /// Change knob value 00126 void setValue(FXint value,FXbool notify=FALSE); 00127 00128 /// Return knob value 00129 FXint getValue() const { return pos; } 00130 00131 /// Change the knob's range 00132 void setRange(FXint lo,FXint hi,FXbool notify=FALSE); 00133 00134 /// Get the knob's current range 00135 void getRange(FXint& lo,FXint& hi) const { lo=range[0]; hi=range[1]; } 00136 00137 /** 00138 * Change the knob's movement limits (start and ending angles) 00139 * accept values in degrees from 0 (south) to 360. 00140 */ 00141 void setLimits(FXint start,FXint end,FXbool notify=FALSE); 00142 00143 /// Get the knob's current limits 00144 void getLimits(FXint& start,FXint& end); 00145 00146 /// Change the knob style 00147 FXuint getKnobStyle() const; 00148 00149 /// Get the current knob style 00150 void setKnobStyle(FXuint style); 00151 00152 /// Get the knob's auto-increment/decrement value 00153 FXint getIncrement() const { return incr; } 00154 00155 /// Change the knob's auto-increment/decrement value 00156 void setIncrement(FXint inc){ incr=inc; } 00157 00158 /// Change the delta between ticks 00159 void setTickDelta(FXint dist); 00160 00161 /// Get delta between ticks 00162 FXint getTickDelta() const { return delta; } 00163 00164 /// Change the indicator needle color 00165 void setLineColor(FXColor clr); 00166 00167 /// Get the current indicator needle color 00168 FXColor getLineColor() const { return lineColor; } 00169 00170 /// Set the help text to be displayed on the status line 00171 void setHelpText(const FXString& text){ help=text; } 00172 00173 /// Get the current help text 00174 const FXString& getHelpText() const { return help; } 00175 00176 /// Set the tip text to be displayed in the tooltip 00177 void setTipText(const FXString& text){ tip=text; } 00178 00179 /// Get the current tooltip text value 00180 const FXString& getTipText() const { return tip; } 00181 00182 /// Save to stream 00183 virtual void save(FXStream& store) const; 00184 00185 /// Load from stream 00186 virtual void load(FXStream& store); 00187 00188 /// Destroy the knob 00189 virtual ~FXKnob(); 00190 }; 00191 00192 } 00193 00194 #endif
Copyright © 1997-2005 Jeroen van der Zijp |