EVT_LEFT_UP (wxStyledTextCtrl::OnMouseLeftUp)
EVT_RIGHT_UP (wxStyledTextCtrl::OnMouseRightUp)
EVT_CHAR (wxStyledTextCtrl::OnChar)
+ EVT_KEY_DOWN (wxStyledTextCtrl::OnKeyDown)
EVT_KILL_FOCUS (wxStyledTextCtrl::OnLoseFocus)
EVT_SET_FOCUS (wxStyledTextCtrl::OnGainFocus)
EVT_SYS_COLOUR_CHANGED (wxStyledTextCtrl::OnSysColourChanged)
EVT_ERASE_BACKGROUND (wxStyledTextCtrl::OnEraseBackground)
EVT_MENU_RANGE (-1, -1, wxStyledTextCtrl::OnMenu)
+ EVT_LISTBOX_DCLICK (-1, wxStyledTextCtrl::OnListBox)
END_EVENT_TABLE()
+
+IMPLEMENT_CLASS(wxStyledTextCtrl, wxControl)
+IMPLEMENT_DYNAMIC_CLASS(wxStyledTextEvent, wxCommandEvent)
+
//----------------------------------------------------------------------
// Constructor and Destructor
//----------------------------------------------------------------------
-inline long wxStyledTextCtrl::SendMsg(int msg, long wp, long lp) {
+long wxStyledTextCtrl::SendMsg(int msg, long wp, long lp) {
return m_swx->WndProc(msg, wp, lp);
}
wxString wxStyledTextCtrl::GetText() {
wxString text;
int len = GetTextLength();
- char* buff = text.GetWriteBuf(len);
+ char* buff = text.GetWriteBuf(len+1);
SendMsg(WM_GETTEXT, len, (long)buff);
+ buff[len] = 0;
text.UngetWriteBuf();
return text;
}
int len = GetLineLength(line);
char* buff = text.GetWriteBuf(len+1);
- *((WORD*)buff) = len+1;
+ *((WORD*)buff) = len;
SendMsg(EM_GETLINE, line, (long)buff);
+ buff[len] = 0;
text.UngetWriteBuf();
return text;
}
int len = GetLineLength(GetCurrentLine());
char* buff = text.GetWriteBuf(len+1);
- int pos = SendMsg(SCI_GETCURLINE, len+1, (long)buff);
+ int pos = SendMsg(SCI_GETCURLINE, len, (long)buff);
text.UngetWriteBuf();
if (linePos)
wxPoint wxStyledTextCtrl::PointFromPosition(int pos) {
Point pt;
- SendMsg(EM_POSFROMCHAR, pos, (long)&pt);
+ SendMsg(EM_POSFROMCHAR, (long)&pt, pos);
return wxPoint(pt.x, pt.y);
}
}
+int wxStyledTextCtrl::GetLinesOnScreen() {
+ return SendMsg(SCI_LINESONSCREEN);
+}
+
+
+bool wxStyledTextCtrl::IsSelectionRectangle() {
+ return SendMsg(SCI_SELECTIONISRECTANGLE) != 0;
+}
+
+
+void wxStyledTextCtrl::SetUseHorizontalScrollBar(bool use) {
+ SendMsg(SCI_SETHSCROLLBAR, use);
+}
+
+
+bool wxStyledTextCtrl::GetUseHorizontalScrollBar() {
+ return SendMsg(SCI_GETHSCROLLBAR) != 0;
+}
+
+
+
//----------------------------------------------------------------------
}
+void wxStyledTextCtrl::SetLineState(int line, int value) {
+ SendMsg(SCI_SETLINESTATE, line, value);
+}
+
+
+int wxStyledTextCtrl::GetLineState(int line) {
+ return SendMsg(SCI_GETLINESTATE, line);
+}
+
+
//----------------------------------------------------------------------
// Style Definition
// face:[facename] sets the font face name to use
// size:[num] sets the font size in points
// eol turns on eol filling
+// underline turns on underlining
//
void wxStyledTextCtrl::StyleSetSpec(int styleNum, const wxString& spec) {
else if (option == "italic")
StyleSetItalic(styleNum, true);
+ else if (option == "underline")
+ StyleSetUnderline(styleNum, true);
+
else if (option == "eol")
StyleSetEOLFilled(styleNum, true);
wxString faceName = font.GetFaceName();
bool bold = font.GetWeight() == wxBOLD;
bool italic = font.GetStyle() != wxNORMAL;
+ bool under = font.GetUnderlined();
- StyleSetFontAttr(styleNum, size, faceName, bold, italic);
+ StyleSetFontAttr(styleNum, size, faceName, bold, italic, under);
}
void wxStyledTextCtrl::StyleSetFontAttr(int styleNum, int size,
const wxString& faceName,
- bool bold, bool italic) {
+ bool bold, bool italic,
+ bool underline) {
StyleSetSize(styleNum, size);
StyleSetFaceName(styleNum, faceName);
StyleSetBold(styleNum, bold);
StyleSetItalic(styleNum, italic);
+ StyleSetUnderline(styleNum, underline);
}
}
+void wxStyledTextCtrl::StyleSetUnderline(int styleNum, bool underline) {
+ SendMsg(SCI_STYLESETUNDERLINE, styleNum, underline);
+}
+
+
//----------------------------------------------------------------------
// Margins in the edit area
void wxStyledTextCtrl::SetCaretForeground(const wxColour& colour) {
- SendMsg(SCI_SETCARETFORE, 0, wxColourAsLong(colour));
+ SendMsg(SCI_SETCARETFORE, wxColourAsLong(colour));
}
}
+void wxStyledTextCtrl::SetIndent(int numChars) {
+ SendMsg(SCI_SETINDENT, numChars);
+}
+
+
+void wxStyledTextCtrl::SetUseTabs(bool usetabs) {
+ SendMsg(SCI_SETUSETABS, usetabs);
+}
+
+
+void wxStyledTextCtrl::SetLineIndentation(int line, int indentation) {
+ SendMsg(SCI_SETLINEINDENTATION, line, indentation);
+}
+
+
+int wxStyledTextCtrl:: GetLineIndentation(int line) {
+ return SendMsg(SCI_GETLINEINDENTATION, line);
+}
+
+
+int wxStyledTextCtrl::GetLineIndentationPos(int line) {
+ return SendMsg(SCI_GETLINEINDENTPOSITION, line);
+}
+
+
void wxStyledTextCtrl::SetWordChars(const wxString& wordChars) {
SendMsg(SCI_SETTABWIDTH, 0, (long)wordChars.c_str());
}
+void wxStyledTextCtrl::SetUsePop(bool usepopup) {
+ SendMsg(SCI_USEPOPUP, usepopup);
+}
+
+
//----------------------------------------------------------------------
// Brace highlighting
void wxStyledTextCtrl::IndicatorSetColour(int indicNum, const wxColour& colour) {
- SendMsg(SCI_INDICSETSTYLE, indicNum, wxColourAsLong(colour));
+ SendMsg(SCI_INDICSETFORE, indicNum, wxColourAsLong(colour));
}
}
+void wxStyledTextCtrl::AutoCompSetSeparator(char separator) {
+ SendMsg(SCI_AUTOCSETSEPARATOR, separator);
+}
+
+
+char wxStyledTextCtrl::AutoCompGetSeparator() {
+ return SendMsg(SCI_AUTOCGETSEPARATOR);
+}
+
+
+void wxStyledTextCtrl::AutoCompSelect(const wxString& stringtoselect) {
+ SendMsg(SCI_AUTOCSELECT, (long)stringtoselect.c_str());
+}
+
+
//----------------------------------------------------------------------
// Call tips
}
-int wxStyledTextCtrl::GetLastChild(int line) {
- return SendMsg(SCI_GETLASTCHILD, line);
+int wxStyledTextCtrl::GetLastChild(int line, int level) {
+ return SendMsg(SCI_GETLASTCHILD, line, level);
}
}
-void wxStyledTextCtrl::SetFoldExpanded(int line) {
- SendMsg(SCI_SETFOLDEXPANDED, line);
+void wxStyledTextCtrl::SetFoldExpanded(int line, bool expanded) {
+ SendMsg(SCI_SETFOLDEXPANDED, line, expanded);
}
}
+void wxStyledTextCtrl::SetFoldFlags(int flags) {
+ SendMsg(SCI_SETFOLDFLAGS, flags);
+}
+
+
+//----------------------------------------------------------------------
+// Zooming
+
+void wxStyledTextCtrl::ZoomIn() {
+ SendMsg(SCI_ZOOMIN);
+}
+
+
+void wxStyledTextCtrl::ZoomOut() {
+ SendMsg(SCI_ZOOMOUT);
+}
+
+
+void wxStyledTextCtrl::SetZoom(int zoom) {
+ SendMsg(SCI_SETZOOM, zoom);
+}
+
+
+int wxStyledTextCtrl::GetZoom() {
+ return SendMsg(SCI_GETZOOM);
+}
+
//----------------------------------------------------------------------
// Long Lines
+//----------------------------------------------------------------------
+// Event mask for Modified Event
+
+void wxStyledTextCtrl::SetModEventMask(int mask) {
+ SendMsg(SCI_SETMODEVENTMASK, mask);
+}
+
+
+//int wxStyledTextCtrl::GetModEventMask() {
+// return SendMsg(SCI_GETMODEVENTMASK);
+//}
+
//----------------------------------------------------------------------
// Event handlers
}
void wxStyledTextCtrl::OnChar(wxKeyEvent& evt) {
- int processed = 0;
long key = evt.KeyCode();
if ((key > WXK_ESCAPE) &&
(key != WXK_DELETE) && (key < 255) &&
!evt.ControlDown() && !evt.AltDown()) {
m_swx->DoAddChar(key);
- processed = true;
}
else {
- key = toupper(key);
- processed = m_swx->DoKeyDown(key, evt.ShiftDown(),
- evt.ControlDown(), evt.AltDown());
+ evt.Skip();
}
+}
+
+void wxStyledTextCtrl::OnKeyDown(wxKeyEvent& evt) {
+ long key = evt.KeyCode();
+ key = toupper(key);
+ int processed = m_swx->DoKeyDown(key, evt.ShiftDown(),
+ evt.ControlDown(), evt.AltDown());
if (! processed)
evt.Skip();
}
}
+void wxStyledTextCtrl::OnListBox(wxCommandEvent& evt) {
+ m_swx->DoOnListBox();
+}
+
+
//----------------------------------------------------------------------
// Turn notifications from Scintilla into events
+
void wxStyledTextCtrl::NotifyChange() {
wxStyledTextEvent evt(wxEVT_STC_CHANGE, GetId());
GetEventHandler()->ProcessEvent(evt);
evt.SetModifiers(scn.modifiers);
if (eventType == wxEVT_STC_MODIFIED) {
evt.SetModificationType(scn.modificationType);
- evt.SetText(scn.text);
+ if (scn.text)
+ evt.SetText(wxString(scn.text, scn.length));
evt.SetLength(scn.length);
evt.SetLinesAdded(scn.linesAdded);
evt.SetLine(scn.line);