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));
}
// Sets the cursor to one of the SC_CURSOR* values.
-void wxStyledTextCtrl::SetCursor(int cursorType) {
+void wxStyledTextCtrl::SetSTCCursor(int cursorType) {
SendMsg(2386, cursorType, 0);
}
// Get cursor type.
-int wxStyledTextCtrl::GetCursor() {
+int wxStyledTextCtrl::GetSTCCursor() {
return SendMsg(2387, 0, 0);
}
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);
// Set style size, face, bold, italic, and underline attributes from
// a wxFont's attributes.
void wxStyledTextCtrl::StyleSetFont(int styleNum, wxFont& font) {
+#ifdef __WXGTK__
+ // Ensure that the native font is initialized
+ int x, y;
+ GetTextExtent(wxT("X"), &x, &y, NULL, NULL, &font);
+#endif
int size = font.GetPointSize();
wxString faceName = font.GetFaceName();
bool bold = font.GetWeight() == wxBOLD;
if (!file.IsOpened())
return FALSE;
- bool success = file.Write(GetText());
+ bool success = file.Write(GetText(), *wxConvCurrent);
if (success)
SetSavePoint();
{
wxString contents;
off_t len = file.Length();
-
if (len > 0)
{
- wxChar *buf = contents.GetWriteBuf(len);
- success = (file.Read(buf, len) == len);
- contents.UngetWriteBuf();
+#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
}
else
success = true; // empty file is ok
}
+#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::OnPaint(wxPaintEvent& evt) {
+void wxStyledTextCtrl::OnPaint(wxPaintEvent& WXUNUSED(evt)) {
wxPaintDC dc(this);
m_swx->DoPaint(&dc, GetUpdateRegion().GetBox());
}
}
}
-void wxStyledTextCtrl::OnSize(wxSizeEvent& evt) {
- wxSize sz = GetClientSize();
- m_swx->DoSize(sz.x, sz.y);
+void wxStyledTextCtrl::OnSize(wxSizeEvent& WXUNUSED(evt)) {
+ if (m_swx) {
+ wxSize sz = GetClientSize();
+ m_swx->DoSize(sz.x, sz.y);
+ }
}
void wxStyledTextCtrl::OnMouseLeftDown(wxMouseEvent& evt) {
int key = evt.GetKeyCode();
bool shift = evt.ShiftDown(),
ctrl = evt.ControlDown(),
- alt = evt.AltDown();
+ alt = evt.AltDown(),
+ meta = evt.MetaDown();
- int processed = m_swx->DoKeyDown(key, shift, ctrl, alt, &m_lastKeyDownConsumed);
+ int processed = m_swx->DoKeyDown(key, shift, ctrl, alt, meta, &m_lastKeyDownConsumed);
// printf("KeyDn key:%d shift:%d ctrl:%d alt:%d processed:%d consumed:%d\n",
// key, shift, ctrl, alt, processed, m_lastKeyDownConsumed);
}
-void wxStyledTextCtrl::OnLoseFocus(wxFocusEvent& evt) {
+void wxStyledTextCtrl::OnLoseFocus(wxFocusEvent& WXUNUSED(evt)) {
m_swx->DoLoseFocus();
}
-void wxStyledTextCtrl::OnGainFocus(wxFocusEvent& evt) {
+void wxStyledTextCtrl::OnGainFocus(wxFocusEvent& WXUNUSED(evt)) {
m_swx->DoGainFocus();
}
-void wxStyledTextCtrl::OnSysColourChanged(wxSysColourChangedEvent& evt) {
+void wxStyledTextCtrl::OnSysColourChanged(wxSysColourChangedEvent& WXUNUSED(evt)) {
m_swx->DoSysColourChange();
}
-void wxStyledTextCtrl::OnEraseBackground(wxEraseEvent& evt) {
+void wxStyledTextCtrl::OnEraseBackground(wxEraseEvent& WXUNUSED(evt)) {
// do nothing to help avoid flashing
}
}
-void wxStyledTextCtrl::OnListBox(wxCommandEvent& evt) {
+void wxStyledTextCtrl::OnListBox(wxCommandEvent& WXUNUSED(evt)) {
m_swx->DoOnListBox();
}
+void wxStyledTextCtrl::OnIdle(wxIdleEvent& evt) {
+ m_swx->DoOnIdle(evt);
+}
+
+
//----------------------------------------------------------------------
// Turn notifications from Scintilla into events