Panda3D
|
00001 // Filename: customGraphicsWindowProc.cxx 00002 // Created by: Walt Destler (May 2010) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) Carnegie Mellon University. All rights reserved. 00008 // 00009 // All use of this software is subject to the terms of the revised BSD 00010 // license. You should have received a copy of this license along 00011 // with this source code in a file named "LICENSE." 00012 // 00013 //////////////////////////////////////////////////////////////////// 00014 00015 #include "pythonGraphicsWindowProc.h" 00016 #include "graphicsWindowProcCallbackData.h" 00017 00018 TypeHandle PythonGraphicsWindowProc::_type_handle; 00019 00020 //////////////////////////////////////////////////////////////////// 00021 // Function: PythonGraphicWindowProc::Constructor 00022 // Access: Public 00023 // Description: Initializes this PythonGraphicsWindowProc to use the 00024 // specified callback handler and name. 00025 //////////////////////////////////////////////////////////////////// 00026 PythonGraphicsWindowProc:: 00027 PythonGraphicsWindowProc(PyObject* function, PyObject* name) : 00028 PythonCallbackObject(function) 00029 { 00030 _name = name; 00031 Py_INCREF(_name); 00032 } 00033 00034 //////////////////////////////////////////////////////////////////// 00035 // Function: PythonGraphicWindowProc::Constructor 00036 // Access: Public, Virtual 00037 // Description: Decrements references to the handler and name objects. 00038 //////////////////////////////////////////////////////////////////// 00039 PythonGraphicsWindowProc:: 00040 ~PythonGraphicsWindowProc(){ 00041 Py_DECREF(_name); 00042 } 00043 00044 #ifdef WIN32 00045 00046 //////////////////////////////////////////////////////////////////// 00047 // Function: PythonGraphicWindowProc::wnd_proc 00048 // Access: Public, Virtual 00049 // Description: A WIN32-specific method that is called when a Window 00050 // proc event occurrs. Calls the python handler. 00051 //////////////////////////////////////////////////////////////////// 00052 LONG PythonGraphicsWindowProc:: 00053 wnd_proc(GraphicsWindow* graphicsWindow, HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam){ 00054 GraphicsWindowProcCallbackData cdata(graphicsWindow); 00055 cdata.set_hwnd((int)hwnd); 00056 cdata.set_msg(msg); 00057 cdata.set_wparam(wparam); 00058 cdata.set_lparam(lparam); 00059 do_callback(&cdata); 00060 00061 return 0; 00062 } 00063 00064 #endif // WIN32 00065 00066 //////////////////////////////////////////////////////////////////// 00067 // Function: PythonGraphicWindowProc::get_name 00068 // Access: Public 00069 // Description: Returns the python name object. 00070 //////////////////////////////////////////////////////////////////// 00071 PyObject* PythonGraphicsWindowProc:: 00072 get_name(){ 00073 return _name; 00074 }