From ebdc838151cae1753a0c11f6d91afb1b1fd453b0 Mon Sep 17 00:00:00 2001 From: New Pagodi Date: Wed, 30 Jan 2019 18:18:21 -0600 Subject: [PATCH 1/8] Preserve recent changes to wxSTC documentation Recent commits 8fbca5cb70 and c68e5d0617 fixed some typos is the documentation for wxSTC. Unfortunatly these changes will be lost the next time the wxSTC files are regenerated. This commit modifies stc.interface.h.in and gen_docs.py to ensure that these changes are preserved when the wxSTC files are regenerated. --- src/stc/gen_docs.py | 8 +++++++- src/stc/stc.interface.h.in | 4 ++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/stc/gen_docs.py b/src/stc/gen_docs.py index c66ff27f77..a4de040ab7 100644 --- a/src/stc/gen_docs.py +++ b/src/stc/gen_docs.py @@ -844,7 +844,13 @@ docSubstitutions = { 'SC_SEL_RECTANGLE':'wxSTC_SEL_RECTANGLE','SC_SEL_THIN':'wxSTC_SEL_THIN', 'SC_SEL_LINES':'wxSTC_SEL_LINES'}, - 'SetFontQuality':{' from the FontQuality enumeration':''} + 'SetFontQuality':{' from the FontQuality enumeration':''}, + + 'GetWrapVisualFlags':{'Retrive':'Retrieve'}, + + 'GetWrapVisualFlagsLocation':{'Retrive':'Retrieve'}, + + 'GetWrapStartIndent':{'Retrive':'Retrieve'} } diff --git a/src/stc/stc.interface.h.in b/src/stc/stc.interface.h.in index 8e18eb8677..ec7885b0dd 100644 --- a/src/stc/stc.interface.h.in +++ b/src/stc/stc.interface.h.in @@ -7,7 +7,7 @@ /* IMPORTANT: This file is generated by src/stc/gen_iface.py from - src/stc/stc.interface.h.in. Do not edit the file in + src/stc/stc.interface.h.in. Do not edit the file in interface/wx/stc or your changes will be lost. */ @@ -223,7 +223,7 @@ public: /** Extract style settings from a spec-string which is composed of one or more of the following comma separated elements: - + bold turns on bold italic turns on italics fore:[name or \#RRGGBB] sets the foreground colour From 91d3981a7bfb4de206fea4a4f89ed07d57b269e8 Mon Sep 17 00:00:00 2001 From: New Pagodi Date: Sat, 2 Feb 2019 16:10:57 -0600 Subject: [PATCH 2/8] Implement BitmapFromRGBAImage without raw bitmap The function BitmapFromRGBAImage in PlatWX.cpp is currently only used when wxHAS_RAW_BITMAP is defined. Consequently some functions in PlatWX.cpp simply do nothing when wxHAS_RAW_BITMAP is not defined. This provides a second implementation of the function based on wxImage that is used when wxHAS_RAW_BITMAP is not defined. --- src/stc/PlatWX.cpp | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/src/stc/PlatWX.cpp b/src/stc/PlatWX.cpp index ffb3db94bc..44dfca3664 100644 --- a/src/stc/PlatWX.cpp +++ b/src/stc/PlatWX.cpp @@ -31,6 +31,7 @@ #include "wx/imaglist.h" #include "wx/tokenzr.h" #include "wx/dynlib.h" +#include "wx/scopedarray.h" #ifdef wxHAS_RAW_BITMAP #include "wx/rawbmp.h" @@ -508,17 +509,36 @@ wxBitmap BitmapFromRGBAImage(int width, int height, const unsigned char *pixelsI } return bmp; } +#else +wxBitmap BitmapFromRGBAImage(int width, int height, const unsigned char *pixelsImage) +{ + const int totalPixels = width * height; + wxScopedArray data(3*totalPixels); + wxScopedArray alpha(totalPixels); + int curDataLocation = 0, curAlphaLocation = 0, curPixelsImageLocation = 0; + + for ( int i = 0; i < totalPixels; ++i ) + { + data[curDataLocation++] = pixelsImage[curPixelsImageLocation++]; + data[curDataLocation++] = pixelsImage[curPixelsImageLocation++]; + data[curDataLocation++] = pixelsImage[curPixelsImageLocation++]; + alpha[curAlphaLocation++] = pixelsImage[curPixelsImageLocation++]; + } + + wxImage img(width, height, data.get(), alpha.get(), true); + wxBitmap bmp(img); + + return bmp; +} #endif void SurfaceImpl::DrawRGBAImage(PRectangle rc, int width, int height, const unsigned char *pixelsImage) { -#ifdef wxHAS_RAW_BITMAP wxRect r = wxRectFromPRectangle(rc); wxBitmap bmp = BitmapFromRGBAImage(width, height, pixelsImage); hdc->DrawBitmap(bmp, r.x, r.y, true); -#endif } @@ -2551,10 +2571,8 @@ void ListBoxImpl::RegisterImage(int type, const char *xpm_data) { void ListBoxImpl::RegisterRGBAImage(int type, int width, int height, const unsigned char *pixelsImage) { -#ifdef wxHAS_RAW_BITMAP wxBitmap bmp = BitmapFromRGBAImage(width, height, pixelsImage); RegisterImageHelper(type, bmp); -#endif } From 8c180ee7b5d00e1e083cdc874ccf8c2437d561eb Mon Sep 17 00:00:00 2001 From: New Pagodi Date: Sun, 17 Mar 2019 01:47:36 -0500 Subject: [PATCH 3/8] Change the implementation of ListBoxImpl::RegisterImage The ListBoxImpl::RegisterImage in PlatWX.cpp is supposed to accept an XPM and convert it into a useable form. For wxWidgets, the useable form is obviously a wxBitmap. According to the Scintilla specification, the function should accept both a copy of an XPM file and a set of XPM data. Currently RegisterImage uses the the wxWidgets XPM image handler. This has 2 drawbacks. First it requires that the XPM handler is loaded before the function can be called. Second, the function only accepts a copy of an XPM file and does not work with XPM data. Instead use wxXPMDecoder. This class can be decode both types of input and can be used to build a wxBitmap. --- src/stc/PlatWX.cpp | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/stc/PlatWX.cpp b/src/stc/PlatWX.cpp index 44dfca3664..58a448deec 100644 --- a/src/stc/PlatWX.cpp +++ b/src/stc/PlatWX.cpp @@ -27,6 +27,7 @@ #include "wx/encconv.h" #include "wx/listctrl.h" #include "wx/mstream.h" +#include "wx/xpmdecod.h" #include "wx/image.h" #include "wx/imaglist.h" #include "wx/tokenzr.h" @@ -2561,10 +2562,23 @@ void ListBoxImpl::RegisterImageHelper(int type, wxBitmap& bmp) } void ListBoxImpl::RegisterImage(int type, const char *xpm_data) { - wxMemoryInputStream stream(xpm_data, strlen(xpm_data)+1); - wxImage img(stream, wxBITMAP_TYPE_XPM); + wxXPMDecoder dec; + wxImage img; + + // This check is borrowed from src/stc/scintilla/src/XPM.cpp. + // Test done is two parts to avoid possibility of overstepping the memory + // if memcmp implemented strangely. Must be 4 bytes at least at destination. + if ( (0 == memcmp(xpm_data, "/* X", 4)) && + (0 == memcmp(xpm_data, "/* XPM */", 9)) ) + { + wxMemoryInputStream stream(xpm_data, strlen(xpm_data)+1); + img = dec.ReadFile(stream); + } + else + img = dec.ReadData(reinterpret_cast(xpm_data)); + wxBitmap bmp(img); - RegisterImageHelper(type, bmp); + RegisterImageHelper(type,bmp); } From f50b18000af921c595d4bc3353f15e49a5141027 Mon Sep 17 00:00:00 2001 From: New Pagodi Date: Thu, 14 Feb 2019 22:25:57 -0600 Subject: [PATCH 4/8] Change wxSTC mapping for SCI_MARKERDEFINEPIXMAP Currently the Scintilla message SCI_MARKERDEFINEPIXMAP is mapped to the wxStyledTextCtrl::MarkerDefineBitmap method. This has two drawbacks. First this requires the XPM image handler be loaded before this method can be called. Second, any alpha data except for opaque and transparent is lost in the conversion to XPM format. Instead have MarkerDefineBitmap be a manually declared method but reimplemented it in a way similar to how the SCI_MARKERDEFINERGBAIMAGE message works. The new implementation preserves alpha data if it exists. To backfill the message map, the SCI_MARKERDEFINEPIXMAP is now mapped to a new method MarkerDefinePixmap(int, const char* const*). The new method accepts XPM data instead of a wxBitmap. --- src/stc/ScintillaWX.cpp | 29 +++++++++++++++++++++++++++++ src/stc/ScintillaWX.h | 1 + src/stc/gen_docs.py | 7 +++++-- src/stc/gen_iface.py | 21 +++++---------------- src/stc/stc.cpp.in | 5 +++++ src/stc/stc.h.in | 3 +++ src/stc/stc.interface.h.in | 5 +++++ 7 files changed, 53 insertions(+), 18 deletions(-) diff --git a/src/stc/ScintillaWX.cpp b/src/stc/ScintillaWX.cpp index e9ddba686d..5ead9fc363 100644 --- a/src/stc/ScintillaWX.cpp +++ b/src/stc/ScintillaWX.cpp @@ -33,6 +33,8 @@ #include "wx/dataobj.h" #include "wx/clipbrd.h" #include "wx/dnd.h" +#include "wx/image.h" +#include "wx/scopedarray.h" #if !wxUSE_STD_CONTAINERS && !wxUSE_STD_IOSTREAM && !wxUSE_STD_STRING #include "wx/beforestd.h" @@ -1336,6 +1338,33 @@ bool ScintillaWX::GetUseAntiAliasing() { return vs.extraFontFlag != 0; } +void ScintillaWX::DoMarkerDefineBitmap(int markerNumber, const wxBitmap& bmp) { + if ( 0 <= markerNumber && markerNumber <= MARKER_MAX) { + // Build an RGBA buffer from bmp. + const int totalPixels = bmp.GetWidth() * bmp.GetHeight(); + wxScopedArray rgba(4*bmp.GetWidth()*bmp.GetHeight()); + wxImage img = bmp.ConvertToImage(); + int curRGBALoc = 0, curDataLoc = 0, curAlphaLoc = 0; + + for ( int i = 0; i < totalPixels; ++i ) { + rgba[curRGBALoc++] = img.GetData()[curDataLoc++]; + rgba[curRGBALoc++] = img.GetData()[curDataLoc++]; + rgba[curRGBALoc++] = img.GetData()[curDataLoc++]; + rgba[curRGBALoc++] = + img.HasAlpha()?img.GetAlpha()[curAlphaLoc++]:255; + } + + // Now follow the same procedure used for handling the + // SCI_MARKERDEFINERGBAIMAGE message, except use the bitmap's width and + // height instead of the values stored in sizeRGBAImage. + Point bitmapSize = Point::FromInts(bmp.GetWidth(), bmp.GetHeight()); + vs.markers[markerNumber].SetRGBAImage(bitmapSize, 1.0f, rgba.get()); + vs.CalcLargestMarkerHeight(); + } + InvalidateStyleData(); + RedrawSelMargin(); +} + sptr_t ScintillaWX::DirectFunction( ScintillaWX* swx, unsigned int iMessage, uptr_t wParam, sptr_t lParam) { return swx->WndProc(iMessage, wParam, lParam); diff --git a/src/stc/ScintillaWX.h b/src/stc/ScintillaWX.h index d4d03f9c0e..b858809b0f 100644 --- a/src/stc/ScintillaWX.h +++ b/src/stc/ScintillaWX.h @@ -199,6 +199,7 @@ public: bool GetUseAntiAliasing(); SurfaceData* GetSurfaceData() const {return m_surfaceData;} void SetPaintAbandoned(){paintState = paintAbandoned;} + void DoMarkerDefineBitmap(int markerNumber, const wxBitmap& bmp); private: bool capturedMouse; diff --git a/src/stc/gen_docs.py b/src/stc/gen_docs.py index a4de040ab7..cb9b1774dd 100644 --- a/src/stc/gen_docs.py +++ b/src/stc/gen_docs.py @@ -40,7 +40,8 @@ categoriesList = [ ('OtherSettings' ,'Other settings', 0), ('BraceHighlighting' ,'Brace highlighting', 0), ('TabsAndIndentationGuides' ,'Tabs and Indentation Guides', 0), - ('Markers' ,'Markers', 0), + ('Markers' ,'Markers', + ('@see MarkerDefineBitmap',)), ('Indicators' ,'Indicators', 0), ('Autocompletion' ,'Autocompletion', 0), ('UserLists' ,'User lists', 0), @@ -1406,7 +1407,9 @@ sinceAnnotations= { 'SetMouseWheelCaptures':'3.1.1', 'SetTabDrawMode':'3.1.1', 'TargetWholeDocument':'3.1.1', - 'ToggleFoldShowText':'3.1.1' + 'ToggleFoldShowText':'3.1.1', + + 'MarkerDefinePixmap':'3.1.3' } diff --git a/src/stc/gen_iface.py b/src/stc/gen_iface.py index 2de2832169..4cfdd2c854 100755 --- a/src/stc/gen_iface.py +++ b/src/stc/gen_iface.py @@ -213,22 +213,11 @@ methodOverrideMap = { ), - 'MarkerDefinePixmap' : - ('MarkerDefineBitmap', - '''void %s(int markerNumber, const wxBitmap& bmp);''', - '''void %s(int markerNumber, const wxBitmap& bmp) { - // convert bmp to a xpm in a string - wxMemoryOutputStream strm; - wxImage img = bmp.ConvertToImage(); - if (img.HasAlpha()) - img.ConvertAlphaToMask(); - img.SaveFile(strm, wxBITMAP_TYPE_XPM); - size_t len = strm.GetSize(); - char* buff = new char[len+1]; - strm.CopyTo(buff, len); - buff[len] = 0; - SendMsg(%s, markerNumber, (sptr_t)buff); - delete [] buff;''' + 'MarkerDefinePixmap' : + (0, + '''void %s(int markerNumber, const char* const* xpmData);''', + '''void %s(int markerNumber, const char* const* xpmData) { + SendMsg(%s, markerNumber, (sptr_t)xpmData);''' ), 'GetMargins' : ('GetMarginCount', 0, 0), diff --git a/src/stc/stc.cpp.in b/src/stc/stc.cpp.in index 827633364d..d082ffd27c 100644 --- a/src/stc/stc.cpp.in +++ b/src/stc/stc.cpp.in @@ -563,6 +563,11 @@ void wxStyledTextCtrl::AnnotationClearLine(int line) { SendMsg(SCI_ANNOTATIONSETTEXT, line, (sptr_t)NULL); } +void wxStyledTextCtrl::MarkerDefineBitmap(int markerNumber, + const wxBitmap& bmp) { + m_swx->DoMarkerDefineBitmap(markerNumber, bmp); +} + diff --git a/src/stc/stc.h.in b/src/stc/stc.h.in index 8413084a7c..c21e8bf061 100644 --- a/src/stc/stc.h.in +++ b/src/stc/stc.h.in @@ -298,6 +298,9 @@ public: // Clear annotations from the given line. void AnnotationClearLine(int line); + // Define a marker from a bitmap. + void MarkerDefineBitmap(int markerNumber, const wxBitmap& bmp); + // The following methods are nearly equivalent to their similarly named diff --git a/src/stc/stc.interface.h.in b/src/stc/stc.interface.h.in index ec7885b0dd..19559197ad 100644 --- a/src/stc/stc.interface.h.in +++ b/src/stc/stc.interface.h.in @@ -353,6 +353,11 @@ public: */ void AnnotationClearLine(int line); + /** + Define a marker with a wxBitmap. + */ + void MarkerDefineBitmap(int markerNumber, const wxBitmap& bmp); + //@} From 8be4f7dde66458e322ae8d9ad7a5fe23f2200602 Mon Sep 17 00:00:00 2001 From: New Pagodi Date: Sun, 17 Mar 2019 01:48:51 -0500 Subject: [PATCH 5/8] Change wxSTC mapping for SCI_REGISTERIMAGE Currently the Scintilla message SCI_REGISTERIMAGE is mapped to wxStyledTextCtrl::RegisterImage(int, const wxBitmap&). This makes RegisterImage a manually defined method and passes the bitmap directly to the listbox instead of first converting to an XPM. To backfill the message map, SCI_REGISTERIMAGE is now mapped to a new method overload RegisterImage(int, const char* const*). The new method accepts XPM data instead of a wxBitmap. --- src/stc/PlatWX.cpp | 43 +------------------------------ src/stc/PlatWX.h | 52 ++++++++++++++++++++++++++++++++++++++ src/stc/ScintillaWX.cpp | 4 +++ src/stc/ScintillaWX.h | 1 + src/stc/gen_docs.py | 6 +++-- src/stc/gen_iface.py | 17 +++---------- src/stc/stc.cpp.in | 5 ++++ src/stc/stc.h.in | 3 +++ src/stc/stc.interface.h.in | 5 ++++ 9 files changed, 78 insertions(+), 58 deletions(-) diff --git a/src/stc/PlatWX.cpp b/src/stc/PlatWX.cpp index 58a448deec..45cdea166a 100644 --- a/src/stc/PlatWX.cpp +++ b/src/stc/PlatWX.cpp @@ -29,7 +29,6 @@ #include "wx/mstream.h" #include "wx/xpmdecod.h" #include "wx/image.h" -#include "wx/imaglist.h" #include "wx/tokenzr.h" #include "wx/dynlib.h" #include "wx/scopedarray.h" @@ -2339,46 +2338,6 @@ inline wxListView* GETLB(WindowID win) { //---------------------------------------------------------------------- -class ListBoxImpl : public ListBox { -private: - int lineHeight; - bool unicodeMode; - int desiredVisibleRows; - int aveCharWidth; - size_t maxStrWidth; - Point location; // Caret location at which the list is opened - wxImageList* imgList; - wxArrayInt* imgTypeMap; - -public: - ListBoxImpl(); - ~ListBoxImpl(); - static ListBox *Allocate(); - - virtual void SetFont(Font &font) wxOVERRIDE; - virtual void Create(Window &parent, int ctrlID, Point location_, int lineHeight_, bool unicodeMode_, int technology_) wxOVERRIDE; - virtual void SetAverageCharWidth(int width) wxOVERRIDE; - virtual void SetVisibleRows(int rows) wxOVERRIDE; - virtual int GetVisibleRows() const wxOVERRIDE; - virtual PRectangle GetDesiredRect() wxOVERRIDE; - virtual int CaretFromEdge() wxOVERRIDE; - virtual void Clear() wxOVERRIDE; - virtual void Append(char *s, int type = -1) wxOVERRIDE; - void Append(const wxString& text, int type); - virtual int Length() wxOVERRIDE; - virtual void Select(int n) wxOVERRIDE; - virtual int GetSelection() wxOVERRIDE; - virtual int Find(const char *prefix) wxOVERRIDE; - virtual void GetValue(int n, char *value, int len) wxOVERRIDE; - virtual void RegisterImage(int type, const char *xpm_data) wxOVERRIDE; - void RegisterImageHelper(int type, wxBitmap& bmp); - virtual void RegisterRGBAImage(int type, int width, int height, const unsigned char *pixelsImage) wxOVERRIDE; - virtual void ClearRegisteredImages() wxOVERRIDE; - virtual void SetDoubleClickAction(CallBackAction, void *) wxOVERRIDE; - virtual void SetList(const char* list, char separator, char typesep) wxOVERRIDE; -}; - - ListBoxImpl::ListBoxImpl() : lineHeight(10), unicodeMode(false), desiredVisibleRows(5), aveCharWidth(8), maxStrWidth(0), @@ -2542,7 +2501,7 @@ void ListBoxImpl::GetValue(int n, char *value, int len) { value[len-1] = '\0'; } -void ListBoxImpl::RegisterImageHelper(int type, wxBitmap& bmp) +void ListBoxImpl::RegisterImageHelper(int type, const wxBitmap& bmp) { if (! imgList) { // assumes all images are the same size diff --git a/src/stc/PlatWX.h b/src/stc/PlatWX.h index 3b051198c6..ce308b50a0 100644 --- a/src/stc/PlatWX.h +++ b/src/stc/PlatWX.h @@ -1,3 +1,12 @@ +#ifndef _SRC_STC_PLATWX_H_ +#define _SRC_STC_PLATWX_H_ + +#include "wx/defs.h" + +#if wxUSE_STC + +#include "wx/imaglist.h" +#include "Platform.h" @@ -6,6 +15,45 @@ wxRect wxRectFromPRectangle(PRectangle prc); PRectangle PRectangleFromwxRect(wxRect rc); wxColour wxColourFromCD(const ColourDesired& ca); +class ListBoxImpl : public ListBox { +private: + int lineHeight; + bool unicodeMode; + int desiredVisibleRows; + int aveCharWidth; + size_t maxStrWidth; + Point location; // Caret location at which the list is opened + wxImageList* imgList; + wxArrayInt* imgTypeMap; + +public: + ListBoxImpl(); + ~ListBoxImpl(); + static ListBox *Allocate(); + + virtual void SetFont(Font &font) wxOVERRIDE; + virtual void Create(Window &parent, int ctrlID, Point location_, int lineHeight_, bool unicodeMode_, int technology_) wxOVERRIDE; + virtual void SetAverageCharWidth(int width) wxOVERRIDE; + virtual void SetVisibleRows(int rows) wxOVERRIDE; + virtual int GetVisibleRows() const wxOVERRIDE; + virtual PRectangle GetDesiredRect() wxOVERRIDE; + virtual int CaretFromEdge() wxOVERRIDE; + virtual void Clear() wxOVERRIDE; + virtual void Append(char *s, int type = -1) wxOVERRIDE; + void Append(const wxString& text, int type); + virtual int Length() wxOVERRIDE; + virtual void Select(int n) wxOVERRIDE; + virtual int GetSelection() wxOVERRIDE; + virtual int Find(const char *prefix) wxOVERRIDE; + virtual void GetValue(int n, char *value, int len) wxOVERRIDE; + virtual void RegisterImage(int type, const char *xpm_data) wxOVERRIDE; + void RegisterImageHelper(int type, const wxBitmap& bmp); + virtual void RegisterRGBAImage(int type, int width, int height, const unsigned char *pixelsImage) wxOVERRIDE; + virtual void ClearRegisteredImages() wxOVERRIDE; + virtual void SetDoubleClickAction(CallBackAction, void *) wxOVERRIDE; + virtual void SetList(const char* list, char separator, char typesep) wxOVERRIDE; +}; + class SurfaceData { public: @@ -72,3 +120,7 @@ private: }; #endif // wxUSE_GRAPHICS_DIRECT2D + +#endif // wxUSE_STC + +#endif // _SRC_STC_PLATWX_H_ diff --git a/src/stc/ScintillaWX.cpp b/src/stc/ScintillaWX.cpp index 5ead9fc363..59d25e9f91 100644 --- a/src/stc/ScintillaWX.cpp +++ b/src/stc/ScintillaWX.cpp @@ -1365,6 +1365,10 @@ void ScintillaWX::DoMarkerDefineBitmap(int markerNumber, const wxBitmap& bmp) { RedrawSelMargin(); } +void ScintillaWX::DoRegisterImage(int type, const wxBitmap& bmp) { + static_cast(ac.lb)->RegisterImageHelper(type, bmp); +} + sptr_t ScintillaWX::DirectFunction( ScintillaWX* swx, unsigned int iMessage, uptr_t wParam, sptr_t lParam) { return swx->WndProc(iMessage, wParam, lParam); diff --git a/src/stc/ScintillaWX.h b/src/stc/ScintillaWX.h index b858809b0f..92079170e3 100644 --- a/src/stc/ScintillaWX.h +++ b/src/stc/ScintillaWX.h @@ -200,6 +200,7 @@ public: SurfaceData* GetSurfaceData() const {return m_surfaceData;} void SetPaintAbandoned(){paintState = paintAbandoned;} void DoMarkerDefineBitmap(int markerNumber, const wxBitmap& bmp); + void DoRegisterImage(int type, const wxBitmap& bmp); private: bool capturedMouse; diff --git a/src/stc/gen_docs.py b/src/stc/gen_docs.py index cb9b1774dd..7228e78cda 100644 --- a/src/stc/gen_docs.py +++ b/src/stc/gen_docs.py @@ -43,7 +43,8 @@ categoriesList = [ ('Markers' ,'Markers', ('@see MarkerDefineBitmap',)), ('Indicators' ,'Indicators', 0), - ('Autocompletion' ,'Autocompletion', 0), + ('Autocompletion' ,'Autocompletion', + ('@see RegisterImage(int, const wxBitmap&)',)), ('UserLists' ,'User lists', 0), ('CallTips' ,'Call tips', 0), ('KeyboardCommands' ,'Keyboard commands', 0), @@ -1409,7 +1410,8 @@ sinceAnnotations= { 'TargetWholeDocument':'3.1.1', 'ToggleFoldShowText':'3.1.1', - 'MarkerDefinePixmap':'3.1.3' + 'MarkerDefinePixmap':'3.1.3', + 'RegisterImage':'3.1.3' } diff --git a/src/stc/gen_iface.py b/src/stc/gen_iface.py index 4cfdd2c854..e885cda3bb 100755 --- a/src/stc/gen_iface.py +++ b/src/stc/gen_iface.py @@ -527,20 +527,9 @@ methodOverrideMap = { 'RegisterImage' : (0, - '''void %s(int type, const wxBitmap& bmp);''', - '''void %s(int type, const wxBitmap& bmp) { - // convert bmp to a xpm in a string - wxMemoryOutputStream strm; - wxImage img = bmp.ConvertToImage(); - if (img.HasAlpha()) - img.ConvertAlphaToMask(); - img.SaveFile(strm, wxBITMAP_TYPE_XPM); - size_t len = strm.GetSize(); - char* buff = new char[len+1]; - strm.CopyTo(buff, len); - buff[len] = 0; - SendMsg(%s, type, (sptr_t)buff); - delete [] buff;''' + '''void %s(int type, const char* const* xpmData);''', + '''void %s(int type, const char* const* xpmData) { + SendMsg(%s, type, (sptr_t)xpmData);''' ), 'SetHScrollBar' : ('SetUseHorizontalScrollBar', 0, 0), diff --git a/src/stc/stc.cpp.in b/src/stc/stc.cpp.in index d082ffd27c..fb44624ab7 100644 --- a/src/stc/stc.cpp.in +++ b/src/stc/stc.cpp.in @@ -568,6 +568,11 @@ void wxStyledTextCtrl::MarkerDefineBitmap(int markerNumber, m_swx->DoMarkerDefineBitmap(markerNumber, bmp); } +void wxStyledTextCtrl::RegisterImage(int type, const wxBitmap& bmp) +{ + m_swx->DoRegisterImage(type, bmp); +} + diff --git a/src/stc/stc.h.in b/src/stc/stc.h.in index c21e8bf061..ef38ee1b20 100644 --- a/src/stc/stc.h.in +++ b/src/stc/stc.h.in @@ -301,6 +301,9 @@ public: // Define a marker from a bitmap. void MarkerDefineBitmap(int markerNumber, const wxBitmap& bmp); + // Register an image for use in autocompletion lists. + void RegisterImage(int type, const wxBitmap& bmp); + // The following methods are nearly equivalent to their similarly named diff --git a/src/stc/stc.interface.h.in b/src/stc/stc.interface.h.in index 19559197ad..f2ac38130b 100644 --- a/src/stc/stc.interface.h.in +++ b/src/stc/stc.interface.h.in @@ -358,6 +358,11 @@ public: */ void MarkerDefineBitmap(int markerNumber, const wxBitmap& bmp); + /** + Register an image for use in autocompletion lists. + */ + void RegisterImage(int type, const wxBitmap& bmp); + //@} From f4e0c1aaee36d4509f1a506cf1463ff3512f37f1 Mon Sep 17 00:00:00 2001 From: New Pagodi Date: Sun, 17 Mar 2019 01:49:30 -0500 Subject: [PATCH 6/8] Regenerate wxSTC files after recent changes --- include/wx/stc/stc.h | 16 ++++++++++----- interface/wx/stc/stc.h | 22 ++++++++++++++++++-- src/stc/stc.cpp | 46 ++++++++++++++++-------------------------- 3 files changed, 48 insertions(+), 36 deletions(-) diff --git a/include/wx/stc/stc.h b/include/wx/stc/stc.h index 9348a023a8..f069dfe2fb 100644 --- a/include/wx/stc/stc.h +++ b/include/wx/stc/stc.h @@ -3090,7 +3090,7 @@ public: int MarkerPrevious(int lineStart, int markerMask); // Define a marker from a bitmap - void MarkerDefineBitmap(int markerNumber, const wxBitmap& bmp); + void MarkerDefinePixmap(int markerNumber, const char* const* xpmData); // Add a set of markers to a line. void MarkerAddSet(int line, int markerSet); @@ -3441,7 +3441,7 @@ public: bool AutoCompGetDropRestOfWord() const; // Register an image for use in autocompletion lists. - void RegisterImage(int type, const wxBitmap& bmp); + void RegisterImage(int type, const char* const* xpmData); // Clear all the registered images. void ClearRegisteredImages(); @@ -3883,19 +3883,19 @@ public: // Set the display mode of visual flags for wrapped lines. void SetWrapVisualFlags(int wrapVisualFlags); - // Retrive the display mode of visual flags for wrapped lines. + // Retrieve the display mode of visual flags for wrapped lines. int GetWrapVisualFlags() const; // Set the location of visual flags for wrapped lines. void SetWrapVisualFlagsLocation(int wrapVisualFlagsLocation); - // Retrive the location of visual flags for wrapped lines. + // Retrieve the location of visual flags for wrapped lines. int GetWrapVisualFlagsLocation() const; // Set the start indent for wrapped lines. void SetWrapStartIndent(int indent); - // Retrive the start indent for wrapped lines. + // Retrieve the start indent for wrapped lines. int GetWrapStartIndent() const; // Sets how wrapped sublines are placed. Default is wxSTC_WRAPINDENT_FIXED. @@ -5181,6 +5181,12 @@ public: // Clear annotations from the given line. void AnnotationClearLine(int line); + // Define a marker from a bitmap. + void MarkerDefineBitmap(int markerNumber, const wxBitmap& bmp); + + // Register an image for use in autocompletion lists. + void RegisterImage(int type, const wxBitmap& bmp); + // The following methods are nearly equivalent to their similarly named diff --git a/interface/wx/stc/stc.h b/interface/wx/stc/stc.h index 3c992fe511..21a3a4cac4 100644 --- a/interface/wx/stc/stc.h +++ b/interface/wx/stc/stc.h @@ -5360,6 +5360,8 @@ public: /** @member_group_name{Markers, Markers} + + @see MarkerDefineBitmap */ //@{ @@ -5437,8 +5439,10 @@ public: /** Define a marker from a bitmap + + @since 3.1.3 */ - void MarkerDefineBitmap(int markerNumber, const wxBitmap& bmp); + void MarkerDefinePixmap(int markerNumber, const char* const* xpmData); /** Add a set of markers to a line. @@ -5644,6 +5648,8 @@ public: /** @member_group_name{Autocompletion, Autocompletion} + + @see RegisterImage(int, const wxBitmap&) */ //@{ @@ -5756,8 +5762,10 @@ public: /** Register an image for use in autocompletion lists. + + @since 3.1.3 */ - void RegisterImage(int type, const wxBitmap& bmp); + void RegisterImage(int type, const char* const* xpmData); /** Clear all the registered images. @@ -7405,6 +7413,16 @@ public: */ void AnnotationClearLine(int line); + /** + Define a marker with a wxBitmap. + */ + void MarkerDefineBitmap(int markerNumber, const wxBitmap& bmp); + + /** + Register an image for use in autocompletion lists. + */ + void RegisterImage(int type, const wxBitmap& bmp); + //@} diff --git a/src/stc/stc.cpp b/src/stc/stc.cpp index 61eea8dad3..b01802915c 100644 --- a/src/stc/stc.cpp +++ b/src/stc/stc.cpp @@ -662,19 +662,8 @@ int wxStyledTextCtrl::MarkerPrevious(int lineStart, int markerMask) } // Define a marker from a bitmap -void wxStyledTextCtrl::MarkerDefineBitmap(int markerNumber, const wxBitmap& bmp) { - // convert bmp to a xpm in a string - wxMemoryOutputStream strm; - wxImage img = bmp.ConvertToImage(); - if (img.HasAlpha()) - img.ConvertAlphaToMask(); - img.SaveFile(strm, wxBITMAP_TYPE_XPM); - size_t len = strm.GetSize(); - char* buff = new char[len+1]; - strm.CopyTo(buff, len); - buff[len] = 0; - SendMsg(SCI_MARKERDEFINEPIXMAP, markerNumber, (sptr_t)buff); - delete [] buff; +void wxStyledTextCtrl::MarkerDefinePixmap(int markerNumber, const char* const* xpmData) { + SendMsg(SCI_MARKERDEFINEPIXMAP, markerNumber, (sptr_t)xpmData); } // Add a set of markers to a line. @@ -1464,19 +1453,8 @@ bool wxStyledTextCtrl::AutoCompGetDropRestOfWord() const } // Register an image for use in autocompletion lists. -void wxStyledTextCtrl::RegisterImage(int type, const wxBitmap& bmp) { - // convert bmp to a xpm in a string - wxMemoryOutputStream strm; - wxImage img = bmp.ConvertToImage(); - if (img.HasAlpha()) - img.ConvertAlphaToMask(); - img.SaveFile(strm, wxBITMAP_TYPE_XPM); - size_t len = strm.GetSize(); - char* buff = new char[len+1]; - strm.CopyTo(buff, len); - buff[len] = 0; - SendMsg(SCI_REGISTERIMAGE, type, (sptr_t)buff); - delete [] buff; +void wxStyledTextCtrl::RegisterImage(int type, const char* const* xpmData) { + SendMsg(SCI_REGISTERIMAGE, type, (sptr_t)xpmData); } // Clear all the registered images. @@ -2384,7 +2362,7 @@ void wxStyledTextCtrl::SetWrapVisualFlags(int wrapVisualFlags) SendMsg(SCI_SETWRAPVISUALFLAGS, wrapVisualFlags, 0); } -// Retrive the display mode of visual flags for wrapped lines. +// Retrieve the display mode of visual flags for wrapped lines. int wxStyledTextCtrl::GetWrapVisualFlags() const { return SendMsg(SCI_GETWRAPVISUALFLAGS, 0, 0); @@ -2396,7 +2374,7 @@ void wxStyledTextCtrl::SetWrapVisualFlagsLocation(int wrapVisualFlagsLocation) SendMsg(SCI_SETWRAPVISUALFLAGSLOCATION, wrapVisualFlagsLocation, 0); } -// Retrive the location of visual flags for wrapped lines. +// Retrieve the location of visual flags for wrapped lines. int wxStyledTextCtrl::GetWrapVisualFlagsLocation() const { return SendMsg(SCI_GETWRAPVISUALFLAGSLOCATION, 0, 0); @@ -2408,7 +2386,7 @@ void wxStyledTextCtrl::SetWrapStartIndent(int indent) SendMsg(SCI_SETWRAPSTARTINDENT, indent, 0); } -// Retrive the start indent for wrapped lines. +// Retrieve the start indent for wrapped lines. int wxStyledTextCtrl::GetWrapStartIndent() const { return SendMsg(SCI_GETWRAPSTARTINDENT, 0, 0); @@ -5058,6 +5036,16 @@ void wxStyledTextCtrl::AnnotationClearLine(int line) { SendMsg(SCI_ANNOTATIONSETTEXT, line, (sptr_t)NULL); } +void wxStyledTextCtrl::MarkerDefineBitmap(int markerNumber, + const wxBitmap& bmp) { + m_swx->DoMarkerDefineBitmap(markerNumber, bmp); +} + +void wxStyledTextCtrl::RegisterImage(int type, const wxBitmap& bmp) +{ + m_swx->DoRegisterImage(type, bmp); +} + From 12749d1a5901b1c6a353109569b614acd91f21cd Mon Sep 17 00:00:00 2001 From: VZ Date: Mon, 18 Mar 2019 15:43:30 -0500 Subject: [PATCH 7/8] Update src/stc/PlatWX.cpp Co-Authored-By: NewPagodi --- src/stc/PlatWX.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/stc/PlatWX.cpp b/src/stc/PlatWX.cpp index 45cdea166a..6ac1b876af 100644 --- a/src/stc/PlatWX.cpp +++ b/src/stc/PlatWX.cpp @@ -2537,7 +2537,7 @@ void ListBoxImpl::RegisterImage(int type, const char *xpm_data) { img = dec.ReadData(reinterpret_cast(xpm_data)); wxBitmap bmp(img); - RegisterImageHelper(type,bmp); + RegisterImageHelper(type, bmp); } From fb8c4bda29314091669dacea6ed80a8ab79ef392 Mon Sep 17 00:00:00 2001 From: VZ Date: Mon, 18 Mar 2019 15:43:39 -0500 Subject: [PATCH 8/8] Update src/stc/ScintillaWX.cpp Co-Authored-By: NewPagodi --- src/stc/ScintillaWX.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/stc/ScintillaWX.cpp b/src/stc/ScintillaWX.cpp index 59d25e9f91..20b155069f 100644 --- a/src/stc/ScintillaWX.cpp +++ b/src/stc/ScintillaWX.cpp @@ -1351,7 +1351,7 @@ void ScintillaWX::DoMarkerDefineBitmap(int markerNumber, const wxBitmap& bmp) { rgba[curRGBALoc++] = img.GetData()[curDataLoc++]; rgba[curRGBALoc++] = img.GetData()[curDataLoc++]; rgba[curRGBALoc++] = - img.HasAlpha()?img.GetAlpha()[curAlphaLoc++]:255; + img.HasAlpha() ? img.GetAlpha()[curAlphaLoc++] : wxALPHA_OPAQUE ; } // Now follow the same procedure used for handling the