Home2L - C/C++ API v1.4-0-g38cc (2024-05-25)
Smart Tools for a Private Home
|
Menu widget.
Definition at line 565 of file ui_widgets.H.
#include "ui_widgets.H"
Public Member Functions | |
Setup ... | |
void | Setup (SDL_Rect _rContainer, int _hAlign=-1, int _vAlign=-1, TColor color=MENU_DEFAULT_COLOR, TTF_Font *_font=NULL) |
Setting menu entries ... | |
void | SetItems (const char *_itemStr) |
Set a list of items separated by '|'. | |
void | SetItems (int _items) |
void | SetItem (int idx, const char *_text, SDL_Surface *_surfIcon=NULL, bool _isSpecial=false, void *data=NULL) |
Running (see CModalWidget) ... | |
int | Run (CScreen *_screen, const char *_itemStr) |
int | Run (CScreen *_screen) |
virtual void | Start (CScreen *_screen) |
Just start the modal widget. | |
Status... | |
The selected Menu entry is obtained by CModalWidget::GetStatus(). If the status is < 0, the menu has been canceled. The following method(s) provide additional information. | |
bool | GetStatusLongPush () |
Return whether the push was a long push. | |
Misc. ... | |
SDL_Rect * | GetArea () |
Callbacks... | |
virtual void | Render (SDL_Renderer *ren) |
Render this widget. More... | |
virtual bool | HandleEvent (SDL_Event *ev) |
Handle event: must always be called last. | |
virtual void | OnPushed (int idx, bool longPush) |
Public Member Functions inherited from CListbox | |
void | SetMode (EListboxMode _mode, int _itemHeight, int _itemGap=1) |
'itemHeight' == 0 indicates variable-height items (Note: presently much worse performance than fixed-height); implicitly deletes all items. | |
void | SetFormat (TTF_Font *_font, int _hAlign=-1, TColor colGrid=BLACK, TColor _colLabel=WHITE, TColor _colBack=DARK_DARK_GREY, TColor _colLabelSelected=WHITE, TColor _colBackSelected=GREY, TColor _colLabelSpecial=WHITE, TColor _colBackSpecial=DARK_GREY) |
Except 'colGrid', all parameters set here are only read in 'RenderItem' & can be ommited (or re-interpreted) if a custom render function is defined. 'colGrid' is the general background color which can also be set via 'CCanvas::SetColors'. | |
void | SetArea (SDL_Rect _area) |
void | Clear () |
void | SetItems (int _items) |
int | GetItems () |
void | SetItem (int idx, const char *_text, const char *_iconName=NULL, bool _isSpecial=false, void *data=NULL) |
void | SetItem (int idx, const char *_text, SDL_Surface *_iconSurf, bool _isSpecial=false, void *data=NULL) |
CListboxItem * | GetItem (int idx) |
int | GetItemHeight () |
int | GetItemLabelWidth (int idx) |
Retrieve the label (net) width of an item (e.g. to optimize geometry). | |
SDL_Rect | GetItemRect (int idx) |
Get the area of an item. | |
void | ScrollTo (int idx, int vAlign=-1) |
void | ScrollIn (int idx) |
void | SelectItem (int idx, bool _isSelected=true) |
(De-)Select item (for 'lmSelectSingle', 'lmSelectAny') | |
void | SelectAll (bool _isSelected=true) |
Select all items (for 'lmSelectAny') | |
void | SelectNone () |
Deselect all items (for 'lmSelectSingle', 'lmSelectAny') | |
bool | MouseDown () |
Determine whether the listbox is currently dragged by the mouse. In this case, calling a Select...() method may interfere with the user interaction and should be avoided. | |
bool | ItemIsSelected (int idx) |
int | GetSelectedItem () |
void | SetCbPushed (FCbListboxPushed *_cbPushed, void *_data=NULL) |
void | ChangedItems (int idx, int num=1) |
Must be called if items changed and SetItem() was not called. | |
Public Member Functions inherited from CCanvas | |
void | SetDefaults () |
Set default colors and scrollbar appearance. | |
void | SetColors (TColor _backColor=BLACK, TColor _scrollbarColor=ToColor(255, 255, 255, 32)) |
void | SetScrollbarWidth (int width=8) |
void | SetArea (SDL_Rect _area) |
void | SetVirtArea (SDL_Rect r) |
Set the virtual area in screen coordinates; ('virtArea' == 'area' represents no displacement); The areas of all subwidgets are relative to the virtual area. | |
SDL_Rect * | GetVirtArea () |
void | MoveVirtArea (int toX0, int toY0) |
void | LimitVirtArea (SDL_Rect *r=NULL) |
Move virtual area (or 'r') so that the visible area is completely filled. | |
void | ScrollTo (SDL_Rect r, int hAlign=0, int vAlign=-1) |
Scroll such that 'r' is aligned according to '[vh]Align' (-1 = left/up, 0 = center, 1 = right/down). | |
void | ScrollIn (SDL_Rect r) |
Scroll just enough to get 'r' fully visible. | |
void | WidgetToScreenCoords (int *x, int *y) |
void | ScreenToWidgetCoords (int *x, int *y) |
void | AddWidget (CWidget *widget) |
void | DelWidget (CWidget *widget) |
void | DelAllWidgets () |
bool | IsVisible (SDL_Rect *r) |
bool | IsVisible (CWidget *w) |
Public Member Functions inherited from CWidget | |
void | Set (SDL_Surface *_surf, int x0, int y0) |
void | SetArea (SDL_Rect _area) |
SDL_Rect * | GetArea () |
class CScreen * | GetScreen () |
bool | IsOnScreen (class CScreen *_screen) |
class CCanvas * | GetCanvas () |
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'. | |
virtual SDL_Surface * | GetSurface () |
Get an up-to-date surface or 'NULL' if none is available. | |
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. | |
void | ClearTexture () |
Clear the internally cached texture object to save memory. | |
Public Member Functions inherited from CModalWidget | |
int | Run (CScreen *_screen) |
Run the widget until it is cancelled or a status >= 0 is set; return status. | |
bool | IsRunning () |
Must be invoked regularly (in each UI iteration), if Run() is not used. | |
virtual void | Stop () |
Remove widget from screen (e.g. useful for inactivity timeout). | |
int | GetStatus () |
Get status: -2: running, -1: cancelled (e.g. by touching outside), >= 0: success, user-defined code set by 'SetStatus'. | |
void | SetStatus (int _status) |
Set a status code. | |
void | SetNoCancelArea (SDL_Rect _rNoCancel) |
Set the no-cancel area. More... | |
void | RemoveNoCancelArea () |
Additional Inherited Members | |
Protected Member Functions inherited from CListbox | |
virtual SDL_Surface * | RenderItem (CListboxItem *item, int idx, SDL_Surface *surf) |
Render a list box item to an SDL surface and return it. More... | |
void | ChangedSetup () |
void | Changed () |
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. | |
|
virtual |
Render this widget.
The default implementation uses the 'GetTexture()' method above. By overriding this method it is possible to define widgets with a custom SDL rendering procedure, which may be more efficient than preparing a single texture containing the complete widget.
It is allowed to pass 'ren == NULL', in which case all textures and internal data structures are (re-)calculated, but nothing is actually rendered.
Reimplemented from CListbox.