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); + //@}