sptk2 logo
SPTK Home Page
Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Friends | List of all members
sptk::CControl Class Referenceabstract

Base class for most of SPTK widgets. More...

#include <CControl.h>

Inheritance diagram for sptk::CControl:
sptk::CLayoutClient sptk::CBaseListBox sptk::CButtonGroup sptk::CInput sptk::CListView sptk::CTreeView sptk::CComboBox sptk::CListBox sptk::CRadioButtons sptk::CBox sptk::CDateIntervalInput sptk::CDateTimeBaseInput sptk::CFloatInput sptk::CHtmlBox sptk::CIntegerInput sptk::CMemoInput sptk::CPasswordInput sptk::CPhoneNumberInput sptk::CProgressBar sptk::CDBListView

Public Member Functions

 CControl (const char *label, int layoutSize=20, CLayoutAlign layoutAlign=CLayoutAlign::TOP)
 Constructor in SPTK style. More...
 
void resize (int x, int y, int w, int h) override
 Resizes the control and inside widgets. More...
 
void draw () override
 Draws the control.
 
virtual int tag () const
 Returns the control's user data tag.
 
virtual void tag (int t)
 Sets the control's user data tag.
 
virtual Fl_Font textFont () const
 Returns the control's text font. More...
 
virtual void textFont (Fl_Font)
 Sets the control's text font. More...
 
virtual uchar textSize () const
 Returns the control's text font size. More...
 
virtual void textSize (uchar)
 Sets the control's text font size. More...
 
virtual Fl_Color textColor () const
 Returns the control's text color. More...
 
virtual void textColor (Fl_Color)
 Sets the control's text color. More...
 
virtual Fl_Color labelColor () const
 Returns the control's label color.
 
virtual void labelColor (Fl_Color)
 Sets the control's label color.
 
virtual Fl_Color color () const
 Returns the control's background color.
 
virtual void color (Fl_Color)
 Sets the control's background color.
 
uint32_t flags () const
 Returns the control's flags.
 
void flags (uint32_t flags)
 Sets the control's flags.
 
Fl_Widget * control () const
 Returns main widget inside the container.
 
const Stringlabel () const override
 Returns control's label. More...
 
void label (const String &) override
 Sets control's label. More...
 
Fl_Menu_ * menu () const
 Returns control's menu.
 
void menu (const Fl_Menu_Item *)
 Sets control's menu.
 
Fl_Font labelFont () const
 Returns control's label font.
 
void labelSize (Fl_Font f)
 Sets control's label font.
 
uchar labelSize () const
 Returns control's label font size.
 
void labelSize (uchar)
 Sets control's label font size.
 
uint32_t labelWidth () const
 Returns control's label width.
 
void labelWidth (uint32_t)
 Sets control's label width.
 
void hint (const String &str)
 Sets control's hint (tooltip) More...
 
String hint () const
 Returns control's hint (tooltip)
 
virtual int maxLength () const
 Returns control's max input length, if applicable. More...
 
virtual void maxLength (int)
 Sets control's max input length, if applicable. More...
 
virtual const StringfieldName () const
 Returns control's field name for universal data connection.
 
virtual void fieldName (const String &)
 Sets control's field name for universal data connection.
 
virtual CControlKind kind () const =0
 Returns control's kind (internal SPTK RTTI). More...
 
String className () const override
 Returns control's class name (internal SPTK RTTI). More...
 
virtual void reset ()
 Sets the control to empty text (for the input entries) More...
 
virtual void load (Query *)
 Loads control data from query fields. More...
 
virtual void save (Query *)
 Saves control data to query params. More...
 
void load (const xdoc::SNode &node, CLayoutXMLmode xmlMode) override
 Loads control data from XML. More...
 
void load (const xdoc::SNode &node) override
 Loads control data from XML. More...
 
void save (const xdoc::SNode &node, CLayoutXMLmode xmlMode) const override
 Saves control data to XML. More...
 
virtual void save (const xdoc::SNode &node) const
 Saves control data to XML. More...
 
virtual bool valid () const =0
 Returns true if the control state is valid, and the data is inside the limits (if applicable) More...
 
virtual Variant data () const
 The universal data connector. More...
 
virtual void data (const Variant &v)
 The universal data connector, sets control data. More...
 
void fireEvent (CEvent ev, int32_t arg)
 Fires the event generated by this control.
 
const CEventInfoevent () const
 Returns the last event fired by this control.
 
CEvent eventType () const
 Returns the event type for the last fired by this control.
 
int eventArgument () const
 Returns the event argument for the last fired by this control.
 
CControloperator= (const String &str)
 Control data assignment.
 
CControloperator= (const char *str)
 Control data assignment.
 
CControloperator= (int32_t v)
 Control data assignment.
 
CControloperator= (uint32_t v)
 Control data assignment.
 
CControloperator= (int64_t v)
 Control data assignment.
 
CControloperator= (float v)
 Control data assignment.
 
CControloperator= (double v)
 Control data assignment.
 
CControloperator= (const DateTime &dt)
 Control data assignment.
 
CControloperator= (const Field &fld)
 Control data assignment.
 
 operator String () const
 Control data conversion.
 
 operator int32_t () const
 Control data conversion.
 
 operator uint32_t () const
 Control data conversion.
 
 operator int64_t () const
 Control data conversion.
 
 operator uint64_t () const
 Control data conversion.
 
 operator float () const
 Control data conversion.
 
 operator double () const
 Control data conversion.
 
 operator DateTime () const
 Control data conversion.
 
- Public Member Functions inherited from sptk::CLayoutClient
 CLayoutClient (Fl_Widget *widget, int layoutSize, CLayoutAlign ca)
 
virtual ~CLayoutClient ()
 
CLayoutAlign layoutAlign () const
 
void layoutAlign (CLayoutAlign al)
 
int layoutSize () const
 
void layoutSize (int ls)
 
virtual void label (const String &l)
 
virtual const Stringlabel () const
 
void name (const char *aname)
 
void name (const String &aname)
 
const Stringname () const
 
virtual bool preferredSize (int &w, int &h)
 
virtual bool computeSize (int &w, int &h)
 
virtual String className () const
 
Fl_Widget * widget () const
 
virtual void load (const xdoc::SNode &node, CLayoutXMLmode xmlMode)
 
virtual void load (const std::shared_ptr< xdoc::Node > &node)
 
virtual void save (const std::shared_ptr< xdoc::Node > &node, CLayoutXMLmode xmlMode) const
 

Static Public Member Functions

static CControlKind controlNameToType (const String &typeName, int &maxLength, const String &values="")
 Converts control name to control kind.
 
static void defaultControlMenuCopy (Fl_Widget *, void *)
 Default callback function to support CControl default menu item 'Copy'.
 
static void defaultControlMenuCut (Fl_Widget *, void *)
 Default callback function to support CControl default menu item 'Delete'.
 
static void defaultControlMenuPaste (Fl_Widget *, void *)
 Default callback function to support CControl default menu item 'Paste'.
 
static void defaultControlMenuClear (Fl_Widget *, void *)
 Default callback function to support CControl default menu item 'Clear'.
 

Static Public Attributes

static const Fl_Menu_Item defaultControlMenu []
 CControl default menu.
 

Protected Member Functions

bool containsFocus () const
 Does the control contain focus?
 
void notifyFocus (bool gotFocus=true)
 Internal focus notification on focus change.
 
virtual void onEnter ()
 Internal focus notification on focus change.
 
virtual void onExit ()
 Internal focus notification on focus change. More...
 
uint32_t labelHeight () const
 Computes the label height based on the labelFont() and labelWidth()
 
int handle (int) override
 Special handle() method.
 
- Protected Member Functions inherited from sptk::CLayoutClient
int lastPreferredH () const
 
int lastPreferredW () const
 
void lastPreferredH (int height)
 
void lastPreferredW (int width)
 

Static Protected Member Functions

static void internalCallback (Fl_Widget *internalWidget, void *data)
 Internal callback function.
 

Protected Attributes

bool m_limited {false}
 
uint32_t m_labelWidth {0}
 
Fl_Color m_labelColor
 
Fl_Color m_textColor
 
Fl_Font m_textFont
 
uchar m_textSize {0}
 
String m_fieldName
 
String m_hint
 
Fl_Widget * m_control {nullptr}
 
int m_tag {0}
 
uint32_t m_controlFlags {0}
 Control's special flags (a bit combination of InputEntryFlags). More...
 
Fl_Menu_Button * m_menuButton {nullptr}
 
CEventInfo m_event
 
bool m_hasFocus {false}
 
- Protected Attributes inherited from sptk::CLayoutClient
Fl_Widget * m_widget
 
String m_name
 
String m_label
 
CLayoutAlign m_layoutAlign
 

Friends

class CInternalComboBoxPanel
 
class CEditor
 
class CBaseButton
 
class CRadioButton
 
class CCheckButton
 
class CInput_
 

Detailed Description

Base class for most of SPTK widgets.

It is a group used as a container for the widget(s) inside. Every CControl has a field name, and it can be a layout client.

Constructor & Destructor Documentation

◆ CControl()

sptk::CControl::CControl ( const char *  label,
int  layoutSize = 20,
CLayoutAlign  layoutAlign = CLayoutAlign::TOP 
)
explicit

Constructor in SPTK style.

Parameters
labelconst char *, label
layoutSizeint, widget align in layout
layoutAlignCLayoutAlign, widget align in layout

Member Function Documentation

◆ className()

String sptk::CControl::className ( ) const
inlineoverridevirtual

◆ data() [1/2]

virtual Variant sptk::CControl::data ( ) const
inlinevirtual

◆ data() [2/2]

virtual void sptk::CControl::data ( const Variant v)
inlinevirtual

◆ hint()

void sptk::CControl::hint ( const String str)
inline

Sets control's hint (tooltip)

Parameters
strTooltip text

◆ kind()

virtual CControlKind sptk::CControl::kind ( ) const
pure virtual

◆ label() [1/2]

const String & sptk::CControl::label ( ) const
inlineoverridevirtual

Returns control's label.

Reimplemented from sptk::CLayoutClient.

◆ label() [2/2]

void sptk::CControl::label ( const String )
overridevirtual

Sets control's label.

Reimplemented from sptk::CLayoutClient.

◆ load() [1/3]

void sptk::CControl::load ( const xdoc::SNode &  node)
inlineoverride

Loads control data from XML.

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

Parameters
nodethe XML node

References DATA.

◆ load() [2/3]

void sptk::CControl::load ( const xdoc::SNode &  node,
CLayoutXMLmode  xmlMode 
)
overridevirtual

Loads control data from XML.

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

Parameters
nodethe XML node
xmlModethe mode defining how the layout and/or data should be stored

Reimplemented from sptk::CLayoutClient.

Reimplemented in sptk::CDateTimeBaseInput, sptk::CInput, and sptk::CListView.

◆ load() [3/3]

virtual void sptk::CControl::load ( Query )
inlinevirtual

Loads control data from query fields.

Reimplemented in sptk::CButtonGroup, sptk::CBaseListBox, sptk::CDateTimeBaseInput, sptk::CInput, sptk::CListView, and sptk::CTreeView.

Referenced by sptk::CInput::load().

◆ maxLength() [1/2]

virtual int sptk::CControl::maxLength ( ) const
inlinevirtual

Returns control's max input length, if applicable.

Reimplemented in sptk::CInput.

◆ maxLength() [2/2]

virtual void sptk::CControl::maxLength ( int  )
inlinevirtual

Sets control's max input length, if applicable.

Reimplemented in sptk::CInput.

◆ onExit()

virtual void sptk::CControl::onExit ( )
protectedvirtual

Internal focus notification on focus change.

Reimplemented in sptk::CDBDropDownListView.

◆ reset()

virtual void sptk::CControl::reset ( )
inlinevirtual

Sets the control to empty text (for the input entries)

Also sets no selection state / default selection (for the lists)

◆ resize()

void sptk::CControl::resize ( int  x,
int  y,
int  w,
int  h 
)
override

Resizes the control and inside widgets.

Parameters
xint, x-position
yint, y-position
wint, width
hint, height

◆ save() [1/3]

virtual void sptk::CControl::save ( const xdoc::SNode &  node) const
inlinevirtual

Saves control data to XML.

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

Parameters
nodethe XML node

Reimplemented in sptk::CButtonGroup, and sptk::CTreeView.

References DATA.

◆ save() [2/3]

void sptk::CControl::save ( const xdoc::SNode &  node,
CLayoutXMLmode  xmlMode 
) const
override

Saves control data to XML.

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

Parameters
nodethe XML node
xmlModethe mode defining how the layout and/or data should be stored

◆ save() [3/3]

virtual void sptk::CControl::save ( Query )
inlinevirtual

◆ textColor() [1/2]

virtual Fl_Color sptk::CControl::textColor ( ) const
virtual

Returns the control's text color.

Reimplemented in sptk::CListView.

◆ textColor() [2/2]

virtual void sptk::CControl::textColor ( Fl_Color  )
virtual

Sets the control's text color.

Reimplemented in sptk::CListView.

◆ textFont() [1/2]

virtual Fl_Font sptk::CControl::textFont ( ) const
virtual

Returns the control's text font.

Reimplemented in sptk::CBox, sptk::CHtmlBox, sptk::CInput, sptk::CListView, and sptk::CMemoInput.

◆ textFont() [2/2]

virtual void sptk::CControl::textFont ( Fl_Font  )
virtual

Sets the control's text font.

Reimplemented in sptk::CBox, sptk::CHtmlBox, sptk::CInput, sptk::CListView, and sptk::CMemoInput.

◆ textSize() [1/2]

virtual uchar sptk::CControl::textSize ( ) const
virtual

Returns the control's text font size.

Reimplemented in sptk::CBox, sptk::CHtmlBox, sptk::CInput, sptk::CListView, and sptk::CMemoInput.

◆ textSize() [2/2]

virtual void sptk::CControl::textSize ( uchar  )
virtual

Sets the control's text font size.

Reimplemented in sptk::CBox, sptk::CHtmlBox, sptk::CInput, sptk::CListView, and sptk::CMemoInput.

◆ valid()

virtual bool sptk::CControl::valid ( ) const
pure virtual

Returns true if the control state is valid, and the data is inside the limits (if applicable)

Implemented in sptk::CButtonGroup, sptk::CBaseListBox, sptk::CDateIntervalInput, sptk::CDateTimeBaseInput, sptk::CFloatInput, sptk::CInput, sptk::CIntegerInput, sptk::CListView, sptk::CPhoneNumberInput, and sptk::CTreeView.

Member Data Documentation

◆ m_control

Fl_Widget* sptk::CControl::m_control {nullptr}
protected

The main widget inside the control.

◆ m_controlFlags

uint32_t sptk::CControl::m_controlFlags {0}
protected

Control's special flags (a bit combination of InputEntryFlags).

See also
InputEntryFlags for details.

◆ m_event

CEventInfo sptk::CControl::m_event
protected

The last SPTK event inside this control.

◆ m_fieldName

String sptk::CControl::m_fieldName
protected

Field name for the universal data connection

◆ m_hasFocus

bool sptk::CControl::m_hasFocus {false}
protected

Does the control have focus?

◆ m_hint

String sptk::CControl::m_hint
protected

The text of the hint

◆ m_labelColor

Fl_Color sptk::CControl::m_labelColor
protected

Control label color

◆ m_labelWidth

uint32_t sptk::CControl::m_labelWidth {0}
protected

Control label width (on the left)

◆ m_limited

bool sptk::CControl::m_limited {false}
protected

Control has the defined min and max values

◆ m_menuButton

Fl_Menu_Button* sptk::CControl::m_menuButton {nullptr}
protected

Control's menu button - to show right-mouse click menu

◆ m_tag

int sptk::CControl::m_tag {0}
protected

Control's special data tag

◆ m_textColor

Fl_Color sptk::CControl::m_textColor
protected

Control text color

◆ m_textFont

Fl_Font sptk::CControl::m_textFont
protected

Control text font

◆ m_textSize

uchar sptk::CControl::m_textSize {0}
protected

Control text font size


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

Fri Oct 14 2022 09:58:34: SPTK 5.4.1