Luanti 5.15.0-dev
 
Loading...
Searching...
No Matches
GUIButtonKey Class Reference

#include <guiButtonKey.h>

+ Inheritance diagram for GUIButtonKey:
+ Collaboration diagram for GUIButtonKey:

Public Member Functions

 GUIButtonKey (gui::IGUIEnvironment *environment, gui::IGUIElement *parent, s32 id, core::rect< s32 > rectangle, ISimpleTextureSource *tsrc, bool noclip=false)
 Constructor.
 
virtual void setText (const wchar_t *text) override
 Sets the text for the key field.
 
virtual const wchar_t * getText () const override
 Gets the value for the key field.
 
virtual bool OnEvent (const SEvent &event) override
 Called if an event happened.
 
- Public Member Functions inherited from GUIButton
 GUIButton (gui::IGUIEnvironment *environment, gui::IGUIElement *parent, s32 id, core::rect< s32 > rectangle, ISimpleTextureSource *tsrc, bool noclip=false)
 constructor
 
virtual ~GUIButton ()
 destructor
 
virtual void draw () override
 draws the element and its children
 
virtual void setOverrideFont (gui::IGUIFont *font=0) override
 sets another skin independent font. if this is set to zero, the button uses the font of the skin.
 
virtual gui::IGUIFont * getOverrideFont () const override
 Gets the override font (if any)
 
virtual gui::IGUIFont * getActiveFont () const override
 Get the font which is used right now for drawing.
 
virtual void setOverrideColor (video::SColor color) override
 Sets another color for the button text.
 
virtual video::SColor getOverrideColor () const override
 Gets the override color.
 
virtual video::SColor getActiveColor () const override
 Gets the currently used text color.
 
virtual void enableOverrideColor (bool enable) override
 Sets if the button text should use the override color or the color in the gui skin.
 
virtual bool isOverrideColorEnabled (void) const override
 Checks if an override color is enabled.
 
virtual void setImage (gui::EGUI_BUTTON_IMAGE_STATE state, video::ITexture *image=nullptr, const core::rect< s32 > &sourceRect=core::rect< s32 >(0, 0, 0, 0)) override
 Sets an image which should be displayed on the button when it is in the given state.
 
virtual void setImage (video::ITexture *image=nullptr) override
 Sets an image which should be displayed on the button when it is in normal state.
 
virtual void setImage (video::ITexture *image, const core::rect< s32 > &pos) override
 Sets an image which should be displayed on the button when it is in normal state.
 
virtual void setPressedImage (video::ITexture *image=nullptr) override
 Sets an image which should be displayed on the button when it is in pressed state.
 
virtual void setPressedImage (video::ITexture *image, const core::rect< s32 > &pos) override
 Sets an image which should be displayed on the button when it is in pressed state.
 
virtual void setSpriteBank (gui::IGUISpriteBank *bank=0) override
 Sets the sprite bank used by the button.
 
virtual void setSprite (gui::EGUI_BUTTON_STATE state, s32 index, video::SColor color=video::SColor(255, 255, 255, 255), bool loop=false) override
 Sets the animated sprite for a specific button state.
 
virtual s32 getSpriteIndex (gui::EGUI_BUTTON_STATE state) const override
 Get the sprite-index for the given state or -1 when no sprite is set.
 
virtual video::SColor getSpriteColor (gui::EGUI_BUTTON_STATE state) const override
 Get the sprite color for the given state. Color is only used when a sprite is set.
 
virtual bool getSpriteLoop (gui::EGUI_BUTTON_STATE state) const override
 Returns if the sprite in the given state does loop.
 
virtual void setIsPushButton (bool isPushButton=true) override
 Sets if the button should behave like a push button.
 
virtual bool isPushButton () const override
 Checks whether the button is a push button.
 
virtual void setPressed (bool pressed=true) override
 Sets the pressed state of the button if this is a pushbutton.
 
virtual bool isPressed () const override
 Returns if the button is currently pressed.
 
bool isHovered () const
 Returns if this element (or one of its direct children) is hovered.
 
bool isFocused () const
 Returns if this element (or one of its direct children) is focused.
 
virtual void setDrawBorder (bool border=true) override
 Sets if the button should use the skin to draw its border.
 
virtual bool isDrawingBorder () const override
 Checks if the button face and border are being drawn.
 
virtual void setUseAlphaChannel (bool useAlphaChannel=true) override
 Sets if the alpha channel should be used for drawing images on the button (default is false)
 
virtual bool isAlphaChannelUsed () const override
 Checks if the alpha channel should be used for drawing images on the button.
 
virtual void setScaleImage (bool scaleImage=true) override
 Sets if the button should scale the button images to fit.
 
virtual bool isScalingImage () const override
 Checks whether the button scales the used images.
 
virtual bool getClickShiftState () const override
 Get if the shift key was pressed in last EGET_BUTTON_CLICKED event.
 
virtual bool getClickControlState () const override
 Get if the control key was pressed in last EGET_BUTTON_CLICKED event.
 
void setColor (video::SColor color)
 
void setFromState ()
 Set element properties from a StyleSpec corresponding to the button state.
 
virtual void setFromStyle (const StyleSpec &style)
 Set element properties from a StyleSpec.
 
void setStyles (const std::array< StyleSpec, StyleSpec::NUM_STATES > &styles)
 Set the styles used for each state.
 

Static Public Member Functions

static GUIButtonKeyaddButton (gui::IGUIEnvironment *environment, const core::rect< s32 > &rectangle, ISimpleTextureSource *tsrc, IGUIElement *parent, s32 id, const wchar_t *text=L"", const wchar_t *tooltiptext=L"")
 Do not drop returned handle.
 
- Static Public Member Functions inherited from GUIButton
static GUIButtonaddButton (gui::IGUIEnvironment *environment, const core::rect< s32 > &rectangle, ISimpleTextureSource *tsrc, IGUIElement *parent, s32 id, const wchar_t *text, const wchar_t *tooltiptext=L"")
 Do not drop returned handle.
 

Private Types

using super = GUIButton
 

Private Member Functions

void sendKey ()
 
void startCapture ()
 Start key capture.
 
void cancelCapture (bool inhibit_restart=false)
 Cancel key capture.
 
void setKey (KeyPress key)
 Sets the captured key and stop capturing.
 

Private Attributes

bool capturing = false
 
bool nostart = false
 
KeyPress key_value = {}
 
std::wstring keysym
 

Additional Inherited Members

- Protected Member Functions inherited from GUIButton
void drawSprite (gui::EGUI_BUTTON_STATE state, u32 startTime, const core::position2di &center)
 
gui::EGUI_BUTTON_IMAGE_STATE getImageState (bool pressed) const
 
ISimpleTextureSourcegetTextureSource ()
 
gui::EGUI_BUTTON_IMAGE_STATE getImageState (bool pressed, const ButtonImage *images) const
 

Member Typedef Documentation

◆ super

using GUIButtonKey::super = GUIButton
private

Constructor & Destructor Documentation

◆ GUIButtonKey()

GUIButtonKey::GUIButtonKey ( gui::IGUIEnvironment * environment,
gui::IGUIElement * parent,
s32 id,
core::rect< s32 > rectangle,
ISimpleTextureSource * tsrc,
bool noclip = false )
inline

Constructor.

Member Function Documentation

◆ addButton()

GUIButtonKey * GUIButtonKey::addButton ( gui::IGUIEnvironment * environment,
const core::rect< s32 > & rectangle,
ISimpleTextureSource * tsrc,
IGUIElement * parent,
s32 id,
const wchar_t * text = L"",
const wchar_t * tooltiptext = L"" )
static

Do not drop returned handle.

References setText().

Referenced by GUIFormSpecMenu::parseButton().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cancelCapture()

void GUIButtonKey::cancelCapture ( bool inhibit_restart = false)
inlineprivate

Cancel key capture.

References capturing, key_value, KeyPress::name(), nostart, GUIButton::setText(), and utf8_to_wide().

Referenced by OnEvent().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getText()

virtual const wchar_t * GUIButtonKey::getText ( ) const
inlineoverridevirtual

Gets the value for the key field.

References keysym.

◆ OnEvent()

bool GUIButtonKey::OnEvent ( const SEvent & event)
overridevirtual

Called if an event happened.

Reimplemented from GUIButton.

References cancelCapture(), capturing, GUIButton::isPressed(), LMBKey, MMBKey, nostart, RMBKey, sendKey(), setKey(), GUIButton::setPressed(), and startCapture().

+ Here is the call graph for this function:

◆ sendKey()

void GUIButtonKey::sendKey ( )
private

Referenced by OnEvent().

+ Here is the caller graph for this function:

◆ setKey()

void GUIButtonKey::setKey ( KeyPress key)
private

Sets the captured key and stop capturing.

References key_value, keysym, KeyPress::name(), GUIButton::setText(), KeyPress::sym(), and utf8_to_wide().

Referenced by OnEvent(), and setText().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setText()

virtual void GUIButtonKey::setText ( const wchar_t * text)
inlineoverridevirtual

Sets the text for the key field.

Reimplemented from GUIButton.

References setKey(), and wide_to_utf8().

Referenced by addButton().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ startCapture()

void GUIButtonKey::startCapture ( )
inlineprivate

Start key capture.

References capturing, nostart, GUIButton::setText(), and wstrgettext().

Referenced by OnEvent().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ capturing

bool GUIButtonKey::capturing = false
private

◆ key_value

KeyPress GUIButtonKey::key_value = {}
private

Referenced by cancelCapture(), and setKey().

◆ keysym

std::wstring GUIButtonKey::keysym
private

Referenced by getText(), and setKey().

◆ nostart

bool GUIButtonKey::nostart = false
private

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