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

#include <clabel.hxx>

Inheritance diagram for NXWidgets::CLabel:
Inheritance graph

Public Types

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
}
 

Public Member Functions

 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 getPreferredDimensions (CRect &rect) 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)
 

Protected Member Functions

virtual void drawContents (CGraphicsPort *port)
 
virtual void drawBorder (CGraphicsPort *port)
 
virtual void onResize (nxgl_coord_t width, nxgl_coord_t height)
 
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 onClick (nxgl_coord_t x, nxgl_coord_t y)
 
virtual void onDoubleClick (nxgl_coord_t x, nxgl_coord_t y)
 
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 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

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
 

Detailed Description

Single-line label widget. Can align text both vertically and horizontally in different ways.

Definition at line 112 of file clabel.hxx.

Member Enumeration Documentation

◆ TextAlignmentHoriz

enum NXWidgets::CLabel::TextAlignmentHoriz

Enum of horizontal alignment options.

Enumerator
TEXT_ALIGNMENT_HORIZ_CENTER 

Centre the text

TEXT_ALIGNMENT_HORIZ_LEFT 

Align left

TEXT_ALIGNMENT_HORIZ_RIGHT 

Align right

Definition at line 120 of file clabel.hxx.

◆ TextAlignmentVert

enum NXWidgets::CLabel::TextAlignmentVert

Enum of vertical alignment options.

Enumerator
TEXT_ALIGNMENT_VERT_CENTER 

Align to centre of textbox

TEXT_ALIGNMENT_VERT_TOP 

Align to top of textbox

TEXT_ALIGNMENT_VERT_BOTTOM 

Align to bottom of textbox

Definition at line 131 of file clabel.hxx.

Constructor & Destructor Documentation

◆ CLabel() [1/2]

NXWidgets::CLabel::CLabel ( const CLabel label)
inlineprotected

Copy constructor is protected to prevent usage.

Definition at line 200 of file clabel.hxx.

◆ CLabel() [2/2]

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 
)

Constructor for a label containing a string.

Parameters
pWidgetControlThe controlling widget for the display
xThe x coordinate of the text box, relative to its parent.
yThe y coordinate of the text box, relative to its parent.
widthThe width of the textbox.
heightThe height of the textbox.
textPointer to a string to display in the textbox.
styleThe style that the button should use. If this is not specified, the button will use the global default widget style.

Definition at line 110 of file clabel.cxx.

◆ ~CLabel()

virtual NXWidgets::CLabel::~CLabel ( )
inlinevirtual

Destructor.

Definition at line 226 of file clabel.hxx.

Member Function Documentation

◆ appendText()

void CLabel::appendText ( const CNxString text)
virtual

Append new text to the end of the current text displayed in the label.

Parameters
textString to append.

Reimplemented in NXWidgets::CTextBox.

Definition at line 184 of file clabel.cxx.

◆ calculateTextPositionHorizontal()

void CLabel::calculateTextPositionHorizontal ( void  )
protectedvirtual

Calculate the position of the string based on its length and the alignment options.

Reimplemented in NXWidgets::CTextBox.

Definition at line 421 of file clabel.cxx.

◆ calculateTextPositionVertical()

void CLabel::calculateTextPositionVertical ( void  )
protectedvirtual

Calculate the vertical position of the string based on the font

height and the alignment options.

Definition at line 393 of file clabel.cxx.

◆ drawBorder()

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

Reimplemented in NXWidgets::CTextBox, NXWidgets::CButton, NXWidgets::CCheckBox, NXWidgets::CCycleButton, and NXWidgets::CStickyButton.

Definition at line 361 of file clabel.cxx.

◆ drawContents()

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

Reimplemented in NXWidgets::CTextBox, NXWidgets::CButton, NXWidgets::CRadioButton, NXWidgets::CCheckBox, NXWidgets::CCycleButton, and NXWidgets::CStickyButton.

Definition at line 278 of file clabel.cxx.

◆ getPreferredDimensions()

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

Parameters
rectReference to a rect to populate with data.

Reimplemented from NXWidgets::CNxWidget.

Reimplemented in NXWidgets::CCycleButton.

Definition at line 226 of file clabel.cxx.

◆ getText()

virtual const CNxString& NXWidgets::CLabel::getText ( void  ) const
inlinevirtual

Returns the string shown in the label.

Returns
The label's text.

Definition at line 272 of file clabel.hxx.

◆ getTextAlignmentHoriz()

const TextAlignmentHoriz NXWidgets::CLabel::getTextAlignmentHoriz ( void  ) const
inline

Set the horizontal alignment of text within the label.

Parameters
alignmentThe horizontal position of the text.

Definition at line 250 of file clabel.hxx.

◆ getTextAlignmentVert()

const TextAlignmentVert NXWidgets::CLabel::getTextAlignmentVert ( void  ) const
inline

Set the vertical alignment of text within the label.

Parameters
alignmentThe vertical position of the text.

Definition at line 261 of file clabel.hxx.

◆ highlight()

void CLabel::highlight ( bool  highlightOn)
virtual

Control the highlight state.

Parameters
highlightOnTrue(1), the label will be highlighted

Definition at line 209 of file clabel.cxx.

◆ insertText()

void CLabel::insertText ( const CNxString text,
const int  index 
)
virtual

Insert text at the specified index.

Parameters
textThe text to insert.
indexIndex at which to insert the text.

Definition at line 197 of file clabel.cxx.

◆ isHighlighted()

virtual bool NXWidgets::CLabel::isHighlighted ( void  ) const
inlinevirtual

Return the current highlight state.

Returns
True if the label is highlighted

Definition at line 317 of file clabel.hxx.

◆ isTextChange()

virtual bool NXWidgets::CLabel::isTextChange ( void  ) const
inlinevirtual

Is the redraw due to a text-only change?

Returns
True if the redraw was caused by a text change

Definition at line 348 of file clabel.hxx.

◆ onResize()

void CLabel::onResize ( nxgl_coord_t  width,
nxgl_coord_t  height 
)
protectedvirtual

Resize the widget to the new dimensions.

Parameters
widthThe new width.
heightThe new height.

Reimplemented from NXWidgets::CNxWidget.

Reimplemented in NXWidgets::CCycleButton.

Definition at line 381 of file clabel.cxx.

◆ onTextChange()

void CLabel::onTextChange ( void  )
protectedvirtual

Updates the GUI after the text has changed.

Definition at line 448 of file clabel.cxx.

◆ setFont()

void CLabel::setFont ( CNxFont font)
virtual

Sets the font.

Parameters
fontA pointer to the font to use.

NOTE: This font is not deleted when the widget is destroyed!

Reimplemented from NXWidgets::CNxWidget.

Definition at line 259 of file clabel.cxx.

◆ setText()

void CLabel::setText ( const CNxString text)
virtual

Set the text displayed in the label.

Parameters
textString to display.

Reimplemented in NXWidgets::CTextBox.

Definition at line 171 of file clabel.cxx.

◆ setTextAlignmentHoriz()

void CLabel::setTextAlignmentHoriz ( TextAlignmentHoriz  alignment)
virtual

Set the horizontal alignment of text within the label.

Parameters
alignmentThe horizontal position of the text.

Definition at line 145 of file clabel.cxx.

◆ setTextAlignmentVert()

void CLabel::setTextAlignmentVert ( TextAlignmentVert  alignment)
virtual

Set the vertical alignment of text within the label.

Parameters
alignmentThe vertical position of the text.

Definition at line 158 of file clabel.cxx.

Member Data Documentation

◆ m_align

struct nxgl_point_s NXWidgets::CLabel::m_align
protected

X/Y offset for text alignment

Definition at line 140 of file clabel.hxx.

◆ m_hAlignment

TextAlignmentHoriz NXWidgets::CLabel::m_hAlignment
protected

Horizontal alignment of the text

Definition at line 141 of file clabel.hxx.

◆ m_highlighted

bool NXWidgets::CLabel::m_highlighted
protected

Label is highlighted

Definition at line 144 of file clabel.hxx.

◆ m_text

CNxString NXWidgets::CLabel::m_text
protected

Text that the textbox will display

Definition at line 139 of file clabel.hxx.

◆ m_textChange

bool NXWidgets::CLabel::m_textChange
protected

Redraw is due to a text change

Definition at line 143 of file clabel.hxx.

◆ m_vAlignment

TextAlignmentVert NXWidgets::CLabel::m_vAlignment
protected

Vertical alignment of the text

Definition at line 142 of file clabel.hxx.


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