const wxPoint& pos,
const wxSize& size,
long style,
- const wxString& name) :
- wxControl(parent, id, pos, size,
- style | wxVSCROLL | wxHSCROLL | wxWANTS_CHARS | wxCLIP_CHILDREN,
- wxDefaultValidator, name)
+ const wxString& name)
{
+ m_swx = NULL;
+ Create(parent, id, pos, size, style, name);
+}
+
+
+void wxStyledTextCtrl::Create(wxWindow *parent,
+ wxWindowID id,
+ const wxPoint& pos,
+ const wxSize& size,
+ long style,
+ const wxString& name)
+{
+#ifdef __WXMAC__
+ style |= wxVSCROLL | wxHSCROLL;
+#endif
+ wxControl::Create(parent, id, pos, size,
+ style | wxWANTS_CHARS | wxCLIP_CHILDREN,
+ wxDefaultValidator, name);
+
#ifdef LINK_LEXERS
Scintilla_LinkLexers();
#endif
SendMsg(2070, MAKELONG(key, modifiers), cmd);
}
-// When key+modifier combination km do nothing.
+// When key+modifier combination km is pressed do nothing.
void wxStyledTextCtrl::CmdKeyClear(int key, int modifiers) {
SendMsg(2071, MAKELONG(key, modifiers));
}
}
// Set the set of characters making up words for when moving or selecting by word.
+// First sets deaults like SetCharsDefault.
void wxStyledTextCtrl::SetWordChars(const wxString& characters) {
SendMsg(2077, 0, (long)(const char*)wx2stc(characters));
}
int startPos,
int endPos,
wxDC* draw,
- wxDC* target, // Why does it use two? Can they be the same?
+ wxDC* target,
wxRect renderRect,
wxRect pageRect) {
RangeToFormat fr;
}
// Replace the target text with the argument text.
-// Text is counted so it can contain nulls.
+// Text is counted so it can contain NULs.
// Returns the length of the replacement text.
int wxStyledTextCtrl::ReplaceTarget(const wxString& text) {
}
// Replace the target text with the argument text after \d processing.
-// Text is counted so it can contain nulls.
+// Text is counted so it can contain NULs.
// Looks for \d where d is between 1 and 9 and replaces these with the strings
// matched in the last search operation which were surrounded by \( and \).
// Returns the length of the replacement text including any change
}
// Search for a counted string in the target and set the target to the found
-// range. Text is counted so it can contain nulls.
+// range. Text is counted so it can contain NULs.
// Returns length of range or -1 for failure in which case target is not moved.
int wxStyledTextCtrl::SearchInTarget(const wxString& text) {
}
// Measure the pixel width of some text in a particular style.
-// Nul terminated text argument.
+// NUL terminated text argument.
// Does not handle tab or control characters.
int wxStyledTextCtrl::TextWidth(int style, const wxString& text) {
return SendMsg(2276, style, (long)(const char*)wx2stc(text));
return SendMsg(2398, 0, 0);
}
-// Set the last x chosen value to be the caret x position
+// Set the last x chosen value to be the caret x position.
void wxStyledTextCtrl::ChooseCaretX() {
SendMsg(2399, 0, 0);
}
SendMsg(2406, mode, 0);
}
-// Is printing line wrapped.
+// Is printing line wrapped?
int wxStyledTextCtrl::GetPrintWrapMode() {
return SendMsg(2407, 0, 0);
}
SendMsg(2412, underline, 0);
}
+// Limit hotspots to single line so hotspots on two lines don't merge.
+void wxStyledTextCtrl::SetHotspotSingleLine(bool singleLine) {
+ SendMsg(2421, singleLine, 0);
+}
+
// Given a valid document position, return the previous position taking code
// page into account. Returns 0 if passed 0.
int wxStyledTextCtrl::PositionBefore(int pos) {
SendMsg(2420, length, (long)(const char*)wx2stc(text));
}
+// Set the selection mode to stream (SC_SEL_STREAM) or rectangular (SC_SEL_RECTANGLE) or
+// by lines (SC_SEL_LINES).
+void wxStyledTextCtrl::SetSelectionMode(int mode) {
+ SendMsg(2422, mode, 0);
+}
+
+// Get the mode of the current selection.
+int wxStyledTextCtrl::GetSelectionMode() {
+ return SendMsg(2423, 0, 0);
+}
+
+// Retrieve the position of the start of the selection at the given line (INVALID_POSITION if no selection on this line).
+int wxStyledTextCtrl::GetLineSelStartPosition(int line) {
+ return SendMsg(2424, line, 0);
+}
+
+// Retrieve the position of the end of the selection at the given line (INVALID_POSITION if no selection on this line).
+int wxStyledTextCtrl::GetLineSelEndPosition(int line) {
+ return SendMsg(2425, line, 0);
+}
+
+// Set the set of characters making up whitespace for when moving or selecting by word.
+// Should be called after SetWordChars.
+void wxStyledTextCtrl::SetWhitespaceChars(const wxString& characters) {
+ SendMsg(2443, 0, (long)(const char*)wx2stc(characters));
+}
+
+// Reset the set of characters for whitespace and word characters to the defaults.
+void wxStyledTextCtrl::SetCharsDefault() {
+ SendMsg(2444, 0, 0);
+}
+
+// Get currently selected item position in the auto-completion list
+int wxStyledTextCtrl::AutoCompGetCurrent() {
+ return SendMsg(2445, 0, 0);
+}
+
// Start notifying the container of all key presses and commands.
void wxStyledTextCtrl::StartRecord() {
SendMsg(3001, 0, 0);
bool success = file.Write(GetText(), *wxConvCurrent);
- if (success) {
+ if (success)
SetSavePoint();
- }
+
return success;
}
if (file.IsOpened())
{
wxString contents;
-#if wxUSE_UNICODE
- wxMemoryBuffer buffer;
-#else
- wxString buffer;
-#endif
-
off_t len = file.Length();
if (len > 0)
{
- void *bufptr = buffer.GetWriteBuf(len);
- success = (file.Read(bufptr, len) == len);
- buffer.UngetWriteBuf(len);
#if wxUSE_UNICODE
+ wxMemoryBuffer buffer(len);
+ success = (file.Read(buffer.GetData(), len) == len);
contents = wxString(buffer, *wxConvCurrent);
#else
+ wxString buffer;
+ success = (file.Read(wxStringBuffer(buffer, len), len) == len);
contents = buffer;
#endif
}
}
+#if wxUSE_DRAG_AND_DROP
+wxDragResult wxStyledTextCtrl::DoDragOver(wxCoord x, wxCoord y, wxDragResult def) {
+ return m_swx->DoDragOver(x, y, def);
+}
+
+
+bool wxStyledTextCtrl::DoDropText(long x, long y, const wxString& data) {
+ return m_swx->DoDropText(x, y, data);
+}
+#endif
+
+
//----------------------------------------------------------------------
// Event handlers
}
void wxStyledTextCtrl::OnSize(wxSizeEvent& WXUNUSED(evt)) {
- wxSize sz = GetClientSize();
- m_swx->DoSize(sz.x, sz.y);
+ if (m_swx) {
+ wxSize sz = GetClientSize();
+ m_swx->DoSize(sz.x, sz.y);
+ }
}
void wxStyledTextCtrl::OnMouseLeftDown(wxMouseEvent& evt) {
}
+void wxStyledTextCtrl::OnIdle(wxIdleEvent& evt) {
+ m_swx->DoOnIdle(evt);
+}
+
+
//----------------------------------------------------------------------
// Turn notifications from Scintilla into events