Author: matt
Date: 2012-04-30 17:29:20 -0700 (Mon, 30 Apr 2012)
New Revision: 9419
Log:
Fixup fltk3::Box for relative coordinates.

Modified:
   branches/branch-3.0/include/fltk3/Box.h
   branches/branch-3.0/src/fltk3/Box.cxx
   branches/branch-3.0/src/fltk3/boxtype.cxx
   branches/branch-3.0/src/fltk3/labeltype.cxx

Modified: branches/branch-3.0/include/fltk3/Box.h
===================================================================
--- branches/branch-3.0/include/fltk3/Box.h     2012-04-30 23:18:28 UTC (rev 
9418)
+++ branches/branch-3.0/include/fltk3/Box.h     2012-05-01 00:29:20 UTC (rev 
9419)
@@ -39,7 +39,9 @@
   class Widget;
 
   /**
-   This widget simply draws its box, and possibly it's label.  Putting it
+   \brief This widget draws a box with an optional label.
+   
+   This widget simply draws its box, and possibly it's label. Putting it
    before some other widgets and making it big enough to surround them
    will let you draw a frame around them.
    */
@@ -50,21 +52,22 @@
     
   public:
     /**
-     - The first constructor sets box() to fltk3::NO_BOX, which
-     means it is invisible. However such widgets are useful as placeholders
-     or fltk3::Group::resizable()
-     values.  To change the box to something visible, use box(n).
-     - The second form of the constructor sets the box to the specified box
-     type.
-     <P>The destructor removes the box.
+     \brief Box constructor.
+     
+     This constructor sets box() to fltk3::NO_BOX, which means it is 
invisible. 
+     However such widgets are useful as placeholders or 
+     fltk3::Group::resizable() values.  To change the box to something 
visible, 
+     use box(n).
      */
-    Box(int X, int Y, int W, int H, const char *l=0)
-    : fltk3::Widget(X,Y,W,H,l) {}
+    Box(int X, int Y, int W, int H, const char *l=0);
     
-    /**    See fltk3::Box::Box(int x, int y, int w, int h, const char * = 0)   
*/
-    Box(fltk3::Boxtype b, int X, int Y, int W, int H, const char *l)
-    : fltk3::Widget(X,Y,W,H,l) {box(b);}
-    
+    /**
+     \brief Box constructor.
+     
+     This constructor also sets the box type.
+     */
+    Box(fltk3::Boxtype b, int X, int Y, int W, int H, const char *l);
+
     virtual int handle(int);
   };
   

Modified: branches/branch-3.0/src/fltk3/Box.cxx
===================================================================
--- branches/branch-3.0/src/fltk3/Box.cxx       2012-04-30 23:18:28 UTC (rev 
9418)
+++ branches/branch-3.0/src/fltk3/Box.cxx       2012-05-01 00:29:20 UTC (rev 
9419)
@@ -30,6 +30,21 @@
 #include <fltk3/Wrapper.h>
 
 
+fltk3::Box::Box(int X, int Y, int W, int H, const char *l)
+: fltk3::Widget(X,Y,W,H,l) 
+{
+  set_group_relative(); // FIXME: remove
+}
+
+
+fltk3::Box::Box(fltk3::Boxtype b, int X, int Y, int W, int H, const char *l)
+: fltk3::Widget(X,Y,W,H,l) 
+{
+  set_group_relative(); // FIXME: remove
+  box(b);
+}
+
+
 void fltk3::Box::draw() {
   draw_box();
   draw_label();

Modified: branches/branch-3.0/src/fltk3/boxtype.cxx
===================================================================
--- branches/branch-3.0/src/fltk3/boxtype.cxx   2012-04-30 23:18:28 UTC (rev 
9418)
+++ branches/branch-3.0/src/fltk3/boxtype.cxx   2012-05-01 00:29:20 UTC (rev 
9419)
@@ -447,7 +447,7 @@
 /** Draws the widget box according its box style */
 void fltk3::Widget::draw_box() const {
   if (box_) {
-    if (flags()&GROUP_RELATIVE) {
+    if (is_group_relative()) {
       draw_box((fltk3::Boxtype)box_, 0, 0, w_, h_, color_);
     } else {
       draw_box((fltk3::Boxtype)box_, x_, y_, w_, h_, color_);

Modified: branches/branch-3.0/src/fltk3/labeltype.cxx
===================================================================
--- branches/branch-3.0/src/fltk3/labeltype.cxx 2012-04-30 23:18:28 UTC (rev 
9418)
+++ branches/branch-3.0/src/fltk3/labeltype.cxx 2012-05-01 00:29:20 UTC (rev 
9419)
@@ -124,10 +124,16 @@
     This is the normal call for a widget's draw() method.
  */
 void fltk3::Widget::draw_label() const {
-  int X = x_+fltk3::box_dx(box());
+  int wx, wy;
+  if (is_group_relative()) {
+    wx = wy = 0;
+  } else {
+    wx = x_; wy = y_;
+  }
+  int X = wx+fltk3::box_dx(box());
   int W = w_-fltk3::box_dw(box());
   if (W > 11 && align()&(fltk3::ALIGN_LEFT|fltk3::ALIGN_RIGHT)) {X += 3; W -= 
6;}
-  draw_label(X, y_+fltk3::box_dy(box()), W, h_-fltk3::box_dh(box()));
+  draw_label(X, wy+fltk3::box_dy(box()), W, h_-fltk3::box_dh(box()));
 }
 
 /** Draws the label in an arbitrary bounding box.

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

Reply via email to