sptk2 logo
SPTK Home Page

sptk::CBaseListBox Class Reference
[GUI Classes]

Base list box widget. More...

#include <CComboBox.h>

Inheritance diagram for sptk::CBaseListBox:

sptk::CControl sptk::CLayoutClient sptk::CComboBox sptk::CListBox sptk::CFontComboBox

List of all members.

Public Member Functions

virtual void clear ()
 Clears the list view inside.
uint32_t buttons ()
 Returns the bitmask of visible buttons' IDs.
void buttons (uint32_t)
 Sets the bitmask for visible buttons' IDs.
Fl_Callback_p buttonClicked () const
 Returns buttons' callback function.
void buttonClicked (Fl_Callback *c)
 Sets buttons' callback function.
void columns (const CColumnList &columnList)
CColumnListcolumns ()
void addColumn (std::string cname, CVariantType type=VAR_STRING, int16_t cwidth=70, bool cvisible=true)
void addRow (CPackedStrings *row)
void addRow (const CStrings &rowStrings, int rowId=0)
void addRow (int rowId, const char *s1, const char *s2=NULL, const char *s3=NULL, const char *s4=NULL, const char *s5=NULL)
void addRows (std::string columnName, CStrings rows)
virtual void resize (int x, int y, int w, int h)
virtual CVariant data () const
 Universal data connection. Operates with selected list view item's ID.
virtual void data (const CVariant v)
 Universal data connection. Operates with selected list view item's ID.
void dataMode (CListViewDataMode dm)
CListViewDataMode dataMode ()
CPackedStringsfindCaption (std::string caption)
CPackedStringsfindKey (int keyValue)
CDatabaseDriverdatabase () const
 Returns database connection pointer.
void database (CDatabaseDriver *db)
 Defines database connection.
std::string sql () const
 Returns SQL query text.
void sql (std::string s)
std::string keyField () const
 Returns SQL query field name that contains unique row IDS, preferrably - integers.
void keyField (std::string keyFieldName)
int sortColumn () const
 Returns sortColumn.
void sort ()
 Sorts the list.
void sortColumn (int sortColumn)
void setup (CDatabaseDriver *db, std::string sql, std::string keyField)
CParamparam (const char *paramName)
void refreshData ()
int findString (std::string str, bool select=true, uint32_t startRow=0, unsigned endRow=0)
CPackedStringsselectedRow () const
 Returns the currently selected row, or reference to NULL if not selected.
void selectRow (unsigned rowNumber)
void showHeaders ()
 Shows column headers in the list.
void hideHeaders ()
 Hides column headers in the list.
unsigned size () const
 Returns the number of rows in list view.
virtual bool preferredSize (int &w, int &h)

Protected Member Functions

virtual void dropDownList ()
 Drops down the window with the List View. CComboBox only.
void load (CQuery *)
 Loads data from the Query.
void save (CQuery *)
 Saves data to the Query.
virtual void load (const CXmlNode *node, CLayoutXMLmode xmlMode)
 Loads control data from XML.
virtual void save (CXmlNode *node, CLayoutXMLmode xmlMode) const
 Saves control data to XML.
bool valid () const
 Returns true, if the data is valid.
 CBaseListBox (const char *label, int layoutSize, CLayoutAlign layoutAlign, int mode)
 ~CBaseListBox ()
 Destructor.
virtual void button_handle (uint32_t buttonKind)
 Internal buttons callback function.

Protected Attributes

int m_mode
 Control mode - CListBox or CComboBox.
CDBDropDownListm_dropDownWindow
 Drop down window - CComboBox only.
CDBListViewm_list
 Internal CDBListView widget.
int m_buttonSpace
 The width of space taken by buttons.

Friends

class CInternalComboBoxPanel


Detailed Description

Base list box widget.

A base class for CListBox and CComboBox. Implements most of the common methods for these two classes.


Constructor & Destructor Documentation

sptk::CBaseListBox::CBaseListBox ( const char *  label,
int  layoutSize,
CLayoutAlign  layoutAlign,
int  mode 
) [protected]

Constructor in SPTK style

Parameters:
label const char *, label
layoutSize int, widget align in layout
layoutAlign CLayoutAlign, widget align in layout
mode int, IS_COMBO_BOX or IS_LIST_BOX - internal


Member Function Documentation

void sptk::CBaseListBox::addColumn ( std::string  cname,
CVariantType  type = VAR_STRING,
int16_t  cwidth = 70,
bool  cvisible = true 
)

Adds a new column to the internal list view.

Parameters:
cname std::string, column name
type CVariantType, column data type
cwidth int16_t, column width
cvisible bool, is the column visible?

void sptk::CBaseListBox::addRow ( int  rowId,
const char *  s1,
const char *  s2 = NULL,
const char *  s3 = NULL,
const char *  s4 = NULL,
const char *  s5 = NULL 
)

Adds new row to the internal list view.

Parameters:
rowId int, row argument (key value)
s1 const char *, text data for the column 1
s2 const char *, text data for the column 2
s3 const char *, text data for the column 3
s4 const char *, text data for the column 4
s5 const char *, text data for the column 5

void sptk::CBaseListBox::addRow ( const CStrings rowStrings,
int  rowId = 0 
)

Adds a new row to the internal list view. Makes a copy of data in rowStrings. The row ID may be defined inside CStrings object, or with rowID parameter.

Parameters:
rowStrings const CStrings&, new row
rowId int, optional row ID

void sptk::CBaseListBox::addRow ( CPackedStrings row  ) 

Adds a new row to the internal list view. Doesn't make a copy - just inserts the pointer. The row will be destroyed in CCombo destructor. The row ID may be defined inside CPackedStrings object.

Parameters:
row CPackedStrings *, new row

void sptk::CBaseListBox::addRows ( std::string  columnName,
CStrings  rows 
)

Creates the column as columnName and adds rows to the internal list view. If the column with such name already exists, it will be used. The method is good the a very simple cases of one-column combo boxes. The row IDs may be defined inside CStrings object strings.

Parameters:
columnName std::string, new columnName
rows CStrings, new rows

CColumnList& sptk::CBaseListBox::columns (  ) 

Returns current column list of the internal list view.

Returns:
the column list reference

void sptk::CBaseListBox::columns ( const CColumnList columnList  ) 

Sets the internal list view columns from the column list. The old column list is destroyed and replaced with a copy of columnList.

Parameters:
columnList CColumnList&, new column list

CListViewDataMode sptk::CBaseListBox::dataMode (  )  [inline]

Returns data mode as LVDM_KEY, LVDM_INDEX, or LVDM_TEXT.

See also:
CListViewDataMode for more information

void sptk::CBaseListBox::dataMode ( CListViewDataMode  dm  )  [inline]

Sets data mode for the data() methods. Defines which information list view are working with in data() method - key value, item index, or item caption.

See also:
CListViewDataMode for more information

CPackedStrings* sptk::CBaseListBox::findCaption ( std::string  caption  )  [inline]

Finds an item with the caption (a string in the first column).

Parameters:
caption std::string, the caption to find and select.
Returns:
an item, or NULL if item caption is not found

CPackedStrings* sptk::CBaseListBox::findKey ( int  keyValue  )  [inline]

Finds an item with the key (an integer associated with the item - argument()).

Parameters:
keyValue int, the caption to find and select.
Returns:
an item, or NULL if item caption is not found

int sptk::CBaseListBox::findString ( std::string  str,
bool  select = true,
uint32_t  startRow = 0,
unsigned  endRow = 0 
)

Finds a string in the sort column of list view defined with sortColumn()

Parameters:
str std::string, string to find
select bool, true if we want to select the found row
startRow uint32_t, the row number to start
endRow uint32_t, the row number to finish
Returns:
the row number, or -1 if not found

void sptk::CBaseListBox::keyField ( std::string  keyFieldName  ) 

Sets SQL query field name that contains unique row IDS, preferrably - integers.

Parameters:
keyFieldName std::string, a name of the key field

virtual void sptk::CBaseListBox::load ( const CXmlNode node,
CLayoutXMLmode  xmlMode 
) [protected, virtual]

Loads control data from XML.

Layout information may also include widget size and position, as well as visible() and active() states

Parameters:
node CXmlNode*, the XML node
xmlMode CLayoutXMLmode, the mode defining how the layout and/or data should be stored

Reimplemented from sptk::CControl.

CParam& sptk::CBaseListBox::param ( const char *  paramName  ) 

Returns the SQL query parameter reference for the parameter name. It is typical to call: myCombo.param("customer_id") = 1234;

Parameters:
paramName const char *, parameter name.
Returns:
the parameter reference, if found, or throws an excception.

virtual bool sptk::CBaseListBox::preferredSize ( int &  w,
int &  h 
) [virtual]

Computes the optimal widgets size

Parameters:
w int&, input - width offered by the program, output - width required by widget
h int&, input - height offered by the program, output - height required by widget
Returns:
true if the size is stable (doesn't depend on input sizes)

Reimplemented from sptk::CLayoutClient.

void sptk::CBaseListBox::refreshData (  ) 

Reloads data from the database if database connection is defined. Throws an exception if any error.

virtual void sptk::CBaseListBox::resize ( int  x,
int  y,
int  w,
int  h 
) [virtual]

Resizes the control and inside widgets.

Parameters:
x int, x-position
y int, y-position
w int, width
h int, height

Reimplemented from sptk::CControl.

virtual void sptk::CBaseListBox::save ( CXmlNode node,
CLayoutXMLmode  xmlMode 
) const [protected, virtual]

Saves control data to XML.

Layout information may also include widget size and position, as well as visible() and active() states

Parameters:
node CXmlNode*, the XML node
xmlMode CLayoutXMLmode, the mode defining how the layout and/or data should be stored

Reimplemented from sptk::CControl.

void sptk::CBaseListBox::selectRow ( unsigned  rowNumber  ) 

Selects a row

Parameters:
rowNumber unsigned, row number

void sptk::CBaseListBox::setup ( CDatabaseDriver db,
std::string  sql,
std::string  keyField 
)

The fast way to define a database connection.

Parameters:
db CDatabaseDriver *, a pointer to the database
sql std::string, a SQL query text
keyField std::string, a name of the query field with unique row IDs

void sptk::CBaseListBox::sortColumn ( int  sortColumn  ) 

Defines sortColumn.

Parameters:
sortColumn int, sort column number. -1 means don't sort.

void sptk::CBaseListBox::sql ( std::string  s  ) 

Defines SQL query text

Parameters:
s std::string, SQL text


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

Mon Mar 5 11:56:10 2012: SPTK 3.5.7