sptk2 logo
SPTK Home Page
Public Member Functions | Protected Member Functions | Friends | List of all members
sptk::CBaseButton Class Reference

#include <CButton.h>

Inheritance diagram for sptk::CBaseButton:
sptk::CLayoutClient sptk::CButton sptk::CSmallButton

Public Member Functions

void defaultButton (bool defaultBtn)
 
bool defaultButton () const
 
String className () const override
 
virtual void buttonImage (CButtonKind bkind, CIconSize iconSize=CIconSize::IS_LARGE_ICON)
 
virtual void buttonImage (Fl_Image *image)
 
virtual const Fl_Image * buttonImage () const
 
const Stringlabel () const override
 
void label (const String &lbl) override
 
- 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
 

Protected Member Functions

void image (CButtonKind buttonKind, CIconSize iconSize, String label="")
 
void draw () override
 
void drawFocus (bool usingTheme)
 
int handle (int event) override
 
bool preferredSize (int &w, int &h) override
 
 CBaseButton (CButtonKind kind, CLayoutAlign layoutAlign=CLayoutAlign::RIGHT, bool is_small=false, const char *label=nullptr, CThemeButtonType tbt=THM_BUTTON_NORMAL)
 
 CBaseButton (const char *label=nullptr, CLayoutAlign layoutAlign=CLayoutAlign::RIGHT, CThemeButtonType tbt=THM_BUTTON_NORMAL)
 
- Protected Member Functions inherited from sptk::CLayoutClient
int lastPreferredH () const
 
int lastPreferredW () const
 
void lastPreferredH (int height)
 
void lastPreferredW (int width)
 

Friends

class CThemes
 

Additional Inherited Members

- Protected Attributes inherited from sptk::CLayoutClient
Fl_Widget * m_widget
 
String m_name
 
String m_label
 
CLayoutAlign m_layoutAlign
 

Detailed Description

Base button widget

Base class for CButton and CSmallButton, uses Fl_Image * or a stock image of CButtonKind.

Constructor & Destructor Documentation

◆ CBaseButton() [1/2]

sptk::CBaseButton::CBaseButton ( CButtonKind  kind,
CLayoutAlign  layoutAlign = CLayoutAlign::RIGHT,
bool  is_small = false,
const char *  label = nullptr,
CThemeButtonType  tbt = THM_BUTTON_NORMAL 
)
protected

Constructor in SPTK style

Parameters
kindCButtonKind, stock image id
layoutAlignCLayoutAlign, widget align in layout
is_smallbool, true for the small button (small pixmap, no label)
labelconst char * label
tbtCThemeButtonType, the type of button

◆ CBaseButton() [2/2]

sptk::CBaseButton::CBaseButton ( const char *  label = nullptr,
CLayoutAlign  layoutAlign = CLayoutAlign::RIGHT,
CThemeButtonType  tbt = THM_BUTTON_NORMAL 
)
protected

Constructor in SPTK style. The image should be assigned separately.

Parameters
labelconst char *, label
layoutAlignCLayoutAlign, widget align in layout
tbtCThemeButtonType, the type of button

Member Function Documentation

◆ buttonImage() [1/3]

virtual const Fl_Image * sptk::CBaseButton::buttonImage ( ) const
inlinevirtual

Returns the button's image. Purely virtual.

Returns
image pointer

◆ buttonImage() [2/3]

virtual void sptk::CBaseButton::buttonImage ( CButtonKind  bkind,
CIconSize  iconSize = CIconSize::IS_LARGE_ICON 
)
inlinevirtual

Sets the stock image to the button. Purely virtual.

Parameters
bkindCButtonKind stock image id.
iconSizeCIconSize, the size of the icon

◆ buttonImage() [3/3]

virtual void sptk::CBaseButton::buttonImage ( Fl_Image *  image)
inlinevirtual

Sets the image to the button. Purely virtual.

Parameters
imageFl_Image * image pointer

◆ className()

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

Returns widget class name (internal SPTK RTTI).

Reimplemented from sptk::CLayoutClient.

◆ defaultButton() [1/2]

bool sptk::CBaseButton::defaultButton ( ) const
inline

Returns true if the button is a default button

Returns
button type - default or not

◆ defaultButton() [2/2]

void sptk::CBaseButton::defaultButton ( bool  defaultBtn)

Makes this button a default button

Is used to define a button as default for the current window of CDialog class. The default button is activated when an Enter button is pressed inside CDialog on the widget and the widget doesn't process Enter button.

Parameters
defaultBtnbool makes button default or not

◆ draw()

void sptk::CBaseButton::draw ( )
overrideprotected

Draws the button

◆ drawFocus()

void sptk::CBaseButton::drawFocus ( bool  usingTheme)
protected

Draws the focus for the button.

Parameters
usingThemebool, to use theme's value for the focus corner radius. Otherwise, radius is 0.

◆ handle()

int sptk::CBaseButton::handle ( int  event)
overrideprotected

Special handle() method

◆ image()

void sptk::CBaseButton::image ( CButtonKind  buttonKind,
CIconSize  iconSize,
String  label = "" 
)
protected

Sets the button image to the selected kind buttonKind

Parameters
buttonKindCButtonKind, the button kind
iconSizeCIconSize, the size of the icon
labelconst char*, optional label

◆ label() [1/2]

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

Returns button label

Returns
button label

Reimplemented from sptk::CLayoutClient.

◆ label() [2/2]

void sptk::CBaseButton::label ( const String lbl)
inlineoverridevirtual

Sets button label

Parameters
lblconst char *, new button label

Reimplemented from sptk::CLayoutClient.

◆ preferredSize()

bool sptk::CBaseButton::preferredSize ( int &  w,
int &  h 
)
overrideprotectedvirtual

Preferred size for the button computes the optimal size for the button

Parameters
wint&, button width
hint&, button height
Returns
true if the size is stable (doesn't depend on input sizes)

Reimplemented from sptk::CLayoutClient.


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

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