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 CEGUIEXPORT 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 00240 virtual bool testClassName_impl(const String& class_name) const 00241 { 00242 if (class_name==(const utf8*)"Thumb") return true; 00243 return PushButton::testClassName_impl(class_name); 00244 } 00245 00246 00247 /************************************************************************* 00248 New Thumb Events 00249 *************************************************************************/ 00254 virtual void onThumbPositionChanged(WindowEventArgs& e); 00255 00256 00261 virtual void onThumbTrackStarted(WindowEventArgs& e); 00262 00263 00268 virtual void onThumbTrackEnded(WindowEventArgs& e); 00269 00270 00271 00272 /************************************************************************* 00273 Overridden event handling routines 00274 *************************************************************************/ 00275 virtual void onMouseMove(MouseEventArgs& e); 00276 virtual void onMouseButtonDown(MouseEventArgs& e); 00277 virtual void onCaptureLost(WindowEventArgs& e); 00278 00279 00280 /************************************************************************* 00281 Implementation Data 00282 *************************************************************************/ 00283 // general settings 00284 bool d_hotTrack; 00285 bool d_vertFree; 00286 bool d_horzFree; 00287 00288 // operational limits 00289 float d_vertMin, d_vertMax; 00290 float d_horzMin, d_horzMax; 00291 00292 // internal state 00293 bool d_beingDragged; 00294 Point d_dragPoint; 00295 00296 00297 private: 00298 /************************************************************************* 00299 Static Properties for this class 00300 *************************************************************************/ 00301 static ThumbProperties::HotTracked d_hotTrackedProperty; 00302 static ThumbProperties::VertFree d_vertFreeProperty; 00303 static ThumbProperties::HorzFree d_horzFreeProperty; 00304 static ThumbProperties::VertRange d_vertRangeProperty; 00305 static ThumbProperties::HorzRange d_horzRangeProperty; 00306 00307 00308 /************************************************************************* 00309 Private methods 00310 *************************************************************************/ 00311 void addThumbProperties(void); 00312 }; 00313 00314 } // End of CEGUI namespace section 00315 00316 #if defined(_MSC_VER) 00317 # pragma warning(pop) 00318 #endif 00319 00320 #endif // end of guard _CEGUIThumb_h_