cwidget  0.5.16
toplevel.h
Go to the documentation of this file.
00001 // toplevel.h                          -*-c++-*-
00002 //
00003 //  Copyright 2000, 2005, 2007-2008 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 
00030 #ifndef TOPLEVEL_H
00031 #define TOPLEVEL_H
00032 
00033 #include <sigc++/signal.h>
00034 
00035 #include <cwidget/generic/util/ref_ptr.h>
00036 
00038 namespace cwidget
00039 {
00041   std::string version();
00042 
00043   namespace threads
00044   {
00045     class mutex;
00046   }
00047 
00048   namespace widgets
00049   {
00050     class widget;
00051   }
00052 
00061   namespace toplevel
00062   {
00066     class event
00067     {
00068     public:
00069       virtual void dispatch() = 0;
00070       virtual ~event();
00071     };
00072 
00082     class slot_event : public event
00083     {
00084       sigc::slot0<void> the_slot;
00085     public:
00086       slot_event(const sigc::slot0<void> &_the_slot)
00087         : the_slot(_the_slot)
00088       {
00089       }
00090 
00091       void dispatch();
00092     };
00093 
00097     void init();
00098 
00109     void install_sighandlers();
00110 
00116     util::ref_ptr<widgets::widget> settoplevel(const util::ref_ptr<widgets::widget> &widget);
00117 
00121     void queuelayout();
00122 
00124     void layoutnow();
00125 
00126     //   Main loop handlers:
00127 
00150     void mainloop(int synch=0);
00151 
00159     void post_event(event *ev);
00160 
00167     bool poll();
00168 
00169     void exitmain();
00170     // Exits the main loop.
00171 
00172     void redraw();
00173     // Redraws the screen completely from scratch
00174 
00176     void update();
00177 
00179     void tryupdate();
00180 
00184     void updatecursor();
00185 
00191     void suspend();
00192 
00197     void suspend_without_signals();
00198 
00203     void shutdown();
00204 
00208     void resume();
00209 
00216     int addtimeout(event *ev, int msecs);
00217 
00219     void deltimeout(int id);
00220 
00221     void handleresize();
00222     // Does anything needed to handle a window resize event.
00223     // FIXME: I --think-- that this is now redundant
00224 
00225     //  Return a mutex that is held whenever the main loop is processing
00226     //  events or drawing the screen.  The mutex can be held by other
00227     //  threads that want to do their own drawing or processing, although
00228     //  this is highly discouraged (use the event posting system instead
00229     //  to run code in the main loop).
00230     threads::mutex &get_mutex();
00231 
00242     int get_suspend_count();
00243 
00244     extern sigc::signal0<void> main_hook;
00245     // Called right after we finish handling input in the mainloop.  Can
00246     // be used (eg) to insert extra actions to be performed after all
00247     // user-input (aptitude uses this to check for apt errors and pop up a
00248     // message about them)
00249   }
00250 }
00251 
00252 #endif