cwidget  0.5.16
toplevel.h
Go to the documentation of this file.
1 // toplevel.h -*-c++-*-
2 //
3 // Copyright 2000, 2005, 2007-2008 Daniel Burrows
4 //
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 2 of the License, or
8 // (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with this program; see the file COPYING. If not, write to
17 // the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 // Boston, MA 02111-1307, USA.
19 //
20 
30 #ifndef TOPLEVEL_H
31 #define TOPLEVEL_H
32 
33 #include <sigc++/signal.h>
34 
35 #include <cwidget/generic/util/ref_ptr.h>
36 
38 namespace cwidget
39 {
41  std::string version();
42 
43  namespace threads
44  {
45  class mutex;
46  }
47 
48  namespace widgets
49  {
50  class widget;
51  }
52 
61  namespace toplevel
62  {
66  class event
67  {
68  public:
69  virtual void dispatch() = 0;
70  virtual ~event();
71  };
72 
82  class slot_event : public event
83  {
84  sigc::slot0<void> the_slot;
85  public:
86  slot_event(const sigc::slot0<void> &_the_slot)
87  : the_slot(_the_slot)
88  {
89  }
90 
91  void dispatch();
92  };
93 
97  void init();
98 
109  void install_sighandlers();
110 
117 
121  void queuelayout();
122 
124  void layoutnow();
125 
126  // Main loop handlers:
127 
150  void mainloop(int synch=0);
151 
159  void post_event(event *ev);
160 
167  bool poll();
168 
169  void exitmain();
170  // Exits the main loop.
171 
172  void redraw();
173  // Redraws the screen completely from scratch
174 
176  void update();
177 
179  void tryupdate();
180 
184  void updatecursor();
185 
191  void suspend();
192 
198 
203  void shutdown();
204 
208  void resume();
209 
216  int addtimeout(event *ev, int msecs);
217 
219  void deltimeout(int id);
220 
221  void handleresize();
222  // Does anything needed to handle a window resize event.
223  // FIXME: I --think-- that this is now redundant
224 
225  // Return a mutex that is held whenever the main loop is processing
226  // events or drawing the screen. The mutex can be held by other
227  // threads that want to do their own drawing or processing, although
228  // this is highly discouraged (use the event posting system instead
229  // to run code in the main loop).
230  threads::mutex &get_mutex();
231 
242  int get_suspend_count();
243 
244  extern sigc::signal0<void> main_hook;
245  // Called right after we finish handling input in the mainloop. Can
246  // be used (eg) to insert extra actions to be performed after all
247  // user-input (aptitude uses this to check for apt errors and pop up a
248  // message about them)
249  }
250 }
251 
252 #endif