Adonthell  0.4
win_event.cc
1 /*
2  $Id: win_event.cc,v 1.6 2011/02/11 20:50:27 ksterker Exp $
3 
4  (C) Copyright 2001 Joel Vennin
5  Part of the Adonthell Project http://adonthell.linuxgames.com
6 
7  This program is free software; you can redistribute it and/or modify
8  it under the terms of the GNU General Public License.
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY.
11 
12  See the COPYING file for more details
13 */
14 
15 
16 #include "win_event.h"
17 #include "py_callback.h"
18 
19 
20 void win_event::py_signal_connect (PyObject *pyfunc, int signal, PyObject *args)
21 {
22  // create the callback
23  py_callback *callback = new py_callback (pyfunc, args);
24  py_callbacks.push_back (callback);
25 
26  // connect the signal
27  switch (signal)
28  {
29  case CLOSE:
30  {
31  set_callback_quit (makeFunctor (*callback, &py_callback::callback_func1));
32  break;
33  }
34 
35  case DESTROY:
36  {
37  Functor0wRet<bool> func0ret;
38  set_callback_destroy (
39  makeFunctor (&func0ret, *callback, &py_callback::callback_func0ret));
40  break;
41  }
42 
43  default:
44  {
45  set_signal_connect (makeFunctor (*callback, &py_callback::callback_func0), signal);
46  }
47  }
48 }
49 
50 
51 bool win_event::update()
52 {
53  if(callback_destroy_ && !callback_destroy_()) return false;
54  return true;
55 }
56 
57 
58 win_event::~win_event()
59 {
60  //notify that window is closing
61  if (callback_quit_) (callback_quit_) (return_code_);
62 
63  //delete any python callbacks
64  for (vector<py_callback *>::iterator i = py_callbacks.begin (); i != py_callbacks.end (); i++)
65  delete *i;
66 }
67 
68 
69 
70 
71 
72