erGtkPageBar.h File Reference

ereader gtk library - GtkPageBar widget for ereader system More...

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

Go to the source code of this file.

Defines

#define GTK_PAGEBAR_TYPE   (gtk_pagebar_get_type ())
#define GTK_PAGEBAR(obj)   (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_PAGEBAR_TYPE, GtkPagebar))
#define GTK_PAGEBAR_CLASS(klass)   (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_PAGEBAR_TYPE, GtkPagebarClass))
#define IS_GTK_PAGEBAR(obj)   (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_PAGEBAR_TYPE))
#define IS_GTK_PAGEBAR_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_PAGEBAR_TYPE))

Typedefs

typedef struct _GtkPagebar GtkPagebar
typedef struct _GtkPagebarClass GtkPagebarClass

Functions

GtkWidget * gtk_pagebar_new (void)
 Creates a new gtk pagebar widget.
void gtk_pagebar_set_number_of_pages (GtkPagebar *pagebar, const unsigned int number)
 Specify the total number of page.
unsigned int gtk_pagebar_get_number_of_pages (GtkPagebar *pagebar)
 Get total number from pagebar.
gboolean gtk_pagebar_set_current_page (GtkPagebar *pagebar, const unsigned int page)
 Specify the current page.
unsigned int gtk_pagebar_get_current_page (GtkPagebar *pagebar)
 Get the current page.
gboolean gtk_pagebar_set_bookmark (GtkPagebar *pagebar, const unsigned int page)
 Add a bookmark to the specified page.
gboolean gtk_pagebar_delete_bookmark (GtkPagebar *pagebar, const unsigned int page)
 Remove a bookmark of specified page.
const GArray * gtk_pagebar_get_bookmarks (GtkPagebar *pagebar)
 Get the read only bookmarks array.
void gtk_pagebar_reset (GtkPagebar *pagebar)
 Reset the pagebar.
GType gtk_pagebar_get_type (void)
 Get type of gtk pagebar widget.
unsigned int gtk_pagebar_get_minimal_height (GtkPagebar *pagebar)
 Get the minimal height of pagebar. If the widget height is less than minimal height, the pagebar cannot be displayed normally.
void gtk_pagebar_update (GtkPagebar *pagebar)
 Redraw the pagebar.

Detailed Description

ereader gtk library - GtkPageBar widget for ereader system

Definition in file erGtkPageBar.h.


Define Documentation

#define GTK_PAGEBAR ( obj   )     (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_PAGEBAR_TYPE, GtkPagebar))
#define GTK_PAGEBAR_CLASS ( klass   )     (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_PAGEBAR_TYPE, GtkPagebarClass))

Definition at line 35 of file erGtkPageBar.h.

#define GTK_PAGEBAR_TYPE   (gtk_pagebar_get_type ())

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

Definition at line 33 of file erGtkPageBar.h.

Referenced by gtk_pagebar_new().

#define IS_GTK_PAGEBAR ( obj   )     (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_PAGEBAR_TYPE))
#define IS_GTK_PAGEBAR_CLASS ( klass   )     (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_PAGEBAR_TYPE))

Definition at line 37 of file erGtkPageBar.h.


Typedef Documentation

typedef struct _GtkPagebar GtkPagebar

Definition at line 39 of file erGtkPageBar.h.

Definition at line 40 of file erGtkPageBar.h.


Function Documentation

gboolean gtk_pagebar_delete_bookmark ( GtkPagebar pagebar,
const unsigned int  page 
)

Remove a bookmark of specified page.

Parameters:
pagebar The pagebar object.
page The target page number.
Returns:
Returns TRUE if sucessfully delete the bookmark, otherwise returns FALSE

Definition at line 1015 of file erGtkPageBar.c.

References remove_bookmark().

01017 {
01018     return remove_bookmark(pagebar, page);
01019 }

Here is the call graph for this function:

const GArray* gtk_pagebar_get_bookmarks ( GtkPagebar pagebar  ) 

Get the read only bookmarks array.

Parameters:
pagebar The pagebar object.
Returns:
Returns the READ ONLY bookmarks array. It can be NULL

Definition at line 1021 of file erGtkPageBar.c.

References _GtkPagebar::bookmarks, and IS_GTK_PAGEBAR.

Referenced by main(), and test_assertions().

01022 {
01023     g_return_val_if_fail(IS_GTK_PAGEBAR(pagebar), NULL);
01024 
01025     return pagebar->bookmarks;
01026 }

Here is the caller graph for this function:

unsigned int gtk_pagebar_get_current_page ( GtkPagebar pagebar  ) 

Get the current page.

Parameters:
pagebar The pagebar object.
Returns:
Return the number of current page

Definition at line 999 of file erGtkPageBar.c.

References _GtkPagebar::current_page, and IS_GTK_PAGEBAR.

Referenced by test_assertions().

01000 {
01001     g_return_val_if_fail(IS_GTK_PAGEBAR(pagebar), -1);
01002 
01003     return pagebar->current_page;
01004 }

Here is the caller graph for this function:

unsigned int gtk_pagebar_get_minimal_height ( GtkPagebar pagebar  ) 

Get the minimal height of pagebar. If the widget height is less than minimal height, the pagebar cannot be displayed normally.

Parameters:
pagebar The pagebar object.
Returns:
return the minimal height of page bar.

Definition at line 1045 of file erGtkPageBar.c.

References bitmap_data_t::cpi_height, IS_GTK_PAGEBAR, and bitmap_data_t::page_field_height.

Referenced by test_assertions().

01046 {
01047     g_return_val_if_fail(IS_GTK_PAGEBAR(pagebar), 0);
01048 
01049     return MAX(g_bitmap_data.cpi_height, g_bitmap_data.page_field_height);
01050 }

Here is the caller graph for this function:

unsigned int gtk_pagebar_get_number_of_pages ( GtkPagebar pagebar  ) 

Get total number from pagebar.

Parameters:
pagebar The pagebar object.
Returns:
return the total number of pages

Definition at line 978 of file erGtkPageBar.c.

References IS_GTK_PAGEBAR, and _GtkPagebar::page_count.

Referenced by test_assertions().

00979 {
00980     g_return_val_if_fail(IS_GTK_PAGEBAR(pagebar), -1);
00981 
00982     return pagebar->page_count;
00983 }

Here is the caller graph for this function:

GType gtk_pagebar_get_type ( void   ) 

Get type of gtk pagebar widget.

Returns:
type

Definition at line 218 of file erGtkPageBar.c.

References gtk_pagebar_class_init(), and gtk_pagebar_init().

00219 {
00220     static GType pagebar_type = 0;
00221 
00222     if (!pagebar_type)
00223     {
00224     static const GTypeInfo pagebar_info = {
00225         sizeof(GtkPagebarClass),
00226         NULL,       /* base_init */
00227         NULL,       /* base_finalize */
00228         (GClassInitFunc) gtk_pagebar_class_init,
00229         NULL,       /* class_finalize */
00230         NULL,       /* class_data */
00231         sizeof(GtkPagebar),
00232         0,          /* n_preallocs */
00233         (GInstanceInitFunc) gtk_pagebar_init,
00234         NULL        /* *value_table */
00235     };
00236 
00237     pagebar_type =
00238         g_type_register_static(GTK_TYPE_DRAWING_AREA,
00239                                 "erGtkPagebar",
00240                                 &pagebar_info,
00241                                 (GTypeFlags)(0));
00242     }
00243 
00244     return pagebar_type;
00245 }

Here is the call graph for this function:

GtkWidget* gtk_pagebar_new ( void   ) 

Creates a new gtk pagebar widget.

Parameters:
- 
Returns:
Reference to created widget.

Definition at line 336 of file erGtkPageBar.c.

References _GtkPagebar::bookmarks, gtk_pagebar_reset(), GTK_PAGEBAR_TYPE, _GtkPagebar::own_gc, _GtkPagebar::pango_layout, and _GtkPagebar::pixmap.

Referenced by main().

00337 {
00338     GtkPagebar *pagebar = 0;
00339     PangoFontDescription *fontdesc = 0;
00340 
00341     pagebar = (GtkPagebar *) g_object_new(GTK_PAGEBAR_TYPE, NULL);
00342 
00343     pagebar->bookmarks = NULL;
00344 
00345     // Initiailize with default values.
00346     gtk_pagebar_reset(pagebar);
00347 
00348     // Calculate layout. Hard code the font family here.
00349     // Any other good way to handle that? TODO
00350     pagebar->pango_layout =
00351         gtk_widget_create_pango_layout(GTK_WIDGET(pagebar),
00352                                        "X");
00353     fontdesc = 
00354         pango_font_description_from_string("Bitstream Vera Sans Roman 7.2");
00355 
00356     pango_layout_set_font_description(pagebar->pango_layout, fontdesc);
00357     pango_font_description_free(fontdesc);
00358 
00359     pagebar->pixmap = NULL;
00360     pagebar->own_gc = NULL;
00361 
00362     return GTK_WIDGET(pagebar);
00363 }

Here is the call graph for this function:

Here is the caller graph for this function:

void gtk_pagebar_reset ( GtkPagebar pagebar  ) 

Reset the pagebar.

Parameters:
pagebar The pagebar object.
Returns:
This function does not have return value.

Definition at line 1028 of file erGtkPageBar.c.

References _GtkPagebar::bookmarks, _GtkPagebar::current_page, IS_GTK_PAGEBAR, _GtkPagebar::page_count, PAGEBAR_DEFAULT_CURRENT_PAGE, PAGEBAR_DEFAULT_PAGE_COUNT, _GtkPagebar::status, and STATUS_NORMAL.

Referenced by gtk_pagebar_finalize(), gtk_pagebar_new(), and test_assertions().

01029 {
01030     g_return_if_fail(IS_GTK_PAGEBAR(pagebar));
01031 
01032     pagebar->page_count = PAGEBAR_DEFAULT_PAGE_COUNT;
01033     pagebar->current_page = PAGEBAR_DEFAULT_CURRENT_PAGE;
01034     pagebar->status = STATUS_NORMAL;
01035 
01036     if (pagebar->bookmarks)
01037     {
01038         g_array_free(pagebar->bookmarks, TRUE);
01039         pagebar->bookmarks = NULL;
01040     }
01041 
01042     // Do not release the bitmap here.
01043 }

Here is the caller graph for this function:

gboolean gtk_pagebar_set_bookmark ( GtkPagebar pagebar,
const unsigned int  page 
)

Add a bookmark to the specified page.

Parameters:
pagebar The pagebar object.
page The target page number.
Returns:
It returns FALSE if set fails, otherwise returns TRUE.

Definition at line 1006 of file erGtkPageBar.c.

References add_bookmark(), and IS_GTK_PAGEBAR.

Referenced by main(), and test_assertions().

01008 {
01009     g_return_val_if_fail(IS_GTK_PAGEBAR(pagebar), FALSE);
01010     g_return_val_if_fail((page > 0 && page <= pagebar->page_count), FALSE);
01011 
01012     return add_bookmark(pagebar, page);
01013 }

Here is the call graph for this function:

Here is the caller graph for this function:

gboolean gtk_pagebar_set_current_page ( GtkPagebar pagebar,
const unsigned int  page 
)

Specify the current page.

Parameters:
pagebar The pagebar object.
page The current page number.
Returns:
It returns FALSE if current page is ouf of range. Otherwise It returns TRUE.

Definition at line 985 of file erGtkPageBar.c.

References _GtkPagebar::current_page, gtk_pagebar_draw(), IS_GTK_PAGEBAR, and _GtkPagebar::last_selected_page.

Referenced by key_release_callback(), main(), and test_assertions().

00987 {
00988     g_return_val_if_fail(IS_GTK_PAGEBAR(pagebar), FALSE);
00989 
00990     if (pagebar->current_page != current)
00991     {
00992         pagebar->current_page = current;
00993         pagebar->last_selected_page = current;
00994         gtk_pagebar_draw(pagebar);
00995     }
00996     return TRUE;
00997 }

Here is the call graph for this function:

Here is the caller graph for this function:

void gtk_pagebar_set_number_of_pages ( GtkPagebar pagebar,
const unsigned int  number 
)

Specify the total number of page.

Parameters:
pagebar The pagebar object.
number The total page number.
Returns:
It does not have return value.

Definition at line 958 of file erGtkPageBar.c.

References gtk_pagebar_draw(), IS_GTK_PAGEBAR, _GtkPagebar::max_detailed_items, _GtkPagebar::page_count, PAGEBAR_MAX_PAGES, _GtkPagebar::status, STATUS_DETAILS, and STATUS_NORMAL.

Referenced by main(), and test_assertions().

00960 {
00961     g_return_if_fail(IS_GTK_PAGEBAR(pagebar));
00962     g_return_if_fail((number <= PAGEBAR_MAX_PAGES));
00963 
00964     pagebar->page_count = number;
00965 
00966     if (pagebar->page_count > pagebar->max_detailed_items)
00967     {
00968         pagebar->status = STATUS_NORMAL;
00969     }
00970     else
00971     {
00972         pagebar->status = STATUS_DETAILS;
00973     }
00974 
00975     gtk_pagebar_draw(pagebar);
00976 }

Here is the call graph for this function:

Here is the caller graph for this function:

void gtk_pagebar_update ( GtkPagebar pagebar  ) 

Redraw the pagebar.

Parameters:
pagebar The pagebar object.

Definition at line 1909 of file erGtkPageBar.c.

References gtk_pagebar_draw().

01910 {
01911     gtk_pagebar_draw(pagebar);
01912 }

Here is the call graph for this function:

Generated by  doxygen 1.6.2-20100208