]> Dogcows Code - chaz/openbox/commitdiff
wrap otk with swig/python
authorDana Jansens <danakj@orodu.net>
Tue, 24 Dec 2002 21:27:16 +0000 (21:27 +0000)
committerDana Jansens <danakj@orodu.net>
Tue, 24 Dec 2002 21:27:16 +0000 (21:27 +0000)
14 files changed:
otk/Makefile.am
otk/application.cc
otk/application.hh
otk/button.hh
otk/color.hh
otk/eventdispatcher.hh
otk/eventhandler.hh
otk/focuslabel.hh
otk/focuswidget.hh
otk/image.hh
otk/otk.i [new file with mode: 0644]
otk/style.hh
otk/texture.hh
otk/widget.hh

index 3f32a45e2386650860821e138d074ecf3310138c..568ade0edf1ad22deb4b5cf25c03238f8a326d6e 100644 (file)
@@ -1,4 +1,4 @@
-CPPFLAGS=$(XFT_CFLAGS) @CPPFLAGS@
+CPPFLAGS=$(XFT_CFLAGS) $(PYTHON_CFLAGS) @CPPFLAGS@
 
 INCLUDES= -I../src
 
@@ -9,7 +9,10 @@ libotk_a_SOURCES= color.cc display.cc font.cc gccache.cc image.cc \
                   texture.cc timer.cc timerqueuemanager.cc style.cc \
                   configuration.cc util.cc widget.cc focuswidget.cc \
                   button.cc eventhandler.cc eventdispatcher.cc \
-                  label.cc focuslabel.cc application.cc appwidget.cc
+                  label.cc focuslabel.cc application.cc appwidget.cc \
+                  otk_wrap.cc
+
+#libotk_a_LDFLAGS = $(PYTHON_LDFLAGS)
 
 MAINTAINERCLEANFILES= Makefile.in
 
@@ -19,6 +22,12 @@ distclean-local:
 otk_test: libotk.a otk_test.cc
        $(CXX) $(CPPFLAGS) -DHAVE_CONFIG_H -I. -I. -I.. -I../src $(XFT_CFLAGS) -Wall -W -pedantic -DNDEBUG -g -O2 -o otk_test otk_test.cc $(XFT_LIBS) ./libotk.a 
 
+otk.i: $(wildcard *.hh)
+       touch $@
+
+otk_wrap.cc: otk.i
+       swig -python -c++ -nodefault -o $@ $<
+
 # local dependencies
 application.o: application.cc application.hh eventdispatcher.hh \
  eventhandler.hh display.hh configuration.hh timerqueuemanager.hh \
index 70f9e24b7565339beccd5e52822679e1a473ddae..dedefaef4b527a4fb9930a377fc229e0b09633a8 100644 (file)
@@ -60,12 +60,12 @@ void OtkApplication::loadStyle(void)
   _style->load(*_style_conf);
 }
 
-void OtkApplication::exec(void)
+void OtkApplication::run(void)
 {
   if (_appwidget_count <= 0) {
     std::cerr << "ERROR: No main widgets exist. You must create and show() " <<
       "an OtkAppWidget for the OtkApplication before calling " <<
-      "OtkApplication::exec().\n";
+      "OtkApplication::run().\n";
     ::exit(1);
   }
 
index 7696e73d3860cd5ef23327faf23600b1eb1dea77..63fb4195a5286c0d6ec4d4f0c8ddc0d30de97e3e 100644 (file)
@@ -19,13 +19,13 @@ public:
   OtkApplication(int argc, char **argv);
   virtual ~OtkApplication();
 
-  virtual void exec(void);
+  virtual void run(void);
   // more bummy cool functionality
 
   void setDockable(bool dockable) { _dockable = dockable; }
   inline bool isDockable(void) const { return _dockable; }
 
-  inline Style *getStyle(void) const { return _style; }
+  inline otk::Style *getStyle(void) const { return _style; }
   // more accessors
 
 private:
index 5924e9b0ebe18783e9b10521c9f23acaccb25127..17ddce03befae988effdbbfabd130a2164ed5be2 100644 (file)
@@ -12,18 +12,18 @@ public:
   OtkButton(OtkWidget *parent);
   ~OtkButton();
 
-  inline const BTexture *getPressedFocusTexture(void) const
+  inline const otk::BTexture *getPressedFocusTexture(void) const
   { return _pressed_focus_tx; }
-  void setPressedFocusTexture(BTexture *texture)
+  void setPressedFocusTexture(otk::BTexture *texture)
   { _pressed_focus_tx = texture; }
 
-  inline const BTexture *getPressedUnfocusTexture(void) const
+  inline const otk::BTexture *getPressedUnfocusTexture(void) const
   { return _pressed_unfocus_tx; }
-  void setPressedUnfocusTexture(BTexture *texture)
+  void setPressedUnfocusTexture(otk::BTexture *texture)
   { _pressed_unfocus_tx = texture; }
 
-  void setTexture(BTexture *texture);
-  void setUnfocusTexture(BTexture *texture);
+  void setTexture(otk::BTexture *texture);
+  void setUnfocusTexture(otk::BTexture *texture);
 
   inline bool isPressed(void) const { return _pressed; }
   void press(unsigned int mouse_button);
@@ -32,7 +32,7 @@ public:
   void buttonPressHandler(const XButtonEvent &e);
   void buttonReleaseHandler(const XButtonEvent &e);
 
-  virtual void setStyle(Style *style);
+  virtual void setStyle(otk::Style *style);
   
 private:
 
index 387c81bf109775625c514dba24279f26cfaa4f89..cbbff6468e95e7f75ab37d7de8d5b591306d322b 100644 (file)
@@ -40,7 +40,9 @@ public:
   unsigned long pixel(void) const;
 
   // operators
+#ifndef SWIG
   BColor &operator=(const BColor &c);
+#endif
   inline bool operator==(const BColor &c) const
   { return (r == c.r && b == c.b && b == c.b); }
   inline bool operator!=(const BColor &c) const
index 9f7fb8656f5febebb7c8e3758d63010af88cb44f..a9b5af7b2997056a3831decf5b230fb822f189b7 100644 (file)
@@ -16,21 +16,21 @@ public:
   virtual ~OtkEventDispatcher();
 
   virtual void clearAllHandlers(void);
-  virtual void registerHandler(Window id, OtkEventHandler *handler);
+  virtual void registerHandler(Window id, otk::OtkEventHandler *handler);
   virtual void clearHandler(Window id);
   virtual void dispatchEvents(void);
 
-  inline void setFallbackHandler(OtkEventHandler *fallback)
+  inline void setFallbackHandler(otk::OtkEventHandler *fallback)
   { _fallback = fallback; }
-  OtkEventHandler *getFallbackHandler(void) const { return _fallback; }
+  otk::OtkEventHandler *getFallbackHandler(void) const { return _fallback; }
 
   //! Sets an event handler that gets all events for all handlers after
   //! any specific handlers have received them
-  inline void setMasterHandler(OtkEventHandler *master)
+  inline void setMasterHandler(otk::OtkEventHandler *master)
   { _master = master; }
-  OtkEventHandler *getMasterHandler(void) const { return _master; }
+  otk::OtkEventHandler *getMasterHandler(void) const { return _master; }
 
-  OtkEventHandler *findHandler(Window win);
+  otk::OtkEventHandler *findHandler(Window win);
   
 private:
   OtkEventMap _map;
index bbc0449db5ae8fb4fb6a20f69b0ca98f4e86d55f..9308ed03fb28d3668df9b0df501a0da5f48c685e 100644 (file)
@@ -11,7 +11,7 @@ extern "C" {
 
 namespace otk {
 
-class OtkEventHandler{
+class OtkEventHandler {
 public:
   //! Dispatches events to one of the other handlers based on their type.
   virtual void handle(const XEvent &e);
index 042082ebae58578c4c1b0fdef9d0f918b58d5c71..64b8189a3dc4d20200d30424f6dd91c20076c8d1 100644 (file)
@@ -18,7 +18,7 @@ public:
 
   void update(void);
 
-  virtual void setStyle(Style *style);
+  virtual void setStyle(otk::Style *style);
   
 private:
   //! Object used by Xft to render to the drawable
index 2a97c6aa5991abaf304af7dd466bd47049fb4e49..bc69ad6b6ae866e54526c16dd45799566b368eaf 100644 (file)
@@ -10,23 +10,23 @@ class OtkFocusWidget : public OtkWidget {
 
 public:
 
-  OtkFocusWidget(OtkWidget *parent, Direction = Horizontal);
+  OtkFocusWidget(otk::OtkWidget *parent, Direction = Horizontal);
   virtual ~OtkFocusWidget();
 
   virtual void focus(void);
   virtual void unfocus(void);
 
-  virtual void setTexture(BTexture *texture);
-  virtual void setBorderColor(const BColor *color);
+  virtual void setTexture(otk::BTexture *texture);
+  virtual void setBorderColor(const otk::BColor *color);
 
-  inline void setUnfocusTexture(BTexture *texture)
+  inline void setUnfocusTexture(otk::BTexture *texture)
   { _unfocus_texture = texture; }
-  inline BTexture *getUnfocusTexture(void) const
+  inline otk::BTexture *getUnfocusTexture(void) const
   { return _unfocus_texture; }
 
-  inline void setUnfocusBorderColor(const BColor *color)
+  inline void setUnfocusBorderColor(const otk::BColor *color)
   { _unfocus_bcolor = color; }
-  inline const BColor *getUnfocusBorderColor(void) const
+  inline const otk::BColor *getUnfocusBorderColor(void) const
   { return _unfocus_bcolor; }
 
   inline bool isFocused(void) const { return _focused; }
index 5407e5227818541f718a0b6624ee957f12a3f1f9..da489323af7e7d1112511d9dbf70d965b0a0a89e 100644 (file)
@@ -68,15 +68,17 @@ public:
 
 class BImageControl {
 public:
+#ifndef SWIG
   struct CachedImage {
     Pixmap pixmap;
 
     unsigned int count, width, height;
     unsigned long pixel1, pixel2, texture;
   };
+#endif
 
-  BImageControl(OBTimerQueueManager *timermanager,
-                const ScreenInfo *scrn,
+  BImageControl(otk::OBTimerQueueManager *timermanager,
+                const otk::ScreenInfo *scrn,
                 bool _dither= False, int _cpc = 4,
                 unsigned long cache_timeout = 300000l,
                 unsigned long cmax = 200l);
@@ -98,7 +100,7 @@ public:
   unsigned long getSqrt(unsigned int x);
 
   Pixmap renderImage(unsigned int width, unsigned int height,
-                     const BTexture &texture);
+                     const otk::BTexture &texture);
 
   void installRootColormap(void);
   void removeImage(Pixmap pixmap);
diff --git a/otk/otk.i b/otk/otk.i
new file mode 100644 (file)
index 0000000..9fcd5b6
--- /dev/null
+++ b/otk/otk.i
@@ -0,0 +1,81 @@
+// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
+
+%module otk
+
+%{
+#ifdef HAVE_CONFIG_H
+#  include "../config.h"
+#endif
+
+#include "application.hh"
+#include "appwidget.hh"
+#include "assassin.hh"
+#include "button.hh"
+#include "color.hh"
+#include "configuration.hh"
+#include "display.hh"
+#include "eventdispatcher.hh"
+#include "eventhandler.hh"
+#include "focuslabel.hh"
+#include "focuswidget.hh"
+#include "font.hh"
+#include "gccache.hh"
+#include "image.hh"
+#include "label.hh"
+#include "point.hh"
+#include "property.hh"
+#include "rect.hh"
+#include "screeninfo.hh"
+#include "strut.hh"
+#include "style.hh"
+#include "texture.hh"
+#include "timer.hh"
+#include "timerqueue.hh"
+#include "timerqueuemanager.hh"
+#include "util.hh"
+#include "widget.hh"
+%}
+
+%include stl.i
+//%include std_list.i
+
+namespace otk {
+%rename(setValue_bool) Configuration::setValue(std::string const &,bool);
+%rename(setValue_unsigned) Configuration::setValue(const std::string &, unsigned int);
+%rename(setValue_long) Configuration::setValue(const std::string &, long);
+%rename(setValue_unsignedlong) Configuration::setValue(const std::string &, unsigned long);
+%rename(setValue_string) Configuration::setValue(const std::string &, const std::string &);
+%rename(setValue_charptr) Configuration::setValue(const std::string &, const char *);
+
+%rename(itostring_unsigned) itostring(unsigned int);
+%rename(itostring_long) itostring(long);
+%rename(itostring_unsigned_long) itostring(unsigned long);
+}
+
+%include "eventdispatcher.hh"
+%include "eventhandler.hh"
+%include "widget.hh"
+%include "focuswidget.hh"
+%include "focuslabel.hh"
+%include "appwidget.hh"
+%include "application.hh"
+%include "assassin.hh"
+%include "button.hh"
+%include "color.hh"
+%include "configuration.hh"
+%include "display.hh"
+%include "font.hh"
+%include "gccache.hh"
+%include "image.hh"
+%include "label.hh"
+%include "point.hh"
+%include "property.hh"
+%include "rect.hh"
+%include "screeninfo.hh"
+%include "strut.hh"
+%include "style.hh"
+%include "texture.hh"
+%include "timer.hh"
+%include "timerqueue.hh"
+%include "timerqueuemanager.hh"
+%include "util.hh"
index c0e0bbd9daeefc5eacd197b58d40ea029e6779db..ec9f3f8d4263a40cb23d7e5a8b9b52ded00622fc 100644 (file)
 
 namespace otk {
 
+struct PixmapMask {
+  Pixmap mask;
+  unsigned int w, h;
+};
+
 class Style {
 public:
 
@@ -23,11 +28,6 @@ public:
   enum TextJustify { LeftJustify = 1, RightJustify, CenterJustify };
   enum BulletType { RoundBullet = 1, TriangleBullet, SquareBullet, NoBullet };
 
-  struct PixmapMask {
-    Pixmap mask;
-    unsigned int w, h;
-  };
-
 // private:
 
   BImageControl *image_control;
@@ -83,17 +83,12 @@ public:
 
   void load(const Configuration &style);
 
-  inline BColor *getBorderColor(void) { return &border_color; }
-
   inline BColor *getTextFocus(void) { return &l_text_focus; }
   inline BColor *getTextUnfocus(void) { return &l_text_unfocus; }
 
   inline BColor *getButtonPicFocus(void) { return &b_pic_focus; }
   inline BColor *getButtonPicUnfocus(void) { return &b_pic_unfocus; }
 
-  inline BTexture *getFrameFocus(void) { return &f_focus; }
-  inline BTexture *getFrameUnfocus(void) { return &f_unfocus; }
-
   inline BTexture *getTitleFocus(void) { return &t_focus; }
   inline BTexture *getTitleUnfocus(void) { return &t_unfocus; }
 
index d887a33783ef66dc38f9ce74893e15ad1e8a135b..f487f449216cad3f582b278839538b5a47c53bf3 100644 (file)
@@ -63,7 +63,9 @@ public:
   void setTexture(const unsigned long _texture) { t  = _texture; }
   void addTexture(const unsigned long _texture) { t |= _texture; }
 
+#ifndef SWIG
   BTexture &operator=(const BTexture &tt);
+#endif
   inline bool operator==(const BTexture &tt)
   { return (c == tt.c && ct == tt.ct && lc == tt.lc &&
             sc == tt.sc && t == tt.t); }
index 608d8e58581b5c0ec8d36464b5c5d752375eeff0..fd14e57b1c0e0039e08009d1525742cd622e5c86 100644 (file)
@@ -25,8 +25,8 @@ public:
 
   typedef std::list<OtkWidget *> OtkWidgetList;
 
-  OtkWidget(OtkWidget *parent, Direction = Horizontal);
-  OtkWidget(OtkEventDispatcher *event_dispatcher, Style *style,
+  OtkWidget(otk::OtkWidget *parent, Direction = Horizontal);
+  OtkWidget(otk::OtkEventDispatcher *event_dispatcher, otk::Style *style,
             Direction direction = Horizontal, Cursor cursor = 0,
             int bevel_width = 1);
 
@@ -38,12 +38,12 @@ public:
   void configureHandler(const XConfigureEvent &e);
 
   inline Window window(void) const { return _window; }
-  inline const OtkWidget *parent(void) const { return _parent; }
+  inline const otk::OtkWidget *parent(void) const { return _parent; }
   inline const OtkWidgetList &children(void) const { return _children; }
   inline unsigned int screen(void) const { return _screen; }
-  inline const Rect &rect(void) const { return _rect; }
+  inline const otk::Rect &rect(void) const { return _rect; }
 
-  void move(const Point &to);
+  void move(const otk::Point &to);
   void move(int x, int y);
 
   virtual void setWidth(int);
@@ -52,11 +52,11 @@ public:
   virtual int width() const { return _rect.width(); }
   virtual int height() const { return _rect.height(); }
 
-  virtual void resize(const Point &to);
+  virtual void resize(const otk::Point &to);
   virtual void resize(int x, int y);
 
-  virtual void setGeometry(const Rect &new_geom);
-  virtual void setGeometry(const Point &topleft, int width, int height);
+  virtual void setGeometry(const otk::Rect &new_geom);
+  virtual void setGeometry(const otk::Point &topleft, int width, int height);
   virtual void setGeometry(int x, int y, int width, int height);
 
   inline bool isVisible(void) const { return _visible; };
@@ -75,12 +75,12 @@ public:
   bool grabKeyboard(void);
   void ungrabKeyboard(void);
 
-  inline BTexture *texture(void) const { return _texture; }
-  virtual void setTexture(BTexture *texture)
+  inline otk::BTexture *texture(void) const { return _texture; }
+  virtual void setTexture(otk::BTexture *texture)
     { _texture = texture; _dirty = true; }
 
-  inline const BColor *borderColor(void) const { return _bcolor; }
-  virtual void setBorderColor(const BColor *color) {
+  inline const otk::BColor *borderColor(void) const { return _bcolor; }
+  virtual void setBorderColor(const otk::BColor *color) {
     assert(color); _bcolor = color;
     XSetWindowBorder(OBDisplay::display, _window, color->pixel());
   }
@@ -88,7 +88,7 @@ public:
   inline int borderWidth(void) const { return _bwidth; }
   void setBorderWidth(int width) {
     _bwidth = width;
-    XSetWindowBorderWidth(OBDisplay::display, _window, width);
+    XSetWindowBorderWidth(otk::OBDisplay::display, _window, width);
   }
 
   virtual void addChild(OtkWidget *child, bool front = false);
@@ -113,12 +113,12 @@ public:
   inline Direction direction(void) const { return _direction; }
   void setDirection(Direction dir) { _direction = dir; }
 
-  inline Style *style(void) const { return _style; }
-  virtual void setStyle(Style *style);
+  inline otk::Style *style(void) const { return _style; }
+  virtual void setStyle(otk::Style *style);
 
-  inline OtkEventDispatcher *eventDispatcher(void)
+  inline otk::OtkEventDispatcher *eventDispatcher(void)
   { return _event_dispatcher; }
-  void setEventDispatcher(OtkEventDispatcher *disp);
+  void setEventDispatcher(otk::OtkEventDispatcher *disp);
 
   void unmanaged(void) { _unmanaged = true; }
 
This page took 0.040916 seconds and 4 git commands to generate.