Data Structures | Macros | Typedefs | Enumerations | Functions
gntwidget.h File Reference

Widget API. More...

#include <stdio.h>
#include <glib.h>
#include <ncurses.h>
#include "gntbindable.h"

Go to the source code of this file.

Data Structures

struct  _GntWidgetPriv
 
struct  _GntWidget
 
struct  _GntWidgetClass
 

Macros

#define GNT_TYPE_WIDGET   (gnt_widget_get_gtype())
 
#define GNT_WIDGET(obj)   (G_TYPE_CHECK_INSTANCE_CAST((obj), GNT_TYPE_WIDGET, GntWidget))
 
#define GNT_WIDGET_CLASS(klass)   (G_TYPE_CHECK_CLASS_CAST((klass), GNT_TYPE_WIDGET, GntWidgetClass))
 
#define GNT_IS_WIDGET(obj)   (G_TYPE_CHECK_INSTANCE_TYPE((obj), GNT_TYPE_WIDGET))
 
#define GNT_IS_WIDGET_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE((klass), GNT_TYPE_WIDGET))
 
#define GNT_WIDGET_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS((obj), GNT_TYPE_WIDGET, GntWidgetClass))
 
#define GNT_WIDGET_FLAGS(obj)   (GNT_WIDGET(obj)->priv.flags)
 
#define GNT_WIDGET_SET_FLAGS(obj, flags)   (GNT_WIDGET_FLAGS(obj) |= flags)
 
#define GNT_WIDGET_UNSET_FLAGS(obj, flags)   (GNT_WIDGET_FLAGS(obj) &= ~(flags))
 
#define GNT_WIDGET_IS_FLAG_SET(obj, flags)   (GNT_WIDGET_FLAGS(obj) & (flags))
 

Typedefs

typedef struct _GntWidget GntWidget
 
typedef struct _GntWidgetPriv GntWidgetPriv
 
typedef struct _GntWidgetClass GntWidgetClass
 
typedef enum _GntWidgetFlags GntWidgetFlags
 
typedef enum _GntMouseEvent GntMouseEvent
 
typedef enum _GntParamFlags GntParamFlags
 

Enumerations

enum  _GntWidgetFlags {
  GNT_WIDGET_DESTROYING = 1 << 0, GNT_WIDGET_CAN_TAKE_FOCUS = 1 << 1, GNT_WIDGET_MAPPED = 1 << 2, GNT_WIDGET_NO_BORDER = 1 << 3,
  GNT_WIDGET_NO_SHADOW = 1 << 4, GNT_WIDGET_HAS_FOCUS = 1 << 5, GNT_WIDGET_DRAWING = 1 << 6, GNT_WIDGET_URGENT = 1 << 7,
  GNT_WIDGET_GROW_X = 1 << 8, GNT_WIDGET_GROW_Y = 1 << 9, GNT_WIDGET_INVISIBLE = 1 << 10, GNT_WIDGET_TRANSIENT = 1 << 11,
  GNT_WIDGET_DISABLE_ACTIONS = 1 << 12
}
 
enum  _GntMouseEvent {
  GNT_LEFT_MOUSE_DOWN = 1, GNT_RIGHT_MOUSE_DOWN, GNT_MIDDLE_MOUSE_DOWN, GNT_MOUSE_UP,
  GNT_MOUSE_SCROLL_UP, GNT_MOUSE_SCROLL_DOWN
}
 
enum  _GntParamFlags { GNT_PARAM_SERIALIZABLE = 1 << G_PARAM_USER_SHIFT }
 

Functions

G_BEGIN_DECLS GType gnt_widget_get_gtype (void)
 
void gnt_widget_destroy (GntWidget *widget)
 Destroy a widget. More...
 
void gnt_widget_show (GntWidget *widget)
 Show a widget. More...
 
void gnt_widget_draw (GntWidget *widget)
 Draw a widget. More...
 
void gnt_widget_expose (GntWidget *widget, int x, int y, int width, int height)
 
void gnt_widget_hide (GntWidget *widget)
 Hide a widget. More...
 
void gnt_widget_get_position (GntWidget *widget, int *x, int *y)
 Get the position of a widget. More...
 
void gnt_widget_set_position (GntWidget *widget, int x, int y)
 Set the position of a widget. More...
 
void gnt_widget_size_request (GntWidget *widget)
 Request a widget to calculate its desired size. More...
 
void gnt_widget_get_size (GntWidget *widget, int *width, int *height)
 Get the size of a widget. More...
 
gboolean gnt_widget_set_size (GntWidget *widget, int width, int height)
 Set the size of a widget. More...
 
gboolean gnt_widget_confirm_size (GntWidget *widget, int width, int height)
 Confirm a requested a size for a widget. More...
 
gboolean gnt_widget_key_pressed (GntWidget *widget, const char *keys)
 Trigger the key-press callbacks for a widget. More...
 
gboolean gnt_widget_clicked (GntWidget *widget, GntMouseEvent event, int x, int y)
 Trigger the 'click' callback of a widget. More...
 
gboolean gnt_widget_set_focus (GntWidget *widget, gboolean set)
 Give or remove focus to a widget. More...
 
void gnt_widget_activate (GntWidget *widget)
 Activate a widget. More...
 
void gnt_widget_set_name (GntWidget *widget, const char *name)
 Set the name of a widget. More...
 
const char * gnt_widget_get_name (GntWidget *widget)
 Get the name of a widget. More...
 
void gnt_widget_queue_update (GntWidget *widget)
 
void gnt_widget_set_take_focus (GntWidget *widget, gboolean set)
 Set whether a widget can take focus or not. More...
 
void gnt_widget_set_visible (GntWidget *widget, gboolean set)
 Set the visibility of a widget. More...
 
gboolean gnt_widget_has_shadow (GntWidget *widget)
 Check whether the widget has shadows. More...
 

Detailed Description

Widget API.

Definition in file gntwidget.h.

Function Documentation

void gnt_widget_activate ( GntWidget widget)

Activate a widget.

This only applies to widgets that can be activated (eg. GntButton)

Parameters
widgetThe widget to activate.
gboolean gnt_widget_clicked ( GntWidget widget,
GntMouseEvent  event,
int  x,
int  y 
)

Trigger the 'click' callback of a widget.

Parameters
widgetThe widget.
eventThe mouseevent.
xThe x-coordinate of the mouse.
yThe y-coordinate of the mouse.
Returns
TRUE if the event was handled, FALSE otherwise.
gboolean gnt_widget_confirm_size ( GntWidget widget,
int  width,
int  height 
)

Confirm a requested a size for a widget.

Parameters
widgetThe widget.
widthThe requested width.
heightThe requested height.
Returns
TRUE if the new size was confirmed, FALSE otherwise.
void gnt_widget_destroy ( GntWidget widget)

Destroy a widget.

Parameters
widgetThe widget to destroy.
void gnt_widget_draw ( GntWidget widget)

Draw a widget.

Parameters
widgetThe widget to draw.
G_BEGIN_DECLS GType gnt_widget_get_gtype ( void  )
Returns
GType for GntWidget.
const char* gnt_widget_get_name ( GntWidget widget)

Get the name of a widget.

Parameters
widgetThe widget.
Returns
The name of the widget.
void gnt_widget_get_position ( GntWidget widget,
int *  x,
int *  y 
)

Get the position of a widget.

Parameters
widgetThe widget.
xLocation to store the x-coordinate of the widget.
yLocation to store the y-coordinate of the widget.
void gnt_widget_get_size ( GntWidget widget,
int *  width,
int *  height 
)

Get the size of a widget.

Parameters
widgetThe widget.
widthLocation to store the width of the widget.
heightLocation to store the height of the widget.
gboolean gnt_widget_has_shadow ( GntWidget widget)

Check whether the widget has shadows.

Parameters
widgetThe widget.
Returns
TRUE if the widget has shadows. This checks both the user-setting and whether the widget can have shadows at all.
void gnt_widget_hide ( GntWidget widget)

Hide a widget.

Parameters
widgetThe widget to hide.
gboolean gnt_widget_key_pressed ( GntWidget widget,
const char *  keys 
)

Trigger the key-press callbacks for a widget.

Parameters
widgetThe widget.
keysThe keypress on the widget.
Returns
TRUE if the key-press was handled, FALSE otherwise.
gboolean gnt_widget_set_focus ( GntWidget widget,
gboolean  set 
)

Give or remove focus to a widget.

Parameters
widgetThe widget.
setTRUE of focus should be given to the widget, FALSE if focus should be removed.
Returns
TRUE if the focus has been changed, FALSE otherwise.
void gnt_widget_set_name ( GntWidget widget,
const char *  name 
)

Set the name of a widget.

Parameters
widgetThe widget.
nameA new name for the widget.
void gnt_widget_set_position ( GntWidget widget,
int  x,
int  y 
)

Set the position of a widget.

Parameters
widgetThe widget to reposition.
xThe x-coordinate of the widget.
yThe x-coordinate of the widget.
gboolean gnt_widget_set_size ( GntWidget widget,
int  width,
int  height 
)

Set the size of a widget.

Parameters
widgetThe widget to resize.
widthThe width of the widget.
heightThe height of the widget.
Returns
If the widget was resized to the new size.
void gnt_widget_set_take_focus ( GntWidget widget,
gboolean  set 
)

Set whether a widget can take focus or not.

Parameters
widgetThe widget.
setTRUE if the widget can take focus.
void gnt_widget_set_visible ( GntWidget widget,
gboolean  set 
)

Set the visibility of a widget.

Parameters
widgetThe widget.
setWhether the widget is visible or not.
void gnt_widget_show ( GntWidget widget)

Show a widget.

This should only be used for toplevel widgets. For the rest of the widgets, use gnt_widget_draw instead.

Parameters
widgetThe widget to show.
void gnt_widget_size_request ( GntWidget widget)

Request a widget to calculate its desired size.

Parameters
widgetThe widget.