00001
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00033
00034 #ifndef GROOVX_GFX_TCLPKG_TOGLET_CC_UTC20050628170310_DEFINED
00035 #define GROOVX_GFX_TCLPKG_TOGLET_CC_UTC20050628170310_DEFINED
00036
00037 #include "tcl-gfx/tclpkg-toglet.h"
00038
00039 #include "gfx/glcanvas.h"
00040 #include "gfx/gxcamera.h"
00041 #include "gfx/gxnode.h"
00042
00043 #include "nub/objfactory.h"
00044 #include "nub/ref.h"
00045
00046 #include "tcl/objpkg.h"
00047 #include "tcl/list.h"
00048 #include "tcl/pkg.h"
00049
00050 #include "tcl-gfx/toglet.h"
00051 #include "tcl-gfx/vectcl.h"
00052
00053 #include "rutz/error.h"
00054
00055 #include "rutz/trace.h"
00056
00057 namespace
00058 {
00059
00060
00061 nub::uid see(nub::soft_ref<Toglet> widg, nub::ref<GxNode> item)
00062 {
00063 widg->setDrawable(item);
00064 widg->setVisibility(true);
00065 widg->fullRender();
00066 return item->id();
00067 }
00068
00069
00070
00071
00072
00073 void clear_on_exit()
00074 {
00075 if (Toglet::getCurrent().is_valid())
00076 {
00077 Toglet::getCurrent()->setVisibility(false);
00078 }
00079 }
00080 }
00081
00082 #include <tcl.h>
00083
00084 extern "C"
00085 int Toglet_Init(Tcl_Interp* interp)
00086 {
00087 GVX_TRACE("Toglet_Init");
00088
00089 if (Tcl_PkgRequire(interp, "Tk", 0, 0) == 0)
00090 return 1;
00091
00092 GVX_PKG_CREATE(pkg, interp, "Toglet", "4.$Revision: 10065 $");
00093
00094 pkg->on_exit( &clear_on_exit );
00095
00096 pkg->inherit_pkg("TkWidget");
00097 tcl::def_basic_type_cmds<Toglet>(pkg, SRC_POS);
00098
00099 nub::obj_factory::instance().register_creator( &Toglet::make );
00100 nub::obj_factory::instance().register_creator( &Toglet::makeToplevel,
00101 "TopToglet" );
00102
00103 pkg->def( "::tog", 0, &Toglet::getCurrent, SRC_POS );
00104 pkg->def( "::cv", 0, &GLCanvas::getCurrent, SRC_POS );
00105
00106 pkg->def( "current", "toglet_id", &Toglet::setCurrent, SRC_POS );
00107 pkg->def( "current", 0, &Toglet::getCurrent, SRC_POS );
00108 pkg->def( "defaultParent", "parent", &Toglet::defaultParent, SRC_POS );
00109 pkg->def( "see", "gxnode_id", &see, SRC_POS );
00110
00111 pkg->def_setter("allowRefresh", &Toglet::allowRefresh, SRC_POS);
00112 pkg->def("animate", "objref(s) frames_per_second", &Toglet::animate, SRC_POS);
00113 pkg->def_get_set("camera", &Toglet::getCamera, &Toglet::setCamera, SRC_POS);
00114 pkg->def_getter("canvas", &Toglet::getCanvas, SRC_POS);
00115 pkg->def_action("clearscreen", &Toglet::fullClearscreen, SRC_POS);
00116 pkg->def("hold", "objref(s) hold_on", &Toglet::setHold, SRC_POS);
00117 pkg->def("setVisible", "objref(s) visibility", &Toglet::setVisibility, SRC_POS);
00118 pkg->def_get_set("size", &Toglet::size, &Toglet::setSize, SRC_POS);
00119 pkg->def_action("swapBuffers", &Toglet::swapBuffers, SRC_POS);
00120 pkg->def_action("undraw", &Toglet::undraw, SRC_POS);
00121
00122 Toglet::make();
00123
00124 pkg->eval("proc ::clearscreen {} { Toglet::clearscreen [Toglet::current] }\n"
00125 "proc ::see {id} { Toglet::see [Toglet::current] $id }\n"
00126 "proc ::undraw {} { Toglet::undraw [Toglet::current] }\n"
00127 );
00128
00129 GVX_PKG_RETURN(pkg);
00130 }
00131
00132 static const char __attribute__((used)) vcid_groovx_gfx_tclpkg_toglet_cc_utc20050628170310[] = "$Id: tclpkg-toglet.cc 10065 2007-04-12 05:54:56Z rjpeters $ $HeadURL: file:
00133 #endif // !GROOVX_GFX_TCLPKG_TOGLET_CC_UTC20050628170310_DEFINED