Author: matt
Date: 2011-01-09 16:14:22 -0800 (Sun, 09 Jan 2011)
New Revision: 8236
Log:
Modified test1/hello.cxx to show that virtual function calls of classes, 
derived from a Wrapper, work in both directions!

Modified:
   branches/branch-3.0-2011/FL/Fl_Group.H
   branches/branch-3.0-2011/FL/Fl_Widget.H
   branches/branch-3.0-2011/fltk3/Wrapper.h
   branches/branch-3.0-2011/src/Fl_Widget.cxx
   branches/branch-3.0-2011/test/hello.cxx
   branches/branch-3.0-2011/test1/hello.cxx
   branches/branch-3.0-2011/test2/hello.cxx

Modified: branches/branch-3.0-2011/FL/Fl_Group.H
===================================================================
--- branches/branch-3.0-2011/FL/Fl_Group.H      2011-01-09 23:49:21 UTC (rev 
8235)
+++ branches/branch-3.0-2011/FL/Fl_Group.H      2011-01-10 00:14:22 UTC (rev 
8236)
@@ -154,7 +154,11 @@
     invisible Fl_Box as the resizable and/or by using a hierarchy
     of child Fl_Group's.
   */
-  void resizable(Fl_Widget* o) {resizable_ = o;}
+#endif
+  
+  void resizable(Fl_Widget* o) { ((fltk3::Group*)_p)->resizable( 
(fltk3::Widget*)(o->_p) ); }
+  
+#if 0
   /**
     See void Fl_Group::resizable(Fl_Widget *box) 
   */

Modified: branches/branch-3.0-2011/FL/Fl_Widget.H
===================================================================
--- branches/branch-3.0-2011/FL/Fl_Widget.H     2011-01-09 23:49:21 UTC (rev 
8235)
+++ branches/branch-3.0-2011/FL/Fl_Widget.H     2011-01-10 00:14:22 UTC (rev 
8236)
@@ -182,9 +182,13 @@
     _p->wrapper(this);
   }
   
+  virtual void draw() {
+    pVCalls |= 1;
+    ((fltk3::Widget*)_p)->draw();
+    pVCalls &= ~1;
+  }
 #if 0 // TODO: FLTK123
   virtual ~Fl_Widget() {}
-  virtual void draw() {}
   virtual int handle(int event) {}
   virtual void resize(int x, int y, int w, int h) {}
   virtual void show() {}

Modified: branches/branch-3.0-2011/fltk3/Wrapper.h
===================================================================
--- branches/branch-3.0-2011/fltk3/Wrapper.h    2011-01-09 23:49:21 UTC (rev 
8235)
+++ branches/branch-3.0-2011/fltk3/Wrapper.h    2011-01-10 00:14:22 UTC (rev 
8236)
@@ -46,7 +46,7 @@
     : _p(0L) { }
     virtual ~Wrapper() { }
     
-    unsigned int vcalls;
+    unsigned int pVCalls;
     virtual void draw() { /* call _p->draw() with a flag set */ }
   };
   

Modified: branches/branch-3.0-2011/src/Fl_Widget.cxx
===================================================================
--- branches/branch-3.0-2011/src/Fl_Widget.cxx  2011-01-09 23:49:21 UTC (rev 
8235)
+++ branches/branch-3.0-2011/src/Fl_Widget.cxx  2011-01-10 00:14:22 UTC (rev 
8236)
@@ -27,6 +27,7 @@
 
 #include <fltk3/run.h>
 #include <fltk3/Widget.h>
+#include <fltk3/Wrapper.h>
 #include <fltk3/Group.H>
 #include <fltk3/Fl_Tooltip.H>
 #include <fltk3/fl_draw.H>
@@ -341,6 +342,13 @@
 }
 
 void fltk3::Widget::draw() {
+  if (pWrapper) {
+    if ( !(pWrapper->pVCalls & 1) )
+      pWrapper->draw();
+    if ( !(pWrapper->pVCalls & 1) )
+      return;
+    pWrapper->pVCalls &= ~1;
+  }
   draw_box();
   draw_label();
 }

Modified: branches/branch-3.0-2011/test/hello.cxx
===================================================================
--- branches/branch-3.0-2011/test/hello.cxx     2011-01-09 23:49:21 UTC (rev 
8235)
+++ branches/branch-3.0-2011/test/hello.cxx     2011-01-10 00:14:22 UTC (rev 
8236)
@@ -32,7 +32,7 @@
 using namespace fltk3;
 
 int main(int argc, char **argv) {
-  Window *window = new Window(340,180);
+  Window *window = new Window(340,180,"FLTK 3");
   Box *box = new Box(20,40,300,100,"Hello, World!");
   box->box(UP_BOX);
   box->labelfont(BOLD+ITALIC);

Modified: branches/branch-3.0-2011/test1/hello.cxx
===================================================================
--- branches/branch-3.0-2011/test1/hello.cxx    2011-01-09 23:49:21 UTC (rev 
8235)
+++ branches/branch-3.0-2011/test1/hello.cxx    2011-01-10 00:14:22 UTC (rev 
8236)
@@ -28,14 +28,31 @@
 #include <FL/Fl.H>
 #include <FL/Fl_Window.H>
 #include <FL/Fl_Box.H>
+//#include <FL/fl_draw.h>
+#include <fltk3/fl_draw.h>
 
+class MyBox : public Fl_Widget 
+{
+public:
+  MyBox(int x, int y, int w, int h, const char *l=0)
+  : Fl_Widget(x, y, w, h, l) { }
+  void draw() {
+    Fl_Widget::draw();
+    fl_color(FL_RED);
+    fl_line(x(), y(), x()+w(), y()+h());
+  }
+};
+
+
 int main(int argc, char **argv) {
-  Fl_Window *window = new Fl_Window(340,180);
-  Fl_Box *box = new Fl_Box(20,40,300,100,"Hello, World!");
+  Fl_Window *window = new Fl_Window(340,180,"FLTK 1");
+  //Fl_Box *box = new Fl_Box(20,40,300,100,"Hello, World!");
+  Fl_Widget *box = new MyBox(20,40,300,100,"Hello, World!");
   box->box(FL_UP_BOX);
   box->labelfont(FL_BOLD+FL_ITALIC);
   box->labelsize(36);
   box->labeltype(FL_SHADOW_LABEL);
+  window->resizable(box);
   window->end();
   window->show(argc, argv);
   return Fl::run();

Modified: branches/branch-3.0-2011/test2/hello.cxx
===================================================================
--- branches/branch-3.0-2011/test2/hello.cxx    2011-01-09 23:49:21 UTC (rev 
8235)
+++ branches/branch-3.0-2011/test2/hello.cxx    2011-01-10 00:14:22 UTC (rev 
8236)
@@ -6,7 +6,7 @@
 using namespace fltk;
 
 int main(int argc, char **argv) {
-  Window *window = new Window(300, 180);
+  Window *window = new Window(300, 180,"FLTK 2");
   window->begin();
   Widget *box = new Widget(20, 40, 260, 100, "Hello, World!");
   // FIXME: box->box(UP_BOX);

_______________________________________________
fltk-commit mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-commit

Reply via email to