gtkIOStream  1.7.0
GTK+ << C++ IOStream operators for GTK+. Now with ORBing, numerical computation, audio client and more ...
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:
[legend]
Collaboration diagram for Selection:
[legend]

Public Member Functions

 Selection (void)
 
 Selection (const char *listName, GCallback callback=NULL, void *data=NULL)
 
virtual ~Selection ()
 
void init (const char *listName, GCallback callback=NULL, void *data=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 getSelection (string &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 string text)
 
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)
 

Private Attributes

gulong changedHandlerID
 The callback handler id for when the selection is changed. More...
 

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);
Examples:
SelectionTest.C, SelectionTest2.C, and SelectionTest3.C.

Definition at line 238 of file Selection.H.

Constructor & Destructor Documentation

◆ Selection() [1/2]

Selection::Selection ( void  )
inline

Simple constructor, giving a Selection class with no columns.

Definition at line 339 of file Selection.H.

◆ Selection() [2/2]

Selection::Selection ( const char *  listName,
GCallback  callback = NULL,
void *  data = 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.

Parameters
listNameThe title for the Selection
callbackthe callback to use when a selection is made
dataUser data to pass to the callback.

Definition at line 349 of file Selection.H.

◆ ~Selection()

virtual Selection::~Selection ( )
inlinevirtual

Definition at line 353 of file Selection.H.

Member Function Documentation

◆ add() [1/3]

void Selection::add ( SelectionColumn newCol)
inline

add a new column to the Selection

Examples:
SelectionTest2.C, and SelectionTest3.C.

Definition at line 413 of file Selection.H.

Here is the call graph for this function:

◆ add() [2/3]

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 513 of file Selection.H.

◆ add() [3/3]

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 532 of file Selection.H.

◆ appendNewIter()

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
storeThe GtkTreeStore to append a row to
sameRowtry to return the last row as the iter if true, otherwise, create a new row and append
sameColumndon't increment the column, use the same column

Definition at line 302 of file Selection.H.

◆ appendRow()

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 284 of file Selection.H.

◆ clear()

void Selection::clear ( void  )
inline

Clear all the contents of the selection

Definition at line 545 of file Selection.H.

◆ currentColumnNumber()

int Selection::currentColumnNumber ( void  )
inlineprotected

Find which column is current

Returns
The column number matching current(), -1 on failure

Definition at line 322 of file Selection.H.

◆ getLastIter()

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 269 of file Selection.H.

◆ getSelection() [1/2]

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.
Examples:
SelectionTest.C, SelectionTest2.C, and SelectionTest3.C.

Definition at line 478 of file Selection.H.

◆ getSelection() [2/2]

void Selection::getSelection ( string &  value)
inline

Get the selected text from the current() column

Parameters
valueThe character array to hold the selected text.

Definition at line 487 of file Selection.H.

◆ getWidget()

GtkWidget* Selection::getWidget ( void  )
inline

Gets the widget for loading into containers

Examples:
SelectionTest.C, SelectionTest2.C, and SelectionTest3.C.

Definition at line 459 of file Selection.H.

Here is the caller graph for this function:

◆ hide()

void Selection::hide ( void  )
inline

A method to hide the Selection widget

Definition at line 471 of file Selection.H.

◆ init() [1/2]

void Selection::init ( void  )
inlineprivate

Initialise this class - common to all constructors.

Definition at line 244 of file Selection.H.

◆ init() [2/2]

void Selection::init ( const char *  listName,
GCallback  callback = NULL,
void *  data = NULL 
)
inline

Initialise a new Selection GUI. Adds a new column and the related callback

Parameters
listNameThe title for the Selection
callbackthe callback to use when a selection is made (if callback==NULL then it is not connected)
datathe user data to pass to the selection callback static method.

Definition at line 363 of file Selection.H.

◆ operator<<() [1/4]

Selection& Selection::operator<< ( const string  text)
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 604 of file Selection.H.

◆ operator<<() [2/4]

Selection& Selection::operator<< ( const char *  text)
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 615 of file Selection.H.

◆ operator<<() [3/4]

Selection& Selection::operator<< ( GdkPixbuf *  pixbuf)
inline

add a GdkPixbuf 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 text item to add
Returns
This Selection object

Definition at line 626 of file Selection.H.

◆ operator<<() [4/4]

Selection& Selection::operator<< ( SelectionColumn newCol)
inline

add a new column to the Selection.

Parameters
newColthe SelectionColumn to add
Returns
This Selection object

Definition at line 645 of file Selection.H.

◆ selectRow()

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 659 of file Selection.H.

◆ setCallbackAfter()

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 453 of file Selection.H.

◆ setSelectionCallback() [1/2]

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
Examples:
SelectionTest2.C, and SelectionTest3.C.

Definition at line 383 of file Selection.H.

◆ setSelectionCallback() [2/2]

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 392 of file Selection.H.

◆ setTreeCallback()

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", reinterpret_cast<GCallback>(treeCallBack), (void*)this);
Parameters
eventThe event to connect to.
callbackThe callback to execute when the button is released (after clicking the tree)
dataThe user data to pass to the callback on execution.

Definition at line 407 of file Selection.H.

◆ show()

void Selection::show ( void  )
inline

A method to show the Selection widget

Examples:
SelectionTest.C, SelectionTest2.C, and SelectionTest3.C.

Definition at line 465 of file Selection.H.

Member Data Documentation

◆ changedHandlerID

gulong Selection::changedHandlerID
private

The callback handler id for when the selection is changed.

Definition at line 240 of file Selection.H.

◆ selection

GtkTreeSelection* Selection::selection
protected

The tree selection box.

Definition at line 317 of file Selection.H.

◆ tree

GtkWidget* Selection::tree
protected

The tree of items for the selection widget.

Definition at line 316 of file Selection.H.


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