wxStyledTextCtrl can now be built and used when wxUSE_UNICODE==1.

When in unicode mode Scintilla uses UTF-8 internally so the wxSTC
wrapper only needs to convert to/from UTF-8 in the right places.
Still need to figure out to get unicode characters from key/char
events...


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@14693 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robin Dunn
2002-03-20 20:43:39 +00:00
parent ef1cae87cd
commit 10ef30eb53
22 changed files with 1033 additions and 534 deletions

View File

@@ -36,7 +36,11 @@
#define wxSTC_START 2000 #define wxSTC_START 2000
#define wxSTC_OPTIONAL_START 3000 #define wxSTC_OPTIONAL_START 3000
#define wxSTC_LEXER_START 4000 #define wxSTC_LEXER_START 4000
// Redoes the next action on the undo history
#define wxSTC_CMD_REDO 2011 #define wxSTC_CMD_REDO 2011
// Select all the text in the document.
#define wxSTC_CMD_SELECTALL 2013 #define wxSTC_CMD_SELECTALL 2013
#define wxSTC_WS_INVISIBLE 0 #define wxSTC_WS_INVISIBLE 0
#define wxSTC_WS_VISIBLEALWAYS 1 #define wxSTC_WS_VISIBLEALWAYS 1
@@ -154,9 +158,17 @@
#define wxSTC_FIND_MATCHCASE 4 #define wxSTC_FIND_MATCHCASE 4
#define wxSTC_FIND_WORDSTART 0x00100000 #define wxSTC_FIND_WORDSTART 0x00100000
#define wxSTC_FIND_REGEXP 0x00200000 #define wxSTC_FIND_REGEXP 0x00200000
// Undo one action in the undo history.
#define wxSTC_CMD_UNDO 2176 #define wxSTC_CMD_UNDO 2176
// Cut the selection to the clipboard.
#define wxSTC_CMD_CUT 2177 #define wxSTC_CMD_CUT 2177
// Copy the selection to the clipboard.
#define wxSTC_CMD_COPY 2178 #define wxSTC_CMD_COPY 2178
// Paste the contents of the clipboard into the document replacing the selection.
#define wxSTC_CMD_PASTE 2179 #define wxSTC_CMD_PASTE 2179
#define wxSTC_FOLDLEVELBASE 0x400 #define wxSTC_FOLDLEVELBASE 0x400
#define wxSTC_FOLDLEVELWHITEFLAG 0x1000 #define wxSTC_FOLDLEVELWHITEFLAG 0x1000
@@ -169,50 +181,144 @@
#define wxSTC_CACHE_CARET 1 #define wxSTC_CACHE_CARET 1
#define wxSTC_CACHE_PAGE 2 #define wxSTC_CACHE_PAGE 2
#define wxSTC_CACHE_DOCUMENT 3 #define wxSTC_CACHE_DOCUMENT 3
// Move caret down one line.
#define wxSTC_CMD_LINEDOWN 2300 #define wxSTC_CMD_LINEDOWN 2300
// Move caret down one line extending selection to new caret position.
#define wxSTC_CMD_LINEDOWNEXTEND 2301 #define wxSTC_CMD_LINEDOWNEXTEND 2301
// Move caret up one line.
#define wxSTC_CMD_LINEUP 2302 #define wxSTC_CMD_LINEUP 2302
// Move caret up one line extending selection to new caret position.
#define wxSTC_CMD_LINEUPEXTEND 2303 #define wxSTC_CMD_LINEUPEXTEND 2303
// Move caret left one character.
#define wxSTC_CMD_CHARLEFT 2304 #define wxSTC_CMD_CHARLEFT 2304
// Move caret left one character extending selection to new caret position.
#define wxSTC_CMD_CHARLEFTEXTEND 2305 #define wxSTC_CMD_CHARLEFTEXTEND 2305
// Move caret right one character.
#define wxSTC_CMD_CHARRIGHT 2306 #define wxSTC_CMD_CHARRIGHT 2306
// Move caret right one character extending selection to new caret position.
#define wxSTC_CMD_CHARRIGHTEXTEND 2307 #define wxSTC_CMD_CHARRIGHTEXTEND 2307
// Move caret left one word.
#define wxSTC_CMD_WORDLEFT 2308 #define wxSTC_CMD_WORDLEFT 2308
// Move caret left one word extending selection to new caret position.
#define wxSTC_CMD_WORDLEFTEXTEND 2309 #define wxSTC_CMD_WORDLEFTEXTEND 2309
// Move caret right one word.
#define wxSTC_CMD_WORDRIGHT 2310 #define wxSTC_CMD_WORDRIGHT 2310
// Move caret right one word extending selection to new caret position.
#define wxSTC_CMD_WORDRIGHTEXTEND 2311 #define wxSTC_CMD_WORDRIGHTEXTEND 2311
// Move caret to first position on line.
#define wxSTC_CMD_HOME 2312 #define wxSTC_CMD_HOME 2312
// Move caret to first position on line extending selection to new caret position.
#define wxSTC_CMD_HOMEEXTEND 2313 #define wxSTC_CMD_HOMEEXTEND 2313
// Move caret to last position on line.
#define wxSTC_CMD_LINEEND 2314 #define wxSTC_CMD_LINEEND 2314
// Move caret to last position on line extending selection to new caret position.
#define wxSTC_CMD_LINEENDEXTEND 2315 #define wxSTC_CMD_LINEENDEXTEND 2315
// Move caret to first position in document.
#define wxSTC_CMD_DOCUMENTSTART 2316 #define wxSTC_CMD_DOCUMENTSTART 2316
// Move caret to first position in document extending selection to new caret position.
#define wxSTC_CMD_DOCUMENTSTARTEXTEND 2317 #define wxSTC_CMD_DOCUMENTSTARTEXTEND 2317
// Move caret to last position in document.
#define wxSTC_CMD_DOCUMENTEND 2318 #define wxSTC_CMD_DOCUMENTEND 2318
// Move caret to last position in document extending selection to new caret position.
#define wxSTC_CMD_DOCUMENTENDEXTEND 2319 #define wxSTC_CMD_DOCUMENTENDEXTEND 2319
// Move caret one page up.
#define wxSTC_CMD_PAGEUP 2320 #define wxSTC_CMD_PAGEUP 2320
// Move caret one page up extending selection to new caret position.
#define wxSTC_CMD_PAGEUPEXTEND 2321 #define wxSTC_CMD_PAGEUPEXTEND 2321
// Move caret one page down.
#define wxSTC_CMD_PAGEDOWN 2322 #define wxSTC_CMD_PAGEDOWN 2322
// Move caret one page down extending selection to new caret position.
#define wxSTC_CMD_PAGEDOWNEXTEND 2323 #define wxSTC_CMD_PAGEDOWNEXTEND 2323
// Switch from insert to overtype mode or the reverse.
#define wxSTC_CMD_EDITTOGGLEOVERTYPE 2324 #define wxSTC_CMD_EDITTOGGLEOVERTYPE 2324
// Cancel any modes such as call tip or auto-completion list display.
#define wxSTC_CMD_CANCEL 2325 #define wxSTC_CMD_CANCEL 2325
// Delete the selection or if no selection, the character before the caret.
#define wxSTC_CMD_DELETEBACK 2326 #define wxSTC_CMD_DELETEBACK 2326
// If selection is empty or all on one line replace the selection with a tab
// character.
// If more than one line selected, indent the lines.
#define wxSTC_CMD_TAB 2327 #define wxSTC_CMD_TAB 2327
// Dedent the selected lines.
#define wxSTC_CMD_BACKTAB 2328 #define wxSTC_CMD_BACKTAB 2328
// Insert a new line, may use a CRLF, CR or LF depending on EOL mode.
#define wxSTC_CMD_NEWLINE 2329 #define wxSTC_CMD_NEWLINE 2329
// Insert a Form Feed character.
#define wxSTC_CMD_FORMFEED 2330 #define wxSTC_CMD_FORMFEED 2330
// Move caret to before first visible character on line.
// If already there move to first character on line.
#define wxSTC_CMD_VCHOME 2331 #define wxSTC_CMD_VCHOME 2331
// Like VCHome but extending selection to new caret position.
#define wxSTC_CMD_VCHOMEEXTEND 2332 #define wxSTC_CMD_VCHOMEEXTEND 2332
// Magnify the displayed text by increasing the sizes by 1 point.
#define wxSTC_CMD_ZOOMIN 2333 #define wxSTC_CMD_ZOOMIN 2333
// Make the displayed text smaller by decreasing the sizes by 1 point.
#define wxSTC_CMD_ZOOMOUT 2334 #define wxSTC_CMD_ZOOMOUT 2334
// Delete the word to the left of the caret.
#define wxSTC_CMD_DELWORDLEFT 2335 #define wxSTC_CMD_DELWORDLEFT 2335
// Delete the word to the right of the caret.
#define wxSTC_CMD_DELWORDRIGHT 2336 #define wxSTC_CMD_DELWORDRIGHT 2336
// Cut the line containing the caret.
#define wxSTC_CMD_LINECUT 2337 #define wxSTC_CMD_LINECUT 2337
// Delete the line containing the caret.
#define wxSTC_CMD_LINEDELETE 2338 #define wxSTC_CMD_LINEDELETE 2338
// Switch the current line with the previous.
#define wxSTC_CMD_LINETRANSPOSE 2339 #define wxSTC_CMD_LINETRANSPOSE 2339
// Transform the selection to lower case.
#define wxSTC_CMD_LOWERCASE 2340 #define wxSTC_CMD_LOWERCASE 2340
// Transform the selection to upper case.
#define wxSTC_CMD_UPPERCASE 2341 #define wxSTC_CMD_UPPERCASE 2341
// Scroll the document down, keeping the caret visible.
#define wxSTC_CMD_LINESCROLLDOWN 2342 #define wxSTC_CMD_LINESCROLLDOWN 2342
// Scroll the document up, keeping the caret visible.
#define wxSTC_CMD_LINESCROLLUP 2343 #define wxSTC_CMD_LINESCROLLUP 2343
// Delete the selection or if no selection, the character before the caret.
// Will not delete the chraacter before at the start of a line.
#define wxSTC_CMD_DELETEBACKNOTLINE 2344 #define wxSTC_CMD_DELETEBACKNOTLINE 2344
#define wxSTC_EDGE_NONE 0 #define wxSTC_EDGE_NONE 0
#define wxSTC_EDGE_LINE 1 #define wxSTC_EDGE_LINE 1
@@ -736,7 +842,7 @@ public:
void AddText(const wxString& text); void AddText(const wxString& text);
// Add array of cells to document // Add array of cells to document
void AddStyledText(const wxString& text); void AddStyledText(const wxMemoryBuffer& data);
// Insert string at a position // Insert string at a position
void InsertText(int pos, const wxString& text); void InsertText(int pos, const wxString& text);
@@ -777,7 +883,7 @@ public:
void SetSavePoint(); void SetSavePoint();
// Retrieve a buffer of cells. // Retrieve a buffer of cells.
wxString GetStyledText(int startPos, int endPos); wxMemoryBuffer GetStyledText(int startPos, int endPos);
// Are there any redoable actions in the undo history. // Are there any redoable actions in the undo history.
bool CanRedo(); bool CanRedo();
@@ -859,7 +965,6 @@ public:
int GetTabWidth(); int GetTabWidth();
// Set the code page used to interpret the bytes of the document as characters. // Set the code page used to interpret the bytes of the document as characters.
// The SC_CP_UTF8 value can be used to enter Unicode mode.
void SetCodePage(int codePage); void SetCodePage(int codePage);
// Set the symbol used for a particular marker number, // Set the symbol used for a particular marker number,
@@ -949,6 +1054,9 @@ public:
// Set a style to be mixed case, or to force upper or lower case. // Set a style to be mixed case, or to force upper or lower case.
void StyleSetCase(int style, int caseForce); void StyleSetCase(int style, int caseForce);
// Set the character set of the font in a style.
void StyleSetCharacterSet(int style, int characterSet);
// Set the foreground colour of the selection and whether to use this setting. // Set the foreground colour of the selection and whether to use this setting.
void SetSelForeground(bool useSetting, const wxColour& fore); void SetSelForeground(bool useSetting, const wxColour& fore);
@@ -1440,10 +1548,6 @@ public:
// Retrieve the degree of caching of layout information // Retrieve the degree of caching of layout information
int GetLayoutCache(); int GetLayoutCache();
// Delete the selection or if no selection, the character before the caret.
// Will not delete the chraacter before at the start of a line.
void DeleteBackNotLine();
// Move the caret inside current view if it's not there already // Move the caret inside current view if it's not there already
void MoveCaretInsideView(); void MoveCaretInsideView();
@@ -1756,7 +1860,7 @@ public:
void SetKey(int k) { m_key = k; } void SetKey(int k) { m_key = k; }
void SetModifiers(int m) { m_modifiers = m; } void SetModifiers(int m) { m_modifiers = m; }
void SetModificationType(int t) { m_modificationType = t; } void SetModificationType(int t) { m_modificationType = t; }
void SetText(const char* t) { m_text = t; } void SetText(const wxString& t) { m_text = t; }
void SetLength(int len) { m_length = len; } void SetLength(int len) { m_length = len; }
void SetLinesAdded(int num) { m_linesAdded = num; } void SetLinesAdded(int num) { m_linesAdded = num; }
void SetLine(int val) { m_line = val; } void SetLine(int val) { m_line = val; }

View File

@@ -7,6 +7,8 @@
#include <ctype.h> #include <ctype.h>
#include <wx/wx.h> #include <wx/wx.h>
#include <wx/encconv.h>
#include "Platform.h" #include "Platform.h"
#include "PlatWX.h" #include "PlatWX.h"
@@ -176,14 +178,16 @@ void Font::Create(const char *faceName, int characterSet, int size, bool bold, b
break; break;
} }
// TODO: Use wxFontMapper and wxEncodingConverter if encoding not available. wxFontEncodingArray ea = wxEncodingConverter::GetPlatformEquivalents(encoding);
if (ea.GetCount())
encoding = ea[0];
id = new wxFont(size, id = new wxFont(size,
wxDEFAULT, wxDEFAULT,
italic ? wxITALIC : wxNORMAL, italic ? wxITALIC : wxNORMAL,
bold ? wxBOLD : wxNORMAL, bold ? wxBOLD : wxNORMAL,
false, false,
faceName, wxString(faceName, wxConvUTF8),
encoding); encoding);
} }
@@ -320,8 +324,6 @@ int SurfaceImpl::LogPixelsY() {
int SurfaceImpl::DeviceHeightFont(int points) { int SurfaceImpl::DeviceHeightFont(int points) {
return points; return points;
// int logPix = LogPixelsY();
// return (points * logPix + logPix / 2) / 72;
} }
void SurfaceImpl::MoveTo(int x_, int y_) { void SurfaceImpl::MoveTo(int x_, int y_) {
@@ -391,11 +393,8 @@ void SurfaceImpl::DrawTextNoClip(PRectangle rc, Font &font, int ybase,
hdc->SetTextBackground(wxColourFromCA(back)); hdc->SetTextBackground(wxColourFromCA(back));
FillRectangle(rc, back); FillRectangle(rc, back);
#if wxUSE_UNICODE // will convert from UTF-8 in unicode mode
#error fix this... Convert s from UTF-8. wxString str(s, wxConvUTF8, len);
#else
wxString str = wxString(s, len);
#endif
// ybase is where the baseline should be, but wxWin uses the upper left // ybase is where the baseline should be, but wxWin uses the upper left
// corner, so I need to calculate the real position for the text... // corner, so I need to calculate the real position for the text...
@@ -411,11 +410,8 @@ void SurfaceImpl::DrawTextClipped(PRectangle rc, Font &font, int ybase,
FillRectangle(rc, back); FillRectangle(rc, back);
hdc->SetClippingRegion(wxRectFromPRectangle(rc)); hdc->SetClippingRegion(wxRectFromPRectangle(rc));
#if wxUSE_UNICODE // will convert from UTF-8 in unicode mode
#error fix this... Convert s from UTF-8. wxString str(s, wxConvUTF8, len);
#else
wxString str = wxString(s, len);
#endif
// see comments above // see comments above
hdc->DrawText(str, rc.left, ybase - font.ascent); hdc->DrawText(str, rc.left, ybase - font.ascent);
@@ -427,43 +423,67 @@ int SurfaceImpl::WidthText(Font &font, const char *s, int len) {
int w; int w;
int h; int h;
#if wxUSE_UNICODE // will convert from UTF-8 in unicode mode
#error fix this... Convert s from UTF-8. wxString str(s, wxConvUTF8, len);
#else
wxString str = wxString(s, len);
#endif
hdc->GetTextExtent(str, &w, &h); hdc->GetTextExtent(str, &w, &h);
return w; return w;
} }
void SurfaceImpl::MeasureWidths(Font &font, const char *s, int len, int *positions) {
#if wxUSE_UNICODE
#error fix this... Convert s from UTF-8.
#else
wxString str = wxString(s, len);
#endif
void SurfaceImpl::MeasureWidths(Font &font, const char *s, int len, int *positions) {
// will convert from UTF-8 in unicode mode
wxString str(s, wxConvUTF8, len);
SetFont(font); SetFont(font);
// Calculate the position of each character based on the widths of
// the previous characters
int* tpos = new int[len];
int totalWidth = 0; int totalWidth = 0;
for (size_t i=0; i<(size_t)len; i++) { size_t i;
int w; for (i=0; i<str.Length(); i++) {
int h; int w, h;
hdc->GetTextExtent(str[i], &w, &h); hdc->GetTextExtent(str[i], &w, &h);
totalWidth += w; totalWidth += w;
positions[i] = totalWidth; tpos[i] = totalWidth;
} }
#if wxUSE_UNICODE
// Map the widths for UCS-2 characters back to the UTF-8 input string
i = 0;
size_t ui = 0;
while (i < len) {
unsigned char uch = (unsigned char)s[i];
positions[i++] = tpos[ui];
if (uch >= 0x80) {
if (uch < (0x80 + 0x40 + 0x20)) {
positions[i++] = tpos[ui];
} else {
positions[i++] = tpos[ui];
positions[i++] = tpos[ui];
}
}
ui++;
}
#else
// If not unicode then just use the widths we have
memcpy(positions, tpos, len * sizeof(*tpos));
#endif
delete [] tpos;
} }
int SurfaceImpl::WidthChar(Font &font, char ch) { int SurfaceImpl::WidthChar(Font &font, char ch) {
SetFont(font); SetFont(font);
int w; int w;
int h; int h;
#if wxUSE_UNICODE char s[2] = { ch, 0 };
#error fix this... Convert s from UTF-8.
#else // will convert from UTF-8 in unicode mode
hdc->GetTextExtent(ch, &w, &h); wxString str(s, wxConvUTF8, 1);
#endif hdc->GetTextExtent(str, &w, &h);
return w; return w;
} }
@@ -517,8 +537,14 @@ void SurfaceImpl::FlushCachedState() {
} }
void SurfaceImpl::SetUnicodeMode(bool unicodeMode_) { void SurfaceImpl::SetUnicodeMode(bool unicodeMode_) {
// TODO: Make this jive with wxUSE_UNICODE
unicodeMode=unicodeMode_; unicodeMode=unicodeMode_;
#if wxUSE_UNICODE
wxASSERT_MSG(unicodeMode == wxUSE_UNICODE,
wxT("Only unicode may be used when wxUSE_UNICODE is on."));
#else
wxASSERT_MSG(unicodeMode == wxUSE_UNICODE,
wxT("Only non-unicode may be used when wxUSE_UNICODE is off."));
#endif
} }
Surface *Surface::Allocate() { Surface *Surface::Allocate() {
@@ -615,11 +641,9 @@ void Window::SetCursor(Cursor curs) {
void Window::SetTitle(const char *s) { void Window::SetTitle(const char *s) {
#if wxUSE_UNICODE // will convert from UTF-8 in unicode mode
#error Fix this... wxString str(s, wxConvUTF8);
#else GETWIN(id)->SetTitle(str);
GETWIN(id)->SetTitle(s);
#endif
} }
@@ -777,12 +801,9 @@ int ListBox::Find(const char *prefix) {
} }
void ListBox::GetValue(int n, char *value, int len) { void ListBox::GetValue(int n, char *value, int len) {
#if wxUSE_UNICODE
#error fix this...
wxString text = GETLB(id)->GetString(n); wxString text = GETLB(id)->GetString(n);
strncpy(value, text.c_str(), len); strncpy(value, text.mb_str(wxConvUTF8), len);
value[len-1] = '\0'; value[len-1] = '\0';
#endif
} }
void ListBox::Sort() { void ListBox::Sort() {
@@ -824,7 +845,9 @@ ColourDesired Platform::ChromeHighlight() {
} }
const char *Platform::DefaultFont() { const char *Platform::DefaultFont() {
return wxNORMAL_FONT->GetFaceName(); static char buf[128];
strcpy(buf, wxNORMAL_FONT->GetFaceName().mbc_str());
return buf;
} }
int Platform::DefaultFontSize() { int Platform::DefaultFontSize() {
@@ -836,7 +859,7 @@ unsigned int Platform::DoubleClickTime() {
} }
void Platform::DebugDisplay(const char *s) { void Platform::DebugDisplay(const char *s) {
wxLogDebug(s); wxLogDebug(wxString(s, *wxConvCurrent));
} }
bool Platform::IsKeyDown(int key) { bool Platform::IsKeyDown(int key) {
@@ -895,7 +918,8 @@ void Platform::Assert(const char *c, const char *file, int line) {
char buffer[2000]; char buffer[2000];
sprintf(buffer, "Assertion [%s] failed at %s %d", c, file, line); sprintf(buffer, "Assertion [%s] failed at %s %d", c, file, line);
if (assertionPopUps) { if (assertionPopUps) {
int idButton = wxMessageBox(buffer, "Assertion failure", int idButton = wxMessageBox(wxString(buffer, *wxConvCurrent),
wxT("Assertion failure"),
wxICON_HAND | wxOK); wxICON_HAND | wxOK);
// if (idButton == IDRETRY) { // if (idButton == IDRETRY) {
// ::DebugBreak(); // ::DebugBreak();

View File

@@ -148,7 +148,7 @@ void ScintillaWX::Finalise() {
void ScintillaWX::StartDrag() { void ScintillaWX::StartDrag() {
#if wxUSE_DRAG_AND_DROP #if wxUSE_DRAG_AND_DROP
wxString dragText(drag.s, drag.len); wxString dragText(drag.s, wxConvUTF8, drag.len);
// Send an event to allow the drag text to be changed // Send an event to allow the drag text to be changed
wxStyledTextEvent evt(wxEVT_STC_START_DRAG, stc->GetId()); wxStyledTextEvent evt(wxEVT_STC_START_DRAG, stc->GetId());
@@ -296,7 +296,8 @@ void ScintillaWX::Copy() {
SelectionText st; SelectionText st;
CopySelectionRange(&st); CopySelectionRange(&st);
wxTheClipboard->Open(); wxTheClipboard->Open();
wxTheClipboard->SetData(new wxTextDataObject(wxString(st.s, st.len))); wxString text(st.s, wxConvUTF8, st.len);
wxTheClipboard->SetData(new wxTextDataObject(text));
wxTheClipboard->Close(); wxTheClipboard->Close();
} }
} }
@@ -313,9 +314,9 @@ void ScintillaWX::Paste() {
gotData = wxTheClipboard->GetData(data); gotData = wxTheClipboard->GetData(data);
wxTheClipboard->Close(); wxTheClipboard->Close();
if (gotData) { if (gotData) {
wxString str = data.GetText(); wxWX2MBbuf buf = (wxWX2MBbuf)data.GetText().mb_str(wxConvUTF8);
int len = str.Length(); int len = strlen(buf);
pdoc->InsertString(currentPos, str.c_str(), len); pdoc->InsertString(currentPos, buf, len);
SetEmptySelection(currentPos + len); SetEmptySelection(currentPos + len);
} }
@@ -329,7 +330,7 @@ bool ScintillaWX::CanPaste() {
bool canPaste; bool canPaste;
wxTheClipboard->Open(); wxTheClipboard->Open();
canPaste = wxTheClipboard->IsSupported( wxDF_TEXT ); canPaste = wxTheClipboard->IsSupported(wxUSE_UNICODE ? wxDF_UNICODETEXT : wxDF_TEXT);
wxTheClipboard->Close(); wxTheClipboard->Close();
return canPaste; return canPaste;
@@ -345,7 +346,7 @@ void ScintillaWX::AddToPopUp(const char *label, int cmd, bool enabled) {
if (!label[0]) if (!label[0])
((wxMenu*)popup.GetID())->AppendSeparator(); ((wxMenu*)popup.GetID())->AppendSeparator();
else else
((wxMenu*)popup.GetID())->Append(cmd, label); ((wxMenu*)popup.GetID())->Append(cmd, wxString(label, *wxConvCurrent));
if (!enabled) if (!enabled)
((wxMenu*)popup.GetID())->Enable(cmd, enabled); ((wxMenu*)popup.GetID())->Enable(cmd, enabled);
@@ -497,8 +498,8 @@ void ScintillaWX::DoButtonMove(Point pt) {
} }
void ScintillaWX::DoAddChar(char ch) { void ScintillaWX::DoAddChar(int key) {
AddChar(ch); AddChar(key);
} }
int ScintillaWX::DoKeyDown(int key, bool shift, bool ctrl, bool alt, bool* consumed) { int ScintillaWX::DoKeyDown(int key, bool shift, bool ctrl, bool alt, bool* consumed) {
@@ -579,7 +580,7 @@ bool ScintillaWX::DoDropText(long x, long y, const wxString& data) {
dragResult = evt.GetDragResult(); dragResult = evt.GetDragResult();
if (dragResult == wxDragMove || dragResult == wxDragCopy) { if (dragResult == wxDragMove || dragResult == wxDragCopy) {
DropAt(evt.GetPosition(), DropAt(evt.GetPosition(),
evt.GetDragText(), evt.GetDragText().mb_str(wxConvUTF8),
dragResult == wxDragMove, dragResult == wxDragMove,
FALSE); // TODO: rectangular? FALSE); // TODO: rectangular?
return TRUE; return TRUE;

View File

@@ -126,7 +126,7 @@ public:
void DoButtonUp(Point pt, unsigned int curTime, bool ctrl); void DoButtonUp(Point pt, unsigned int curTime, bool ctrl);
void DoButtonMove(Point pt); void DoButtonMove(Point pt);
void DoMouseWheel(int rotation, int delta, int linesPerAction, int ctrlDown); void DoMouseWheel(int rotation, int delta, int linesPerAction, int ctrlDown);
void DoAddChar(char ch); void DoAddChar(int key);
int DoKeyDown(int key, bool shift, bool ctrl, bool alt, bool* consumed); int DoKeyDown(int key, bool shift, bool ctrl, bool alt, bool* consumed);
void DoTick() { Tick(); } void DoTick() { Tick(); }

View File

@@ -68,38 +68,39 @@ methodOverrideMap = {
'void %s(const wxString& text);', 'void %s(const wxString& text);',
'''void %s(const wxString& text) { '''void %s(const wxString& text) {
SendMsg(%s, text.Len(), (long)text.c_str());''', wxWX2MBbuf buf = (wxWX2MBbuf)text.mb_str(wxConvUTF8);
SendMsg(%s, strlen(buf), (long)(const char*)buf);''',
0), 0),
'AddStyledText' : (0, 'AddStyledText' : (0,
'void %s(const wxString& text);', 'void %s(const wxMemoryBuffer& data);',
'''void %s(const wxString& text) { '''void %s(const wxMemoryBuffer& data) {
SendMsg(%s, text.Len(), (long)text.c_str());''', SendMsg(%s, data.GetDataLen(), (long)data.GetData());''',
0), 0),
'GetViewWS' : ( 'GetViewWhiteSpace', 0, 0, 0), 'GetViewWS' : ( 'GetViewWhiteSpace', 0, 0, 0),
'SetViewWS' : ( 'SetViewWhiteSpace', 0, 0, 0), 'SetViewWS' : ( 'SetViewWhiteSpace', 0, 0, 0),
'GetStyledText' : (0, 'GetStyledText' : (0,
'wxString %s(int startPos, int endPos);', 'wxMemoryBuffer %s(int startPos, int endPos);',
'''wxString %s(int startPos, int endPos) { '''wxMemoryBuffer %s(int startPos, int endPos) {
wxString text; wxMemoryBuffer buf;
if (endPos < startPos) { if (endPos < startPos) {
int temp = startPos; int temp = startPos;
startPos = endPos; startPos = endPos;
endPos = temp; endPos = temp;
} }
int len = endPos - startPos; int len = endPos - startPos;
if (!len) return ""; if (!len) return buf;
TextRange tr; TextRange tr;
tr.lpstrText = text.GetWriteBuf(len*2); tr.lpstrText = (char*)buf.GetWriteBuf(len*2+1);
tr.chrg.cpMin = startPos; tr.chrg.cpMin = startPos;
tr.chrg.cpMax = endPos; tr.chrg.cpMax = endPos;
SendMsg(%s, 0, (long)&tr); len = SendMsg(%s, 0, (long)&tr);
text.UngetWriteBuf(len*2); buf.UngetWriteBuf(len);
return text;''', return buf;''',
('Retrieve a buffer of cells.',)), ('Retrieve a buffer of cells.',)),
@@ -116,20 +117,20 @@ methodOverrideMap = {
'#ifdef SWIG\n wxString %s(int* OUTPUT);\n#else\n wxString GetCurLine(int* linePos=NULL);\n#endif', '#ifdef SWIG\n wxString %s(int* OUTPUT);\n#else\n wxString GetCurLine(int* linePos=NULL);\n#endif',
'''wxString %s(int* linePos) { '''wxString %s(int* linePos) {
wxString text;
int len = LineLength(GetCurrentLine()); int len = LineLength(GetCurrentLine());
if (!len) { if (!len) {
if (linePos) *linePos = 0; if (linePos) *linePos = 0;
return ""; return wxEmptyString;
} }
// Need an extra byte because SCI_GETCURLINE writes a null to the string
char* buf = text.GetWriteBuf(len+1); wxMemoryBuffer mbuf(len+1);
char* buf = (char*)mbuf.GetWriteBuf(len+1);
int pos = SendMsg(%s, len+1, (long)buf); int pos = SendMsg(%s, len+1, (long)buf);
text.UngetWriteBuf(len); mbuf.UngetWriteBuf(len);
mbuf.AppendByte(0);
if (linePos) *linePos = pos; if (linePos) *linePos = pos;
return wxString(buf, wxConvUTF8);''',
return text;''',
0), 0),
@@ -172,9 +173,6 @@ methodOverrideMap = {
'SetCaretFore' : ('SetCaretForeground', 0, 0, 0), 'SetCaretFore' : ('SetCaretForeground', 0, 0, 0),
'StyleSetFont' : ('StyleSetFaceName', 0, 0, 0), 'StyleSetFont' : ('StyleSetFaceName', 0, 0, 0),
# need to fix this to map between wx and scintilla encoding flags, leave it out for now...
'StyleSetCharacterSet' : (None, 0, 0, 0),
'AssignCmdKey' : ('CmdKeyAssign', 'AssignCmdKey' : ('CmdKeyAssign',
'void %s(int key, int modifiers, int cmd);', 'void %s(int key, int modifiers, int cmd);',
@@ -251,7 +249,7 @@ methodOverrideMap = {
flags |= wholeWord ? SCFIND_WHOLEWORD : 0; flags |= wholeWord ? SCFIND_WHOLEWORD : 0;
ft.chrg.cpMin = minPos; ft.chrg.cpMin = minPos;
ft.chrg.cpMax = maxPos; ft.chrg.cpMax = maxPos;
ft.lpstrText = (char*)text.c_str(); ft.lpstrText = (char*)(const char*)text.mb_str(wxConvUTF8);
return SendMsg(%s, flags, (long)&ft);''', return SendMsg(%s, flags, (long)&ft);''',
0), 0),
@@ -299,15 +297,15 @@ methodOverrideMap = {
'wxString %s(int line);', 'wxString %s(int line);',
'''wxString %s(int line) { '''wxString %s(int line) {
wxString text;
int len = LineLength(line); int len = LineLength(line);
if (!len) return ""; if (!len) return wxEmptyString;
char* buf = text.GetWriteBuf(len);
int pos = SendMsg(%s, line, (long)buf); wxMemoryBuffer mbuf(len+1);
text.UngetWriteBuf(len); char* buf = (char*)mbuf.GetWriteBuf(len+1);
SendMsg(%s, line, (long)buf);
return text;''', mbuf.UngetWriteBuf(len);
mbuf.AppendByte(0);
return wxString(buf, wxConvUTF8);''',
('Retrieve the contents of a line.',)), ('Retrieve the contents of a line.',)),
@@ -316,18 +314,19 @@ methodOverrideMap = {
'wxString %s();', 'wxString %s();',
'''wxString %s() { '''wxString %s() {
wxString text;
int start; int start;
int end; int end;
GetSelection(&start, &end); GetSelection(&start, &end);
int len = end - start; int len = end - start;
if (!len) return ""; if (!len) return wxEmptyString;
char* buff = text.GetWriteBuf(len);
SendMsg(%s, 0, (long)buff); wxMemoryBuffer mbuf(len+1);
text.UngetWriteBuf(len); char* buf = (char*)mbuf.GetWriteBuf(len+1);
return text;''', SendMsg(%s, 0, (long)buf);
mbuf.UngetWriteBuf(len);
mbuf.AppendByte(0);
return wxString(buf, wxConvUTF8);''',
('Retrieve the selected text.',)), ('Retrieve the selected text.',)),
@@ -335,23 +334,23 @@ methodOverrideMap = {
'wxString %s(int startPos, int endPos);', 'wxString %s(int startPos, int endPos);',
'''wxString %s(int startPos, int endPos) { '''wxString %s(int startPos, int endPos) {
wxString text;
if (endPos < startPos) { if (endPos < startPos) {
int temp = startPos; int temp = startPos;
startPos = endPos; startPos = endPos;
endPos = temp; endPos = temp;
} }
int len = endPos - startPos; int len = endPos - startPos;
if (!len) return ""; if (!len) return wxEmptyString;
char* buff = text.GetWriteBuf(len); wxMemoryBuffer mbuf(len+1);
char* buf = (char*)mbuf.GetWriteBuf(len);
TextRange tr; TextRange tr;
tr.lpstrText = buff; tr.lpstrText = buf;
tr.chrg.cpMin = startPos; tr.chrg.cpMin = startPos;
tr.chrg.cpMax = endPos; tr.chrg.cpMax = endPos;
SendMsg(%s, 0, (long)&tr); SendMsg(%s, 0, (long)&tr);
text.UngetWriteBuf(len); mbuf.UngetWriteBuf(len);
return text;''', mbuf.AppendByte(0);
return wxString(buf, wxConvUTF8);''',
('Retrieve a range of text.',)), ('Retrieve a range of text.',)),
@@ -366,13 +365,13 @@ methodOverrideMap = {
'wxString %s();', 'wxString %s();',
'''wxString %s() { '''wxString %s() {
wxString text; int len = GetTextLength();
int len = GetTextLength(); wxMemoryBuffer mbuf(len+1); // leave room for the null...
char* buff = text.GetWriteBuf(len+1); // leave room for the null... char* buf = (char*)mbuf.GetWriteBuf(len+1);
SendMsg(%s, len+1, (long)buf);
SendMsg(%s, len+1, (long)buff); mbuf.UngetWriteBuf(len);
text.UngetWriteBuf(len); mbuf.AppendByte(0);
return text;''', return wxString(buf, wxConvUTF8);''',
('Retrieve all the text in the document.', )), ('Retrieve all the text in the document.', )),
@@ -389,9 +388,8 @@ methodOverrideMap = {
''' '''
int %s(const wxString& text) { int %s(const wxString& text) {
return SendMsg(%s, text.Len(), (long)text.c_str()); wxWX2MBbuf buf = (wxWX2MBbuf)text.mb_str(wxConvUTF8);
''', return SendMsg(%s, strlen(buf), (long)(const char*)buf);''',
0), 0),
'ReplaceTargetRE' : (0, 'ReplaceTargetRE' : (0,
@@ -399,9 +397,8 @@ methodOverrideMap = {
''' '''
int %s(const wxString& text) { int %s(const wxString& text) {
return SendMsg(%s, text.Len(), (long)text.c_str()); wxWX2MBbuf buf = (wxWX2MBbuf)text.mb_str(wxConvUTF8);
''', return SendMsg(%s, strlen(buf), (long)(const char*)buf);''',
0), 0),
'SearchInTarget' : (0, 'SearchInTarget' : (0,
@@ -409,9 +406,8 @@ methodOverrideMap = {
''' '''
int %s(const wxString& text) { int %s(const wxString& text) {
return SendMsg(%s, text.Len(), (long)text.c_str()); wxWX2MBbuf buf = (wxWX2MBbuf)text.mb_str(wxConvUTF8);
''', return SendMsg(%s, strlen(buf), (long)(const char*)buf);''',
0), 0),
@@ -462,6 +458,7 @@ methodOverrideMap = {
'UpperCase' : (None, 0, 0, 0), 'UpperCase' : (None, 0, 0, 0),
'LineScrollDown' : (None, 0, 0, 0), 'LineScrollDown' : (None, 0, 0, 0),
'LineScrollUp' : (None, 0, 0, 0), 'LineScrollUp' : (None, 0, 0, 0),
'DeleteBackNotLine' : (None, 0, 0, 0),
'GetDocPointer' : (0, 'GetDocPointer' : (0,
@@ -493,6 +490,19 @@ methodOverrideMap = {
'''void %s(void* docPointer) { '''void %s(void* docPointer) {
SendMsg(%s, (long)docPointer);''', SendMsg(%s, (long)docPointer);''',
0), 0),
'SetCodePage' : (0,
0,
'''void %s(int codePage) {
#if wxUSE_UNICODE
wxASSERT_MSG(codePage == wxSTC_CP_UTF8,
wxT("Only wxSTC_CP_UTF8 may be used when wxUSE_UNICODE is on."));
#else
wxASSERT_MSG(codePage != wxSTC_CP_UTF8,
wxT("wxSTC_CP_UTF8 may not be used when wxUSE_UNICODE is off."));
#endif
SendMsg(%s, codePage);''',
("Set the code page used to interpret the bytes of the document as characters.",) ),
'GrabFocus' : (None, 0, 0, 0), 'GrabFocus' : (None, 0, 0, 0),
'SetFocus' : ('SetSTCFocus', 0, 0, 0), 'SetFocus' : ('SetSTCFocus', 0, 0, 0),
@@ -652,7 +662,7 @@ def makeArgString(param):
typ, name = param typ, name = param
if typ == 'string': if typ == 'string':
return '(long)%s.c_str()' % name return '(long)(const char*)%s.mb_str(wxConvUTF8)' % name
if typ == 'colour': if typ == 'colour':
return 'wxColourAsLong(%s)' % name return 'wxColourAsLong(%s)' % name
@@ -721,7 +731,7 @@ def parseFun(line, methods, docs, values):
num = string.atoi(number) num = string.atoi(number)
for v in cmdValues: for v in cmdValues:
if (type(v) == type(()) and v[0] <= num < v[1]) or v == num: if (type(v) == type(()) and v[0] <= num < v[1]) or v == num:
parseVal('CMD_%s=%s' % (string.upper(name), number), values, ()) parseVal('CMD_%s=%s' % (string.upper(name), number), values, docs)
#if retType == 'void' and not param1 and not param2: #if retType == 'void' and not param1 and not param2:

View File

@@ -25,7 +25,7 @@
//---------------------------------------------------------------------- //----------------------------------------------------------------------
const wxChar* wxSTCNameStr = "stcwindow"; const wxChar* wxSTCNameStr = wxT("stcwindow");
DEFINE_EVENT_TYPE( wxEVT_STC_CHANGE ) DEFINE_EVENT_TYPE( wxEVT_STC_CHANGE )
DEFINE_EVENT_TYPE( wxEVT_STC_STYLENEEDED ) DEFINE_EVENT_TYPE( wxEVT_STC_STYLENEEDED )
@@ -105,6 +105,10 @@ wxStyledTextCtrl::wxStyledTextCtrl(wxWindow *parent,
m_lastKeyDownConsumed = FALSE; m_lastKeyDownConsumed = FALSE;
m_vScrollBar = NULL; m_vScrollBar = NULL;
m_hScrollBar = NULL; m_hScrollBar = NULL;
#if wxUSE_UNICODE
// Put Scintilla into unicode (UTF-8) mode
SetCodePage(wxSTC_CP_UTF8);
#endif
} }
@@ -142,11 +146,12 @@ static wxColour wxColourFromLong(long c) {
static wxColour wxColourFromSpec(const wxString& spec) { static wxColour wxColourFromSpec(const wxString& spec) {
// spec should be #RRGGBB // spec should be "#RRGGBB"
char* junk; long red, green, blue;
int red = strtol(spec.Mid(1,2), &junk, 16); red = green = blue = 0;
int green = strtol(spec.Mid(3,2), &junk, 16); spec.Mid(1,2).ToLong(&red, 16);
int blue = strtol(spec.Mid(5,2), &junk, 16); spec.Mid(3,2).ToLong(&green, 16);
spec.Mid(5,2).ToLong(&blue, 16);
return wxColour(red, green, blue); return wxColour(red, green, blue);
} }
@@ -159,17 +164,18 @@ static wxColour wxColourFromSpec(const wxString& spec) {
// Add text to the document // Add text to the document
void wxStyledTextCtrl::AddText(const wxString& text) { void wxStyledTextCtrl::AddText(const wxString& text) {
SendMsg(2001, text.Len(), (long)text.c_str()); wxWX2MBbuf buf = (wxWX2MBbuf)text.mb_str(wxConvUTF8);
SendMsg(2001, strlen(buf), (long)(const char*)buf);
} }
// Add array of cells to document // Add array of cells to document
void wxStyledTextCtrl::AddStyledText(const wxString& text) { void wxStyledTextCtrl::AddStyledText(const wxMemoryBuffer& data) {
SendMsg(2002, text.Len(), (long)text.c_str()); SendMsg(2002, data.GetDataLen(), (long)data.GetData());
} }
// Insert string at a position // Insert string at a position
void wxStyledTextCtrl::InsertText(int pos, const wxString& text) { void wxStyledTextCtrl::InsertText(int pos, const wxString& text) {
SendMsg(2003, pos, (long)text.c_str()); SendMsg(2003, pos, (long)(const char*)text.mb_str(wxConvUTF8));
} }
// Delete all text in the document // Delete all text in the document
@@ -230,22 +236,22 @@ void wxStyledTextCtrl::SetSavePoint() {
} }
// Retrieve a buffer of cells. // Retrieve a buffer of cells.
wxString wxStyledTextCtrl::GetStyledText(int startPos, int endPos) { wxMemoryBuffer wxStyledTextCtrl::GetStyledText(int startPos, int endPos) {
wxString text; wxMemoryBuffer buf;
if (endPos < startPos) { if (endPos < startPos) {
int temp = startPos; int temp = startPos;
startPos = endPos; startPos = endPos;
endPos = temp; endPos = temp;
} }
int len = endPos - startPos; int len = endPos - startPos;
if (!len) return ""; if (!len) return buf;
TextRange tr; TextRange tr;
tr.lpstrText = text.GetWriteBuf(len*2); tr.lpstrText = (char*)buf.GetWriteBuf(len*2+1);
tr.chrg.cpMin = startPos; tr.chrg.cpMin = startPos;
tr.chrg.cpMax = endPos; tr.chrg.cpMax = endPos;
SendMsg(2015, 0, (long)&tr); len = SendMsg(2015, 0, (long)&tr);
text.UngetWriteBuf(len*2); buf.UngetWriteBuf(len);
return text; return buf;
} }
// Are there any redoable actions in the undo history. // Are there any redoable actions in the undo history.
@@ -309,20 +315,20 @@ void wxStyledTextCtrl::SetAnchor(int posAnchor) {
// Retrieve the text of the line containing the caret. // Retrieve the text of the line containing the caret.
// Returns the index of the caret on the line. // Returns the index of the caret on the line.
wxString wxStyledTextCtrl::GetCurLine(int* linePos) { wxString wxStyledTextCtrl::GetCurLine(int* linePos) {
wxString text;
int len = LineLength(GetCurrentLine()); int len = LineLength(GetCurrentLine());
if (!len) { if (!len) {
if (linePos) *linePos = 0; if (linePos) *linePos = 0;
return ""; return wxEmptyString;
} }
// Need an extra byte because SCI_GETCURLINE writes a null to the string
char* buf = text.GetWriteBuf(len+1); wxMemoryBuffer mbuf(len+1);
char* buf = (char*)mbuf.GetWriteBuf(len+1);
int pos = SendMsg(2027, len+1, (long)buf); int pos = SendMsg(2027, len+1, (long)buf);
text.UngetWriteBuf(len); mbuf.UngetWriteBuf(len);
mbuf.AppendByte(0);
if (linePos) *linePos = pos; if (linePos) *linePos = pos;
return wxString(buf, wxConvUTF8);
return text;
} }
// Retrieve the position of the last correctly styled character. // Retrieve the position of the last correctly styled character.
@@ -381,9 +387,15 @@ int wxStyledTextCtrl::GetTabWidth() {
} }
// Set the code page used to interpret the bytes of the document as characters. // Set the code page used to interpret the bytes of the document as characters.
// The SC_CP_UTF8 value can be used to enter Unicode mode.
void wxStyledTextCtrl::SetCodePage(int codePage) { void wxStyledTextCtrl::SetCodePage(int codePage) {
SendMsg(2037, codePage, 0); #if wxUSE_UNICODE
wxASSERT_MSG(codePage == wxSTC_CP_UTF8,
wxT("Only wxSTC_CP_UTF8 may be used when wxUSE_UNICODE is on."));
#else
wxASSERT_MSG(codePage != wxSTC_CP_UTF8,
wxT("wxSTC_CP_UTF8 may not be used when wxUSE_UNICODE is off."));
#endif
SendMsg(2037, codePage);
} }
// Set the symbol used for a particular marker number, // Set the symbol used for a particular marker number,
@@ -511,7 +523,7 @@ void wxStyledTextCtrl::StyleSetSize(int style, int sizePoints) {
// Set the font of a style. // Set the font of a style.
void wxStyledTextCtrl::StyleSetFaceName(int style, const wxString& fontName) { void wxStyledTextCtrl::StyleSetFaceName(int style, const wxString& fontName) {
SendMsg(2056, style, (long)fontName.c_str()); SendMsg(2056, style, (long)(const char*)fontName.mb_str(wxConvUTF8));
} }
// Set a style to have its end of line filled or not. // Set a style to have its end of line filled or not.
@@ -534,6 +546,11 @@ void wxStyledTextCtrl::StyleSetCase(int style, int caseForce) {
SendMsg(2060, style, caseForce); SendMsg(2060, style, caseForce);
} }
// Set the character set of the font in a style.
void wxStyledTextCtrl::StyleSetCharacterSet(int style, int characterSet) {
SendMsg(2066, style, characterSet);
}
// Set the foreground colour of the selection and whether to use this setting. // Set the foreground colour of the selection and whether to use this setting.
void wxStyledTextCtrl::SetSelForeground(bool useSetting, const wxColour& fore) { void wxStyledTextCtrl::SetSelForeground(bool useSetting, const wxColour& fore) {
SendMsg(2067, useSetting, wxColourAsLong(fore)); SendMsg(2067, useSetting, wxColourAsLong(fore));
@@ -587,7 +604,7 @@ void wxStyledTextCtrl::SetCaretPeriod(int periodMilliseconds) {
// Set the set of characters making up words for when moving or selecting // Set the set of characters making up words for when moving or selecting
// by word. // by word.
void wxStyledTextCtrl::SetWordChars(const wxString& characters) { void wxStyledTextCtrl::SetWordChars(const wxString& characters) {
SendMsg(2077, 0, (long)characters.c_str()); SendMsg(2077, 0, (long)(const char*)characters.mb_str(wxConvUTF8));
} }
// Start a sequence of actions that is undone and redone as a unit. // Start a sequence of actions that is undone and redone as a unit.
@@ -680,7 +697,7 @@ void wxStyledTextCtrl::StyleSetChangeable(int style, bool changeable) {
// The lenEntered parameter indicates how many characters before // The lenEntered parameter indicates how many characters before
// the caret should be used to provide context. // the caret should be used to provide context.
void wxStyledTextCtrl::AutoCompShow(int lenEntered, const wxString& itemList) { void wxStyledTextCtrl::AutoCompShow(int lenEntered, const wxString& itemList) {
SendMsg(2100, lenEntered, (long)itemList.c_str()); SendMsg(2100, lenEntered, (long)(const char*)itemList.mb_str(wxConvUTF8));
} }
// Remove the auto-completion list from the screen. // Remove the auto-completion list from the screen.
@@ -706,7 +723,7 @@ void wxStyledTextCtrl::AutoCompComplete() {
// Define a set of character that when typed cancel the auto-completion list. // Define a set of character that when typed cancel the auto-completion list.
void wxStyledTextCtrl::AutoCompStops(const wxString& characterSet) { void wxStyledTextCtrl::AutoCompStops(const wxString& characterSet) {
SendMsg(2105, 0, (long)characterSet.c_str()); SendMsg(2105, 0, (long)(const char*)characterSet.mb_str(wxConvUTF8));
} }
// Change the separator character in the string setting up an auto-completion // Change the separator character in the string setting up an auto-completion
@@ -722,7 +739,7 @@ int wxStyledTextCtrl::AutoCompGetSeparator() {
// Select the item in the auto-completion list that starts with a string. // Select the item in the auto-completion list that starts with a string.
void wxStyledTextCtrl::AutoCompSelect(const wxString& text) { void wxStyledTextCtrl::AutoCompSelect(const wxString& text) {
SendMsg(2108, 0, (long)text.c_str()); SendMsg(2108, 0, (long)(const char*)text.mb_str(wxConvUTF8));
} }
// Should the auto-completion list be cancelled if the user backspaces to a // Should the auto-completion list be cancelled if the user backspaces to a
@@ -739,7 +756,7 @@ bool wxStyledTextCtrl::AutoCompGetCancelAtStart() {
// Define a set of characters that when typed will cause the autocompletion to // Define a set of characters that when typed will cause the autocompletion to
// choose the selected item. // choose the selected item.
void wxStyledTextCtrl::AutoCompSetFillUps(const wxString& characterSet) { void wxStyledTextCtrl::AutoCompSetFillUps(const wxString& characterSet) {
SendMsg(2112, 0, (long)characterSet.c_str()); SendMsg(2112, 0, (long)(const char*)characterSet.mb_str(wxConvUTF8));
} }
// Should a single item auto-completion list automatically choose the item. // Should a single item auto-completion list automatically choose the item.
@@ -764,7 +781,7 @@ bool wxStyledTextCtrl::AutoCompGetIgnoreCase() {
// Display a list of strings and send notification when user chooses one. // Display a list of strings and send notification when user chooses one.
void wxStyledTextCtrl::UserListShow(int listType, const wxString& itemList) { void wxStyledTextCtrl::UserListShow(int listType, const wxString& itemList) {
SendMsg(2117, listType, (long)itemList.c_str()); SendMsg(2117, listType, (long)(const char*)itemList.mb_str(wxConvUTF8));
} }
// Set whether or not autocompletion is hidden automatically when nothing matches // Set whether or not autocompletion is hidden automatically when nothing matches
@@ -936,7 +953,7 @@ int wxStyledTextCtrl::FindText(int minPos, int maxPos,
flags |= wholeWord ? SCFIND_WHOLEWORD : 0; flags |= wholeWord ? SCFIND_WHOLEWORD : 0;
ft.chrg.cpMin = minPos; ft.chrg.cpMin = minPos;
ft.chrg.cpMax = maxPos; ft.chrg.cpMax = maxPos;
ft.lpstrText = (char*)text.c_str(); ft.lpstrText = (char*)(const char*)text.mb_str(wxConvUTF8);
return SendMsg(2150, flags, (long)&ft); return SendMsg(2150, flags, (long)&ft);
} }
@@ -979,15 +996,15 @@ int wxStyledTextCtrl::GetFirstVisibleLine() {
// Retrieve the contents of a line. // Retrieve the contents of a line.
wxString wxStyledTextCtrl::GetLine(int line) { wxString wxStyledTextCtrl::GetLine(int line) {
wxString text;
int len = LineLength(line); int len = LineLength(line);
if (!len) return ""; if (!len) return wxEmptyString;
char* buf = text.GetWriteBuf(len);
int pos = SendMsg(2153, line, (long)buf); wxMemoryBuffer mbuf(len+1);
text.UngetWriteBuf(len); char* buf = (char*)mbuf.GetWriteBuf(len+1);
SendMsg(2153, line, (long)buf);
return text; mbuf.UngetWriteBuf(len);
mbuf.AppendByte(0);
return wxString(buf, wxConvUTF8);
} }
// Returns the number of lines in the document. There is always at least one. // Returns the number of lines in the document. There is always at least one.
@@ -1027,39 +1044,40 @@ void wxStyledTextCtrl::SetSelection(int start, int end) {
// Retrieve the selected text. // Retrieve the selected text.
wxString wxStyledTextCtrl::GetSelectedText() { wxString wxStyledTextCtrl::GetSelectedText() {
wxString text;
int start; int start;
int end; int end;
GetSelection(&start, &end); GetSelection(&start, &end);
int len = end - start; int len = end - start;
if (!len) return ""; if (!len) return wxEmptyString;
char* buff = text.GetWriteBuf(len);
SendMsg(2161, 0, (long)buff); wxMemoryBuffer mbuf(len+1);
text.UngetWriteBuf(len); char* buf = (char*)mbuf.GetWriteBuf(len+1);
return text; SendMsg(2161, 0, (long)buf);
mbuf.UngetWriteBuf(len);
mbuf.AppendByte(0);
return wxString(buf, wxConvUTF8);
} }
// Retrieve a range of text. // Retrieve a range of text.
wxString wxStyledTextCtrl::GetTextRange(int startPos, int endPos) { wxString wxStyledTextCtrl::GetTextRange(int startPos, int endPos) {
wxString text;
if (endPos < startPos) { if (endPos < startPos) {
int temp = startPos; int temp = startPos;
startPos = endPos; startPos = endPos;
endPos = temp; endPos = temp;
} }
int len = endPos - startPos; int len = endPos - startPos;
if (!len) return ""; if (!len) return wxEmptyString;
char* buff = text.GetWriteBuf(len); wxMemoryBuffer mbuf(len+1);
char* buf = (char*)mbuf.GetWriteBuf(len);
TextRange tr; TextRange tr;
tr.lpstrText = buff; tr.lpstrText = buf;
tr.chrg.cpMin = startPos; tr.chrg.cpMin = startPos;
tr.chrg.cpMax = endPos; tr.chrg.cpMax = endPos;
SendMsg(2162, 0, (long)&tr); SendMsg(2162, 0, (long)&tr);
text.UngetWriteBuf(len); mbuf.UngetWriteBuf(len);
return text; mbuf.AppendByte(0);
return wxString(buf, wxConvUTF8);
} }
// Draw the selection in normal style or with selection highlighted. // Draw the selection in normal style or with selection highlighted.
@@ -1089,7 +1107,7 @@ void wxStyledTextCtrl::EnsureCaretVisible() {
// Replace the selected text with the argument text. // Replace the selected text with the argument text.
void wxStyledTextCtrl::ReplaceSelection(const wxString& text) { void wxStyledTextCtrl::ReplaceSelection(const wxString& text) {
SendMsg(2170, 0, (long)text.c_str()); SendMsg(2170, 0, (long)(const char*)text.mb_str(wxConvUTF8));
} }
// Set to read only or read write. // Set to read only or read write.
@@ -1139,18 +1157,18 @@ void wxStyledTextCtrl::Clear() {
// Replace the contents of the document with the argument text. // Replace the contents of the document with the argument text.
void wxStyledTextCtrl::SetText(const wxString& text) { void wxStyledTextCtrl::SetText(const wxString& text) {
SendMsg(2181, 0, (long)text.c_str()); SendMsg(2181, 0, (long)(const char*)text.mb_str(wxConvUTF8));
} }
// Retrieve all the text in the document. // Retrieve all the text in the document.
wxString wxStyledTextCtrl::GetText() { wxString wxStyledTextCtrl::GetText() {
wxString text; int len = GetTextLength();
int len = GetTextLength(); wxMemoryBuffer mbuf(len+1); // leave room for the null...
char* buff = text.GetWriteBuf(len+1); // leave room for the null... char* buf = (char*)mbuf.GetWriteBuf(len+1);
SendMsg(2182, len+1, (long)buf);
SendMsg(2182, len+1, (long)buff); mbuf.UngetWriteBuf(len);
text.UngetWriteBuf(len); mbuf.AppendByte(0);
return text; return wxString(buf, wxConvUTF8);
} }
// Retrieve the number of characters in the document. // Retrieve the number of characters in the document.
@@ -1205,8 +1223,8 @@ int wxStyledTextCtrl::GetTargetEnd() {
// Returns the length of the replacement text. // Returns the length of the replacement text.
int wxStyledTextCtrl::ReplaceTarget(const wxString& text) { int wxStyledTextCtrl::ReplaceTarget(const wxString& text) {
return SendMsg(2194, text.Len(), (long)text.c_str()); wxWX2MBbuf buf = (wxWX2MBbuf)text.mb_str(wxConvUTF8);
return SendMsg(2194, strlen(buf), (long)(const char*)buf);
} }
// Replace the target text with the argument text after \d processing. // Replace the target text with the argument text after \d processing.
@@ -1217,8 +1235,8 @@ int wxStyledTextCtrl::GetTargetEnd() {
// caused by processing the \d patterns. // caused by processing the \d patterns.
int wxStyledTextCtrl::ReplaceTargetRE(const wxString& text) { int wxStyledTextCtrl::ReplaceTargetRE(const wxString& text) {
return SendMsg(2195, text.Len(), (long)text.c_str()); wxWX2MBbuf buf = (wxWX2MBbuf)text.mb_str(wxConvUTF8);
return SendMsg(2195, strlen(buf), (long)(const char*)buf);
} }
// Search for a counted string in the target and set the target to the found // Search for a counted string in the target and set the target to the found
@@ -1226,8 +1244,8 @@ int wxStyledTextCtrl::GetTargetEnd() {
// Returns length of range or -1 for failure in which case target is not moved. // Returns length of range or -1 for failure in which case target is not moved.
int wxStyledTextCtrl::SearchInTarget(const wxString& text) { int wxStyledTextCtrl::SearchInTarget(const wxString& text) {
return SendMsg(2197, text.Len(), (long)text.c_str()); wxWX2MBbuf buf = (wxWX2MBbuf)text.mb_str(wxConvUTF8);
return SendMsg(2197, strlen(buf), (long)(const char*)buf);
} }
// Set the search flags used by SearchInTarget // Set the search flags used by SearchInTarget
@@ -1242,7 +1260,7 @@ int wxStyledTextCtrl::GetSearchFlags() {
// Show a call tip containing a definition near position pos. // Show a call tip containing a definition near position pos.
void wxStyledTextCtrl::CallTipShow(int pos, const wxString& definition) { void wxStyledTextCtrl::CallTipShow(int pos, const wxString& definition) {
SendMsg(2200, pos, (long)definition.c_str()); SendMsg(2200, pos, (long)(const char*)definition.mb_str(wxConvUTF8));
} }
// Remove the call tip from the screen. // Remove the call tip from the screen.
@@ -1408,12 +1426,6 @@ int wxStyledTextCtrl::GetLayoutCache() {
return SendMsg(2273, 0, 0); return SendMsg(2273, 0, 0);
} }
// Delete the selection or if no selection, the character before the caret.
// Will not delete the chraacter before at the start of a line.
void wxStyledTextCtrl::DeleteBackNotLine() {
SendMsg(2344, 0, 0);
}
// Move the caret inside current view if it's not there already // Move the caret inside current view if it's not there already
void wxStyledTextCtrl::MoveCaretInsideView() { void wxStyledTextCtrl::MoveCaretInsideView() {
SendMsg(2401, 0, 0); SendMsg(2401, 0, 0);
@@ -1505,13 +1517,13 @@ void wxStyledTextCtrl::SearchAnchor() {
// Find some text starting at the search anchor. // Find some text starting at the search anchor.
// Does not ensure the selection is visible. // Does not ensure the selection is visible.
int wxStyledTextCtrl::SearchNext(int flags, const wxString& text) { int wxStyledTextCtrl::SearchNext(int flags, const wxString& text) {
return SendMsg(2367, flags, (long)text.c_str()); return SendMsg(2367, flags, (long)(const char*)text.mb_str(wxConvUTF8));
} }
// Find some text starting at the search anchor and moving backwards. // Find some text starting at the search anchor and moving backwards.
// Does not ensure the selection is visible. // Does not ensure the selection is visible.
int wxStyledTextCtrl::SearchPrev(int flags, const wxString& text) { int wxStyledTextCtrl::SearchPrev(int flags, const wxString& text) {
return SendMsg(2368, flags, (long)text.c_str()); return SendMsg(2368, flags, (long)(const char*)text.mb_str(wxConvUTF8));
} }
// Set the way the line the caret is on is kept visible. // Set the way the line the caret is on is kept visible.
@@ -1688,17 +1700,17 @@ void wxStyledTextCtrl::Colourise(int start, int end) {
// Set up a value that may be used by a lexer for some optional feature. // Set up a value that may be used by a lexer for some optional feature.
void wxStyledTextCtrl::SetProperty(const wxString& key, const wxString& value) { void wxStyledTextCtrl::SetProperty(const wxString& key, const wxString& value) {
SendMsg(4004, (long)key.c_str(), (long)value.c_str()); SendMsg(4004, (long)(const char*)key.mb_str(wxConvUTF8), (long)(const char*)value.mb_str(wxConvUTF8));
} }
// Set up the key words used by the lexer. // Set up the key words used by the lexer.
void wxStyledTextCtrl::SetKeyWords(int keywordSet, const wxString& keyWords) { void wxStyledTextCtrl::SetKeyWords(int keywordSet, const wxString& keyWords) {
SendMsg(4005, keywordSet, (long)keyWords.c_str()); SendMsg(4005, keywordSet, (long)(const char*)keyWords.mb_str(wxConvUTF8));
} }
// Set the lexing language of the document based on string name. // Set the lexing language of the document based on string name.
void wxStyledTextCtrl::SetLexerLanguage(const wxString& language) { void wxStyledTextCtrl::SetLexerLanguage(const wxString& language) {
SendMsg(4006, 0, (long)language.c_str()); SendMsg(4006, 0, (long)(const char*)language.mb_str(wxConvUTF8));
} }
// END of generated section // END of generated section
@@ -1863,6 +1875,7 @@ void wxStyledTextCtrl::OnScroll(wxScrollEvent& evt) {
void wxStyledTextCtrl::OnSize(wxSizeEvent& evt) { void wxStyledTextCtrl::OnSize(wxSizeEvent& evt) {
wxSize sz = GetClientSize(); wxSize sz = GetClientSize();
m_swx->DoSize(sz.x, sz.y); m_swx->DoSize(sz.x, sz.y);
Refresh(FALSE);
} }
void wxStyledTextCtrl::OnMouseLeftDown(wxMouseEvent& evt) { void wxStyledTextCtrl::OnMouseLeftDown(wxMouseEvent& evt) {
@@ -1905,10 +1918,7 @@ void wxStyledTextCtrl::OnMouseWheel(wxMouseEvent& evt) {
void wxStyledTextCtrl::OnChar(wxKeyEvent& evt) { void wxStyledTextCtrl::OnChar(wxKeyEvent& evt) {
long key = evt.KeyCode(); int key = evt.GetKeyCode();
// printf("OnChar key:%d consumed:%d ctrl:%d alt:%d\n",
// key, m_lastKeyDownConsumed, evt.ControlDown(), evt.AltDown());
// AltGr keys??? // AltGr keys???
// \|@#<23>[]{}?<3F>$~ <20>,<2C>,<2C>,<2C>, <20>, <20> // \|@#<23>[]{}?<3F>$~ <20>,<2C>,<2C>,<2C>, <20>, <20>
@@ -1921,7 +1931,10 @@ void wxStyledTextCtrl::OnChar(wxKeyEvent& evt) {
bool alt = evt.AltDown(); bool alt = evt.AltDown();
bool skip = ((ctrl || alt) && ! (ctrl && alt)); bool skip = ((ctrl || alt) && ! (ctrl && alt));
if (key <= 0xff && key >= 32 && !m_lastKeyDownConsumed && !skip) { //printf("OnChar key:%d consumed:%d ctrl:%d alt:%d skip:%d\n",
// key, m_lastKeyDownConsumed, ctrl, alt, skip);
if (key <= WXK_START && /*key >= 32 &&*/ !m_lastKeyDownConsumed && !skip) {
m_swx->DoAddChar(key); m_swx->DoAddChar(key);
return; return;
} }
@@ -1930,10 +1943,10 @@ void wxStyledTextCtrl::OnChar(wxKeyEvent& evt) {
void wxStyledTextCtrl::OnKeyDown(wxKeyEvent& evt) { void wxStyledTextCtrl::OnKeyDown(wxKeyEvent& evt) {
long key = evt.KeyCode(); int key = evt.GetKeyCode();
bool shift = evt.ShiftDown(), bool shift = evt.ShiftDown(),
ctrl = evt.ControlDown(), ctrl = evt.ControlDown(),
alt = evt.AltDown(); alt = evt.AltDown();
int processed = m_swx->DoKeyDown(key, shift, ctrl, alt, &m_lastKeyDownConsumed); int processed = m_swx->DoKeyDown(key, shift, ctrl, alt, &m_lastKeyDownConsumed);
@@ -2031,8 +2044,14 @@ void wxStyledTextCtrl::NotifyParent(SCNotification* _scn) {
case SCN_MODIFIED: case SCN_MODIFIED:
evt.SetEventType(wxEVT_STC_MODIFIED); evt.SetEventType(wxEVT_STC_MODIFIED);
evt.SetModificationType(scn.modificationType); evt.SetModificationType(scn.modificationType);
if (scn.text) if (scn.text) {
evt.SetText(wxString(scn.text, scn.length)); // The unicode conversion MUST have a null byte to terminate the
// string so move it into a buffer first and give it one.
wxMemoryBuffer buf(scn.length+1);
buf.AppendData((void*)scn.text, scn.length);
buf.AppendByte(0);
evt.SetText(wxString(buf, wxConvUTF8));
}
evt.SetLength(scn.length); evt.SetLength(scn.length);
evt.SetLinesAdded(scn.linesAdded); evt.SetLinesAdded(scn.linesAdded);
evt.SetLine(scn.line); evt.SetLine(scn.line);

View File

@@ -25,7 +25,7 @@
//---------------------------------------------------------------------- //----------------------------------------------------------------------
const wxChar* wxSTCNameStr = "stcwindow"; const wxChar* wxSTCNameStr = wxT("stcwindow");
DEFINE_EVENT_TYPE( wxEVT_STC_CHANGE ) DEFINE_EVENT_TYPE( wxEVT_STC_CHANGE )
DEFINE_EVENT_TYPE( wxEVT_STC_STYLENEEDED ) DEFINE_EVENT_TYPE( wxEVT_STC_STYLENEEDED )
@@ -105,6 +105,10 @@ wxStyledTextCtrl::wxStyledTextCtrl(wxWindow *parent,
m_lastKeyDownConsumed = FALSE; m_lastKeyDownConsumed = FALSE;
m_vScrollBar = NULL; m_vScrollBar = NULL;
m_hScrollBar = NULL; m_hScrollBar = NULL;
#if wxUSE_UNICODE
// Put Scintilla into unicode (UTF-8) mode
SetCodePage(wxSTC_CP_UTF8);
#endif
} }
@@ -142,11 +146,12 @@ static wxColour wxColourFromLong(long c) {
static wxColour wxColourFromSpec(const wxString& spec) { static wxColour wxColourFromSpec(const wxString& spec) {
// spec should be #RRGGBB // spec should be "#RRGGBB"
char* junk; long red, green, blue;
int red = strtol(spec.Mid(1,2), &junk, 16); red = green = blue = 0;
int green = strtol(spec.Mid(3,2), &junk, 16); spec.Mid(1,2).ToLong(&red, 16);
int blue = strtol(spec.Mid(5,2), &junk, 16); spec.Mid(3,2).ToLong(&green, 16);
spec.Mid(5,2).ToLong(&blue, 16);
return wxColour(red, green, blue); return wxColour(red, green, blue);
} }
@@ -320,6 +325,7 @@ void wxStyledTextCtrl::OnScroll(wxScrollEvent& evt) {
void wxStyledTextCtrl::OnSize(wxSizeEvent& evt) { void wxStyledTextCtrl::OnSize(wxSizeEvent& evt) {
wxSize sz = GetClientSize(); wxSize sz = GetClientSize();
m_swx->DoSize(sz.x, sz.y); m_swx->DoSize(sz.x, sz.y);
Refresh(FALSE);
} }
void wxStyledTextCtrl::OnMouseLeftDown(wxMouseEvent& evt) { void wxStyledTextCtrl::OnMouseLeftDown(wxMouseEvent& evt) {
@@ -362,10 +368,7 @@ void wxStyledTextCtrl::OnMouseWheel(wxMouseEvent& evt) {
void wxStyledTextCtrl::OnChar(wxKeyEvent& evt) { void wxStyledTextCtrl::OnChar(wxKeyEvent& evt) {
long key = evt.KeyCode(); int key = evt.GetKeyCode();
// printf("OnChar key:%%d consumed:%%d ctrl:%%d alt:%%d\n",
// key, m_lastKeyDownConsumed, evt.ControlDown(), evt.AltDown());
// AltGr keys??? // AltGr keys???
// \|@#<23>[]{}?<3F>$~ <20>,<2C>,<2C>,<2C>, <20>, <20> // \|@#<23>[]{}?<3F>$~ <20>,<2C>,<2C>,<2C>, <20>, <20>
@@ -378,7 +381,10 @@ void wxStyledTextCtrl::OnChar(wxKeyEvent& evt) {
bool alt = evt.AltDown(); bool alt = evt.AltDown();
bool skip = ((ctrl || alt) && ! (ctrl && alt)); bool skip = ((ctrl || alt) && ! (ctrl && alt));
if (key <= 0xff && key >= 32 && !m_lastKeyDownConsumed && !skip) { //printf("OnChar key:%%d consumed:%%d ctrl:%%d alt:%%d skip:%%d\n",
// key, m_lastKeyDownConsumed, ctrl, alt, skip);
if (key <= WXK_START && /*key >= 32 &&*/ !m_lastKeyDownConsumed && !skip) {
m_swx->DoAddChar(key); m_swx->DoAddChar(key);
return; return;
} }
@@ -387,10 +393,10 @@ void wxStyledTextCtrl::OnChar(wxKeyEvent& evt) {
void wxStyledTextCtrl::OnKeyDown(wxKeyEvent& evt) { void wxStyledTextCtrl::OnKeyDown(wxKeyEvent& evt) {
long key = evt.KeyCode(); int key = evt.GetKeyCode();
bool shift = evt.ShiftDown(), bool shift = evt.ShiftDown(),
ctrl = evt.ControlDown(), ctrl = evt.ControlDown(),
alt = evt.AltDown(); alt = evt.AltDown();
int processed = m_swx->DoKeyDown(key, shift, ctrl, alt, &m_lastKeyDownConsumed); int processed = m_swx->DoKeyDown(key, shift, ctrl, alt, &m_lastKeyDownConsumed);
@@ -488,8 +494,14 @@ void wxStyledTextCtrl::NotifyParent(SCNotification* _scn) {
case SCN_MODIFIED: case SCN_MODIFIED:
evt.SetEventType(wxEVT_STC_MODIFIED); evt.SetEventType(wxEVT_STC_MODIFIED);
evt.SetModificationType(scn.modificationType); evt.SetModificationType(scn.modificationType);
if (scn.text) if (scn.text) {
evt.SetText(wxString(scn.text, scn.length)); // The unicode conversion MUST have a null byte to terminate the
// string so move it into a buffer first and give it one.
wxMemoryBuffer buf(scn.length+1);
buf.AppendData((void*)scn.text, scn.length);
buf.AppendByte(0);
evt.SetText(wxString(buf, wxConvUTF8));
}
evt.SetLength(scn.length); evt.SetLength(scn.length);
evt.SetLinesAdded(scn.linesAdded); evt.SetLinesAdded(scn.linesAdded);
evt.SetLine(scn.line); evt.SetLine(scn.line);

View File

@@ -210,7 +210,7 @@ public:
void SetKey(int k) { m_key = k; } void SetKey(int k) { m_key = k; }
void SetModifiers(int m) { m_modifiers = m; } void SetModifiers(int m) { m_modifiers = m; }
void SetModificationType(int t) { m_modificationType = t; } void SetModificationType(int t) { m_modificationType = t; }
void SetText(const char* t) { m_text = t; } void SetText(const wxString& t) { m_text = t; }
void SetLength(int len) { m_length = len; } void SetLength(int len) { m_length = len; }
void SetLinesAdded(int num) { m_linesAdded = num; } void SetLinesAdded(int num) { m_linesAdded = num; }
void SetLine(int val) { m_line = val; } void SetLine(int val) { m_line = val; }

View File

@@ -36,7 +36,11 @@
#define wxSTC_START 2000 #define wxSTC_START 2000
#define wxSTC_OPTIONAL_START 3000 #define wxSTC_OPTIONAL_START 3000
#define wxSTC_LEXER_START 4000 #define wxSTC_LEXER_START 4000
// Redoes the next action on the undo history
#define wxSTC_CMD_REDO 2011 #define wxSTC_CMD_REDO 2011
// Select all the text in the document.
#define wxSTC_CMD_SELECTALL 2013 #define wxSTC_CMD_SELECTALL 2013
#define wxSTC_WS_INVISIBLE 0 #define wxSTC_WS_INVISIBLE 0
#define wxSTC_WS_VISIBLEALWAYS 1 #define wxSTC_WS_VISIBLEALWAYS 1
@@ -154,9 +158,17 @@
#define wxSTC_FIND_MATCHCASE 4 #define wxSTC_FIND_MATCHCASE 4
#define wxSTC_FIND_WORDSTART 0x00100000 #define wxSTC_FIND_WORDSTART 0x00100000
#define wxSTC_FIND_REGEXP 0x00200000 #define wxSTC_FIND_REGEXP 0x00200000
// Undo one action in the undo history.
#define wxSTC_CMD_UNDO 2176 #define wxSTC_CMD_UNDO 2176
// Cut the selection to the clipboard.
#define wxSTC_CMD_CUT 2177 #define wxSTC_CMD_CUT 2177
// Copy the selection to the clipboard.
#define wxSTC_CMD_COPY 2178 #define wxSTC_CMD_COPY 2178
// Paste the contents of the clipboard into the document replacing the selection.
#define wxSTC_CMD_PASTE 2179 #define wxSTC_CMD_PASTE 2179
#define wxSTC_FOLDLEVELBASE 0x400 #define wxSTC_FOLDLEVELBASE 0x400
#define wxSTC_FOLDLEVELWHITEFLAG 0x1000 #define wxSTC_FOLDLEVELWHITEFLAG 0x1000
@@ -169,50 +181,144 @@
#define wxSTC_CACHE_CARET 1 #define wxSTC_CACHE_CARET 1
#define wxSTC_CACHE_PAGE 2 #define wxSTC_CACHE_PAGE 2
#define wxSTC_CACHE_DOCUMENT 3 #define wxSTC_CACHE_DOCUMENT 3
// Move caret down one line.
#define wxSTC_CMD_LINEDOWN 2300 #define wxSTC_CMD_LINEDOWN 2300
// Move caret down one line extending selection to new caret position.
#define wxSTC_CMD_LINEDOWNEXTEND 2301 #define wxSTC_CMD_LINEDOWNEXTEND 2301
// Move caret up one line.
#define wxSTC_CMD_LINEUP 2302 #define wxSTC_CMD_LINEUP 2302
// Move caret up one line extending selection to new caret position.
#define wxSTC_CMD_LINEUPEXTEND 2303 #define wxSTC_CMD_LINEUPEXTEND 2303
// Move caret left one character.
#define wxSTC_CMD_CHARLEFT 2304 #define wxSTC_CMD_CHARLEFT 2304
// Move caret left one character extending selection to new caret position.
#define wxSTC_CMD_CHARLEFTEXTEND 2305 #define wxSTC_CMD_CHARLEFTEXTEND 2305
// Move caret right one character.
#define wxSTC_CMD_CHARRIGHT 2306 #define wxSTC_CMD_CHARRIGHT 2306
// Move caret right one character extending selection to new caret position.
#define wxSTC_CMD_CHARRIGHTEXTEND 2307 #define wxSTC_CMD_CHARRIGHTEXTEND 2307
// Move caret left one word.
#define wxSTC_CMD_WORDLEFT 2308 #define wxSTC_CMD_WORDLEFT 2308
// Move caret left one word extending selection to new caret position.
#define wxSTC_CMD_WORDLEFTEXTEND 2309 #define wxSTC_CMD_WORDLEFTEXTEND 2309
// Move caret right one word.
#define wxSTC_CMD_WORDRIGHT 2310 #define wxSTC_CMD_WORDRIGHT 2310
// Move caret right one word extending selection to new caret position.
#define wxSTC_CMD_WORDRIGHTEXTEND 2311 #define wxSTC_CMD_WORDRIGHTEXTEND 2311
// Move caret to first position on line.
#define wxSTC_CMD_HOME 2312 #define wxSTC_CMD_HOME 2312
// Move caret to first position on line extending selection to new caret position.
#define wxSTC_CMD_HOMEEXTEND 2313 #define wxSTC_CMD_HOMEEXTEND 2313
// Move caret to last position on line.
#define wxSTC_CMD_LINEEND 2314 #define wxSTC_CMD_LINEEND 2314
// Move caret to last position on line extending selection to new caret position.
#define wxSTC_CMD_LINEENDEXTEND 2315 #define wxSTC_CMD_LINEENDEXTEND 2315
// Move caret to first position in document.
#define wxSTC_CMD_DOCUMENTSTART 2316 #define wxSTC_CMD_DOCUMENTSTART 2316
// Move caret to first position in document extending selection to new caret position.
#define wxSTC_CMD_DOCUMENTSTARTEXTEND 2317 #define wxSTC_CMD_DOCUMENTSTARTEXTEND 2317
// Move caret to last position in document.
#define wxSTC_CMD_DOCUMENTEND 2318 #define wxSTC_CMD_DOCUMENTEND 2318
// Move caret to last position in document extending selection to new caret position.
#define wxSTC_CMD_DOCUMENTENDEXTEND 2319 #define wxSTC_CMD_DOCUMENTENDEXTEND 2319
// Move caret one page up.
#define wxSTC_CMD_PAGEUP 2320 #define wxSTC_CMD_PAGEUP 2320
// Move caret one page up extending selection to new caret position.
#define wxSTC_CMD_PAGEUPEXTEND 2321 #define wxSTC_CMD_PAGEUPEXTEND 2321
// Move caret one page down.
#define wxSTC_CMD_PAGEDOWN 2322 #define wxSTC_CMD_PAGEDOWN 2322
// Move caret one page down extending selection to new caret position.
#define wxSTC_CMD_PAGEDOWNEXTEND 2323 #define wxSTC_CMD_PAGEDOWNEXTEND 2323
// Switch from insert to overtype mode or the reverse.
#define wxSTC_CMD_EDITTOGGLEOVERTYPE 2324 #define wxSTC_CMD_EDITTOGGLEOVERTYPE 2324
// Cancel any modes such as call tip or auto-completion list display.
#define wxSTC_CMD_CANCEL 2325 #define wxSTC_CMD_CANCEL 2325
// Delete the selection or if no selection, the character before the caret.
#define wxSTC_CMD_DELETEBACK 2326 #define wxSTC_CMD_DELETEBACK 2326
// If selection is empty or all on one line replace the selection with a tab
// character.
// If more than one line selected, indent the lines.
#define wxSTC_CMD_TAB 2327 #define wxSTC_CMD_TAB 2327
// Dedent the selected lines.
#define wxSTC_CMD_BACKTAB 2328 #define wxSTC_CMD_BACKTAB 2328
// Insert a new line, may use a CRLF, CR or LF depending on EOL mode.
#define wxSTC_CMD_NEWLINE 2329 #define wxSTC_CMD_NEWLINE 2329
// Insert a Form Feed character.
#define wxSTC_CMD_FORMFEED 2330 #define wxSTC_CMD_FORMFEED 2330
// Move caret to before first visible character on line.
// If already there move to first character on line.
#define wxSTC_CMD_VCHOME 2331 #define wxSTC_CMD_VCHOME 2331
// Like VCHome but extending selection to new caret position.
#define wxSTC_CMD_VCHOMEEXTEND 2332 #define wxSTC_CMD_VCHOMEEXTEND 2332
// Magnify the displayed text by increasing the sizes by 1 point.
#define wxSTC_CMD_ZOOMIN 2333 #define wxSTC_CMD_ZOOMIN 2333
// Make the displayed text smaller by decreasing the sizes by 1 point.
#define wxSTC_CMD_ZOOMOUT 2334 #define wxSTC_CMD_ZOOMOUT 2334
// Delete the word to the left of the caret.
#define wxSTC_CMD_DELWORDLEFT 2335 #define wxSTC_CMD_DELWORDLEFT 2335
// Delete the word to the right of the caret.
#define wxSTC_CMD_DELWORDRIGHT 2336 #define wxSTC_CMD_DELWORDRIGHT 2336
// Cut the line containing the caret.
#define wxSTC_CMD_LINECUT 2337 #define wxSTC_CMD_LINECUT 2337
// Delete the line containing the caret.
#define wxSTC_CMD_LINEDELETE 2338 #define wxSTC_CMD_LINEDELETE 2338
// Switch the current line with the previous.
#define wxSTC_CMD_LINETRANSPOSE 2339 #define wxSTC_CMD_LINETRANSPOSE 2339
// Transform the selection to lower case.
#define wxSTC_CMD_LOWERCASE 2340 #define wxSTC_CMD_LOWERCASE 2340
// Transform the selection to upper case.
#define wxSTC_CMD_UPPERCASE 2341 #define wxSTC_CMD_UPPERCASE 2341
// Scroll the document down, keeping the caret visible.
#define wxSTC_CMD_LINESCROLLDOWN 2342 #define wxSTC_CMD_LINESCROLLDOWN 2342
// Scroll the document up, keeping the caret visible.
#define wxSTC_CMD_LINESCROLLUP 2343 #define wxSTC_CMD_LINESCROLLUP 2343
// Delete the selection or if no selection, the character before the caret.
// Will not delete the chraacter before at the start of a line.
#define wxSTC_CMD_DELETEBACKNOTLINE 2344 #define wxSTC_CMD_DELETEBACKNOTLINE 2344
#define wxSTC_EDGE_NONE 0 #define wxSTC_EDGE_NONE 0
#define wxSTC_EDGE_LINE 1 #define wxSTC_EDGE_LINE 1
@@ -736,7 +842,7 @@ public:
void AddText(const wxString& text); void AddText(const wxString& text);
// Add array of cells to document // Add array of cells to document
void AddStyledText(const wxString& text); void AddStyledText(const wxMemoryBuffer& data);
// Insert string at a position // Insert string at a position
void InsertText(int pos, const wxString& text); void InsertText(int pos, const wxString& text);
@@ -777,7 +883,7 @@ public:
void SetSavePoint(); void SetSavePoint();
// Retrieve a buffer of cells. // Retrieve a buffer of cells.
wxString GetStyledText(int startPos, int endPos); wxMemoryBuffer GetStyledText(int startPos, int endPos);
// Are there any redoable actions in the undo history. // Are there any redoable actions in the undo history.
bool CanRedo(); bool CanRedo();
@@ -859,7 +965,6 @@ public:
int GetTabWidth(); int GetTabWidth();
// Set the code page used to interpret the bytes of the document as characters. // Set the code page used to interpret the bytes of the document as characters.
// The SC_CP_UTF8 value can be used to enter Unicode mode.
void SetCodePage(int codePage); void SetCodePage(int codePage);
// Set the symbol used for a particular marker number, // Set the symbol used for a particular marker number,
@@ -949,6 +1054,9 @@ public:
// Set a style to be mixed case, or to force upper or lower case. // Set a style to be mixed case, or to force upper or lower case.
void StyleSetCase(int style, int caseForce); void StyleSetCase(int style, int caseForce);
// Set the character set of the font in a style.
void StyleSetCharacterSet(int style, int characterSet);
// Set the foreground colour of the selection and whether to use this setting. // Set the foreground colour of the selection and whether to use this setting.
void SetSelForeground(bool useSetting, const wxColour& fore); void SetSelForeground(bool useSetting, const wxColour& fore);
@@ -1440,10 +1548,6 @@ public:
// Retrieve the degree of caching of layout information // Retrieve the degree of caching of layout information
int GetLayoutCache(); int GetLayoutCache();
// Delete the selection or if no selection, the character before the caret.
// Will not delete the chraacter before at the start of a line.
void DeleteBackNotLine();
// Move the caret inside current view if it's not there already // Move the caret inside current view if it's not there already
void MoveCaretInsideView(); void MoveCaretInsideView();
@@ -1756,7 +1860,7 @@ public:
void SetKey(int k) { m_key = k; } void SetKey(int k) { m_key = k; }
void SetModifiers(int m) { m_modifiers = m; } void SetModifiers(int m) { m_modifiers = m; }
void SetModificationType(int t) { m_modificationType = t; } void SetModificationType(int t) { m_modificationType = t; }
void SetText(const char* t) { m_text = t; } void SetText(const wxString& t) { m_text = t; }
void SetLength(int len) { m_length = len; } void SetLength(int len) { m_length = len; }
void SetLinesAdded(int num) { m_linesAdded = num; } void SetLinesAdded(int num) { m_linesAdded = num; }
void SetLine(int val) { m_line = val; } void SetLine(int val) { m_line = val; }

View File

@@ -7,6 +7,8 @@
#include <ctype.h> #include <ctype.h>
#include <wx/wx.h> #include <wx/wx.h>
#include <wx/encconv.h>
#include "Platform.h" #include "Platform.h"
#include "PlatWX.h" #include "PlatWX.h"
@@ -176,14 +178,16 @@ void Font::Create(const char *faceName, int characterSet, int size, bool bold, b
break; break;
} }
// TODO: Use wxFontMapper and wxEncodingConverter if encoding not available. wxFontEncodingArray ea = wxEncodingConverter::GetPlatformEquivalents(encoding);
if (ea.GetCount())
encoding = ea[0];
id = new wxFont(size, id = new wxFont(size,
wxDEFAULT, wxDEFAULT,
italic ? wxITALIC : wxNORMAL, italic ? wxITALIC : wxNORMAL,
bold ? wxBOLD : wxNORMAL, bold ? wxBOLD : wxNORMAL,
false, false,
faceName, wxString(faceName, wxConvUTF8),
encoding); encoding);
} }
@@ -320,8 +324,6 @@ int SurfaceImpl::LogPixelsY() {
int SurfaceImpl::DeviceHeightFont(int points) { int SurfaceImpl::DeviceHeightFont(int points) {
return points; return points;
// int logPix = LogPixelsY();
// return (points * logPix + logPix / 2) / 72;
} }
void SurfaceImpl::MoveTo(int x_, int y_) { void SurfaceImpl::MoveTo(int x_, int y_) {
@@ -391,11 +393,8 @@ void SurfaceImpl::DrawTextNoClip(PRectangle rc, Font &font, int ybase,
hdc->SetTextBackground(wxColourFromCA(back)); hdc->SetTextBackground(wxColourFromCA(back));
FillRectangle(rc, back); FillRectangle(rc, back);
#if wxUSE_UNICODE // will convert from UTF-8 in unicode mode
#error fix this... Convert s from UTF-8. wxString str(s, wxConvUTF8, len);
#else
wxString str = wxString(s, len);
#endif
// ybase is where the baseline should be, but wxWin uses the upper left // ybase is where the baseline should be, but wxWin uses the upper left
// corner, so I need to calculate the real position for the text... // corner, so I need to calculate the real position for the text...
@@ -411,11 +410,8 @@ void SurfaceImpl::DrawTextClipped(PRectangle rc, Font &font, int ybase,
FillRectangle(rc, back); FillRectangle(rc, back);
hdc->SetClippingRegion(wxRectFromPRectangle(rc)); hdc->SetClippingRegion(wxRectFromPRectangle(rc));
#if wxUSE_UNICODE // will convert from UTF-8 in unicode mode
#error fix this... Convert s from UTF-8. wxString str(s, wxConvUTF8, len);
#else
wxString str = wxString(s, len);
#endif
// see comments above // see comments above
hdc->DrawText(str, rc.left, ybase - font.ascent); hdc->DrawText(str, rc.left, ybase - font.ascent);
@@ -427,43 +423,67 @@ int SurfaceImpl::WidthText(Font &font, const char *s, int len) {
int w; int w;
int h; int h;
#if wxUSE_UNICODE // will convert from UTF-8 in unicode mode
#error fix this... Convert s from UTF-8. wxString str(s, wxConvUTF8, len);
#else
wxString str = wxString(s, len);
#endif
hdc->GetTextExtent(str, &w, &h); hdc->GetTextExtent(str, &w, &h);
return w; return w;
} }
void SurfaceImpl::MeasureWidths(Font &font, const char *s, int len, int *positions) {
#if wxUSE_UNICODE
#error fix this... Convert s from UTF-8.
#else
wxString str = wxString(s, len);
#endif
void SurfaceImpl::MeasureWidths(Font &font, const char *s, int len, int *positions) {
// will convert from UTF-8 in unicode mode
wxString str(s, wxConvUTF8, len);
SetFont(font); SetFont(font);
// Calculate the position of each character based on the widths of
// the previous characters
int* tpos = new int[len];
int totalWidth = 0; int totalWidth = 0;
for (size_t i=0; i<(size_t)len; i++) { size_t i;
int w; for (i=0; i<str.Length(); i++) {
int h; int w, h;
hdc->GetTextExtent(str[i], &w, &h); hdc->GetTextExtent(str[i], &w, &h);
totalWidth += w; totalWidth += w;
positions[i] = totalWidth; tpos[i] = totalWidth;
} }
#if wxUSE_UNICODE
// Map the widths for UCS-2 characters back to the UTF-8 input string
i = 0;
size_t ui = 0;
while (i < len) {
unsigned char uch = (unsigned char)s[i];
positions[i++] = tpos[ui];
if (uch >= 0x80) {
if (uch < (0x80 + 0x40 + 0x20)) {
positions[i++] = tpos[ui];
} else {
positions[i++] = tpos[ui];
positions[i++] = tpos[ui];
}
}
ui++;
}
#else
// If not unicode then just use the widths we have
memcpy(positions, tpos, len * sizeof(*tpos));
#endif
delete [] tpos;
} }
int SurfaceImpl::WidthChar(Font &font, char ch) { int SurfaceImpl::WidthChar(Font &font, char ch) {
SetFont(font); SetFont(font);
int w; int w;
int h; int h;
#if wxUSE_UNICODE char s[2] = { ch, 0 };
#error fix this... Convert s from UTF-8.
#else // will convert from UTF-8 in unicode mode
hdc->GetTextExtent(ch, &w, &h); wxString str(s, wxConvUTF8, 1);
#endif hdc->GetTextExtent(str, &w, &h);
return w; return w;
} }
@@ -517,8 +537,14 @@ void SurfaceImpl::FlushCachedState() {
} }
void SurfaceImpl::SetUnicodeMode(bool unicodeMode_) { void SurfaceImpl::SetUnicodeMode(bool unicodeMode_) {
// TODO: Make this jive with wxUSE_UNICODE
unicodeMode=unicodeMode_; unicodeMode=unicodeMode_;
#if wxUSE_UNICODE
wxASSERT_MSG(unicodeMode == wxUSE_UNICODE,
wxT("Only unicode may be used when wxUSE_UNICODE is on."));
#else
wxASSERT_MSG(unicodeMode == wxUSE_UNICODE,
wxT("Only non-unicode may be used when wxUSE_UNICODE is off."));
#endif
} }
Surface *Surface::Allocate() { Surface *Surface::Allocate() {
@@ -615,11 +641,9 @@ void Window::SetCursor(Cursor curs) {
void Window::SetTitle(const char *s) { void Window::SetTitle(const char *s) {
#if wxUSE_UNICODE // will convert from UTF-8 in unicode mode
#error Fix this... wxString str(s, wxConvUTF8);
#else GETWIN(id)->SetTitle(str);
GETWIN(id)->SetTitle(s);
#endif
} }
@@ -777,12 +801,9 @@ int ListBox::Find(const char *prefix) {
} }
void ListBox::GetValue(int n, char *value, int len) { void ListBox::GetValue(int n, char *value, int len) {
#if wxUSE_UNICODE
#error fix this...
wxString text = GETLB(id)->GetString(n); wxString text = GETLB(id)->GetString(n);
strncpy(value, text.c_str(), len); strncpy(value, text.mb_str(wxConvUTF8), len);
value[len-1] = '\0'; value[len-1] = '\0';
#endif
} }
void ListBox::Sort() { void ListBox::Sort() {
@@ -824,7 +845,9 @@ ColourDesired Platform::ChromeHighlight() {
} }
const char *Platform::DefaultFont() { const char *Platform::DefaultFont() {
return wxNORMAL_FONT->GetFaceName(); static char buf[128];
strcpy(buf, wxNORMAL_FONT->GetFaceName().mbc_str());
return buf;
} }
int Platform::DefaultFontSize() { int Platform::DefaultFontSize() {
@@ -836,7 +859,7 @@ unsigned int Platform::DoubleClickTime() {
} }
void Platform::DebugDisplay(const char *s) { void Platform::DebugDisplay(const char *s) {
wxLogDebug(s); wxLogDebug(wxString(s, *wxConvCurrent));
} }
bool Platform::IsKeyDown(int key) { bool Platform::IsKeyDown(int key) {
@@ -895,7 +918,8 @@ void Platform::Assert(const char *c, const char *file, int line) {
char buffer[2000]; char buffer[2000];
sprintf(buffer, "Assertion [%s] failed at %s %d", c, file, line); sprintf(buffer, "Assertion [%s] failed at %s %d", c, file, line);
if (assertionPopUps) { if (assertionPopUps) {
int idButton = wxMessageBox(buffer, "Assertion failure", int idButton = wxMessageBox(wxString(buffer, *wxConvCurrent),
wxT("Assertion failure"),
wxICON_HAND | wxOK); wxICON_HAND | wxOK);
// if (idButton == IDRETRY) { // if (idButton == IDRETRY) {
// ::DebugBreak(); // ::DebugBreak();

View File

@@ -148,7 +148,7 @@ void ScintillaWX::Finalise() {
void ScintillaWX::StartDrag() { void ScintillaWX::StartDrag() {
#if wxUSE_DRAG_AND_DROP #if wxUSE_DRAG_AND_DROP
wxString dragText(drag.s, drag.len); wxString dragText(drag.s, wxConvUTF8, drag.len);
// Send an event to allow the drag text to be changed // Send an event to allow the drag text to be changed
wxStyledTextEvent evt(wxEVT_STC_START_DRAG, stc->GetId()); wxStyledTextEvent evt(wxEVT_STC_START_DRAG, stc->GetId());
@@ -296,7 +296,8 @@ void ScintillaWX::Copy() {
SelectionText st; SelectionText st;
CopySelectionRange(&st); CopySelectionRange(&st);
wxTheClipboard->Open(); wxTheClipboard->Open();
wxTheClipboard->SetData(new wxTextDataObject(wxString(st.s, st.len))); wxString text(st.s, wxConvUTF8, st.len);
wxTheClipboard->SetData(new wxTextDataObject(text));
wxTheClipboard->Close(); wxTheClipboard->Close();
} }
} }
@@ -313,9 +314,9 @@ void ScintillaWX::Paste() {
gotData = wxTheClipboard->GetData(data); gotData = wxTheClipboard->GetData(data);
wxTheClipboard->Close(); wxTheClipboard->Close();
if (gotData) { if (gotData) {
wxString str = data.GetText(); wxWX2MBbuf buf = (wxWX2MBbuf)data.GetText().mb_str(wxConvUTF8);
int len = str.Length(); int len = strlen(buf);
pdoc->InsertString(currentPos, str.c_str(), len); pdoc->InsertString(currentPos, buf, len);
SetEmptySelection(currentPos + len); SetEmptySelection(currentPos + len);
} }
@@ -329,7 +330,7 @@ bool ScintillaWX::CanPaste() {
bool canPaste; bool canPaste;
wxTheClipboard->Open(); wxTheClipboard->Open();
canPaste = wxTheClipboard->IsSupported( wxDF_TEXT ); canPaste = wxTheClipboard->IsSupported(wxUSE_UNICODE ? wxDF_UNICODETEXT : wxDF_TEXT);
wxTheClipboard->Close(); wxTheClipboard->Close();
return canPaste; return canPaste;
@@ -345,7 +346,7 @@ void ScintillaWX::AddToPopUp(const char *label, int cmd, bool enabled) {
if (!label[0]) if (!label[0])
((wxMenu*)popup.GetID())->AppendSeparator(); ((wxMenu*)popup.GetID())->AppendSeparator();
else else
((wxMenu*)popup.GetID())->Append(cmd, label); ((wxMenu*)popup.GetID())->Append(cmd, wxString(label, *wxConvCurrent));
if (!enabled) if (!enabled)
((wxMenu*)popup.GetID())->Enable(cmd, enabled); ((wxMenu*)popup.GetID())->Enable(cmd, enabled);
@@ -497,8 +498,8 @@ void ScintillaWX::DoButtonMove(Point pt) {
} }
void ScintillaWX::DoAddChar(char ch) { void ScintillaWX::DoAddChar(int key) {
AddChar(ch); AddChar(key);
} }
int ScintillaWX::DoKeyDown(int key, bool shift, bool ctrl, bool alt, bool* consumed) { int ScintillaWX::DoKeyDown(int key, bool shift, bool ctrl, bool alt, bool* consumed) {
@@ -579,7 +580,7 @@ bool ScintillaWX::DoDropText(long x, long y, const wxString& data) {
dragResult = evt.GetDragResult(); dragResult = evt.GetDragResult();
if (dragResult == wxDragMove || dragResult == wxDragCopy) { if (dragResult == wxDragMove || dragResult == wxDragCopy) {
DropAt(evt.GetPosition(), DropAt(evt.GetPosition(),
evt.GetDragText(), evt.GetDragText().mb_str(wxConvUTF8),
dragResult == wxDragMove, dragResult == wxDragMove,
FALSE); // TODO: rectangular? FALSE); // TODO: rectangular?
return TRUE; return TRUE;

View File

@@ -126,7 +126,7 @@ public:
void DoButtonUp(Point pt, unsigned int curTime, bool ctrl); void DoButtonUp(Point pt, unsigned int curTime, bool ctrl);
void DoButtonMove(Point pt); void DoButtonMove(Point pt);
void DoMouseWheel(int rotation, int delta, int linesPerAction, int ctrlDown); void DoMouseWheel(int rotation, int delta, int linesPerAction, int ctrlDown);
void DoAddChar(char ch); void DoAddChar(int key);
int DoKeyDown(int key, bool shift, bool ctrl, bool alt, bool* consumed); int DoKeyDown(int key, bool shift, bool ctrl, bool alt, bool* consumed);
void DoTick() { Tick(); } void DoTick() { Tick(); }

View File

@@ -68,38 +68,39 @@ methodOverrideMap = {
'void %s(const wxString& text);', 'void %s(const wxString& text);',
'''void %s(const wxString& text) { '''void %s(const wxString& text) {
SendMsg(%s, text.Len(), (long)text.c_str());''', wxWX2MBbuf buf = (wxWX2MBbuf)text.mb_str(wxConvUTF8);
SendMsg(%s, strlen(buf), (long)(const char*)buf);''',
0), 0),
'AddStyledText' : (0, 'AddStyledText' : (0,
'void %s(const wxString& text);', 'void %s(const wxMemoryBuffer& data);',
'''void %s(const wxString& text) { '''void %s(const wxMemoryBuffer& data) {
SendMsg(%s, text.Len(), (long)text.c_str());''', SendMsg(%s, data.GetDataLen(), (long)data.GetData());''',
0), 0),
'GetViewWS' : ( 'GetViewWhiteSpace', 0, 0, 0), 'GetViewWS' : ( 'GetViewWhiteSpace', 0, 0, 0),
'SetViewWS' : ( 'SetViewWhiteSpace', 0, 0, 0), 'SetViewWS' : ( 'SetViewWhiteSpace', 0, 0, 0),
'GetStyledText' : (0, 'GetStyledText' : (0,
'wxString %s(int startPos, int endPos);', 'wxMemoryBuffer %s(int startPos, int endPos);',
'''wxString %s(int startPos, int endPos) { '''wxMemoryBuffer %s(int startPos, int endPos) {
wxString text; wxMemoryBuffer buf;
if (endPos < startPos) { if (endPos < startPos) {
int temp = startPos; int temp = startPos;
startPos = endPos; startPos = endPos;
endPos = temp; endPos = temp;
} }
int len = endPos - startPos; int len = endPos - startPos;
if (!len) return ""; if (!len) return buf;
TextRange tr; TextRange tr;
tr.lpstrText = text.GetWriteBuf(len*2); tr.lpstrText = (char*)buf.GetWriteBuf(len*2+1);
tr.chrg.cpMin = startPos; tr.chrg.cpMin = startPos;
tr.chrg.cpMax = endPos; tr.chrg.cpMax = endPos;
SendMsg(%s, 0, (long)&tr); len = SendMsg(%s, 0, (long)&tr);
text.UngetWriteBuf(len*2); buf.UngetWriteBuf(len);
return text;''', return buf;''',
('Retrieve a buffer of cells.',)), ('Retrieve a buffer of cells.',)),
@@ -116,20 +117,20 @@ methodOverrideMap = {
'#ifdef SWIG\n wxString %s(int* OUTPUT);\n#else\n wxString GetCurLine(int* linePos=NULL);\n#endif', '#ifdef SWIG\n wxString %s(int* OUTPUT);\n#else\n wxString GetCurLine(int* linePos=NULL);\n#endif',
'''wxString %s(int* linePos) { '''wxString %s(int* linePos) {
wxString text;
int len = LineLength(GetCurrentLine()); int len = LineLength(GetCurrentLine());
if (!len) { if (!len) {
if (linePos) *linePos = 0; if (linePos) *linePos = 0;
return ""; return wxEmptyString;
} }
// Need an extra byte because SCI_GETCURLINE writes a null to the string
char* buf = text.GetWriteBuf(len+1); wxMemoryBuffer mbuf(len+1);
char* buf = (char*)mbuf.GetWriteBuf(len+1);
int pos = SendMsg(%s, len+1, (long)buf); int pos = SendMsg(%s, len+1, (long)buf);
text.UngetWriteBuf(len); mbuf.UngetWriteBuf(len);
mbuf.AppendByte(0);
if (linePos) *linePos = pos; if (linePos) *linePos = pos;
return wxString(buf, wxConvUTF8);''',
return text;''',
0), 0),
@@ -172,9 +173,6 @@ methodOverrideMap = {
'SetCaretFore' : ('SetCaretForeground', 0, 0, 0), 'SetCaretFore' : ('SetCaretForeground', 0, 0, 0),
'StyleSetFont' : ('StyleSetFaceName', 0, 0, 0), 'StyleSetFont' : ('StyleSetFaceName', 0, 0, 0),
# need to fix this to map between wx and scintilla encoding flags, leave it out for now...
'StyleSetCharacterSet' : (None, 0, 0, 0),
'AssignCmdKey' : ('CmdKeyAssign', 'AssignCmdKey' : ('CmdKeyAssign',
'void %s(int key, int modifiers, int cmd);', 'void %s(int key, int modifiers, int cmd);',
@@ -251,7 +249,7 @@ methodOverrideMap = {
flags |= wholeWord ? SCFIND_WHOLEWORD : 0; flags |= wholeWord ? SCFIND_WHOLEWORD : 0;
ft.chrg.cpMin = minPos; ft.chrg.cpMin = minPos;
ft.chrg.cpMax = maxPos; ft.chrg.cpMax = maxPos;
ft.lpstrText = (char*)text.c_str(); ft.lpstrText = (char*)(const char*)text.mb_str(wxConvUTF8);
return SendMsg(%s, flags, (long)&ft);''', return SendMsg(%s, flags, (long)&ft);''',
0), 0),
@@ -299,15 +297,15 @@ methodOverrideMap = {
'wxString %s(int line);', 'wxString %s(int line);',
'''wxString %s(int line) { '''wxString %s(int line) {
wxString text;
int len = LineLength(line); int len = LineLength(line);
if (!len) return ""; if (!len) return wxEmptyString;
char* buf = text.GetWriteBuf(len);
int pos = SendMsg(%s, line, (long)buf); wxMemoryBuffer mbuf(len+1);
text.UngetWriteBuf(len); char* buf = (char*)mbuf.GetWriteBuf(len+1);
SendMsg(%s, line, (long)buf);
return text;''', mbuf.UngetWriteBuf(len);
mbuf.AppendByte(0);
return wxString(buf, wxConvUTF8);''',
('Retrieve the contents of a line.',)), ('Retrieve the contents of a line.',)),
@@ -316,18 +314,19 @@ methodOverrideMap = {
'wxString %s();', 'wxString %s();',
'''wxString %s() { '''wxString %s() {
wxString text;
int start; int start;
int end; int end;
GetSelection(&start, &end); GetSelection(&start, &end);
int len = end - start; int len = end - start;
if (!len) return ""; if (!len) return wxEmptyString;
char* buff = text.GetWriteBuf(len);
SendMsg(%s, 0, (long)buff); wxMemoryBuffer mbuf(len+1);
text.UngetWriteBuf(len); char* buf = (char*)mbuf.GetWriteBuf(len+1);
return text;''', SendMsg(%s, 0, (long)buf);
mbuf.UngetWriteBuf(len);
mbuf.AppendByte(0);
return wxString(buf, wxConvUTF8);''',
('Retrieve the selected text.',)), ('Retrieve the selected text.',)),
@@ -335,23 +334,23 @@ methodOverrideMap = {
'wxString %s(int startPos, int endPos);', 'wxString %s(int startPos, int endPos);',
'''wxString %s(int startPos, int endPos) { '''wxString %s(int startPos, int endPos) {
wxString text;
if (endPos < startPos) { if (endPos < startPos) {
int temp = startPos; int temp = startPos;
startPos = endPos; startPos = endPos;
endPos = temp; endPos = temp;
} }
int len = endPos - startPos; int len = endPos - startPos;
if (!len) return ""; if (!len) return wxEmptyString;
char* buff = text.GetWriteBuf(len); wxMemoryBuffer mbuf(len+1);
char* buf = (char*)mbuf.GetWriteBuf(len);
TextRange tr; TextRange tr;
tr.lpstrText = buff; tr.lpstrText = buf;
tr.chrg.cpMin = startPos; tr.chrg.cpMin = startPos;
tr.chrg.cpMax = endPos; tr.chrg.cpMax = endPos;
SendMsg(%s, 0, (long)&tr); SendMsg(%s, 0, (long)&tr);
text.UngetWriteBuf(len); mbuf.UngetWriteBuf(len);
return text;''', mbuf.AppendByte(0);
return wxString(buf, wxConvUTF8);''',
('Retrieve a range of text.',)), ('Retrieve a range of text.',)),
@@ -366,13 +365,13 @@ methodOverrideMap = {
'wxString %s();', 'wxString %s();',
'''wxString %s() { '''wxString %s() {
wxString text; int len = GetTextLength();
int len = GetTextLength(); wxMemoryBuffer mbuf(len+1); // leave room for the null...
char* buff = text.GetWriteBuf(len+1); // leave room for the null... char* buf = (char*)mbuf.GetWriteBuf(len+1);
SendMsg(%s, len+1, (long)buf);
SendMsg(%s, len+1, (long)buff); mbuf.UngetWriteBuf(len);
text.UngetWriteBuf(len); mbuf.AppendByte(0);
return text;''', return wxString(buf, wxConvUTF8);''',
('Retrieve all the text in the document.', )), ('Retrieve all the text in the document.', )),
@@ -389,9 +388,8 @@ methodOverrideMap = {
''' '''
int %s(const wxString& text) { int %s(const wxString& text) {
return SendMsg(%s, text.Len(), (long)text.c_str()); wxWX2MBbuf buf = (wxWX2MBbuf)text.mb_str(wxConvUTF8);
''', return SendMsg(%s, strlen(buf), (long)(const char*)buf);''',
0), 0),
'ReplaceTargetRE' : (0, 'ReplaceTargetRE' : (0,
@@ -399,9 +397,8 @@ methodOverrideMap = {
''' '''
int %s(const wxString& text) { int %s(const wxString& text) {
return SendMsg(%s, text.Len(), (long)text.c_str()); wxWX2MBbuf buf = (wxWX2MBbuf)text.mb_str(wxConvUTF8);
''', return SendMsg(%s, strlen(buf), (long)(const char*)buf);''',
0), 0),
'SearchInTarget' : (0, 'SearchInTarget' : (0,
@@ -409,9 +406,8 @@ methodOverrideMap = {
''' '''
int %s(const wxString& text) { int %s(const wxString& text) {
return SendMsg(%s, text.Len(), (long)text.c_str()); wxWX2MBbuf buf = (wxWX2MBbuf)text.mb_str(wxConvUTF8);
''', return SendMsg(%s, strlen(buf), (long)(const char*)buf);''',
0), 0),
@@ -462,6 +458,7 @@ methodOverrideMap = {
'UpperCase' : (None, 0, 0, 0), 'UpperCase' : (None, 0, 0, 0),
'LineScrollDown' : (None, 0, 0, 0), 'LineScrollDown' : (None, 0, 0, 0),
'LineScrollUp' : (None, 0, 0, 0), 'LineScrollUp' : (None, 0, 0, 0),
'DeleteBackNotLine' : (None, 0, 0, 0),
'GetDocPointer' : (0, 'GetDocPointer' : (0,
@@ -493,6 +490,19 @@ methodOverrideMap = {
'''void %s(void* docPointer) { '''void %s(void* docPointer) {
SendMsg(%s, (long)docPointer);''', SendMsg(%s, (long)docPointer);''',
0), 0),
'SetCodePage' : (0,
0,
'''void %s(int codePage) {
#if wxUSE_UNICODE
wxASSERT_MSG(codePage == wxSTC_CP_UTF8,
wxT("Only wxSTC_CP_UTF8 may be used when wxUSE_UNICODE is on."));
#else
wxASSERT_MSG(codePage != wxSTC_CP_UTF8,
wxT("wxSTC_CP_UTF8 may not be used when wxUSE_UNICODE is off."));
#endif
SendMsg(%s, codePage);''',
("Set the code page used to interpret the bytes of the document as characters.",) ),
'GrabFocus' : (None, 0, 0, 0), 'GrabFocus' : (None, 0, 0, 0),
'SetFocus' : ('SetSTCFocus', 0, 0, 0), 'SetFocus' : ('SetSTCFocus', 0, 0, 0),
@@ -652,7 +662,7 @@ def makeArgString(param):
typ, name = param typ, name = param
if typ == 'string': if typ == 'string':
return '(long)%s.c_str()' % name return '(long)(const char*)%s.mb_str(wxConvUTF8)' % name
if typ == 'colour': if typ == 'colour':
return 'wxColourAsLong(%s)' % name return 'wxColourAsLong(%s)' % name
@@ -721,7 +731,7 @@ def parseFun(line, methods, docs, values):
num = string.atoi(number) num = string.atoi(number)
for v in cmdValues: for v in cmdValues:
if (type(v) == type(()) and v[0] <= num < v[1]) or v == num: if (type(v) == type(()) and v[0] <= num < v[1]) or v == num:
parseVal('CMD_%s=%s' % (string.upper(name), number), values, ()) parseVal('CMD_%s=%s' % (string.upper(name), number), values, docs)
#if retType == 'void' and not param1 and not param2: #if retType == 'void' and not param1 and not param2:

View File

@@ -25,7 +25,7 @@
//---------------------------------------------------------------------- //----------------------------------------------------------------------
const wxChar* wxSTCNameStr = "stcwindow"; const wxChar* wxSTCNameStr = wxT("stcwindow");
DEFINE_EVENT_TYPE( wxEVT_STC_CHANGE ) DEFINE_EVENT_TYPE( wxEVT_STC_CHANGE )
DEFINE_EVENT_TYPE( wxEVT_STC_STYLENEEDED ) DEFINE_EVENT_TYPE( wxEVT_STC_STYLENEEDED )
@@ -105,6 +105,10 @@ wxStyledTextCtrl::wxStyledTextCtrl(wxWindow *parent,
m_lastKeyDownConsumed = FALSE; m_lastKeyDownConsumed = FALSE;
m_vScrollBar = NULL; m_vScrollBar = NULL;
m_hScrollBar = NULL; m_hScrollBar = NULL;
#if wxUSE_UNICODE
// Put Scintilla into unicode (UTF-8) mode
SetCodePage(wxSTC_CP_UTF8);
#endif
} }
@@ -142,11 +146,12 @@ static wxColour wxColourFromLong(long c) {
static wxColour wxColourFromSpec(const wxString& spec) { static wxColour wxColourFromSpec(const wxString& spec) {
// spec should be #RRGGBB // spec should be "#RRGGBB"
char* junk; long red, green, blue;
int red = strtol(spec.Mid(1,2), &junk, 16); red = green = blue = 0;
int green = strtol(spec.Mid(3,2), &junk, 16); spec.Mid(1,2).ToLong(&red, 16);
int blue = strtol(spec.Mid(5,2), &junk, 16); spec.Mid(3,2).ToLong(&green, 16);
spec.Mid(5,2).ToLong(&blue, 16);
return wxColour(red, green, blue); return wxColour(red, green, blue);
} }
@@ -159,17 +164,18 @@ static wxColour wxColourFromSpec(const wxString& spec) {
// Add text to the document // Add text to the document
void wxStyledTextCtrl::AddText(const wxString& text) { void wxStyledTextCtrl::AddText(const wxString& text) {
SendMsg(2001, text.Len(), (long)text.c_str()); wxWX2MBbuf buf = (wxWX2MBbuf)text.mb_str(wxConvUTF8);
SendMsg(2001, strlen(buf), (long)(const char*)buf);
} }
// Add array of cells to document // Add array of cells to document
void wxStyledTextCtrl::AddStyledText(const wxString& text) { void wxStyledTextCtrl::AddStyledText(const wxMemoryBuffer& data) {
SendMsg(2002, text.Len(), (long)text.c_str()); SendMsg(2002, data.GetDataLen(), (long)data.GetData());
} }
// Insert string at a position // Insert string at a position
void wxStyledTextCtrl::InsertText(int pos, const wxString& text) { void wxStyledTextCtrl::InsertText(int pos, const wxString& text) {
SendMsg(2003, pos, (long)text.c_str()); SendMsg(2003, pos, (long)(const char*)text.mb_str(wxConvUTF8));
} }
// Delete all text in the document // Delete all text in the document
@@ -230,22 +236,22 @@ void wxStyledTextCtrl::SetSavePoint() {
} }
// Retrieve a buffer of cells. // Retrieve a buffer of cells.
wxString wxStyledTextCtrl::GetStyledText(int startPos, int endPos) { wxMemoryBuffer wxStyledTextCtrl::GetStyledText(int startPos, int endPos) {
wxString text; wxMemoryBuffer buf;
if (endPos < startPos) { if (endPos < startPos) {
int temp = startPos; int temp = startPos;
startPos = endPos; startPos = endPos;
endPos = temp; endPos = temp;
} }
int len = endPos - startPos; int len = endPos - startPos;
if (!len) return ""; if (!len) return buf;
TextRange tr; TextRange tr;
tr.lpstrText = text.GetWriteBuf(len*2); tr.lpstrText = (char*)buf.GetWriteBuf(len*2+1);
tr.chrg.cpMin = startPos; tr.chrg.cpMin = startPos;
tr.chrg.cpMax = endPos; tr.chrg.cpMax = endPos;
SendMsg(2015, 0, (long)&tr); len = SendMsg(2015, 0, (long)&tr);
text.UngetWriteBuf(len*2); buf.UngetWriteBuf(len);
return text; return buf;
} }
// Are there any redoable actions in the undo history. // Are there any redoable actions in the undo history.
@@ -309,20 +315,20 @@ void wxStyledTextCtrl::SetAnchor(int posAnchor) {
// Retrieve the text of the line containing the caret. // Retrieve the text of the line containing the caret.
// Returns the index of the caret on the line. // Returns the index of the caret on the line.
wxString wxStyledTextCtrl::GetCurLine(int* linePos) { wxString wxStyledTextCtrl::GetCurLine(int* linePos) {
wxString text;
int len = LineLength(GetCurrentLine()); int len = LineLength(GetCurrentLine());
if (!len) { if (!len) {
if (linePos) *linePos = 0; if (linePos) *linePos = 0;
return ""; return wxEmptyString;
} }
// Need an extra byte because SCI_GETCURLINE writes a null to the string
char* buf = text.GetWriteBuf(len+1); wxMemoryBuffer mbuf(len+1);
char* buf = (char*)mbuf.GetWriteBuf(len+1);
int pos = SendMsg(2027, len+1, (long)buf); int pos = SendMsg(2027, len+1, (long)buf);
text.UngetWriteBuf(len); mbuf.UngetWriteBuf(len);
mbuf.AppendByte(0);
if (linePos) *linePos = pos; if (linePos) *linePos = pos;
return wxString(buf, wxConvUTF8);
return text;
} }
// Retrieve the position of the last correctly styled character. // Retrieve the position of the last correctly styled character.
@@ -381,9 +387,15 @@ int wxStyledTextCtrl::GetTabWidth() {
} }
// Set the code page used to interpret the bytes of the document as characters. // Set the code page used to interpret the bytes of the document as characters.
// The SC_CP_UTF8 value can be used to enter Unicode mode.
void wxStyledTextCtrl::SetCodePage(int codePage) { void wxStyledTextCtrl::SetCodePage(int codePage) {
SendMsg(2037, codePage, 0); #if wxUSE_UNICODE
wxASSERT_MSG(codePage == wxSTC_CP_UTF8,
wxT("Only wxSTC_CP_UTF8 may be used when wxUSE_UNICODE is on."));
#else
wxASSERT_MSG(codePage != wxSTC_CP_UTF8,
wxT("wxSTC_CP_UTF8 may not be used when wxUSE_UNICODE is off."));
#endif
SendMsg(2037, codePage);
} }
// Set the symbol used for a particular marker number, // Set the symbol used for a particular marker number,
@@ -511,7 +523,7 @@ void wxStyledTextCtrl::StyleSetSize(int style, int sizePoints) {
// Set the font of a style. // Set the font of a style.
void wxStyledTextCtrl::StyleSetFaceName(int style, const wxString& fontName) { void wxStyledTextCtrl::StyleSetFaceName(int style, const wxString& fontName) {
SendMsg(2056, style, (long)fontName.c_str()); SendMsg(2056, style, (long)(const char*)fontName.mb_str(wxConvUTF8));
} }
// Set a style to have its end of line filled or not. // Set a style to have its end of line filled or not.
@@ -534,6 +546,11 @@ void wxStyledTextCtrl::StyleSetCase(int style, int caseForce) {
SendMsg(2060, style, caseForce); SendMsg(2060, style, caseForce);
} }
// Set the character set of the font in a style.
void wxStyledTextCtrl::StyleSetCharacterSet(int style, int characterSet) {
SendMsg(2066, style, characterSet);
}
// Set the foreground colour of the selection and whether to use this setting. // Set the foreground colour of the selection and whether to use this setting.
void wxStyledTextCtrl::SetSelForeground(bool useSetting, const wxColour& fore) { void wxStyledTextCtrl::SetSelForeground(bool useSetting, const wxColour& fore) {
SendMsg(2067, useSetting, wxColourAsLong(fore)); SendMsg(2067, useSetting, wxColourAsLong(fore));
@@ -587,7 +604,7 @@ void wxStyledTextCtrl::SetCaretPeriod(int periodMilliseconds) {
// Set the set of characters making up words for when moving or selecting // Set the set of characters making up words for when moving or selecting
// by word. // by word.
void wxStyledTextCtrl::SetWordChars(const wxString& characters) { void wxStyledTextCtrl::SetWordChars(const wxString& characters) {
SendMsg(2077, 0, (long)characters.c_str()); SendMsg(2077, 0, (long)(const char*)characters.mb_str(wxConvUTF8));
} }
// Start a sequence of actions that is undone and redone as a unit. // Start a sequence of actions that is undone and redone as a unit.
@@ -680,7 +697,7 @@ void wxStyledTextCtrl::StyleSetChangeable(int style, bool changeable) {
// The lenEntered parameter indicates how many characters before // The lenEntered parameter indicates how many characters before
// the caret should be used to provide context. // the caret should be used to provide context.
void wxStyledTextCtrl::AutoCompShow(int lenEntered, const wxString& itemList) { void wxStyledTextCtrl::AutoCompShow(int lenEntered, const wxString& itemList) {
SendMsg(2100, lenEntered, (long)itemList.c_str()); SendMsg(2100, lenEntered, (long)(const char*)itemList.mb_str(wxConvUTF8));
} }
// Remove the auto-completion list from the screen. // Remove the auto-completion list from the screen.
@@ -706,7 +723,7 @@ void wxStyledTextCtrl::AutoCompComplete() {
// Define a set of character that when typed cancel the auto-completion list. // Define a set of character that when typed cancel the auto-completion list.
void wxStyledTextCtrl::AutoCompStops(const wxString& characterSet) { void wxStyledTextCtrl::AutoCompStops(const wxString& characterSet) {
SendMsg(2105, 0, (long)characterSet.c_str()); SendMsg(2105, 0, (long)(const char*)characterSet.mb_str(wxConvUTF8));
} }
// Change the separator character in the string setting up an auto-completion // Change the separator character in the string setting up an auto-completion
@@ -722,7 +739,7 @@ int wxStyledTextCtrl::AutoCompGetSeparator() {
// Select the item in the auto-completion list that starts with a string. // Select the item in the auto-completion list that starts with a string.
void wxStyledTextCtrl::AutoCompSelect(const wxString& text) { void wxStyledTextCtrl::AutoCompSelect(const wxString& text) {
SendMsg(2108, 0, (long)text.c_str()); SendMsg(2108, 0, (long)(const char*)text.mb_str(wxConvUTF8));
} }
// Should the auto-completion list be cancelled if the user backspaces to a // Should the auto-completion list be cancelled if the user backspaces to a
@@ -739,7 +756,7 @@ bool wxStyledTextCtrl::AutoCompGetCancelAtStart() {
// Define a set of characters that when typed will cause the autocompletion to // Define a set of characters that when typed will cause the autocompletion to
// choose the selected item. // choose the selected item.
void wxStyledTextCtrl::AutoCompSetFillUps(const wxString& characterSet) { void wxStyledTextCtrl::AutoCompSetFillUps(const wxString& characterSet) {
SendMsg(2112, 0, (long)characterSet.c_str()); SendMsg(2112, 0, (long)(const char*)characterSet.mb_str(wxConvUTF8));
} }
// Should a single item auto-completion list automatically choose the item. // Should a single item auto-completion list automatically choose the item.
@@ -764,7 +781,7 @@ bool wxStyledTextCtrl::AutoCompGetIgnoreCase() {
// Display a list of strings and send notification when user chooses one. // Display a list of strings and send notification when user chooses one.
void wxStyledTextCtrl::UserListShow(int listType, const wxString& itemList) { void wxStyledTextCtrl::UserListShow(int listType, const wxString& itemList) {
SendMsg(2117, listType, (long)itemList.c_str()); SendMsg(2117, listType, (long)(const char*)itemList.mb_str(wxConvUTF8));
} }
// Set whether or not autocompletion is hidden automatically when nothing matches // Set whether or not autocompletion is hidden automatically when nothing matches
@@ -936,7 +953,7 @@ int wxStyledTextCtrl::FindText(int minPos, int maxPos,
flags |= wholeWord ? SCFIND_WHOLEWORD : 0; flags |= wholeWord ? SCFIND_WHOLEWORD : 0;
ft.chrg.cpMin = minPos; ft.chrg.cpMin = minPos;
ft.chrg.cpMax = maxPos; ft.chrg.cpMax = maxPos;
ft.lpstrText = (char*)text.c_str(); ft.lpstrText = (char*)(const char*)text.mb_str(wxConvUTF8);
return SendMsg(2150, flags, (long)&ft); return SendMsg(2150, flags, (long)&ft);
} }
@@ -979,15 +996,15 @@ int wxStyledTextCtrl::GetFirstVisibleLine() {
// Retrieve the contents of a line. // Retrieve the contents of a line.
wxString wxStyledTextCtrl::GetLine(int line) { wxString wxStyledTextCtrl::GetLine(int line) {
wxString text;
int len = LineLength(line); int len = LineLength(line);
if (!len) return ""; if (!len) return wxEmptyString;
char* buf = text.GetWriteBuf(len);
int pos = SendMsg(2153, line, (long)buf); wxMemoryBuffer mbuf(len+1);
text.UngetWriteBuf(len); char* buf = (char*)mbuf.GetWriteBuf(len+1);
SendMsg(2153, line, (long)buf);
return text; mbuf.UngetWriteBuf(len);
mbuf.AppendByte(0);
return wxString(buf, wxConvUTF8);
} }
// Returns the number of lines in the document. There is always at least one. // Returns the number of lines in the document. There is always at least one.
@@ -1027,39 +1044,40 @@ void wxStyledTextCtrl::SetSelection(int start, int end) {
// Retrieve the selected text. // Retrieve the selected text.
wxString wxStyledTextCtrl::GetSelectedText() { wxString wxStyledTextCtrl::GetSelectedText() {
wxString text;
int start; int start;
int end; int end;
GetSelection(&start, &end); GetSelection(&start, &end);
int len = end - start; int len = end - start;
if (!len) return ""; if (!len) return wxEmptyString;
char* buff = text.GetWriteBuf(len);
SendMsg(2161, 0, (long)buff); wxMemoryBuffer mbuf(len+1);
text.UngetWriteBuf(len); char* buf = (char*)mbuf.GetWriteBuf(len+1);
return text; SendMsg(2161, 0, (long)buf);
mbuf.UngetWriteBuf(len);
mbuf.AppendByte(0);
return wxString(buf, wxConvUTF8);
} }
// Retrieve a range of text. // Retrieve a range of text.
wxString wxStyledTextCtrl::GetTextRange(int startPos, int endPos) { wxString wxStyledTextCtrl::GetTextRange(int startPos, int endPos) {
wxString text;
if (endPos < startPos) { if (endPos < startPos) {
int temp = startPos; int temp = startPos;
startPos = endPos; startPos = endPos;
endPos = temp; endPos = temp;
} }
int len = endPos - startPos; int len = endPos - startPos;
if (!len) return ""; if (!len) return wxEmptyString;
char* buff = text.GetWriteBuf(len); wxMemoryBuffer mbuf(len+1);
char* buf = (char*)mbuf.GetWriteBuf(len);
TextRange tr; TextRange tr;
tr.lpstrText = buff; tr.lpstrText = buf;
tr.chrg.cpMin = startPos; tr.chrg.cpMin = startPos;
tr.chrg.cpMax = endPos; tr.chrg.cpMax = endPos;
SendMsg(2162, 0, (long)&tr); SendMsg(2162, 0, (long)&tr);
text.UngetWriteBuf(len); mbuf.UngetWriteBuf(len);
return text; mbuf.AppendByte(0);
return wxString(buf, wxConvUTF8);
} }
// Draw the selection in normal style or with selection highlighted. // Draw the selection in normal style or with selection highlighted.
@@ -1089,7 +1107,7 @@ void wxStyledTextCtrl::EnsureCaretVisible() {
// Replace the selected text with the argument text. // Replace the selected text with the argument text.
void wxStyledTextCtrl::ReplaceSelection(const wxString& text) { void wxStyledTextCtrl::ReplaceSelection(const wxString& text) {
SendMsg(2170, 0, (long)text.c_str()); SendMsg(2170, 0, (long)(const char*)text.mb_str(wxConvUTF8));
} }
// Set to read only or read write. // Set to read only or read write.
@@ -1139,18 +1157,18 @@ void wxStyledTextCtrl::Clear() {
// Replace the contents of the document with the argument text. // Replace the contents of the document with the argument text.
void wxStyledTextCtrl::SetText(const wxString& text) { void wxStyledTextCtrl::SetText(const wxString& text) {
SendMsg(2181, 0, (long)text.c_str()); SendMsg(2181, 0, (long)(const char*)text.mb_str(wxConvUTF8));
} }
// Retrieve all the text in the document. // Retrieve all the text in the document.
wxString wxStyledTextCtrl::GetText() { wxString wxStyledTextCtrl::GetText() {
wxString text; int len = GetTextLength();
int len = GetTextLength(); wxMemoryBuffer mbuf(len+1); // leave room for the null...
char* buff = text.GetWriteBuf(len+1); // leave room for the null... char* buf = (char*)mbuf.GetWriteBuf(len+1);
SendMsg(2182, len+1, (long)buf);
SendMsg(2182, len+1, (long)buff); mbuf.UngetWriteBuf(len);
text.UngetWriteBuf(len); mbuf.AppendByte(0);
return text; return wxString(buf, wxConvUTF8);
} }
// Retrieve the number of characters in the document. // Retrieve the number of characters in the document.
@@ -1205,8 +1223,8 @@ int wxStyledTextCtrl::GetTargetEnd() {
// Returns the length of the replacement text. // Returns the length of the replacement text.
int wxStyledTextCtrl::ReplaceTarget(const wxString& text) { int wxStyledTextCtrl::ReplaceTarget(const wxString& text) {
return SendMsg(2194, text.Len(), (long)text.c_str()); wxWX2MBbuf buf = (wxWX2MBbuf)text.mb_str(wxConvUTF8);
return SendMsg(2194, strlen(buf), (long)(const char*)buf);
} }
// Replace the target text with the argument text after \d processing. // Replace the target text with the argument text after \d processing.
@@ -1217,8 +1235,8 @@ int wxStyledTextCtrl::GetTargetEnd() {
// caused by processing the \d patterns. // caused by processing the \d patterns.
int wxStyledTextCtrl::ReplaceTargetRE(const wxString& text) { int wxStyledTextCtrl::ReplaceTargetRE(const wxString& text) {
return SendMsg(2195, text.Len(), (long)text.c_str()); wxWX2MBbuf buf = (wxWX2MBbuf)text.mb_str(wxConvUTF8);
return SendMsg(2195, strlen(buf), (long)(const char*)buf);
} }
// Search for a counted string in the target and set the target to the found // Search for a counted string in the target and set the target to the found
@@ -1226,8 +1244,8 @@ int wxStyledTextCtrl::GetTargetEnd() {
// Returns length of range or -1 for failure in which case target is not moved. // Returns length of range or -1 for failure in which case target is not moved.
int wxStyledTextCtrl::SearchInTarget(const wxString& text) { int wxStyledTextCtrl::SearchInTarget(const wxString& text) {
return SendMsg(2197, text.Len(), (long)text.c_str()); wxWX2MBbuf buf = (wxWX2MBbuf)text.mb_str(wxConvUTF8);
return SendMsg(2197, strlen(buf), (long)(const char*)buf);
} }
// Set the search flags used by SearchInTarget // Set the search flags used by SearchInTarget
@@ -1242,7 +1260,7 @@ int wxStyledTextCtrl::GetSearchFlags() {
// Show a call tip containing a definition near position pos. // Show a call tip containing a definition near position pos.
void wxStyledTextCtrl::CallTipShow(int pos, const wxString& definition) { void wxStyledTextCtrl::CallTipShow(int pos, const wxString& definition) {
SendMsg(2200, pos, (long)definition.c_str()); SendMsg(2200, pos, (long)(const char*)definition.mb_str(wxConvUTF8));
} }
// Remove the call tip from the screen. // Remove the call tip from the screen.
@@ -1408,12 +1426,6 @@ int wxStyledTextCtrl::GetLayoutCache() {
return SendMsg(2273, 0, 0); return SendMsg(2273, 0, 0);
} }
// Delete the selection or if no selection, the character before the caret.
// Will not delete the chraacter before at the start of a line.
void wxStyledTextCtrl::DeleteBackNotLine() {
SendMsg(2344, 0, 0);
}
// Move the caret inside current view if it's not there already // Move the caret inside current view if it's not there already
void wxStyledTextCtrl::MoveCaretInsideView() { void wxStyledTextCtrl::MoveCaretInsideView() {
SendMsg(2401, 0, 0); SendMsg(2401, 0, 0);
@@ -1505,13 +1517,13 @@ void wxStyledTextCtrl::SearchAnchor() {
// Find some text starting at the search anchor. // Find some text starting at the search anchor.
// Does not ensure the selection is visible. // Does not ensure the selection is visible.
int wxStyledTextCtrl::SearchNext(int flags, const wxString& text) { int wxStyledTextCtrl::SearchNext(int flags, const wxString& text) {
return SendMsg(2367, flags, (long)text.c_str()); return SendMsg(2367, flags, (long)(const char*)text.mb_str(wxConvUTF8));
} }
// Find some text starting at the search anchor and moving backwards. // Find some text starting at the search anchor and moving backwards.
// Does not ensure the selection is visible. // Does not ensure the selection is visible.
int wxStyledTextCtrl::SearchPrev(int flags, const wxString& text) { int wxStyledTextCtrl::SearchPrev(int flags, const wxString& text) {
return SendMsg(2368, flags, (long)text.c_str()); return SendMsg(2368, flags, (long)(const char*)text.mb_str(wxConvUTF8));
} }
// Set the way the line the caret is on is kept visible. // Set the way the line the caret is on is kept visible.
@@ -1688,17 +1700,17 @@ void wxStyledTextCtrl::Colourise(int start, int end) {
// Set up a value that may be used by a lexer for some optional feature. // Set up a value that may be used by a lexer for some optional feature.
void wxStyledTextCtrl::SetProperty(const wxString& key, const wxString& value) { void wxStyledTextCtrl::SetProperty(const wxString& key, const wxString& value) {
SendMsg(4004, (long)key.c_str(), (long)value.c_str()); SendMsg(4004, (long)(const char*)key.mb_str(wxConvUTF8), (long)(const char*)value.mb_str(wxConvUTF8));
} }
// Set up the key words used by the lexer. // Set up the key words used by the lexer.
void wxStyledTextCtrl::SetKeyWords(int keywordSet, const wxString& keyWords) { void wxStyledTextCtrl::SetKeyWords(int keywordSet, const wxString& keyWords) {
SendMsg(4005, keywordSet, (long)keyWords.c_str()); SendMsg(4005, keywordSet, (long)(const char*)keyWords.mb_str(wxConvUTF8));
} }
// Set the lexing language of the document based on string name. // Set the lexing language of the document based on string name.
void wxStyledTextCtrl::SetLexerLanguage(const wxString& language) { void wxStyledTextCtrl::SetLexerLanguage(const wxString& language) {
SendMsg(4006, 0, (long)language.c_str()); SendMsg(4006, 0, (long)(const char*)language.mb_str(wxConvUTF8));
} }
// END of generated section // END of generated section
@@ -1863,6 +1875,7 @@ void wxStyledTextCtrl::OnScroll(wxScrollEvent& evt) {
void wxStyledTextCtrl::OnSize(wxSizeEvent& evt) { void wxStyledTextCtrl::OnSize(wxSizeEvent& evt) {
wxSize sz = GetClientSize(); wxSize sz = GetClientSize();
m_swx->DoSize(sz.x, sz.y); m_swx->DoSize(sz.x, sz.y);
Refresh(FALSE);
} }
void wxStyledTextCtrl::OnMouseLeftDown(wxMouseEvent& evt) { void wxStyledTextCtrl::OnMouseLeftDown(wxMouseEvent& evt) {
@@ -1905,10 +1918,7 @@ void wxStyledTextCtrl::OnMouseWheel(wxMouseEvent& evt) {
void wxStyledTextCtrl::OnChar(wxKeyEvent& evt) { void wxStyledTextCtrl::OnChar(wxKeyEvent& evt) {
long key = evt.KeyCode(); int key = evt.GetKeyCode();
// printf("OnChar key:%d consumed:%d ctrl:%d alt:%d\n",
// key, m_lastKeyDownConsumed, evt.ControlDown(), evt.AltDown());
// AltGr keys??? // AltGr keys???
// \|@#<23>[]{}?<3F>$~ <20>,<2C>,<2C>,<2C>, <20>, <20> // \|@#<23>[]{}?<3F>$~ <20>,<2C>,<2C>,<2C>, <20>, <20>
@@ -1921,7 +1931,10 @@ void wxStyledTextCtrl::OnChar(wxKeyEvent& evt) {
bool alt = evt.AltDown(); bool alt = evt.AltDown();
bool skip = ((ctrl || alt) && ! (ctrl && alt)); bool skip = ((ctrl || alt) && ! (ctrl && alt));
if (key <= 0xff && key >= 32 && !m_lastKeyDownConsumed && !skip) { //printf("OnChar key:%d consumed:%d ctrl:%d alt:%d skip:%d\n",
// key, m_lastKeyDownConsumed, ctrl, alt, skip);
if (key <= WXK_START && /*key >= 32 &&*/ !m_lastKeyDownConsumed && !skip) {
m_swx->DoAddChar(key); m_swx->DoAddChar(key);
return; return;
} }
@@ -1930,10 +1943,10 @@ void wxStyledTextCtrl::OnChar(wxKeyEvent& evt) {
void wxStyledTextCtrl::OnKeyDown(wxKeyEvent& evt) { void wxStyledTextCtrl::OnKeyDown(wxKeyEvent& evt) {
long key = evt.KeyCode(); int key = evt.GetKeyCode();
bool shift = evt.ShiftDown(), bool shift = evt.ShiftDown(),
ctrl = evt.ControlDown(), ctrl = evt.ControlDown(),
alt = evt.AltDown(); alt = evt.AltDown();
int processed = m_swx->DoKeyDown(key, shift, ctrl, alt, &m_lastKeyDownConsumed); int processed = m_swx->DoKeyDown(key, shift, ctrl, alt, &m_lastKeyDownConsumed);
@@ -2031,8 +2044,14 @@ void wxStyledTextCtrl::NotifyParent(SCNotification* _scn) {
case SCN_MODIFIED: case SCN_MODIFIED:
evt.SetEventType(wxEVT_STC_MODIFIED); evt.SetEventType(wxEVT_STC_MODIFIED);
evt.SetModificationType(scn.modificationType); evt.SetModificationType(scn.modificationType);
if (scn.text) if (scn.text) {
evt.SetText(wxString(scn.text, scn.length)); // The unicode conversion MUST have a null byte to terminate the
// string so move it into a buffer first and give it one.
wxMemoryBuffer buf(scn.length+1);
buf.AppendData((void*)scn.text, scn.length);
buf.AppendByte(0);
evt.SetText(wxString(buf, wxConvUTF8));
}
evt.SetLength(scn.length); evt.SetLength(scn.length);
evt.SetLinesAdded(scn.linesAdded); evt.SetLinesAdded(scn.linesAdded);
evt.SetLine(scn.line); evt.SetLine(scn.line);

View File

@@ -25,7 +25,7 @@
//---------------------------------------------------------------------- //----------------------------------------------------------------------
const wxChar* wxSTCNameStr = "stcwindow"; const wxChar* wxSTCNameStr = wxT("stcwindow");
DEFINE_EVENT_TYPE( wxEVT_STC_CHANGE ) DEFINE_EVENT_TYPE( wxEVT_STC_CHANGE )
DEFINE_EVENT_TYPE( wxEVT_STC_STYLENEEDED ) DEFINE_EVENT_TYPE( wxEVT_STC_STYLENEEDED )
@@ -105,6 +105,10 @@ wxStyledTextCtrl::wxStyledTextCtrl(wxWindow *parent,
m_lastKeyDownConsumed = FALSE; m_lastKeyDownConsumed = FALSE;
m_vScrollBar = NULL; m_vScrollBar = NULL;
m_hScrollBar = NULL; m_hScrollBar = NULL;
#if wxUSE_UNICODE
// Put Scintilla into unicode (UTF-8) mode
SetCodePage(wxSTC_CP_UTF8);
#endif
} }
@@ -142,11 +146,12 @@ static wxColour wxColourFromLong(long c) {
static wxColour wxColourFromSpec(const wxString& spec) { static wxColour wxColourFromSpec(const wxString& spec) {
// spec should be #RRGGBB // spec should be "#RRGGBB"
char* junk; long red, green, blue;
int red = strtol(spec.Mid(1,2), &junk, 16); red = green = blue = 0;
int green = strtol(spec.Mid(3,2), &junk, 16); spec.Mid(1,2).ToLong(&red, 16);
int blue = strtol(spec.Mid(5,2), &junk, 16); spec.Mid(3,2).ToLong(&green, 16);
spec.Mid(5,2).ToLong(&blue, 16);
return wxColour(red, green, blue); return wxColour(red, green, blue);
} }
@@ -320,6 +325,7 @@ void wxStyledTextCtrl::OnScroll(wxScrollEvent& evt) {
void wxStyledTextCtrl::OnSize(wxSizeEvent& evt) { void wxStyledTextCtrl::OnSize(wxSizeEvent& evt) {
wxSize sz = GetClientSize(); wxSize sz = GetClientSize();
m_swx->DoSize(sz.x, sz.y); m_swx->DoSize(sz.x, sz.y);
Refresh(FALSE);
} }
void wxStyledTextCtrl::OnMouseLeftDown(wxMouseEvent& evt) { void wxStyledTextCtrl::OnMouseLeftDown(wxMouseEvent& evt) {
@@ -362,10 +368,7 @@ void wxStyledTextCtrl::OnMouseWheel(wxMouseEvent& evt) {
void wxStyledTextCtrl::OnChar(wxKeyEvent& evt) { void wxStyledTextCtrl::OnChar(wxKeyEvent& evt) {
long key = evt.KeyCode(); int key = evt.GetKeyCode();
// printf("OnChar key:%%d consumed:%%d ctrl:%%d alt:%%d\n",
// key, m_lastKeyDownConsumed, evt.ControlDown(), evt.AltDown());
// AltGr keys??? // AltGr keys???
// \|@#<23>[]{}?<3F>$~ <20>,<2C>,<2C>,<2C>, <20>, <20> // \|@#<23>[]{}?<3F>$~ <20>,<2C>,<2C>,<2C>, <20>, <20>
@@ -378,7 +381,10 @@ void wxStyledTextCtrl::OnChar(wxKeyEvent& evt) {
bool alt = evt.AltDown(); bool alt = evt.AltDown();
bool skip = ((ctrl || alt) && ! (ctrl && alt)); bool skip = ((ctrl || alt) && ! (ctrl && alt));
if (key <= 0xff && key >= 32 && !m_lastKeyDownConsumed && !skip) { //printf("OnChar key:%%d consumed:%%d ctrl:%%d alt:%%d skip:%%d\n",
// key, m_lastKeyDownConsumed, ctrl, alt, skip);
if (key <= WXK_START && /*key >= 32 &&*/ !m_lastKeyDownConsumed && !skip) {
m_swx->DoAddChar(key); m_swx->DoAddChar(key);
return; return;
} }
@@ -387,10 +393,10 @@ void wxStyledTextCtrl::OnChar(wxKeyEvent& evt) {
void wxStyledTextCtrl::OnKeyDown(wxKeyEvent& evt) { void wxStyledTextCtrl::OnKeyDown(wxKeyEvent& evt) {
long key = evt.KeyCode(); int key = evt.GetKeyCode();
bool shift = evt.ShiftDown(), bool shift = evt.ShiftDown(),
ctrl = evt.ControlDown(), ctrl = evt.ControlDown(),
alt = evt.AltDown(); alt = evt.AltDown();
int processed = m_swx->DoKeyDown(key, shift, ctrl, alt, &m_lastKeyDownConsumed); int processed = m_swx->DoKeyDown(key, shift, ctrl, alt, &m_lastKeyDownConsumed);
@@ -488,8 +494,14 @@ void wxStyledTextCtrl::NotifyParent(SCNotification* _scn) {
case SCN_MODIFIED: case SCN_MODIFIED:
evt.SetEventType(wxEVT_STC_MODIFIED); evt.SetEventType(wxEVT_STC_MODIFIED);
evt.SetModificationType(scn.modificationType); evt.SetModificationType(scn.modificationType);
if (scn.text) if (scn.text) {
evt.SetText(wxString(scn.text, scn.length)); // The unicode conversion MUST have a null byte to terminate the
// string so move it into a buffer first and give it one.
wxMemoryBuffer buf(scn.length+1);
buf.AppendData((void*)scn.text, scn.length);
buf.AppendByte(0);
evt.SetText(wxString(buf, wxConvUTF8));
}
evt.SetLength(scn.length); evt.SetLength(scn.length);
evt.SetLinesAdded(scn.linesAdded); evt.SetLinesAdded(scn.linesAdded);
evt.SetLine(scn.line); evt.SetLine(scn.line);

View File

@@ -210,7 +210,7 @@ public:
void SetKey(int k) { m_key = k; } void SetKey(int k) { m_key = k; }
void SetModifiers(int m) { m_modifiers = m; } void SetModifiers(int m) { m_modifiers = m; }
void SetModificationType(int t) { m_modificationType = t; } void SetModificationType(int t) { m_modificationType = t; }
void SetText(const char* t) { m_text = t; } void SetText(const wxString& t) { m_text = t; }
void SetLength(int len) { m_length = len; } void SetLength(int len) { m_length = len; }
void SetLinesAdded(int num) { m_linesAdded = num; } void SetLinesAdded(int num) { m_linesAdded = num; }
void SetLine(int val) { m_line = val; } void SetLine(int val) { m_line = val; }

View File

@@ -218,10 +218,10 @@ static PyObject *_wrap_wxStyledTextCtrl_AddText(PyObject *self, PyObject *args,
static PyObject *_wrap_wxStyledTextCtrl_AddStyledText(PyObject *self, PyObject *args, PyObject *kwargs) { static PyObject *_wrap_wxStyledTextCtrl_AddStyledText(PyObject *self, PyObject *args, PyObject *kwargs) {
PyObject * _resultobj; PyObject * _resultobj;
wxStyledTextCtrl * _arg0; wxStyledTextCtrl * _arg0;
wxString * _arg1; wxMemoryBuffer * _arg1;
PyObject * _argo0 = 0; PyObject * _argo0 = 0;
PyObject * _obj1 = 0; PyObject * _obj1 = 0;
char *_kwnames[] = { "self","text", NULL }; char *_kwnames[] = { "self","data", NULL };
self = self; self = self;
if(!PyArg_ParseTupleAndKeywords(args,kwargs,"OO:wxStyledTextCtrl_AddStyledText",_kwnames,&_argo0,&_obj1)) if(!PyArg_ParseTupleAndKeywords(args,kwargs,"OO:wxStyledTextCtrl_AddStyledText",_kwnames,&_argo0,&_obj1))
@@ -234,9 +234,14 @@ static PyObject *_wrap_wxStyledTextCtrl_AddStyledText(PyObject *self, PyObject *
} }
} }
{ {
_arg1 = wxString_in_helper(_obj1); if (!PyString_Check(_obj1)) {
if (_arg1 == NULL) PyErr_SetString(PyExc_TypeError, "String buffer expected");
return NULL; return NULL;
}
char* str = PyString_AS_STRING(_obj1);
int len = PyString_GET_SIZE(_obj1);
_arg1 = new wxMemoryBuffer(len);
memcpy(_arg1->GetData(), str, len);
} }
{ {
PyThreadState* __tstate = wxPyBeginAllowThreads(); PyThreadState* __tstate = wxPyBeginAllowThreads();
@@ -609,7 +614,7 @@ static PyObject *_wrap_wxStyledTextCtrl_SetSavePoint(PyObject *self, PyObject *a
#define wxStyledTextCtrl_GetStyledText(_swigobj,_swigarg0,_swigarg1) (_swigobj->GetStyledText(_swigarg0,_swigarg1)) #define wxStyledTextCtrl_GetStyledText(_swigobj,_swigarg0,_swigarg1) (_swigobj->GetStyledText(_swigarg0,_swigarg1))
static PyObject *_wrap_wxStyledTextCtrl_GetStyledText(PyObject *self, PyObject *args, PyObject *kwargs) { static PyObject *_wrap_wxStyledTextCtrl_GetStyledText(PyObject *self, PyObject *args, PyObject *kwargs) {
PyObject * _resultobj; PyObject * _resultobj;
wxString * _result; wxMemoryBuffer * _result;
wxStyledTextCtrl * _arg0; wxStyledTextCtrl * _arg0;
int _arg1; int _arg1;
int _arg2; int _arg2;
@@ -628,16 +633,12 @@ static PyObject *_wrap_wxStyledTextCtrl_GetStyledText(PyObject *self, PyObject *
} }
{ {
PyThreadState* __tstate = wxPyBeginAllowThreads(); PyThreadState* __tstate = wxPyBeginAllowThreads();
_result = new wxString (wxStyledTextCtrl_GetStyledText(_arg0,_arg1,_arg2)); _result = new wxMemoryBuffer (wxStyledTextCtrl_GetStyledText(_arg0,_arg1,_arg2));
wxPyEndAllowThreads(__tstate); wxPyEndAllowThreads(__tstate);
if (PyErr_Occurred()) return NULL; if (PyErr_Occurred()) return NULL;
}{ }{
#if wxUSE_UNICODE _resultobj = PyString_FromStringAndSize((char*)_result->GetData(), _result->GetDataLen());
_resultobj = PyUnicode_FromUnicode(_result->c_str(), _result->Len());
#else
_resultobj = PyString_FromStringAndSize(_result->c_str(), _result->Len());
#endif
} }
{ {
delete _result; delete _result;
@@ -2231,6 +2232,36 @@ static PyObject *_wrap_wxStyledTextCtrl_StyleSetCase(PyObject *self, PyObject *a
return _resultobj; return _resultobj;
} }
#define wxStyledTextCtrl_StyleSetCharacterSet(_swigobj,_swigarg0,_swigarg1) (_swigobj->StyleSetCharacterSet(_swigarg0,_swigarg1))
static PyObject *_wrap_wxStyledTextCtrl_StyleSetCharacterSet(PyObject *self, PyObject *args, PyObject *kwargs) {
PyObject * _resultobj;
wxStyledTextCtrl * _arg0;
int _arg1;
int _arg2;
PyObject * _argo0 = 0;
char *_kwnames[] = { "self","style","characterSet", NULL };
self = self;
if(!PyArg_ParseTupleAndKeywords(args,kwargs,"Oii:wxStyledTextCtrl_StyleSetCharacterSet",_kwnames,&_argo0,&_arg1,&_arg2))
return NULL;
if (_argo0) {
if (_argo0 == Py_None) { _arg0 = NULL; }
else if (SWIG_GetPtrObj(_argo0,(void **) &_arg0,"_wxStyledTextCtrl_p")) {
PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of wxStyledTextCtrl_StyleSetCharacterSet. Expected _wxStyledTextCtrl_p.");
return NULL;
}
}
{
PyThreadState* __tstate = wxPyBeginAllowThreads();
wxStyledTextCtrl_StyleSetCharacterSet(_arg0,_arg1,_arg2);
wxPyEndAllowThreads(__tstate);
if (PyErr_Occurred()) return NULL;
} Py_INCREF(Py_None);
_resultobj = Py_None;
return _resultobj;
}
#define wxStyledTextCtrl_SetSelForeground(_swigobj,_swigarg0,_swigarg1) (_swigobj->SetSelForeground(_swigarg0,_swigarg1)) #define wxStyledTextCtrl_SetSelForeground(_swigobj,_swigarg0,_swigarg1) (_swigobj->SetSelForeground(_swigarg0,_swigarg1))
static PyObject *_wrap_wxStyledTextCtrl_SetSelForeground(PyObject *self, PyObject *args, PyObject *kwargs) { static PyObject *_wrap_wxStyledTextCtrl_SetSelForeground(PyObject *self, PyObject *args, PyObject *kwargs) {
PyObject * _resultobj; PyObject * _resultobj;
@@ -6907,34 +6938,6 @@ static PyObject *_wrap_wxStyledTextCtrl_GetLayoutCache(PyObject *self, PyObject
return _resultobj; return _resultobj;
} }
#define wxStyledTextCtrl_DeleteBackNotLine(_swigobj) (_swigobj->DeleteBackNotLine())
static PyObject *_wrap_wxStyledTextCtrl_DeleteBackNotLine(PyObject *self, PyObject *args, PyObject *kwargs) {
PyObject * _resultobj;
wxStyledTextCtrl * _arg0;
PyObject * _argo0 = 0;
char *_kwnames[] = { "self", NULL };
self = self;
if(!PyArg_ParseTupleAndKeywords(args,kwargs,"O:wxStyledTextCtrl_DeleteBackNotLine",_kwnames,&_argo0))
return NULL;
if (_argo0) {
if (_argo0 == Py_None) { _arg0 = NULL; }
else if (SWIG_GetPtrObj(_argo0,(void **) &_arg0,"_wxStyledTextCtrl_p")) {
PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of wxStyledTextCtrl_DeleteBackNotLine. Expected _wxStyledTextCtrl_p.");
return NULL;
}
}
{
PyThreadState* __tstate = wxPyBeginAllowThreads();
wxStyledTextCtrl_DeleteBackNotLine(_arg0);
wxPyEndAllowThreads(__tstate);
if (PyErr_Occurred()) return NULL;
} Py_INCREF(Py_None);
_resultobj = Py_None;
return _resultobj;
}
#define wxStyledTextCtrl_MoveCaretInsideView(_swigobj) (_swigobj->MoveCaretInsideView()) #define wxStyledTextCtrl_MoveCaretInsideView(_swigobj) (_swigobj->MoveCaretInsideView())
static PyObject *_wrap_wxStyledTextCtrl_MoveCaretInsideView(PyObject *self, PyObject *args, PyObject *kwargs) { static PyObject *_wrap_wxStyledTextCtrl_MoveCaretInsideView(PyObject *self, PyObject *args, PyObject *kwargs) {
PyObject * _resultobj; PyObject * _resultobj;
@@ -9312,12 +9315,13 @@ static PyObject *_wrap_wxStyledTextEvent_SetModificationType(PyObject *self, PyO
static PyObject *_wrap_wxStyledTextEvent_SetText(PyObject *self, PyObject *args, PyObject *kwargs) { static PyObject *_wrap_wxStyledTextEvent_SetText(PyObject *self, PyObject *args, PyObject *kwargs) {
PyObject * _resultobj; PyObject * _resultobj;
wxStyledTextEvent * _arg0; wxStyledTextEvent * _arg0;
char * _arg1; wxString * _arg1;
PyObject * _argo0 = 0; PyObject * _argo0 = 0;
PyObject * _obj1 = 0;
char *_kwnames[] = { "self","t", NULL }; char *_kwnames[] = { "self","t", NULL };
self = self; self = self;
if(!PyArg_ParseTupleAndKeywords(args,kwargs,"Os:wxStyledTextEvent_SetText",_kwnames,&_argo0,&_arg1)) if(!PyArg_ParseTupleAndKeywords(args,kwargs,"OO:wxStyledTextEvent_SetText",_kwnames,&_argo0,&_obj1))
return NULL; return NULL;
if (_argo0) { if (_argo0) {
if (_argo0 == Py_None) { _arg0 = NULL; } if (_argo0 == Py_None) { _arg0 = NULL; }
@@ -9326,14 +9330,23 @@ static PyObject *_wrap_wxStyledTextEvent_SetText(PyObject *self, PyObject *args,
return NULL; return NULL;
} }
} }
{
_arg1 = wxString_in_helper(_obj1);
if (_arg1 == NULL)
return NULL;
}
{ {
PyThreadState* __tstate = wxPyBeginAllowThreads(); PyThreadState* __tstate = wxPyBeginAllowThreads();
wxStyledTextEvent_SetText(_arg0,_arg1); wxStyledTextEvent_SetText(_arg0,*_arg1);
wxPyEndAllowThreads(__tstate); wxPyEndAllowThreads(__tstate);
if (PyErr_Occurred()) return NULL; if (PyErr_Occurred()) return NULL;
} Py_INCREF(Py_None); } Py_INCREF(Py_None);
_resultobj = Py_None; _resultobj = Py_None;
{
if (_obj1)
delete _arg1;
}
return _resultobj; return _resultobj;
} }
@@ -10597,7 +10610,6 @@ static PyMethodDef stc_cMethods[] = {
{ "wxStyledTextCtrl_BraceHighlight", (PyCFunction) _wrap_wxStyledTextCtrl_BraceHighlight, METH_VARARGS | METH_KEYWORDS }, { "wxStyledTextCtrl_BraceHighlight", (PyCFunction) _wrap_wxStyledTextCtrl_BraceHighlight, METH_VARARGS | METH_KEYWORDS },
{ "wxStyledTextCtrl_LineLength", (PyCFunction) _wrap_wxStyledTextCtrl_LineLength, METH_VARARGS | METH_KEYWORDS }, { "wxStyledTextCtrl_LineLength", (PyCFunction) _wrap_wxStyledTextCtrl_LineLength, METH_VARARGS | METH_KEYWORDS },
{ "wxStyledTextCtrl_MoveCaretInsideView", (PyCFunction) _wrap_wxStyledTextCtrl_MoveCaretInsideView, METH_VARARGS | METH_KEYWORDS }, { "wxStyledTextCtrl_MoveCaretInsideView", (PyCFunction) _wrap_wxStyledTextCtrl_MoveCaretInsideView, METH_VARARGS | METH_KEYWORDS },
{ "wxStyledTextCtrl_DeleteBackNotLine", (PyCFunction) _wrap_wxStyledTextCtrl_DeleteBackNotLine, METH_VARARGS | METH_KEYWORDS },
{ "wxStyledTextCtrl_GetLayoutCache", (PyCFunction) _wrap_wxStyledTextCtrl_GetLayoutCache, METH_VARARGS | METH_KEYWORDS }, { "wxStyledTextCtrl_GetLayoutCache", (PyCFunction) _wrap_wxStyledTextCtrl_GetLayoutCache, METH_VARARGS | METH_KEYWORDS },
{ "wxStyledTextCtrl_SetLayoutCache", (PyCFunction) _wrap_wxStyledTextCtrl_SetLayoutCache, METH_VARARGS | METH_KEYWORDS }, { "wxStyledTextCtrl_SetLayoutCache", (PyCFunction) _wrap_wxStyledTextCtrl_SetLayoutCache, METH_VARARGS | METH_KEYWORDS },
{ "wxStyledTextCtrl_GetWrapMode", (PyCFunction) _wrap_wxStyledTextCtrl_GetWrapMode, METH_VARARGS | METH_KEYWORDS }, { "wxStyledTextCtrl_GetWrapMode", (PyCFunction) _wrap_wxStyledTextCtrl_GetWrapMode, METH_VARARGS | METH_KEYWORDS },
@@ -10750,6 +10762,7 @@ static PyMethodDef stc_cMethods[] = {
{ "wxStyledTextCtrl_SetCaretForeground", (PyCFunction) _wrap_wxStyledTextCtrl_SetCaretForeground, METH_VARARGS | METH_KEYWORDS }, { "wxStyledTextCtrl_SetCaretForeground", (PyCFunction) _wrap_wxStyledTextCtrl_SetCaretForeground, METH_VARARGS | METH_KEYWORDS },
{ "wxStyledTextCtrl_SetSelBackground", (PyCFunction) _wrap_wxStyledTextCtrl_SetSelBackground, METH_VARARGS | METH_KEYWORDS }, { "wxStyledTextCtrl_SetSelBackground", (PyCFunction) _wrap_wxStyledTextCtrl_SetSelBackground, METH_VARARGS | METH_KEYWORDS },
{ "wxStyledTextCtrl_SetSelForeground", (PyCFunction) _wrap_wxStyledTextCtrl_SetSelForeground, METH_VARARGS | METH_KEYWORDS }, { "wxStyledTextCtrl_SetSelForeground", (PyCFunction) _wrap_wxStyledTextCtrl_SetSelForeground, METH_VARARGS | METH_KEYWORDS },
{ "wxStyledTextCtrl_StyleSetCharacterSet", (PyCFunction) _wrap_wxStyledTextCtrl_StyleSetCharacterSet, METH_VARARGS | METH_KEYWORDS },
{ "wxStyledTextCtrl_StyleSetCase", (PyCFunction) _wrap_wxStyledTextCtrl_StyleSetCase, METH_VARARGS | METH_KEYWORDS }, { "wxStyledTextCtrl_StyleSetCase", (PyCFunction) _wrap_wxStyledTextCtrl_StyleSetCase, METH_VARARGS | METH_KEYWORDS },
{ "wxStyledTextCtrl_StyleSetUnderline", (PyCFunction) _wrap_wxStyledTextCtrl_StyleSetUnderline, METH_VARARGS | METH_KEYWORDS }, { "wxStyledTextCtrl_StyleSetUnderline", (PyCFunction) _wrap_wxStyledTextCtrl_StyleSetUnderline, METH_VARARGS | METH_KEYWORDS },
{ "wxStyledTextCtrl_StyleResetDefault", (PyCFunction) _wrap_wxStyledTextCtrl_StyleResetDefault, METH_VARARGS | METH_KEYWORDS }, { "wxStyledTextCtrl_StyleResetDefault", (PyCFunction) _wrap_wxStyledTextCtrl_StyleResetDefault, METH_VARARGS | METH_KEYWORDS },

View File

@@ -310,6 +310,9 @@ class wxStyledTextCtrlPtr(wxControlPtr):
def StyleSetCase(self, *_args, **_kwargs): def StyleSetCase(self, *_args, **_kwargs):
val = apply(stc_c.wxStyledTextCtrl_StyleSetCase,(self,) + _args, _kwargs) val = apply(stc_c.wxStyledTextCtrl_StyleSetCase,(self,) + _args, _kwargs)
return val return val
def StyleSetCharacterSet(self, *_args, **_kwargs):
val = apply(stc_c.wxStyledTextCtrl_StyleSetCharacterSet,(self,) + _args, _kwargs)
return val
def SetSelForeground(self, *_args, **_kwargs): def SetSelForeground(self, *_args, **_kwargs):
val = apply(stc_c.wxStyledTextCtrl_SetSelForeground,(self,) + _args, _kwargs) val = apply(stc_c.wxStyledTextCtrl_SetSelForeground,(self,) + _args, _kwargs)
return val return val
@@ -769,9 +772,6 @@ class wxStyledTextCtrlPtr(wxControlPtr):
def GetLayoutCache(self, *_args, **_kwargs): def GetLayoutCache(self, *_args, **_kwargs):
val = apply(stc_c.wxStyledTextCtrl_GetLayoutCache,(self,) + _args, _kwargs) val = apply(stc_c.wxStyledTextCtrl_GetLayoutCache,(self,) + _args, _kwargs)
return val return val
def DeleteBackNotLine(self, *_args, **_kwargs):
val = apply(stc_c.wxStyledTextCtrl_DeleteBackNotLine,(self,) + _args, _kwargs)
return val
def MoveCaretInsideView(self, *_args, **_kwargs): def MoveCaretInsideView(self, *_args, **_kwargs):
val = apply(stc_c.wxStyledTextCtrl_MoveCaretInsideView,(self,) + _args, _kwargs) val = apply(stc_c.wxStyledTextCtrl_MoveCaretInsideView,(self,) + _args, _kwargs)
return val return val

View File

@@ -42,7 +42,11 @@
<FONT color=#a020f0>#define wxSTC_START </FONT><FONT color=#ff00ff>2000</FONT> <FONT color=#a020f0>#define wxSTC_START </FONT><FONT color=#ff00ff>2000</FONT>
<FONT color=#a020f0>#define wxSTC_OPTIONAL_START </FONT><FONT color=#ff00ff>3000</FONT> <FONT color=#a020f0>#define wxSTC_OPTIONAL_START </FONT><FONT color=#ff00ff>3000</FONT>
<FONT color=#a020f0>#define wxSTC_LEXER_START </FONT><FONT color=#ff00ff>4000</FONT> <FONT color=#a020f0>#define wxSTC_LEXER_START </FONT><FONT color=#ff00ff>4000</FONT>
<FONT color=#0000ff>// Redoes the next action on the undo history</FONT>
<FONT color=#a020f0>#define wxSTC_CMD_REDO </FONT><FONT color=#ff00ff>2011</FONT> <FONT color=#a020f0>#define wxSTC_CMD_REDO </FONT><FONT color=#ff00ff>2011</FONT>
<FONT color=#0000ff>// Select all the text in the document.</FONT>
<FONT color=#a020f0>#define wxSTC_CMD_SELECTALL </FONT><FONT color=#ff00ff>2013</FONT> <FONT color=#a020f0>#define wxSTC_CMD_SELECTALL </FONT><FONT color=#ff00ff>2013</FONT>
<FONT color=#a020f0>#define wxSTC_WS_INVISIBLE </FONT><FONT color=#ff00ff>0</FONT> <FONT color=#a020f0>#define wxSTC_WS_INVISIBLE </FONT><FONT color=#ff00ff>0</FONT>
<FONT color=#a020f0>#define wxSTC_WS_VISIBLEALWAYS </FONT><FONT color=#ff00ff>1</FONT> <FONT color=#a020f0>#define wxSTC_WS_VISIBLEALWAYS </FONT><FONT color=#ff00ff>1</FONT>
@@ -160,9 +164,17 @@
<FONT color=#a020f0>#define wxSTC_FIND_MATCHCASE </FONT><FONT color=#ff00ff>4</FONT> <FONT color=#a020f0>#define wxSTC_FIND_MATCHCASE </FONT><FONT color=#ff00ff>4</FONT>
<FONT color=#a020f0>#define wxSTC_FIND_WORDSTART </FONT><FONT color=#ff00ff>0x00100000</FONT> <FONT color=#a020f0>#define wxSTC_FIND_WORDSTART </FONT><FONT color=#ff00ff>0x00100000</FONT>
<FONT color=#a020f0>#define wxSTC_FIND_REGEXP </FONT><FONT color=#ff00ff>0x00200000</FONT> <FONT color=#a020f0>#define wxSTC_FIND_REGEXP </FONT><FONT color=#ff00ff>0x00200000</FONT>
<FONT color=#0000ff>// Undo one action in the undo history.</FONT>
<FONT color=#a020f0>#define wxSTC_CMD_UNDO </FONT><FONT color=#ff00ff>2176</FONT> <FONT color=#a020f0>#define wxSTC_CMD_UNDO </FONT><FONT color=#ff00ff>2176</FONT>
<FONT color=#0000ff>// Cut the selection to the clipboard.</FONT>
<FONT color=#a020f0>#define wxSTC_CMD_CUT </FONT><FONT color=#ff00ff>2177</FONT> <FONT color=#a020f0>#define wxSTC_CMD_CUT </FONT><FONT color=#ff00ff>2177</FONT>
<FONT color=#0000ff>// Copy the selection to the clipboard.</FONT>
<FONT color=#a020f0>#define wxSTC_CMD_COPY </FONT><FONT color=#ff00ff>2178</FONT> <FONT color=#a020f0>#define wxSTC_CMD_COPY </FONT><FONT color=#ff00ff>2178</FONT>
<FONT color=#0000ff>// Paste the contents of the clipboard into the document replacing the selection.</FONT>
<FONT color=#a020f0>#define wxSTC_CMD_PASTE </FONT><FONT color=#ff00ff>2179</FONT> <FONT color=#a020f0>#define wxSTC_CMD_PASTE </FONT><FONT color=#ff00ff>2179</FONT>
<FONT color=#a020f0>#define wxSTC_FOLDLEVELBASE </FONT><FONT color=#ff00ff>0x400</FONT> <FONT color=#a020f0>#define wxSTC_FOLDLEVELBASE </FONT><FONT color=#ff00ff>0x400</FONT>
<FONT color=#a020f0>#define wxSTC_FOLDLEVELWHITEFLAG </FONT><FONT color=#ff00ff>0x1000</FONT> <FONT color=#a020f0>#define wxSTC_FOLDLEVELWHITEFLAG </FONT><FONT color=#ff00ff>0x1000</FONT>
@@ -175,50 +187,144 @@
<FONT color=#a020f0>#define wxSTC_CACHE_CARET </FONT><FONT color=#ff00ff>1</FONT> <FONT color=#a020f0>#define wxSTC_CACHE_CARET </FONT><FONT color=#ff00ff>1</FONT>
<FONT color=#a020f0>#define wxSTC_CACHE_PAGE </FONT><FONT color=#ff00ff>2</FONT> <FONT color=#a020f0>#define wxSTC_CACHE_PAGE </FONT><FONT color=#ff00ff>2</FONT>
<FONT color=#a020f0>#define wxSTC_CACHE_DOCUMENT </FONT><FONT color=#ff00ff>3</FONT> <FONT color=#a020f0>#define wxSTC_CACHE_DOCUMENT </FONT><FONT color=#ff00ff>3</FONT>
<FONT color=#0000ff>// Move caret down one line.</FONT>
<FONT color=#a020f0>#define wxSTC_CMD_LINEDOWN </FONT><FONT color=#ff00ff>2300</FONT> <FONT color=#a020f0>#define wxSTC_CMD_LINEDOWN </FONT><FONT color=#ff00ff>2300</FONT>
<FONT color=#0000ff>// Move caret down one line extending selection to new caret position.</FONT>
<FONT color=#a020f0>#define wxSTC_CMD_LINEDOWNEXTEND </FONT><FONT color=#ff00ff>2301</FONT> <FONT color=#a020f0>#define wxSTC_CMD_LINEDOWNEXTEND </FONT><FONT color=#ff00ff>2301</FONT>
<FONT color=#0000ff>// Move caret up one line.</FONT>
<FONT color=#a020f0>#define wxSTC_CMD_LINEUP </FONT><FONT color=#ff00ff>2302</FONT> <FONT color=#a020f0>#define wxSTC_CMD_LINEUP </FONT><FONT color=#ff00ff>2302</FONT>
<FONT color=#0000ff>// Move caret up one line extending selection to new caret position.</FONT>
<FONT color=#a020f0>#define wxSTC_CMD_LINEUPEXTEND </FONT><FONT color=#ff00ff>2303</FONT> <FONT color=#a020f0>#define wxSTC_CMD_LINEUPEXTEND </FONT><FONT color=#ff00ff>2303</FONT>
<FONT color=#0000ff>// Move caret left one character.</FONT>
<FONT color=#a020f0>#define wxSTC_CMD_CHARLEFT </FONT><FONT color=#ff00ff>2304</FONT> <FONT color=#a020f0>#define wxSTC_CMD_CHARLEFT </FONT><FONT color=#ff00ff>2304</FONT>
<FONT color=#0000ff>// Move caret left one character extending selection to new caret position.</FONT>
<FONT color=#a020f0>#define wxSTC_CMD_CHARLEFTEXTEND </FONT><FONT color=#ff00ff>2305</FONT> <FONT color=#a020f0>#define wxSTC_CMD_CHARLEFTEXTEND </FONT><FONT color=#ff00ff>2305</FONT>
<FONT color=#0000ff>// Move caret right one character.</FONT>
<FONT color=#a020f0>#define wxSTC_CMD_CHARRIGHT </FONT><FONT color=#ff00ff>2306</FONT> <FONT color=#a020f0>#define wxSTC_CMD_CHARRIGHT </FONT><FONT color=#ff00ff>2306</FONT>
<FONT color=#0000ff>// Move caret right one character extending selection to new caret position.</FONT>
<FONT color=#a020f0>#define wxSTC_CMD_CHARRIGHTEXTEND </FONT><FONT color=#ff00ff>2307</FONT> <FONT color=#a020f0>#define wxSTC_CMD_CHARRIGHTEXTEND </FONT><FONT color=#ff00ff>2307</FONT>
<FONT color=#0000ff>// Move caret left one word.</FONT>
<FONT color=#a020f0>#define wxSTC_CMD_WORDLEFT </FONT><FONT color=#ff00ff>2308</FONT> <FONT color=#a020f0>#define wxSTC_CMD_WORDLEFT </FONT><FONT color=#ff00ff>2308</FONT>
<FONT color=#0000ff>// Move caret left one word extending selection to new caret position.</FONT>
<FONT color=#a020f0>#define wxSTC_CMD_WORDLEFTEXTEND </FONT><FONT color=#ff00ff>2309</FONT> <FONT color=#a020f0>#define wxSTC_CMD_WORDLEFTEXTEND </FONT><FONT color=#ff00ff>2309</FONT>
<FONT color=#0000ff>// Move caret right one word.</FONT>
<FONT color=#a020f0>#define wxSTC_CMD_WORDRIGHT </FONT><FONT color=#ff00ff>2310</FONT> <FONT color=#a020f0>#define wxSTC_CMD_WORDRIGHT </FONT><FONT color=#ff00ff>2310</FONT>
<FONT color=#0000ff>// Move caret right one word extending selection to new caret position.</FONT>
<FONT color=#a020f0>#define wxSTC_CMD_WORDRIGHTEXTEND </FONT><FONT color=#ff00ff>2311</FONT> <FONT color=#a020f0>#define wxSTC_CMD_WORDRIGHTEXTEND </FONT><FONT color=#ff00ff>2311</FONT>
<FONT color=#0000ff>// Move caret to first position on line.</FONT>
<FONT color=#a020f0>#define wxSTC_CMD_HOME </FONT><FONT color=#ff00ff>2312</FONT> <FONT color=#a020f0>#define wxSTC_CMD_HOME </FONT><FONT color=#ff00ff>2312</FONT>
<FONT color=#0000ff>// Move caret to first position on line extending selection to new caret position.</FONT>
<FONT color=#a020f0>#define wxSTC_CMD_HOMEEXTEND </FONT><FONT color=#ff00ff>2313</FONT> <FONT color=#a020f0>#define wxSTC_CMD_HOMEEXTEND </FONT><FONT color=#ff00ff>2313</FONT>
<FONT color=#0000ff>// Move caret to last position on line.</FONT>
<FONT color=#a020f0>#define wxSTC_CMD_LINEEND </FONT><FONT color=#ff00ff>2314</FONT> <FONT color=#a020f0>#define wxSTC_CMD_LINEEND </FONT><FONT color=#ff00ff>2314</FONT>
<FONT color=#0000ff>// Move caret to last position on line extending selection to new caret position.</FONT>
<FONT color=#a020f0>#define wxSTC_CMD_LINEENDEXTEND </FONT><FONT color=#ff00ff>2315</FONT> <FONT color=#a020f0>#define wxSTC_CMD_LINEENDEXTEND </FONT><FONT color=#ff00ff>2315</FONT>
<FONT color=#0000ff>// Move caret to first position in document.</FONT>
<FONT color=#a020f0>#define wxSTC_CMD_DOCUMENTSTART </FONT><FONT color=#ff00ff>2316</FONT> <FONT color=#a020f0>#define wxSTC_CMD_DOCUMENTSTART </FONT><FONT color=#ff00ff>2316</FONT>
<FONT color=#0000ff>// Move caret to first position in document extending selection to new caret position.</FONT>
<FONT color=#a020f0>#define wxSTC_CMD_DOCUMENTSTARTEXTEND </FONT><FONT color=#ff00ff>2317</FONT> <FONT color=#a020f0>#define wxSTC_CMD_DOCUMENTSTARTEXTEND </FONT><FONT color=#ff00ff>2317</FONT>
<FONT color=#0000ff>// Move caret to last position in document.</FONT>
<FONT color=#a020f0>#define wxSTC_CMD_DOCUMENTEND </FONT><FONT color=#ff00ff>2318</FONT> <FONT color=#a020f0>#define wxSTC_CMD_DOCUMENTEND </FONT><FONT color=#ff00ff>2318</FONT>
<FONT color=#0000ff>// Move caret to last position in document extending selection to new caret position.</FONT>
<FONT color=#a020f0>#define wxSTC_CMD_DOCUMENTENDEXTEND </FONT><FONT color=#ff00ff>2319</FONT> <FONT color=#a020f0>#define wxSTC_CMD_DOCUMENTENDEXTEND </FONT><FONT color=#ff00ff>2319</FONT>
<FONT color=#0000ff>// Move caret one page up.</FONT>
<FONT color=#a020f0>#define wxSTC_CMD_PAGEUP </FONT><FONT color=#ff00ff>2320</FONT> <FONT color=#a020f0>#define wxSTC_CMD_PAGEUP </FONT><FONT color=#ff00ff>2320</FONT>
<FONT color=#0000ff>// Move caret one page up extending selection to new caret position.</FONT>
<FONT color=#a020f0>#define wxSTC_CMD_PAGEUPEXTEND </FONT><FONT color=#ff00ff>2321</FONT> <FONT color=#a020f0>#define wxSTC_CMD_PAGEUPEXTEND </FONT><FONT color=#ff00ff>2321</FONT>
<FONT color=#0000ff>// Move caret one page down.</FONT>
<FONT color=#a020f0>#define wxSTC_CMD_PAGEDOWN </FONT><FONT color=#ff00ff>2322</FONT> <FONT color=#a020f0>#define wxSTC_CMD_PAGEDOWN </FONT><FONT color=#ff00ff>2322</FONT>
<FONT color=#0000ff>// Move caret one page down extending selection to new caret position.</FONT>
<FONT color=#a020f0>#define wxSTC_CMD_PAGEDOWNEXTEND </FONT><FONT color=#ff00ff>2323</FONT> <FONT color=#a020f0>#define wxSTC_CMD_PAGEDOWNEXTEND </FONT><FONT color=#ff00ff>2323</FONT>
<FONT color=#0000ff>// Switch from insert to overtype mode or the reverse.</FONT>
<FONT color=#a020f0>#define wxSTC_CMD_EDITTOGGLEOVERTYPE </FONT><FONT color=#ff00ff>2324</FONT> <FONT color=#a020f0>#define wxSTC_CMD_EDITTOGGLEOVERTYPE </FONT><FONT color=#ff00ff>2324</FONT>
<FONT color=#0000ff>// Cancel any modes such as call tip or auto-completion list display.</FONT>
<FONT color=#a020f0>#define wxSTC_CMD_CANCEL </FONT><FONT color=#ff00ff>2325</FONT> <FONT color=#a020f0>#define wxSTC_CMD_CANCEL </FONT><FONT color=#ff00ff>2325</FONT>
<FONT color=#0000ff>// Delete the selection or if no selection, the character before the caret.</FONT>
<FONT color=#a020f0>#define wxSTC_CMD_DELETEBACK </FONT><FONT color=#ff00ff>2326</FONT> <FONT color=#a020f0>#define wxSTC_CMD_DELETEBACK </FONT><FONT color=#ff00ff>2326</FONT>
<FONT color=#0000ff>// If selection is empty or all on one line replace the selection with a tab</FONT>
<FONT color=#0000ff>// character.</FONT>
<FONT color=#0000ff>// If more than one line selected, indent the lines.</FONT>
<FONT color=#a020f0>#define wxSTC_CMD_TAB </FONT><FONT color=#ff00ff>2327</FONT> <FONT color=#a020f0>#define wxSTC_CMD_TAB </FONT><FONT color=#ff00ff>2327</FONT>
<FONT color=#0000ff>// Dedent the selected lines.</FONT>
<FONT color=#a020f0>#define wxSTC_CMD_BACKTAB </FONT><FONT color=#ff00ff>2328</FONT> <FONT color=#a020f0>#define wxSTC_CMD_BACKTAB </FONT><FONT color=#ff00ff>2328</FONT>
<FONT color=#0000ff>// Insert a new line, may use a CRLF, CR or LF depending on EOL mode.</FONT>
<FONT color=#a020f0>#define wxSTC_CMD_NEWLINE </FONT><FONT color=#ff00ff>2329</FONT> <FONT color=#a020f0>#define wxSTC_CMD_NEWLINE </FONT><FONT color=#ff00ff>2329</FONT>
<FONT color=#0000ff>// Insert a Form Feed character.</FONT>
<FONT color=#a020f0>#define wxSTC_CMD_FORMFEED </FONT><FONT color=#ff00ff>2330</FONT> <FONT color=#a020f0>#define wxSTC_CMD_FORMFEED </FONT><FONT color=#ff00ff>2330</FONT>
<FONT color=#0000ff>// Move caret to before first visible character on line.</FONT>
<FONT color=#0000ff>// If already there move to first character on line.</FONT>
<FONT color=#a020f0>#define wxSTC_CMD_VCHOME </FONT><FONT color=#ff00ff>2331</FONT> <FONT color=#a020f0>#define wxSTC_CMD_VCHOME </FONT><FONT color=#ff00ff>2331</FONT>
<FONT color=#0000ff>// Like VCHome but extending selection to new caret position.</FONT>
<FONT color=#a020f0>#define wxSTC_CMD_VCHOMEEXTEND </FONT><FONT color=#ff00ff>2332</FONT> <FONT color=#a020f0>#define wxSTC_CMD_VCHOMEEXTEND </FONT><FONT color=#ff00ff>2332</FONT>
<FONT color=#0000ff>// Magnify the displayed text by increasing the sizes by 1 point.</FONT>
<FONT color=#a020f0>#define wxSTC_CMD_ZOOMIN </FONT><FONT color=#ff00ff>2333</FONT> <FONT color=#a020f0>#define wxSTC_CMD_ZOOMIN </FONT><FONT color=#ff00ff>2333</FONT>
<FONT color=#0000ff>// Make the displayed text smaller by decreasing the sizes by 1 point.</FONT>
<FONT color=#a020f0>#define wxSTC_CMD_ZOOMOUT </FONT><FONT color=#ff00ff>2334</FONT> <FONT color=#a020f0>#define wxSTC_CMD_ZOOMOUT </FONT><FONT color=#ff00ff>2334</FONT>
<FONT color=#0000ff>// Delete the word to the left of the caret.</FONT>
<FONT color=#a020f0>#define wxSTC_CMD_DELWORDLEFT </FONT><FONT color=#ff00ff>2335</FONT> <FONT color=#a020f0>#define wxSTC_CMD_DELWORDLEFT </FONT><FONT color=#ff00ff>2335</FONT>
<FONT color=#0000ff>// Delete the word to the right of the caret.</FONT>
<FONT color=#a020f0>#define wxSTC_CMD_DELWORDRIGHT </FONT><FONT color=#ff00ff>2336</FONT> <FONT color=#a020f0>#define wxSTC_CMD_DELWORDRIGHT </FONT><FONT color=#ff00ff>2336</FONT>
<FONT color=#0000ff>// Cut the line containing the caret.</FONT>
<FONT color=#a020f0>#define wxSTC_CMD_LINECUT </FONT><FONT color=#ff00ff>2337</FONT> <FONT color=#a020f0>#define wxSTC_CMD_LINECUT </FONT><FONT color=#ff00ff>2337</FONT>
<FONT color=#0000ff>// Delete the line containing the caret.</FONT>
<FONT color=#a020f0>#define wxSTC_CMD_LINEDELETE </FONT><FONT color=#ff00ff>2338</FONT> <FONT color=#a020f0>#define wxSTC_CMD_LINEDELETE </FONT><FONT color=#ff00ff>2338</FONT>
<FONT color=#0000ff>// Switch the current line with the previous.</FONT>
<FONT color=#a020f0>#define wxSTC_CMD_LINETRANSPOSE </FONT><FONT color=#ff00ff>2339</FONT> <FONT color=#a020f0>#define wxSTC_CMD_LINETRANSPOSE </FONT><FONT color=#ff00ff>2339</FONT>
<FONT color=#0000ff>// Transform the selection to lower case.</FONT>
<FONT color=#a020f0>#define wxSTC_CMD_LOWERCASE </FONT><FONT color=#ff00ff>2340</FONT> <FONT color=#a020f0>#define wxSTC_CMD_LOWERCASE </FONT><FONT color=#ff00ff>2340</FONT>
<FONT color=#0000ff>// Transform the selection to upper case.</FONT>
<FONT color=#a020f0>#define wxSTC_CMD_UPPERCASE </FONT><FONT color=#ff00ff>2341</FONT> <FONT color=#a020f0>#define wxSTC_CMD_UPPERCASE </FONT><FONT color=#ff00ff>2341</FONT>
<FONT color=#0000ff>// Scroll the document down, keeping the caret visible.</FONT>
<FONT color=#a020f0>#define wxSTC_CMD_LINESCROLLDOWN </FONT><FONT color=#ff00ff>2342</FONT> <FONT color=#a020f0>#define wxSTC_CMD_LINESCROLLDOWN </FONT><FONT color=#ff00ff>2342</FONT>
<FONT color=#0000ff>// Scroll the document up, keeping the caret visible.</FONT>
<FONT color=#a020f0>#define wxSTC_CMD_LINESCROLLUP </FONT><FONT color=#ff00ff>2343</FONT> <FONT color=#a020f0>#define wxSTC_CMD_LINESCROLLUP </FONT><FONT color=#ff00ff>2343</FONT>
<FONT color=#0000ff>// Delete the selection or if no selection, the character before the caret.</FONT>
<FONT color=#0000ff>// Will not delete the chraacter before at the start of a line.</FONT>
<FONT color=#a020f0>#define wxSTC_CMD_DELETEBACKNOTLINE </FONT><FONT color=#ff00ff>2344</FONT> <FONT color=#a020f0>#define wxSTC_CMD_DELETEBACKNOTLINE </FONT><FONT color=#ff00ff>2344</FONT>
<FONT color=#a020f0>#define wxSTC_EDGE_NONE </FONT><FONT color=#ff00ff>0</FONT> <FONT color=#a020f0>#define wxSTC_EDGE_NONE </FONT><FONT color=#ff00ff>0</FONT>
<FONT color=#a020f0>#define wxSTC_EDGE_LINE </FONT><FONT color=#ff00ff>1</FONT> <FONT color=#a020f0>#define wxSTC_EDGE_LINE </FONT><FONT color=#ff00ff>1</FONT>
@@ -742,7 +848,7 @@
<B><FONT color=#2e8b57>void</FONT></B> AddText(<B><FONT color=#2e8b57>const</FONT></B> wxString&amp; text); <B><FONT color=#2e8b57>void</FONT></B> AddText(<B><FONT color=#2e8b57>const</FONT></B> wxString&amp; text);
<FONT color=#0000ff>// Add array of cells to document</FONT> <FONT color=#0000ff>// Add array of cells to document</FONT>
<B><FONT color=#2e8b57>void</FONT></B> AddStyledText(<B><FONT color=#2e8b57>const</FONT></B> wxString&amp; text); <B><FONT color=#2e8b57>void</FONT></B> AddStyledText(<B><FONT color=#2e8b57>const</FONT></B> wxMemoryBuffer&amp; data);
<FONT color=#0000ff>// Insert string at a position</FONT> <FONT color=#0000ff>// Insert string at a position</FONT>
<B><FONT color=#2e8b57>void</FONT></B> InsertText(<B><FONT color=#2e8b57>int</FONT></B> pos, <B><FONT color=#2e8b57>const</FONT></B> wxString&amp; text); <B><FONT color=#2e8b57>void</FONT></B> InsertText(<B><FONT color=#2e8b57>int</FONT></B> pos, <B><FONT color=#2e8b57>const</FONT></B> wxString&amp; text);
@@ -783,7 +889,7 @@
<B><FONT color=#2e8b57>void</FONT></B> SetSavePoint(); <B><FONT color=#2e8b57>void</FONT></B> SetSavePoint();
<FONT color=#0000ff>// Retrieve a buffer of cells.</FONT> <FONT color=#0000ff>// Retrieve a buffer of cells.</FONT>
wxString GetStyledText(<B><FONT color=#2e8b57>int</FONT></B> startPos, <B><FONT color=#2e8b57>int</FONT></B> endPos); wxMemoryBuffer GetStyledText(<B><FONT color=#2e8b57>int</FONT></B> startPos, <B><FONT color=#2e8b57>int</FONT></B> endPos);
<FONT color=#0000ff>// Are there any redoable actions in the undo history.</FONT> <FONT color=#0000ff>// Are there any redoable actions in the undo history.</FONT>
<B><FONT color=#2e8b57>bool</FONT></B> CanRedo(); <B><FONT color=#2e8b57>bool</FONT></B> CanRedo();
@@ -865,7 +971,6 @@
<B><FONT color=#2e8b57>int</FONT></B> GetTabWidth(); <B><FONT color=#2e8b57>int</FONT></B> GetTabWidth();
<FONT color=#0000ff>// Set the code page used to interpret the bytes of the document as characters.</FONT> <FONT color=#0000ff>// Set the code page used to interpret the bytes of the document as characters.</FONT>
<FONT color=#0000ff>// The SC_CP_UTF8 value can be used to enter Unicode mode.</FONT>
<B><FONT color=#2e8b57>void</FONT></B> SetCodePage(<B><FONT color=#2e8b57>int</FONT></B> codePage); <B><FONT color=#2e8b57>void</FONT></B> SetCodePage(<B><FONT color=#2e8b57>int</FONT></B> codePage);
<FONT color=#0000ff>// Set the symbol used for a particular marker number,</FONT> <FONT color=#0000ff>// Set the symbol used for a particular marker number,</FONT>
@@ -955,6 +1060,9 @@
<FONT color=#0000ff>// Set a style to be mixed case, or to force upper or lower case.</FONT> <FONT color=#0000ff>// Set a style to be mixed case, or to force upper or lower case.</FONT>
<B><FONT color=#2e8b57>void</FONT></B> StyleSetCase(<B><FONT color=#2e8b57>int</FONT></B> style, <B><FONT color=#2e8b57>int</FONT></B> caseForce); <B><FONT color=#2e8b57>void</FONT></B> StyleSetCase(<B><FONT color=#2e8b57>int</FONT></B> style, <B><FONT color=#2e8b57>int</FONT></B> caseForce);
<FONT color=#0000ff>// Set the character set of the font in a style.</FONT>
<B><FONT color=#2e8b57>void</FONT></B> StyleSetCharacterSet(<B><FONT color=#2e8b57>int</FONT></B> style, <B><FONT color=#2e8b57>int</FONT></B> characterSet);
<FONT color=#0000ff>// Set the foreground colour of the selection and whether to use this setting.</FONT> <FONT color=#0000ff>// Set the foreground colour of the selection and whether to use this setting.</FONT>
<B><FONT color=#2e8b57>void</FONT></B> SetSelForeground(<B><FONT color=#2e8b57>bool</FONT></B> useSetting, <B><FONT color=#2e8b57>const</FONT></B> wxColour&amp; fore); <B><FONT color=#2e8b57>void</FONT></B> SetSelForeground(<B><FONT color=#2e8b57>bool</FONT></B> useSetting, <B><FONT color=#2e8b57>const</FONT></B> wxColour&amp; fore);
@@ -1446,10 +1554,6 @@
<FONT color=#0000ff>// Retrieve the degree of caching of layout information</FONT> <FONT color=#0000ff>// Retrieve the degree of caching of layout information</FONT>
<B><FONT color=#2e8b57>int</FONT></B> GetLayoutCache(); <B><FONT color=#2e8b57>int</FONT></B> GetLayoutCache();
<FONT color=#0000ff>// Delete the selection or if no selection, the character before the caret.</FONT>
<FONT color=#0000ff>// Will not delete the chraacter before at the start of a line.</FONT>
<B><FONT color=#2e8b57>void</FONT></B> DeleteBackNotLine();
<FONT color=#0000ff>// Move the caret inside current view if it's not there already</FONT> <FONT color=#0000ff>// Move the caret inside current view if it's not there already</FONT>
<B><FONT color=#2e8b57>void</FONT></B> MoveCaretInsideView(); <B><FONT color=#2e8b57>void</FONT></B> MoveCaretInsideView();
@@ -1762,7 +1866,7 @@
<B><FONT color=#2e8b57>void</FONT></B> SetKey(<B><FONT color=#2e8b57>int</FONT></B> k) { m_key = k; } <B><FONT color=#2e8b57>void</FONT></B> SetKey(<B><FONT color=#2e8b57>int</FONT></B> k) { m_key = k; }
<B><FONT color=#2e8b57>void</FONT></B> SetModifiers(<B><FONT color=#2e8b57>int</FONT></B> m) { m_modifiers = m; } <B><FONT color=#2e8b57>void</FONT></B> SetModifiers(<B><FONT color=#2e8b57>int</FONT></B> m) { m_modifiers = m; }
<B><FONT color=#2e8b57>void</FONT></B> SetModificationType(<B><FONT color=#2e8b57>int</FONT></B> t) { m_modificationType = t; } <B><FONT color=#2e8b57>void</FONT></B> SetModificationType(<B><FONT color=#2e8b57>int</FONT></B> t) { m_modificationType = t; }
<B><FONT color=#2e8b57>void</FONT></B> SetText(<B><FONT color=#2e8b57>const</FONT></B> <B><FONT color=#2e8b57>char</FONT></B>* t) { m_text = t; } <B><FONT color=#2e8b57>void</FONT></B> SetText(<B><FONT color=#2e8b57>const</FONT></B> wxString&amp; t) { m_text = t; }
<B><FONT color=#2e8b57>void</FONT></B> SetLength(<B><FONT color=#2e8b57>int</FONT></B> len) { m_length = len; } <B><FONT color=#2e8b57>void</FONT></B> SetLength(<B><FONT color=#2e8b57>int</FONT></B> len) { m_length = len; }
<B><FONT color=#2e8b57>void</FONT></B> SetLinesAdded(<B><FONT color=#2e8b57>int</FONT></B> num) { m_linesAdded = num; } <B><FONT color=#2e8b57>void</FONT></B> SetLinesAdded(<B><FONT color=#2e8b57>int</FONT></B> num) { m_linesAdded = num; }
<B><FONT color=#2e8b57>void</FONT></B> SetLine(<B><FONT color=#2e8b57>int</FONT></B> val) { m_line = val; } <B><FONT color=#2e8b57>void</FONT></B> SetLine(<B><FONT color=#2e8b57>int</FONT></B> val) { m_line = val; }

View File

@@ -107,7 +107,7 @@ class MySTC(wxStyledTextCtrl):
evt.GetPosition(), evt.GetPosition(),
evt.GetLinesAdded(), evt.GetLinesAdded(),
evt.GetLength(), evt.GetLength(),
evt.GetText() )) repr(evt.GetText()) ))
def transModType(self, modType): def transModType(self, modType):
@@ -153,7 +153,23 @@ def runTest(frame, nb, log):
p.SetSizer(s) p.SetSizer(s)
p.SetAutoLayout(true) p.SetAutoLayout(true)
## ed.SetBufferedDraw(false)
## ed.StyleClearAll()
ed.SetText(demoText) ed.SetText(demoText)
if wxUSE_UNICODE:
import codecs
decode = codecs.lookup("utf-8")[1]
ed.GotoPos(ed.GetLength())
ed.AddText("\n\nwxStyledTextCtrl can also do Unicode:\n")
unitext, l = decode('\xd0\x9f\xd0\xb8\xd1\x82\xd0\xbe\xd0\xbd - '
'\xd0\xbb\xd1\x83\xd1\x87\xd1\x88\xd0\xb8\xd0\xb9 '
'\xd1\x8f\xd0\xb7\xd1\x8b\xd0\xba \xd0\xbf\xd1\x80\xd0\xbe\xd0\xb3\xd1\x80\xd0\xb0\xd0\xbc\xd0\xbc\xd0\xb8\xd1\x80\xd0\xbe\xd0\xb2\xd0\xb0\xd0\xbd\xd0\xb8\xd1\x8f!\n\n')
ed.AddText('\tRussian: ')
ed.AddText(unitext)
ed.GotoPos(0)
ed.EmptyUndoBuffer() ed.EmptyUndoBuffer()
# make some styles # make some styles
@@ -163,8 +179,7 @@ def runTest(frame, nb, log):
ed.StyleSetSpec(3, "face:%s,bold,size:%d" % (face2, pb+2)) ed.StyleSetSpec(3, "face:%s,bold,size:%d" % (face2, pb+2))
ed.StyleSetSpec(4, "face:%s,size:%d" % (face1, pb-1)) ed.StyleSetSpec(4, "face:%s,size:%d" % (face1, pb-1))
# Now set some text to those styles... Normally this would be
# now set some text to those styles... Normally this would be
# done in an event handler that happens when text needs displayed. # done in an event handler that happens when text needs displayed.
ed.StartStyling(98, 0xff) ed.StartStyling(98, 0xff)
ed.SetStyling(6, 1) # set style for 6 characters using style 1 ed.SetStyling(6, 1) # set style for 6 characters using style 1
@@ -211,6 +226,7 @@ def runTest(frame, nb, log):
ed.SetStyling(10, wxSTC_INDIC1_MASK) ed.SetStyling(10, wxSTC_INDIC1_MASK)
ed.SetStyling(10, wxSTC_INDIC2_MASK | wxSTC_INDIC1_MASK) ed.SetStyling(10, wxSTC_INDIC2_MASK | wxSTC_INDIC1_MASK)
# some test stuff... # some test stuff...
if debug: if debug:
print "GetTextLength(): ", ed.GetTextLength(), len(ed.GetText()) print "GetTextLength(): ", ed.GetTextLength(), len(ed.GetText())

View File

@@ -465,7 +465,7 @@ if BUILD_GLCANVAS or GL_ONLY:
other_sources = [] other_sources = []
swig_sources = run_swig(swig_files, location, GENDIR, PKGDIR, swig_sources = run_swig(swig_files, location, GENDIR, PKGDIR,
USE_SWIG, swig_force, swig_args) USE_SWIG, swig_force, swig_args, swig_deps)
gl_libs = [] gl_libs = []
if os.name == 'posix': if os.name == 'posix':
@@ -507,7 +507,7 @@ if not GL_ONLY and BUILD_OGL:
'oglcanvas.i'] 'oglcanvas.i']
swig_sources = run_swig(swig_files, location, '', PKGDIR, swig_sources = run_swig(swig_files, location, '', PKGDIR,
USE_SWIG, swig_force, swig_args) USE_SWIG, swig_force, swig_args, swig_deps)
if IN_CVS_TREE: if IN_CVS_TREE:
# make sure local copy of contrib files are up to date # make sure local copy of contrib files are up to date
@@ -577,7 +577,7 @@ if not GL_ONLY and BUILD_STC:
swig_sources = run_swig(swig_files, location, GENDIR, PKGDIR, swig_sources = run_swig(swig_files, location, GENDIR, PKGDIR,
USE_SWIG, swig_force, USE_SWIG, swig_force,
swig_args + ['-I'+STC_H, '-I'+location], swig_args + ['-I'+STC_H, '-I'+location],
[opj(STC_H, 'stc.h')]) [opj(STC_H, 'stc.h')] + swig_deps)
# copy a contrib project specific py module to the main package dir # copy a contrib project specific py module to the main package dir
copy_file(opj(location, 'stc.py'), PKGDIR, update=1, verbose=0) copy_file(opj(location, 'stc.py'), PKGDIR, update=1, verbose=0)
@@ -666,7 +666,7 @@ if not GL_ONLY and BUILD_IEWIN:
swig_files = ['iewin.i', ] swig_files = ['iewin.i', ]
swig_sources = run_swig(swig_files, location, '', PKGDIR, swig_sources = run_swig(swig_files, location, '', PKGDIR,
USE_SWIG, swig_force, swig_args) USE_SWIG, swig_force, swig_args, swig_deps)
ext = Extension('iewinc', ['%s/IEHtmlWin.cpp' % location, ext = Extension('iewinc', ['%s/IEHtmlWin.cpp' % location,
@@ -698,7 +698,7 @@ if not GL_ONLY and BUILD_XRC:
swig_files = ['xrc.i'] swig_files = ['xrc.i']
swig_sources = run_swig(swig_files, location, '', PKGDIR, swig_sources = run_swig(swig_files, location, '', PKGDIR,
USE_SWIG, swig_force, swig_args) USE_SWIG, swig_force, swig_args, swig_deps)
xmlres_includes = includes[:] xmlres_includes = includes[:]
xmlres_includes.append('%s/expat/xmlparse' % XMLLOC) xmlres_includes.append('%s/expat/xmlparse' % XMLLOC)
@@ -786,7 +786,7 @@ if not GL_ONLY and BUILD_GIZMOS:
swig_files = ['gizmos.i'] swig_files = ['gizmos.i']
swig_sources = run_swig(swig_files, location, '', PKGDIR, swig_sources = run_swig(swig_files, location, '', PKGDIR,
USE_SWIG, swig_force, swig_args) USE_SWIG, swig_force, swig_args, swig_deps)
gizmos_includes = includes[:] gizmos_includes = includes[:]
gizmos_includes.append(GIZMOINC) gizmos_includes.append(GIZMOINC)
@@ -829,7 +829,7 @@ if not GL_ONLY and BUILD_DLLWIDGET:
swig_files = ['dllwidget_.i'] swig_files = ['dllwidget_.i']
swig_sources = run_swig(swig_files, location, '', PKGDIR, swig_sources = run_swig(swig_files, location, '', PKGDIR,
USE_SWIG, swig_force, swig_args) USE_SWIG, swig_force, swig_args, swig_deps)
# copy a contrib project specific py module to the main package dir # copy a contrib project specific py module to the main package dir
copy_file(opj(location, 'dllwidget.py'), PKGDIR, update=1, verbose=0) copy_file(opj(location, 'dllwidget.py'), PKGDIR, update=1, verbose=0)

View File

@@ -188,6 +188,32 @@ $function
//---------------------------------------------------------------------------
%typemap(python, in) wxMemoryBuffer& {
if (!PyString_Check($source)) {
PyErr_SetString(PyExc_TypeError, "String buffer expected");
return NULL;
}
char* str = PyString_AS_STRING($source);
int len = PyString_GET_SIZE($source);
$target = new wxMemoryBuffer(len);
memcpy($target->GetData(), str, len);
}
%typemap(python, freearg) wxMemoryBuffer& {
if ($target)
delete $source;
}
%typemap(python, out) wxMemoryBuffer {
$target = PyString_FromStringAndSize((char*)$source->GetData(), $source->GetDataLen());
}
%typemap(python, ret) wxMemoryBuffer {
delete $source;
}
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------