2002-05-01 21:35:30 +04:00
|
|
|
//
|
2005-02-06 19:28:36 +03:00
|
|
|
// "$Id$"
|
2002-05-01 21:35:30 +04:00
|
|
|
//
|
2005-03-20 07:00:48 +03:00
|
|
|
// Alignment code for the Fast Light Tool Kit (FLTK).
|
2002-05-01 21:35:30 +04:00
|
|
|
//
|
2009-01-01 19:11:32 +03:00
|
|
|
// Copyright 1998-2009 by Bill Spitzak and others.
|
2002-05-01 21:35:30 +04:00
|
|
|
//
|
|
|
|
// This library is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU Library General Public
|
|
|
|
// License as published by the Free Software Foundation; either
|
|
|
|
// version 2 of the License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This library is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
// Library General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Library General Public
|
|
|
|
// License along with this library; if not, write to the Free Software
|
|
|
|
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
|
|
|
// USA.
|
|
|
|
//
|
2005-04-16 04:13:17 +04:00
|
|
|
// Please report all bugs and problems on the following page:
|
|
|
|
//
|
|
|
|
// http://www.fltk.org/str.php
|
2002-05-01 21:35:30 +04:00
|
|
|
//
|
|
|
|
|
|
|
|
#include <FL/Fl.H>
|
2003-01-10 22:29:09 +03:00
|
|
|
#include <FL/Fl_Window.H>
|
2002-05-01 21:35:30 +04:00
|
|
|
#include "Fl_Widget_Type.h"
|
2005-03-20 07:00:48 +03:00
|
|
|
#include "undo.h"
|
2002-05-01 21:35:30 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* the first behaviour always uses the first selected widget as a reference
|
2005-03-19 07:09:32 +03:00
|
|
|
* the second behaviour uses the largest widget (most extreme positions) as
|
|
|
|
* a reference.
|
2002-05-01 21:35:30 +04:00
|
|
|
*/
|
|
|
|
#define BREAK_ON_FIRST break
|
|
|
|
//#define BREAK_ON_FIRST
|
|
|
|
|
|
|
|
void align_widget_cb(Fl_Widget*, long how)
|
|
|
|
{
|
|
|
|
const int max = 32768, min = -32768;
|
|
|
|
int left, right, top, bot, wdt, hgt, n;
|
|
|
|
Fl_Type *o;
|
2005-03-20 07:00:48 +03:00
|
|
|
int changed = 0;
|
2002-05-01 21:35:30 +04:00
|
|
|
switch ( how )
|
|
|
|
{
|
|
|
|
//---- align
|
|
|
|
case 10: // align left
|
|
|
|
left = max;
|
|
|
|
for (o = Fl_Type::first; o; o = o->next)
|
|
|
|
if (o->selected && o->is_widget())
|
|
|
|
{
|
|
|
|
Fl_Widget *w = ((Fl_Widget_Type *)o)->o;
|
|
|
|
if (w->x()<left)
|
|
|
|
left = w->x();
|
|
|
|
BREAK_ON_FIRST;
|
|
|
|
}
|
|
|
|
if (left!=max)
|
|
|
|
for (Fl_Type *o = Fl_Type::first; o; o = o->next)
|
|
|
|
if (o->selected && o->is_widget())
|
|
|
|
{
|
2005-03-20 07:00:48 +03:00
|
|
|
if (!changed) {
|
|
|
|
changed = 1;
|
|
|
|
set_modflag(1);
|
|
|
|
undo_checkpoint();
|
|
|
|
}
|
|
|
|
|
2002-05-01 21:35:30 +04:00
|
|
|
Fl_Widget *w = ((Fl_Widget_Type *)o)->o;
|
2005-03-05 18:09:59 +03:00
|
|
|
if (o->next && o->next->level > o->level && !o->next->selected &&
|
|
|
|
!o->is_menu_button()) {
|
2004-04-06 22:32:52 +04:00
|
|
|
// When resizing a group, make sure we also move the children...
|
|
|
|
((igroup *)w)->full_resize(left, w->y(), w->w(), w->h());
|
|
|
|
} else {
|
|
|
|
// Otherwise, just do the widget...
|
|
|
|
w->resize(left, w->y(), w->w(), w->h());
|
|
|
|
}
|
2002-05-01 21:35:30 +04:00
|
|
|
w->redraw();
|
2004-04-06 06:47:26 +04:00
|
|
|
if (w->window()) w->window()->redraw();
|
2002-05-01 21:35:30 +04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 11: // align h.center
|
|
|
|
left = max; right = 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 (w->x()<left)
|
|
|
|
left = w->x();
|
|
|
|
if (w->x()+w->w()>right)
|
|
|
|
right = w->x()+w->w();
|
|
|
|
BREAK_ON_FIRST;
|
|
|
|
}
|
|
|
|
if (left!=max)
|
|
|
|
{
|
|
|
|
int center2 = left+right;
|
|
|
|
for (Fl_Type *o = Fl_Type::first; o; o = o->next)
|
|
|
|
if (o->selected && o->is_widget())
|
|
|
|
{
|
2005-03-20 07:00:48 +03:00
|
|
|
if (!changed) {
|
|
|
|
changed = 1;
|
|
|
|
set_modflag(1);
|
|
|
|
undo_checkpoint();
|
|
|
|
}
|
|
|
|
|
2002-05-01 21:35:30 +04:00
|
|
|
Fl_Widget *w = ((Fl_Widget_Type *)o)->o;
|
2005-03-05 18:09:59 +03:00
|
|
|
if (o->next && o->next->level > o->level && !o->next->selected &&
|
|
|
|
!o->is_menu_button()) {
|
2004-04-06 22:32:52 +04:00
|
|
|
// When resizing a group, make sure we also move the children...
|
|
|
|
((igroup *)w)->full_resize((center2-w->w())/2, w->y(), w->w(), w->h());
|
|
|
|
} else {
|
|
|
|
// Otherwise, just do the widget...
|
|
|
|
w->resize((center2-w->w())/2, w->y(), w->w(), w->h());
|
|
|
|
}
|
2002-05-01 21:35:30 +04:00
|
|
|
w->redraw();
|
2004-04-06 06:47:26 +04:00
|
|
|
if (w->window()) w->window()->redraw();
|
2002-05-01 21:35:30 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 12: // align right
|
|
|
|
right = 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 (w->x()+w->w()>right)
|
|
|
|
right = w->x()+w->w();
|
|
|
|
BREAK_ON_FIRST;
|
|
|
|
}
|
|
|
|
if (right!=min)
|
|
|
|
for (Fl_Type *o = Fl_Type::first; o; o = o->next)
|
|
|
|
if (o->selected && o->is_widget())
|
|
|
|
{
|
2005-03-20 07:00:48 +03:00
|
|
|
if (!changed) {
|
|
|
|
changed = 1;
|
|
|
|
set_modflag(1);
|
|
|
|
undo_checkpoint();
|
|
|
|
}
|
|
|
|
|
2002-05-01 21:35:30 +04:00
|
|
|
Fl_Widget *w = ((Fl_Widget_Type *)o)->o;
|
2005-03-05 18:09:59 +03:00
|
|
|
if (o->next && o->next->level > o->level && !o->next->selected &&
|
|
|
|
!o->is_menu_button()) {
|
2004-04-06 22:32:52 +04:00
|
|
|
// When resizing a group, make sure we also move the children...
|
|
|
|
((igroup *)w)->full_resize(right-w->w(), w->y(), w->w(), w->h());
|
|
|
|
} else {
|
|
|
|
// Otherwise, just do the widget...
|
|
|
|
w->resize(right-w->w(), w->y(), w->w(), w->h());
|
|
|
|
}
|
2002-05-01 21:35:30 +04:00
|
|
|
w->redraw();
|
2004-04-06 06:47:26 +04:00
|
|
|
if (w->window()) w->window()->redraw();
|
2002-05-01 21:35:30 +04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 13: // align top
|
|
|
|
top = max;
|
|
|
|
for (o = Fl_Type::first; o; o = o->next)
|
|
|
|
if (o->selected && o->is_widget())
|
|
|
|
{
|
|
|
|
Fl_Widget *w = ((Fl_Widget_Type *)o)->o;
|
|
|
|
if (w->y()<top)
|
|
|
|
top = w->y();
|
|
|
|
BREAK_ON_FIRST;
|
|
|
|
}
|
|
|
|
if (top!=max)
|
|
|
|
for (Fl_Type *o = Fl_Type::first; o; o = o->next)
|
|
|
|
if (o->selected && o->is_widget())
|
|
|
|
{
|
2005-03-20 07:00:48 +03:00
|
|
|
if (!changed) {
|
|
|
|
changed = 1;
|
|
|
|
set_modflag(1);
|
|
|
|
undo_checkpoint();
|
|
|
|
}
|
|
|
|
|
2002-05-01 21:35:30 +04:00
|
|
|
Fl_Widget *w = ((Fl_Widget_Type *)o)->o;
|
2005-03-05 18:09:59 +03:00
|
|
|
if (o->next && o->next->level > o->level && !o->next->selected &&
|
|
|
|
!o->is_menu_button()) {
|
2004-04-06 22:32:52 +04:00
|
|
|
// When resizing a group, make sure we also move the children...
|
|
|
|
((igroup *)w)->full_resize(w->x(), top, w->w(), w->h());
|
|
|
|
} else {
|
|
|
|
// Otherwise, just do the widget...
|
|
|
|
w->resize(w->x(), top, w->w(), w->h());
|
|
|
|
}
|
2002-05-01 21:35:30 +04:00
|
|
|
w->redraw();
|
2004-04-06 06:47:26 +04:00
|
|
|
if (w->window()) w->window()->redraw();
|
2002-05-01 21:35:30 +04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 14: // align v.center
|
|
|
|
top = max; bot = 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 (w->y()<top)
|
|
|
|
top = w->y();
|
|
|
|
if (w->y()+w->h()>bot)
|
|
|
|
bot = w->y()+w->h();
|
|
|
|
BREAK_ON_FIRST;
|
|
|
|
}
|
|
|
|
if (top!=max)
|
|
|
|
{
|
|
|
|
int center2 = top+bot;
|
|
|
|
for (Fl_Type *o = Fl_Type::first; o; o = o->next)
|
|
|
|
if (o->selected && o->is_widget())
|
|
|
|
{
|
2005-03-20 07:00:48 +03:00
|
|
|
if (!changed) {
|
|
|
|
changed = 1;
|
|
|
|
set_modflag(1);
|
|
|
|
undo_checkpoint();
|
|
|
|
}
|
|
|
|
|
2002-05-01 21:35:30 +04:00
|
|
|
Fl_Widget *w = ((Fl_Widget_Type *)o)->o;
|
2005-03-05 18:09:59 +03:00
|
|
|
if (o->next && o->next->level > o->level && !o->next->selected &&
|
|
|
|
!o->is_menu_button()) {
|
2004-04-06 22:32:52 +04:00
|
|
|
// When resizing a group, make sure we also move the children...
|
|
|
|
((igroup *)w)->full_resize(w->x(), (center2-w->h())/2, w->w(), w->h());
|
|
|
|
} else {
|
|
|
|
// Otherwise, just do the widget...
|
|
|
|
w->resize(w->x(), (center2-w->h())/2, w->w(), w->h());
|
|
|
|
}
|
2002-05-01 21:35:30 +04:00
|
|
|
w->redraw();
|
2004-04-06 06:47:26 +04:00
|
|
|
if (w->window()) w->window()->redraw();
|
2002-05-01 21:35:30 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 15: // align bottom
|
|
|
|
bot = 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 (w->y()+w->h()>bot)
|
|
|
|
bot = w->y()+w->h();
|
|
|
|
BREAK_ON_FIRST;
|
|
|
|
}
|
|
|
|
if (bot!=min)
|
|
|
|
for (Fl_Type *o = Fl_Type::first; o; o = o->next)
|
|
|
|
if (o->selected && o->is_widget())
|
|
|
|
{
|
2005-03-20 07:00:48 +03:00
|
|
|
if (!changed) {
|
|
|
|
changed = 1;
|
|
|
|
set_modflag(1);
|
|
|
|
undo_checkpoint();
|
|
|
|
}
|
|
|
|
|
2002-05-01 21:35:30 +04:00
|
|
|
Fl_Widget *w = ((Fl_Widget_Type *)o)->o;
|
2005-03-05 18:09:59 +03:00
|
|
|
if (o->next && o->next->level > o->level && !o->next->selected &&
|
|
|
|
!o->is_menu_button()) {
|
2004-04-06 22:32:52 +04:00
|
|
|
// When resizing a group, make sure we also move the children...
|
|
|
|
((igroup *)w)->full_resize( w->x(), bot-w->h(), w->w(), w->h());
|
|
|
|
} else {
|
|
|
|
// Otherwise, just do the widget...
|
|
|
|
w->resize( w->x(), bot-w->h(), w->w(), w->h());
|
|
|
|
}
|
2002-05-01 21:35:30 +04:00
|
|
|
w->redraw();
|
2004-04-06 06:47:26 +04:00
|
|
|
if (w->window()) w->window()->redraw();
|
2002-05-01 21:35:30 +04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
//---- space evently
|
|
|
|
case 20: // space evenly across
|
|
|
|
left = max; right = min; wdt = 0, n = 0;
|
|
|
|
for (o = Fl_Type::first; o; o = o->next)
|
|
|
|
if (o->selected && o->is_widget())
|
|
|
|
{
|
|
|
|
Fl_Widget *w = ((Fl_Widget_Type *)o)->o;
|
|
|
|
if (w->x()<left)
|
|
|
|
left = w->x();
|
|
|
|
if (w->x()+w->w()>right)
|
|
|
|
right = w->x()+w->w();
|
|
|
|
wdt += w->w();
|
|
|
|
n++;
|
|
|
|
}
|
|
|
|
wdt = (right-left)-wdt;
|
|
|
|
n--;
|
|
|
|
if (n>0)
|
|
|
|
{
|
|
|
|
int cnt = 0, wsum = 0;
|
|
|
|
for (Fl_Type *o = Fl_Type::first; o; o = o->next)
|
|
|
|
if (o->selected && o->is_widget())
|
|
|
|
{
|
2005-03-20 07:00:48 +03:00
|
|
|
if (!changed) {
|
|
|
|
changed = 1;
|
|
|
|
set_modflag(1);
|
|
|
|
undo_checkpoint();
|
|
|
|
}
|
|
|
|
|
2002-05-01 21:35:30 +04:00
|
|
|
Fl_Widget *w = ((Fl_Widget_Type *)o)->o;
|
2005-03-05 18:09:59 +03:00
|
|
|
if (o->next && o->next->level > o->level && !o->next->selected &&
|
|
|
|
!o->is_menu_button()) {
|
2004-04-06 22:32:52 +04:00
|
|
|
// When resizing a group, make sure we also move the children...
|
|
|
|
((igroup *)w)->full_resize(left+wsum+wdt*cnt/n, w->y(), w->w(), w->h());
|
|
|
|
} else {
|
|
|
|
// Otherwise, just do the widget...
|
|
|
|
w->resize(left+wsum+wdt*cnt/n, w->y(), w->w(), w->h());
|
|
|
|
}
|
2002-05-01 21:35:30 +04:00
|
|
|
w->redraw();
|
2004-04-06 06:47:26 +04:00
|
|
|
if (w->window()) w->window()->redraw();
|
2002-05-01 21:35:30 +04:00
|
|
|
cnt++;
|
|
|
|
wsum += w->w();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 21: // space evenly down
|
|
|
|
top = max; bot = min; hgt = 0, n = 0;
|
|
|
|
for (o = Fl_Type::first; o; o = o->next)
|
|
|
|
if (o->selected && o->is_widget())
|
|
|
|
{
|
|
|
|
Fl_Widget *w = ((Fl_Widget_Type *)o)->o;
|
|
|
|
if (w->y()<top)
|
|
|
|
top = w->y();
|
|
|
|
if (w->y()+w->h()>bot)
|
|
|
|
bot = w->y()+w->h();
|
|
|
|
hgt += w->h();
|
|
|
|
n++;
|
|
|
|
}
|
|
|
|
hgt = (bot-top)-hgt;
|
|
|
|
n--;
|
|
|
|
if (n>0)
|
|
|
|
{
|
|
|
|
int cnt = 0, hsum = 0;
|
|
|
|
for (Fl_Type *o = Fl_Type::first; o; o = o->next)
|
|
|
|
if (o->selected && o->is_widget())
|
|
|
|
{
|
2005-03-20 07:00:48 +03:00
|
|
|
if (!changed) {
|
|
|
|
changed = 1;
|
|
|
|
set_modflag(1);
|
|
|
|
undo_checkpoint();
|
|
|
|
}
|
|
|
|
|
2002-05-01 21:35:30 +04:00
|
|
|
Fl_Widget *w = ((Fl_Widget_Type *)o)->o;
|
2005-03-05 18:09:59 +03:00
|
|
|
if (o->next && o->next->level > o->level && !o->next->selected &&
|
|
|
|
!o->is_menu_button()) {
|
2004-04-06 22:32:52 +04:00
|
|
|
// When resizing a group, make sure we also move the children...
|
|
|
|
((igroup *)w)->full_resize(w->x(), top+hsum+hgt*cnt/n, w->w(), w->h());
|
|
|
|
} else {
|
|
|
|
// Otherwise, just do the widget...
|
|
|
|
w->resize(w->x(), top+hsum+hgt*cnt/n, w->w(), w->h());
|
|
|
|
}
|
2002-05-01 21:35:30 +04:00
|
|
|
w->redraw();
|
2004-04-06 06:47:26 +04:00
|
|
|
if (w->window()) w->window()->redraw();
|
2002-05-01 21:35:30 +04:00
|
|
|
cnt++;
|
|
|
|
hsum += w->h();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
//---- make same size
|
|
|
|
case 30: // same width
|
|
|
|
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 (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())
|
|
|
|
{
|
2005-03-20 07:00:48 +03:00
|
|
|
if (!changed) {
|
|
|
|
changed = 1;
|
|
|
|
set_modflag(1);
|
|
|
|
undo_checkpoint();
|
|
|
|
}
|
|
|
|
|
2002-05-01 21:35:30 +04:00
|
|
|
Fl_Widget *w = ((Fl_Widget_Type *)o)->o;
|
2005-03-05 18:09:59 +03:00
|
|
|
if (o->next && o->next->level > o->level && !o->next->selected &&
|
|
|
|
!o->is_menu_button()) {
|
2004-04-06 22:32:52 +04:00
|
|
|
// When resizing a group, make sure we also move the children...
|
|
|
|
((igroup *)w)->full_resize(w->x(), w->y(), wdt, w->h());
|
|
|
|
} else {
|
|
|
|
// Otherwise, just do the widget...
|
|
|
|
w->resize(w->x(), w->y(), wdt, w->h());
|
|
|
|
}
|
2002-05-01 21:35:30 +04:00
|
|
|
w->redraw();
|
2004-04-06 06:47:26 +04:00
|
|
|
if (w->window()) w->window()->redraw();
|
2002-05-01 21:35:30 +04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 31: // same height
|
|
|
|
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 (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())
|
|
|
|
{
|
2005-03-20 07:00:48 +03:00
|
|
|
if (!changed) {
|
|
|
|
changed = 1;
|
|
|
|
set_modflag(1);
|
|
|
|
undo_checkpoint();
|
|
|
|
}
|
|
|
|
|
2002-05-01 21:35:30 +04:00
|
|
|
Fl_Widget *w = ((Fl_Widget_Type *)o)->o;
|
2005-03-05 18:09:59 +03:00
|
|
|
if (o->next && o->next->level > o->level && !o->next->selected &&
|
|
|
|
!o->is_menu_button()) {
|
2004-04-06 22:32:52 +04:00
|
|
|
// When resizing a group, make sure we also move the children...
|
|
|
|
((igroup *)w)->full_resize( w->x(), w->y(), w->w(), hgt);
|
|
|
|
} else {
|
|
|
|
// Otherwise, just do the widget...
|
|
|
|
w->resize( w->x(), w->y(), w->w(), hgt);
|
|
|
|
}
|
2002-05-01 21:35:30 +04:00
|
|
|
w->redraw();
|
2004-04-06 06:47:26 +04:00
|
|
|
if (w->window()) w->window()->redraw();
|
2002-05-01 21:35:30 +04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 32: // same size
|
|
|
|
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 (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())
|
|
|
|
{
|
2005-03-20 07:00:48 +03:00
|
|
|
if (!changed) {
|
|
|
|
changed = 1;
|
|
|
|
set_modflag(1);
|
|
|
|
undo_checkpoint();
|
|
|
|
}
|
|
|
|
|
2002-05-01 21:35:30 +04:00
|
|
|
Fl_Widget *w = ((Fl_Widget_Type *)o)->o;
|
2005-03-05 18:09:59 +03:00
|
|
|
if (o->next && o->next->level > o->level && !o->next->selected &&
|
|
|
|
!o->is_menu_button()) {
|
2004-04-06 22:32:52 +04:00
|
|
|
// When resizing a group, make sure we also move the children...
|
|
|
|
((igroup *)w)->full_resize( w->x(), w->y(), wdt, hgt);
|
|
|
|
} else {
|
|
|
|
// Otherwise, just do the widget...
|
|
|
|
w->resize( w->x(), w->y(), wdt, hgt);
|
|
|
|
}
|
2002-05-01 21:35:30 +04:00
|
|
|
w->redraw();
|
2004-04-06 06:47:26 +04:00
|
|
|
if (w->window()) w->window()->redraw();
|
2002-05-01 21:35:30 +04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
//---- center in group
|
|
|
|
case 40: // center hor
|
|
|
|
for (o = Fl_Type::first; o; o = o->next)
|
|
|
|
if (o->selected && o->is_widget() && o->parent)
|
|
|
|
{
|
2005-03-20 07:00:48 +03:00
|
|
|
if (!changed) {
|
|
|
|
changed = 1;
|
|
|
|
set_modflag(1);
|
|
|
|
undo_checkpoint();
|
|
|
|
}
|
|
|
|
|
2002-05-01 21:35:30 +04:00
|
|
|
Fl_Widget *w = ((Fl_Widget_Type *)o)->o;
|
|
|
|
Fl_Widget *p = ((Fl_Widget_Type *)o->parent)->o;
|
2004-04-06 21:38:36 +04:00
|
|
|
int center2;
|
|
|
|
|
|
|
|
if (w->window() == p) center2 = p->w();
|
|
|
|
else center2 = 2*p->x()+p->w();
|
2004-04-06 22:32:52 +04:00
|
|
|
|
2005-03-05 18:09:59 +03:00
|
|
|
if (o->next && o->next->level > o->level && !o->next->selected &&
|
|
|
|
!o->is_menu_button() && !o->is_menu_button()) {
|
2004-04-06 22:32:52 +04:00
|
|
|
// When resizing a group, make sure we also move the children...
|
|
|
|
((igroup *)w)->full_resize((center2-w->w())/2, w->y(), w->w(), w->h());
|
|
|
|
} else {
|
|
|
|
// Otherwise, just do the widget...
|
|
|
|
w->resize((center2-w->w())/2, w->y(), w->w(), w->h());
|
|
|
|
}
|
2002-05-01 21:35:30 +04:00
|
|
|
w->redraw();
|
2004-04-06 06:47:26 +04:00
|
|
|
if (w->window()) w->window()->redraw();
|
2002-05-01 21:35:30 +04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 41: // center vert
|
|
|
|
for (o = Fl_Type::first; o; o = o->next)
|
|
|
|
if (o->selected && o->is_widget() && o->parent)
|
|
|
|
{
|
2005-03-20 07:00:48 +03:00
|
|
|
if (!changed) {
|
|
|
|
changed = 1;
|
|
|
|
set_modflag(1);
|
|
|
|
undo_checkpoint();
|
|
|
|
}
|
|
|
|
|
2002-05-01 21:35:30 +04:00
|
|
|
Fl_Widget *w = ((Fl_Widget_Type *)o)->o;
|
|
|
|
Fl_Widget *p = ((Fl_Widget_Type *)o->parent)->o;
|
2004-04-06 21:38:36 +04:00
|
|
|
int center2;
|
|
|
|
|
|
|
|
if (w->window() == p) center2 = p->h();
|
|
|
|
else center2 = 2*p->y()+p->h();
|
2004-04-06 22:32:52 +04:00
|
|
|
|
2005-03-05 18:09:59 +03:00
|
|
|
if (o->next && o->next->level > o->level && !o->next->selected &&
|
|
|
|
!o->is_menu_button()) {
|
2004-04-06 22:32:52 +04:00
|
|
|
// When resizing a group, make sure we also move the children...
|
|
|
|
((igroup *)w)->full_resize(w->x(), (center2-w->h())/2, w->w(), w->h());
|
|
|
|
} else {
|
|
|
|
// Otherwise, just do the widget...
|
|
|
|
w->resize(w->x(), (center2-w->h())/2, w->w(), w->h());
|
|
|
|
}
|
2005-03-19 11:38:21 +03:00
|
|
|
set_modflag(1);
|
2002-05-01 21:35:30 +04:00
|
|
|
w->redraw();
|
2004-04-06 06:47:26 +04:00
|
|
|
if (w->window()) w->window()->redraw();
|
2002-05-01 21:35:30 +04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2003-01-10 22:29:09 +03:00
|
|
|
|
|
|
|
|
2005-09-09 15:36:36 +04:00
|
|
|
// Set sizes of selected widgets...
|
2005-03-19 07:09:32 +03:00
|
|
|
void widget_size_cb(Fl_Widget *, long size) {
|
|
|
|
// Update any selected widgets...
|
2005-03-20 07:00:48 +03:00
|
|
|
int changed = 0;
|
2005-09-09 15:36:36 +04:00
|
|
|
for (Fl_Type *o = Fl_Type::first; o; o = o->next) {
|
2005-03-19 07:09:32 +03:00
|
|
|
if (o->selected && o->is_widget()) {
|
2005-03-20 07:00:48 +03:00
|
|
|
if (!changed) {
|
|
|
|
changed = 1;
|
|
|
|
set_modflag(1);
|
|
|
|
undo_checkpoint();
|
|
|
|
}
|
|
|
|
|
2005-03-19 07:09:32 +03:00
|
|
|
Fl_Widget *w = ((Fl_Widget_Type *)o)->o;
|
2008-04-23 23:09:28 +04:00
|
|
|
w->labelsize((Fl_Font)size);
|
2005-03-19 07:09:32 +03:00
|
|
|
Fl_Font f;
|
|
|
|
int s = (int)size;
|
|
|
|
Fl_Color c;
|
|
|
|
((Fl_Widget_Type *)o)->textstuff(2, f, s, c);
|
|
|
|
|
|
|
|
w->redraw();
|
2005-09-09 15:36:36 +04:00
|
|
|
// since this may be a major change, the whole window should be redrawn
|
|
|
|
if (w->window()) w->window()->redraw();
|
2005-03-19 07:09:32 +03:00
|
|
|
}
|
2005-09-09 15:36:36 +04:00
|
|
|
}
|
2005-03-19 07:09:32 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-01-10 22:29:09 +03:00
|
|
|
//
|
2005-02-06 19:28:36 +03:00
|
|
|
// End of "$Id$".
|
2003-01-10 22:29:09 +03:00
|
|
|
//
|
|
|
|
|