Skip to content

Commit 93bca1d

Browse files
authored
Merge pull request #718 from RobinD42/fix-issue716
Allow buffer objects in RGBImage methods in STC
2 parents de70310 + b378df4 commit 93bca1d

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

CHANGES.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,10 @@ Changes in this release include the following:
121121
subordinate extensions that have their own wxModules (wx.html, wx.adv, etc.)
122122
(#688)
123123

124+
* Fixed StyledTextCtrl.MarkerDefineRGBAImage and RegisterRGBAImage methods to
125+
be able to accept any Python buffer compatible object for the pixel data. (#716)
126+
127+
124128

125129

126130

etg/_stc.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ def run():
6464
#-----------------------------------------------------------------
6565

6666
module.addHeaderCode('#include <wx/stc/stc.h>')
67+
module.addHeaderCode('#include "wxpybuffer.h"')
6768

6869

6970
c = module.find('wxStyledTextCtrl')
@@ -162,6 +163,29 @@ def run():
162163
c.find('ShowNativeCaret').ignore()
163164
c.find('HideNativeCaret').ignore()
164165

166+
# Change the *RGBAImage methods to accept any buffer object
167+
c.find('MarkerDefineRGBAImage').ignore()
168+
c.addCppMethod('void', 'MarkerDefineRGBAImage', '(int markerNumber, wxPyBuffer* pixels)',
169+
doc="""\
170+
Define a marker from RGBA data.\n
171+
It has the width and height from RGBAImageSetWidth/Height. You must
172+
ensure that the buffer is at least width*height*4 bytes long.
173+
""",
174+
body="""\
175+
self->MarkerDefineRGBAImage(markerNumber, (unsigned char*)pixels->m_ptr);
176+
""")
177+
178+
c.find('RegisterRGBAImage').ignore()
179+
c.addCppMethod('void', 'RegisterRGBAImage', '(int type, wxPyBuffer* pixels)',
180+
doc="""\
181+
Register an RGBA image for use in autocompletion lists.\n
182+
It has the width and height from RGBAImageSetWidth/Height. You must
183+
ensure that the buffer is at least width*height*4 bytes long.
184+
""",
185+
body="""\
186+
self->RegisterRGBAImage(type, (unsigned char*)pixels->m_ptr);
187+
""")
188+
165189

166190
# TODO: Add the UTF8 PyMethods from classic (see _stc_utf8_methods.py)
167191

0 commit comments

Comments
 (0)