#endif
//----------------------------------------------------------------------
+// Utility functions used within wxSTC
+
+#ifndef SWIG
+
+inline wxString stc2wx(const char* str) {
+#if wxUSE_UNICODE
+ return wxString(str, wxConvUTF8);
+#else
+ return wxString(str);
+#endif
+}
+
+inline wxString stc2wx(const char* str, size_t len) {
+#if wxUSE_UNICODE
+ return wxString(str, wxConvUTF8, len);
+#else
+ return wxString(str, len);
+#endif
+}
+
+#if wxUSE_UNICODE
+inline const wxWX2MBbuf wx2stc(const wxString& str) {
+ return str.mb_str(wxConvUTF8);
+}
+#else
+inline const wxWX2MBbuf wx2stc(const wxString& str) {
+ return str.mbc_str();
+}
+#endif
+
+#endif
+
+
//----------------------------------------------------------------------
#endif
italic ? wxITALIC : wxNORMAL,
bold ? wxBOLD : wxNORMAL,
false,
- wxString(faceName, wxConvUTF8),
+ stc2wx(faceName),
encoding);
}
hdc->SetTextBackground(wxColourFromCA(back));
FillRectangle(rc, back);
- // will convert from UTF-8 in unicode mode
- wxString str(s, wxConvUTF8, len);
-
// 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...
- hdc->DrawText(str, rc.left, ybase - font.ascent);
+ hdc->DrawText(stc2wx(s, len), rc.left, ybase - font.ascent);
}
void SurfaceImpl::DrawTextClipped(PRectangle rc, Font &font, int ybase,
FillRectangle(rc, back);
hdc->SetClippingRegion(wxRectFromPRectangle(rc));
- // will convert from UTF-8 in unicode mode
- wxString str(s, wxConvUTF8, len);
-
// see comments above
- hdc->DrawText(str, rc.left, ybase - font.ascent);
+ hdc->DrawText(stc2wx(s, len), rc.left, ybase - font.ascent);
hdc->DestroyClippingRegion();
}
int w;
int h;
- // will convert from UTF-8 in unicode mode
- wxString str(s, wxConvUTF8, len);
-
- hdc->GetTextExtent(str, &w, &h);
+ hdc->GetTextExtent(stc2wx(s, len), &w, &h);
return w;
}
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);
+ wxString str = stc2wx(s, len);
SetFont(font);
// Calculate the position of each character based on the widths of
int h;
char s[2] = { ch, 0 };
- // will convert from UTF-8 in unicode mode
- wxString str(s, wxConvUTF8, 1);
- hdc->GetTextExtent(str, &w, &h);
+ hdc->GetTextExtent(stc2wx(s, 1), &w, &h);
return w;
}
void Window::SetTitle(const char *s) {
- // will convert from UTF-8 in unicode mode
- wxString str(s, wxConvUTF8);
- GETWIN(id)->SetTitle(str);
+ GETWIN(id)->SetTitle(stc2wx(s));
}
void ListBox::GetValue(int n, char *value, int len) {
wxString text = GETLB(id)->GetString(n);
- strncpy(value, text.mb_str(wxConvUTF8), len);
+ strncpy(value, wx2stc(text), len);
value[len-1] = '\0';
}
}
void Platform::DebugDisplay(const char *s) {
- wxLogDebug(wxString(s, *wxConvCurrent));
+ wxLogDebug(stc2wx(s));
}
bool Platform::IsKeyDown(int key) {
char buffer[2000];
sprintf(buffer, "Assertion [%s] failed at %s %d", c, file, line);
if (assertionPopUps) {
- int idButton = wxMessageBox(wxString(buffer, *wxConvCurrent),
- wxT("Assertion failure"),
- wxICON_HAND | wxOK);
+ /*int idButton = */
+ wxMessageBox(stc2wx(buffer),
+ wxT("Assertion failure"),
+ wxICON_HAND | wxOK);
// if (idButton == IDRETRY) {
// ::DebugBreak();
// } else if (idButton == IDIGNORE) {
void ScintillaWX::StartDrag() {
#if wxUSE_DRAG_AND_DROP
- wxString dragText(drag.s, wxConvUTF8, drag.len);
+ wxString dragText = stc2wx(drag.s, drag.len);
// Send an event to allow the drag text to be changed
wxStyledTextEvent evt(wxEVT_STC_START_DRAG, stc->GetId());
SelectionText st;
CopySelectionRange(&st);
wxTheClipboard->Open();
- wxString text(st.s, wxConvUTF8, st.len);
+ wxString text = stc2wx(st.s, st.len);
wxTheClipboard->SetData(new wxTextDataObject(text));
wxTheClipboard->Close();
}
gotData = wxTheClipboard->GetData(data);
wxTheClipboard->Close();
if (gotData) {
- wxWX2MBbuf buf = (wxWX2MBbuf)data.GetText().mb_str(wxConvUTF8);
+ wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(data.GetText());
int len = strlen(buf);
pdoc->InsertString(currentPos, buf, len);
SetEmptySelection(currentPos + len);
if (!label[0])
((wxMenu*)popup.GetID())->AppendSeparator();
else
- ((wxMenu*)popup.GetID())->Append(cmd, wxString(label, *wxConvCurrent));
+ ((wxMenu*)popup.GetID())->Append(cmd, stc2wx(label));
if (!enabled)
((wxMenu*)popup.GetID())->Enable(cmd, enabled);
dragResult = evt.GetDragResult();
if (dragResult == wxDragMove || dragResult == wxDragCopy) {
DropAt(evt.GetPosition(),
- evt.GetDragText().mb_str(wxConvUTF8),
+ wx2stc(evt.GetDragText()),
dragResult == wxDragMove,
FALSE); // TODO: rectangular?
return TRUE;
'void %s(const wxString& text);',
'''void %s(const wxString& text) {
- wxWX2MBbuf buf = (wxWX2MBbuf)text.mb_str(wxConvUTF8);
+ wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(text);
SendMsg(%s, strlen(buf), (long)(const char*)buf);''',
0),
mbuf.UngetWriteBuf(len);
mbuf.AppendByte(0);
if (linePos) *linePos = pos;
- return wxString(buf, wxConvUTF8);''',
+ return stc2wx(buf);''',
0),
flags |= wholeWord ? SCFIND_WHOLEWORD : 0;
ft.chrg.cpMin = minPos;
ft.chrg.cpMax = maxPos;
- ft.lpstrText = (char*)(const char*)text.mb_str(wxConvUTF8);
+ ft.lpstrText = (char*)(const char*)wx2stc(text);
return SendMsg(%s, flags, (long)&ft);''',
0),
SendMsg(%s, line, (long)buf);
mbuf.UngetWriteBuf(len);
mbuf.AppendByte(0);
- return wxString(buf, wxConvUTF8);''',
+ return stc2wx(buf);''',
('Retrieve the contents of a line.',)),
SendMsg(%s, 0, (long)buf);
mbuf.UngetWriteBuf(len);
mbuf.AppendByte(0);
- return wxString(buf, wxConvUTF8);''',
+ return stc2wx(buf);''',
('Retrieve the selected text.',)),
SendMsg(%s, 0, (long)&tr);
mbuf.UngetWriteBuf(len);
mbuf.AppendByte(0);
- return wxString(buf, wxConvUTF8);''',
+ return stc2wx(buf);''',
('Retrieve a range of text.',)),
SendMsg(%s, len+1, (long)buf);
mbuf.UngetWriteBuf(len);
mbuf.AppendByte(0);
- return wxString(buf, wxConvUTF8);''',
+ return stc2wx(buf);''',
('Retrieve all the text in the document.', )),
'''
int %s(const wxString& text) {
- wxWX2MBbuf buf = (wxWX2MBbuf)text.mb_str(wxConvUTF8);
+ wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(text);
return SendMsg(%s, strlen(buf), (long)(const char*)buf);''',
0),
'''
int %s(const wxString& text) {
- wxWX2MBbuf buf = (wxWX2MBbuf)text.mb_str(wxConvUTF8);
+ wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(text);
return SendMsg(%s, strlen(buf), (long)(const char*)buf);''',
0),
'''
int %s(const wxString& text) {
- wxWX2MBbuf buf = (wxWX2MBbuf)text.mb_str(wxConvUTF8);
+ wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(text);
return SendMsg(%s, strlen(buf), (long)(const char*)buf);''',
0),
typ, name = param
if typ == 'string':
- return '(long)(const char*)%s.mb_str(wxConvUTF8)' % name
+ return '(long)(const char*)wx2stc(%s)' % name
if typ == 'colour':
return 'wxColourAsLong(%s)' % name
// Add text to the document
void wxStyledTextCtrl::AddText(const wxString& text) {
- wxWX2MBbuf buf = (wxWX2MBbuf)text.mb_str(wxConvUTF8);
+ wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(text);
SendMsg(2001, strlen(buf), (long)(const char*)buf);
}
// Insert string at a position
void wxStyledTextCtrl::InsertText(int pos, const wxString& text) {
- SendMsg(2003, pos, (long)(const char*)text.mb_str(wxConvUTF8));
+ SendMsg(2003, pos, (long)(const char*)wx2stc(text));
}
// Delete all text in the document
mbuf.UngetWriteBuf(len);
mbuf.AppendByte(0);
if (linePos) *linePos = pos;
- return wxString(buf, wxConvUTF8);
+ return stc2wx(buf);
}
// Retrieve the position of the last correctly styled character.
// Set the font of a style.
void wxStyledTextCtrl::StyleSetFaceName(int style, const wxString& fontName) {
- SendMsg(2056, style, (long)(const char*)fontName.mb_str(wxConvUTF8));
+ SendMsg(2056, style, (long)(const char*)wx2stc(fontName));
}
// Set a style to have its end of line filled or not.
// Set the set of characters making up words for when moving or selecting
// by word.
void wxStyledTextCtrl::SetWordChars(const wxString& characters) {
- SendMsg(2077, 0, (long)(const char*)characters.mb_str(wxConvUTF8));
+ SendMsg(2077, 0, (long)(const char*)wx2stc(characters));
}
// Start a sequence of actions that is undone and redone as a unit.
// The lenEntered parameter indicates how many characters before
// the caret should be used to provide context.
void wxStyledTextCtrl::AutoCompShow(int lenEntered, const wxString& itemList) {
- SendMsg(2100, lenEntered, (long)(const char*)itemList.mb_str(wxConvUTF8));
+ SendMsg(2100, lenEntered, (long)(const char*)wx2stc(itemList));
}
// Remove the auto-completion list from the screen.
// Define a set of character that when typed cancel the auto-completion list.
void wxStyledTextCtrl::AutoCompStops(const wxString& characterSet) {
- SendMsg(2105, 0, (long)(const char*)characterSet.mb_str(wxConvUTF8));
+ SendMsg(2105, 0, (long)(const char*)wx2stc(characterSet));
}
// Change the separator character in the string setting up an auto-completion
// Select the item in the auto-completion list that starts with a string.
void wxStyledTextCtrl::AutoCompSelect(const wxString& text) {
- SendMsg(2108, 0, (long)(const char*)text.mb_str(wxConvUTF8));
+ SendMsg(2108, 0, (long)(const char*)wx2stc(text));
}
// Should the auto-completion list be cancelled if the user backspaces to a
// Define a set of characters that when typed will cause the autocompletion to
// choose the selected item.
void wxStyledTextCtrl::AutoCompSetFillUps(const wxString& characterSet) {
- SendMsg(2112, 0, (long)(const char*)characterSet.mb_str(wxConvUTF8));
+ SendMsg(2112, 0, (long)(const char*)wx2stc(characterSet));
}
// Should a single item auto-completion list automatically choose the item.
// Display a list of strings and send notification when user chooses one.
void wxStyledTextCtrl::UserListShow(int listType, const wxString& itemList) {
- SendMsg(2117, listType, (long)(const char*)itemList.mb_str(wxConvUTF8));
+ SendMsg(2117, listType, (long)(const char*)wx2stc(itemList));
}
// Set whether or not autocompletion is hidden automatically when nothing matches
flags |= wholeWord ? SCFIND_WHOLEWORD : 0;
ft.chrg.cpMin = minPos;
ft.chrg.cpMax = maxPos;
- ft.lpstrText = (char*)(const char*)text.mb_str(wxConvUTF8);
+ ft.lpstrText = (char*)(const char*)wx2stc(text);
return SendMsg(2150, flags, (long)&ft);
}
SendMsg(2153, line, (long)buf);
mbuf.UngetWriteBuf(len);
mbuf.AppendByte(0);
- return wxString(buf, wxConvUTF8);
+ return stc2wx(buf);
}
// Returns the number of lines in the document. There is always at least one.
SendMsg(2161, 0, (long)buf);
mbuf.UngetWriteBuf(len);
mbuf.AppendByte(0);
- return wxString(buf, wxConvUTF8);
+ return stc2wx(buf);
}
// Retrieve a range of text.
SendMsg(2162, 0, (long)&tr);
mbuf.UngetWriteBuf(len);
mbuf.AppendByte(0);
- return wxString(buf, wxConvUTF8);
+ return stc2wx(buf);
}
// Draw the selection in normal style or with selection highlighted.
// Replace the selected text with the argument text.
void wxStyledTextCtrl::ReplaceSelection(const wxString& text) {
- SendMsg(2170, 0, (long)(const char*)text.mb_str(wxConvUTF8));
+ SendMsg(2170, 0, (long)(const char*)wx2stc(text));
}
// Set to read only or read write.
// Replace the contents of the document with the argument text.
void wxStyledTextCtrl::SetText(const wxString& text) {
- SendMsg(2181, 0, (long)(const char*)text.mb_str(wxConvUTF8));
+ SendMsg(2181, 0, (long)(const char*)wx2stc(text));
}
// Retrieve all the text in the document.
SendMsg(2182, len+1, (long)buf);
mbuf.UngetWriteBuf(len);
mbuf.AppendByte(0);
- return wxString(buf, wxConvUTF8);
+ return stc2wx(buf);
}
// Retrieve the number of characters in the document.
// Returns the length of the replacement text.
int wxStyledTextCtrl::ReplaceTarget(const wxString& text) {
- wxWX2MBbuf buf = (wxWX2MBbuf)text.mb_str(wxConvUTF8);
+ wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(text);
return SendMsg(2194, strlen(buf), (long)(const char*)buf);
}
// caused by processing the \d patterns.
int wxStyledTextCtrl::ReplaceTargetRE(const wxString& text) {
- wxWX2MBbuf buf = (wxWX2MBbuf)text.mb_str(wxConvUTF8);
+ wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(text);
return SendMsg(2195, strlen(buf), (long)(const char*)buf);
}
// Returns length of range or -1 for failure in which case target is not moved.
int wxStyledTextCtrl::SearchInTarget(const wxString& text) {
- wxWX2MBbuf buf = (wxWX2MBbuf)text.mb_str(wxConvUTF8);
+ wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(text);
return SendMsg(2197, strlen(buf), (long)(const char*)buf);
}
// Show a call tip containing a definition near position pos.
void wxStyledTextCtrl::CallTipShow(int pos, const wxString& definition) {
- SendMsg(2200, pos, (long)(const char*)definition.mb_str(wxConvUTF8));
+ SendMsg(2200, pos, (long)(const char*)wx2stc(definition));
}
// Remove the call tip from the screen.
// Find some text starting at the search anchor.
// Does not ensure the selection is visible.
int wxStyledTextCtrl::SearchNext(int flags, const wxString& text) {
- return SendMsg(2367, flags, (long)(const char*)text.mb_str(wxConvUTF8));
+ return SendMsg(2367, flags, (long)(const char*)wx2stc(text));
}
// Find some text starting at the search anchor and moving backwards.
// Does not ensure the selection is visible.
int wxStyledTextCtrl::SearchPrev(int flags, const wxString& text) {
- return SendMsg(2368, flags, (long)(const char*)text.mb_str(wxConvUTF8));
+ return SendMsg(2368, flags, (long)(const char*)wx2stc(text));
}
// Set the way the line the caret is on is kept visible.
// Set up a value that may be used by a lexer for some optional feature.
void wxStyledTextCtrl::SetProperty(const wxString& key, const wxString& value) {
- SendMsg(4004, (long)(const char*)key.mb_str(wxConvUTF8), (long)(const char*)value.mb_str(wxConvUTF8));
+ SendMsg(4004, (long)(const char*)wx2stc(key), (long)(const char*)wx2stc(value));
}
// Set up the key words used by the lexer.
void wxStyledTextCtrl::SetKeyWords(int keywordSet, const wxString& keyWords) {
- SendMsg(4005, keywordSet, (long)(const char*)keyWords.mb_str(wxConvUTF8));
+ SendMsg(4005, keywordSet, (long)(const char*)wx2stc(keyWords));
}
// Set the lexing language of the document based on string name.
void wxStyledTextCtrl::SetLexerLanguage(const wxString& language) {
- SendMsg(4006, 0, (long)(const char*)language.mb_str(wxConvUTF8));
+ SendMsg(4006, 0, (long)(const char*)wx2stc(language));
}
// END of generated section
wxMemoryBuffer buf(scn.length+1);
buf.AppendData((void*)scn.text, scn.length);
buf.AppendByte(0);
- evt.SetText(wxString(buf, wxConvUTF8));
+ evt.SetText(stc2wx(buf));
}
evt.SetLength(scn.length);
evt.SetLinesAdded(scn.linesAdded);
wxMemoryBuffer buf(scn.length+1);
buf.AppendData((void*)scn.text, scn.length);
buf.AppendByte(0);
- evt.SetText(wxString(buf, wxConvUTF8));
+ evt.SetText(stc2wx(buf));
}
evt.SetLength(scn.length);
evt.SetLinesAdded(scn.linesAdded);
#endif
//----------------------------------------------------------------------
+// Utility functions used within wxSTC
+
+#ifndef SWIG
+
+inline wxString stc2wx(const char* str) {
+#if wxUSE_UNICODE
+ return wxString(str, wxConvUTF8);
+#else
+ return wxString(str);
+#endif
+}
+
+inline wxString stc2wx(const char* str, size_t len) {
+#if wxUSE_UNICODE
+ return wxString(str, wxConvUTF8, len);
+#else
+ return wxString(str, len);
+#endif
+}
+
+#if wxUSE_UNICODE
+inline const wxWX2MBbuf wx2stc(const wxString& str) {
+ return str.mb_str(wxConvUTF8);
+}
+#else
+inline const wxWX2MBbuf wx2stc(const wxString& str) {
+ return str.mbc_str();
+}
+#endif
+
+#endif
+
+
//----------------------------------------------------------------------
#endif
#endif
//----------------------------------------------------------------------
+// Utility functions used within wxSTC
+
+#ifndef SWIG
+
+inline wxString stc2wx(const char* str) {
+#if wxUSE_UNICODE
+ return wxString(str, wxConvUTF8);
+#else
+ return wxString(str);
+#endif
+}
+
+inline wxString stc2wx(const char* str, size_t len) {
+#if wxUSE_UNICODE
+ return wxString(str, wxConvUTF8, len);
+#else
+ return wxString(str, len);
+#endif
+}
+
+#if wxUSE_UNICODE
+inline const wxWX2MBbuf wx2stc(const wxString& str) {
+ return str.mb_str(wxConvUTF8);
+}
+#else
+inline const wxWX2MBbuf wx2stc(const wxString& str) {
+ return str.mbc_str();
+}
+#endif
+
+#endif
+
+
//----------------------------------------------------------------------
#endif
italic ? wxITALIC : wxNORMAL,
bold ? wxBOLD : wxNORMAL,
false,
- wxString(faceName, wxConvUTF8),
+ stc2wx(faceName),
encoding);
}
hdc->SetTextBackground(wxColourFromCA(back));
FillRectangle(rc, back);
- // will convert from UTF-8 in unicode mode
- wxString str(s, wxConvUTF8, len);
-
// 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...
- hdc->DrawText(str, rc.left, ybase - font.ascent);
+ hdc->DrawText(stc2wx(s, len), rc.left, ybase - font.ascent);
}
void SurfaceImpl::DrawTextClipped(PRectangle rc, Font &font, int ybase,
FillRectangle(rc, back);
hdc->SetClippingRegion(wxRectFromPRectangle(rc));
- // will convert from UTF-8 in unicode mode
- wxString str(s, wxConvUTF8, len);
-
// see comments above
- hdc->DrawText(str, rc.left, ybase - font.ascent);
+ hdc->DrawText(stc2wx(s, len), rc.left, ybase - font.ascent);
hdc->DestroyClippingRegion();
}
int w;
int h;
- // will convert from UTF-8 in unicode mode
- wxString str(s, wxConvUTF8, len);
-
- hdc->GetTextExtent(str, &w, &h);
+ hdc->GetTextExtent(stc2wx(s, len), &w, &h);
return w;
}
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);
+ wxString str = stc2wx(s, len);
SetFont(font);
// Calculate the position of each character based on the widths of
int h;
char s[2] = { ch, 0 };
- // will convert from UTF-8 in unicode mode
- wxString str(s, wxConvUTF8, 1);
- hdc->GetTextExtent(str, &w, &h);
+ hdc->GetTextExtent(stc2wx(s, 1), &w, &h);
return w;
}
void Window::SetTitle(const char *s) {
- // will convert from UTF-8 in unicode mode
- wxString str(s, wxConvUTF8);
- GETWIN(id)->SetTitle(str);
+ GETWIN(id)->SetTitle(stc2wx(s));
}
void ListBox::GetValue(int n, char *value, int len) {
wxString text = GETLB(id)->GetString(n);
- strncpy(value, text.mb_str(wxConvUTF8), len);
+ strncpy(value, wx2stc(text), len);
value[len-1] = '\0';
}
}
void Platform::DebugDisplay(const char *s) {
- wxLogDebug(wxString(s, *wxConvCurrent));
+ wxLogDebug(stc2wx(s));
}
bool Platform::IsKeyDown(int key) {
char buffer[2000];
sprintf(buffer, "Assertion [%s] failed at %s %d", c, file, line);
if (assertionPopUps) {
- int idButton = wxMessageBox(wxString(buffer, *wxConvCurrent),
- wxT("Assertion failure"),
- wxICON_HAND | wxOK);
+ /*int idButton = */
+ wxMessageBox(stc2wx(buffer),
+ wxT("Assertion failure"),
+ wxICON_HAND | wxOK);
// if (idButton == IDRETRY) {
// ::DebugBreak();
// } else if (idButton == IDIGNORE) {
void ScintillaWX::StartDrag() {
#if wxUSE_DRAG_AND_DROP
- wxString dragText(drag.s, wxConvUTF8, drag.len);
+ wxString dragText = stc2wx(drag.s, drag.len);
// Send an event to allow the drag text to be changed
wxStyledTextEvent evt(wxEVT_STC_START_DRAG, stc->GetId());
SelectionText st;
CopySelectionRange(&st);
wxTheClipboard->Open();
- wxString text(st.s, wxConvUTF8, st.len);
+ wxString text = stc2wx(st.s, st.len);
wxTheClipboard->SetData(new wxTextDataObject(text));
wxTheClipboard->Close();
}
gotData = wxTheClipboard->GetData(data);
wxTheClipboard->Close();
if (gotData) {
- wxWX2MBbuf buf = (wxWX2MBbuf)data.GetText().mb_str(wxConvUTF8);
+ wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(data.GetText());
int len = strlen(buf);
pdoc->InsertString(currentPos, buf, len);
SetEmptySelection(currentPos + len);
if (!label[0])
((wxMenu*)popup.GetID())->AppendSeparator();
else
- ((wxMenu*)popup.GetID())->Append(cmd, wxString(label, *wxConvCurrent));
+ ((wxMenu*)popup.GetID())->Append(cmd, stc2wx(label));
if (!enabled)
((wxMenu*)popup.GetID())->Enable(cmd, enabled);
dragResult = evt.GetDragResult();
if (dragResult == wxDragMove || dragResult == wxDragCopy) {
DropAt(evt.GetPosition(),
- evt.GetDragText().mb_str(wxConvUTF8),
+ wx2stc(evt.GetDragText()),
dragResult == wxDragMove,
FALSE); // TODO: rectangular?
return TRUE;
'void %s(const wxString& text);',
'''void %s(const wxString& text) {
- wxWX2MBbuf buf = (wxWX2MBbuf)text.mb_str(wxConvUTF8);
+ wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(text);
SendMsg(%s, strlen(buf), (long)(const char*)buf);''',
0),
mbuf.UngetWriteBuf(len);
mbuf.AppendByte(0);
if (linePos) *linePos = pos;
- return wxString(buf, wxConvUTF8);''',
+ return stc2wx(buf);''',
0),
flags |= wholeWord ? SCFIND_WHOLEWORD : 0;
ft.chrg.cpMin = minPos;
ft.chrg.cpMax = maxPos;
- ft.lpstrText = (char*)(const char*)text.mb_str(wxConvUTF8);
+ ft.lpstrText = (char*)(const char*)wx2stc(text);
return SendMsg(%s, flags, (long)&ft);''',
0),
SendMsg(%s, line, (long)buf);
mbuf.UngetWriteBuf(len);
mbuf.AppendByte(0);
- return wxString(buf, wxConvUTF8);''',
+ return stc2wx(buf);''',
('Retrieve the contents of a line.',)),
SendMsg(%s, 0, (long)buf);
mbuf.UngetWriteBuf(len);
mbuf.AppendByte(0);
- return wxString(buf, wxConvUTF8);''',
+ return stc2wx(buf);''',
('Retrieve the selected text.',)),
SendMsg(%s, 0, (long)&tr);
mbuf.UngetWriteBuf(len);
mbuf.AppendByte(0);
- return wxString(buf, wxConvUTF8);''',
+ return stc2wx(buf);''',
('Retrieve a range of text.',)),
SendMsg(%s, len+1, (long)buf);
mbuf.UngetWriteBuf(len);
mbuf.AppendByte(0);
- return wxString(buf, wxConvUTF8);''',
+ return stc2wx(buf);''',
('Retrieve all the text in the document.', )),
'''
int %s(const wxString& text) {
- wxWX2MBbuf buf = (wxWX2MBbuf)text.mb_str(wxConvUTF8);
+ wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(text);
return SendMsg(%s, strlen(buf), (long)(const char*)buf);''',
0),
'''
int %s(const wxString& text) {
- wxWX2MBbuf buf = (wxWX2MBbuf)text.mb_str(wxConvUTF8);
+ wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(text);
return SendMsg(%s, strlen(buf), (long)(const char*)buf);''',
0),
'''
int %s(const wxString& text) {
- wxWX2MBbuf buf = (wxWX2MBbuf)text.mb_str(wxConvUTF8);
+ wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(text);
return SendMsg(%s, strlen(buf), (long)(const char*)buf);''',
0),
typ, name = param
if typ == 'string':
- return '(long)(const char*)%s.mb_str(wxConvUTF8)' % name
+ return '(long)(const char*)wx2stc(%s)' % name
if typ == 'colour':
return 'wxColourAsLong(%s)' % name
// Add text to the document
void wxStyledTextCtrl::AddText(const wxString& text) {
- wxWX2MBbuf buf = (wxWX2MBbuf)text.mb_str(wxConvUTF8);
+ wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(text);
SendMsg(2001, strlen(buf), (long)(const char*)buf);
}
// Insert string at a position
void wxStyledTextCtrl::InsertText(int pos, const wxString& text) {
- SendMsg(2003, pos, (long)(const char*)text.mb_str(wxConvUTF8));
+ SendMsg(2003, pos, (long)(const char*)wx2stc(text));
}
// Delete all text in the document
mbuf.UngetWriteBuf(len);
mbuf.AppendByte(0);
if (linePos) *linePos = pos;
- return wxString(buf, wxConvUTF8);
+ return stc2wx(buf);
}
// Retrieve the position of the last correctly styled character.
// Set the font of a style.
void wxStyledTextCtrl::StyleSetFaceName(int style, const wxString& fontName) {
- SendMsg(2056, style, (long)(const char*)fontName.mb_str(wxConvUTF8));
+ SendMsg(2056, style, (long)(const char*)wx2stc(fontName));
}
// Set a style to have its end of line filled or not.
// Set the set of characters making up words for when moving or selecting
// by word.
void wxStyledTextCtrl::SetWordChars(const wxString& characters) {
- SendMsg(2077, 0, (long)(const char*)characters.mb_str(wxConvUTF8));
+ SendMsg(2077, 0, (long)(const char*)wx2stc(characters));
}
// Start a sequence of actions that is undone and redone as a unit.
// The lenEntered parameter indicates how many characters before
// the caret should be used to provide context.
void wxStyledTextCtrl::AutoCompShow(int lenEntered, const wxString& itemList) {
- SendMsg(2100, lenEntered, (long)(const char*)itemList.mb_str(wxConvUTF8));
+ SendMsg(2100, lenEntered, (long)(const char*)wx2stc(itemList));
}
// Remove the auto-completion list from the screen.
// Define a set of character that when typed cancel the auto-completion list.
void wxStyledTextCtrl::AutoCompStops(const wxString& characterSet) {
- SendMsg(2105, 0, (long)(const char*)characterSet.mb_str(wxConvUTF8));
+ SendMsg(2105, 0, (long)(const char*)wx2stc(characterSet));
}
// Change the separator character in the string setting up an auto-completion
// Select the item in the auto-completion list that starts with a string.
void wxStyledTextCtrl::AutoCompSelect(const wxString& text) {
- SendMsg(2108, 0, (long)(const char*)text.mb_str(wxConvUTF8));
+ SendMsg(2108, 0, (long)(const char*)wx2stc(text));
}
// Should the auto-completion list be cancelled if the user backspaces to a
// Define a set of characters that when typed will cause the autocompletion to
// choose the selected item.
void wxStyledTextCtrl::AutoCompSetFillUps(const wxString& characterSet) {
- SendMsg(2112, 0, (long)(const char*)characterSet.mb_str(wxConvUTF8));
+ SendMsg(2112, 0, (long)(const char*)wx2stc(characterSet));
}
// Should a single item auto-completion list automatically choose the item.
// Display a list of strings and send notification when user chooses one.
void wxStyledTextCtrl::UserListShow(int listType, const wxString& itemList) {
- SendMsg(2117, listType, (long)(const char*)itemList.mb_str(wxConvUTF8));
+ SendMsg(2117, listType, (long)(const char*)wx2stc(itemList));
}
// Set whether or not autocompletion is hidden automatically when nothing matches
flags |= wholeWord ? SCFIND_WHOLEWORD : 0;
ft.chrg.cpMin = minPos;
ft.chrg.cpMax = maxPos;
- ft.lpstrText = (char*)(const char*)text.mb_str(wxConvUTF8);
+ ft.lpstrText = (char*)(const char*)wx2stc(text);
return SendMsg(2150, flags, (long)&ft);
}
SendMsg(2153, line, (long)buf);
mbuf.UngetWriteBuf(len);
mbuf.AppendByte(0);
- return wxString(buf, wxConvUTF8);
+ return stc2wx(buf);
}
// Returns the number of lines in the document. There is always at least one.
SendMsg(2161, 0, (long)buf);
mbuf.UngetWriteBuf(len);
mbuf.AppendByte(0);
- return wxString(buf, wxConvUTF8);
+ return stc2wx(buf);
}
// Retrieve a range of text.
SendMsg(2162, 0, (long)&tr);
mbuf.UngetWriteBuf(len);
mbuf.AppendByte(0);
- return wxString(buf, wxConvUTF8);
+ return stc2wx(buf);
}
// Draw the selection in normal style or with selection highlighted.
// Replace the selected text with the argument text.
void wxStyledTextCtrl::ReplaceSelection(const wxString& text) {
- SendMsg(2170, 0, (long)(const char*)text.mb_str(wxConvUTF8));
+ SendMsg(2170, 0, (long)(const char*)wx2stc(text));
}
// Set to read only or read write.
// Replace the contents of the document with the argument text.
void wxStyledTextCtrl::SetText(const wxString& text) {
- SendMsg(2181, 0, (long)(const char*)text.mb_str(wxConvUTF8));
+ SendMsg(2181, 0, (long)(const char*)wx2stc(text));
}
// Retrieve all the text in the document.
SendMsg(2182, len+1, (long)buf);
mbuf.UngetWriteBuf(len);
mbuf.AppendByte(0);
- return wxString(buf, wxConvUTF8);
+ return stc2wx(buf);
}
// Retrieve the number of characters in the document.
// Returns the length of the replacement text.
int wxStyledTextCtrl::ReplaceTarget(const wxString& text) {
- wxWX2MBbuf buf = (wxWX2MBbuf)text.mb_str(wxConvUTF8);
+ wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(text);
return SendMsg(2194, strlen(buf), (long)(const char*)buf);
}
// caused by processing the \d patterns.
int wxStyledTextCtrl::ReplaceTargetRE(const wxString& text) {
- wxWX2MBbuf buf = (wxWX2MBbuf)text.mb_str(wxConvUTF8);
+ wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(text);
return SendMsg(2195, strlen(buf), (long)(const char*)buf);
}
// Returns length of range or -1 for failure in which case target is not moved.
int wxStyledTextCtrl::SearchInTarget(const wxString& text) {
- wxWX2MBbuf buf = (wxWX2MBbuf)text.mb_str(wxConvUTF8);
+ wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(text);
return SendMsg(2197, strlen(buf), (long)(const char*)buf);
}
// Show a call tip containing a definition near position pos.
void wxStyledTextCtrl::CallTipShow(int pos, const wxString& definition) {
- SendMsg(2200, pos, (long)(const char*)definition.mb_str(wxConvUTF8));
+ SendMsg(2200, pos, (long)(const char*)wx2stc(definition));
}
// Remove the call tip from the screen.
// Find some text starting at the search anchor.
// Does not ensure the selection is visible.
int wxStyledTextCtrl::SearchNext(int flags, const wxString& text) {
- return SendMsg(2367, flags, (long)(const char*)text.mb_str(wxConvUTF8));
+ return SendMsg(2367, flags, (long)(const char*)wx2stc(text));
}
// Find some text starting at the search anchor and moving backwards.
// Does not ensure the selection is visible.
int wxStyledTextCtrl::SearchPrev(int flags, const wxString& text) {
- return SendMsg(2368, flags, (long)(const char*)text.mb_str(wxConvUTF8));
+ return SendMsg(2368, flags, (long)(const char*)wx2stc(text));
}
// Set the way the line the caret is on is kept visible.
// Set up a value that may be used by a lexer for some optional feature.
void wxStyledTextCtrl::SetProperty(const wxString& key, const wxString& value) {
- SendMsg(4004, (long)(const char*)key.mb_str(wxConvUTF8), (long)(const char*)value.mb_str(wxConvUTF8));
+ SendMsg(4004, (long)(const char*)wx2stc(key), (long)(const char*)wx2stc(value));
}
// Set up the key words used by the lexer.
void wxStyledTextCtrl::SetKeyWords(int keywordSet, const wxString& keyWords) {
- SendMsg(4005, keywordSet, (long)(const char*)keyWords.mb_str(wxConvUTF8));
+ SendMsg(4005, keywordSet, (long)(const char*)wx2stc(keyWords));
}
// Set the lexing language of the document based on string name.
void wxStyledTextCtrl::SetLexerLanguage(const wxString& language) {
- SendMsg(4006, 0, (long)(const char*)language.mb_str(wxConvUTF8));
+ SendMsg(4006, 0, (long)(const char*)wx2stc(language));
}
// END of generated section
wxMemoryBuffer buf(scn.length+1);
buf.AppendData((void*)scn.text, scn.length);
buf.AppendByte(0);
- evt.SetText(wxString(buf, wxConvUTF8));
+ evt.SetText(stc2wx(buf));
}
evt.SetLength(scn.length);
evt.SetLinesAdded(scn.linesAdded);
wxMemoryBuffer buf(scn.length+1);
buf.AppendData((void*)scn.text, scn.length);
buf.AppendByte(0);
- evt.SetText(wxString(buf, wxConvUTF8));
+ evt.SetText(stc2wx(buf));
}
evt.SetLength(scn.length);
evt.SetLinesAdded(scn.linesAdded);
#endif
//----------------------------------------------------------------------
+// Utility functions used within wxSTC
+
+#ifndef SWIG
+
+inline wxString stc2wx(const char* str) {
+#if wxUSE_UNICODE
+ return wxString(str, wxConvUTF8);
+#else
+ return wxString(str);
+#endif
+}
+
+inline wxString stc2wx(const char* str, size_t len) {
+#if wxUSE_UNICODE
+ return wxString(str, wxConvUTF8, len);
+#else
+ return wxString(str, len);
+#endif
+}
+
+#if wxUSE_UNICODE
+inline const wxWX2MBbuf wx2stc(const wxString& str) {
+ return str.mb_str(wxConvUTF8);
+}
+#else
+inline const wxWX2MBbuf wx2stc(const wxString& str) {
+ return str.mbc_str();
+}
+#endif
+
+#endif
+
+
//----------------------------------------------------------------------
#endif