core/vgui/vgui_enhance_tableau.h
Go to the documentation of this file.
00001 // This is core/vgui/vgui_enhance_tableau.h
00002 #ifndef vgui_enhance_tableau_h_
00003 #define vgui_enhance_tableau_h_
00004 #ifdef VCL_NEEDS_PRAGMA_INTERFACE
00005 #pragma interface
00006 #endif
00007 //:
00008 // \file
00009 // \brief  Magnify/display another tableau in a region around the mouse pointer.
00010 // \author Philip C. Pritchett, Robotics Research Group, University of Oxford
00011 // \date   16 Nov 99
00012 //
00013 //  Contains classes vgui_enhance_tableau  vgui_enhance_tableau_new
00014 //
00015 // \verbatim
00016 //  Modifications
00017 //   16-NOV-1999 P.Pritchett - Initial version.
00018 //   26-APR-2002 K.Y.McGaul - Converted to and added doxygen style comments.
00019 //   01-OCT-2002 K.Y.McGaul - Moved vgui_enhance to vgui_enhance_tableau.
00020 // \endverbatim
00021 
00022 #include <vgui/vgui_tableau.h>
00023 #include <vgui/vgui_parent_child_link.h>
00024 #include <vgui/vgui_enhance_tableau_sptr.h>
00025 
00026 class vgui_event;
00027 
00028 //: Magnify or display another tableau in a region around the mouse pointer.
00029 //  This happens when the user presses the left mouse button inside the
00030 //  rendering area.
00031 //
00032 //  Use '[' and ']' to change size of region around the mouse pointer.
00033 //
00034 //  Use '{' and '}' to change the magnification.
00035 class vgui_enhance_tableau : public vgui_tableau
00036 {
00037  public:
00038   //: Constructor - don't use this, use vgui_enhance_tableau_new.
00039   //  A tableau constructed this way magnifies an area under the mouse pointer.
00040   vgui_enhance_tableau();
00041 
00042   //: Constructor - don't use this, use vgui_enhance_tableau_new.
00043   //  A tableau constructed this way magnifies area of the given tableau
00044   //  under the mouse pointer.
00045   vgui_enhance_tableau(vgui_tableau_sptr const& t);
00046 
00047   //: Constructor - don't use this, use vgui_enhance_tableau_new.
00048   //  A tableau constructed this way displays the tableau t2 on top of t1 in
00049   //  a region around the mouse pointer.
00050   vgui_enhance_tableau(vgui_tableau_sptr const& t1,
00051                        vgui_tableau_sptr const& t2);
00052 
00053   //: Returns the file_name of the first child tableau.
00054   vcl_string file_name() const;
00055 
00056   //: Returns the type of this tableau ('vgui_enhance_tableau').
00057   vcl_string type_name() const;
00058 
00059   //: True to enable key-presses to change size and magnification.
00060   void set_enable_key_bindings(bool on) { enable_key_bindings = on; }
00061 
00062   //: Set the child in the first slot.
00063   void set_child(vgui_tableau_sptr const& t);
00064 
00065  protected:
00066   //: Destructor - called by vgui_enhance_tableau_sptr.
00067  ~vgui_enhance_tableau();
00068 
00069   //: Handle all events sent to this tableau.
00070   //  In particular, use left mouse press to enhance/magnify.
00071   bool handle(const vgui_event&);
00072 
00073   //: First child, this is the tableau displayed, except when the mouse is down.
00074   vgui_parent_child_link slot1;
00075 
00076   //: Second child, displayed when the mouse is pressed in the rendering area.
00077   vgui_parent_child_link slot2;
00078 
00079   //: True if enhancing is on.
00080   bool enhancing_;
00081 
00082   //: Mouse x-position.
00083   int x;
00084 
00085   //: Mouse y-position.
00086   int y;
00087 
00088   //: Size of enhance region around the mouse pointer.
00089   int size;
00090 
00091   //: Amount to zoom if we are magnifying.
00092   float zoom_factor;
00093 
00094   //: True if key presses can change size and zoom factor.
00095   bool enable_key_bindings;
00096 };
00097 
00098 //: Create a smart-pointer to a vgui_enhance_tableau tableau.
00099 struct vgui_enhance_tableau_new : public vgui_enhance_tableau_sptr
00100 {
00101   //: Constructor - magnifies an area under the mouse pointer.
00102   vgui_enhance_tableau_new() :
00103     vgui_enhance_tableau_sptr(new vgui_enhance_tableau()) { }
00104 
00105   //: Constructor - magnifies area of the given tableau under the mouse pointer.
00106   vgui_enhance_tableau_new(vgui_tableau_sptr const&t) :
00107     vgui_enhance_tableau_sptr(new vgui_enhance_tableau(t)) { }
00108 
00109   //: Constructor - displays t2 on top of t1 in a region around mouse pointer.
00110   vgui_enhance_tableau_new(vgui_tableau_sptr const&t1,
00111                            vgui_tableau_sptr const&t2) :
00112     vgui_enhance_tableau_sptr(new vgui_enhance_tableau(t1,t2)) { }
00113 };
00114 
00115 #endif // vgui_enhance_tableau_h_