GUIFramework 1.1.0
Framework for desktop GUI applications in C++.
Loading...
Searching...
No Matches
gui_framework::BaseButton Class Referenceabstract

Base class for all buttons. More...

#include <BaseButton.h>

Inheritance diagram for gui_framework::BaseButton:
gui_framework::interfaces::ISingleTextLocalized gui_framework::BaseComponent gui_framework::interfaces::ITextOperations gui_framework::interfaces::ITextLocalized gui_framework::interfaces::ISerializable gui_framework::BaseCheckBox gui_framework::Button gui_framework::ImageButton gui_framework::CheckBox

Public Member Functions

 BaseButton (const std::wstring &buttonName, const std::wstring &buttonText, const utility::ComponentSettings &settings, const styles::ButtonStyles &styles, BaseComposite *parent, const std::function< void()> &onClick=nullptr)
 
 BaseButton (const std::wstring &buttonName, const std::wstring &buttonText, const utility::ComponentSettings &settings, const styles::ButtonStyles &styles, BaseComposite *parent, const std::string &functionName, const std::string &moduleName)
 
void setOnClick (const std::function< void()> &onClick)
 Can't serialize.
 
virtual void setOnClick (const std::string &functionName, const std::string &moduleName)
 Load function from module. Can be seriazlied.
 
const std::function< void()> & getOnClick () const
 
const std::string & getFunctionName () const
 Get onClick function name from loaded module.
 
const std::string & getModuleName () const
 Get onClick function associated module name.
 
virtual void setTextColor (uint8_t red, uint8_t green, uint8_t blue) final override
 Not implemented.
 
virtual size_t getHash () const override=0
 Used as key in creators.
 
virtual json::JSONBuilder getStructure () const override
 
virtual void setText (std::string_view localizationKey) final override
 
virtual ~BaseButton ()=default
 
- Public Member Functions inherited from gui_framework::interfaces::ISingleTextLocalized
 ISingleTextLocalized (bool autoUpdate=true)
 
virtual void setLocalizationKey (std::string_view localizationKey) final
 
virtual void setLocalizationKey (std::string &&localizationKey) noexcept final
 
virtual const std::string & getLocalizationKey () const final
 
virtual bool updateLocalizationEvent () final override
 
virtual ~ISingleTextLocalized ()=default
 
- Public Member Functions inherited from gui_framework::interfaces::ITextLocalized
 ITextLocalized (bool autoUpdate=true)
 
virtual void setAutoUpdate (bool autoUpdate) final
 
virtual bool getAutoUpdate () const final
 
virtual ~ITextLocalized ()=default
 
- Public Member Functions inherited from gui_framework::BaseComponent
 BaseComponent (std::wstring_view className, std::wstring_view windowName, const utility::ComponentSettings &settings, const interfaces::IStyles &styles, BaseComposite *parent=nullptr, std::string_view windowFunctionName="", std::string_view moduleName="", uint16_t smallIconResource=NULL, uint16_t largeIconResource=NULL)
 
LRESULT handleMessages (HWND handle, UINT message, WPARAM wparam, LPARAM lparam, bool &isUsed)
 
bool destroyComponent ()
 
bool asyncDestroyComponent ()
 
void enable ()
 
void disable ()
 
bool isEnabled () const
 
bool isDisabled () const
 
LRESULT sendRawMessage (UINT message, WPARAM wparam, LPARAM lparam)
 SendMessage WinAPI wrapper.
 
void setDesiredWidth (uint16_t desiredWidth)
 
void setDesiredHeight (uint16_t desiredHeight)
 
void setDesiredX (int desiredX)
 
void setDesiredY (int desiredY)
 
virtual void setBackgroundColor (uint8_t red, uint8_t green, uint8_t blue)
 
BaseComponentgetParent () const
 
HWND getHandle () const
 
std::wstring_view getWindowName () const
 
std::wstring_view getClassName () const
 
uint16_t getDesiredWidth () const
 
uint16_t getDesiredHeight () const
 
uint16_t getActualWidth () const
 
uint16_t getActualHeight () const
 
RECT getActualCoordinates () const
 
int getDesiredX () const
 
int getDesiredY () const
 
uint32_t getId () const
 
COLORREF getBackgroundColor () const
 
COLORREF getTextColor () const
 
const smartPointerType< interfaces::IStyles > & getStyles () const
 
virtual ~BaseComponent ()
 
- Public Member Functions inherited from gui_framework::interfaces::ISerializable
 ISerializable ()=default
 
virtual ~ISerializable ()=default
 
- Public Member Functions inherited from gui_framework::interfaces::ITextOperations
 ITextOperations (HWND handle, const std::wstring &text=L"")
 
 ITextOperations (HWND handle, const std::string &localizationKey)
 
void setText (std::wstring_view text)
 
virtual std::wstring getText () const final
 Get text from control.
 
virtual ~ITextOperations ()=default
 

Static Public Attributes

static constexpr uint16_t buttonWidth = 200
 
static constexpr uint16_t buttonHeight = 20
 

Protected Member Functions

virtual LRESULT windowMessagesHandle (HWND handle, UINT message, WPARAM wparam, LPARAM lparam, bool &isUsed) override
 
virtual void updateLocalization (std::wstring_view localizedText) override
 
- Protected Member Functions inherited from gui_framework::interfaces::ISingleTextLocalized
- Protected Member Functions inherited from gui_framework::BaseComponent
virtual LRESULT preWindowMessagesHandle (HWND handle, UINT message, WPARAM wparam, LPARAM lparam, bool &isUsed)
 
virtual void setLocalizationKeys (interfaces::ITextLocalized *localized, const std::vector< std::string > &localizationKeys)
 Override for custom localization.
 

Protected Attributes

std::function< void()> onClick
 
std::string functionName
 
std::string moduleName
 
- Protected Attributes inherited from gui_framework::BaseComponent
BaseCompositeparent
 
const std::wstring className
 
const std::wstring windowName
 
HWND handle
 
uint16_t desiredWidth
 
uint16_t desiredHeight
 
int desiredX
 
int desiredY
 
uint32_t id
 
COLORREF backgroundColor
 
COLORREF textColor
 
smartPointerType< interfaces::IStylesstyles
 
- Protected Attributes inherited from gui_framework::interfaces::ITextOperations
HWND textHandle
 

Additional Inherited Members

- Static Public Member Functions inherited from gui_framework::BaseComponent
static void runFunctionAsync (const std::function< void()> &callable, const std::function< void()> &callback=nullptr) noexcept
 Add task to thread pool.
 
static void runFunctionAsync (std::function< void()> &&callable, const std::function< void()> &callback=nullptr) noexcept
 Add task to thread pool.
 
- Static Public Member Functions inherited from gui_framework::interfaces::ISerializable
static uint32_t getCodepage ()
 

Detailed Description

Base class for all buttons.

Definition at line 11 of file BaseButton.h.

Constructor & Destructor Documentation

◆ BaseButton() [1/2]

gui_framework::BaseButton::BaseButton ( const std::wstring & buttonName,
const std::wstring & buttonText,
const utility::ComponentSettings & settings,
const styles::ButtonStyles & styles,
BaseComposite * parent,
const std::function< void()> & onClick = nullptr )

◆ BaseButton() [2/2]

gui_framework::BaseButton::BaseButton ( const std::wstring & buttonName,
const std::wstring & buttonText,
const utility::ComponentSettings & settings,
const styles::ButtonStyles & styles,
BaseComposite * parent,
const std::string & functionName,
const std::string & moduleName )
Exceptions
CantFindFunctionFromModuleException
std::out_of_rangeCan't find moduleName in loaded modules

◆ ~BaseButton()

virtual gui_framework::BaseButton::~BaseButton ( )
virtualdefault

Member Function Documentation

◆ getFunctionName()

const string & gui_framework::BaseButton::getFunctionName ( ) const

Get onClick function name from loaded module.

Returns
functionName

Definition at line 99 of file BaseButton.cpp.

◆ getHash()

virtual size_t gui_framework::BaseButton::getHash ( ) const
overridepure virtual

Used as key in creators.

Returns
typeid().hash_code()

Implements gui_framework::BaseComponent.

Implemented in gui_framework::BaseCheckBox, gui_framework::Button, gui_framework::CheckBox, and gui_framework::ImageButton.

◆ getModuleName()

const string & gui_framework::BaseButton::getModuleName ( ) const

Get onClick function associated module name.

Returns
moduleName

Definition at line 104 of file BaseButton.cpp.

◆ getOnClick()

const function< void()> & gui_framework::BaseButton::getOnClick ( ) const

Definition at line 94 of file BaseButton.cpp.

◆ getStructure()

json::JSONBuilder gui_framework::BaseButton::getStructure ( ) const
overridevirtual

◆ setOnClick() [1/2]

void gui_framework::BaseButton::setOnClick ( const std::function< void()> & onClick)

Can't serialize.

Parameters
onClick

◆ setOnClick() [2/2]

virtual void gui_framework::BaseButton::setOnClick ( const std::string & functionName,
const std::string & moduleName )
virtual

Load function from module. Can be seriazlied.

Parameters
functionName
moduleName
Exceptions
CantFindFunctionFromModuleException
std::out_of_rangeCan't find moduleName in loaded modules

◆ setText()

void gui_framework::BaseButton::setText ( std::string_view localizationKey)
finaloverridevirtual

Reimplemented from gui_framework::interfaces::ITextOperations.

Definition at line 135 of file BaseButton.cpp.

◆ setTextColor()

void gui_framework::BaseButton::setTextColor ( uint8_t red,
uint8_t green,
uint8_t blue )
finaloverridevirtual

Not implemented.

Parameters
red
green
blue
Exceptions
NotImplementedText color does not affects at button

Reimplemented from gui_framework::BaseComponent.

Definition at line 109 of file BaseButton.cpp.

◆ updateLocalization()

void gui_framework::BaseButton::updateLocalization ( std::wstring_view localizedText)
overrideprotectedvirtual

Implements gui_framework::interfaces::ISingleTextLocalized.

Definition at line 32 of file BaseButton.cpp.

◆ windowMessagesHandle()

LRESULT gui_framework::BaseButton::windowMessagesHandle ( HWND handle,
UINT message,
WPARAM wparam,
LPARAM lparam,
bool & isUsed )
overrideprotectedvirtual

Reimplemented from gui_framework::BaseComponent.

Definition at line 13 of file BaseButton.cpp.

Member Data Documentation

◆ buttonHeight

uint16_t gui_framework::BaseButton::buttonHeight = 20
inlinestaticconstexpr

Definition at line 18 of file BaseButton.h.

◆ buttonWidth

uint16_t gui_framework::BaseButton::buttonWidth = 200
inlinestaticconstexpr

Definition at line 17 of file BaseButton.h.

◆ functionName

std::string gui_framework::BaseButton::functionName
protected

Definition at line 22 of file BaseButton.h.

◆ moduleName

std::string gui_framework::BaseButton::moduleName
protected

Definition at line 23 of file BaseButton.h.

◆ onClick

std::function<void()> gui_framework::BaseButton::onClick
protected

Definition at line 21 of file BaseButton.h.


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