cwidget 0.5.16
bin.h
00001 // bin.h        -*-c++-*-
00002 //
00003 //  Generic stuff for a container that can only handle one child.
00004 
00005 #ifndef BIN_H
00006 #define BIN_H
00007 
00008 #include "passthrough.h"
00009 
00010 #include <sigc++/connection.h>
00011 
00012 namespace cwidget
00013 {
00014   namespace widgets
00015   {
00016     class bin : public passthrough
00017     {
00018       widget_ref subwidget;
00019 
00020       // These are unfortunate necessities; when a widget is /removed/
00021       // (but not destroyed), it is necessary to delete the connections to
00022       // it.  :-(
00023       sigc::connection show_conn, hide_conn;
00024 
00025       // right now these just show or hide the bin itself
00026       void show_widget(const widget_ref &w);
00027       void hide_widget(const widget_ref &w);
00028 
00029       void show_widget_bare(widget &w);
00030       void hide_widget_bare(widget &w);
00031 
00032     protected:
00033       bin();
00034 
00035     public:
00036       virtual ~bin();
00037 
00038       void set_subwidget(const util::ref_ptr<widget> &w);
00039       void set_subwidget(widget &w)
00040       {
00041         set_subwidget(util::ref_ptr<widget>(&w));
00042       }
00043 
00044       widget_ref get_subwidget() {return subwidget;}
00045 
00046       void destroy();
00047 
00048       virtual void show_all();
00049 
00050       virtual void add_widget(const widget_ref &w);
00051       virtual void rem_widget(const widget_ref &w);
00052 
00053       widget_ref get_focus();
00054 
00055       void paint(const style &st);
00056     };
00057   }
00058 }
00059 
00060 #endif