changeset 389:554fc02750fa

- Fixed check and radio buttons size_request.
author jcid
date Sun, 05 Oct 2008 18:43:23 +0200
parents dfd25e7990be
children 27cb8017f278
files dw/fltkui.cc dw/fltkui.hh
diffstat 2 files changed, 17 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/dw/fltkui.cc	Sun Oct 05 01:25:59 2008 +0200
+++ b/dw/fltkui.cc	Sun Oct 05 18:43:23 2008 +0200
@@ -678,10 +678,18 @@
 template <class I>
 void FltkToggleButtonResource<I>::sizeRequest (core::Requisition *requisition)
 {
-   /** \bug Random values. */
-   requisition->width = 20;
-   requisition->ascent = 18;
-   requisition->descent = 5;
+   FltkFont *font = getFont();
+
+   if (font) {
+      ::fltk::setfont(font->font, font->size);
+      requisition->width = font->ascent + font->descent + 2*RELIEF_X_THICKNESS;
+      requisition->ascent = font->ascent + RELIEF_Y_THICKNESS;
+      requisition->descent = font->descent + RELIEF_Y_THICKNESS;
+   } else {
+      requisition->width = 1;
+      requisition->ascent = 1;
+      requisition->descent = 0;
+   }
 }
 
 
--- a/dw/fltkui.hh	Sun Oct 05 01:25:59 2008 +0200
+++ b/dw/fltkui.hh	Sun Oct 05 18:43:23 2008 +0200
@@ -350,6 +350,8 @@
 
 protected:
    virtual ::fltk::Button *createNewButton (core::Allocation *allocation) = 0;
+   // TODO: maybe getFont() is not the best way to do it...
+   virtual FltkFont *getFont() = 0;
    ::fltk::Widget *createNewWidget (core::Allocation *allocation);
    
 public:
@@ -367,6 +369,8 @@
 class FltkCheckButtonResource:
    public FltkToggleButtonResource <dw::core::ui::CheckButtonResource>
 {
+private:
+   FltkFont *getFont() {return style ? (FltkFont *)style->font : NULL;}
 protected:
    ::fltk::Button *createNewButton (core::Allocation *allocation);
 
@@ -427,6 +431,7 @@
    Group *group;
 
    static void widgetCallback (::fltk::Widget *widget, void *data);
+   FltkFont *getFont() {return style ? (FltkFont *)style->font : NULL;}
    void buttonClicked ();
 
 protected: