I implemented new fluid layout options and propose then to be added to
fltk distribution:

on fluid.cxx:

   {"&Make Same Size",0,0,0,FL_SUBMENU},
     {"&Width",0,(Fl_Callback *)align_widget_cb,(void*)30},
     {"&Height",0,(Fl_Callback *)align_widget_cb,(void*)31},
     {"&Both",0,(Fl_Callback *)align_widget_cb,(void*)32},
     {0},
//new code bellow
   {"Make Same Size as Parent",0,0,0,FL_SUBMENU},
     {"Width",0,(Fl_Callback *)align_widget_cb,(void*)300},
     {"Height",0,(Fl_Callback *)align_widget_cb,(void*)310},
     {"Both",0,(Fl_Callback *)align_widget_cb,(void*)320},
     {0},
//bellow is a wish list not implemented yet
   {"Fill Parent Same Size",0,0,0,FL_SUBMENU},
     {"Width",0,(Fl_Callback *)align_widget_cb,(void*)3000},
     {"Height",0,(Fl_Callback *)align_widget_cb,(void*)3100},
     {"Both",0,(Fl_Callback *)align_widget_cb,(void*)3200},
     {0},
//end new code
   {"&Center In Group",0,0,0,FL_SUBMENU},
     {"&Horizontal",0,(Fl_Callback *)align_widget_cb,(void*)40},


on align_widget.cxx:

  int left, right, top, bot, wdt, hgt, n;
//new variables
  int fill_parent, use_parent, parent_is_window, use_x, use_y;
//end new variables
  Fl_Type *o;
..
//new modifications bellow
  //---- make same size
  case 30: // same width
  case 300: // same parent width
  //case 3000: // fill parent width same size
    //fill_parent = how == 3000;
    use_parent = parent_is_window = 0;
    wdt = min;
    for (o = Fl_Type::first; o; o = o->next)
      if (o->selected && o->is_widget())
      {
        Fl_Widget *w = ((Fl_Widget_Type *)o)->o;
    if((how == 300) && w->parent()) {
        wdt = w->parent()->w();
        use_parent = 1;
        parent_is_window = !w->parent()->parent();
    }
    else if (w->w()>wdt) wdt = w->w();
        BREAK_ON_FIRST;
      }
    if (wdt!=min)
      for (Fl_Type *o = Fl_Type::first; o; o = o->next)
        if (o->selected && o->is_widget())
        {
          if (!changed) {
            changed = 1;
            set_modflag(1);
            undo_checkpoint();
          }

          Fl_Widget *w = ((Fl_Widget_Type *)o)->o;
          use_x = use_parent ? (parent_is_window ? 0 : w->parent()->x()) : 
w->x();
          if (o->next && o->next->level > o->level && !o->next->selected &&
              !o->is_menu_button()) {
            // When resizing a group, make sure we also move the children...
            ((igroup *)w)->full_resize(use_x, w->y(), wdt, w->h());
          } else {
            // Otherwise, just do the widget...
            w->resize(use_x, w->y(), wdt, w->h());
          }
          w->redraw();
          if (w->window()) w->window()->redraw();
        }
    break;
  case 31: // same height
  case 310: // same parent height
  //case 3100: // fill parent same parent height
    //fill_parent = how == 3100;
    use_parent = parent_is_window = 0;
    hgt = min;
    for (o = Fl_Type::first; o; o = o->next)
      if (o->selected && o->is_widget())
      {
        Fl_Widget *w = ((Fl_Widget_Type *)o)->o;
    if((how == 310) && w->parent()) {
        hgt = w->parent()->h();
        use_parent = 1;
        parent_is_window = !w->parent()->parent();
    }
    else if (w->h()>hgt) hgt = w->h();
        BREAK_ON_FIRST;
      }
    if (hgt!=min)
      for (Fl_Type *o = Fl_Type::first; o; o = o->next)
        if (o->selected && o->is_widget())
        {
          if (!changed) {
            changed = 1;
            set_modflag(1);
            undo_checkpoint();
          }

          Fl_Widget *w = ((Fl_Widget_Type *)o)->o;
          use_y = use_parent ? (parent_is_window ? 0 : w->parent()->y()) : 
w->y();
          if (o->next && o->next->level > o->level && !o->next->selected &&
              !o->is_menu_button()) {
            // When resizing a group, make sure we also move the children...
            ((igroup *)w)->full_resize( w->x(), use_y, w->w(), hgt);
          } else {
            // Otherwise, just do the widget...
            w->resize( w->x(), use_y, w->w(), hgt);
          }
          w->redraw();
          if (w->window()) w->window()->redraw();
        }
    break;
  case 32: // same size
  case 320: // same parent size
  //case 3200: // fill parent same parent size
    //fill_parent = how == 3200;
    use_parent = parent_is_window = 0;
    hgt = min; wdt = min;
    for (o = Fl_Type::first; o; o = o->next)
      if (o->selected && o->is_widget())
      {
        Fl_Widget *w = ((Fl_Widget_Type *)o)->o;
    if((how == 320) && w->parent()) {
        use_parent = 1;
        parent_is_window = !w->parent()->parent();
        wdt = w->parent()->w();
        hgt = w->parent()->h();
    } else {
        if (w->w()>wdt)
          wdt = w->w();
        if (w->h()>hgt)
          hgt = w->h();
    }
        BREAK_ON_FIRST;
      }
    if (hgt!=min)
      for (Fl_Type *o = Fl_Type::first; o; o = o->next)
        if (o->selected && o->is_widget())
        {
          if (!changed) {
            changed = 1;
            set_modflag(1);
            undo_checkpoint();
          }

          Fl_Widget *w = ((Fl_Widget_Type *)o)->o;
          use_x = use_parent ? (parent_is_window ? 0 : w->parent()->x()) : 
w->x();
          use_y = use_parent ? (parent_is_window ? 0 : w->parent()->y()) : 
w->y();
          if (o->next && o->next->level > o->level && !o->next->selected &&
              !o->is_menu_button()) {
            // When resizing a group, make sure we also move the children...
            ((igroup *)w)->full_resize(use_x , use_y, wdt, hgt);
          } else {
            // Otherwise, just do the widget...
            w->resize(use_x , use_y,  wdt, hgt);
          }
          w->redraw();
          if (w->window()) w->window()->redraw();
        }
    break;
//end new modifications
_______________________________________________
fltk-dev mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-dev

Reply via email to