widget.h

Go to the documentation of this file.
00001 
00003 
00004 //
00005 // Copyright (c) 2001-2004 California Institute of Technology
00006 // Copyright (c) 2004-2007 University of Southern California
00007 // Rob Peters <rjpeters at usc dot edu>
00008 //
00009 // created: Fri Jun 15 16:59:35 2001
00010 // commit: $Id: widget.h 10065 2007-04-12 05:54:56Z rjpeters $
00011 // $HeadURL: file:///lab/rjpeters/svnrepo/code/trunk/groovx/src/tk/widget.h $
00012 //
00013 // --------------------------------------------------------------------
00014 //
00015 // This file is part of GroovX.
00016 //   [http://ilab.usc.edu/rjpeters/groovx/]
00017 //
00018 // GroovX is free software; you can redistribute it and/or modify it
00019 // under the terms of the GNU General Public License as published by
00020 // the Free Software Foundation; either version 2 of the License, or
00021 // (at your option) any later version.
00022 //
00023 // GroovX is distributed in the hope that it will be useful, but
00024 // WITHOUT ANY WARRANTY; without even the implied warranty of
00025 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00026 // General Public License for more details.
00027 //
00028 // You should have received a copy of the GNU General Public License
00029 // along with GroovX; if not, write to the Free Software Foundation,
00030 // Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
00031 //
00033 
00034 #ifndef GROOVX_TK_WIDGET_H_UTC20050628165845_DEFINED
00035 #define GROOVX_TK_WIDGET_H_UTC20050628165845_DEFINED
00036 
00037 #include "nub/object.h"
00038 #include "nub/signal.h"
00039 
00040 typedef struct Tk_Window_ *Tk_Window;
00041 
00042 namespace geom
00043 {
00044   template <class T> class vec2;
00045 }
00046 
00047 namespace tcl
00048 {
00049   class interpreter;
00050   class TkWidget;
00051 
00052   enum EventStatus { HANDLED, NOT_HANDLED };
00053 
00055   struct ButtonPressEvent
00056   {
00057     unsigned int button;
00058     int x;
00059     int y;
00060   };
00061 
00063   struct KeyPressEvent
00064   {
00065     const char* keys;
00066     int x;
00067     int y;
00068     bool controlPressed;
00069   };
00070 }
00071 
00072 class TkWidgImpl;
00073 
00074 
00076 
00082 
00083 
00084 class tcl::TkWidget : public virtual nub::object
00085 {
00086 public:
00088   TkWidget(tcl::interpreter& interp,
00089            const char* classname,
00090            const char* pathname,
00091            bool topLevel = false);
00092   virtual ~TkWidget() throw();
00093 
00094   void destroyWidget();
00095 
00097   void winInfo() throw();
00098 
00099   int width() const;
00100   int height() const;
00101   geom::vec2<int> size() const;
00102   void setWidth(int w);
00103   void setHeight(int h);
00104   void setSize(geom::vec2<int> sz);
00105 
00106   tcl::interpreter& interp() const;
00107   Tk_Window tkWin() const;
00108   const char* pathname() const;
00109   double pixelsPerInch() const;
00110 
00112   void setCursor(const char* cursor_spec);
00113 
00115   const char* getCursor() const;
00116 
00118   void warpPointer(int x, int y) const;
00119 
00121   void pack();
00122 
00124 
00126   void repack(const char* options);
00127 
00129   void unpack();
00130 
00131   void iconify();
00132 
00134   void grabKeyboard();
00135 
00137   void ungrabKeyboard();
00138 
00140   void maximize();
00141 
00143   void minimize();
00144 
00145   virtual void displayCallback() = 0;
00146 
00147   virtual void reshapeCallback(int width, int height) = 0;
00148 
00150   void bind(const rutz::fstring& event_sequence,
00151             const rutz::fstring& script);
00152 
00154   void takeFocus();
00155 
00157   void loseFocus();
00158 
00159   void requestRedisplay();
00160 
00161   void hook();
00162 
00163   nub::Signal1<const tcl::ButtonPressEvent&> sigButtonPressed;
00164   nub::Signal1<const tcl::KeyPressEvent&> sigKeyPressed;
00165 
00166 private:
00167   TkWidget(const TkWidget&);
00168   TkWidget& operator=(const TkWidget&);
00169 
00170   TkWidgImpl* const rep;
00171 };
00172 
00173 static const char __attribute__((used)) vcid_groovx_tk_widget_h_utc20050628165845[] = "$Id: widget.h 10065 2007-04-12 05:54:56Z rjpeters $ $HeadURL: file:
00174 #endif // !GROOVX_TK_WIDGET_H_UTC20050628165845_DEFINED

The software described here is Copyright (c) 1998-2005, Rob Peters.
This page was generated Wed Dec 3 06:49:41 2008 by Doxygen version 1.5.5.