ubit
uzoom.hpp
1 /************************************************************************
2  *
3  * uzoom.hpp: semantic zooming
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 _uzoom_hpp_
18 #define _uzoom_hpp_ 1
19 #include <ubit/ucond.hpp>
20 #include <ubit/ubox.hpp>
21 #include <ubit/uctlmenu.hpp>
22 namespace ubit {
23 
24  class UZoommenu;
25 
34  class UZoompane : public UBox {
35  public:
36  UCLASS(UZoompane)
37 
38  UZoompane(UArgs arglist = UArgs::none);
39 
40  UBox& viewport() {return *pviewport;}
42 
43  UPos& viewportPos() {return *ppos;}
48  UScale& viewportScale() {return *pscale;}
53  UZoommenu& zoommenu() {return *pmenu;}
59  void openMenuOn(int event_mask);
60 
61  private:
62  uptr<UBox> pviewport;
63  uptr<UZoommenu> pmenu;
64  uptr<UPos> ppos;
65  uptr<UScale> pscale;
66  };
67 
68  inline UZoompane& uzoompane(UArgs arglist = UArgs::none) {return *new UZoompane(arglist);}
70 
71 
72  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
76  class UZoommenu: public UCtlmenu {
77  public:
78  UCLASSDEF("UZoommenu", UZoommenu, null) // UZoommenu() not defined
79 
80  UZoommenu(UBox& zoomed_box, UBox& panned_box);
86  void openMenuOn(int event_mask);
87  virtual void openMenuCB(UMouseEvent&);
88 
89  protected:
90  uptr<UZoomAction> pzoom_action;
91  uptr<UPanAction> ppan_action;
92  int event_mask;
93  };
94 
95 
96  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
110  class UInscale : public UCond {
111  public:
112  UInscale() : smin(0.), smax(0.) {}
113  UInscale(float _smin, float _smax) : smin(_smin), smax(_smax) {}
114 
115  void setMin(float _smin) {smin = _smin;}
116  void setMax(float _smax) {smax = _smax;}
117  float getMin() const {return smin;}
118  float getMax() const {return smax;}
119 
120  virtual bool verifies(const UUpdateContext&, const UElem&) const;
121  private:
122  float smin, smax;
123  };
124 
125  inline UInscale& uinscale(float smin, float smax) {return *new UInscale(smin,smax);}
127 
128 }
129 #endif
Widget position.
Definition: uboxgeom.hpp:91
Zooming conditions (for semantic zooming).
Definition: uzoom.hpp:110
Box container.
Definition: ubox.hpp:64
UBox & viewport()
returns the viewport that is controlled by this zoompane.
Definition: uzoom.hpp:40
Zoom pane for zooming and panning children.
Definition: uzoom.hpp:34
Base class for Ubit conditions.
Definition: ucond.hpp:29
UScale & viewportScale()
returns the scale attribute of the viewport.
Definition: uzoom.hpp:48
lightweight general purpose container.
Definition: uelem.hpp:44
UPos & viewportPos()
returns the position attribute of the viewport.
Definition: uzoom.hpp:43
UZoommenu & zoommenu()
returns the menu that controls this zoompane.
Definition: uzoom.hpp:53
Argument list (for passing arguments to constructor or add functions).
Definition: uargs.hpp:43
Definition: uupdatecontext.hpp:32
Definition: uhardfont.hpp:31
static const UArgs none
the empty arglist.
Definition: uargs.hpp:45
Widget scale.
Definition: uboxgeom.hpp:31
Panning (Callback object for UCtlmenu items).
Definition: uctlmenu.hpp:140
Control menu.
Definition: uctlmenu.hpp:73
Zoom menu for zooming and panning widgets.
Definition: uzoom.hpp:76
mouse events
Definition: uevent.hpp:172
Centred zoom (Callback object for UCtlmenu items).
Definition: uctlmenu.hpp:122