Debian Codegraph @

swig/Fl_Widget.i

raw
1 /* File : Fl_Widget.i */
2 //%module Fl_Widget
3
4 %feature("docstring") ::Fl_Widget
5 """
6 Fl_Widget is the base class for all widgets in FLTK. You can't create one of
7 these because the constructor is not public. However you can subclass it.
8
9 All 'property' accessing methods, such as color(), parent(), or argument()
10 are implemented as trivial inline functions and thus are as fast and small
11 as accessing fields in a structure. Unless otherwise noted, the property
12 setting methods such as color(n) or label(s) are also trivial inline
13 functions, even if they change the widget's appearance. It is up to the user
14 code to call redraw() after these.
15 """ ;
16
17 %{
18 #include <FL/Fl.H>
19 #include "FL/Fl_Widget.H"
20 %}
21
22 %include "macros.i"
23
24 CHANGE_OWNERSHIP(Fl_Widget)
25
26 %pythonappend Fl_Widget::image(Fl_Image *a) %{
27 if len(args) > 0:
28 #delegate ownership to C++
29 self.my_image = args[0]
30 %}
31 %pythonappend Fl_Widget::deimage(Fl_Image *a) %{
32 if len(args) > 0:
33 #delegate ownership to C++
34 self.my_deimage = args[0]
35 %}
36
37 %pythonappend Fl_Widget::label %{
38 if len(args) > 0:
39 self.my_label = args[len(args)-1]
40 %}
41
42 DEFINE_CALLBACK(Fl_Widget)
43
44 %ignore Fl_Widget::image(Fl_Image& a);
45 %ignore Fl_Widget::deimage(Fl_Image& a);
46 //%ignore Fl_Widget::label;
47 %ignore Fl_Widget::user_data(void *);
48 %ignore Fl_Widget::user_data() const;
49
50 // typemap for Fl_Label::measure
51 %apply int *INOUT { int &w };
52 %apply int *INOUT { int &h };
53
54 // typemap for Fl_Widget::measure_label
55 %apply int *INOUT { int& ww };
56 %apply int *INOUT { int& hh };
57
58 %include "FL/Fl_Widget.H"
59
60 %clear int &w;
61 %clear int &h;
62 %clear int& ww;
63 %clear int& hh;
64
65 %extend Fl_Widget {
66 #include <FL/Fl_Window.H>
67 #include <FL/Fl_Image.H>
68
69 // reimplementing protected member draw_label()
70 void draw_label()
71 {
72 int X = self->x()+Fl::box_dx(self->box());
73 int W = self->w()-Fl::box_dw(self->box());
74 if (W > 11 && self->align()&(FL_ALIGN_LEFT|FL_ALIGN_RIGHT)) {X += 3; W -= 6;}
75 self->draw_label(X, self->y()+Fl::box_dy(self->box()), W, self->h()-Fl::box_dh(self->box()),self->align());
76 }
77
78 // reimplementing protected member draw_label()
79 void draw_backdrop()
80 {
81 if (self->align() & FL_ALIGN_IMAGE_BACKDROP) {
82 const Fl_Image *img = self->image();
83 // if there is no image, we will not draw the deimage either
84 if (img && self->deimage() && !self->active_r())
85 img = self->deimage();
86 if (img)
87 ((Fl_Image*)img)->draw(self->x()+(self->w()-img->w())/2, self->y()+(self->h()-img->h())/2);
88 }
89 }
90 }
91
92 ADD_CALLBACK(Fl_Widget)
93 ADD_USERDATA(Fl_Widget)
94
95
96 %typemap(in) PyObject *PyFunc {
97 if (!PyCallable_Check($input)) {
98 PyErr_SetString(PyExc_TypeError, "Need a callable object!");
99 return NULL;
100 }
101 $1 = $input;
102 }
103
104
105