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

#include <clistbox.hxx>

Inheritance diagram for NXWidgets::CListBox:
Inheritance graph

Public Member Functions

 CListBox (CWidgetControl *pWidgetControl, nxgl_coord_t x, nxgl_coord_t y, nxgl_coord_t width, nxgl_coord_t height, CWidgetStyle *style=(CWidgetStyle *) NULL)
 
virtual ~CListBox (void)
 
virtual void addOption (const CNxString &text, const uint32_t value)
 
virtual void addOption (CListBoxDataItem *option)
 
virtual void removeOption (const int index)
 
virtual void removeAllOptions (void)
 
virtual void addOption (const CNxString &text, const uint32_t value, const nxwidget_pixel_t normalTextColor, const nxwidget_pixel_t normalBackColor, const nxwidget_pixel_t selectedTextColor, const nxwidget_pixel_t selectedBackColor)
 
virtual void selectOption (const int index)
 
virtual void deselectOption (const int index)
 
virtual void selectAllOptions (void)
 
virtual void deselectAllOptions (void)
 
virtual const int getSelectedIndex (void) const
 
virtual void setSelectedIndex (const int index)
 
virtual const CListBoxDataItemgetSelectedOption (void) const
 
virtual void setAllowMultipleSelections (const bool allowMultipleSelections)
 
virtual const bool allowsMultipleSelections (void) const
 
virtual void resizeCanvas (void)
 
virtual const CListBoxDataItemgetOption (const int index)
 
virtual void sort (void)
 
virtual const int getOptionCount (void) const
 
virtual const nxgl_coord_t getOptionHeight (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
 
virtual bool isDoubleClick (nxgl_coord_t x, nxgl_coord_t y)
 
- Public Member Functions inherited from NXWidgets::IListBox
virtual ~IListBox (void)
 
- Public Member Functions inherited from NXWidgets::CScrollingPanel
 CScrollingPanel (CWidgetControl *pWidgetControl, nxgl_coord_t x, nxgl_coord_t y, nxgl_coord_t width, nxgl_coord_t height, uint32_t flags, CWidgetStyle *style=(CWidgetStyle *) NULL)
 
virtual void scroll (int32_t dx, int32_t dy)
 
virtual void jump (int32_t x, int32_t y)
 
bool allowsVerticalScroll (void) const
 
bool allowsHorizontalScroll (void) const
 
virtual const int32_t getCanvasX (void) const
 
virtual const int32_t getCanvasY (void) const
 
virtual const int32_t getCanvasWidth (void) const
 
virtual const int32_t getCanvasHeight (void) const
 
void setAllowsVerticalScroll (bool allow)
 
void setAllowsHorizontalScroll (bool allow)
 
void setContentScrolled (bool scrolled)
 
bool IsContentScrolled (void)
 
virtual void setCanvasWidth (const int32_t width)
 
virtual void setCanvasHeight (const int32_t height)
 
- 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)
 
virtual void setFont (CNxFont *font)
 
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)
 
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::IScrollable
virtual ~IScrollable (void)
 
- 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 onClick (nxgl_coord_t x, nxgl_coord_t y)
 
virtual void onDoubleClick (nxgl_coord_t x, nxgl_coord_t y)
 
virtual void setOptionSelected (const int index, const bool selected)
 
 CListBox (const CListBox &listBox)
 
- Protected Member Functions inherited from NXWidgets::CScrollingPanel
virtual void onDrag (nxgl_coord_t x, nxgl_coord_t y, nxgl_coord_t vX, nxgl_coord_t vY)
 
void scrollChildren (int32_t dx, int32_t dy, bool do_redraw)
 
virtual ~CScrollingPanel (void)
 
 CScrollingPanel (const CScrollingPanel &scrollingPanel)
 
- 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 onPreRelease (nxgl_coord_t x, nxgl_coord_t y)
 
virtual void onRelease (nxgl_coord_t x, nxgl_coord_t y)
 
virtual void onReleaseOutside (nxgl_coord_t x, nxgl_coord_t y)
 
virtual void onDragStart (void)
 
virtual void onDragStop (void)
 
virtual void onFocus (void)
 
virtual void onBlur (void)
 
virtual void onEnable (void)
 
virtual void onDisable (void)
 
virtual void onResize (nxgl_coord_t width, nxgl_coord_t height)
 

Protected Attributes

CListData m_options
 
uint8_t m_optionPadding
 
int m_lastSelectedIndex
 
- Protected Attributes inherited from NXWidgets::CScrollingPanel
CWidgetControlm_widgetControl
 
int32_t m_canvasX
 
int32_t m_canvasY
 
int32_t m_canvasWidth
 
int32_t m_canvasHeight
 
bool m_allowVerticalScroll
 
bool m_allowHorizontalScroll
 
bool m_isContentScrolled
 
- 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::CNxWidget
enum  WidgetFlagType {
  WIDGET_BORDERLESS = 0x0001, WIDGET_DRAGGABLE = 0x0002, WIDGET_PERMEABLE = 0x0004, WIDGET_DOUBLE_CLICKABLE = 0x0008,
  WIDGET_NO_RAISE_EVENTS = 0x0010
}
 

Detailed Description

Class providing a scrollable list of options. The CListBox can be set up to only allow one selection or multiple selections. Processes double-clicks and raises double-click events, so that a double-click on an option can be made to automatically select and close a window/etc. The options themselves have user-definable text and background colors for their selected and unselected states.

Definition at line 113 of file clistbox.hxx.

Constructor & Destructor Documentation

◆ CListBox() [1/2]

NXWidgets::CListBox::CListBox ( const CListBox listBox)
inlineprotected

Copy constructor is protected to prevent usage.

Definition at line 175 of file clistbox.hxx.

◆ CListBox() [2/2]

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

Constructor.

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

Definition at line 109 of file clistbox.cxx.

◆ ~CListBox()

CListBox::~CListBox ( void  )
virtual

Destructor.

Definition at line 130 of file clistbox.cxx.

Member Function Documentation

◆ addOption() [1/3]

void CListBox::addOption ( const CNxString text,
const uint32_t  value 
)
virtual

Add a new option to the widget using default colors.

Parameters
textText to show in the option.
valueThe value of the option.

Implements NXWidgets::IListBox.

Definition at line 143 of file clistbox.cxx.

◆ addOption() [2/3]

void CListBox::addOption ( CListBoxDataItem option)
virtual

Add an option to the widget.

Parameters
optionThe option to add.

Implements NXWidgets::IListBox.

Definition at line 156 of file clistbox.cxx.

◆ addOption() [3/3]

void CListBox::addOption ( const CNxString text,
const uint32_t  value,
const nxwidget_pixel_t  normalTextColor,
const nxwidget_pixel_t  normalBackColor,
const nxwidget_pixel_t  selectedTextColor,
const nxwidget_pixel_t  selectedBackColor 
)
virtual

Add a new option to the widget.

Parameters
textText to show in the option.
valueThe value of the option.
normalTextColorColor to draw the text with when not selected.
normalBackColorColor to draw the background with when not selected.
selectedTextColorColor to draw the text with when selected.
selectedBackColorColor to draw the background with when selected.

Implements NXWidgets::IListBox.

Definition at line 192 of file clistbox.cxx.

◆ allowsMultipleSelections()

virtual const bool NXWidgets::CListBox::allowsMultipleSelections ( void  ) const
inlinevirtual

Sets whether multiple selections are possible or not.

Returns
True if multiple selections are allowed.

Implements NXWidgets::IListBox.

Definition at line 331 of file clistbox.hxx.

◆ deselectAllOptions()

void CListBox::deselectAllOptions ( void  )
virtual

Deselect all options. Redraws the widget and raises a value changed event.

Implements NXWidgets::IListBox.

Definition at line 243 of file clistbox.cxx.

◆ deselectOption()

void CListBox::deselectOption ( const int  index)
virtual

De-select an option by its index. Redraws the widget and raises a value changed event.

Parameters
indexThe index of the option to select.

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

Parameters
indexThe index of the option to select.

Implements NXWidgets::IListBox.

Definition at line 222 of file clistbox.cxx.

◆ drawBorder()

void CListBox::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::CScrollingPanel.

Definition at line 582 of file clistbox.cxx.

◆ drawContents()

void CListBox::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::CScrollingPanel.

Definition at line 446 of file clistbox.cxx.

◆ getOption()

virtual const CListBoxDataItem* NXWidgets::CListBox::getOption ( const int  index)
inlinevirtual

Get the specified option.

Returns
The specified option.

Implements NXWidgets::IListBox.

Definition at line 348 of file clistbox.hxx.

◆ getOptionCount()

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

Get the total number of options.

Returns
The number of options.

Implements NXWidgets::IListBox.

Definition at line 365 of file clistbox.hxx.

◆ getOptionHeight()

const nxgl_coord_t CListBox::getOptionHeight ( void  ) const
virtual

Get the height of a single option.

Returns
The height of an option.

Implements NXWidgets::IListBox.

Definition at line 330 of file clistbox.cxx.

◆ getPreferredDimensions()

void CListBox::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::CNxWidget.

Definition at line 371 of file clistbox.cxx.

◆ getSelectedIndex()

const int CListBox::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.

Implements NXWidgets::IListBox.

Definition at line 256 of file clistbox.cxx.

◆ getSelectedOption()

const CListBoxDataItem * CListBox::getSelectedOption ( void  ) const
virtual

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

Returns
The selected option.

Implements NXWidgets::IListBox.

Definition at line 280 of file clistbox.cxx.

◆ handleListDataChangedEvent()

void CListBox::handleListDataChangedEvent ( const CListDataEventArgs e)
virtual

Handles list data changed events.

Parameters
eEvent arguments.

Implements NXWidgets::IListDataEventHandler.

Definition at line 341 of file clistbox.cxx.

◆ handleListDataSelectionChangedEvent()

void CListBox::handleListDataSelectionChangedEvent ( const CListDataEventArgs e)
virtual

Handles list selection changed events.

Parameters
eEvent arguments.

Implements NXWidgets::IListDataEventHandler.

Definition at line 356 of file clistbox.cxx.

◆ isDoubleClick()

bool CListBox::isDoubleClick ( nxgl_coord_t  x,
nxgl_coord_t  y 
)
virtual

Check if the click is a double-click.

Parameters
xX coordinate of the click.
yY coordinate of the click.
Returns
True if the click is a double-click.

Reimplemented from NXWidgets::CNxWidget.

Definition at line 416 of file clistbox.cxx.

◆ onClick()

void CListBox::onClick ( nxgl_coord_t  x,
nxgl_coord_t  y 
)
protectedvirtual

Determines which item was clicked and selects or deselects it as appropriate. Also starts the dragging system.

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

Reimplemented from NXWidgets::CScrollingPanel.

Definition at line 601 of file clistbox.cxx.

◆ onDoubleClick()

void CListBox::onDoubleClick ( nxgl_coord_t  x,
nxgl_coord_t  y 
)
protectedvirtual

Selects the clicked item and deselects all others.

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

Reimplemented from NXWidgets::CNxWidget.

Definition at line 640 of file clistbox.cxx.

◆ removeAllOptions()

void CListBox::removeAllOptions ( void  )
virtual

Remove all options from the widget.

Implements NXWidgets::IListBox.

Definition at line 176 of file clistbox.cxx.

◆ removeOption()

void CListBox::removeOption ( const int  index)
virtual

Remove an option from the widget by its index.

Parameters
indexThe index of the option to remove.

Implements NXWidgets::IListBox.

Definition at line 167 of file clistbox.cxx.

◆ resizeCanvas()

void CListBox::resizeCanvas ( void  )
virtual

Resize the scrolling canvas to encompass all options.

Definition at line 289 of file clistbox.cxx.

◆ selectAllOptions()

void CListBox::selectAllOptions ( void  )
virtual

Select all options. Does nothing if the listbox does not allow multiple selections. Redraws the widget and raises a value changed event.

Implements NXWidgets::IListBox.

Definition at line 233 of file clistbox.cxx.

◆ selectOption()

void CListBox::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.

Implements NXWidgets::IListBox.

Definition at line 210 of file clistbox.cxx.

◆ setAllowMultipleSelections()

virtual void NXWidgets::CListBox::setAllowMultipleSelections ( const bool  allowMultipleSelections)
inlinevirtual

Sets whether multiple selections are possible or not.

Parameters
allowMultipleSelectionsTrue to allow multiple selections.

Implements NXWidgets::IListBox.

Definition at line 320 of file clistbox.hxx.

◆ setOptionSelected()

void CListBox::setOptionSelected ( const int  index,
const bool  selected 
)
protectedvirtual

Select or deselect an option by its index. Does not deselect any other selected options. Set index to -1 to select nothing. Redraws the widget and raises a value changed event.

Parameters
indexThe index of the option to select.
selectedTrue to select the option, false to deselect it.

Definition at line 662 of file clistbox.cxx.

◆ setSelectedIndex()

void CListBox::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.

Implements NXWidgets::IListBox.

Definition at line 269 of file clistbox.cxx.

◆ setSortInsertedItems()

virtual void NXWidgets::CListBox::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.

Implements NXWidgets::IListBox.

Definition at line 384 of file clistbox.hxx.

◆ sort()

void CListBox::sort ( void  )
virtual

Sort the options alphabetically by the text of the options.

Implements NXWidgets::IListBox.

Definition at line 319 of file clistbox.cxx.

Member Data Documentation

◆ m_lastSelectedIndex

int NXWidgets::CListBox::m_lastSelectedIndex
protected

Index of the last option selected.

Definition at line 119 of file clistbox.hxx.

◆ m_optionPadding

uint8_t NXWidgets::CListBox::m_optionPadding
protected

Padding between options.

Definition at line 118 of file clistbox.hxx.

◆ m_options

CListData NXWidgets::CListBox::m_options
protected

Option storage.

Definition at line 117 of file clistbox.hxx.


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