/* gui_list.c - GUI component to display a selectable list of items. */
/*
* 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>
#include <grub/gfxmenu_view.h>
#include <grub/gfxwidgets.h>
struct grub_gui_list_impl
{
char *id;
int visible;
int icon_width;
int icon_height;
int item_height;
int item_padding;
int item_icon_space;
int item_spacing;
int draw_scrollbar;
char *scrollbar_frame_pattern;
char *scrollbar_thumb_pattern;
int scrollbar_width;
int first_shown_index;
char *theme_dir;
char *menu_box_pattern;
char *selected_item_box_pattern;
};
static void
{
if (self->selected_item_box)
if (self->icon_manager)
}
static int
{
}
static int
{
if (self->need_to_recreate_boxes)
{
self->need_to_recreate_boxes = 0;
}
}
static int
{
{
}
}
static const char *
{
}
static int
{
}
static struct grub_video_bitmap *
{
if (! entry)
return 0;
}
static void
{
if (selected_index < 0)
return; /* No item is selected. */
else if (selected_index > last_shown_index)
}
/* Draw a scrollbar on the menu. */
static void
{
topy);
thumby);
}
/* Draw the list of items. */
static void
{
return;
int menu_index;
int visible_index;
visible_index++, menu_index++)
{
if (is_selected)
{
if (selbox->get_border_width)
item_top - sel_toppad);
}
if (icon != 0)
const char *item_title =
: self->item_color);
font,
/ 2 + ascent));
}
oviewport.y,
}
static void
{
return;
return;
check_boxes (self);
return;
{
&& check_scrollbar (self));
content_rect.x = box_left_pad;
content_rect.y = box_top_pad;
if (drawing_scrollbar)
+ self->scrollbar_width,
}
}
static void
{
}
static grub_gui_container_t
{
}
static void
{
}
static void
{
}
static void
{
if (check_boxes (self))
{
unsigned width_s;
"Typical OS");
/* Set the menu box height to fit the items. */
+ 2 * boxpad
}
else
{
*width = 0;
*height = 0;
}
}
static grub_err_t
{
{
}
{
self->selected_item_font = 0;
else
}
{
}
{
{
self->selected_item_color_set = 0;
}
else
{
== GRUB_ERR_NONE)
}
}
{
self->icon_height);
}
{
self->icon_height);
}
{
}
{
}
{
}
{
}
{
}
{
}
{
}
{
}
{
}
{
}
{
}
{
}
{
if (value)
else
}
return grub_errno;
}
/* Set necessary information that the gfxmenu view provides. */
static void
{
view->theme_path);
}
{
.destroy = list_destroy,
.get_id = list_get_id,
.paint = list_paint,
};
{
};
grub_gui_list_new (void)
{
if (! self)
return 0;
default_fg_color = grub_video_rgba_color_rgb (0, 0, 0);
self->scrollbar_frame = 0;
self->scrollbar_thumb = 0;
self->scrollbar_frame_pattern = 0;
self->scrollbar_thumb_pattern = 0;
self->first_shown_index = 0;
self->need_to_recreate_boxes = 0;
self->menu_box_pattern = 0;
if (! self->icon_manager)
{
return 0;
}
self->icon_height);
return (grub_gui_component_t) self;
}