mirror of
https://github.com/wxWidgets/Phoenix.git
synced 2026-01-07 20:40:11 +01:00
More work on wxDVC support, including DataViewItem support and GetValue override work, along with a few misc. things, and add a script in etgtools to create new etg files given command line params.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxPython/Phoenix/trunk@69197 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import wx
|
||||
|
||||
class DataViewItemObjectMapper(object):
|
||||
"""
|
||||
This class provides a mechanism for mapping between Python objects and the
|
||||
@@ -32,7 +34,7 @@ class DataViewItemObjectMapper(object):
|
||||
"""
|
||||
Retrieve the object that was used to create an item.
|
||||
"""
|
||||
oid = item.GetID()
|
||||
oid = int(item.GetID())
|
||||
return self.mapper[oid]
|
||||
|
||||
def UseWeakRefs(self, flag):
|
||||
@@ -51,8 +53,34 @@ class DataViewItemObjectMapper(object):
|
||||
self.mapper = newmap
|
||||
self.usingWeakRefs = flag
|
||||
|
||||
class PyDataViewModel(DataViewModelBase, DataViewItemObjectMapper):
|
||||
def __init__(self, *a, **kw):
|
||||
super(PyDataViewModel, self).__init__(*a, **kw)
|
||||
class PyDataViewModel(PyDataViewModelBase, DataViewItemObjectMapper):
|
||||
def __init__(self):
|
||||
PyDataViewModelBase.__init__(self)
|
||||
DataViewItemObjectMapper.__init__(self)
|
||||
|
||||
NullDataViewItem = DataViewItem()
|
||||
|
||||
EVT_DATAVIEW_SELECTION_CHANGED = wx.PyEventBinder(wxEVT_COMMAND_DATAVIEW_SELECTION_CHANGED, 1)
|
||||
|
||||
EVT_DATAVIEW_ITEM_ACTIVATED = wx.PyEventBinder(wxEVT_COMMAND_DATAVIEW_ITEM_ACTIVATED, 1)
|
||||
EVT_DATAVIEW_ITEM_COLLAPSING = wx.PyEventBinder(wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSING, 1)
|
||||
EVT_DATAVIEW_ITEM_COLLAPSED = wx.PyEventBinder(wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSED, 1)
|
||||
EVT_DATAVIEW_ITEM_EXPANDING = wx.PyEventBinder(wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDING, 1)
|
||||
EVT_DATAVIEW_ITEM_EXPANDED = wx.PyEventBinder(wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDED, 1)
|
||||
EVT_DATAVIEW_ITEM_START_EDITING = wx.PyEventBinder(wxEVT_COMMAND_DATAVIEW_ITEM_START_EDITING, 1)
|
||||
EVT_DATAVIEW_ITEM_EDITING_STARTED = wx.PyEventBinder(wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_STARTED, 1)
|
||||
EVT_DATAVIEW_ITEM_EDITING_DONE = wx.PyEventBinder(wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_DONE, 1)
|
||||
EVT_DATAVIEW_ITEM_VALUE_CHANGED = wx.PyEventBinder(wxEVT_COMMAND_DATAVIEW_ITEM_VALUE_CHANGED, 1)
|
||||
|
||||
EVT_DATAVIEW_ITEM_CONTEXT_MENU = wx.PyEventBinder(wxEVT_COMMAND_DATAVIEW_ITEM_CONTEXT_MENU, 1)
|
||||
|
||||
EVT_DATAVIEW_COLUMN_HEADER_CLICK = wx.PyEventBinder(wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_CLICK, 1)
|
||||
EVT_DATAVIEW_COLUMN_HEADER_RIGHT_CLICKED = wx.PyEventBinder(wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK, 1)
|
||||
EVT_DATAVIEW_COLUMN_SORTED = wx.PyEventBinder(wxEVT_COMMAND_DATAVIEW_COLUMN_SORTED, 1)
|
||||
EVT_DATAVIEW_COLUMN_REORDERED = wx.PyEventBinder(wxEVT_COMMAND_DATAVIEW_COLUMN_REORDERED, 1)
|
||||
EVT_DATAVIEW_CACHE_HINT = wx.PyEventBinder(wxEVT_COMMAND_DATAVIEW_CACHE_HINT, 1)
|
||||
|
||||
EVT_DATAVIEW_ITEM_BEGIN_DRAG = wx.PyEventBinder(wxEVT_COMMAND_DATAVIEW_ITEM_BEGIN_DRAG, 1)
|
||||
EVT_DATAVIEW_ITEM_DROP_POSSIBLE = wx.PyEventBinder(wxEVT_COMMAND_DATAVIEW_ITEM_DROP_POSSIBLE, 1)
|
||||
EVT_DATAVIEW_ITEM_DROP = wx.PyEventBinder(wxEVT_COMMAND_DATAVIEW_ITEM_DROP, 1)
|
||||
|
||||
|
||||
|
||||
@@ -31,10 +31,15 @@ public:
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
virtual void GetValue( wxVariant &variant,
|
||||
void GetValue( wxVariant &variant,
|
||||
const wxDataViewItem &item, unsigned int col ) const
|
||||
{
|
||||
variant = GetValue(item, col);
|
||||
}
|
||||
|
||||
virtual wxVariant GetValue( const wxDataViewItem &item, unsigned int col ) const
|
||||
{
|
||||
return wxVariant();
|
||||
}
|
||||
|
||||
virtual bool SetValue( const wxVariant &variant,
|
||||
@@ -50,7 +55,7 @@ public:
|
||||
|
||||
virtual bool IsEnabled(const wxDataViewItem &item, unsigned int col) const
|
||||
{
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
virtual unsigned int GetColumnCount() const
|
||||
@@ -84,38 +89,16 @@ public:
|
||||
|
||||
virtual int Compare (const wxDataViewItem &item1, const wxDataViewItem &item2, unsigned int column, bool ascending) const;
|
||||
|
||||
virtual wxVariant GetValue( const wxDataViewItem &item, unsigned int col ) const;
|
||||
|
||||
virtual void GetValue( wxVariant &variant,
|
||||
const wxDataViewItem &item, unsigned int col ) const;
|
||||
|
||||
/* FIXME: This is how we want to implement the method, but when compiling it always wants
|
||||
the void version of this method, even if we add both.
|
||||
virtual wxVariant GetValue( wxVariant &variant,
|
||||
void GetValue( wxVariant &variant,
|
||||
const wxDataViewItem &item, unsigned int col ) const;
|
||||
%MethodCode
|
||||
Py_BEGIN_ALLOW_THREADS
|
||||
wxVariant result;
|
||||
sipCpp->wxDataViewModel::GetValue(result, item, col);
|
||||
sipRes = result;
|
||||
// call the version that returns a variant so that it will call the Python callback
|
||||
*variant = sipCpp->GetValue(*item, col);
|
||||
Py_END_ALLOW_THREADS
|
||||
%End
|
||||
%VirtualCatcherCode
|
||||
// Convert the 2 element array of integers to the two element
|
||||
// tuple.
|
||||
|
||||
PyObject *result;
|
||||
|
||||
result = sipCallMethod(&sipIsErr, sipMethod, "Oi", item, col);
|
||||
|
||||
if (result != NULL)
|
||||
{
|
||||
// Convert the result to the C++ type.
|
||||
sipParseResult(&sipIsErr, sipMethod, result, "i", &sipRes);
|
||||
|
||||
Py_DECREF(result);
|
||||
}
|
||||
%End
|
||||
*/
|
||||
|
||||
virtual bool SetValue( const wxVariant &variant,
|
||||
const wxDataViewItem &item, unsigned int col );
|
||||
@@ -133,6 +116,27 @@ public:
|
||||
virtual bool IsContainer(const wxDataViewItem&) const;
|
||||
};
|
||||
|
||||
/*
|
||||
%MappedType wxPyLongPtr
|
||||
{
|
||||
%ConvertToTypeCode
|
||||
// Code to test a PyObject for compatibility
|
||||
if (!sipIsErr) {
|
||||
return PyLong_Check(sipPy) || PyInt_Check(sipPy);
|
||||
}
|
||||
if (PyLong_Check(sipPy) || PyInt_Check(sipPy))
|
||||
*sipCppPtrV = (wxPyLongPtr)PyLong_AsVoidPtr(sipPy);
|
||||
|
||||
return sipGetState(sipTransferObj);
|
||||
%End
|
||||
|
||||
|
||||
%ConvertFromTypeCode
|
||||
return PyLong_FromVoidPtr(sipCpp);
|
||||
%End
|
||||
|
||||
};
|
||||
*/
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
|
||||
@@ -281,10 +281,13 @@ EVT_UPDATE_UI_RANGE = wx.PyEventBinder( wxEVT_UPDATE_UI, 2)
|
||||
|
||||
EVT_CONTEXT_MENU = wx.PyEventBinder( wxEVT_CONTEXT_MENU )
|
||||
|
||||
EVT_TEXT = wx.PyEventBinder( wxEVT_COMMAND_TEXT_UPDATED )
|
||||
EVT_TEXT_CUT = wx.PyEventBinder( wxEVT_COMMAND_TEXT_CUT )
|
||||
EVT_TEXT_COPY = wx.PyEventBinder( wxEVT_COMMAND_TEXT_COPY )
|
||||
EVT_TEXT_PASTE = wx.PyEventBinder( wxEVT_COMMAND_TEXT_PASTE )
|
||||
|
||||
EVT_THREAD = wx.PyEventBinder( wxEVT_THREAD )
|
||||
|
||||
EVT_WINDOW_MODAL_DIALOG_CLOSED = wx.PyEventBinder( wxEVT_WINDOW_MODAL_DIALOG_CLOSED )
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user