cwidget 0.5.18
stacked.h
1// stacked.h -*-c++-*-
2//
3// Manages a set of overlapping widgets, displaying them in a consistent
4// order (it is possible to change the stacking order)
5//
6// The size of the widget is unrelated to the sizes of its components.
7// (why? why not size it in a more flexible way?)
8
9#ifndef STACKED_H
10#define STACKED_H
11
12#include "passthrough.h"
13
14#include <sigc++/connection.h>
15
16namespace cwidget
17{
18 namespace widgets
19 {
20 class stacked : public passthrough
21 {
22 // bleach, but we need somewhere to store the info on what the signals to
23 // disconnect are :(
24 struct child_info
25 {
26 widget_ref w;
27
28 sigc::connection shown_conn, hidden_conn;
29
30 child_info(const widget_ref &_w,
31 sigc::connection &_shown_conn,
32 sigc::connection &_hidden_conn)
33 :w(_w), shown_conn(_shown_conn),
34 hidden_conn(_hidden_conn)
35 {
36 }
37 };
38
39 typedef std::list<child_info> childlist;
40
41 childlist children;
42
43 int req_w, req_h;
44
45 void layout_me();
46
47 void hide_widget();
48 protected:
49 void paint(const style &st);
50
51 // The size passed in is used as a preferred size. (what we get might be
52 // larger or smaller)
53 stacked(int w, int h);
54 public:
55 ~stacked();
56
57 void destroy();
58
59 static util::ref_ptr<stacked> create(int w=0, int h=0)
60 {
61 util::ref_ptr<stacked> rval(new stacked(w, h));
62 rval->decref();
63 return rval;
64 }
65
66 void add_widget(const widget_ref &w);
67 void rem_widget(const widget_ref &w);
68 void raise_widget(const widget_ref &w);
69 void lower_widget(const widget_ref &w);
70
71 void raise_widget_bare(widget &w)
72 {
73 raise_widget(widget_ref(&w));
74 }
75 void lower_widget_bare(widget &w)
76 {
77 lower_widget(widget_ref(&w));
78 }
79
80 void dispatch_mouse(short id, int x, int y, int z, mmask_t bstate);
81
82 widget_ref get_focus();
83
84 void show_all();
85
86 int width_request();
87 int height_request(int w);
88 };
89
91 }
92}
93
94#endif
A "style" is a setting to be applied to a display element (widget, text, etc).
Definition: style.h:52
Definition: passthrough.h:16
Definition: stacked.h:21
void destroy()
Destroys the visible representation of this widget and disconnects it from any children that it may h...
Definition: stacked.cc:24
int width_request()
Definition: stacked.cc:190
void paint(const style &st)
Display this widget.
Definition: stacked.cc:128
void show_all()
Display this widget and all its subwidgets.
Definition: stacked.cc:170
int height_request(int w)
Calculate the desired height of the widget, given its width.
Definition: stacked.cc:195
The basic widget interface.
Definition: widget.h:107
The namespace containing everything defined by cwidget.
Definition: columnify.cc:28