cwidget 0.5.16
|
00001 // minibuf_win.h -*-c++-*- 00002 // 00003 // Copyright 2000-2001, 2004-2005 Daniel Burrows 00004 // 00005 // This program is free software; you can redistribute it and/or modify 00006 // it under the terms of the GNU General Public License as published by 00007 // the Free Software Foundation; either version 2 of the License, or 00008 // (at your option) any later version. 00009 // 00010 // This program is distributed in the hope that it will be useful, 00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 // GNU General Public License for more details. 00014 // 00015 // You should have received a copy of the GNU General Public License 00016 // along with this program; see the file COPYING. If not, write to 00017 // the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 00018 // Boston, MA 02111-1307, USA. 00019 // 00020 // Apologies for the lame name, but I couldn't think of anything else. 00021 // 00022 // This class provides basic support for a common UI theme: a widget with a 00023 // header and status line, where the status line can contain various widgets 00024 // for getting input, displaying messages, etc. (the header line will probably 00025 // vanish in the future) 00026 00027 #ifndef MINIBUF_WIN_H 00028 #define MINIBUF_WIN_H 00029 00030 #include <cwidget/style.h> 00031 00032 #include "passthrough.h" 00033 #include "widget.h" 00034 00035 #include <list> 00036 00037 #include <sigc++/connection.h> 00038 00039 namespace cwidget 00040 { 00041 namespace widgets 00042 { 00043 class minibuf; 00044 class label; 00045 class multiplex; 00046 00047 class minibuf_win:public passthrough 00048 { 00049 util::ref_ptr<label> status_lbl, header; 00050 00051 widget_ref main_widget; 00052 // This is displayed in the center of the screen. 00053 00054 util::ref_ptr<multiplex> status; 00055 00056 sigc::connection main_destroy_conn; 00057 00058 protected: 00059 minibuf_win(); 00060 public: 00061 static 00062 util::ref_ptr<minibuf_win> create() 00063 { 00064 util::ref_ptr<minibuf_win> rval = new minibuf_win; 00065 rval->decref(); 00066 return rval; 00067 } 00068 00069 ~minibuf_win(); 00070 00071 void destroy(); 00072 00073 void set_main_widget(const widget_ref &w); 00074 00075 int width_request(); 00076 int height_request(int w); 00077 void layout_me(); 00078 00079 virtual void paint(const style &st); 00080 00081 void show_header(); 00082 void show_status(); 00083 // Should mainly be used if it's necessary to force an update of the status 00084 // line 00085 00086 void set_status(std::string new_status); 00087 void set_header(std::string new_header); 00088 // Set the status and header lines of the window, respectively. 00089 // These routines do NOT call refresh()! 00090 00091 widget_ref get_focus(); 00092 00093 static const style &retr_header_style() {return get_style("Header");} 00094 static const style &retr_status_style() {return get_style("Status");} 00095 void display_error(std::string err); 00096 00097 void add_widget(const widget_ref &widget); 00098 // Adds a widget. Widgets are automatically shown if they're the first 00099 // one to be added, otherwise show() should be called. 00100 void rem_widget(const widget_ref &widget); 00101 // Removes a widget 00102 00103 void show_all(); 00104 }; 00105 00106 typedef util::ref_ptr<minibuf_win> minibuf_win_ref; 00107 } 00108 } 00109 00110 #endif