/* gui_box.c - GUI container that stack components. */
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2008,2009 Free Software Foundation, Inc.
*
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* GRUB 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
*/
#include <grub/gui_string_util.h>
struct component_node
{
};
unsigned *minimal_width,
unsigned *minimal_height);
struct grub_gui_box
{
char *id;
/* Doubly linked list of components with dummy head & tail nodes. */
/* The layout function: differs for vertical and horizontal boxes. */
};
static void
{
{
/* Copy the 'next' pointer, since we need it for the next iteration,
and we're going to free the memory it is stored in. */
/* Destroy the child component. */
/* Free the linked list node. */
}
}
static const char *
{
}
static int
{
}
static void
unsigned *min_width, unsigned *min_height)
{
/* Start at the left (chead) and set the x coordinates as we go right. */
/* All components have their width set to the box's width. */
unsigned w = 0, mwfrac = 0, h = 0, x = 0;
int bogus_frac = 0;
{
if (c->ops->get_minimal_size)
if (c->h > (signed) h)
h = c->h;
if (mh > h)
h = mh;
w += c->w;
if (mw - c->w > 0)
}
bogus_frac = 1;
if (min_width)
{
if (wfrac < GRUB_FIXED_1)
else
*min_width = w;
}
if (min_height)
*min_height = h;
if (!modify_layout)
return;
{
r.x = x;
r.y = 0;
r.height = h;
if (c->ops->get_minimal_size)
r.width = c->w;
if (!bogus_frac)
c->ops->set_bounds (c, &r);
x += r.width;
}
}
static void
unsigned *min_width, unsigned *min_height)
{
/* Start at the top (chead) and set the y coordinates as we go rdown. */
/* All components have their height set to the box's height. */
unsigned h = 0, mhfrac = 0, w = 0, y = 0;
int bogus_frac = 0;
{
if (c->ops->get_minimal_size)
if (c->w > (signed) w)
w = c->w;
if (mw > w)
w = mw;
h += c->h;
if (mh - c->h > 0)
}
bogus_frac = 1;
if (min_height)
{
if (hfrac < GRUB_FIXED_1)
else
*min_height = h;
if (*min_height < h + mhfrac)
*min_height = h + mhfrac;
}
if (min_width)
*min_width = w;
if (!modify_layout)
return;
{
r.x = 0;
r.y = y;
r.width = w;
if (c->ops->get_minimal_size)
r.height = c->h;
if (!bogus_frac)
c->ops->set_bounds (c, &r);
y += r.height;
}
}
static void
{
{
}
}
static void
{
}
static grub_gui_container_t
{
}
static void
{
}
static void
{
}
/* The box's preferred size is based on the preferred sizes
of its children. */
static void
{
}
static grub_err_t
{
{
if (value)
{
return grub_errno;
}
else
}
return grub_errno;
}
static void
{
if (! node)
return; /* Note: probably should handle the error. */
/* Insert the node before the tail. */
}
static void
{
{
{
/* Unlink 'cur' from the list. */
/* Free the node's memory (but don't destroy the component). */
/* Must not loop again, since 'cur' would be dereferenced! */
return;
}
}
}
static void
{
}
{
.destroy = box_destroy,
.get_id = box_get_id,
};
{
.remove = box_remove,
};
/* Box constructor. Specify the appropriate layout function to create
a horizontal or vertical stacking box. */
static grub_gui_box_t
{
if (! box)
return 0;
return box;
}
/* Create a new container that stacks its child components horizontally,
from left to right. Each child get a width corresponding to its
preferred width. The height of each child is set the maximum of the
preferred heights of all children. */
grub_gui_hbox_new (void)
{
}
/* Create a new container that stacks its child components verticallyj,
from top to bottom. Each child get a height corresponding to its
preferred height. The width of each child is set the maximum of the
preferred widths of all children. */
grub_gui_vbox_new (void)
{
}