NXWidgets  1.19
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
NXWidgets::CCycleButton Class Reference

#include <ccyclebutton.hxx>

Inheritance diagram for NXWidgets::CCycleButton:
Inheritance graph

Public Member Functions

 CCycleButton (CWidgetControl *pWidgetControl, nxgl_coord_t x, nxgl_coord_t y, nxgl_coord_t width, nxgl_coord_t height, CWidgetStyle *style=(CWidgetStyle *) NULL)
 
virtual ~CCycleButton (void)
 
void addOption (const CNxString &text, const uint32_t value)
 
virtual void removeOption (const int index)
 
virtual void removeAllOptions (void)
 
virtual void selectOption (const int index)
 
virtual const int getSelectedIndex (void) const
 
virtual void setSelectedIndex (const int index)
 
virtual const CListDataItemgetSelectedOption (void) const
 
const uint32_t getValue (void) const
 
virtual const CListDataItemgetOption (const int index)
 
virtual void sort (void)
 
virtual const int getOptionCount (void) const
 
virtual void setSortInsertedItems (const bool sortInsertedItems)
 
virtual void handleListDataChangedEvent (const CListDataEventArgs &e)
 
virtual void handleListDataSelectionChangedEvent (const CListDataEventArgs &e)
 
virtual void getPreferredDimensions (CRect &rect) const
 
- Public Member Functions inherited from NXWidgets::CButton
 CButton (CWidgetControl *pWidgetControl, nxgl_coord_t x, nxgl_coord_t y, nxgl_coord_t width, nxgl_coord_t height, const CNxString &text, CWidgetStyle *style=(CWidgetStyle *) NULL)
 
virtual ~CButton ()
 
- Public Member Functions inherited from NXWidgets::CLabel
 CLabel (CWidgetControl *pWidgetControl, nxgl_coord_t x, nxgl_coord_t y, nxgl_coord_t width, nxgl_coord_t height, const CNxString &text, CWidgetStyle *style=(CWidgetStyle *) NULL)
 
virtual ~CLabel ()
 
virtual void setTextAlignmentHoriz (TextAlignmentHoriz alignment)
 
virtual void setTextAlignmentVert (TextAlignmentVert alignment)
 
const TextAlignmentHoriz getTextAlignmentHoriz (void) const
 
const TextAlignmentVert getTextAlignmentVert (void) const
 
virtual const CNxStringgetText (void) const
 
virtual void setText (const CNxString &text)
 
virtual void appendText (const CNxString &text)
 
virtual void insertText (const CNxString &text, const int index)
 
virtual void highlight (bool highlightOn)
 
virtual bool isHighlighted (void) const
 
virtual void setFont (CNxFont *font)
 
virtual bool isTextChange (void) const
 
- Public Member Functions inherited from NXWidgets::CNxWidget
 CNxWidget (CWidgetControl *pWidgetControl, nxgl_coord_t x, nxgl_coord_t y, nxgl_coord_t width, nxgl_coord_t height, uint32_t flags, FAR const CWidgetStyle *style=(FAR const CWidgetStyle *) NULL)
 
virtual ~CNxWidget (void)
 
nxgl_coord_t getX (void) const
 
nxgl_coord_t getY (void) const
 
nxgl_coord_t getRelativeX (void) const
 
nxgl_coord_t getRelativeY (void) const
 
bool hasFocus (void) const
 
bool isDeleted (void) const
 
bool isDrawingEnabled (void) const
 
bool isHidden (void) const
 
bool isEnabled (void) const
 
bool isPermeable (void) const
 
bool isDoubleClickable (void) const
 
bool isBorderless (void) const
 
bool isClicked (void) const
 
bool isBeingDragged (void) const
 
nxgl_coord_t getWidth (void) const
 
nxgl_coord_t getHeight (void) const
 
void getSize (struct nxgl_size_s &size) const
 
void getPos (struct nxgl_point_s &pos) const
 
CRect getBoundingBox (void)
 
void getBorderSize (WidgetBorderSize &borderSize)
 
CNxWidgetgetParent (void) const
 
CNxWidgetgetFocusedWidget (void)
 
void getClientRect (CRect &rect) const
 
void getRect (CRect &rect) const
 
CNxFontgetFont (void) const
 
nxgl_mxpixel_t getBackgroundColor (void) const
 
nxgl_mxpixel_t getSelectedBackgroundColor (void) const
 
nxgl_mxpixel_t getShineEdgeColor (void) const
 
nxgl_mxpixel_t getShadowEdgeColor (void) const
 
nxgl_mxpixel_t getHighlightColor (void) const
 
nxgl_mxpixel_t getDisabledTextColor (void) const
 
nxgl_mxpixel_t getEnabledTextColor (void) const
 
nxgl_mxpixel_t getSelectedTextColor (void) const
 
const CWidgetStylegetWidgetStyle () const
 
void setBorderless (bool isBorderless)
 
void setDraggable (bool isDraggable)
 
void setPermeable (bool permeable)
 
void setDoubleClickable (bool doubleClickable)
 
void addWidgetEventHandler (CWidgetEventHandler *eventHandler)
 
void removeWidgetEventHandler (CWidgetEventHandler *eventHandler)
 
int nWidgetEventHandlers (void) const
 
void setRaisesEvents (bool raises)
 
bool raisesEvents (void) const
 
void disableDrawing (void)
 
void enableDrawing (void)
 
void setBackgroundColor (nxgl_mxpixel_t color)
 
void setSelectedBackgroundColor (nxgl_mxpixel_t color)
 
void setShineEdgeColor (nxgl_mxpixel_t color)
 
void setShadowEdgeColor (nxgl_mxpixel_t color)
 
void setHighlightColor (nxgl_mxpixel_t color)
 
void setDisabledTextColor (nxgl_mxpixel_t color)
 
void setEnabledTextColor (nxgl_mxpixel_t color)
 
void setSelectedTextColor (nxgl_mxpixel_t color)
 
void redraw (void)
 
bool enable (void)
 
bool disable (void)
 
void close (void)
 
bool show (void)
 
bool hide (void)
 
virtual bool click (nxgl_coord_t x, nxgl_coord_t y)
 
virtual bool isDoubleClick (nxgl_coord_t x, nxgl_coord_t y)
 
bool doubleClick (nxgl_coord_t x, nxgl_coord_t y)
 
bool release (nxgl_coord_t x, nxgl_coord_t y)
 
bool drag (nxgl_coord_t x, nxgl_coord_t y, nxgl_coord_t vX, nxgl_coord_t vY)
 
bool keyPress (nxwidget_char_t key)
 
bool cursorControl (ECursorControl control)
 
bool focus (void)
 
bool blur (void)
 
bool moveTo (nxgl_coord_t x, nxgl_coord_t y)
 
bool resize (nxgl_coord_t width, nxgl_coord_t height)
 
bool changeDimensions (nxgl_coord_t x, nxgl_coord_t y, nxgl_coord_t width, nxgl_coord_t height)
 
void moveChildToDeleteQueue (CNxWidget *widget)
 
void setFocusedWidget (CNxWidget *widget)
 
virtual bool checkCollision (nxgl_coord_t x, nxgl_coord_t y) const
 
virtual bool checkCollision (nxgl_coord_t x, nxgl_coord_t y, nxgl_coord_t width, nxgl_coord_t height) const
 
bool checkCollision (CNxWidget *widget) const
 
void addWidget (CNxWidget *widget)
 
void insertWidget (CNxWidget *widget)
 
void setParent (CNxWidget *parent)
 
void destroy (void)
 
bool remove (void)
 
bool removeChild (CNxWidget *widget)
 
const CNxWidgetgetChild (int index) const
 
int getChildCount (void) const
 
void setBorderSize (const WidgetBorderSize &borderSize)
 
- Public Member Functions inherited from NXWidgets::IListDataEventHandler
virtual ~IListDataEventHandler (void)
 

Protected Member Functions

virtual void drawContents (CGraphicsPort *port)
 
virtual void drawBorder (CGraphicsPort *port)
 
virtual void drawOutline (CGraphicsPort *port)
 
virtual void onPreRelease (nxgl_coord_t x, nxgl_coord_t y)
 
virtual void onReleaseOutside (nxgl_coord_t x, nxgl_coord_t y)
 
virtual void onResize (nxgl_coord_t width, nxgl_coord_t height)
 
virtual void calculateTextPosition (void)
 
 CCycleButton (const CCycleButton &cycleButton)
 
- Protected Member Functions inherited from NXWidgets::CButton
void drawOutline (CGraphicsPort *port, bool useClicked)
 
void drawContents (CGraphicsPort *port, bool useClicked)
 
void drawBorder (CGraphicsPort *port, bool useClicked)
 
virtual void onClick (nxgl_coord_t x, nxgl_coord_t y)
 
virtual void onRelease (nxgl_coord_t x, nxgl_coord_t y)
 
 CButton (const CButton &button)
 
- Protected Member Functions inherited from NXWidgets::CLabel
virtual void calculateTextPositionVertical (void)
 
virtual void calculateTextPositionHorizontal (void)
 
virtual void onTextChange (void)
 
 CLabel (const CLabel &label)
 
- Protected Member Functions inherited from NXWidgets::CNxWidget
void useWidgetStyle (const CWidgetStyle *style)
 
void drawChildren (void)
 
void closeChild (CNxWidget *widget)
 
void startDragging (nxgl_coord_t x, nxgl_coord_t y)
 
void stopDragging (nxgl_coord_t x, nxgl_coord_t y)
 
 CNxWidget (const CNxWidget &widget)
 
virtual void onDoubleClick (nxgl_coord_t x, nxgl_coord_t y)
 
virtual void onDrag (nxgl_coord_t x, nxgl_coord_t y, nxgl_coord_t vX, nxgl_coord_t vY)
 
virtual void onDragStart (void)
 
virtual void onDragStop (void)
 
virtual void onFocus (void)
 
virtual void onBlur (void)
 
virtual void onEnable (void)
 
virtual void onDisable (void)
 

Protected Attributes

CListData m_options
 
- Protected Attributes inherited from NXWidgets::CLabel
CNxString m_text
 
struct nxgl_point_s m_align
 
TextAlignmentHoriz m_hAlignment
 
TextAlignmentVert m_vAlignment
 
bool m_textChange
 
bool m_highlighted
 
- Protected Attributes inherited from NXWidgets::CNxWidget
CWidgetControlm_widgetControl
 
CRect m_rect
 
nxgl_coord_t m_grabPointX
 
nxgl_coord_t m_grabPointY
 
nxgl_coord_t m_newX
 
nxgl_coord_t m_newY
 
CWidgetStyle m_style
 
Flags m_flags
 
CWidgetEventHandlerListm_widgetEventHandlers
 
struct timespec m_lastClickTime
 
nxgl_coord_t m_lastClickX
 
nxgl_coord_t m_lastClickY
 
int m_doubleClickBounds
 
CNxWidgetm_parent
 
CNxWidgetm_focusedChild
 
TNxArray< CNxWidget * > m_children
 
WidgetBorderSize m_borderSize
 

Additional Inherited Members

- Public Types inherited from NXWidgets::CLabel
enum  TextAlignmentHoriz { TEXT_ALIGNMENT_HORIZ_CENTER = 0, TEXT_ALIGNMENT_HORIZ_LEFT = 1, TEXT_ALIGNMENT_HORIZ_RIGHT = 2 }
 
enum  TextAlignmentVert { TEXT_ALIGNMENT_VERT_CENTER = 0, TEXT_ALIGNMENT_VERT_TOP = 1, TEXT_ALIGNMENT_VERT_BOTTOM = 2 }
 
- Public Types inherited from NXWidgets::CNxWidget
enum  WidgetFlagType {
  WIDGET_BORDERLESS = 0x0001, WIDGET_DRAGGABLE = 0x0002, WIDGET_PERMEABLE = 0x0004, WIDGET_DOUBLE_CLICKABLE = 0x0008,
  WIDGET_NO_RAISE_EVENTS = 0x0010
}
 

Detailed Description

Cycle button widget. Displays text within the button. Clicking it cycles through its available options.

Definition at line 114 of file ccyclebutton.hxx.

Constructor & Destructor Documentation

◆ CCycleButton() [1/2]

NXWidgets::CCycleButton::CCycleButton ( const CCycleButton cycleButton)
inlineprotected

Copy constructor is protected to prevent usage.

Definition at line 186 of file ccyclebutton.hxx.

◆ CCycleButton() [2/2]

CCycleButton::CCycleButton ( CWidgetControl pWidgetControl,
nxgl_coord_t  x,
nxgl_coord_t  y,
nxgl_coord_t  width,
nxgl_coord_t  height,
CWidgetStyle style = (CWidgetStyle *)NULL 
)

Constructor for cycle buttons.

Parameters
pWidgetControlThe widget control for the display.
xThe x coordinate of the button, relative to its parent.
yThe y coordinate of the button, relative to its parent.
widthThe width of the button.
heightThe height of the button.
styleThe style that the button should use. If this is not specified, the button will use the values stored in the global g_defaultWidgetStyle object. The button will copy the properties of the style into its own internal style object.

Definition at line 111 of file ccyclebutton.cxx.

◆ ~CCycleButton()

virtual NXWidgets::CCycleButton::~CCycleButton ( void  )
inlinevirtual

Destructor.

Definition at line 213 of file ccyclebutton.hxx.

Member Function Documentation

◆ addOption()

void CCycleButton::addOption ( const CNxString text,
const uint32_t  value 
)

Add a new option to the widget.

Parameters
textThe text of the option.
valueThe value of the option.

Definition at line 137 of file ccyclebutton.cxx.

◆ calculateTextPosition()

virtual void NXWidgets::CCycleButton::calculateTextPosition ( void  )
inlineprotectedvirtual

Override method in Label class to prevent recalculation of text positions.

Definition at line 180 of file ccyclebutton.hxx.

◆ drawBorder()

void CCycleButton::drawBorder ( CGraphicsPort port)
protectedvirtual

Draw the area of this widget that falls within the clipping region. Called by the redraw() function to draw all visible regions.

Parameters
portThe CGraphicsPort to draw to.
See also
redraw()

Reimplemented from NXWidgets::CButton.

Definition at line 358 of file ccyclebutton.cxx.

◆ drawContents()

void CCycleButton::drawContents ( CGraphicsPort port)
protectedvirtual

Draw the area of this widget that falls within the clipping region. Called by the redraw() function to draw all visible regions.

Parameters
portThe CGraphicsPort to draw to.
See also
redraw()

Reimplemented from NXWidgets::CButton.

Definition at line 305 of file ccyclebutton.cxx.

◆ drawOutline()

void CCycleButton::drawOutline ( CGraphicsPort port)
protectedvirtual

Draws the outline of the button.

Parameters
portGraphics port to draw to.

Reimplemented from NXWidgets::CButton.

Definition at line 388 of file ccyclebutton.cxx.

◆ getOption()

virtual const CListDataItem* NXWidgets::CCycleButton::getOption ( const int  index)
inlinevirtual

Get the specified option.

Returns
The specified option.

Definition at line 291 of file ccyclebutton.hxx.

◆ getOptionCount()

virtual const int NXWidgets::CCycleButton::getOptionCount ( void  ) const
inlinevirtual

Get the total number of options.

Returns
The number of options.

Definition at line 308 of file ccyclebutton.hxx.

◆ getPreferredDimensions()

void CCycleButton::getPreferredDimensions ( CRect rect) const
virtual

Insert the dimensions that this widget wants to have into the rect passed in as a parameter. All coordinates are relative to the widget's parent. Value is based on the length of the largest string in the set of options.

Parameters
rectReference to a rect to populate with data.

Reimplemented from NXWidgets::CLabel.

Definition at line 258 of file ccyclebutton.cxx.

◆ getSelectedIndex()

const int CCycleButton::getSelectedIndex ( void  ) const
virtual

Get the selected index. Returns -1 if nothing is selected. If more than one option is selected, the index of the first selected option is returned.

Returns
The selected index.

Definition at line 188 of file ccyclebutton.cxx.

◆ getSelectedOption()

const CListDataItem * CCycleButton::getSelectedOption ( void  ) const
virtual

Get the selected option. Returns NULL if nothing is selected.

Returns
The selected option.

Definition at line 212 of file ccyclebutton.cxx.

◆ getValue()

const uint32_t NXWidgets::CCycleButton::getValue ( void  ) const
inline

Get the value of the current option.

Returns
Value of the current option.

Definition at line 280 of file ccyclebutton.hxx.

◆ handleListDataChangedEvent()

void CCycleButton::handleListDataChangedEvent ( const CListDataEventArgs e)
virtual

Handles list data changed events.

Parameters
eEvent arguments.

Implements NXWidgets::IListDataEventHandler.

Definition at line 232 of file ccyclebutton.cxx.

◆ handleListDataSelectionChangedEvent()

void CCycleButton::handleListDataSelectionChangedEvent ( const CListDataEventArgs e)
virtual

Handles list selection changed events.

Parameters
eEvent arguments.

Implements NXWidgets::IListDataEventHandler.

Definition at line 243 of file ccyclebutton.cxx.

◆ onPreRelease()

void CCycleButton::onPreRelease ( nxgl_coord_t  x,
nxgl_coord_t  y 
)
protectedvirtual

Selects the next option in the list and redraws the button.

Parameters
xThe x coordinate of the mouse.
yThe y coordinate of the mouse.

Reimplemented from NXWidgets::CButton.

Definition at line 427 of file ccyclebutton.cxx.

◆ onReleaseOutside()

void CCycleButton::onReleaseOutside ( nxgl_coord_t  x,
nxgl_coord_t  y 
)
protectedvirtual

Redraws the button.

Parameters
xThe x coordinate of the mouse.
yThe y coordinate of the mouse.

Reimplemented from NXWidgets::CButton.

Definition at line 461 of file ccyclebutton.cxx.

◆ onResize()

virtual void NXWidgets::CCycleButton::onResize ( nxgl_coord_t  width,
nxgl_coord_t  height 
)
inlineprotectedvirtual

Prevents the CButton onResize() method from recalculating the text positions by overriding it.

Parameters
widthThe new width.
heightThe new height.

Reimplemented from NXWidgets::CLabel.

Definition at line 174 of file ccyclebutton.hxx.

◆ removeAllOptions()

void CCycleButton::removeAllOptions ( void  )
virtual

Remove all options from the widget.

Definition at line 164 of file ccyclebutton.cxx.

◆ removeOption()

void CCycleButton::removeOption ( const int  index)
virtual

Remove an option from the widget by its index.

Parameters
indexThe index of the option to remove.

Definition at line 155 of file ccyclebutton.cxx.

◆ selectOption()

void CCycleButton::selectOption ( const int  index)
virtual

Select an option by its index. Redraws the widget and raises a value changed event.

Parameters
indexThe index of the option to select.

Definition at line 176 of file ccyclebutton.cxx.

◆ setSelectedIndex()

void CCycleButton::setSelectedIndex ( const int  index)
virtual

Sets the selected index. Specify -1 to select nothing. Resets any other selected options to deselected. Redraws the widget and raises a value changed event.

Parameters
indexThe selected index.

Definition at line 201 of file ccyclebutton.cxx.

◆ setSortInsertedItems()

virtual void NXWidgets::CCycleButton::setSortInsertedItems ( const bool  sortInsertedItems)
inlinevirtual

Sets whether or not items added to the list are automatically sorted on insert or not.

Parameters
sortInsertedItemsTrue to enable sort on insertion.

Definition at line 320 of file ccyclebutton.hxx.

◆ sort()

void CCycleButton::sort ( void  )
virtual

Sort the options alphabetically by the text of the options.

Definition at line 221 of file ccyclebutton.cxx.

Member Data Documentation

◆ m_options

CListData NXWidgets::CCycleButton::m_options
protected

Option storage.

Definition at line 118 of file ccyclebutton.hxx.


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