cwidget 0.5.18
label.h
1// label.h -*-c++-*-
2
3#ifndef LABEL_H
4#define LABEL_H
5
6#include "widget.h"
7
8namespace cwidget
9{
10 class fragment;
11 class fragment_cache;
12
13 namespace widgets
14 {
24 class label : public widget
25 {
26 fragment_cache *txt;
27 protected:
28 label(fragment *f);
29 label(const std::string &_txt, const style &st);
30 label(const std::string &_txt);
31 label(const std::wstring &_txt, const style &st);
32 label(const std::wstring &_txt);
33
34 public:
35 static util::ref_ptr<label> create(fragment *f)
36 {
37 util::ref_ptr<label> rval(new label(f));
38 rval->decref();
39 return rval;
40 }
41
43 static util::ref_ptr<label> create(const std::string &txt, const style &st);
44
46 static util::ref_ptr<label> create(const std::string &txt);
47
49 static util::ref_ptr<label> create(const std::wstring &txt, const style &st);
50
52 static util::ref_ptr<label> create(const std::wstring &txt);
53
54
55 ~label();
56
57 bool get_cursorvisible();
58 point get_cursorloc();
59
61 int width_request();
62
64 int height_request(int width);
65
66 void paint(const style &st);
67 void set_text(const std::string &_txt, const style &st);
68 void set_text(const std::string &_txt);
69 void set_text(const std::wstring &_txt, const style &st);
70 void set_text(const std::wstring &_txt);
71 void set_text(fragment *f);
72 };
73
74 class transientlabel:public label
75 // Displays a transient message -- grabs the input focus and vanishes when a
76 // key is pressed.
77 {
78 protected:
79 virtual bool handle_char(chtype ch);
80
81 transientlabel(const std::string &msg, const style &st)
82 :label(msg, st)
83 {
84 }
85 public:
86 static
87 util::ref_ptr<transientlabel> create(const std::string &msg,
88 const style &st)
89 {
90 return new transientlabel(msg, st);
91 }
92
93 bool focus_me() {return true;}
94 };
95
97
99 }
100}
101
102#endif
A fragment that caches its contents; a cached result is used if the same width is passed to the layou...
Definition fragment_cache.h:35
A fragment represents a logical unit of text.
Definition fragment.h:38
A "style" is a setting to be applied to a display element (widget, text, etc).
Definition style.h:52
Definition ref_ptr.h:20
label widgets display some (possibly formatted) text statically.
Definition label.h:25
static util::ref_ptr< label > create(const std::string &txt, const style &st)
Create a label with the given text and background.
static util::ref_ptr< label > create(const std::wstring &txt)
CReate a label with the given text.
int height_request(int width)
Definition label.cc:130
void paint(const style &st)
Display this widget.
Definition label.cc:117
static util::ref_ptr< label > create(const std::string &txt)
Create a label with the given text.
int width_request()
Definition label.cc:125
static util::ref_ptr< label > create(const std::wstring &txt, const style &st)
Create a label with the given text and background.
The basic widget interface.
Definition widget.h:107
The namespace containing everything defined by cwidget.
Definition columnify.cc:28
Definition widget.h:89