mirror of
https://github.com/wxWidgets/Phoenix.git
synced 2025-12-15 17:20: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
|
||||
# aware of any custom attributes that may have been set for
|
||||
# this item.
|
||||
return self.GetTextExtent(self.value)
|
||||
value = self.value if self.value else ""
|
||||
return self.GetTextExtent(value)
|
||||
|
||||
|
||||
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
|
||||
# text for us, dealing with alignment, font and color
|
||||
# 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
|
||||
rect,
|
||||
dc,
|
||||
state # wxDataViewCellRenderState flags
|
||||
)
|
||||
|
||||
return True
|
||||
|
||||
|
||||
# The HasEditorCtrl, CreateEditorCtrl and GetValueFromEditorCtrl
|
||||
# methods need to be implemented if this renderer is going to
|
||||
# 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.
|
||||
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.
|
||||
# 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
|
||||
# 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
|
||||
@@ -39,6 +39,7 @@ class TestModel(dv.DataViewIndexListModel):
|
||||
def SetValueByRow(self, value, row, col):
|
||||
self.log.write("SetValue: (%d,%d) %s\n" % (row, col, value))
|
||||
self.data[row][col] = value
|
||||
return True
|
||||
|
||||
# Report how many columns this model provides data for.
|
||||
def GetColumnCount(self):
|
||||
|
||||
@@ -25,7 +25,7 @@ import sys, os
|
||||
# stuff for debugging
|
||||
print("Python %s" % sys.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_EXCEPTION
|
||||
|
||||
@@ -229,6 +229,7 @@ def run():
|
||||
def _fixupBoolGetters(method, sig):
|
||||
method.type = 'void'
|
||||
method.find('value').out = True
|
||||
method.find('value').type = 'wxDVCVariant&'
|
||||
method.cppSignature = sig
|
||||
|
||||
|
||||
@@ -240,17 +241,38 @@ def run():
|
||||
|
||||
# Change variant getters to return the value
|
||||
for name, sig in [
|
||||
('GetValue', 'bool (wxDVCVariant& value)'),
|
||||
('GetValueFromEditorCtrl', 'bool (wxWindow * editor, wxDVCVariant& value)'),
|
||||
('GetValue', 'bool (wxVariant& value)'),
|
||||
('GetValueFromEditorCtrl', 'bool (wxWindow * editor, wxVariant& value)'),
|
||||
]:
|
||||
_fixupBoolGetters(c.find(name), sig)
|
||||
|
||||
m = c.find('SetValue')
|
||||
m.find('value').type = 'wxDVCVariant&'
|
||||
m.cppSignature = 'bool (const wxVariant& value)'
|
||||
|
||||
|
||||
c = module.find('wxDataViewCustomRenderer')
|
||||
_fixupBoolGetters(c.find('GetValueFromEditorCtrl'),
|
||||
'bool (wxWindow * editor, wxDVCVariant& value)')
|
||||
m = c.find('GetValueFromEditorCtrl')
|
||||
_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.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("""\
|
||||
PyDataViewCustomRenderer = wx.deprecated(DataViewCustomRenderer,
|
||||
"Use DataViewCustomRenderer instead")""")
|
||||
@@ -272,10 +294,10 @@ def run():
|
||||
c.addAutoProperties()
|
||||
|
||||
c.addItem(etgtools.WigCode("""\
|
||||
virtual bool SetValue( const wxDVCVariant &value );
|
||||
virtual void GetValue( wxDVCVariant &value /Out/ ) const [bool (wxDVCVariant& value)];
|
||||
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'))
|
||||
|
||||
|
||||
# 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
|
||||
# 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.
|
||||
virtualCatcherCode="""\
|
||||
// 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
|
||||
# aware of any custom attributes that may have been set for
|
||||
# this item.
|
||||
size = self.GetTextExtent(self.value)
|
||||
value = self.value if self.value else ""
|
||||
size = self.GetTextExtent(value)
|
||||
return size
|
||||
|
||||
|
||||
@@ -45,7 +46,8 @@ class MyCustomRenderer(dv.DataViewCustomRenderer):
|
||||
# And then finish up with this helper function that draws the
|
||||
# text for us, dealing with alignment, font and color
|
||||
# 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
|
||||
rect,
|
||||
dc,
|
||||
|
||||
Reference in New Issue
Block a user