gtkIOStream  1.6.0
GTK+ << C++ IOStream operators for GTK+. Now with ORBing, numerical computation, audio client and more ...
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Buttons Class Reference

Class to setup buttons whic are either text, image or toggle types. Buttons are defined in terms of their callbacks functions and data as well as their type (image, text or toggle) You stream in any new buttons you want to create, for example : More...

#include <Buttons.H>

Inheritance diagram for Buttons:
[legend]
Collaboration diagram for Buttons:
[legend]

Public Member Functions

 Buttons (void)
 Constructor. More...
 
void setAlignment (float xAlign, float yAlign)
 
void getAlignment (float *xAlign, float *yAlign)
 
void signalConnectAfter (LabelFuncData nf)
 Destructor. More...
 
void signalConnectAfter (const AnyFuncData &af)
 connect a callback to execute after the currently connected callbacks More...
 
void signalReplace (LabelFuncData nfOld, LabelFuncData nfNew)
 disconnect the old callback and reconnect a new callback More...
 
void signalRemove (AnyFuncData nfOld)
 disconnect the old callback and reconnect a new callback More...
 
Buttonsoperator<< (LabelFuncData nf)
 generate a label button More...
 
Buttonsoperator<< (const PixmapFuncData nf)
 generate a button with a static pixmap More...
 
Buttonsoperator<< (ToggleFuncData nf)
 generate a toggle button with label More...
 
Buttonsoperator<< (const PixmapFuncDataTransparent pfdt)
 generate a button with a pixmap which is partially transparent More...
 
Buttonsoperator<< (ArrowFuncData af)
 generate an arrow button If the arrow widget is supplied in the ArrowFuncData class, then it will be used instead of generating a new one. See arroFuncData for the various class member variables which are used in this method. More...
 
Buttonsoperator<< (RadioFuncData nf)
 generate a radio button with label If other radio buttons are present, then they are all added to the same group More...
 
Buttonsoperator<< (CheckFuncData nf)
 generate a check button with label More...
 
void setLabelsFont (PangoFontDescription *pangoFontDescription)
 
void setLabel (const char *l)
 
const gchar * getLabel ()
 
int findIndex (GtkWidget *widget)
 
GtkWidget * findWidget (int index)
 
void setActive (bool state)
 
bool getActive (void)
 
int findActiveButtonIndex ()
 

Static Public Member Functions

static gboolean exposePixmap (GtkWidget *widget, GdkEventExpose *event, gpointer data)
 overlay the pixmap image onto the button whenever required This method allows transparent XPMs to be displayed on buttons. Whenever the background is changed, the transparent pixmap is re-drawn More...
 
static void setActive (GtkWidget *wid, bool state)
 
static bool getActive (GtkWidget *wid)
 

Additional Inherited Members

Detailed Description

Class to setup buttons whic are either text, image or toggle types. Buttons are defined in terms of their callbacks functions and data as well as their type (image, text or toggle) You stream in any new buttons you want to create, for example :

Buttons buttons << BUTTONLABELSTRUCT {"display text", callbackFunc, (void *)dataVariable};

This will create a button with the display text, when pressed, the callbackFunc will be called with the dataVariable as a variable. You can add buttons to your window like so :

// create 2 buttons
Buttons buttons << BUTTONLABELSTRUCT {"button1", callbackFunc1, (void *)dataVariable1} << BUTTONLABELSTRUCT {"button2", callbackFunc2, (void *)dataVariable2};
HBox box; // A horizontal box to show the buttons in
for (int i=0;i<buttons.getCount();i++) // add the buttons to the box
box << buttons.next();
box.show(); // make sure the box is not hidden
Examples:
AlignmentTest.C, ButtonsFontTest.C, ButtonsTest.C, ButtonsTest2.C, CairoArrowTest.C, CairoBoxTest.C, CairoCircleTest.C, colourWheelTest.C, ComboBoxTextTest.C, DragNDropNowindowTest.C, DragNDropSimpleTest.C, DragNDropTest.C, DrawingAreaTest.C, InlineTest.C, LabelsTest.C, LabelsTest2.C, LabelsTest3.C, MessageDialogTest.C, NeuralNetworkFnTest.C, PangoTest.C, PangoTest2.C, PixmapTest.C, ProgressBarTest.C, ScaleTest.C, SelectionAreaTest.C, SeparatorTest.C, TableTest.C, TextViewTest.C, and WidgetTest.C.

Definition at line 184 of file Buttons.H.

Constructor & Destructor Documentation

Buttons::Buttons ( void  )
inline

Constructor.

Definition at line 189 of file Buttons.H.

Member Function Documentation

static gboolean Buttons::exposePixmap ( GtkWidget *  widget,
GdkEventExpose *  event,
gpointer  data 
)
inlinestatic

overlay the pixmap image onto the button whenever required This method allows transparent XPMs to be displayed on buttons. Whenever the background is changed, the transparent pixmap is re-drawn

widget The button to re-draw event the event (we are looking for an expose event) data The XPM pointer (char**) to use for display

Returns
false to keep propagating the event

Definition at line 387 of file Buttons.H.

int Buttons::findActiveButtonIndex ( )
inline

Finds the active button. Only works for toggle buttons (toggle, checkbox, etc.).

Returns
the index of the button which is active, or 0 if none active.

Definition at line 531 of file Buttons.H.

int Buttons::findIndex ( GtkWidget *  widget)
inline

Find the GTK widget index (from 1) in the list of buttons

Parameters
widgetThe widget to look for
Returns
0 if it isn't on the list, the index (from 1) otherwise

Definition at line 461 of file Buttons.H.

Here is the caller graph for this function:

GtkWidget* Buttons::findWidget ( int  index)
inline

Get the widget at index (starting from 1)

Parameters
indexthe widget at this index to grab (starting from 1)
Returns
The widget at index, or NULL on error

Definition at line 483 of file Buttons.H.

bool Buttons::getActive ( void  )
inline

Method to get the currently selected button's active state. Only works for toggle buttons (toggle, checkbox, etc.).

Returns
the current state of the button, or false if no buttons exist

Definition at line 512 of file Buttons.H.

Here is the caller graph for this function:

static bool Buttons::getActive ( GtkWidget *  wid)
inlinestatic

Method to get an arbitrary button's active state. Only works for toggle buttons (toggle, checkbox, etc.).

Parameters
widThe toggle button to query for its active state.
Returns
the current state of the button, or false if no buttons exist

Definition at line 523 of file Buttons.H.

void Buttons::getAlignment ( float *  xAlign,
float *  yAlign 
)
inline

Get the alignment within the button. Operates on the GtkWidget* which is LinkList::current - i.e. currently pointed to Fills the pointers to the floats with the alignment settings.

Parameters
xAlignthe x-alignment 0.0 is a left alignment, 1.0 is for right alignment
yAlignthe y-alignment 0.0 is a left alignment, 1.0 is for right alignment

Definition at line 211 of file Buttons.H.

const gchar* Buttons::getLabel ( )
inline

Get the label associated with the button.

Returns
The label, if none, then NULL.

Definition at line 453 of file Buttons.H.

Here is the caller graph for this function:

Buttons& Buttons::operator<< ( LabelFuncData  nf)
inline

generate a label button

Parameters
nfThe label, callback function and data to show.
Returns
This Buttons class for further overloading

Definition at line 264 of file Buttons.H.

Here is the call graph for this function:

Buttons& Buttons::operator<< ( const PixmapFuncData  nf)
inline

generate a button with a static pixmap

Parameters
nfThe pixmap, callback function and data to show.
Returns
This Buttons class for further overloading

Definition at line 280 of file Buttons.H.

Here is the call graph for this function:

Buttons& Buttons::operator<< ( ToggleFuncData  nf)
inline

generate a toggle button with label

Parameters
nfThe label, callback function and data to show.
Returns
This Buttons class for further overloading

Definition at line 294 of file Buttons.H.

Here is the call graph for this function:

Buttons& Buttons::operator<< ( const PixmapFuncDataTransparent  pfdt)
inline

generate a button with a pixmap which is partially transparent

Parameters
pfdtThe pixmap, callback function and data to show.
Returns
This Buttons class for further overloading

Definition at line 318 of file Buttons.H.

Here is the call graph for this function:

Buttons& Buttons::operator<< ( ArrowFuncData  af)
inline

generate an arrow button If the arrow widget is supplied in the ArrowFuncData class, then it will be used instead of generating a new one. See arroFuncData for the various class member variables which are used in this method.

Parameters
afThe callback function, data, arrow type, shadow type and possibly a pre-existing arrow to use/show. If the pre-existing arrow is to be used, then the ArrowFuncData.whichArrow and ArrowFuncData.whichShdow variables are ignored.
Returns
This Buttons class for further overloading

Definition at line 335 of file Buttons.H.

Here is the call graph for this function:

Buttons& Buttons::operator<< ( RadioFuncData  nf)
inline

generate a radio button with label If other radio buttons are present, then they are all added to the same group

Parameters
nfThe label, callback function and data to show.
Returns
This Buttons class for further overloading

Definition at line 352 of file Buttons.H.

Here is the call graph for this function:

Buttons& Buttons::operator<< ( CheckFuncData  nf)
inline

generate a check button with label

Parameters
nfThe label, callback function and data to show.
Returns
This Buttons class for further overloading

Definition at line 367 of file Buttons.H.

Here is the call graph for this function:

static void Buttons::setActive ( GtkWidget *  wid,
bool  state 
)
inlinestatic

Method to set the currently selected button to active. Only works for toggle buttons (toggle, checkbox, etc.).

Parameters
widThe toggle button to query for its active state.
stateThe state of the button

Definition at line 495 of file Buttons.H.

Here is the caller graph for this function:

void Buttons::setActive ( bool  state)
inline

Method to set the currently selected button to active. Only works for toggle buttons (toggle, checkbox, etc.).

Parameters
stateThe state of the button

Definition at line 503 of file Buttons.H.

void Buttons::setAlignment ( float  xAlign,
float  yAlign 
)
inline

Set the alignment within the button. Operates on the GtkWidget* which is LinkList::current - i.e. currently pointed to

Parameters
xAlignthe x-alignment 0.0 is a left alignment, 1.0 is for right alignment
yAlignthe y-alignment 0.0 is a left alignment, 1.0 is for right alignment

Definition at line 200 of file Buttons.H.

void Buttons::setLabel ( const char *  l)
inline

Set the current() button's label.

Parameters
lthe label the set on the button.

Definition at line 446 of file Buttons.H.

void Buttons::setLabelsFont ( PangoFontDescription *  pangoFontDescription)
inline

Set the current botton's label's font For example :

#include "Pango.H"
Font font("bold"); // could be something else, like "Sans 12"
Buttons button<<BUTTONLABELSTRUCT("I want this to be bold", (void (*)(void *, void *))buttonPressed, (void *)this);
button.setLabelsFont(font.getPangoFontDescription());
Examples:
ButtonsFontTest.C.

Definition at line 435 of file Buttons.H.

void Buttons::signalConnectAfter ( LabelFuncData  nf)
inline

Destructor.

connect a callback to execute after the currently connected callbacks

Parameters
nflabelFuncData matching the callback to connect

Definition at line 226 of file Buttons.H.

void Buttons::signalConnectAfter ( const AnyFuncData af)
inline

connect a callback to execute after the currently connected callbacks

Parameters
afanyFuncData matching the callback to connect

Definition at line 234 of file Buttons.H.

void Buttons::signalRemove ( AnyFuncData  nfOld)
inline

disconnect the old callback and reconnect a new callback

Parameters
nfOldAnyFuncData matching the old callback to be removed

Definition at line 254 of file Buttons.H.

void Buttons::signalReplace ( LabelFuncData  nfOld,
LabelFuncData  nfNew 
)
inline

disconnect the old callback and reconnect a new callback

Parameters
nfOldlabelFuncData matching the old callback to be removed
nfNewlabelFuncData matching the new to be connected callback

Definition at line 243 of file Buttons.H.


The documentation for this class was generated from the following file:
gtkIOStream: Buttons Class Reference
GTK+ IOStream  Beta
GTK+ << C++ IOStream operators for GTK+. Now with extra abilities ... like ORBing, numerical computation, audio clients and more...