libergtk/include/erGtkSelectionList.h File Reference

ereader gtk library - display list of button that the user can select/deselect. More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _erGtkSelectionList
struct  _erGtkSelectionListClass

Defines

#define ERGTK_SELECTION_LIST_H_PADDING   13
#define ERGTK_SELECTION_LIST_V_PADDING   10
#define ERGTK_SELECTION_LIST_TITLE_HEIGHT   27
#define ERGTK_SELECTION_LIST_TITLE_SPACING   5
#define ERGTK_SELECTION_LIST_TITLE_BACKGROUND_STYLE   "erGtkSelectionList_TitleBackground"
#define ERGTK_SELECTION_LIST_TITLE_TEXT_STYLE   "erGtkSelectionList_TitleText"
#define ERGTK_SELECTION_LIST_BACKGROUND_STYLE   "erGtkSelectionList_Background"
#define ERGTK_SELECTION_LIST_INSTRUCTION_HEIGHT   29
#define ERGTK_SELECTION_LIST_INSTRUCTION_STYLE   "erGtkSelectionList_Instruction"
#define ERGTK_SELECTION_LIST_BUTTON_H_SPACING   13
#define ERGTK_SELECTION_LIST_BUTTON_V_SPACING   7
#define ERGTK_SELECTION_LIST_CHECKBUTTON_HEIGHT   29
#define ERGTK_SELECTION_LIST_CHECKBUTTON_STYLE   "erGtkSelectionList_CheckButton"
#define ERGTK_SELECTION_LIST_RADIOBUTTON_HEIGHT   22
#define ERGTK_SELECTION_LIST_RADIOBUTTON_STYLE   "erGtkSelectionList_RadioButton"
#define ERGTK_SELECTION_LIST_TEXTBUTTON_WIDTH   150
#define ERGTK_SELECTION_LIST_TEXTBUTTON_HEIGHT   27
#define ERGTK_SELECTION_LIST_TEXTBUTTON_STYLE   "erGtkSelectionList_TextButton"
#define ERGTK_SELECTION_LIST_CONTINUATION_H_PADDING   5
#define ERGTK_SELECTION_LIST_CONTINUATION_TEXT   "..."
#define ERGTK_SELECTION_LIST_CONTINUATION_STYLE   "erGtkSelectionList_Continuation"
#define ERGTK_SELECTION_LIST_TYPE   (ergtk_selection_list_get_type())
#define ERGTK_SELECTION_LIST(obj)   (G_TYPE_CHECK_INSTANCE_CAST((obj), ERGTK_SELECTION_LIST_TYPE, erGtkSelectionList))
#define ERGTK_IS_SELECTION_LIST(obj)   (G_TYPE_CHECK_INSTANCE_TYPE((obj), ERGTK_SELECTION_LIST_TYPE))
#define ERGTK_SELECTION_LIST_CLASS(klass)   (G_TYPE_CHECK_CLASS_CAST((klass), ERGTK_SELECTION_LIST_TYPE, erGtkSelectionListClass))
#define ERGTK_SELECTION_LIST_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS ((obj), ERGTK_SELECTION_LIST_TYPE, erGtkSelectionListClass))
#define ERGTK_IS_SELECTION_LIST_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE((klass), ERGTK_SELECTION_LIST_TYPE))

Typedefs

typedef struct _erGtkSelectionList erGtkSelectionList
typedef struct
_erGtkSelectionListClass 
erGtkSelectionListClass

Enumerations

enum  erGtkSelectionList_displayAs_e { esl_Checklist, esl_RadioButton, esl_TextButton }

Functions

GtkWidget * ergtk_selection_list_new (const erGtkSelectionList_displayAs_e display_as, const gchar *title, const gchar *instruction, const gchar **item_names, const guint max_height, guint *allocated_items, guint *allocated_height)
GtkWidget * ergtk_selection_list_new_from_master (const erGtkSelectionList *master, const guint first_item, const guint max_height, guint *allocated_items, guint *allocated_height)
void ergtk_selection_list_show_titlebar (const erGtkSelectionList *item, const gboolean show)
GType ergtk_selection_list_get_type (void)


Detailed Description

ereader gtk library - display list of button that the user can select/deselect.

Ensure only the allowed number of buttons is selected at any time. Note: no relation with the standard GTK class GtkSelection.

Copyright (C) 2007 iRex Technologies B.V. All rights reserved.

Definition in file erGtkSelectionList.h.


Define Documentation

#define ERGTK_IS_SELECTION_LIST ( obj   )     (G_TYPE_CHECK_INSTANCE_TYPE((obj), ERGTK_SELECTION_LIST_TYPE))

Definition at line 69 of file erGtkSelectionList.h.

#define ERGTK_IS_SELECTION_LIST_CLASS ( klass   )     (G_TYPE_CHECK_CLASS_TYPE((klass), ERGTK_SELECTION_LIST_TYPE))

Definition at line 73 of file erGtkSelectionList.h.

#define ERGTK_SELECTION_LIST ( obj   )     (G_TYPE_CHECK_INSTANCE_CAST((obj), ERGTK_SELECTION_LIST_TYPE, erGtkSelectionList))

Definition at line 68 of file erGtkSelectionList.h.

#define ERGTK_SELECTION_LIST_BACKGROUND_STYLE   "erGtkSelectionList_Background"

Definition at line 44 of file erGtkSelectionList.h.

#define ERGTK_SELECTION_LIST_BUTTON_H_SPACING   13

Definition at line 49 of file erGtkSelectionList.h.

#define ERGTK_SELECTION_LIST_BUTTON_V_SPACING   7

Definition at line 50 of file erGtkSelectionList.h.

#define ERGTK_SELECTION_LIST_CHECKBUTTON_HEIGHT   29

Definition at line 52 of file erGtkSelectionList.h.

#define ERGTK_SELECTION_LIST_CHECKBUTTON_STYLE   "erGtkSelectionList_CheckButton"

Definition at line 53 of file erGtkSelectionList.h.

#define ERGTK_SELECTION_LIST_CLASS ( klass   )     (G_TYPE_CHECK_CLASS_CAST((klass), ERGTK_SELECTION_LIST_TYPE, erGtkSelectionListClass))

Definition at line 71 of file erGtkSelectionList.h.

#define ERGTK_SELECTION_LIST_CONTINUATION_H_PADDING   5

Definition at line 62 of file erGtkSelectionList.h.

#define ERGTK_SELECTION_LIST_CONTINUATION_STYLE   "erGtkSelectionList_Continuation"

Definition at line 64 of file erGtkSelectionList.h.

#define ERGTK_SELECTION_LIST_CONTINUATION_TEXT   "..."

Definition at line 63 of file erGtkSelectionList.h.

#define ERGTK_SELECTION_LIST_GET_CLASS ( obj   )     (G_TYPE_INSTANCE_GET_CLASS ((obj), ERGTK_SELECTION_LIST_TYPE, erGtkSelectionListClass))

Definition at line 72 of file erGtkSelectionList.h.

#define ERGTK_SELECTION_LIST_H_PADDING   13

Definition at line 36 of file erGtkSelectionList.h.

#define ERGTK_SELECTION_LIST_INSTRUCTION_HEIGHT   29

Definition at line 46 of file erGtkSelectionList.h.

#define ERGTK_SELECTION_LIST_INSTRUCTION_STYLE   "erGtkSelectionList_Instruction"

Definition at line 47 of file erGtkSelectionList.h.

#define ERGTK_SELECTION_LIST_RADIOBUTTON_HEIGHT   22

Definition at line 55 of file erGtkSelectionList.h.

#define ERGTK_SELECTION_LIST_RADIOBUTTON_STYLE   "erGtkSelectionList_RadioButton"

Definition at line 56 of file erGtkSelectionList.h.

#define ERGTK_SELECTION_LIST_TEXTBUTTON_HEIGHT   27

Definition at line 59 of file erGtkSelectionList.h.

#define ERGTK_SELECTION_LIST_TEXTBUTTON_STYLE   "erGtkSelectionList_TextButton"

Definition at line 60 of file erGtkSelectionList.h.

#define ERGTK_SELECTION_LIST_TEXTBUTTON_WIDTH   150

Definition at line 58 of file erGtkSelectionList.h.

#define ERGTK_SELECTION_LIST_TITLE_BACKGROUND_STYLE   "erGtkSelectionList_TitleBackground"

Definition at line 41 of file erGtkSelectionList.h.

#define ERGTK_SELECTION_LIST_TITLE_HEIGHT   27

Definition at line 39 of file erGtkSelectionList.h.

#define ERGTK_SELECTION_LIST_TITLE_SPACING   5

Definition at line 40 of file erGtkSelectionList.h.

#define ERGTK_SELECTION_LIST_TITLE_TEXT_STYLE   "erGtkSelectionList_TitleText"

Definition at line 42 of file erGtkSelectionList.h.

#define ERGTK_SELECTION_LIST_TYPE   (ergtk_selection_list_get_type())

Definition at line 67 of file erGtkSelectionList.h.

#define ERGTK_SELECTION_LIST_V_PADDING   10

Definition at line 37 of file erGtkSelectionList.h.


Typedef Documentation

Definition at line 82 of file erGtkSelectionList.h.

Definition at line 83 of file erGtkSelectionList.h.


Enumeration Type Documentation

Enumerator:
esl_Checklist 
esl_RadioButton 
esl_TextButton 

Definition at line 75 of file erGtkSelectionList.h.


Function Documentation

GType ergtk_selection_list_get_type ( void   ) 

Definition at line 490 of file erGtkSelectionList.c.

00491 {
00492     static GType class_type = 0;
00493 
00494     if (class_type == 0)
00495     {
00496         static const GTypeInfo class_info =
00497         {
00498             sizeof(erGtkSelectionListClass),
00499             NULL,               /* base_init */
00500             NULL,               /* base_finalize */
00501             (GClassInitFunc) ergtk_selection_list_class_init,
00502             NULL,               /* class_finalize */
00503             NULL,               /* class_data */
00504             sizeof(erGtkSelectionList),
00505             0,                  /* n_preallocs */
00506             (GInstanceInitFunc) ergtk_selection_list_init,
00507         };
00508 
00509         class_type = g_type_register_static(ERGTK_SELECTION_GROUP_TYPE, "erGtkSelectionList", &class_info, 0);
00510     }
00511     return class_type;
00512 }

Here is the call graph for this function:

GtkWidget* ergtk_selection_list_new ( const erGtkSelectionList_displayAs_e  display_as,
const gchar *  title,
const gchar *  instruction,
const gchar **  item_names,
const guint  max_height,
guint *  allocated_items,
guint *  allocated_height 
)

Create a new erGtkSelectionList object

Parameters:
in display_as: layout of selection list object
in title: text to be displayed in the object's title bar
in instruction: text to be displayed above the selection items
in item_names: NULL-terminated array of strings to be displayed on the selection items
in max_height: maximum height of the object, measured in pixels
out allocated_items: number of selection items displayed in the new list
out allocated_height: number of pixels required to display the new list
Returns:
reference to created widget

Definition at line 69 of file erGtkSelectionList.c.

00076 {
00077     int               i;
00078     const gchar**     cpp;
00079     guint             height;
00080     guint             num_items = 0;
00081     guint             item_height = 0;
00082     GtkToggleButton** button_tbl = NULL;
00083     guint             items_allocated = 0;
00084     gboolean          instruction_added = FALSE;
00085 
00086     GtkWidget*        widget;
00087     GtkWidget*        alignment;
00088     GtkWidget*        background;
00089     GtkWidget*        vbox;
00090 
00091     LOGPRINTF("entry: title [%s]", title);
00092 
00093     // create new object
00094     erGtkSelectionList* item = (erGtkSelectionList*) g_object_new(ERGTK_SELECTION_LIST_TYPE, NULL);
00095     gtk_widget_show(GTK_WIDGET(item));
00096     item->display_as = display_as;
00097 
00098     // create buttons for all selection items (including the items that will not be displayed)
00099     for (cpp = item_names ; *cpp != NULL ; cpp++)
00100     {
00101         num_items++;
00102     }
00103     button_tbl = g_new0(GtkToggleButton*, num_items + 1);
00104     g_assert(button_tbl != NULL);
00105     for (i = 0 ; i < num_items ; i++)
00106     {
00107         button_tbl[i] = create_button(display_as, item_names[i]);
00108     }
00109     button_tbl[i] = NULL;
00110 
00111     // append buttons to selection group (parent class)
00112     g_parent_class->add_buttons(&(item->parent), button_tbl);
00113 
00114     // create screen objects
00115     //
00116     // widget hierarchy:
00117     //   item (erGtkSelectionList inherits from GtkEventBox)
00118     //     |-- vbox
00119     //           |
00120     widget = gtk_vbox_new(FALSE, ERGTK_SELECTION_LIST_TITLE_SPACING);
00121     gtk_widget_show(widget);
00122     gtk_container_add(GTK_CONTAINER(item), widget);
00123     vbox = widget;
00124     //           |
00125     //           |   #  title
00126     //           |-- titlebar
00127     //           |     |-- label
00128     //           |
00129     widget = gtk_event_box_new();
00130     gtk_widget_show(widget);
00131     gtk_widget_set_name(widget, ERGTK_SELECTION_LIST_TITLE_BACKGROUND_STYLE);
00132     gtk_widget_set_size_request(widget, -1, ERGTK_SELECTION_LIST_TITLE_HEIGHT);
00133     gtk_box_pack_start(GTK_BOX(vbox), widget, FALSE, FALSE, 0);
00134     item_height += ERGTK_SELECTION_LIST_TITLE_HEIGHT;
00135     item->titlebar = widget;
00136     //
00137     widget = gtk_label_new(title);
00138     gtk_widget_show(widget);
00139     gtk_widget_set_name(widget, ERGTK_SELECTION_LIST_TITLE_TEXT_STYLE);
00140     gtk_misc_set_padding(GTK_MISC(widget), ERGTK_SELECTION_LIST_H_PADDING, 0);
00141     gtk_misc_set_alignment(GTK_MISC(widget), 0.0, 0.5);
00142     gtk_container_add(GTK_CONTAINER(item->titlebar), widget);
00143     //           |
00144     //           |   #  selection list
00145     //           |-- background
00146     //                 |-- alignment
00147     //                       |-- vbox
00148     //                             |
00149     widget = gtk_event_box_new();
00150     gtk_widget_show(widget);
00151     gtk_widget_set_name(widget, ERGTK_SELECTION_LIST_BACKGROUND_STYLE);
00152     gtk_box_pack_start(GTK_BOX(vbox), widget, FALSE, FALSE, 0);
00153     item_height += ERGTK_SELECTION_LIST_TITLE_SPACING;
00154     background = widget;
00155     //
00156     widget = gtk_alignment_new(0.0, 0.0, 0.0, 0.0);
00157     gtk_widget_show(widget);
00158     gtk_alignment_set_padding(GTK_ALIGNMENT(widget),
00159                               ERGTK_SELECTION_LIST_V_PADDING, ERGTK_SELECTION_LIST_V_PADDING,
00160                               ERGTK_SELECTION_LIST_H_PADDING, ERGTK_SELECTION_LIST_H_PADDING);
00161     gtk_container_add(GTK_CONTAINER(background), widget);
00162     item_height += 2 * ERGTK_SELECTION_LIST_V_PADDING;
00163     alignment = widget;
00164     //
00165     widget = gtk_vbox_new(FALSE, ERGTK_SELECTION_LIST_BUTTON_V_SPACING);
00166     gtk_widget_show(widget);
00167     gtk_container_add(GTK_CONTAINER(alignment), widget);
00168     vbox = widget;
00169     //                             |-- [instruction]
00170     //                             |
00171     if (instruction  &&  instruction[0] != '\0')
00172     {
00173         instruction_added = TRUE;
00174         widget = gtk_label_new(instruction);
00175         gtk_widget_show(widget);
00176         gtk_widget_set_name(widget, ERGTK_SELECTION_LIST_INSTRUCTION_STYLE);
00177         gtk_misc_set_alignment(GTK_MISC(widget), 0.0, 0.5);
00178         gtk_box_pack_start(GTK_BOX(vbox), widget, FALSE, FALSE, 0);
00179         item_height += ERGTK_SELECTION_LIST_INSTRUCTION_HEIGHT;
00180     }
00181     //                             |-- buttons (0 ..)
00182     add_buttons_to_screen_layout( item,
00183                                   GTK_VBOX(vbox),
00184                                   item->parent.buttons,
00185                                   0,
00186                                   max_height - item_height,
00187                                   &items_allocated,
00188                                   &height );
00189     item_height += height;
00190     //
00191     if (instruction_added  &&  items_allocated > 0)
00192     {
00193         item_height += ERGTK_SELECTION_LIST_BUTTON_V_SPACING;
00194     }
00195 
00196     // that's all folks ..
00197     *allocated_items  = items_allocated;
00198     *allocated_height = item_height;
00199     g_free(button_tbl);
00200     if (item_height <= max_height)
00201     {
00202         return GTK_WIDGET(item);
00203     }
00204     else
00205     {
00206         gtk_widget_destroy(GTK_WIDGET(item));
00207         return NULL;
00208     }
00209 }

Here is the call graph for this function:

GtkWidget* ergtk_selection_list_new_from_master ( const erGtkSelectionList master,
const guint  first_item,
const guint  max_height,
guint *  allocated_items,
guint *  allocated_height 
)

Create a new erGtkSelectionList object as extension from another (master) object

Parameters:
in master: the master erGtkSelectionList object
in first_item: index (0 ..) of first item displayed
in max_height: maximum height of the object, measured in pixels
out allocated_items: number of selection items displayed in the new list
out allocated_height: number of pixels required to display the new list
Returns:
reference to created widget

Definition at line 212 of file erGtkSelectionList.c.

00217 {
00218     g_return_val_if_fail(ERGTK_IS_SELECTION_LIST(master), FALSE);
00219 
00220     guint      height;
00221     guint      item_height = 0;
00222     guint      items_allocated = 0;
00223     
00224     GtkWidget* widget;
00225     GtkWidget* alignment;
00226     GtkWidget* vbox;
00227 
00228     // create new object
00229     erGtkSelectionList* item = (erGtkSelectionList*) g_object_new(ERGTK_SELECTION_LIST_TYPE, NULL);
00230     item->display_as = master->display_as;
00231     gtk_widget_show(GTK_WIDGET(item));
00232 
00233     // create screen objects
00234     //
00235     // widget hierarchy:
00236     //   item (erGtkSelectionList inherits from GtkEventBox)
00237     //     |
00238     gtk_widget_set_name(GTK_WIDGET(item), ERGTK_SELECTION_LIST_BACKGROUND_STYLE);
00239     //     |
00240     //     |   #  selection list
00241     //     |-- alignment
00242     //           |-- vbox
00243     //                 |
00244     widget = gtk_alignment_new(0.0, 0.0, 0.0, 0.0);
00245     gtk_widget_show(widget);
00246     gtk_alignment_set_padding(GTK_ALIGNMENT(widget),
00247                               ERGTK_SELECTION_LIST_V_PADDING, ERGTK_SELECTION_LIST_V_PADDING,
00248                               ERGTK_SELECTION_LIST_H_PADDING, ERGTK_SELECTION_LIST_H_PADDING);
00249     gtk_container_add(GTK_CONTAINER(item), widget);
00250     item_height += 2 * ERGTK_SELECTION_LIST_V_PADDING;
00251     alignment = widget;
00252     //
00253     widget = gtk_vbox_new(FALSE, ERGTK_SELECTION_LIST_BUTTON_V_SPACING);
00254     gtk_widget_show(widget);
00255     gtk_container_add(GTK_CONTAINER(alignment), widget);
00256     vbox = widget;
00257     //                 |
00258     //                 |-- buttons (0 ..)
00259     add_buttons_to_screen_layout( item,
00260                                   GTK_VBOX(vbox),
00261                                   master->parent.buttons,
00262                                   first_item,
00263                                   max_height,
00264                                   &items_allocated,
00265                                   &height);
00266     item_height += height;
00267 
00268     // that's all folks ..
00269     *allocated_items  = items_allocated;
00270     *allocated_height = item_height;
00271     if (item_height <= max_height)
00272     {
00273         return GTK_WIDGET(item);
00274     }
00275     else
00276     {
00277         gtk_widget_destroy(GTK_WIDGET(item));
00278         return NULL;
00279     }
00280 }

Here is the call graph for this function:

void ergtk_selection_list_show_titlebar ( const erGtkSelectionList item,
const gboolean  show 
)

Show or hide the title bar

Parameters:
in item: the erGtkSelectionList object
in show: TRUE/FALSE = show/hide title bar
Returns:
--

Definition at line 474 of file erGtkSelectionList.c.

00475 {
00476     g_return_if_fail(item != NULL);
00477     g_return_if_fail(ERGTK_IS_SELECTION_LIST(item));
00478 
00479     if (show)
00480     {
00481         gtk_widget_show(item->titlebar);
00482     }
00483     else
00484     {
00485         gtk_widget_hide(item->titlebar);
00486     }
00487 }


Generated on Sun Dec 14 17:12:33 2008 by  doxygen 1.5.6