mirror of
https://github.com/wxWidgets/Phoenix.git
synced 2026-01-04 11:00:07 +01:00
Fix some virtual method signatures
This commit is contained in:
@@ -27,7 +27,8 @@ class MyCustomRenderer(dv.DataViewCustomRenderer):
|
|||||||
# has a helper function we can use for measuring text that is
|
# has a helper function we can use for measuring text that is
|
||||||
# aware of any custom attributes that may have been set for
|
# aware of any custom attributes that may have been set for
|
||||||
# this item.
|
# this item.
|
||||||
return self.GetTextExtent(self.value)
|
value = self.value if self.value else ""
|
||||||
|
return self.GetTextExtent(value)
|
||||||
|
|
||||||
|
|
||||||
def Render(self, rect, dc, state):
|
def Render(self, rect, dc, state):
|
||||||
@@ -45,15 +46,16 @@ class MyCustomRenderer(dv.DataViewCustomRenderer):
|
|||||||
# And then finish up with this helper function that draws the
|
# And then finish up with this helper function that draws the
|
||||||
# text for us, dealing with alignment, font and color
|
# text for us, dealing with alignment, font and color
|
||||||
# attributes, etc
|
# attributes, etc
|
||||||
self.RenderText(self.value,
|
value = self.value if self.value else ""
|
||||||
|
self.RenderText(value,
|
||||||
4, # x-offset, to compensate for the rounded rectangles
|
4, # x-offset, to compensate for the rounded rectangles
|
||||||
rect,
|
rect,
|
||||||
dc,
|
dc,
|
||||||
state # wxDataViewCellRenderState flags
|
state # wxDataViewCellRenderState flags
|
||||||
)
|
)
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
# The HasEditorCtrl, CreateEditorCtrl and GetValueFromEditorCtrl
|
# The HasEditorCtrl, CreateEditorCtrl and GetValueFromEditorCtrl
|
||||||
# methods need to be implemented if this renderer is going to
|
# methods need to be implemented if this renderer is going to
|
||||||
# support in-place editing of the cell value, otherwise they can
|
# support in-place editing of the cell value, otherwise they can
|
||||||
@@ -101,7 +103,7 @@ class MyCustomRenderer(dv.DataViewCustomRenderer):
|
|||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
|
|
||||||
# To help focus this sammple on the custom renderer, we'll reuse the
|
# To help focus this sample on the custom renderer, we'll reuse the
|
||||||
# model class from another sample.
|
# model class from another sample.
|
||||||
from DVC_IndexListModel import TestModel
|
from DVC_IndexListModel import TestModel
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import wx.dataview as dv
|
|||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
|
|
||||||
# This model class provides the data to the view when it is asked for.
|
# This model class provides the data to the view when it is asked for.
|
||||||
# Since it is a list-only model (no hierachical data) then it is able
|
# Since it is a list-only model (no hierarchical data) then it is able
|
||||||
# to be referenced by row rather than by item object, so in this way
|
# to be referenced by row rather than by item object, so in this way
|
||||||
# it is easier to comprehend and use than other model types. In this
|
# it is easier to comprehend and use than other model types. In this
|
||||||
# example we also provide a Compare function to assist with sorting of
|
# example we also provide a Compare function to assist with sorting of
|
||||||
@@ -39,6 +39,7 @@ class TestModel(dv.DataViewIndexListModel):
|
|||||||
def SetValueByRow(self, value, row, col):
|
def SetValueByRow(self, value, row, col):
|
||||||
self.log.write("SetValue: (%d,%d) %s\n" % (row, col, value))
|
self.log.write("SetValue: (%d,%d) %s\n" % (row, col, value))
|
||||||
self.data[row][col] = value
|
self.data[row][col] = value
|
||||||
|
return True
|
||||||
|
|
||||||
# Report how many columns this model provides data for.
|
# Report how many columns this model provides data for.
|
||||||
def GetColumnCount(self):
|
def GetColumnCount(self):
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ import sys, os
|
|||||||
# stuff for debugging
|
# stuff for debugging
|
||||||
print("Python %s" % sys.version)
|
print("Python %s" % sys.version)
|
||||||
print("wx.version: %s" % wx.version())
|
print("wx.version: %s" % wx.version())
|
||||||
##print("pid: %s" % os.getpid()); raw_input("Press Enter...")
|
##print("pid: %s" % os.getpid()); input("Press Enter...")
|
||||||
|
|
||||||
assertMode = wx.APP_ASSERT_DIALOG
|
assertMode = wx.APP_ASSERT_DIALOG
|
||||||
##assertMode = wx.APP_ASSERT_EXCEPTION
|
##assertMode = wx.APP_ASSERT_EXCEPTION
|
||||||
|
|||||||
@@ -229,6 +229,7 @@ def run():
|
|||||||
def _fixupBoolGetters(method, sig):
|
def _fixupBoolGetters(method, sig):
|
||||||
method.type = 'void'
|
method.type = 'void'
|
||||||
method.find('value').out = True
|
method.find('value').out = True
|
||||||
|
method.find('value').type = 'wxDVCVariant&'
|
||||||
method.cppSignature = sig
|
method.cppSignature = sig
|
||||||
|
|
||||||
|
|
||||||
@@ -240,17 +241,38 @@ def run():
|
|||||||
|
|
||||||
# Change variant getters to return the value
|
# Change variant getters to return the value
|
||||||
for name, sig in [
|
for name, sig in [
|
||||||
('GetValue', 'bool (wxDVCVariant& value)'),
|
('GetValue', 'bool (wxVariant& value)'),
|
||||||
('GetValueFromEditorCtrl', 'bool (wxWindow * editor, wxDVCVariant& value)'),
|
('GetValueFromEditorCtrl', 'bool (wxWindow * editor, wxVariant& value)'),
|
||||||
]:
|
]:
|
||||||
_fixupBoolGetters(c.find(name), sig)
|
_fixupBoolGetters(c.find(name), sig)
|
||||||
|
|
||||||
|
m = c.find('SetValue')
|
||||||
|
m.find('value').type = 'wxDVCVariant&'
|
||||||
|
m.cppSignature = 'bool (const wxVariant& value)'
|
||||||
|
|
||||||
|
|
||||||
c = module.find('wxDataViewCustomRenderer')
|
c = module.find('wxDataViewCustomRenderer')
|
||||||
_fixupBoolGetters(c.find('GetValueFromEditorCtrl'),
|
m = c.find('GetValueFromEditorCtrl')
|
||||||
'bool (wxWindow * editor, wxDVCVariant& value)')
|
_fixupBoolGetters(m, 'bool (wxWindow * editor, wxVariant& value)')
|
||||||
|
|
||||||
|
# m.virtualCatcherCode = """\
|
||||||
|
# bool sipRes = 0;
|
||||||
|
# PyObject *sipResObj = sipCallMethod(0, sipMethod, "D", editor, sipType_wxWindow, NULL);
|
||||||
|
#
|
||||||
|
# sipParseResultEx(sipGILState, sipErrorHandler, sipPySelf, sipMethod, sipResObj, "(bH5)", &sipRes, sipType_wxDVCVariant, &value);
|
||||||
|
#
|
||||||
|
# return sipRes;
|
||||||
|
#
|
||||||
|
# """
|
||||||
|
|
||||||
c.find('GetTextExtent').ignore(False)
|
c.find('GetTextExtent').ignore(False)
|
||||||
|
|
||||||
|
c.addItem(etgtools.WigCode("""\
|
||||||
|
virtual bool SetValue( const wxDVCVariant &value ) [bool (const wxVariant& value)];
|
||||||
|
virtual void GetValue( wxDVCVariant &value /Out/ ) const [bool (wxVariant& value)];
|
||||||
|
%Property(name=Value, get=GetValue, set=SetValue)
|
||||||
|
""", protection='public'))
|
||||||
|
|
||||||
module.addPyCode("""\
|
module.addPyCode("""\
|
||||||
PyDataViewCustomRenderer = wx.deprecated(DataViewCustomRenderer,
|
PyDataViewCustomRenderer = wx.deprecated(DataViewCustomRenderer,
|
||||||
"Use DataViewCustomRenderer instead")""")
|
"Use DataViewCustomRenderer instead")""")
|
||||||
@@ -272,10 +294,10 @@ def run():
|
|||||||
c.addAutoProperties()
|
c.addAutoProperties()
|
||||||
|
|
||||||
c.addItem(etgtools.WigCode("""\
|
c.addItem(etgtools.WigCode("""\
|
||||||
virtual bool SetValue( const wxDVCVariant &value );
|
virtual bool SetValue( const wxDVCVariant &value ) [bool (const wxVariant& value)];
|
||||||
virtual void GetValue( wxDVCVariant &value /Out/ ) const [bool (wxDVCVariant& value)];
|
virtual void GetValue( wxDVCVariant &value /Out/ ) const [bool (wxVariant& value)];
|
||||||
%Property(name=Value, get=GetValue, set=SetValue)
|
%Property(name=Value, get=GetValue, set=SetValue)
|
||||||
"""))
|
""", protection='public'))
|
||||||
|
|
||||||
|
|
||||||
# The SpinRenderer has a few additional pure virtuals that need to be declared
|
# The SpinRenderer has a few additional pure virtuals that need to be declared
|
||||||
|
|||||||
@@ -224,7 +224,7 @@ def run():
|
|||||||
|
|
||||||
# Code for C++ --> Python calls. This is used when a C++ method
|
# Code for C++ --> Python calls. This is used when a C++ method
|
||||||
# call needs to be reflected to a call to the overridden Python
|
# call needs to be reflected to a call to the overridden Python
|
||||||
# method, so we need to translate between the real C++ siganture
|
# method, so we need to translate between the real C++ signature
|
||||||
# and the Python signature.
|
# and the Python signature.
|
||||||
virtualCatcherCode="""\
|
virtualCatcherCode="""\
|
||||||
// VirtualCatcherCode for wx.grid.GridCellEditor.EndEdit
|
// VirtualCatcherCode for wx.grid.GridCellEditor.EndEdit
|
||||||
|
|||||||
@@ -26,7 +26,8 @@ class MyCustomRenderer(dv.DataViewCustomRenderer):
|
|||||||
# has a helper function we can use for measuring text that is
|
# has a helper function we can use for measuring text that is
|
||||||
# aware of any custom attributes that may have been set for
|
# aware of any custom attributes that may have been set for
|
||||||
# this item.
|
# this item.
|
||||||
size = self.GetTextExtent(self.value)
|
value = self.value if self.value else ""
|
||||||
|
size = self.GetTextExtent(value)
|
||||||
return size
|
return size
|
||||||
|
|
||||||
|
|
||||||
@@ -45,7 +46,8 @@ class MyCustomRenderer(dv.DataViewCustomRenderer):
|
|||||||
# And then finish up with this helper function that draws the
|
# And then finish up with this helper function that draws the
|
||||||
# text for us, dealing with alignment, font and color
|
# text for us, dealing with alignment, font and color
|
||||||
# attributes, etc
|
# attributes, etc
|
||||||
self.RenderText(self.value,
|
value = self.value if self.value else ""
|
||||||
|
self.RenderText(value,
|
||||||
4, # x-offset, to compensate for the rounded rectangles
|
4, # x-offset, to compensate for the rounded rectangles
|
||||||
rect,
|
rect,
|
||||||
dc,
|
dc,
|
||||||
|
|||||||
Reference in New Issue
Block a user