gtkIOStream  1.7.0
GTK+ << C++ IOStream operators for GTK+. Now with ORBing, numerical computation, audio client and more ...
Labels Class Reference

class to create and handle labels. More...

#include <Labels.H>

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

Public Member Functions

Labelsoperator<< (std::string str)
 
Labelsoperator<< (const char *str)
 
Labelsoperator<< (LabelFuncData nf)
 
GtkWidget * getWidget (void)
 returns the current GtkWidget* in the list More...
 
void pangoMarkup (const char *str)
 Set the pango markup of the currently displayed text. Allows you to set the current text to different pango text styles, specified in str. Specify only the pango styles here. For example, to set the colour to red we require str="foreground='#ffffa5a50000'", Which we can generate like so: More...
 
void pangoMarkup (Pango &p)
 Set the pango markup of the currently displayed text. The Pango class is used to setup the label. More...
 
GtkWidget * setAlignment (float xalign, float yalign)
 
Labelsoperator<< (Pango &p)
 
void setLabelsFont (PangoFontDescription *pangoFontDescription)
 
void setAngle (double angle)
 
void setText (const char *text)
 
const char * getText (void)
 
Labelsoperator= (string text)
 
Labelsoperator= (const char *text)
 

Additional Inherited Members

Detailed Description

class to create and handle labels.

Generally you use istream operators as follows :

Window topWindow; // Create the top box
Labels labels; // create the class
labels<<"label 1"<<"label 2"; // create two labels
VBox vbox; // create a suitable container
vbox<<labels.grab(1); // add "label 1" to the vbox
vbox<<labels.grab(2); // add "label 2" to the vbox
vbox.show(); // show the vbox with the two labels present
topWindow << vBox; // Load the VBox into the top window

You can also do the same thing inline :

Window() << (VBox()<<(Labels()<<"label 1"<<"label 2")).show();

You can have clickable labels like so :

Labels::operator<<(BUTTONLABELSTRUCT((char *)"clickable label", (void (*)(void *, void *))labelCallback, (gpointer)this));
gboolean labelCallback(GtkWidget *widget, GdkEventButton *event, gpointer data){
// handle the label callback here.
}
Examples:
AlignmentTest.C, InlineTest.C, LabelsTest.C, LabelsTest2.C, LabelsTest3.C, PangoTest.C, PangoTest2.C, ProgressBarTest.C, and SeparatorTest.C.

Definition at line 58 of file Labels.H.

Member Function Documentation

◆ getText()

const char* Labels::getText ( void  )
inline

Set the labels text

Parameters
textThe new text for the label

Definition at line 194 of file Labels.H.

Here is the call graph for this function:

◆ getWidget()

GtkWidget* Labels::getWidget ( void  )
inline

returns the current GtkWidget* in the list

Returns
GtkWidget* The current GtkWidget* in the list

Definition at line 102 of file Labels.H.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator<<() [1/4]

Labels& Labels::operator<< ( std::string  str)
inline

Create a label from a string

Parameters
strThe string to show as the label
Returns
A reference to this Labels class for further overloading

Definition at line 65 of file Labels.H.

◆ operator<<() [2/4]

Labels& Labels::operator<< ( const char *  str)
inline

Create a label from a string

Parameters
strThe char * string to show as the label
Returns
A reference to this Labels class for further overloading

Definition at line 73 of file Labels.H.

Here is the call graph for this function:

◆ operator<<() [3/4]

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

Add a label with an event box. This creates a label with a clickable eventBox, which will call a callback.

Parameters
nfThe labelFuncData which specifies the label string, the callback function and the data to pass to the callback function.
Returns
A reference to this Labels class for further overloading

Definition at line 86 of file Labels.H.

Here is the call graph for this function:

◆ operator<<() [4/4]

Labels& Labels::operator<< ( Pango p)
inline

Create a label from a Pango markup class

Parameters
pThe Pango class which contains the formatting
Returns
A reference to this Labels class for further overloading

Definition at line 155 of file Labels.H.

Here is the call graph for this function:

◆ operator=() [1/2]

Labels& Labels::operator= ( string  text)
inline

Set the labels text

Parameters
textThe new text for the label

Definition at line 202 of file Labels.H.

Here is the call graph for this function:

◆ operator=() [2/2]

Labels& Labels::operator= ( const char *  text)
inline

Set the labels text

Parameters
textThe new text for the label

Definition at line 210 of file Labels.H.

Here is the call graph for this function:

◆ pangoMarkup() [1/2]

void Labels::pangoMarkup ( const char *  str)
inline

Set the pango markup of the currently displayed text. Allows you to set the current text to different pango text styles, specified in str. Specify only the pango styles here. For example, to set the colour to red we require str="foreground='#ffffa5a50000'", Which we can generate like so:

ColourLineSpec cls="r"; // specify the desired colour
gchar *gdkCString=gdk_color_to_string(&cls.colour); // generate the equivalent colour specification in a string
string pangoColour("foreground='"); pangoColour=pangoColour+gdkCString+"'"; // create the string "foreground='#ffffa5a50000'"
g_free(gdkCString); // free the created colour string
pangoMarkup(pangoColour.c_str()); // set the text to the correct colour.
Parameters
strCan be a valid pango markup string. See http://developer.gnome.org/pango/stable/PangoMarkupFormat.html

Definition at line 121 of file Labels.H.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pangoMarkup() [2/2]

void Labels::pangoMarkup ( Pango p)
inline

Set the pango markup of the currently displayed text. The Pango class is used to setup the label.

Parameters
pThe pango marked up string to set (see Pango)

Definition at line 134 of file Labels.H.

Here is the call graph for this function:

◆ setAlignment()

GtkWidget* Labels::setAlignment ( float  xalign,
float  yalign 
)
inline

Set the alignment of the label for parents.

Parameters
xalignthe x alignment (0.0 for left, 1.0 for right)
yalignthe y alignment (0.0 for top, 1.0 for bottom)
Returns
the current label which was adjusted, NULL if there are no labels

Definition at line 143 of file Labels.H.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setAngle()

void Labels::setAngle ( double  angle)
inline

Set the label's angle. The angle setting for the label is ignored if the label is selectable, wrapped, or ellipsized.

Parameters
angleAn angle of 90 reads from from bottom to top, an angle of 270, from top to bottom.

Definition at line 178 of file Labels.H.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setLabelsFont()

void Labels::setLabelsFont ( PangoFontDescription *  pangoFontDescription)
inline

Given a PangoFontDescription, set a label's font.

Font font("bold");
Labels lablel<<"Text I want to Bold";
label.setLabelsFont(font.getPangoFontDescription());

Definition at line 169 of file Labels.H.

Here is the call graph for this function:

◆ setText()

void Labels::setText ( const char *  text)
inline

Set the labels text

Parameters
textThe new text for the label

Definition at line 186 of file Labels.H.

Here is the call graph for this function:
Here is the caller graph for this function:

The documentation for this class was generated from the following file:
gtkIOStream: Labels Class Reference
GTK+ IOStream  Beta