wrap otk with swig/python
This commit is contained in:
parent
2e273ae3ac
commit
5869cc29ef
14 changed files with 149 additions and 58 deletions
|
@ -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 \
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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:
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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; }
|
||||
|
|
|
@ -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);
|
||||
|
|
81
otk/otk.i
Normal file
81
otk/otk.i
Normal file
|
@ -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"
|
15
otk/style.hh
15
otk/style.hh
|
@ -13,6 +13,11 @@
|
|||
|
||||
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; }
|
||||
|
||||
|
|
|
@ -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); }
|
||||
|
|
|
@ -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; }
|
||||
|
||||
|
|
Loading…
Reference in a new issue