Home2L - C/C++ API v1.4-0-g38cc (2024-05-25)
Smart Tools for a Private Home
List of all members
CButton Class Reference

Description

Push-button widget.

This is the normal push button.

Definition at line 214 of file ui_widgets.H.

#include "ui_widgets.H"

Inheritance diagram for CButton:
Inheritance graph
[legend]

Public Member Functions

Quick setup...
void Set (SDL_Rect _area, TColor _color=GREY)
 
void Set (SDL_Rect _area, TColor _color, SDL_Surface *_icon)
 
void Set (SDL_Rect _area, TColor _color, const char *text, TColor textColor=WHITE, TTF_Font *font=NULL)
 
void Set (SDL_Rect _area, TColor _color, SDL_Surface *_icon, const char *text, TColor textColor=WHITE, TTF_Font *font=NULL)
 
Set parameters...
void SetArea (SDL_Rect _area)
 
void SetColor (TColor _colNorm)
 
void SetColor (TColor _colNorm, TColor _colDown)
 
void SetLabel (SDL_Surface *_icon, SDL_Rect *srcRect=NULL, bool takeOwnership=false)
 Set '_icon' as the button label. More...
 
void SetLabel (const char *text, TColor textColor=WHITE, TTF_Font *font=NULL)
 Set a text-only label.
 
void SetLabel (SDL_Surface *_icon, const char *text, TColor textColor=WHITE, TTF_Font *font=NULL)
 Set icon (and optionally text) label. The icon has its own color(s).
 
void SetLabel (TColor color, const char *iconName, const char *text=NULL, TTF_Font *font=NULL)
 Set icon (and optionally text) label. Both have the same color.
 
void ClearLabel ()
 Remove label.
 
void SetLabelAlignment (int _hAlign=0, int _vAlign=0)
 Set/change label alignment.
 
void SetHotkey (SDL_Keycode _hotkey)
 Set hotkey which activates the button callback.
 
Set actions...
virtual void OnPushed (bool longPush)
 
void SetCbPushed (FCbButtonPushed *cb, void *_data=NULL)
 
void * GetCbPushedData ()
 
Callbacks...
virtual SDL_Surface * GetSurface ()
 Get an up-to-date surface or 'NULL' if none is available.
 
virtual bool HandleEvent (SDL_Event *ev)
 Handle an event and return 'true' if the event was consumed and is to be ignored by later widgets.
 
- Public Member Functions inherited from CWidget
void Set (SDL_Surface *_surf, int x0, int y0)
 
void SetArea (SDL_Rect _area)
 
SDL_Rect * GetArea ()
 
class CScreenGetScreen ()
 
bool IsOnScreen (class CScreen *_screen)
 
class CCanvasGetCanvas ()
 
void LocalToScreenCoords (int *x, int *y)
 
void ScreenToLocalCoords (int *x, int *y)
 
void GetMouseEventPos (SDL_Event *ev, int *x, int *y)
 
void SetSurface (SDL_Surface *_surface)
 Set the static surface to display. The caller stays owner of surface, must not delete it as long as it is set here. The surface dimensions must match 'area'.
 
void GetRenderArea (SDL_Rect *ra)
 Transpose 'area' to the current screen coordinates to be passed to all SDL rendering functions.
 
virtual SDL_Texture * GetTexture ()
 Return an up-to-date texture. More...
 
void SetTextureBlendMode (SDL_BlendMode _sdlBlendMode)
 Set the blend mode for the texture created by the default implementation of GetTexture(). The default is SDL_BLENDMODE_NONE.
 
virtual void Render (SDL_Renderer *ren)
 Render this widget. More...
 
void ClearTexture ()
 Clear the internally cached texture object to save memory.
 

Protected Member Functions

Change management...
void ChangedSurface ()
 
- Protected Member Functions inherited from CWidget
void ChangedSurface ()
 Mark (only) the surface as changed to trigger a redrawing at next occasion.
 
void Changed ()
 Anything may have changed: Trigger a redrawing at next occasion.
 

Member Function Documentation

◆ SetLabel()

void CButton::SetLabel ( SDL_Surface *  _icon,
SDL_Rect *  srcRect = NULL,
bool  takeOwnership = false 
)

Set '_icon' as the button label.

By default, the object keeps a reference to '_icon' internally, and the caller must keep the icon valid as long as the button object lives or until another label is set. If 'takeOwnership == true', the button object will free the surface as soon as appropriate (which may be later or very soon, e.g. during this call!). Hence, if the caller cannot conveniently keep '_icon' valid, the caller should make a copy (SurfaceDup() ) and pass 'takeOwnership = true' here.

Note: It is legal to not call any of the SetLabel() methods and have no label at all. This is, for example, used in the floor plan view, where the "labels" are actually parts of other (background) widgets.


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