cxWidgets 1.0
cxLabel.h
Go to the documentation of this file.
1// Copyright (c) 2026 E. Oulashin
2#ifndef __CXLABEL_H__
3#define __CXLABEL_H__
4
5// cxLabel: A non-editable text display widget derived from cxWindow.
6// This widget displays static text and does not accept user input.
7
8#include "cxWindow.h"
9#include <string>
10
11namespace cx {
12
17class cxLabel : public cxWindow
18{
19 public:
20
31 explicit cxLabel(cxWindow *pParentWindow = nullptr,
32 int pRow = 0, int pCol = 0,
33 int pWidth = 10,
34 const std::string& pText = "",
35 eBorderStyle pBorderStyle = eBS_NOBORDER);
36
40 cxLabel(const cxLabel& pThatLabel);
41
45 virtual ~cxLabel();
46
47 // Overridden virtual functions from cxWindow
48
49 virtual long show(bool pBringToTop = false, bool pShowSubwindows = false) override;
50 virtual long showModal(bool pShowSelf = true, bool pBringToTop = true, bool pShowSubwindows = false) override;
51 virtual bool modalGetsKeypress() const override;
52 virtual void draw() override;
53 virtual bool move(int pNewRow, int pNewCol, bool pRefresh = true) override;
54 virtual void resize(int pNewHeight, int pNewWidth, bool pRefresh = true) override;
55 virtual void clear(bool pRefresh = false) override;
56 virtual std::string cxTypeStr() const override;
57
58 // Label-specific functions
59
64 virtual std::string getText() const;
65
71 virtual void setText(const std::string& pText, bool pRefresh = false);
72
73 private:
74 std::string mText; // The text displayed by the label
75};
76
77} // namespace cx
78
79#endif // __CXLABEL_H__
This is a class for displaying a read-only label.
Definition cxLabel.h:18
virtual long showModal(bool pShowSelf=true, bool pBringToTop=true, bool pShowSubwindows=false) override
Shows the window and waits for input.
Definition cxLabel.cpp:44
virtual std::string getText() const
Gets the label text.
Definition cxLabel.cpp:82
virtual std::string cxTypeStr() const override
Returns the name of the cxWidgets class. This is overridden.
Definition cxLabel.cpp:77
virtual bool modalGetsKeypress() const override
Returns whether or not a call to showModal() will wait for a.
Definition cxLabel.cpp:51
virtual void resize(int pNewHeight, int pNewWidth, bool pRefresh=true) override
Changes the window's width and height. The window's upper-left.
Definition cxLabel.cpp:67
virtual long show(bool pBringToTop=false, bool pShowSubwindows=false) override
Shows the window.
Definition cxLabel.cpp:36
virtual bool move(int pNewRow, int pNewCol, bool pRefresh=true) override
Changes the window's position, based on a new upper-left corner.
Definition cxLabel.cpp:62
virtual void setText(const std::string &pText, bool pRefresh=false)
Sets the label text.
Definition cxLabel.cpp:87
virtual ~cxLabel()
Destructor.
Definition cxLabel.cpp:32
virtual void clear(bool pRefresh=false) override
Clears the text from the window.
Definition cxLabel.cpp:72
cxLabel(cxWindow *pParentWindow=nullptr, int pRow=0, int pCol=0, int pWidth=10, const std::string &pText="", eBorderStyle pBorderStyle=eBS_NOBORDER)
Constructor.
virtual void draw() override
Fills the member ncurses window structure with the current.
Definition cxLabel.cpp:56
Represents a text-based window on the screen. Can contain a title, status, and a message to appear wi...
Definition cxWindow.h:195
cxBorderChars.h - Defines border characters to be used in drawing a box (i.e., in cxWindow and all it...
Definition cxApp.cpp:5
eBorderStyle
Definition cxBorderStyles.h:26
@ eBS_NOBORDER
Definition cxBorderStyles.h:27