cwidget 0.5.16

container.h

00001 // container.h              -*-c++-*-
00002 //
00003 //
00004 //   Copyright (C) 2000, 2005 Daniel Burrows
00005 //
00006 //   This program is free software; you can redistribute it and/or
00007 //   modify it under the terms of the GNU General Public License as
00008 //   published by the Free Software Foundation; either version 2 of
00009 //   the License, or (at your option) any later version.
00010 //
00011 //   This program is distributed in the hope that it will be useful,
00012 //   but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 //   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 //   General Public License for more details.
00015 //
00016 //   You should have received a copy of the GNU General Public License
00017 //   along with this program; see the file COPYING.  If not, write to
00018 //   the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00019 //   Boston, MA 02111-1307, USA.
00020 //
00021 //  A generic interface for a widget that can hold other widgets.
00022 
00023 #ifndef CONTAINER_H
00024 #define CONTAINER_H
00025 
00026 #include "widget.h"
00027 
00028 namespace cwidget
00029 {
00030   namespace widgets
00031   {
00032     class container : public widget
00033     {
00034     public:
00035       container() : widget() {}
00036       ~container();
00037 
00038       virtual void add_widget(const widget_ref &)=0;
00039       void add_visible_widget(const widget_ref &, bool visible);
00040       virtual void rem_widget(const widget_ref &)=0;
00041 
00042       // Variants of the above that take a bare reference; used for weak
00043       // slot connections.
00044       void add_widget_bare(widget &w)
00045       {
00046         add_widget(widget_ref(&w));
00047       }
00048 
00049       void add_visible_widget_bare(widget &w, bool visible)
00050       {
00051         add_visible_widget(widget_ref(&w), visible);
00052       }
00053 
00054       void rem_widget_bare(widget &w)
00055       {
00056         rem_widget(widget_ref(&w));
00057       }
00058 
00060       virtual widget_ref get_active_widget() = 0;
00061 
00063       virtual void show_all()=0;
00064     };
00065   }
00066 }
00067 
00068 #endif