cwidget
0.5.16
|
00001 // stacked.h -*-c++-*- 00002 // 00003 // Manages a set of overlapping widgets, displaying them in a consistent 00004 // order (it is possible to change the stacking order) 00005 // 00006 // The size of the widget is unrelated to the sizes of its components. 00007 // (why? why not size it in a more flexible way?) 00008 00009 #ifndef STACKED_H 00010 #define STACKED_H 00011 00012 #include "passthrough.h" 00013 00014 #include <sigc++/connection.h> 00015 00016 namespace cwidget 00017 { 00018 namespace widgets 00019 { 00020 class stacked : public passthrough 00021 { 00022 // bleach, but we need somewhere to store the info on what the signals to 00023 // disconnect are :( 00024 struct child_info 00025 { 00026 widget_ref w; 00027 00028 sigc::connection shown_conn, hidden_conn; 00029 00030 child_info(const widget_ref &_w, 00031 sigc::connection &_shown_conn, 00032 sigc::connection &_hidden_conn) 00033 :w(_w), shown_conn(_shown_conn), 00034 hidden_conn(_hidden_conn) 00035 { 00036 } 00037 }; 00038 00039 typedef std::list<child_info> childlist; 00040 00041 childlist children; 00042 00043 int req_w, req_h; 00044 00045 void layout_me(); 00046 00047 void hide_widget(); 00048 protected: 00049 void paint(const style &st); 00050 00051 // The size passed in is used as a preferred size. (what we get might be 00052 // larger or smaller) 00053 stacked(int w, int h); 00054 public: 00055 ~stacked(); 00056 00057 void destroy(); 00058 00059 static util::ref_ptr<stacked> create(int w=0, int h=0) 00060 { 00061 util::ref_ptr<stacked> rval(new stacked(w, h)); 00062 rval->decref(); 00063 return rval; 00064 } 00065 00066 void add_widget(const widget_ref &w); 00067 void rem_widget(const widget_ref &w); 00068 void raise_widget(const widget_ref &w); 00069 void lower_widget(const widget_ref &w); 00070 00071 void raise_widget_bare(widget &w) 00072 { 00073 raise_widget(widget_ref(&w)); 00074 } 00075 void lower_widget_bare(widget &w) 00076 { 00077 lower_widget(widget_ref(&w)); 00078 } 00079 00080 void dispatch_mouse(short id, int x, int y, int z, mmask_t bstate); 00081 00082 widget_ref get_focus(); 00083 00084 void show_all(); 00085 00086 int width_request(); 00087 int height_request(int w); 00088 }; 00089 00090 typedef util::ref_ptr<stacked> stacked_ref; 00091 } 00092 } 00093 00094 #endif