Crazy Eddie's GUI System
0.8.4
|
00001 /*********************************************************************** 00002 created: 13/4/2004 00003 author: Paul D Turner 00004 *************************************************************************/ 00005 /*************************************************************************** 00006 * Copyright (C) 2004 - 2012 Paul D Turner & The CEGUI Development Team 00007 * 00008 * Permission is hereby granted, free of charge, to any person obtaining 00009 * a copy of this software and associated documentation files (the 00010 * "Software"), to deal in the Software without restriction, including 00011 * without limitation the rights to use, copy, modify, merge, publish, 00012 * distribute, sublicense, and/or sell copies of the Software, and to 00013 * permit persons to whom the Software is furnished to do so, subject to 00014 * the following conditions: 00015 * 00016 * The above copyright notice and this permission notice shall be 00017 * included in all copies or substantial portions of the Software. 00018 * 00019 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 00020 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 00021 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 00022 * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 00023 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 00024 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 00025 * OTHER DEALINGS IN THE SOFTWARE. 00026 ***************************************************************************/ 00027 #ifndef _CEGUIScrollbar_h_ 00028 #define _CEGUIScrollbar_h_ 00029 00030 #include "../Base.h" 00031 #include "../Window.h" 00032 00033 #if defined(_MSC_VER) 00034 # pragma warning(push) 00035 # pragma warning(disable : 4251) 00036 #endif 00037 00038 // Start of CEGUI namespace section 00039 namespace CEGUI 00040 { 00042 class CEGUIEXPORT ScrollbarWindowRenderer : public WindowRenderer 00043 { 00044 public: 00045 ScrollbarWindowRenderer(const String& name); 00046 00052 virtual void updateThumb(void) = 0; 00053 00063 virtual float getValueFromThumb(void) const = 0; 00064 00078 virtual float getAdjustDirectionFromPoint(const Vector2f& pt) const = 0; 00079 }; 00080 00089 class CEGUIEXPORT Scrollbar : public Window 00090 { 00091 public: 00093 static const String WidgetTypeName; 00094 00096 static const String EventNamespace; 00102 static const String EventScrollPositionChanged; 00108 static const String EventThumbTrackStarted; 00114 static const String EventThumbTrackEnded; 00120 static const String EventScrollConfigChanged; 00121 00123 static const String ThumbName; 00125 static const String IncreaseButtonName; 00127 static const String DecreaseButtonName; 00128 00145 float getDocumentSize(void) const 00146 { 00147 return d_documentSize; 00148 } 00149 00166 void setDocumentSize(float document_size); 00167 00185 float getPageSize(void) const 00186 { 00187 return d_pageSize; 00188 } 00189 00207 void setPageSize(float page_size); 00208 00226 float getStepSize(void) const 00227 { 00228 return d_stepSize; 00229 } 00230 00248 void setStepSize(float step_size); 00249 00267 float getOverlapSize(void) const 00268 { 00269 return d_overlapSize; 00270 } 00271 00289 void setOverlapSize(float overlap_size); 00290 00307 float getScrollPosition(void) const 00308 { 00309 return d_position; 00310 } 00311 00330 void setScrollPosition(float position); 00331 00333 float getUnitIntervalScrollPosition() const; 00335 void setUnitIntervalScrollPosition(float position); 00336 00348 PushButton* getIncreaseButton() const; 00349 00361 PushButton* getDecreaseButton() const; 00362 00373 Thumb* getThumb() const; 00374 00409 void setConfig(const float* const document_size, 00410 const float* const page_size, 00411 const float* const step_size, 00412 const float* const overlap_size, 00413 const float* const position); 00414 00429 void setEndLockEnabled(const bool enabled); 00430 00446 bool isEndLockEnabled() const; 00447 00449 void scrollForwardsByStep(); 00451 void scrollBackwardsByStep(); 00452 00454 void scrollForwardsByPage(); 00456 void scrollBackwardsByPage(); 00457 00458 Scrollbar(const String& type, const String& name); 00459 ~Scrollbar(void); 00460 00461 // overrides 00462 void initialiseComponents(void); 00463 00464 protected: 00470 void updateThumb(void); 00471 00481 float getValueFromThumb(void) const; 00482 00496 float getAdjustDirectionFromPoint(const Vector2f& pt) const; 00497 00501 bool setScrollPosition_impl(const float position); 00502 00504 bool isAtEnd() const; 00505 00507 float getMaxScrollPosition() const; 00508 00510 bool handleThumbMoved(const EventArgs& e); 00511 00513 bool handleIncreaseClicked(const EventArgs& e); 00514 00516 bool handleDecreaseClicked(const EventArgs& e); 00517 00519 bool handleThumbTrackStarted(const EventArgs& e); 00520 00522 bool handleThumbTrackEnded(const EventArgs& e); 00523 00525 virtual bool validateWindowRenderer(const WindowRenderer* renderer) const; 00526 00527 // New event handlers for slider widget 00529 virtual void onScrollPositionChanged(WindowEventArgs& e); 00530 00532 virtual void onThumbTrackStarted(WindowEventArgs& e); 00533 00535 virtual void onThumbTrackEnded(WindowEventArgs& e); 00536 00538 virtual void onScrollConfigChanged(WindowEventArgs& e); 00539 00540 // Overridden event handlers 00541 virtual void onMouseButtonDown(MouseEventArgs& e); 00542 virtual void onMouseWheel(MouseEventArgs& e); 00543 00544 // base class overrides 00545 void banPropertiesForAutoWindow(); 00546 00547 // Implementation Data 00549 float d_documentSize; 00551 float d_pageSize; 00553 float d_stepSize; 00555 float d_overlapSize; 00557 float d_position; 00559 bool d_endLockPosition; 00560 00561 private: 00563 void addScrollbarProperties(void); 00564 }; 00565 00566 } // End of CEGUI namespace section 00567 00568 #if defined(_MSC_VER) 00569 # pragma warning(pop) 00570 #endif 00571 00572 #endif // end of guard _CEGUIScrollbar_h_