1 // Copyright (C) 2002-2012 Nikolaus Gebhardt 2 // This file is part of the "Irrlicht Engine". 3 // For conditions of distribution and use, see copyright notice in irrlicht.h 4 5 #ifndef __C_GUI_SCROLL_BAR_H_INCLUDED__ 6 #define __C_GUI_SCROLL_BAR_H_INCLUDED__ 7 8 #include "IrrCompileConfig.h" 9 #ifdef _IRR_COMPILE_WITH_GUI_ 10 11 #include "IGUIScrollBar.h" 12 #include "IGUIButton.h" 13 14 namespace irr 15 { 16 namespace gui 17 { 18 19 class CGUIScrollBar : public IGUIScrollBar 20 { 21 public: 22 23 //! constructor 24 CGUIScrollBar(bool horizontal, IGUIEnvironment* environment, 25 IGUIElement* parent, s32 id, core::rect<s32> rectangle, 26 bool noclip=false); 27 28 //! destructor 29 virtual ~CGUIScrollBar(); 30 31 //! called if an event happened. 32 virtual bool OnEvent(const SEvent& event); 33 34 //! draws the element and its children 35 virtual void draw(); 36 37 virtual void OnPostRender(u32 timeMs); 38 39 40 //! gets the maximum value of the scrollbar. 41 virtual s32 getMax() const; 42 43 //! sets the maximum value of the scrollbar. 44 virtual void setMax(s32 max); 45 46 //! gets the minimum value of the scrollbar. 47 virtual s32 getMin() const; 48 49 //! sets the minimum value of the scrollbar. 50 virtual void setMin(s32 min); 51 52 //! gets the small step value 53 virtual s32 getSmallStep() const; 54 55 //! sets the small step value 56 virtual void setSmallStep(s32 step); 57 58 //! gets the large step value 59 virtual s32 getLargeStep() const; 60 61 //! sets the large step value 62 virtual void setLargeStep(s32 step); 63 64 //! gets the current position of the scrollbar 65 virtual s32 getPos() const; 66 67 //! sets the position of the scrollbar 68 virtual void setPos(s32 pos); 69 70 //! updates the rectangle 71 virtual void updateAbsolutePosition(); 72 73 //! Writes attributes of the element. 74 virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const; 75 76 //! Reads attributes of the element 77 virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options); 78 79 private: 80 81 void refreshControls(); 82 s32 getPosFromMousePos(const core::position2di &p) const; 83 84 IGUIButton* UpButton; 85 IGUIButton* DownButton; 86 87 core::rect<s32> SliderRect; 88 89 bool Dragging; 90 bool Horizontal; 91 bool DraggedBySlider; 92 bool TrayClick; 93 s32 Pos; 94 s32 DrawPos; 95 s32 DrawHeight; 96 s32 Min; 97 s32 Max; 98 s32 SmallStep; 99 s32 LargeStep; 100 s32 DesiredPos; 101 u32 LastChange; 102 video::SColor CurrentIconColor; 103 range()104 f32 range () const { return (f32) ( Max - Min ); } 105 }; 106 107 } // end namespace gui 108 } // end namespace irr 109 110 #endif // _IRR_COMPILE_WITH_GUI_ 111 112 #endif 113 114