• Main Page
  • Related Pages
  • Classes
  • Files
  • File List
  • File Members

win_event.cc

00001 /*
00002    $Id: win_event.cc,v 1.5 2002/12/16 19:09:54 ksterker Exp $
00003 
00004    (C) Copyright 2001 Joel Vennin
00005    Part of the Adonthell Project http://adonthell.linuxgames.com
00006 
00007    This program is free software; you can redistribute it and/or modify
00008    it under the terms of the GNU General Public License.
00009    This program is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY.
00011 
00012    See the COPYING file for more details
00013 */
00014 
00015 
00016 #include "win_event.h"
00017 #include "py_callback.h"
00018 
00019 
00020 void win_event::py_signal_connect (PyObject *pyfunc, int signal, PyObject *args) 
00021 {
00022     // create the callback
00023     py_callback *callback = new py_callback (pyfunc, args);
00024     py_callbacks.push_back (callback);
00025 
00026     // connect the signal
00027     switch (signal)
00028     {
00029         case CLOSE:
00030         {
00031             set_callback_quit (makeFunctor (*callback, &py_callback::callback_func1));
00032             break;
00033         }
00034     
00035         case DESTROY:
00036         {
00037             set_callback_destroy (
00038             makeFunctor (&Functor0wRet<bool>(), *callback, &py_callback::callback_func0ret));
00039             break;
00040         }
00041     
00042         default:
00043         {
00044             set_signal_connect (makeFunctor (*callback, &py_callback::callback_func0), signal);
00045         }
00046     }
00047 }
00048   
00049 
00050 bool win_event::update()
00051 {
00052   if(callback_destroy_ && !callback_destroy_()) return false;
00053   return true;
00054 }
00055 
00056 
00057 win_event::~win_event()
00058 {
00059   //notify that window is closing 
00060   if (callback_quit_) (callback_quit_) (return_code_);
00061   
00062   //delete any python callbacks
00063   for (vector<py_callback *>::iterator i = py_callbacks.begin (); i != py_callbacks.end (); i++)
00064     delete *i;
00065 }
00066 
00067 
00068 
00069 
00070 
00071 

Generated on Tue Jul 27 2010 for Adonthell by  doxygen 1.7.1