cwidget 0.5.18
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
38namespace 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
147 void mainloop();
148
156 void post_event(event *ev);
157
164 bool poll();
165
168 void exitmain();
169
172 void redraw();
173
175 void update();
176
178 void tryupdate();
179
183 void updatecursor();
184
190 void suspend();
191
197
202 void shutdown();
203
207 void resume();
208
215 int addtimeout(event *ev, int msecs);
216
218 void deltimeout(int id);
219
220 void handleresize();
221 // Does anything needed to handle a window resize event.
222 // FIXME: I --think-- that this is now redundant
223
224 // Return a mutex that is held whenever the main loop is processing
225 // events or drawing the screen. The mutex can be held by other
226 // threads that want to do their own drawing or processing, although
227 // this is highly discouraged (use the event posting system instead
228 // to run code in the main loop).
229 threads::mutex &get_mutex();
230
241 int get_suspend_count();
242
243 extern sigc::signal0<void> main_hook;
244 // Called right after we finish handling input in the mainloop. Can
245 // be used (eg) to insert extra actions to be performed after all
246 // user-input (aptitude uses this to check for apt errors and pop up a
247 // message about them)
248 }
249}
250
251#endif
Definition: threads.h:237
An event in the global event queue.
Definition: toplevel.h:67
An event based on sigc++ slots.
Definition: toplevel.h:83
Definition: ref_ptr.h:20
The basic widget interface.
Definition: widget.h:107
void queuelayout()
Posts a request to recalculate every widget's layout and update the screen.
Definition: toplevel.cc:1093
void shutdown()
Does the same thing as suspend, except that it also destroys the top-level widget.
Definition: toplevel.cc:1231
void redraw()
Redraws the screen completely from scratch.
Definition: toplevel.cc:1274
void suspend()
Hides all widgets and suspends Curses operation until resume() is called.
Definition: toplevel.cc:1213
int get_suspend_count()
Definition: toplevel.cc:86
void deltimeout(int num)
Delete the event with the given identifier.
Definition: toplevel.cc:1308
void post_event(event *ev)
Post the given event to the main event queue.
Definition: toplevel.cc:229
void mainloop()
Start the main event loop.
Definition: toplevel.cc:1155
void update()
Posts a request to redraw the screen; may be called from any thread.
Definition: toplevel.cc:1072
bool poll()
Dispatch any events in the event queue.
Definition: toplevel.cc:1135
void install_sighandlers()
Installs signal handlers to cleanly shut down cwidget.
Definition: toplevel.cc:1022
void resume()
Returns to Curses mode after a suspend*, restoring any signal handlers that were modified by the susp...
Definition: toplevel.cc:1247
void init()
Initializes curses and the global state of the cwidget library.
Definition: toplevel.cc:854
void layoutnow()
Immediately recalculates the layout of all widgets.
Definition: toplevel.cc:1104
void updatecursor()
Posts a request to update the cursor location; may be called from any thread.
Definition: toplevel.cc:1050
void tryupdate()
Executes any pending draws or redraws.
Definition: toplevel.cc:1111
int addtimeout(event *ev, int msecs)
Invoke the given event in at least msecs from the current time.
Definition: toplevel.cc:1300
void exitmain()
Exits the main loop.
Definition: toplevel.cc:1188
void suspend_without_signals()
Hides all widgets and suspends Curses operation until resume() is called, but does NOT reset the SIGC...
Definition: toplevel.cc:1193
The namespace containing everything defined by cwidget.
Definition: columnify.cc:28
std::string version()
Return the version number of the library.
Definition: toplevel.cc:64