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 
8 namespace 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
cwidget::widgets::transientlabel
Definition: label.h:74
cwidget::util::ref_ptr
Definition: ref_ptr.h:19
cwidget::widgets::label::width_request
int width_request()
Definition: label.cc:125
cwidget::widgets::point
Definition: widget.h:88
cwidget::fragment_cache
A fragment that caches its contents; a cached result is used if the same width is passed to the layou...
Definition: fragment_cache.h:34
toplevel.h
Routines to manage the global cwidget state.
cwidget::widgets::widget::destroy
virtual void destroy()
Destroys the visible representation of this widget and disconnects it from any children that it may h...
Definition: widget.cc:129
cwidget::widgets::label
label widgets display some (possibly formatted) text statically.
Definition: label.h:24
cwidget::style
A "style" is a setting to be applied to a display element (widget, text, etc).
Definition: style.h:51
cwidget::fragment
A fragment represents a logical unit of text.
Definition: fragment.h:37
cwidget::toplevel::queuelayout
void queuelayout()
Posts a request to recalculate every widget's layout and update the screen.
Definition: toplevel.cc:1093
cwidget::widgets::size
Definition: widget.h:82
cwidget::widgets::label::paint
void paint(const style &st)
Display this widget.
Definition: label.cc:117
cwidget::fragment_contents
This class represents the formatted contents of a fragment.
Definition: fragment_contents.h:30
cwidget::widgets::label::height_request
int height_request(int width)
Definition: label.cc:130
colors.h
Routines to support independently changing foreground and background colors.
cwidget
The namespace containing everything defined by cwidget.
Definition: columnify.cc:27
cwidget::widgets::widget
The basic widget interface.
Definition: widget.h:106
cwidget::widgets::widget::set_bg_style
void set_bg_style(const style &new_style)
Update this widget's basic style to the given value.
Definition: widget.cc:53