Author: dejan
Date: 2007-11-28 11:42:30 -0800 (Wed, 28 Nov 2007)
New Revision: 5990
Log:
Davy Durham's patch described in STR#1836 has been applied. It makes 
the buttons for ask.h dialogs sized according to the given labels 
instead of a constant width of 75px.
Also, for some reason, small Item patch desribed in my previous commit
hasn't been commited.




Modified:
   trunk/src/Item.cxx
   trunk/src/message.cxx

Modified: trunk/src/Item.cxx
===================================================================
--- trunk/src/Item.cxx  2007-11-21 05:00:55 UTC (rev 5989)
+++ trunk/src/Item.cxx  2007-11-28 19:42:30 UTC (rev 5990)
@@ -179,7 +179,10 @@
       if (w) h += H; else h = H;
       if (W > w) w = W;
     }
-  } else {
+  } else if ((type() & RADIO) || (type() & TOGGLE)) {
+      w += 20;
+  }
+  else {
     w += 6; // further adjustment to match Windows menubars
   }
   this->w(w);

Modified: trunk/src/message.cxx
===================================================================
--- trunk/src/message.cxx       2007-11-21 05:00:55 UTC (rev 5989)
+++ trunk/src/message.cxx       2007-11-28 19:42:30 UTC (rev 5990)
@@ -82,7 +82,7 @@
 #define BORDER_W 10
 #define BORDER_H 10
 #define INPUT_W 270
-#define BUTTON_W 75
+#define MIN_BUTTON_W 75
 #define BUTTON_H 21
 
 static Input *textfield;
@@ -223,6 +223,53 @@
     if (blabels[i][0] == '*') {blabels[i]++; default_button = i;}
   }
 
+#if 1
+  int bx = window.w();
+  int by = window.h()-(BORDER_H+BUTTON_H);
+  int bh = BUTTON_H;
+  for (i = 3; i--;) {
+    if (blabels[i]) {
+      fltk::Button* button;
+      int glyph_width=0;
+      if (i == default_button) {
+        button = new ReturnButton(0, 0, 0, 0, blabels[i]);
+        window.hotspot(button);
+        if (!istr) window.set_focus(button);
+
+        // a ReturnButton uses this as the glyph size.. I don't know what else 
to do except do the same thing here
+        glyph_width = 2*int(button->textsize());
+
+        // and best I can tell from the code, 3 is the constant width between 
label and glyph
+        glyph_width += 3; 
+
+      } else {
+        button = new fltk::Button(0, 0, 0, 0, blabels[i]);
+      }
+      button->callback(set_button_number, i);
+
+      // calculate the horizontal size of the button
+      int bw, dummy;
+      button->measure_label(bw, dummy);
+
+      // add a 5+5 px padding in button
+      bw += 10; 
+
+      // and include any glyph width
+      bw += glyph_width;
+
+      // enforce button min size
+      bw = bw < MIN_BUTTON_W ? MIN_BUTTON_W : bw;
+
+      // accumulate the horizontal button position based on button widths
+      bx -= bw + BORDER_W;
+
+      // finally position and size the button
+      button->resize(bx, by, bw, bh);
+    }
+  }
+
+#else // the old way of placing constant sized buttons
+
   for (i = 3; i--;) if (blabels[i]) {
     fltk::Button* button;
     if (i == default_button) {
@@ -239,6 +286,9 @@
     button->callback(set_button_number, i);
   }
 
+#endif
+
+
   window.end();
 
   timed_out=0;

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

Reply via email to