changeset 1831:9678798c900a

just get fltkui into compilable state
author corvid <corvid@lavabit.com>
date Thu, 13 Jan 2011 23:48:11 +0000
parents b2ae84e167d1
children 553e63661ec1
files dw/fltkui.cc dw/fltkui.hh
diffstat 2 files changed, 53 insertions(+), 35 deletions(-) [+]
line wrap: on
line diff
--- a/dw/fltkui.cc	Thu Jan 13 23:14:45 2011 +0000
+++ b/dw/fltkui.cc	Thu Jan 13 23:48:11 2011 +0000
@@ -31,6 +31,8 @@
 #include <FL/Fl_Text_Editor.H>
 #include <FL/Fl_Check_Button.H>
 #include <FL/Fl_Radio_Button.H>
+#include <FL/Fl_Choice.H>
+#include <FL/Fl_Tree.H>
 
 #include <stdio.h>
 
@@ -138,8 +140,6 @@
    FltkFont *font = (FltkFont*)style->font;
    widget->labelsize (font->size);
    widget->labelfont (font->font);
-   widget->textsize (font->size);
-   widget->textfont (font->font);
 
    FltkColor *bg = (FltkColor*)style->backgroundColor;
    if (bg) {
@@ -151,18 +151,10 @@
          Fl_Color fg = fl_contrast(style_fg, normal_bg);
 
          widget->labelcolor(fg);
-         widget->textcolor(fg);
          widget->selection_color(fg);
       }
 
       widget->color(normal_bg);
-      widget->buttoncolor(normal_bg);
-      widget->selection_textcolor(normal_bg);
-      if (widget->type() != Fl_Widget::RADIO &&
-          widget->type() != Fl_Widget::TOGGLE) {
-         /* it looks awful to highlight the buttons */
-         widget->highlight_color(bg->colors[FltkColor::SHADING_LIGHT]);
-      }
    }
 }
 
@@ -252,7 +244,7 @@
    Fl_Button *button =
         new Fl_Button (allocation->x, allocation->y, allocation->width,
                        allocation->ascent + allocation->descent, label);
-   button->clear_flag (SHORTCUT_LABEL);
+// button->clear_flag (SHORTCUT_LABEL);
    button->callback (widgetCallback, this);
    button->when (FL_WHEN_RELEASE);
    return button;
@@ -262,7 +254,10 @@
 {
    if (style) {
       FltkFont *font = (FltkFont*)style->font;
+#if 0
+PORT1.3
       ::fltk::setfont(font->font,font->size);
+#endif
       requisition->width =
          (int)fl_width (label, strlen (label))
          + 2 * RELIEF_X_THICKNESS;
@@ -475,7 +470,7 @@
 
    if (label) {
       input->label(label);
-      input->set_flag(FL_ALIGN_INSIDE);
+      input->align(FL_ALIGN_INSIDE);
    }
    if (initText)
       input->value (initText);
@@ -493,7 +488,10 @@
 {
    if (displayed() && style) {
       FltkFont *font = (FltkFont*)style->font;
+#if 0
+PORT1.3
       ::fltk::setfont(font->font,font->size);
+#endif
       requisition->width =
          (int)fl_width ('n')
          * (maxLength == UNLIMITED_MAX_LENGTH ? 10 : maxLength)
@@ -591,7 +589,10 @@
 {
    if (style) {
       FltkFont *font = (FltkFont*)style->font;
+#if 0
+PORT1.3
       ::fltk::setfont(font->font,font->size);
+#endif
       requisition->width =
          (int)fl_width ('n') * numCols + 2 * RELIEF_X_THICKNESS;
       requisition->ascent =
@@ -661,7 +662,10 @@
       (this->FltkResource::style ? this->FltkResource::style->font : NULL);
 
    if (font) {
+#if 0
+PORT1.3
       ::fltk::setfont(font->font, font->size);
+#endif
       requisition->width = font->ascent + font->descent + 2*RELIEF_X_THICKNESS;
       requisition->ascent = font->ascent + RELIEF_Y_THICKNESS;
       requisition->descent = font->descent + RELIEF_Y_THICKNESS;
@@ -709,7 +713,7 @@
    Fl_Check_Button *cb =
       new Fl_Check_Button (allocation->x, allocation->y, allocation->width,
                            allocation->ascent + allocation->descent);
-   cb->clear_flag (SHORTCUT_LABEL);
+// cb->clear_flag (SHORTCUT_LABEL);
    return cb;
 }
 
@@ -821,7 +825,7 @@
    Fl_Button *button =
       new Fl_Radio_Button (allocation->x, allocation->y, allocation->width,
                            allocation->ascent + allocation->descent);
-   button->clear_flag (SHORTCUT_LABEL);
+// button->clear_flag (SHORTCUT_LABEL);
    button->when (FL_WHEN_CHANGED);
    button->callback (widgetCallback, this);
    button->type (FL_TOGGLE_BUTTON);
@@ -829,6 +833,8 @@
    return button;
 }
 
+/*
+
 FLTK 1.3's Browser doesn't seem to permit a hierarchy, so I think we'll
 use Choice and Tree. There is no Item or ItemGroup, but I see they both
 have an add("menu/sub/sub/leaf") interface (not based on a common
@@ -837,9 +843,10 @@
 enough that I don't want to write the code until dw's in good enough shape
 to test whether I'm going about it sensibly.
 
-
+*/
 // ----------------------------------------------------------------------
 
+#if 0
 template <class I> FltkSelectionResource<I>::Item::Item (Type type,
                                                          const char *name,
                                                          bool enabled,
@@ -889,7 +896,6 @@
    delete stack;
 }
 
-
 template <class I>
 FltkSelectionResource<I>::FltkSelectionResource (FltkPlatform *platform):
    FltkSpecificResource<I> (platform)
@@ -963,11 +969,12 @@
                                          bool selected) {
    return new Item(type,name,enabled,selected);
 }
-
+#endif
 template <class I> void FltkSelectionResource<I>::addItem (const char *str,
                                                            bool enabled,
                                                            bool selected)
 {
+#if 0
    int index = items->size ();
    Item *item = createNewItem (Item::ITEM, str, enabled, selected);
    items->put (item);
@@ -1001,8 +1008,10 @@
          }
       }
    }
+#endif
 }
 
+#if 0
 template <class I> void FltkSelectionResource<I>::pushGroup (const char *name,
                                                              bool enabled)
 {
@@ -1051,7 +1060,7 @@
    }
    return width;
 }
-
+#endif
 // ----------------------------------------------------------------------
 
 FltkOptionMenuResource::FltkOptionMenuResource (FltkPlatform *platform):
@@ -1066,14 +1075,14 @@
 }
 
 
-Fl_Menu *FltkOptionMenuResource::createNewMenu (core::Allocation
+Fl_Widget *FltkOptionMenuResource::createNewMenu (core::Allocation
                                                      *allocation)
 {
-   Fl_Menu *menu =
+   Fl_Menu_ *menu =
       new Fl_Choice (allocation->x, allocation->y,
                           allocation->width,
                           allocation->ascent + allocation->descent);
-   menu->clear_flag (SHORTCUT_LABEL);
+// menu->clear_flag (SHORTCUT_LABEL);
    menu->callback(widgetCallback,this);
    return menu;
 }
@@ -1081,12 +1090,15 @@
 void FltkOptionMenuResource::widgetCallback (Fl_Widget *widget,
                                              void *data)
 {
+#if 0
    ((FltkOptionMenuResource *) data)->selection =
       (long) (((Fl_Menu *) widget)->item()->user_data());
+#endif
 }
 
 void FltkOptionMenuResource::sizeRequest (core::Requisition *requisition)
 {
+#if 0
    if (style) {
       FltkFont *font = (FltkFont*)style->font;
       ::fltk::setfont(font->font,font->size);
@@ -1097,10 +1109,13 @@
          + (requisition->ascent + requisition->descent) * 4 / 5
          + 2 * RELIEF_X_THICKNESS;
    } else {
+#endif
       requisition->width = 1;
       requisition->ascent = 1;
       requisition->descent = 0;
+#if 0
    }
+#endif
 }
 
 void FltkOptionMenuResource::addItem (const char *str,
@@ -1137,22 +1152,22 @@
 }
 
 
-Fl_Menu *FltkListResource::createNewMenu (core::Allocation *allocation)
+Fl_Widget *FltkListResource::createNewMenu (core::Allocation *allocation)
 {
-   Fl_Menu *menu =
-      new Fl_Browser (allocation->x, allocation->y, allocation->width,
+   Fl_Tree *tree =
+      new Fl_Tree (allocation->x, allocation->y, allocation->width,
                            allocation->ascent + allocation->descent);
    if (mode == SELECTION_MULTIPLE)
-      menu->type(Fl_Browser::MULTI);
-   menu->clear_flag (SHORTCUT_LABEL);
-   menu->callback(widgetCallback,this);
-   menu->when(FL_WHEN_CHANGED);
-   return menu;
+      tree->selectmode(FL_TREE_SELECT_MULTI);
+// tree->clear_flag (SHORTCUT_LABEL);
+   tree->callback(widgetCallback,this);
+   tree->when(FL_WHEN_CHANGED);
+   return tree;
 }
 
 void FltkListResource::widgetCallback (Fl_Widget *widget, void *data)
 {
-   Fl_Widget *fltkItem = ((Fl_Menu *) widget)->item ();
+   Fl_Tree_Item *fltkItem = ((Fl_Tree *) widget)->callback_item ();
    int index = -1;
    if (fltkItem)
       index = (long) (fltkItem->user_data ());
@@ -1164,7 +1179,7 @@
        */
       FltkListResource *res = (FltkListResource *) data;
       if (res->mode == SELECTION_MULTIPLE) {
-         bool selected = fltkItem->selected ();
+         bool selected = fltkItem->is_selected ();
          res->itemsSelected.set (index, selected);
       } else {
          int size = res->itemsSelected.size();
@@ -1189,7 +1204,10 @@
 {
    if (style) {
       FltkFont *font = (FltkFont*)style->font;
+#if 0
+PORT1.3
       ::fltk::setfont(font->font,font->size);
+#endif
       int rows = getNumberOfItems();
       if (showRows < rows) {
          rows = showRows;
--- a/dw/fltkui.hh	Thu Jan 13 23:14:45 2011 +0000
+++ b/dw/fltkui.hh	Thu Jan 13 23:48:11 2011 +0000
@@ -449,7 +449,7 @@
       ~Item ();
 
       Item *createNewWidget (int index);
-      Fl_ItemGroup *createNewGroupWidget ();
+//    Fl_ItemGroup *createNewGroupWidget ();
    };
 
    class WidgetStack: public lout::object::Object
@@ -472,7 +472,7 @@
                         bool selected = false);
 
    Fl_Widget *createNewWidget (core::Allocation *allocation);
-   virtual Fl_Menu *createNewMenu (core::Allocation *allocation) = 0;
+   virtual Fl_Widget *createNewMenu (core::Allocation *allocation) = 0;
    virtual bool setSelectedItems() { return false; }
 
    int getMaxStringWidth ();
@@ -497,7 +497,7 @@
    public FltkSelectionResource <dw::core::ui::OptionMenuResource>
 {
 protected:
-   Fl_Menu *createNewMenu (core::Allocation *allocation);
+   Fl_Widget *createNewMenu (core::Allocation *allocation);
    virtual bool setSelectedItems() { return true; }
 
 private:
@@ -518,7 +518,7 @@
    public FltkSelectionResource <dw::core::ui::ListResource>
 {
 protected:
-   Fl_Menu *createNewMenu (core::Allocation *allocation);
+   Fl_Widget *createNewMenu (core::Allocation *allocation);
 
 private:
    static void widgetCallback (Fl_Widget *widget, void *data);