Author: matt
Date: 2011-05-30 10:26:30 -0700 (Mon, 30 May 2011)
New Revision: 8765
Log:
123: handle() function can also be overridden.
Modified:
branches/branch-3.0/FL/Fl_Group.H
branches/branch-3.0/FL/Fl_Window.H
branches/branch-3.0/fltk3/Wrapper.h
branches/branch-3.0/src/Fl_Gl_Window.cxx
branches/branch-3.0/test1/cube.cxx
Modified: branches/branch-3.0/FL/Fl_Group.H
===================================================================
--- branches/branch-3.0/FL/Fl_Group.H 2011-05-30 16:47:48 UTC (rev 8764)
+++ branches/branch-3.0/FL/Fl_Group.H 2011-05-30 17:26:30 UTC (rev 8765)
@@ -48,7 +48,11 @@
#endif
public:
- Fl_Group(int,int,int,int, const char * = 0);
+
+ Fl_Group(int x, int y, int w, int h, const char *label = 0) {
+ _p = new fltk3::Group(x, y, w, h, label);
+ _p->wrapper(this);
+ }
void begin() {
((fltk3::Group*)_p)->begin();
@@ -58,9 +62,12 @@
((fltk3::Group*)_p)->end();
}
+ static Fl_Group *current() {
+ return fltk3::_3to1_group( fltk3::Group::current() );
+ }
+
#if 0 // FIXME: 123
int handle(int);
- static Fl_Group *current();
static void current(Fl_Group *g);
int children() const {return children_;}
Fl_Widget* child(int n) const {return array()[n];}
@@ -98,18 +105,14 @@
unsigned int clip_children() { return (flags() & CLIP_CHILDREN) != 0; }
virtual Fl_Group* as_group() { return this; }
void focus(Fl_Widget* W) {W->take_focus();}
- Fl_Widget* & _ddfdesign_kludge() {return resizable_;}
void forms_end();
#endif
};
class FL_EXPORT Fl_End {
-#if 0 // FIXME: 123
public:
- /** All it does is calling Fl_Group::current()->end() */
- Fl_End() {Fl_Group::current()->end();}
-#endif
+ Fl_End() { Fl_Group::current()->end(); }
};
#endif
Modified: branches/branch-3.0/FL/Fl_Window.H
===================================================================
--- branches/branch-3.0/FL/Fl_Window.H 2011-05-30 16:47:48 UTC (rev 8764)
+++ branches/branch-3.0/FL/Fl_Window.H 2011-05-30 17:26:30 UTC (rev 8765)
@@ -62,8 +62,12 @@
_p->wrapper(this);
}
+ Fl_Window(int x, int y, int w, int h, const char* label = 0) {
+ _p = new fltk3::Window(x, y, w, h, label);
+ _p->wrapper(this);
+ }
+
#if 0 // FIXME: 123
- Fl_Window(int x, int y, int w, int h, const char* title = 0);
virtual ~Fl_Window();
virtual int handle(int);
virtual void resize(int,int,int,int);
@@ -115,7 +119,13 @@
static Fl_Window *current();
void make_current();
virtual Fl_Window* as_window() { return this; }
- void cursor(Fl_Cursor, Fl_Color=FL_BLACK, Fl_Color=FL_WHITE); // platform
dependent
+#endif
+
+ void cursor(Fl_Cursor c, Fl_Color a=FL_BLACK, Fl_Color b=FL_WHITE) {
+ ((fltk3::Window*)_p)->cursor( fltk3::_1to3_cursor(c),
fltk3::_1to3_color(a), fltk3::_1to3_color(b));
+ }
+
+#if 0 // FIXME: 123
void default_cursor(Fl_Cursor, Fl_Color=FL_BLACK, Fl_Color=FL_WHITE);
static void default_callback(Fl_Window*, void* v);
int decorated_w();
Modified: branches/branch-3.0/fltk3/Wrapper.h
===================================================================
--- branches/branch-3.0/fltk3/Wrapper.h 2011-05-30 16:47:48 UTC (rev 8764)
+++ branches/branch-3.0/fltk3/Wrapper.h 2011-05-30 17:26:30 UTC (rev 8765)
@@ -33,6 +33,31 @@
#include <fltk3/Widget.h>
+/*
+ FLTK3_OBJECT_VCALLS_WRAPPER:
+if (pWrapper) {
+ // We only do this tests if there is a wrapper connected to me.
+ if ( pWrapper->pVCalls & Wrapper::pVCallWidgetDraw ) {
+ // if my flag is set, we are being called from the wrapper, so we simply
+ // continue with the original code. The wrapper mus clear the flag.
+ } else {
+ // if my flag is clear, we are called from the core. So lets set the
+ // flag and call the wrapper.
+ pWrapper->pVCalls |= Wrapper::pVCallWidgetDraw;
+ ((WidgetWrapper*)pWrapper)->draw();
+ if ( (pWrapper->pVCalls & Wrapper::pVCallWidgetDraw) ) {
+ // If the flag is still set, the function was overridden in the wrapper.
+ // Clear the flag for the next call and abort.
+ pWrapper->pVCalls &= ~Wrapper::pVCallWidgetDraw;
+ return;
+ } else {
+ // If the wrapper returns with the flag cleared, the default code was
+ // called and we continue with the original code.
+ }
+ }
+}
+*/
+
#define FLTK3_WRAPPER_VCALLS_OBJECT(proto, call, flag) \
virtual void proto { \
if ( pVCalls & pVCallWidget##flag ) { \
@@ -49,12 +74,15 @@
} else { \
pWrapper->pVCalls |= Wrapper::pVCallWidget##flag; \
((WidgetWrapper*)pWrapper)->call; \
- if ( !(pWrapper->pVCalls & Wrapper::pVCallWidget##flag) ) \
+ if ( (pWrapper->pVCalls & Wrapper::pVCallWidget##flag) ) { \
+ pWrapper->pVCalls &= ~Wrapper::pVCallWidget##flag; \
return; \
+ } else { \
+ } \
} \
- pWrapper->pVCalls &= ~Wrapper::pVCallWidget##flag; \
}
+
#define FLTK3_WRAPPER_VCALLS_OBJECT_INT(proto, call, flag) \
virtual int proto { \
int ret = 0; \
@@ -73,10 +101,12 @@
} else { \
pWrapper->pVCalls |= Wrapper::pVCallWidget##flag; \
int ret = ((WidgetWrapper*)pWrapper)->call; \
- if ( !(pWrapper->pVCalls & Wrapper::pVCallWidget##flag) ) \
+ if ( (pWrapper->pVCalls & Wrapper::pVCallWidget##flag) ) { \
+ pWrapper->pVCalls &= ~Wrapper::pVCallWidget##flag; \
return ret; \
+ } else { \
+ } \
} \
- pWrapper->pVCalls &= ~Wrapper::pVCallWidget##flag; \
}
Modified: branches/branch-3.0/src/Fl_Gl_Window.cxx
===================================================================
--- branches/branch-3.0/src/Fl_Gl_Window.cxx 2011-05-30 16:47:48 UTC (rev
8764)
+++ branches/branch-3.0/src/Fl_Gl_Window.cxx 2011-05-30 17:26:30 UTC (rev
8765)
@@ -533,30 +533,7 @@
buffers are swapped after this function is completed.
*/
void fltk3::GlWindow::draw() {
- //FLTK3_OBJECT_VCALLS_WRAPPER(draw(), Draw)
-
- if (pWrapper) {
- // We only do this tests if there is a wrapper connected to me.
- if ( pWrapper->pVCalls & Wrapper::pVCallWidgetDraw ) {
- // if my flag is set, we are being called from the wrapper, so we simply
- // continue with the original code. The wrapper mus clear the flag.
- } else {
- // if my flag is clear, we are called from the core. So lets set the
- // flag and call the wrapper.
- pWrapper->pVCalls |= Wrapper::pVCallWidgetDraw;
- ((WidgetWrapper*)pWrapper)->draw();
- if ( (pWrapper->pVCalls & Wrapper::pVCallWidgetDraw) ) {
- // If the flag is still set, the function was overridden in the
wrapper.
- // Clear the flag for the next call and abort.
- pWrapper->pVCalls &= ~Wrapper::pVCallWidgetDraw;
- return;
- } else {
- // If the wrapper returns with the flag cleared, the default code was
- // called and we continue with the original code.
- }
- }
- }
-
+ FLTK3_OBJECT_VCALLS_WRAPPER(draw(), Draw)
fltk3::fatal("fltk3::GlWindow::draw() *must* be overriden. Please refer to
the documentation.");
}
@@ -566,18 +543,7 @@
*/
int fltk3::GlWindow::handle(int event)
{
-#ifdef __APPLE_QUARTZ__
- /*if (event==fltk3::HIDE) {
- // if we are not hidden, just the parent was hidden, so we must throw away
the context
- if (!visible_r())
- context(0); // remove context without setting the hidden flags
- }
- if (event==fltk3::SHOW) {
- // if we are not hidden, just the parent was shown, so we must create a
new context
- if (visible_r())
- show(); //
- }*/
-#endif
+ FLTK3_OBJECT_VCALLS_WRAPPER_INT(handle(event), Handle)
return fltk3::Window::handle(event);
}
Modified: branches/branch-3.0/test1/cube.cxx
===================================================================
--- branches/branch-3.0/test1/cube.cxx 2011-05-30 16:47:48 UTC (rev 8764)
+++ branches/branch-3.0/test1/cube.cxx 2011-05-30 17:26:30 UTC (rev 8765)
@@ -57,9 +57,7 @@
class cube_box : public Fl_Gl_Window {
void draw();
-#if 0 // FIXME: 123
int handle(int);
-#endif
public:
double lasttime;
int wire;
@@ -130,8 +128,6 @@
glEnable(GL_DEPTH_TEST);
}
-#if 0 // FIXME: 123
-
int cube_box::handle(int e) {
switch (e) {
case FL_ENTER: cursor(FL_CURSOR_CROSS); break;
@@ -142,8 +138,6 @@
#endif
-#endif
-
Fl_Window *form;
Fl_Slider *speed, *size;
Fl_Button *button, *wire, *flat;
_______________________________________________
fltk-commit mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-commit