ubit
uscrollpane.hpp
1 /************************************************************************
2  *
3  * uscrollpane.hpp
4  * Ubit GUI Toolkit - Version 6
5  * (C) 2009 | Eric Lecolinet | TELECOM ParisTech | http://www.enst.fr/~elc/ubit
6  *
7  * ***********************************************************************
8  * COPYRIGHT NOTICE :
9  * THIS PROGRAM IS DISTRIBUTED WITHOUT ANY WARRANTY AND WITHOUT EVEN THE
10  * IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
11  * YOU CAN REDISTRIBUTE IT AND/OR MODIFY IT UNDER THE TERMS OF THE GNU
12  * GENERAL PUBLIC LICENSE AS PUBLISHED BY THE FREE SOFTWARE FOUNDATION;
13  * EITHER VERSION 2 OF THE LICENSE, OR (AT YOUR OPTION) ANY LATER VERSION.
14  * SEE FILES 'COPYRIGHT' AND 'COPYING' FOR MORE DETAILS.
15  * ***********************************************************************/
16 
17 #ifndef _uscrollpane_hpp_
18 #define _uscrollpane_hpp_ 1
19 #include <ubit/uborder.hpp>
20 #include <ubit/uview.hpp>
21 namespace ubit {
22 
37  class UScrollpane: public UBox {
38  public:
39  UCLASS(UScrollpane)
40 
43 
44  UScrollpane(int vert_scrollbar, int horiz_scrollbar, UArgs = UArgs::none);
50  virtual ~UScrollpane();
51 
52  static UStyle* createStyle();
53 
54  void setTracking(bool);
56 
57  float getXScroll() const {return xscroll;}
59 
60  float getYScroll() const {return yscroll;}
62 
63  UScrollpane& setXScroll(float _xscroll) {return setScroll(_xscroll, yscroll);}
65 
66  UScrollpane& setYScroll(float _yscroll) {return setScroll(xscroll, _yscroll);}
68 
69  virtual UScrollpane& setScroll(float xscroll, float yscroll);
71 
72  virtual void makeVisible(UBox& child);
77  UScrollpane& showHScrollbar(bool state);
78  UScrollpane& showVScrollbar(bool state);
79 
80  UScrollpane& showHScrollButtons(bool state);
81  UScrollpane& showVScrollButtons(bool state);
82 
83  UScrollbar* getHScrollbar() {return hscrollbar;}
85 
86  UScrollbar* getVScrollbar() {return vscrollbar;}
88 
91 
92  UView* getScrolledView(UView* pane_view);
99  // - - - Impl. - - - - - - - - - - - - - - - - - - - - - - - - - - -
100 #ifndef NO_DOC
101  virtual void setScrollImpl(float xscroll, float yscroll);
102  protected:
103  friend class UScrollbar;
104  UScrollbar *hscrollbar, *vscrollbar;
105  float xscroll, yscroll;
106 
107  virtual void constructs(int vs_mode, int hs_mode, const UArgs&);
108  virtual void unsetHScrollbar();
109  virtual void unsetVScrollbar();
110  virtual void resizeCB(UResizeEvent&);
111  virtual void wheelCB(UWheelEvent&);
112 #endif
113  };
114 
115  inline UScrollpane& uscrollpane(const UArgs& args = UArgs::none)
116  {return *new UScrollpane(args);}
118 
119  inline UScrollpane& uscrollpane(int vscrollbar, int hscrollbar, const UArgs& args = UArgs::none)
120  {return *new UScrollpane(vscrollbar, hscrollbar, args);}
122 
123 
124  /* ==================================================== ======== ======= */
127  class UPaneView: public UView {
128  public:
129  static UViewStyle style; // renderer
130  virtual UViewStyle* getViewStyle() {return &style;}
131 
132  UPaneView(UBox*, UView* parview, UHardwinImpl*);
133  virtual ~UPaneView() {}
134  static UView* createView(UBox*, UView* parview, UHardwinImpl*);
135 
136  virtual UPaneView* toPaneView() {return this;}
137 
138  float getXScroll() {return xscroll;}
139  float getYScroll() {return yscroll;}
140 
141  virtual void setXScroll(float scr) {xscroll = scr;}
142  virtual void setYScroll(float scr) {yscroll = scr;}
144 
145  void setPadding(const UPaddingSpec& p) {padding = p;} // for UView::initLayoutViewport
146 
147 #ifndef NO_DOC
148  friend class UScrollpane;
149  UPaddingSpec padding;
150  float xscroll, yscroll;
151 #endif
152  };
153 }
154 #endif
155 
float getXScroll() const
returns the current X scroll value (float value in [0,100]).
Definition: uscrollpane.hpp:57
float getYScroll() const
returns the current Y scroll value (float value in [0,100]).
Definition: uscrollpane.hpp:60
Box container.
Definition: ubox.hpp:64
UScrollpane & setXScroll(float _xscroll)
changes the X scroll value (float value in [0,100]).
Definition: uscrollpane.hpp:63
UScrollpane(UArgs=UArgs::none)
create a scroll pane with 2 scrollbars; see also shortcut functions uscrollpane().
void setTracking(bool)
tracking mode updates the value while the scrollbar is being dragged (default is true).
Definition: uscrollpane.cpp:95
UScrollbar * getHScrollbar()
returns the horizontal scrollbar (if any; null otherwise)
Definition: uscrollpane.hpp:83
UBox * getScrolledBox()
returns the box that is scrolled by this pane.
Definition: uscrollpane.cpp:136
UView * getScrolledView(UView *pane_view)
returns the appropriate view of the box that is scrolled by this pane.
Definition: uscrollpane.cpp:144
UScrollbar * getVScrollbar()
returns the vertical scrollbar (if any; null otherwise)
Definition: uscrollpane.hpp:86
virtual ~UScrollpane()
Definition: uscrollpane.cpp:49
Box padding.
Definition: ulength.hpp:150
Argument list (for passing arguments to constructor or add functions).
Definition: uargs.hpp:43
wheel events
Definition: uevent.hpp:286
Scrollbar widget.
Definition: uscrollbar.hpp:38
A box with (optionnal) scrollbars that manages a viewport.
Definition: uscrollpane.hpp:37
Box View.
Definition: uview.hpp:65
Specifies the View Style of an UBox.
Definition: uview.hpp:42
Definition: uhardfont.hpp:31
static const UArgs none
the empty arglist.
Definition: uargs.hpp:45
UScrollpane & setYScroll(float _yscroll)
changes the Y scroll value (float value in [0,100]).
Definition: uscrollpane.hpp:66
Definition: uwinImpl.hpp:84
virtual UScrollpane & setScroll(float xscroll, float yscroll)
changes the X and Y scroll values (float values in [0,100]).
Definition: uscrollpane.cpp:225
Resize event.
Definition: uevent.hpp:418
[Impl] UPane View.
Definition: uscrollpane.hpp:127
Compiled Object Style.
Definition: ustyle.hpp:44
virtual void makeVisible(UBox &child)
scrolls the pane to make this child visible.
Definition: uscrollpane.cpp:187
virtual void setYScroll(float scr)
note that using these functions is not a good idea if this pane is already controlled by scrollbars...
Definition: uscrollpane.hpp:142