Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: MaximInterface
Button Class Reference
Clickable button control with text label. More...
#include <Button.hpp>
Inherits Graphic.
| Public Member Functions | |
| void | setClickedHandler (const EventHandler &clickedHandler) | 
| Set the event handler that is called when the button is clicked. | |
| const ChildContainer & | children () const | 
| List of child graphics for this parent. | |
| bool | focused () const | 
| Check if this graphic is focused. | |
| void | setFocused () | 
| Set this graphic as the focused graphic. | |
| void | move (int x, int y) | 
| Move graphic to a new location measured in pixels. | |
| void | resize (int width, int height) | 
| Resize graphic to a new size measure in pixels. | |
| bool | update (Bitmap *canvas) | 
| Update this graphic and all child graphics. | |
| bool | processKey (Key key) | 
| Process a key-press input event. | |
| Text | |
| Text label of the button. | |
| const std::string & | text () const | 
| void | setText (const std::string &text) | 
| Word wrap | |
| Enable or disable word wrapping on the label. | |
| bool | wordWrap () const | 
| void | setWordWrap (bool wordWrap) | 
| Preferred width | |
| 
 | |
| int | preferredWidth () const | 
| int | preferredHeight () const | 
| Parent | |
| Get or set the parent graphic of this graphic. Set to NULL if this graphic has no parent. | |
| Graphic * | parent () | 
| const Graphic * | parent () const | 
| void | setParent (Graphic *parent) | 
| int | x () const | 
| Coordinates of this graphic in pixels. | |
| int | width () const | 
| Displayed dimensions of this graphic in pixels. | |
| void | render (Bitmap &bitmap, int xOffset, int yOffset) const | 
| Render this graphic onto a bitmap. | |
| Protected Member Functions | |
| virtual void | focusChanged (bool focused) | 
| Event handler for when this graphic has been focused or unfocused. | |
| virtual void | resized () | 
| Event handler for when this graphic has been resized. | |
| virtual bool | doProcessKey (Key key) | 
| Process a key-press input event. | |
| void | invalidate () | 
| Mark the visual region as invalid. | |
| virtual void | childrenChanged () | 
| Event handler for when a child is added or removed. | |
| virtual void | moved () | 
| Event handler for when this graphic has been moved. | |
| virtual void | updated () | 
| Event handler for when this graphic has been updated. | |
| virtual void | doRender (Bitmap &bitmap, int xOffset, int yOffset) const | 
| Render this graphic onto a bitmap. | |
Detailed Description
Clickable button control with text label.
Definition at line 42 of file Button.hpp.
Member Function Documentation
| const ChildContainer& children | ( | ) | const  [inherited] | 
List of child graphics for this parent.
- Note:
- Children should be added and removed by calling setParent. Children will be removed automatically when they are destroyed.
Definition at line 73 of file Graphic.hpp.
| void childrenChanged | ( | ) |  [protected, virtual, inherited] | 
Event handler for when a child is added or removed.
Definition at line 231 of file Graphic.cpp.
| bool doProcessKey | ( | Key | ) |  [protected, virtual] | 
Process a key-press input event.
- Returns:
- True if the key event was handled. False if the key event should be propagated.
Reimplemented from Graphic.
Definition at line 70 of file Button.cpp.
| void doRender | ( | Bitmap & | bitmap, | 
| int | xOffset, | ||
| int | yOffset | ||
| ) | const  [protected, virtual, inherited] | 
Render this graphic onto a bitmap.
The default implementation renders each child in order.
Reimplemented in DisplayGraphicWindow, DisplayIdWindow, ErrorWindow, Image, InitWindow, NormalOperationWindow, Rectangle, and Text.
Definition at line 150 of file Graphic.cpp.
| void focusChanged | ( | bool | focused ) |  [protected, virtual] | 
Event handler for when this graphic has been focused or unfocused.
- Parameters:
- 
  focused True if focused or false if unfocused. 
Reimplemented from Graphic.
Definition at line 58 of file Button.cpp.
| bool focused | ( | ) | const  [inherited] | 
Check if this graphic is focused.
- Returns:
- True if focused.
Definition at line 78 of file Graphic.cpp.
| void invalidate | ( | ) |  [protected, inherited] | 
Mark the visual region as invalid.
- Note:
- Indicates a redraw is necessary during next update.
Definition at line 143 of file Graphic.hpp.
| void move | ( | int | x, | 
| int | y | ||
| ) |  [inherited] | 
Move graphic to a new location measured in pixels.
Coordinates are relative to the top-left corner of the parent graphic.
- See also:
- moved
Definition at line 114 of file Graphic.cpp.
| void moved | ( | ) |  [protected, virtual, inherited] | 
Event handler for when this graphic has been moved.
Definition at line 235 of file Graphic.cpp.
| bool processKey | ( | Key | key ) |  [inherited] | 
Process a key-press input event.
The event will first be directed to the focused graphic. Processing will proceed to each parent graphic until it has been handled.
- See also:
- doProcessKey
- Returns:
- True if the key event was handled.
Definition at line 216 of file Graphic.cpp.
| void render | ( | Bitmap & | bitmap, | 
| int | xOffset, | ||
| int | yOffset | ||
| ) | const  [inherited] | 
Render this graphic onto a bitmap.
Definition at line 155 of file Graphic.cpp.
| void resize | ( | int | width, | 
| int | height | ||
| ) |  [inherited] | 
Resize graphic to a new size measure in pixels.
Minimum width and height is 1.
- See also:
- resized
Definition at line 123 of file Graphic.cpp.
| void resized | ( | ) |  [protected, virtual] | 
Event handler for when this graphic has been resized.
Reimplemented from Graphic.
Definition at line 63 of file Button.cpp.
| void setClickedHandler | ( | const EventHandler & | clickedHandler ) | 
Set the event handler that is called when the button is clicked.
Definition at line 76 of file Button.hpp.
| void setFocused | ( | ) |  [inherited] | 
Set this graphic as the focused graphic.
The focused graphic is the first to receive input events such as key presses.
- See also:
- focusChanged
Definition at line 89 of file Graphic.cpp.
| void setParent | ( | Graphic * | parent ) |  [inherited] | 
- Note:
- Adds this graphic to the parent's list of children.
- See also:
- childrenChanged
Definition at line 53 of file Graphic.cpp.
| bool update | ( | Bitmap * | canvas ) |  [inherited] | 
Update this graphic and all child graphics.
Checks if graphic has been invalidated and should be redrawn.
- Parameters:
- 
  canvas Canvas used for rendering. May be set to NULL to defer redraw. 
- Returns:
- True if the canvas has been updated.
- See also:
- updated
Definition at line 207 of file Graphic.cpp.
| void updated | ( | ) |  [protected, virtual, inherited] | 
Event handler for when this graphic has been updated.
Reimplemented in HardwareTestWindow, InitWindow, NormalOperationWindow, and WifiConnectWindow.
Definition at line 239 of file Graphic.cpp.
| int width | ( | ) | const  [inherited] | 
Displayed dimensions of this graphic in pixels.
Definition at line 99 of file Graphic.hpp.
| int x | ( | ) | const  [inherited] | 
Coordinates of this graphic in pixels.
Coordinates are relative to the top-left corner of the parent graphic.
Definition at line 91 of file Graphic.hpp.
Generated on Tue Jul 12 2022 12:06:50 by
 1.7.2
 1.7.2