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.
This commit is contained in:
@@ -29,7 +29,6 @@
|
|||||||
#include "wx/mstream.h"
|
#include "wx/mstream.h"
|
||||||
#include "wx/xpmdecod.h"
|
#include "wx/xpmdecod.h"
|
||||||
#include "wx/image.h"
|
#include "wx/image.h"
|
||||||
#include "wx/imaglist.h"
|
|
||||||
#include "wx/tokenzr.h"
|
#include "wx/tokenzr.h"
|
||||||
#include "wx/dynlib.h"
|
#include "wx/dynlib.h"
|
||||||
#include "wx/scopedarray.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()
|
ListBoxImpl::ListBoxImpl()
|
||||||
: lineHeight(10), unicodeMode(false),
|
: lineHeight(10), unicodeMode(false),
|
||||||
desiredVisibleRows(5), aveCharWidth(8), maxStrWidth(0),
|
desiredVisibleRows(5), aveCharWidth(8), maxStrWidth(0),
|
||||||
@@ -2542,7 +2501,7 @@ void ListBoxImpl::GetValue(int n, char *value, int len) {
|
|||||||
value[len-1] = '\0';
|
value[len-1] = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
void ListBoxImpl::RegisterImageHelper(int type, wxBitmap& bmp)
|
void ListBoxImpl::RegisterImageHelper(int type, const wxBitmap& bmp)
|
||||||
{
|
{
|
||||||
if (! imgList) {
|
if (! imgList) {
|
||||||
// assumes all images are the same size
|
// assumes all images are the same size
|
||||||
|
@@ -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);
|
PRectangle PRectangleFromwxRect(wxRect rc);
|
||||||
wxColour wxColourFromCD(const ColourDesired& ca);
|
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
|
class SurfaceData
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -72,3 +120,7 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
#endif // wxUSE_GRAPHICS_DIRECT2D
|
#endif // wxUSE_GRAPHICS_DIRECT2D
|
||||||
|
|
||||||
|
#endif // wxUSE_STC
|
||||||
|
|
||||||
|
#endif // _SRC_STC_PLATWX_H_
|
||||||
|
@@ -1365,6 +1365,10 @@ void ScintillaWX::DoMarkerDefineBitmap(int markerNumber, const wxBitmap& bmp) {
|
|||||||
RedrawSelMargin();
|
RedrawSelMargin();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ScintillaWX::DoRegisterImage(int type, const wxBitmap& bmp) {
|
||||||
|
static_cast<ListBoxImpl*>(ac.lb)->RegisterImageHelper(type, bmp);
|
||||||
|
}
|
||||||
|
|
||||||
sptr_t ScintillaWX::DirectFunction(
|
sptr_t ScintillaWX::DirectFunction(
|
||||||
ScintillaWX* swx, unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
|
ScintillaWX* swx, unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
|
||||||
return swx->WndProc(iMessage, wParam, lParam);
|
return swx->WndProc(iMessage, wParam, lParam);
|
||||||
|
@@ -200,6 +200,7 @@ public:
|
|||||||
SurfaceData* GetSurfaceData() const {return m_surfaceData;}
|
SurfaceData* GetSurfaceData() const {return m_surfaceData;}
|
||||||
void SetPaintAbandoned(){paintState = paintAbandoned;}
|
void SetPaintAbandoned(){paintState = paintAbandoned;}
|
||||||
void DoMarkerDefineBitmap(int markerNumber, const wxBitmap& bmp);
|
void DoMarkerDefineBitmap(int markerNumber, const wxBitmap& bmp);
|
||||||
|
void DoRegisterImage(int type, const wxBitmap& bmp);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool capturedMouse;
|
bool capturedMouse;
|
||||||
|
@@ -43,7 +43,8 @@ categoriesList = [
|
|||||||
('Markers' ,'Markers',
|
('Markers' ,'Markers',
|
||||||
('@see MarkerDefineBitmap',)),
|
('@see MarkerDefineBitmap',)),
|
||||||
('Indicators' ,'Indicators', 0),
|
('Indicators' ,'Indicators', 0),
|
||||||
('Autocompletion' ,'Autocompletion', 0),
|
('Autocompletion' ,'Autocompletion',
|
||||||
|
('@see RegisterImage(int, const wxBitmap&)',)),
|
||||||
('UserLists' ,'User lists', 0),
|
('UserLists' ,'User lists', 0),
|
||||||
('CallTips' ,'Call tips', 0),
|
('CallTips' ,'Call tips', 0),
|
||||||
('KeyboardCommands' ,'Keyboard commands', 0),
|
('KeyboardCommands' ,'Keyboard commands', 0),
|
||||||
@@ -1409,7 +1410,8 @@ sinceAnnotations= {
|
|||||||
'TargetWholeDocument':'3.1.1',
|
'TargetWholeDocument':'3.1.1',
|
||||||
'ToggleFoldShowText':'3.1.1',
|
'ToggleFoldShowText':'3.1.1',
|
||||||
|
|
||||||
'MarkerDefinePixmap':'3.1.3'
|
'MarkerDefinePixmap':'3.1.3',
|
||||||
|
'RegisterImage':'3.1.3'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -527,20 +527,9 @@ methodOverrideMap = {
|
|||||||
|
|
||||||
'RegisterImage' :
|
'RegisterImage' :
|
||||||
(0,
|
(0,
|
||||||
'''void %s(int type, const wxBitmap& bmp);''',
|
'''void %s(int type, const char* const* xpmData);''',
|
||||||
'''void %s(int type, const wxBitmap& bmp) {
|
'''void %s(int type, const char* const* xpmData) {
|
||||||
// convert bmp to a xpm in a string
|
SendMsg(%s, type, (sptr_t)xpmData);'''
|
||||||
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;'''
|
|
||||||
),
|
),
|
||||||
|
|
||||||
'SetHScrollBar' : ('SetUseHorizontalScrollBar', 0, 0),
|
'SetHScrollBar' : ('SetUseHorizontalScrollBar', 0, 0),
|
||||||
|
@@ -568,6 +568,11 @@ void wxStyledTextCtrl::MarkerDefineBitmap(int markerNumber,
|
|||||||
m_swx->DoMarkerDefineBitmap(markerNumber, bmp);
|
m_swx->DoMarkerDefineBitmap(markerNumber, bmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void wxStyledTextCtrl::RegisterImage(int type, const wxBitmap& bmp)
|
||||||
|
{
|
||||||
|
m_swx->DoRegisterImage(type, bmp);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@@ -301,6 +301,9 @@ public:
|
|||||||
// Define a marker from a bitmap.
|
// Define a marker from a bitmap.
|
||||||
void MarkerDefineBitmap(int markerNumber, const wxBitmap& bmp);
|
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
|
// The following methods are nearly equivalent to their similarly named
|
||||||
|
@@ -358,6 +358,11 @@ public:
|
|||||||
*/
|
*/
|
||||||
void MarkerDefineBitmap(int markerNumber, const wxBitmap& bmp);
|
void MarkerDefineBitmap(int markerNumber, const wxBitmap& bmp);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Register an image for use in autocompletion lists.
|
||||||
|
*/
|
||||||
|
void RegisterImage(int type, const wxBitmap& bmp);
|
||||||
|
|
||||||
//@}
|
//@}
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user