Enabling the use of masks for wxGTK in some of the demos
wxWindow.GetHandle returns the X-Window instead of the GtkWidget pointer so the X-Window can be given to other Python modules such as VTK. wxPython.lib.vtk updated to get the window handle at widget creation instead of in the constructor. other updates git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@5147 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
cfe17b7435
commit
54b9688254
@ -41,14 +41,12 @@ class TestPanel(wxPanel):
|
||||
b = wxGenBitmapButton(self, -1, None, (100, 130))
|
||||
EVT_BUTTON(self, b.GetId(), self.OnButton)
|
||||
bmp = wxBitmap('bitmaps/lb1.bmp', wxBITMAP_TYPE_BMP)
|
||||
if wxPlatform == '__WXMSW__':
|
||||
mask = wxMaskColour(bmp, wxBLUE)
|
||||
bmp.SetMask(mask)
|
||||
mask = wxMaskColour(bmp, wxBLUE)
|
||||
bmp.SetMask(mask)
|
||||
b.SetBitmapLabel(bmp)
|
||||
bmp = wxBitmap('bitmaps/lb2.bmp', wxBITMAP_TYPE_BMP)
|
||||
if wxPlatform == '__WXMSW__':
|
||||
mask = wxMaskColour(bmp, wxBLUE)
|
||||
bmp.SetMask(mask)
|
||||
mask = wxMaskColour(bmp, wxBLUE)
|
||||
bmp.SetMask(mask)
|
||||
b.SetBitmapSelected(bmp)
|
||||
b.SetBestSize()
|
||||
|
||||
@ -59,14 +57,12 @@ class TestPanel(wxPanel):
|
||||
b = wxGenBitmapToggleButton(self, -1, None, (100, 230))
|
||||
EVT_BUTTON(self, b.GetId(), self.OnToggleButton)
|
||||
bmp = wxBitmap('bitmaps/lb1.bmp', wxBITMAP_TYPE_BMP)
|
||||
if wxPlatform == '__WXMSW__':
|
||||
mask = wxMaskColour(bmp, wxBLUE)
|
||||
bmp.SetMask(mask)
|
||||
mask = wxMaskColour(bmp, wxBLUE)
|
||||
bmp.SetMask(mask)
|
||||
b.SetBitmapLabel(bmp)
|
||||
bmp = wxBitmap('bitmaps/lb2.bmp', wxBITMAP_TYPE_BMP)
|
||||
if wxPlatform == '__WXMSW__':
|
||||
mask = wxMaskColour(bmp, wxBLUE)
|
||||
bmp.SetMask(mask)
|
||||
mask = wxMaskColour(bmp, wxBLUE)
|
||||
bmp.SetMask(mask)
|
||||
b.SetBitmapSelected(bmp)
|
||||
b.SetToggle(true)
|
||||
b.SetBestSize()
|
||||
|
@ -18,9 +18,8 @@ class TestPanel(wxPanel):
|
||||
EVT_BUTTON(self, 20, self.OnClick)
|
||||
|
||||
bmp = wxBitmap('bitmaps/test2.bmp', wxBITMAP_TYPE_BMP)
|
||||
if wxPlatform == '__WXMSW__':
|
||||
mask = wxMaskColour(bmp, wxBLUE)
|
||||
bmp.SetMask(mask)
|
||||
mask = wxMaskColour(bmp, wxBLUE)
|
||||
bmp.SetMask(mask)
|
||||
wxBitmapButton(self, 30, bmp, wxPoint(140, 20),
|
||||
wxSize(bmp.GetWidth()+10, bmp.GetHeight()+10))
|
||||
EVT_BUTTON(self, 30, self.OnClick)
|
||||
|
@ -2,12 +2,19 @@
|
||||
from wxPython.wx import *
|
||||
try:
|
||||
from wxPython.glcanvas import *
|
||||
from OpenGL.GL import *
|
||||
from OpenGL.GLUT import *
|
||||
haveGLCanvas = true
|
||||
except ImportError:
|
||||
haveGLCanvas = false
|
||||
|
||||
try:
|
||||
# The Python OpenGL package can be found at
|
||||
# http://starship.python.net:9673/crew/da/Code/PyOpenGL/
|
||||
from OpenGL.GL import *
|
||||
from OpenGL.GLUT import *
|
||||
haveOpenGL = true
|
||||
except ImportError:
|
||||
haveOpenGL = false
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
if not haveGLCanvas:
|
||||
@ -17,9 +24,17 @@ if not haveGLCanvas:
|
||||
dlg.ShowModal()
|
||||
dlg.Destroy()
|
||||
|
||||
elif not haveOpenGL:
|
||||
def runTest(frame, nb, log):
|
||||
dlg = wxMessageDialog(frame,
|
||||
'The OpenGL package was not found. You can get it at\n'
|
||||
'http://starship.python.net:9673/crew/da/Code/PyOpenGL/',
|
||||
'Sorry', wxOK | wxICON_INFORMATION)
|
||||
dlg.ShowModal()
|
||||
dlg.Destroy()
|
||||
|
||||
|
||||
else:
|
||||
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
win = wxFrame(frame, -1, "GL Demos", wxDefaultPosition, wxSize(300,300))
|
||||
CubeCanvas(win)
|
||||
@ -51,6 +66,7 @@ else:
|
||||
|
||||
def OnSize(self, event):
|
||||
size = self.GetClientSize()
|
||||
print size
|
||||
if self.GetContext():
|
||||
self.SetCurrent()
|
||||
glViewport(0, 0, size.width, size.height)
|
||||
@ -60,6 +76,7 @@ else:
|
||||
dc = wxPaintDC(self)
|
||||
|
||||
self.SetCurrent()
|
||||
print self.init
|
||||
|
||||
if not self.init:
|
||||
self.InitGL()
|
||||
|
@ -10,7 +10,8 @@ except ImportError:
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
if haveVTK:
|
||||
win = vtk.wxVTKRenderWindow(nb, -1)
|
||||
f = wxFrame(frame, -1, "wxVTKRenderWindow", size=(450, 300))
|
||||
win = vtk.wxVTKRenderWindow(f, -1)
|
||||
|
||||
# Get the render window
|
||||
renWin = win.GetRenderWindow()
|
||||
@ -38,7 +39,9 @@ def runTest(frame, nb, log):
|
||||
scalarBar.SetHeight(0.17)
|
||||
ren.AddActor2D(scalarBar)
|
||||
|
||||
return win
|
||||
f.Show(true)
|
||||
frame.otherWin = f
|
||||
return None
|
||||
|
||||
|
||||
else:
|
||||
|
@ -28,15 +28,14 @@ import math
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
class wxVTKRenderWindow(wxWindow):
|
||||
class wxVTKRenderWindow(wxScrolledWindow):
|
||||
def __init__(self, parent, id, position=wxDefaultPosition,
|
||||
size=wxDefaultSize, style=0):
|
||||
wxWindow.__init__(self, parent, id, position, size, style)
|
||||
wxScrolledWindow.__init__(self, parent, id, position, size, style)
|
||||
|
||||
self.renderWindow = vtkRenderWindow()
|
||||
|
||||
hdl = self.GetHandle()
|
||||
self.renderWindow.SetWindowInfo(str(hdl))
|
||||
EVT_WINDOW_CREATE(self, self.OnCreateWindow)
|
||||
|
||||
EVT_LEFT_DOWN (self, self.SaveClick)
|
||||
EVT_MIDDLE_DOWN(self, self.SaveClick)
|
||||
@ -44,7 +43,7 @@ class wxVTKRenderWindow(wxWindow):
|
||||
EVT_LEFT_UP (self, self.Release)
|
||||
EVT_MIDDLE_UP (self, self.Release)
|
||||
EVT_RIGHT_UP (self, self.Release)
|
||||
EVT_MOTION(self, self.MouseMotion)
|
||||
EVT_MOTION (self, self.MouseMotion)
|
||||
|
||||
|
||||
def GetRenderer(self):
|
||||
@ -60,6 +59,14 @@ class wxVTKRenderWindow(wxWindow):
|
||||
dc = wxPaintDC(self)
|
||||
self.renderWindow.Render()
|
||||
|
||||
def OnCreateWindow(self, event):
|
||||
hdl = self.GetHandle()
|
||||
self.renderWindow.SetWindowInfo(str(hdl))
|
||||
|
||||
def OnEraseBackground(self, event):
|
||||
pass
|
||||
|
||||
|
||||
|
||||
def SaveClick(self, event):
|
||||
self.prev_x, self.prev_y = event.GetPositionTuple()
|
||||
@ -109,50 +116,3 @@ class wxVTKRenderWindow(wxWindow):
|
||||
|
||||
|
||||
|
||||
## testcode is now in the demo ##
|
||||
|
||||
## if __name__ == '__main__':
|
||||
## class TestFrame(wxFrame):
|
||||
## def __init__(self, parent):
|
||||
## wxFrame.__init__(self, parent, -1, "VTK Test", size=(450,450))
|
||||
|
||||
## rw = wxVTKRenderWindow(self, -1)
|
||||
|
||||
## # Get the render window
|
||||
## renWin = rw.GetRenderWindow()
|
||||
|
||||
## # Next, do the VTK stuff
|
||||
## ren = vtkRenderer()
|
||||
## renWin.AddRenderer(ren)
|
||||
## cone = vtkConeSource()
|
||||
## cone.SetResolution(80)
|
||||
## coneMapper = vtkPolyDataMapper()
|
||||
## coneMapper.SetInput(cone.GetOutput())
|
||||
## coneActor = vtkActor()
|
||||
## coneActor.SetMapper(coneMapper)
|
||||
## ren.AddActor(coneActor)
|
||||
## coneMapper.GetLookupTable().Build()
|
||||
|
||||
## # Create a scalar bar
|
||||
## scalarBar = vtkScalarBarActor()
|
||||
## scalarBar.SetLookupTable(coneMapper.GetLookupTable())
|
||||
## scalarBar.SetTitle("Temperature")
|
||||
## scalarBar.GetPositionCoordinate().SetCoordinateSystemToNormalizedViewport()
|
||||
## scalarBar.GetPositionCoordinate().SetValue(0.1, 0.01)
|
||||
## scalarBar.SetOrientationToHorizontal()
|
||||
## scalarBar.SetWidth(0.8)
|
||||
## scalarBar.SetHeight(0.17)
|
||||
## ren.AddActor2D(scalarBar)
|
||||
|
||||
|
||||
|
||||
## class TestApp(wxApp):
|
||||
## def OnInit(self):
|
||||
## f = TestFrame(None)
|
||||
## self.SetTopWindow(f)
|
||||
## f.Show(true)
|
||||
## return true
|
||||
|
||||
## app = TestApp(0)
|
||||
## app.MainLoop()
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -153,10 +153,10 @@ def EVT_QUERY_NEW_PALETTE(win, func):
|
||||
win.Connect(-1, -1, wxEVT_QUERY_NEW_PALETTE, func)
|
||||
|
||||
def EVT_WINDOW_CREATE(win, func):
|
||||
win.Connect(-1, -1, wxEVT_WINDOW_CREATE, func)
|
||||
win.Connect(-1, -1, wxEVT_CREATE, func)
|
||||
|
||||
def EVT_WINDOW_DESTROY(win, func):
|
||||
win.Connect(-1, -1, wxEVT_WINDOW_DESTROY, func)
|
||||
win.Connect(-1, -1, wxEVT_DESTROY, func)
|
||||
|
||||
|
||||
|
||||
|
@ -1784,6 +1784,7 @@ static wxListItem * wxListCtrl_GetItem(wxListCtrl *self,long itemId,int col) {
|
||||
wxListItem* info = new wxListItem;
|
||||
info->m_itemId = itemId;
|
||||
info->m_col = col;
|
||||
info->m_mask = 0xFFFF;
|
||||
self->GetItem(*info);
|
||||
return info;
|
||||
}
|
||||
|
@ -112,7 +112,7 @@ static char* wxStringErrorMsg = "string type is required for parameter";
|
||||
|
||||
// Since this one would be tough and ugly to do with the Macros...
|
||||
void wxPyPrintout::GetPageInfo(int *minPage, int *maxPage, int *pageFrom, int *pageTo) {
|
||||
bool hadErr = false;
|
||||
bool hadErr = FALSE;
|
||||
|
||||
bool doSave = wxPyRestoreThread();
|
||||
if (m_myInst.findCallback("GetPageInfo")) {
|
||||
@ -122,22 +122,22 @@ void wxPyPrintout::GetPageInfo(int *minPage, int *maxPage, int *pageFrom, int *p
|
||||
|
||||
val = PyTuple_GetItem(result, 0);
|
||||
if (PyInt_Check(val)) *minPage = PyInt_AsLong(val);
|
||||
else hadErr = true;
|
||||
else hadErr = TRUE;
|
||||
|
||||
val = PyTuple_GetItem(result, 1);
|
||||
if (PyInt_Check(val)) *maxPage = PyInt_AsLong(val);
|
||||
else hadErr = true;
|
||||
else hadErr = TRUE;
|
||||
|
||||
val = PyTuple_GetItem(result, 2);
|
||||
if (PyInt_Check(val)) *pageFrom = PyInt_AsLong(val);
|
||||
else hadErr = true;
|
||||
else hadErr = TRUE;
|
||||
|
||||
val = PyTuple_GetItem(result, 3);
|
||||
if (PyInt_Check(val)) *pageTo = PyInt_AsLong(val);
|
||||
else hadErr = true;
|
||||
else hadErr = TRUE;
|
||||
}
|
||||
else
|
||||
hadErr = true;
|
||||
hadErr = TRUE;
|
||||
|
||||
if (hadErr) {
|
||||
PyErr_SetString(PyExc_TypeError, "GetPageInfo should return a tuple of 4 integers.");
|
||||
|
@ -1610,7 +1610,7 @@ static PyObject *_wrap_wxWindow_GetGrandParent(PyObject *self, PyObject *args, P
|
||||
}
|
||||
|
||||
static long wxWindow_GetHandle(wxWindow *self) {
|
||||
return (long)self->GetHandle();
|
||||
return wxPyGetWinHandle(self); //(long)self->GetHandle();
|
||||
}
|
||||
static PyObject *_wrap_wxWindow_GetHandle(PyObject *self, PyObject *args, PyObject *kwargs) {
|
||||
PyObject * _resultobj;
|
||||
|
@ -2540,6 +2540,7 @@ SWIGEXPORT(void) initwxc() {
|
||||
PyDict_SetItemString(d,"wxEVT_COMMAND_LISTBOX_SELECTED", PyInt_FromLong((long) wxEVT_COMMAND_LISTBOX_SELECTED));
|
||||
PyDict_SetItemString(d,"wxEVT_COMMAND_LISTBOX_DOUBLECLICKED", PyInt_FromLong((long) wxEVT_COMMAND_LISTBOX_DOUBLECLICKED));
|
||||
PyDict_SetItemString(d,"wxEVT_COMMAND_CHECKLISTBOX_TOGGLED", PyInt_FromLong((long) wxEVT_COMMAND_CHECKLISTBOX_TOGGLED));
|
||||
PyDict_SetItemString(d,"wxEVT_COMMAND_SPINCTRL_UPDATED", PyInt_FromLong((long) wxEVT_COMMAND_SPINCTRL_UPDATED));
|
||||
PyDict_SetItemString(d,"wxEVT_COMMAND_TEXT_UPDATED", PyInt_FromLong((long) wxEVT_COMMAND_TEXT_UPDATED));
|
||||
PyDict_SetItemString(d,"wxEVT_COMMAND_TEXT_ENTER", PyInt_FromLong((long) wxEVT_COMMAND_TEXT_ENTER));
|
||||
PyDict_SetItemString(d,"wxEVT_COMMAND_MENU_SELECTED", PyInt_FromLong((long) wxEVT_COMMAND_MENU_SELECTED));
|
||||
|
@ -662,6 +662,7 @@ wxEVT_COMMAND_CHOICE_SELECTED = wxc.wxEVT_COMMAND_CHOICE_SELECTED
|
||||
wxEVT_COMMAND_LISTBOX_SELECTED = wxc.wxEVT_COMMAND_LISTBOX_SELECTED
|
||||
wxEVT_COMMAND_LISTBOX_DOUBLECLICKED = wxc.wxEVT_COMMAND_LISTBOX_DOUBLECLICKED
|
||||
wxEVT_COMMAND_CHECKLISTBOX_TOGGLED = wxc.wxEVT_COMMAND_CHECKLISTBOX_TOGGLED
|
||||
wxEVT_COMMAND_SPINCTRL_UPDATED = wxc.wxEVT_COMMAND_SPINCTRL_UPDATED
|
||||
wxEVT_COMMAND_TEXT_UPDATED = wxc.wxEVT_COMMAND_TEXT_UPDATED
|
||||
wxEVT_COMMAND_TEXT_ENTER = wxc.wxEVT_COMMAND_TEXT_ENTER
|
||||
wxEVT_COMMAND_MENU_SELECTED = wxc.wxEVT_COMMAND_MENU_SELECTED
|
||||
@ -961,6 +962,20 @@ def EVT_ICONIZE(win, func):
|
||||
def EVT_NAVIGATION_KEY(win, func):
|
||||
win.Connect(-1, -1, wxEVT_NAVIGATION_KEY, func)
|
||||
|
||||
def EVT_PALETTE_CHANGED(win, func):
|
||||
win.Connect(-1, -1, wxEVT_PALETTE_CHANGED, func)
|
||||
|
||||
def EVT_QUERY_NEW_PALETTE(win, func):
|
||||
win.Connect(-1, -1, wxEVT_QUERY_NEW_PALETTE, func)
|
||||
|
||||
def EVT_WINDOW_CREATE(win, func):
|
||||
win.Connect(-1, -1, wxEVT_CREATE, func)
|
||||
|
||||
def EVT_WINDOW_DESTROY(win, func):
|
||||
win.Connect(-1, -1, wxEVT_DESTROY, func)
|
||||
|
||||
|
||||
|
||||
def EVT_IDLE(win, func):
|
||||
win.Connect(-1, -1, wxEVT_IDLE, func)
|
||||
|
||||
@ -1205,15 +1220,25 @@ def EVT_COMBOBOX(win, id, func):
|
||||
def EVT_TOOL(win, id, func):
|
||||
win.Connect(id, -1, wxEVT_COMMAND_TOOL_CLICKED, func)
|
||||
|
||||
def EVT_TOOL_RANGE(win, id, id2, func):
|
||||
win.Connect(id, id2, wxEVT_COMMAND_TOOL_CLICKED, func)
|
||||
|
||||
def EVT_TOOL_RCLICKED(win, id, func):
|
||||
win.Connect(id, -1, wxEVT_COMMAND_TOOL_RCLICKED, func)
|
||||
|
||||
def EVT_TOOL_RCLICKED_RANGE(win, id, id2, func):
|
||||
win.Connect(id, id2, wxEVT_COMMAND_TOOL_RCLICKED, func)
|
||||
|
||||
def EVT_TOOL_ENTER(win, id, func):
|
||||
win.Connect(id, -1, wxEVT_COMMAND_TOOL_ENTER, func)
|
||||
|
||||
def EVT_CHECKLISTBOX(win, id, func):
|
||||
win.Connect(id, -1, wxEVT_COMMAND_CHECKLISTBOX_TOGGLED, func)
|
||||
|
||||
def EVT_SPINCTRL(win, id, func):
|
||||
win.Connect(id, -1, wxEVT_COMMAND_SPINCTRL_UPDATED, func)
|
||||
|
||||
|
||||
|
||||
# Generic command events
|
||||
|
||||
|
@ -27,6 +27,11 @@
|
||||
|
||||
#ifdef __WXGTK__
|
||||
#include <gtk/gtk.h>
|
||||
#include <gdk/gdkprivate.h>
|
||||
#include <wx/gtk/win_gtk.h>
|
||||
//#include <gdk/gdk.h>
|
||||
//#include <gdk/gdkx.h>
|
||||
//#include <gtk/gtkwindow.h>
|
||||
#endif
|
||||
|
||||
|
||||
@ -575,6 +580,25 @@ PyObject* wxPy_ConvertList(wxListBase* list, const char* className) {
|
||||
return pyList;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
long wxPyGetWinHandle(wxWindow* win) {
|
||||
#ifdef __WXMSW__
|
||||
return (long)win->GetHandle();
|
||||
#endif
|
||||
|
||||
// Find and return the actual X-Window.
|
||||
#ifdef __WXGTK__
|
||||
if (win->m_wxwindow) {
|
||||
GdkWindowPrivate* bwin = (GdkWindowPrivate*)GTK_PIZZA(win->m_wxwindow)->bin_window;
|
||||
if (bwin) {
|
||||
return (long)bwin->xwindow;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Some helper functions for typemaps in my_typemaps.i, so they won't be
|
||||
// included in every file...
|
||||
|
@ -70,7 +70,7 @@ HELPEREXPORT PyObject* wxPyConstructObject(void* ptr, const char* className);
|
||||
HELPEREXPORT bool wxPyRestoreThread();
|
||||
HELPEREXPORT void wxPySaveThread(bool doSave);
|
||||
HELPEREXPORT PyObject* wxPy_ConvertList(wxListBase* list, const char* className);
|
||||
|
||||
HELPEREXPORT long wxPyGetWinHandle(wxWindow* win);
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
|
@ -207,7 +207,7 @@ public:
|
||||
wxWindow * GetGrandParent();
|
||||
%addmethods {
|
||||
long GetHandle() {
|
||||
return (long)self->GetHandle();
|
||||
return wxPyGetWinHandle(self); //(long)self->GetHandle();
|
||||
}
|
||||
}
|
||||
int GetId();
|
||||
|
Loading…
Reference in New Issue
Block a user