cwidget  0.5.17
minibuf_win.h
1 // minibuf_win.h -*-c++-*-
2 //
3 // Copyright 2000-2001, 2004-2005 Daniel Burrows
4 //
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 2 of the License, or
8 // (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with this program; see the file COPYING. If not, write to
17 // the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 // Boston, MA 02111-1307, USA.
19 //
20 // Apologies for the lame name, but I couldn't think of anything else.
21 //
22 // This class provides basic support for a common UI theme: a widget with a
23 // header and status line, where the status line can contain various widgets
24 // for getting input, displaying messages, etc. (the header line will probably
25 // vanish in the future)
26 
27 #ifndef MINIBUF_WIN_H
28 #define MINIBUF_WIN_H
29 
30 #include <cwidget/style.h>
31 
32 #include "passthrough.h"
33 #include "widget.h"
34 
35 #include <list>
36 
37 #include <sigc++/connection.h>
38 
39 namespace cwidget
40 {
41  namespace widgets
42  {
43  class minibuf;
44  class label;
45  class multiplex;
46 
47  class minibuf_win:public passthrough
48  {
49  util::ref_ptr<label> status_lbl, header;
50 
51  widget_ref main_widget;
52  // This is displayed in the center of the screen.
53 
55 
56  sigc::connection main_destroy_conn;
57 
58  protected:
59  minibuf_win();
60  public:
61  static
63  {
65  rval->decref();
66  return rval;
67  }
68 
69  ~minibuf_win();
70 
71  void destroy();
72 
73  void set_main_widget(const widget_ref &w);
74 
75  int width_request();
76  int height_request(int w);
77  void layout_me();
78 
79  virtual void paint(const style &st);
80 
81  void show_header();
82  void show_status();
83  // Should mainly be used if it's necessary to force an update of the status
84  // line
85 
86  void set_status(std::string new_status);
87  void set_header(std::string new_header);
88  // Set the status and header lines of the window, respectively.
89  // These routines do NOT call refresh()!
90 
91  widget_ref get_focus();
92 
93  static const style &retr_header_style() {return get_style("Header");}
94  static const style &retr_status_style() {return get_style("Status");}
95  void display_error(std::string err);
96 
97  void add_widget(const widget_ref &widget);
98  // Adds a widget. Widgets are automatically shown if they're the first
99  // one to be added, otherwise show() should be called.
100  void rem_widget(const widget_ref &widget);
101  // Removes a widget
102 
103  void show_all();
104  };
105 
107  }
108 }
109 
110 #endif
A "style" is a setting to be applied to a display element (widget, text, etc).
Definition: style.h:51
void show_all()
Display this widget and all its subwidgets.
Definition: minibuf_win.cc:211
Definition: ref_ptr.h:19
int width_request()
Definition: minibuf_win.cc:100
The namespace containing everything defined by cwidget.
Definition: columnify.cc:26
The basic widget interface.
Definition: widget.h:107
Definition: passthrough.h:15
virtual void paint(const style &st)
Display this widget.
Definition: minibuf_win.cc:146
int height_request(int w)
Calculate the desired height of the widget, given its width.
Definition: minibuf_win.cc:118
void destroy()
Destroys the visible representation of this widget and disconnects it from any children that it may h...
Definition: minibuf_win.cc:58
const style & get_style(const std::string &name)
Look up a style in the global registry.
Definition: style.cc:31
Definition: minibuf_win.h:47