mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-01 09:23:03 -04:00
Fixed the following issues with the multitouch and python eventing code comitted earlier this week:
- Renamed CustomGraphicsWindowProc to PythonGraphicsWindowProc. - PythonGraphicsWindowProc now extends the PythonCallbackObject class. - Added a GraphicsWindowProcCallbackData class. The data stored in this class depends on the OS being compiled for. (Currently only members for WIN32.) o Multitouch is now handled through this class as well. It has is_touch_event(), get_num_touches(), and get_touch_info() methods. The GraphicsWindow class still has these methods (GraphicsWindowProcCallbackData simply calls them), but they are no longer published. - Updated Sources.pp to use all these new files. - Added function and class comment blocks to everything. - Fixed a few coding convention things and continued to follow those conventions to the best of my knowledge. - Checked for literal tab characters. - pandabase.h comes before all other includes - No Windows-specific typedefs in non-Windows code. - All python-specific code in HAVE_PYTHON blocks. - Fixed the case between TIF_move, TIF_down, and TIF_UP (now TIF_up).
This commit is contained in:
parent
fc10962638
commit
bb5d97f1bf
@ -1412,10 +1412,11 @@ def SdkLocateVisualStudio():
|
||||
def SdkLocateMSPlatform():
|
||||
if (sys.platform != "win32"): return
|
||||
platsdk = GetRegistryKey("SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows\\v7.0", "InstallationFolder")
|
||||
if (platsdk and not os.path.isdir(platsdk)):
|
||||
platsdk = 0
|
||||
else:
|
||||
print "Windows 7 SDK detected. Enabling special features (multi-touch)."
|
||||
if (platsdk):
|
||||
if os.path.isdir(platsdk):
|
||||
print "Windows 7 SDK detected. Enabling special features (multi-touch)."
|
||||
else:
|
||||
platsdk = 0
|
||||
if (platsdk == 0):
|
||||
platsdk = GetRegistryKey("SOFTWARE\\Microsoft\\MicrosoftSDK\\InstalledSDKs\\D2FF9F89-8AA2-4373-8A31-C838BF4DBBE1", "Install Dir")
|
||||
if (platsdk and not os.path.isdir(platsdk)): platsdk = 0
|
||||
|
@ -13,7 +13,7 @@
|
||||
#define SOURCES \
|
||||
standardMunger.I standardMunger.h \
|
||||
config_display.h \
|
||||
customGraphicsWindowProc.h \
|
||||
$[if $[HAVE_PYTHON], pythonGraphicsWindowProc.h] \
|
||||
drawableRegion.I drawableRegion.h \
|
||||
displayRegion.I displayRegion.h \
|
||||
displayRegionCullCallbackData.I displayRegionCullCallbackData.h \
|
||||
@ -32,6 +32,7 @@
|
||||
graphicsWindowInputDevice.I \
|
||||
graphicsWindowInputDevice.h \
|
||||
graphicsWindowProc.h \
|
||||
graphicsWindowProcCallbackData.I graphicsWindowProcCallbackData.h \
|
||||
lru.h \
|
||||
nativeWindowHandle.I nativeWindowHandle.h \
|
||||
parasiteBuffer.I parasiteBuffer.h \
|
||||
@ -50,7 +51,7 @@
|
||||
#define INCLUDED_SOURCES \
|
||||
standardMunger.cxx \
|
||||
config_display.cxx \
|
||||
customGraphicsWindowProc.cxx \
|
||||
$[if $[HAVE_PYTHON], pythonGraphicsWindowProc.cxx] \
|
||||
drawableRegion.cxx \
|
||||
displayRegion.cxx \
|
||||
displayRegionCullCallbackData.cxx \
|
||||
@ -67,6 +68,7 @@
|
||||
graphicsThreadingModel.cxx \
|
||||
graphicsWindow.cxx graphicsWindowInputDevice.cxx \
|
||||
graphicsWindowProc.cxx \
|
||||
graphicsWindowProcCalbackData.cxx \
|
||||
graphicsDevice.cxx \
|
||||
lru.cxx \
|
||||
nativeWindowHandle.cxx \
|
||||
@ -81,7 +83,7 @@
|
||||
#define INSTALL_HEADERS \
|
||||
standardMunger.I standardMunger.h \
|
||||
config_display.h \
|
||||
customGraphicsWindowProc.h \
|
||||
$[if $[HAVE_PYTHON], pythonGraphicsWindowProc.h] \
|
||||
drawableRegion.I drawableRegion.h \
|
||||
displayInformation.h \
|
||||
displayRegion.I displayRegion.h \
|
||||
@ -98,6 +100,7 @@
|
||||
graphicsStateGuardian.h \
|
||||
graphicsWindow.I graphicsWindow.h \
|
||||
graphicsWindowProc.h \
|
||||
graphicsWindowProcCallbackData.I graphicsWindowProcCallbackData.h \
|
||||
graphicsThreadingModel.I graphicsThreadingModel.h \
|
||||
graphicsWindowInputDevice.I graphicsWindowInputDevice.h \
|
||||
graphicsDevice.I graphicsDevice.h \
|
||||
|
@ -23,6 +23,10 @@
|
||||
#include "graphicsBuffer.h"
|
||||
#include "graphicsWindow.h"
|
||||
#include "graphicsDevice.h"
|
||||
#ifdef HAVE_PYTHON
|
||||
#include "pythonGraphicsWindowProc.h"
|
||||
#endif
|
||||
#include "graphicsWindowProcCallbackData.h"
|
||||
#include "nativeWindowHandle.h"
|
||||
#include "parasiteBuffer.h"
|
||||
#include "pandaSystem.h"
|
||||
@ -435,6 +439,10 @@ init_libdisplay() {
|
||||
GraphicsPipe::init_type();
|
||||
GraphicsStateGuardian::init_type();
|
||||
GraphicsWindow::init_type();
|
||||
#ifdef HAVE_PYTHON
|
||||
PythonGraphicsWindowProc::init_type();
|
||||
#endif
|
||||
GraphicsWindowProcCallbackData::init_type();
|
||||
NativeWindowHandle::init_type();
|
||||
ParasiteBuffer::init_type();
|
||||
StandardMunger::init_type();
|
||||
|
@ -1,44 +0,0 @@
|
||||
// Filename: customGraphicsWindowProc.cxx
|
||||
// Created by: Walt Destler (May 2010)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// PANDA 3D SOFTWARE
|
||||
// Copyright (c) Carnegie Mellon University. All rights reserved.
|
||||
//
|
||||
// All use of this software is subject to the terms of the revised BSD
|
||||
// license. You should have received a copy of this license along
|
||||
// with this source code in a file named "LICENSE."
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "customGraphicsWindowProc.h"
|
||||
|
||||
CustomGraphicsWindowProc::CustomGraphicsWindowProc(PyObject* handler, PyObject* name){
|
||||
_handler = handler;
|
||||
_name = name;
|
||||
Py_INCREF(_handler);
|
||||
Py_INCREF(_name);
|
||||
}
|
||||
|
||||
CustomGraphicsWindowProc::~CustomGraphicsWindowProc(){
|
||||
Py_DECREF(_name);
|
||||
Py_DECREF(_handler);
|
||||
}
|
||||
|
||||
#ifdef WIN32
|
||||
LONG CustomGraphicsWindowProc::wnd_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam){
|
||||
PyObject* ret = PyObject_CallFunction(_handler, "IIII", hwnd, msg, wparam, lparam);
|
||||
Py_XDECREF(ret);
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
PyObject* CustomGraphicsWindowProc::get_handler(){
|
||||
return _handler;
|
||||
}
|
||||
|
||||
PyObject* CustomGraphicsWindowProc::get_name(){
|
||||
return _name;
|
||||
}
|
@ -1,38 +0,0 @@
|
||||
// Filename: customGgraphicswindowProc.h
|
||||
// Created by: Walt Destler (May 2010)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// PANDA 3D SOFTWARE
|
||||
// Copyright (c) Carnegie Mellon University. All rights reserved.
|
||||
//
|
||||
// All use of this software is subject to the terms of the revised BSD
|
||||
// license. You should have received a copy of this license along
|
||||
// with this source code in a file named "LICENSE."
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef CUSTOMGRAPHICSWINDOWPROC_H
|
||||
#define CUSTOMGRAPHICSWINDOWPROC_H
|
||||
|
||||
#include "pandabase.h"
|
||||
#include "graphicsWindowProc.h"
|
||||
|
||||
class CustomGraphicsWindowProc: public GraphicsWindowProc{
|
||||
public:
|
||||
CustomGraphicsWindowProc(PyObject* handler, PyObject* name);
|
||||
virtual ~CustomGraphicsWindowProc();
|
||||
|
||||
#ifdef WIN32
|
||||
virtual LONG wnd_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam);
|
||||
#endif
|
||||
|
||||
PyObject* get_handler();
|
||||
PyObject* get_name();
|
||||
|
||||
private:
|
||||
PyObject* _handler;
|
||||
PyObject* _name;
|
||||
};
|
||||
|
||||
#endif //CUSTOMGRAPHICSWINDOWPROC_H
|
@ -3,7 +3,10 @@
|
||||
#include "graphicsThreadingModel.cxx"
|
||||
#include "graphicsWindow.cxx"
|
||||
#include "graphicsWindowProc.cxx"
|
||||
#include "customGraphicsWindowProc.cxx"
|
||||
#include "graphicsWindowProcCallbackData.cxx"
|
||||
#ifdef HAVE_PYTHON
|
||||
#include "pythonGraphicsWindowProc.cxx"
|
||||
#endif
|
||||
#include "graphicsWindowInputDevice.cxx"
|
||||
#include "lru.cxx"
|
||||
#include "nativeWindowHandle.cxx"
|
||||
|
@ -77,12 +77,13 @@ GraphicsWindow(GraphicsEngine *engine, GraphicsPipe *pipe,
|
||||
////////////////////////////////////////////////////////////////////
|
||||
GraphicsWindow::
|
||||
~GraphicsWindow() {
|
||||
|
||||
// Clean up custom event handlers.
|
||||
CustomWinProcClasses::iterator iter;
|
||||
for(iter = _custom_window_proc_classes.begin(); iter != _custom_window_proc_classes.end(); ++iter){
|
||||
#ifdef HAVE_PYTHON
|
||||
// Clean up python event handlers.
|
||||
PythonWinProcClasses::iterator iter;
|
||||
for(iter = _python_window_proc_classes.begin(); iter != _python_window_proc_classes.end(); ++iter){
|
||||
delete *iter;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
@ -927,64 +928,56 @@ mouse_mode_absolute() {
|
||||
|
||||
}
|
||||
|
||||
#ifdef HAVE_PYTHON
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: GraphicsWindow::add_custom_event_handler
|
||||
// Access: Published
|
||||
// Description: Adds a custom python event handler to be called
|
||||
// Description: Adds a python event handler to be called
|
||||
// when a window event occurs.
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void GraphicsWindow::
|
||||
add_custom_event_handler(PyObject* handler, PyObject* name){
|
||||
CustomGraphicsWindowProc* cgwp = new CustomGraphicsWindowProc(handler, name);
|
||||
_custom_window_proc_classes.insert(cgwp);
|
||||
add_window_proc(cgwp);
|
||||
add_python_event_handler(PyObject* handler, PyObject* name){
|
||||
PythonGraphicsWindowProc* pgwp = new PythonGraphicsWindowProc(handler, name);
|
||||
_python_window_proc_classes.insert(pgwp);
|
||||
add_window_proc(pgwp);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: GraphicsWindow::remove_custom_event_handler
|
||||
// Access: Published
|
||||
// Description: Removes the specified custom python event handler.
|
||||
// Description: Removes the specified python event handler.
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void GraphicsWindow::
|
||||
remove_custom_event_handler(PyObject* name){
|
||||
//nassertv(wnd_proc != NULL);
|
||||
//_window_proc_classes.erase( (GraphicsWindowProc*)wnd_proc );
|
||||
list<CustomGraphicsWindowProc*> toRemove;
|
||||
CustomWinProcClasses::iterator iter;
|
||||
for(iter = _custom_window_proc_classes.begin(); iter != _custom_window_proc_classes.end(); ++iter){
|
||||
CustomGraphicsWindowProc* cgwp = *iter;
|
||||
if(PyObject_Compare(cgwp->get_name(), name) == 0)
|
||||
toRemove.push_back(cgwp);
|
||||
remove_python_event_handler(PyObject* name){
|
||||
list<PythonGraphicsWindowProc*> toRemove;
|
||||
PythonWinProcClasses::iterator iter;
|
||||
for(iter = _python_window_proc_classes.begin(); iter != _python_window_proc_classes.end(); ++iter){
|
||||
PythonGraphicsWindowProc* pgwp = *iter;
|
||||
if(PyObject_Compare(pgwp->get_name(), name) == 0)
|
||||
toRemove.push_back(pgwp);
|
||||
}
|
||||
list<CustomGraphicsWindowProc*>::iterator iter2;
|
||||
list<PythonGraphicsWindowProc*>::iterator iter2;
|
||||
for(iter2 = toRemove.begin(); iter2 != toRemove.end(); ++iter2){
|
||||
CustomGraphicsWindowProc* cgwp = *iter2;
|
||||
remove_window_proc(cgwp);
|
||||
_custom_window_proc_classes.erase(cgwp);
|
||||
delete cgwp;
|
||||
PythonGraphicsWindowProc* pgwp = *iter2;
|
||||
remove_window_proc(pgwp);
|
||||
_python_window_proc_classes.erase(pgwp);
|
||||
delete pgwp;
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: GraphicsWindow::supports_window_procs
|
||||
// Access: Published, Virtual
|
||||
// Description: Returns whether this window supports adding of Windows proc handlers.
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
bool GraphicsWindow::supports_window_procs() const{
|
||||
return false;
|
||||
}
|
||||
#endif // HAVE_PYTHON
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: GraphicsWindow::is_touch_msg
|
||||
// Function: GraphicsWindow::is_touch_event
|
||||
// Access: Published, Virtual
|
||||
// Description: Returns whether the specified event msg is a touch message.
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
bool GraphicsWindow::
|
||||
is_touch_msg(int msg){
|
||||
is_touch_event(GraphicsWindowProcCallbackData* callbackData){
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -1009,3 +1002,13 @@ TouchInfo GraphicsWindow::
|
||||
get_touch_info(int index){
|
||||
return TouchInfo();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: GraphicsWindow::supports_window_procs
|
||||
// Access: Published, Virtual
|
||||
// Description: Returns whether this window supports adding of Windows proc handlers.
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
bool GraphicsWindow::supports_window_procs() const{
|
||||
return false;
|
||||
}
|
||||
|
@ -20,7 +20,10 @@
|
||||
#include "graphicsOutput.h"
|
||||
#include "graphicsWindowInputDevice.h"
|
||||
#include "graphicsWindowProc.h"
|
||||
#include "customGraphicsWindowProc.h"
|
||||
#include "graphicsWindowProcCallbackData.h"
|
||||
#ifdef HAVE_PYTHON
|
||||
#include "pythonGraphicsWindowProc.h"
|
||||
#endif
|
||||
#include "windowProperties.h"
|
||||
#include "mouseData.h"
|
||||
#include "modifierButtons.h"
|
||||
@ -87,12 +90,10 @@ PUBLISHED:
|
||||
virtual bool move_pointer(int device, int x, int y);
|
||||
virtual void close_ime();
|
||||
|
||||
void add_custom_event_handler(PyObject* handler, PyObject* name);
|
||||
void remove_custom_event_handler(PyObject* name);
|
||||
|
||||
virtual bool is_touch_msg(int msg);
|
||||
virtual int get_num_touches();
|
||||
virtual TouchInfo get_touch_info(int index);
|
||||
#ifdef HAVE_PYTHON
|
||||
void add_python_event_handler(PyObject* handler, PyObject* name);
|
||||
void remove_python_event_handler(PyObject* name);
|
||||
#endif
|
||||
|
||||
public:
|
||||
// No need to publish these.
|
||||
@ -108,6 +109,10 @@ public:
|
||||
|
||||
virtual int verify_window_sizes(int numsizes, int *dimen);
|
||||
|
||||
virtual bool is_touch_event(GraphicsWindowProcCallbackData* callbackData);
|
||||
virtual int get_num_touches();
|
||||
virtual TouchInfo get_touch_info(int index);
|
||||
|
||||
public:
|
||||
virtual void request_open();
|
||||
virtual void request_close();
|
||||
@ -159,9 +164,11 @@ private:
|
||||
string _window_event;
|
||||
string _close_request_event;
|
||||
|
||||
typedef pset<CustomGraphicsWindowProc*> CustomWinProcClasses;
|
||||
CustomWinProcClasses _custom_window_proc_classes;
|
||||
|
||||
#ifdef HAVE_PYTHON
|
||||
typedef pset<PythonGraphicsWindowProc*> PythonWinProcClasses;
|
||||
PythonWinProcClasses _python_window_proc_classes;
|
||||
#endif
|
||||
|
||||
public:
|
||||
static TypeHandle get_class_type() {
|
||||
return _type_handle;
|
||||
|
@ -14,13 +14,28 @@
|
||||
|
||||
#include "graphicsWindowProc.h"
|
||||
|
||||
TypeHandle GraphicsWindowProc::_type_handle;
|
||||
|
||||
GraphicsWindowProc::GraphicsWindowProc(){
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: GraphicWindowProc::Constructor
|
||||
// Access: Public
|
||||
// Description: Does nothing.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
GraphicsWindowProc::
|
||||
GraphicsWindowProc(){
|
||||
}
|
||||
|
||||
#if defined(__WIN32__) || defined(_WIN32)
|
||||
LONG GraphicsWindowProc::wnd_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam){
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: GraphicsWindowProc::wnd_proc
|
||||
// Access: Public, Virtual
|
||||
// Description: A WIN32-specific method that is called when a Window
|
||||
// proc event occurrs. Should be overridden by a derived
|
||||
// class.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
LONG GraphicsWindowProc::
|
||||
wnd_proc(GraphicsWindow* graphicsWindow, HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam){
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
//most an empty file.
|
@ -17,7 +17,6 @@
|
||||
#define GRAPHICSWINDOWPROC_H
|
||||
|
||||
#include "pandabase.h"
|
||||
#include "typedReferenceCount.h"
|
||||
|
||||
#ifdef WIN32
|
||||
#ifndef WIN32_LEAN_AND_MEAN
|
||||
@ -26,38 +25,18 @@
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
/*
|
||||
Defines a little interface for storing a platform specific window
|
||||
processor methods. Since this is a purely virtual class, it never
|
||||
really gets instaniated so this even though this is type reference
|
||||
counted, it doesn't need to registered.
|
||||
*/
|
||||
class EXPCL_PANDA_DISPLAY GraphicsWindowProc: public TypedReferenceCount{
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Class : GraphicsWindowProc
|
||||
// Description : Defines an interface for storing platform-specific
|
||||
// window processor methods.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
class GraphicsWindowProc{
|
||||
public:
|
||||
GraphicsWindowProc();
|
||||
#if defined(__WIN32__) || defined(_WIN32)
|
||||
virtual LONG wnd_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam);
|
||||
virtual LONG wnd_proc(GraphicsWindow* graphicsWindow, HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam);
|
||||
#endif
|
||||
//purely virtual class
|
||||
|
||||
// In theory, this stuff below never gets used since it's purely virtual
|
||||
// class that can't be instaniated anyways
|
||||
public:
|
||||
static TypeHandle get_class_type() {
|
||||
return _type_handle;
|
||||
}
|
||||
static void init_type() {
|
||||
TypedReferenceCount::init_type();
|
||||
register_type(_type_handle, "GraphicsWindowProc",
|
||||
TypedReferenceCount::get_class_type());
|
||||
}
|
||||
virtual TypeHandle get_type() const {
|
||||
return get_class_type();
|
||||
}
|
||||
virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
|
||||
|
||||
private:
|
||||
static TypeHandle _type_handle;
|
||||
};
|
||||
|
||||
#endif //GRAPHICSWINDOWPROC_H
|
||||
|
117
panda/src/display/graphicsWindowProcCallbackData.I
Normal file
117
panda/src/display/graphicsWindowProcCallbackData.I
Normal file
@ -0,0 +1,117 @@
|
||||
// Filename: graphicsWindowProcCallbackData.I
|
||||
// Created by: Walt Destler (June 2010)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// PANDA 3D SOFTWARE
|
||||
// Copyright (c) Carnegie Mellon University. All rights reserved.
|
||||
//
|
||||
// All use of this software is subject to the terms of the revised BSD
|
||||
// license. You should have received a copy of this license along
|
||||
// with this source code in a file named "LICENSE."
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: GraphicsWindowProcCallbackData::Constructor
|
||||
// Access: Public
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE GraphicsWindowProcCallbackData::
|
||||
GraphicsWindowProcCallbackData(GraphicsWindow* graphicsWindow){
|
||||
_graphicsWindow = graphicsWindow;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: GraphicsWindowProcCallbackData::get_hwnd
|
||||
// Access: Published
|
||||
// Description: Returns the GraphicsWindow that generated this event.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE GraphicsWindow* GraphicsWindowProcCallbackData::
|
||||
get_graphics_window() const {
|
||||
return _graphicsWindow;
|
||||
}
|
||||
|
||||
#ifdef WIN32
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: GraphicsWindowProcCallbackData::get_hwnd
|
||||
// Access: Published
|
||||
// Description: Returns the Windows proc hwnd parameter.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE int GraphicsWindowProcCallbackData::
|
||||
get_hwnd() const {
|
||||
return _hwnd;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: GraphicsWindowProcCallbackData::get_msg
|
||||
// Access: Published
|
||||
// Description: Returns the Windows proc msg parameter.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE int GraphicsWindowProcCallbackData::
|
||||
get_msg() const {
|
||||
return _msg;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: GraphicsWindowProcCallbackData::get_wparam
|
||||
// Access: Published
|
||||
// Description: Returns the Windows proc wparam parameter.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE int GraphicsWindowProcCallbackData::
|
||||
get_wparam() const {
|
||||
return _wparam;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: GraphicsWindowProcCallbackData::get_lparam
|
||||
// Access: Published
|
||||
// Description: Returns the Windows proc lparam parameter.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE int GraphicsWindowProcCallbackData::
|
||||
get_lparam() const {
|
||||
return _lparam;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: GraphicsWindowProcCallbackData::set_hwnd
|
||||
// Access: Published
|
||||
// Description: Sets the Windows proc hwnd parameter.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void GraphicsWindowProcCallbackData::
|
||||
set_hwnd(int hwnd) {
|
||||
_hwnd = hwnd;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: GraphicsWindowProcCallbackData::set_msg
|
||||
// Access: Published
|
||||
// Description: Sets the Windows proc msg parameter.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void GraphicsWindowProcCallbackData::
|
||||
set_msg(int msg) {
|
||||
_msg = msg;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: GraphicsWindowProcCallbackData::set_wparam
|
||||
// Access: Published
|
||||
// Description: Sets the Windows proc wparam parameter.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void GraphicsWindowProcCallbackData::
|
||||
set_wparam(int wparam) {
|
||||
_wparam = wparam;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: GraphicsWindowProcCallbackData::set_lparam
|
||||
// Access: Published
|
||||
// Description: Sets the Windows proc lparam parameter.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void GraphicsWindowProcCallbackData::
|
||||
set_lparam(int lparam) {
|
||||
_lparam = lparam;
|
||||
}
|
||||
|
||||
#endif
|
64
panda/src/display/graphicsWindowProcCallbackData.cxx
Normal file
64
panda/src/display/graphicsWindowProcCallbackData.cxx
Normal file
@ -0,0 +1,64 @@
|
||||
// Filename: graphicsWindowProcCallbackData.cxx
|
||||
// Created by: Walt Destler (June 2010)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// PANDA 3D SOFTWARE
|
||||
// Copyright (c) Carnegie Mellon University. All rights reserved.
|
||||
//
|
||||
// All use of this software is subject to the terms of the revised BSD
|
||||
// license. You should have received a copy of this license along
|
||||
// with this source code in a file named "LICENSE."
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "graphicsWindowProcCallbackData.h"
|
||||
|
||||
TypeHandle GraphicsWindowProcCallbackData::_type_handle;
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: GraphicsWindowProcCallbackData::output
|
||||
// Access: Published, Virtual
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void GraphicsWindowProcCallbackData::
|
||||
output(ostream &out) const {
|
||||
#ifdef WIN32
|
||||
out << get_type() << "(" << (void*)_graphicsWindow << ", " << _hwnd << ", "
|
||||
<< _msg << ", " << _wparam << ", " << _lparam << ")";
|
||||
#else
|
||||
out << get_type() << "()";
|
||||
#endif
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: GraphicsWindowProcCallbackData::is_touch_event
|
||||
// Access: Public, Virtual
|
||||
// Description: Returns whether the event is a touch event.
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
bool GraphicsWindowProcCallbackData::
|
||||
is_touch_event(){
|
||||
return _graphicsWindow->is_touch_event(this);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: GraphicsWindowProcCallbackData::get_num_touches
|
||||
// Access: Public, Virtual
|
||||
// Description: Returns the current number of touches on the window.
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
int GraphicsWindowProcCallbackData::
|
||||
get_num_touches(){
|
||||
return _graphicsWindow->get_num_touches();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: GraphicsWindowProcCallbackData::get_touch_info
|
||||
// Access: Public, Virtual
|
||||
// Description: Returns the TouchInfo object describing the specified touch.
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
TouchInfo GraphicsWindowProcCallbackData::
|
||||
get_touch_info(int index){
|
||||
return _graphicsWindow->get_touch_info(index);
|
||||
}
|
85
panda/src/display/graphicsWindowProcCallbackData.h
Normal file
85
panda/src/display/graphicsWindowProcCallbackData.h
Normal file
@ -0,0 +1,85 @@
|
||||
// Filename: graphicsWindowProcCallbackData.h
|
||||
// Created by: Walt Destler (June 2010)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// PANDA 3D SOFTWARE
|
||||
// Copyright (c) Carnegie Mellon University. All rights reserved.
|
||||
//
|
||||
// All use of this software is subject to the terms of the revised BSD
|
||||
// license. You should have received a copy of this license along
|
||||
// with this source code in a file named "LICENSE."
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef GRAPHICSWINDOWPROCCALLBACKDATA_H
|
||||
#define GRAPHICSWINDOWPROCCALLBACKDATA_H
|
||||
|
||||
#include "pandabase.h"
|
||||
#include "callbackData.h"
|
||||
#include "graphicsWindow.h"
|
||||
#include "touchInfo.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Class : GraphicsWindowProcCallbackData
|
||||
// Description : This specialization on CallbackData is passed when
|
||||
// the callback is initiated from from an implementation
|
||||
// of the GraphicsWindowProc class, such as PythonGraphicsWindowProc.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
class EXPCL_PANDA_DISPLAY GraphicsWindowProcCallbackData : public CallbackData {
|
||||
public:
|
||||
INLINE GraphicsWindowProcCallbackData(GraphicsWindow* graphicsWindow);
|
||||
|
||||
INLINE GraphicsWindow* get_graphics_window() const;
|
||||
|
||||
#ifdef WIN32
|
||||
INLINE void set_hwnd(int hwnd);
|
||||
INLINE void set_msg(int msg);
|
||||
INLINE void set_wparam(int wparam);
|
||||
INLINE void set_lparam(int lparam);
|
||||
#endif
|
||||
|
||||
PUBLISHED:
|
||||
virtual void output(ostream &out) const;
|
||||
|
||||
#ifdef WIN32
|
||||
INLINE int get_hwnd() const;
|
||||
INLINE int get_msg() const;
|
||||
INLINE int get_wparam() const;
|
||||
INLINE int get_lparam() const;
|
||||
#endif
|
||||
|
||||
bool is_touch_event();
|
||||
int get_num_touches();
|
||||
TouchInfo get_touch_info(int index);
|
||||
|
||||
private:
|
||||
GraphicsWindow* _graphicsWindow;
|
||||
#ifdef WIN32
|
||||
int _hwnd;
|
||||
int _msg;
|
||||
int _wparam;
|
||||
int _lparam;
|
||||
#endif
|
||||
|
||||
public:
|
||||
static TypeHandle get_class_type() {
|
||||
return _type_handle;
|
||||
}
|
||||
static void init_type() {
|
||||
CallbackData::init_type();
|
||||
register_type(_type_handle, "GraphicsWindowProcCallbackData",
|
||||
CallbackData::get_class_type());
|
||||
}
|
||||
virtual TypeHandle get_type() const {
|
||||
return get_class_type();
|
||||
}
|
||||
virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
|
||||
|
||||
private:
|
||||
static TypeHandle _type_handle;
|
||||
};
|
||||
|
||||
#include "graphicsWindowProcCallbackData.I"
|
||||
|
||||
#endif // GRAPHICSWINDOWPROCCALLBACKDATA_H
|
74
panda/src/display/pythonGraphicsWindowProc.cxx
Normal file
74
panda/src/display/pythonGraphicsWindowProc.cxx
Normal file
@ -0,0 +1,74 @@
|
||||
// Filename: customGraphicsWindowProc.cxx
|
||||
// Created by: Walt Destler (May 2010)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// PANDA 3D SOFTWARE
|
||||
// Copyright (c) Carnegie Mellon University. All rights reserved.
|
||||
//
|
||||
// All use of this software is subject to the terms of the revised BSD
|
||||
// license. You should have received a copy of this license along
|
||||
// with this source code in a file named "LICENSE."
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "pythonGraphicsWindowProc.h"
|
||||
#include "graphicsWindowProcCallbackData.h"
|
||||
|
||||
TypeHandle PythonGraphicsWindowProc::_type_handle;
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PythonGraphicWindowProc::Constructor
|
||||
// Access: Public
|
||||
// Description: Initializes this PythonGraphicsWindowProc to use the
|
||||
// specified callback handler and name.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
PythonGraphicsWindowProc::
|
||||
PythonGraphicsWindowProc(PyObject* function, PyObject* name) :
|
||||
PythonCallbackObject(function)
|
||||
{
|
||||
_name = name;
|
||||
Py_INCREF(_name);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PythonGraphicWindowProc::Constructor
|
||||
// Access: Public, Virtual
|
||||
// Description: Decrements references to the handler and name objects.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
PythonGraphicsWindowProc::
|
||||
~PythonGraphicsWindowProc(){
|
||||
Py_DECREF(_name);
|
||||
}
|
||||
|
||||
#ifdef WIN32
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PythonGraphicWindowProc::wnd_proc
|
||||
// Access: Public, Virtual
|
||||
// Description: A WIN32-specific method that is called when a Window
|
||||
// proc event occurrs. Calls the python handler.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
LONG PythonGraphicsWindowProc::
|
||||
wnd_proc(GraphicsWindow* graphicsWindow, HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam){
|
||||
GraphicsWindowProcCallbackData cdata(graphicsWindow);
|
||||
cdata.set_hwnd((int)hwnd);
|
||||
cdata.set_msg(msg);
|
||||
cdata.set_wparam(wparam);
|
||||
cdata.set_lparam(lparam);
|
||||
do_callback(&cdata);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif // WIN32
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PythonGraphicWindowProc::get_name
|
||||
// Access: Public
|
||||
// Description: Returns the python name object.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
PyObject* PythonGraphicsWindowProc::
|
||||
get_name(){
|
||||
return _name;
|
||||
}
|
60
panda/src/display/pythonGraphicsWindowProc.h
Normal file
60
panda/src/display/pythonGraphicsWindowProc.h
Normal file
@ -0,0 +1,60 @@
|
||||
// Filename: customGgraphicswindowProc.h
|
||||
// Created by: Walt Destler (May 2010)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// PANDA 3D SOFTWARE
|
||||
// Copyright (c) Carnegie Mellon University. All rights reserved.
|
||||
//
|
||||
// All use of this software is subject to the terms of the revised BSD
|
||||
// license. You should have received a copy of this license along
|
||||
// with this source code in a file named "LICENSE."
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef PYTHONGRAPHICSWINDOWPROC_H
|
||||
#define PYTHONGRAPHICSWINDOWPROC_H
|
||||
|
||||
#include "pandabase.h"
|
||||
#include "graphicsWindowProc.h"
|
||||
#include "pythonCallbackObject.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Class : PythonGraphicsWindowProc
|
||||
// Description : Extends GraphicsWindowProc to provde callback functionality
|
||||
// to a python program.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
class PythonGraphicsWindowProc: public GraphicsWindowProc, public PythonCallbackObject{
|
||||
public:
|
||||
PythonGraphicsWindowProc(PyObject *function, PyObject* name);
|
||||
virtual ~PythonGraphicsWindowProc();
|
||||
ALLOC_DELETED_CHAIN(PythonGraphicsWindowProc);
|
||||
|
||||
#ifdef WIN32
|
||||
virtual LONG wnd_proc(GraphicsWindow* graphicsWindow, HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam);
|
||||
#endif
|
||||
|
||||
PyObject* get_name();
|
||||
|
||||
private:
|
||||
PyObject* _name;
|
||||
|
||||
public:
|
||||
static TypeHandle get_class_type() {
|
||||
return _type_handle;
|
||||
}
|
||||
static void init_type() {
|
||||
TypedReferenceCount::init_type();
|
||||
register_type(_type_handle, "PythonGraphicsWindowProc",
|
||||
TypedReferenceCount::get_class_type());
|
||||
}
|
||||
virtual TypeHandle get_type() const {
|
||||
return get_class_type();
|
||||
}
|
||||
virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
|
||||
|
||||
private:
|
||||
static TypeHandle _type_handle;
|
||||
};
|
||||
|
||||
#endif //PYTHONGRAPHICSWINDOWPROC_H
|
@ -28,7 +28,7 @@ PUBLISHED:
|
||||
{
|
||||
TIF_move = 0x0001,
|
||||
TIF_down = 0x0002,
|
||||
TIF_UP = 0x0004,
|
||||
TIF_up = 0x0004,
|
||||
};
|
||||
|
||||
public:
|
||||
|
@ -2092,7 +2092,7 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) {
|
||||
|
||||
//do custom messages processing if any has been set
|
||||
for ( WinProcClasses::iterator it=_window_proc_classes.begin() ; it != _window_proc_classes.end(); it++ ){
|
||||
(*it)->wnd_proc(hwnd, msg, wparam, lparam);
|
||||
(*it)->wnd_proc(this, hwnd, msg, wparam, lparam);
|
||||
}
|
||||
|
||||
return DefWindowProc(hwnd, msg, wparam, lparam);
|
||||
@ -2860,14 +2860,15 @@ bool WinGraphicsWindow::supports_window_procs() const{
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: WinGraphicsWindow::is_touch_msg
|
||||
// Function: WinGraphicsWindow::is_touch_event
|
||||
// Access: Public, Virtual
|
||||
// Description: Returns whether the specified event msg is a touch message.
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
bool WinGraphicsWindow::is_touch_msg(UINT msg){
|
||||
bool WinGraphicsWindow::
|
||||
is_touch_event(GraphicsWindowProcCallbackData* callbackData){
|
||||
#ifdef PANDA_WIN7
|
||||
return msg == WM_TOUCH;
|
||||
return callbackData->get_msg() == WM_TOUCH;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
|
@ -83,7 +83,7 @@ public:
|
||||
virtual void clear_window_procs();
|
||||
virtual bool supports_window_procs() const;
|
||||
|
||||
virtual bool is_touch_msg(UINT msg);
|
||||
virtual bool is_touch_event(GraphicsWindowProcCallbackData* callbackData);
|
||||
virtual int get_num_touches();
|
||||
virtual TouchInfo get_touch_info(int index);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user