Panda3D

pythonGraphicsWindowProc.cxx
Go to the documentation of this file.
1 /**
2 * PANDA 3D SOFTWARE
3 * Copyright (c) Carnegie Mellon University. All rights reserved.
4 *
5 * All use of this software is subject to the terms of the revised BSD
6 * license. You should have received a copy of this license along
7 * with this source code in a file named "LICENSE."
8 *
9 * @file pythonGraphicsWindowProc.cxx
10 * @author Walt Destler
11 * @date 2010-05
12 */
13
14 #include "pythonGraphicsWindowProc.h"
15 #include "graphicsWindowProcCallbackData.h"
16
17 #ifdef HAVE_PYTHON
18
19 TypeHandle PythonGraphicsWindowProc::_type_handle;
20
21 /**
22 * Initializes this PythonGraphicsWindowProc to use the specified callback
23 * handler and name.
24 */
25 PythonGraphicsWindowProc::
26 PythonGraphicsWindowProc(PyObject* function, PyObject* name) :
27 PythonCallbackObject(function)
28 {
29 _name = name;
30 Py_INCREF(_name);
31 }
32
33 /**
34 * Decrements references to the handler and name objects.
35 */
36 PythonGraphicsWindowProc::
37 ~PythonGraphicsWindowProc(){
38 Py_DECREF(_name);
39 }
40
41 #ifdef WIN32
42
43 /**
44 * A WIN32-specific method that is called when a Window proc event occurrs.
45 * Calls the python handler.
46 */
47 LONG PythonGraphicsWindowProc::
48 wnd_proc(GraphicsWindow* graphicsWindow, HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam){
49 GraphicsWindowProcCallbackData cdata(graphicsWindow);
50 cdata.set_hwnd((uintptr_t)hwnd);
51 cdata.set_msg(msg);
52 cdata.set_wparam(wparam);
53 cdata.set_lparam(lparam);
54 do_callback(&cdata);
55
56 return 0;
57 }
58
59 #endif // WIN32
60
61 /**
62 * Returns the python name object.
63 */
64 PyObject* PythonGraphicsWindowProc::
65 get_name(){
66 return _name;
67 }
68
69 #endif // HAVE_PYTHON
GraphicsWindowProcCallbackData
This specialization on CallbackData is passed when the callback is initiated from from an implementat...
Definition: graphicsWindowProcCallbackData.h:28
GraphicsWindow
A window, fullscreen or on a desktop, into which a graphics device sends its output for interactive d...
Definition: graphicsWindow.h:40
TypeHandle
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:81
graphicsWindowProcCallbackData.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pythonGraphicsWindowProc.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.