GTK+ IOStream  Beta
<< GTK+ >> add C++ IOStream operators to GTK+. Now with extra abilities ... like network serialisation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | List of all members
Selection Class Reference

Selection GtkTreeView based widget Inherits from a LinkList of GtkTreeViewColumn* which allows modification of the columns. More...

#include <Selection.H>

Inheritance diagram for Selection:
Inheritance graph
[legend]
Collaboration diagram for Selection:
Collaboration graph
[legend]

Public Member Functions

 Selection (void)
 
 Selection (const char *listName, GCallback callback=NULL)
 
void setSelectionCallback (GCallback callback)
 
void setSelectionCallback (const char *event, GCallback callback, gpointer data)
 
void setTreeCallback (const char *event, GCallback callback, gpointer data)
 
void add (SelectionColumn *newCol)
 
void setCallbackAfter (GCallback callback, void *data)
 change the callback data to be returned with the callback. More...
 
GtkWidget * getWidget (void)
 
void show (void)
 
void hide (void)
 
void getSelection (char *value)
 
void add (const char *text, gboolean sameRow=false, gboolean sameColumn=true)
 
void add (GdkPixbuf *pixbuf, gboolean sameRow=false, gboolean sameColumn=true)
 
void clear (void)
 
Selectionoperator<< (const char *text)
 
Selectionoperator<< (GdkPixbuf *pixbuf)
 
Selectionoperator<< (SelectionColumn *newCol)
 
void selectRow (char *path)
 

Protected Member Functions

int currentColumnNumber (void)
 

Protected Attributes

GtkWidget * tree
 The tree of items for the selection widget. More...
 
GtkTreeSelection * selection
 The tree selection box. More...
 

Private Member Functions

void init (void)
 
GtkTreeIter * getLastIter (GtkTreeStore *store=NULL)
 
GtkTreeIter * appendRow (GtkTreeStore *store=NULL)
 
GtkTreeIter * appendNewIter (GtkTreeStore *store, gboolean sameRow, gboolean sameColumn)
 

Additional Inherited Members

Detailed Description

Selection GtkTreeView based widget Inherits from a LinkList of GtkTreeViewColumn* which allows modification of the columns.

In its simplest form, you can easily generate a text selection like so :

SelectionTest.jpg
Selection selection("test list items",G_CALLBACK(selectionCallback));
selection<<"test"<<"this"<<"one"; // display each string on their own row.

In a more complex form, you can have many columns, in this case text and a pixbuf :

SelectionTest2.jpg
Selection selection("test list items"); // construct a Selection class
SelectionColumn *sc= new SelectionColumn("text column", 1); // create the columns class with a new column which handles text
*sc<<pair<string*, GtkCellRendererPixbuf*>(new string("pixbuf"), GTK_CELL_RENDERER_PIXBUF(gtk_cell_renderer_pixbuf_new())); // create a second column which handles pixbufs
selection<<sc; // setup the Selection with the columns
GdkPixbuf *testPixBuf = gdk_pixbuf_new_from_xpm_data(static_cast<const char**>(playXPM)); // get the pixbuf
selection.grab(1); // get the first column
selection<<"test col 1"; // add some text to the column
selection.grab(2); // get the second column - the pixbuf column
selection<<testPixBuf; // add the pix buf to the column
// add a third row with both text and a pixbuf
selection.grab(1); // get the text column
selection<<"test row 2";
selection.grab(2); // get the second pixbuf
selection.add(testPixBuf, true); // add to the same row
// or add the pixbuf first and then the text
selection.grab(2); // get the second column - the pixbuf column
selection.add(testPixBuf); // add to the same row
selection.grab(1); // get the second column - the pixbuf column
selection.add("test row 3", true);

Definition at line 233 of file Selection.H.

Constructor & Destructor Documentation

Selection::Selection ( void  )
inline

Simple constructor, giving a Selection class with no columns.

Definition at line 326 of file Selection.H.

Selection::Selection ( const char *  listName,
GCallback  callback = NULL 
)
inline
Construct a Selection widget with one column and assigns a callback

When this constructor is used, one text column is added. This automates everything for you if you only want a simple text column selection.

Definition at line 333 of file Selection.H.

Here is the call graph for this function:

Member Function Documentation

void Selection::add ( SelectionColumn newCol)
inline

add a new column to the Selection

Definition at line 379 of file Selection.H.

Here is the call graph for this function:

Here is the caller graph for this function:

void Selection::add ( const char *  text,
gboolean  sameRow = false,
gboolean  sameColumn = true 
)
inline
add a text item to the selection column

if you want to add to a different column, shift the inherited LinkList<SelectionColumn *> to the correct one. For example use one of these to locate the desired column prior to adding : LinkList<SelectionColumn *>::grab, LinkList<SelectionColumn *>::next, LinkList<SelectionColumn *>::prev

Parameters
textthe text item to add to the list
sameRowUse the same row. Defaults to false, append a new row
sameColumnUse the same column, defaults to true
Returns
This Selection object

Definition at line 466 of file Selection.H.

void Selection::add ( GdkPixbuf *  pixbuf,
gboolean  sameRow = false,
gboolean  sameColumn = true 
)
inline
add a pixbuf item to the selection column

if you want to add to a different column, shift the inherited LinkList<SelectionColumn *> to the correct one. For example use one of these to locate the desired column prior to adding : LinkList<SelectionColumn *>::grab, LinkList<SelectionColumn *>::next, LinkList<SelectionColumn *>::prev

Parameters
pixbufthe GdkPixbuf item to add to the list
sameRowUse the same row. Defaults to false, append a new row
sameColumnUse the same column, defaults to true
Returns
This Selection object

Definition at line 485 of file Selection.H.

GtkTreeIter* Selection::appendNewIter ( GtkTreeStore *  store,
gboolean  sameRow,
gboolean  sameColumn 
)
inlineprivate
Get a GtkTreeIter

If the sameRow is requested, try to get it, if no rows, then create a new row and append as last.

Parameters
sameRow,tryto return the last row as the iter if true, otherwise, create a new row and append
sameColumn,don'tincrement the column, use the same column

Definition at line 293 of file Selection.H.

GtkTreeIter* Selection::appendRow ( GtkTreeStore *  store = NULL)
inlineprivate
append a row to a given store

The returned row must be deleted

Parameters
storeThe GtkTreeStore to append a row to, can be null to use the store associated with the tree
Returns
GtkTreeIter* to the created row, NULL on failure

Definition at line 276 of file Selection.H.

void Selection::clear ( void  )
inline

Clear all the contents of the selection

Definition at line 498 of file Selection.H.

int Selection::currentColumnNumber ( void  )
inlineprotected
Find which column is current
Returns
The column number matching current()

Definition at line 313 of file Selection.H.

GtkTreeIter* Selection::getLastIter ( GtkTreeStore *  store = NULL)
inlineprivate
Get the last root row of the tree store
Parameters
storeThe GtkTreeStore to append a row to, can be null to use the store associated with the tree
Returns
GtkTreeIter* to the last row, NULL on failure/if there isn't a row

Definition at line 261 of file Selection.H.

void Selection::getSelection ( char *  value)
inline
Get the selected text from the current() column
Parameters
valueThe character array to hold the selected text. NOTE: Ensure the length of the char * passed in is large enough to contain the selected text.

Definition at line 442 of file Selection.H.

Here is the caller graph for this function:

GtkWidget* Selection::getWidget ( void  )
inline

Gets the widget for loading into containers

Definition at line 423 of file Selection.H.

Here is the caller graph for this function:

void Selection::hide ( void  )
inline

A method to hide the Selection widget

Definition at line 435 of file Selection.H.

void Selection::init ( void  )
inlineprivate

Initialise this class - common to all constructors.

Definition at line 237 of file Selection.H.

Selection& Selection::operator<< ( const char *  text)
inline
      add a pixbuf item to the selection column

if you want to add to a different column, shift the inherited LinkList<SelectionColumn *> to the correct one. For example use one of these to locate the desired column prior to adding : LinkList<SelectionColumn *>::grab, LinkList<SelectionColumn *>::next, LinkList<SelectionColumn *>::prev

Parameters
firstColumn,whichcolumn to start with, 1 for the first column
Returns
This Selection object add a list of items to the same row in each column - starting from the first column
Parameters
llthe LinkList of items to add to the list on the current row
Returns
This Selection object add a text item to the Selection column if you want to add to a different column, shift the inherited LinkList<SelectionColumn *> to the correct one. For example use one of these to locate the desired column prior to adding : LinkList<SelectionColumn *>::grab, LinkList<SelectionColumn *>::next, LinkList<SelectionColumn *>::prev
Parameters
textthe text item to add
Returns
This Selection object

Definition at line 552 of file Selection.H.

Selection& Selection::operator<< ( GdkPixbuf *  pixbuf)
inline
add a text item to the Selection column

if you want to add to a different column, shift the inherited LinkList<SelectionColumn *> to the correct one. For example use one of these to locate the desired column prior to adding : LinkList<SelectionColumn *>::grab, LinkList<SelectionColumn *>::next, LinkList<SelectionColumn *>::prev

Parameters
textthe text item to add
Returns
This Selection object

Definition at line 563 of file Selection.H.

Selection& Selection::operator<< ( SelectionColumn newCol)
inline
      add a row with multiple items

starts from row 0

Parameters
llthe LinkList of items to add
Returns
This Selection object add a new column to the Selection
Parameters
textthe text item to add
Returns
This Selection object

Definition at line 582 of file Selection.H.

void Selection::selectRow ( char *  path)
inline
Activates a row for the current LinkList selected column

For example :

selection.grab(2); // get the second column
selection.activateRow("0"); // activate the first row
selection.activateRow("1:1"); // activate the second row, second node of the tree
Parameters
patha GtkTreePath string, such as "A" for a root node number A or "A:B:C" root node A, sub-node B, sub-node C.

Definition at line 596 of file Selection.H.

void Selection::setCallbackAfter ( GCallback  callback,
void *  data 
)
inline

change the callback data to be returned with the callback.

Parameters
callbackthe callback function to be called upon selection change
datathe data to be returned with the selection changed callback.

Definition at line 417 of file Selection.H.

void Selection::setSelectionCallback ( GCallback  callback)
inline
Calls the callback when the "changed" event is called on the selection.
Parameters
callbackThe callback to call when a "changed" event is caught

Definition at line 350 of file Selection.H.

Here is the caller graph for this function:

void Selection::setSelectionCallback ( const char *  event,
GCallback  callback,
gpointer  data 
)
inline
Setup a new selection callback
Parameters
eventThe event to connect to
callbackThe callback to call when the event is encountered
dataThe user data to pass to the callback

Definition at line 360 of file Selection.H.

void Selection::setTreeCallback ( const char *  event,
GCallback  callback,
gpointer  data 
)
inline
Sets the tree to call the callback when the button is released.

This is good for generic event and table related event handling. For example your class could use the following :

Selection list;
list.setTreeCallback("button-release-event", GTK_SIGNAL_FUNC(treeCallBack), (void*)this);
Parameters
callbackThe callback to execute when the button is released (after clicking the tree)

Definition at line 373 of file Selection.H.

void Selection::show ( void  )
inline

A method to show the Selection widget

Definition at line 429 of file Selection.H.

Here is the caller graph for this function:

Member Data Documentation

GtkTreeSelection* Selection::selection
protected

The tree selection box.

Definition at line 308 of file Selection.H.

GtkWidget* Selection::tree
protected

The tree of items for the selection widget.

Definition at line 307 of file Selection.H.


The documentation for this class was generated from the following file: