00001 /************************************************************************ 00002 filename: CEGUIThumb.h 00003 created: 25/4/2004 00004 author: Paul D Turner 00005 00006 purpose: Interface for a 'Thumb' widget. Intended to be used as 00007 part of other widgets such as scrollers and sliders. 00008 *************************************************************************/ 00009 /************************************************************************* 00010 Crazy Eddie's GUI System (http://www.cegui.org.uk) 00011 Copyright (C)2004 - 2005 Paul D Turner (paul@cegui.org.uk) 00012 00013 This library is free software; you can redistribute it and/or 00014 modify it under the terms of the GNU Lesser General Public 00015 License as published by the Free Software Foundation; either 00016 version 2.1 of the License, or (at your option) any later version. 00017 00018 This library is distributed in the hope that it will be useful, 00019 but WITHOUT ANY WARRANTY; without even the implied warranty of 00020 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00021 Lesser General Public License for more details. 00022 00023 You should have received a copy of the GNU Lesser General Public 00024 License along with this library; if not, write to the Free Software 00025 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00026 *************************************************************************/ 00027 #ifndef _CEGUIThumb_h_ 00028 #define _CEGUIThumb_h_ 00029 00030 #include "CEGUIPushButton.h" 00031 #include "elements/CEGUIThumbProperties.h" 00032 #include <utility> 00033 00034 00035 #if defined(_MSC_VER) 00036 # pragma warning(push) 00037 # pragma warning(disable : 4251) 00038 #endif 00039 00040 00041 // Start of CEGUI namespace section 00042 namespace CEGUI 00043 { 00044 00052 class CEGUIBASE_API Thumb : public PushButton 00053 { 00054 public: 00055 static const String EventNamespace; 00056 00057 00058 /************************************************************************* 00059 Event name constants 00060 *************************************************************************/ 00061 // generated internally by Window 00062 static const String EventThumbPositionChanged; 00063 static const String EventThumbTrackStarted; 00064 static const String EventThumbTrackEnded; 00065 00066 00067 /************************************************************************* 00068 Accessor Functions 00069 *************************************************************************/ 00077 bool isHotTracked(void) const {return d_hotTrack;} 00078 00087 bool isVertFree(void) const {return d_vertFree;} 00088 00097 bool isHorzFree(void) const {return d_horzFree;} 00098 00099 00108 std::pair<float, float> getVertRange(void) const; 00109 00110 00119 std::pair<float, float> getHorzRange(void) const; 00120 00121 00122 /************************************************************************* 00123 Manipulator Functions 00124 *************************************************************************/ 00135 void setHotTracked(bool setting) {d_hotTrack = setting;} 00136 00137 00148 void setVertFree(bool setting) {d_vertFree = setting;} 00149 00150 00161 void setHorzFree(bool setting) {d_horzFree = setting;} 00162 00163 00180 void setVertRange(float min, float max); 00181 00182 00199 void setHorzRange(float min, float max); 00200 00201 00202 /************************************************************************* 00203 Construction / Destruction 00204 *************************************************************************/ 00209 Thumb(const String& type, const String& name); 00210 00211 00216 virtual ~Thumb(void); 00217 00218 00219 protected: 00220 /************************************************************************* 00221 Implementation Functions 00222 *************************************************************************/ 00227 void addThumbEvents(void); 00228 00229 00230 /************************************************************************* 00231 New Thumb Events 00232 *************************************************************************/ 00237 virtual void onThumbPositionChanged(WindowEventArgs& e); 00238 00239 00244 virtual void onThumbTrackStarted(WindowEventArgs& e); 00245 00246 00251 virtual void onThumbTrackEnded(WindowEventArgs& e); 00252 00253 00254 00255 /************************************************************************* 00256 Overridden event handling routines 00257 *************************************************************************/ 00258 virtual void onMouseMove(MouseEventArgs& e); 00259 virtual void onMouseButtonDown(MouseEventArgs& e); 00260 virtual void onCaptureLost(WindowEventArgs& e); 00261 00262 00263 /************************************************************************* 00264 Implementation Data 00265 *************************************************************************/ 00266 // general settings 00267 bool d_hotTrack; 00268 bool d_vertFree; 00269 bool d_horzFree; 00270 00271 // operational limits 00272 float d_vertMin, d_vertMax; 00273 float d_horzMin, d_horzMax; 00274 00275 // internal state 00276 bool d_beingDragged; 00277 Point d_dragPoint; 00278 00279 00280 private: 00281 /************************************************************************* 00282 Static Properties for this class 00283 *************************************************************************/ 00284 static ThumbProperties::HotTracked d_hotTrackedProperty; 00285 static ThumbProperties::VertFree d_vertFreeProperty; 00286 static ThumbProperties::HorzFree d_horzFreeProperty; 00287 static ThumbProperties::VertRange d_vertRangeProperty; 00288 static ThumbProperties::HorzRange d_horzRangeProperty; 00289 00290 00291 /************************************************************************* 00292 Private methods 00293 *************************************************************************/ 00294 void addThumbProperties(void); 00295 }; 00296 00297 } // End of CEGUI namespace section 00298 00299 #if defined(_MSC_VER) 00300 # pragma warning(pop) 00301 #endif 00302 00303 #endif // end of guard _CEGUIThumb_h_