#include <ctype.h>
#include "wx/wx.h"
#include "wx/tokenzr.h"
#include "wx/mstream.h"
#include "wx/image.h"
#include "wx/file.h"
#include "stc.h"
#include "ScintillaWX.h"
using namespace Scintilla;
const wxChar* wxSTCNameStr = wxT("stcwindow");
#ifdef MAKELONG
#undef MAKELONG
#endif
#define MAKELONG(a, b) ((a) | ((b) << 16))
static long wxColourAsLong(const wxColour& co) {
return (((long)co.Blue() << 16) |
((long)co.Green() << 8) |
((long)co.Red()));
}
static wxColour wxColourFromLong(long c) {
wxColour clr;
clr.Set((unsigned char)(c & 0xff),
(unsigned char)((c >> 8) & 0xff),
(unsigned char)((c >> 16) & 0xff));
return clr;
}
static wxColour wxColourFromSpec(const wxString& spec) {
if (spec.GetChar(0) == wxT('#')) {
long red, green, blue;
red = green = blue = 0;
spec.Mid(1,2).ToLong(&red, 16);
spec.Mid(3,2).ToLong(&green, 16);
spec.Mid(5,2).ToLong(&blue, 16);
return wxColour((unsigned char)red,
(unsigned char)green,
(unsigned char)blue);
}
else
return wxColour(spec);
}
DEFINE_EVENT_TYPE( wxEVT_STC_CHANGE )
DEFINE_EVENT_TYPE( wxEVT_STC_STYLENEEDED )
DEFINE_EVENT_TYPE( wxEVT_STC_CHARADDED )
DEFINE_EVENT_TYPE( wxEVT_STC_SAVEPOINTREACHED )
DEFINE_EVENT_TYPE( wxEVT_STC_SAVEPOINTLEFT )
DEFINE_EVENT_TYPE( wxEVT_STC_ROMODIFYATTEMPT )
DEFINE_EVENT_TYPE( wxEVT_STC_KEY )
DEFINE_EVENT_TYPE( wxEVT_STC_DOUBLECLICK )
DEFINE_EVENT_TYPE( wxEVT_STC_UPDATEUI )
DEFINE_EVENT_TYPE( wxEVT_STC_MODIFIED )
DEFINE_EVENT_TYPE( wxEVT_STC_MACRORECORD )
DEFINE_EVENT_TYPE( wxEVT_STC_MARGINCLICK )
DEFINE_EVENT_TYPE( wxEVT_STC_NEEDSHOWN )
DEFINE_EVENT_TYPE( wxEVT_STC_PAINTED )
DEFINE_EVENT_TYPE( wxEVT_STC_USERLISTSELECTION )
DEFINE_EVENT_TYPE( wxEVT_STC_URIDROPPED )
DEFINE_EVENT_TYPE( wxEVT_STC_DWELLSTART )
DEFINE_EVENT_TYPE( wxEVT_STC_DWELLEND )
DEFINE_EVENT_TYPE( wxEVT_STC_START_DRAG )
DEFINE_EVENT_TYPE( wxEVT_STC_DRAG_OVER )
DEFINE_EVENT_TYPE( wxEVT_STC_DO_DROP )
DEFINE_EVENT_TYPE( wxEVT_STC_ZOOM )
DEFINE_EVENT_TYPE( wxEVT_STC_HOTSPOT_CLICK )
DEFINE_EVENT_TYPE( wxEVT_STC_HOTSPOT_DCLICK )
DEFINE_EVENT_TYPE( wxEVT_STC_CALLTIP_CLICK )
DEFINE_EVENT_TYPE( wxEVT_STC_AUTOCOMP_SELECTION )
BEGIN_EVENT_TABLE(wxStyledTextCtrl, wxControl)
EVT_PAINT (wxStyledTextCtrl::OnPaint)
EVT_SCROLLWIN (wxStyledTextCtrl::OnScrollWin)
EVT_SCROLL (wxStyledTextCtrl::OnScroll)
EVT_SIZE (wxStyledTextCtrl::OnSize)
EVT_LEFT_DOWN (wxStyledTextCtrl::OnMouseLeftDown)
EVT_LEFT_DCLICK (wxStyledTextCtrl::OnMouseLeftDown)
EVT_MOTION (wxStyledTextCtrl::OnMouseMove)
EVT_LEFT_UP (wxStyledTextCtrl::OnMouseLeftUp)
#if defined(__WXGTK__) || defined(__WXMAC__)
EVT_RIGHT_UP (wxStyledTextCtrl::OnMouseRightUp)
#else
EVT_CONTEXT_MENU (wxStyledTextCtrl::OnContextMenu)
#endif
EVT_MOUSEWHEEL (wxStyledTextCtrl::OnMouseWheel)
EVT_MIDDLE_UP (wxStyledTextCtrl::OnMouseMiddleUp)
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 (10, 16, wxStyledTextCtrl::OnMenu)
EVT_LISTBOX_DCLICK (wxID_ANY, wxStyledTextCtrl::OnListBox)
END_EVENT_TABLE()
IMPLEMENT_CLASS(wxStyledTextCtrl, wxControl)
IMPLEMENT_DYNAMIC_CLASS(wxStyledTextEvent, wxCommandEvent)
#ifdef LINK_LEXERS
int Scintilla_LinkLexers();
#endif
wxStyledTextCtrl::wxStyledTextCtrl(wxWindow *parent,
wxWindowID id,
const wxPoint& pos,
const wxSize& size,
long style,
const wxString& name)
{
m_swx = NULL;
Create(parent, id, pos, size, style, name);
}
bool wxStyledTextCtrl::Create(wxWindow *parent,
wxWindowID id,
const wxPoint& pos,
const wxSize& size,
long style,
const wxString& name)
{
#ifdef __WXMAC__
style |= wxVSCROLL | wxHSCROLL;
#endif
if (!wxControl::Create(parent, id, pos, size,
style | wxWANTS_CHARS | wxCLIP_CHILDREN,
wxDefaultValidator, name))
return false;
#ifdef LINK_LEXERS
Scintilla_LinkLexers();
#endif
m_swx = new ScintillaWX(this);
m_stopWatch.Start();
m_lastKeyDownConsumed = false;
m_vScrollBar = NULL;
m_hScrollBar = NULL;
#if wxUSE_UNICODE
SetCodePage(wxSTC_CP_UTF8);
#endif
SetSize(size);
SetBackgroundStyle(wxBG_STYLE_CUSTOM);
return true;
}
wxStyledTextCtrl::~wxStyledTextCtrl() {
delete m_swx;
}
long wxStyledTextCtrl::SendMsg(int msg, long wp, long lp)
{
return m_swx->WndProc(msg, wp, lp);
}
void wxStyledTextCtrl::SetVScrollBar(wxScrollBar* bar) {
m_vScrollBar = bar;
if (bar != NULL) {
SetScrollbar(wxVERTICAL, 0, 0, 0);
}
}
void wxStyledTextCtrl::SetHScrollBar(wxScrollBar* bar) {
m_hScrollBar = bar;
if (bar != NULL) {
SetScrollbar(wxHORIZONTAL, 0, 0, 0);
}
}
void wxStyledTextCtrl::AddText(const wxString& text) {
size_t buflen;
wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(text, buflen);
SendMsg(2001, buflen, (long)(const char*)buf);
}
void wxStyledTextCtrl::AddStyledText(const wxMemoryBuffer& data) {
SendMsg(2002, data.GetDataLen(), (long)data.GetData());
}
void wxStyledTextCtrl::InsertText(int pos, const wxString& text) {
SendMsg(2003, pos, (long)(const char*)wx2stcz(text));
}
void wxStyledTextCtrl::ClearAll() {
SendMsg(2004, 0, 0);
}
void wxStyledTextCtrl::ClearDocumentStyle() {
SendMsg(2005, 0, 0);
}
int wxStyledTextCtrl::GetLength() {
return SendMsg(2006, 0, 0);
}
int wxStyledTextCtrl::GetCharAt(int pos) {
return (unsigned char)SendMsg(2007, pos, 0);
}
int wxStyledTextCtrl::GetCurrentPos() {
return SendMsg(2008, 0, 0);
}
int wxStyledTextCtrl::GetAnchor() {
return SendMsg(2009, 0, 0);
}
int wxStyledTextCtrl::GetStyleAt(int pos) {
return (unsigned char)SendMsg(2010, pos, 0);
}
void wxStyledTextCtrl::Redo() {
SendMsg(2011, 0, 0);
}
void wxStyledTextCtrl::SetUndoCollection(bool collectUndo) {
SendMsg(2012, collectUndo, 0);
}
void wxStyledTextCtrl::SelectAll() {
SendMsg(2013, 0, 0);
}
void wxStyledTextCtrl::SetSavePoint() {
SendMsg(2014, 0, 0);
}
wxMemoryBuffer wxStyledTextCtrl::GetStyledText(int startPos, int endPos)
{
wxMemoryBuffer buf;
if (endPos < startPos) {
int temp = startPos;
startPos = endPos;
endPos = temp;
}
int len = endPos - startPos;
if (!len) return buf;
TextRange tr;
tr.lpstrText = (char*)buf.GetWriteBuf(len*2+1);
tr.chrg.cpMin = startPos;
tr.chrg.cpMax = endPos;
len = SendMsg(2015, 0, (long)&tr);
buf.UngetWriteBuf(len);
return buf;
}
bool wxStyledTextCtrl::CanRedo() {
return SendMsg(2016, 0, 0) != 0;
}
int wxStyledTextCtrl::MarkerLineFromHandle(int handle) {
return SendMsg(2017, handle, 0);
}
void wxStyledTextCtrl::MarkerDeleteHandle(int handle) {
SendMsg(2018, handle, 0);
}
bool wxStyledTextCtrl::GetUndoCollection() {
return SendMsg(2019, 0, 0) != 0;
}
int wxStyledTextCtrl::GetViewWhiteSpace() {
return SendMsg(2020, 0, 0);
}
void wxStyledTextCtrl::SetViewWhiteSpace(int viewWS) {
SendMsg(2021, viewWS, 0);
}
int wxStyledTextCtrl::PositionFromPoint(wxPoint pt) {
return SendMsg(2022, pt.x, pt.y);
}
int wxStyledTextCtrl::PositionFromPointClose(int x, int y) {
return SendMsg(2023, x, y);
}
void wxStyledTextCtrl::GotoLine(int line) {
SendMsg(2024, line, 0);
}
void wxStyledTextCtrl::GotoPos(int pos) {
SendMsg(2025, pos, 0);
}
void wxStyledTextCtrl::SetAnchor(int posAnchor) {
SendMsg(2026, posAnchor, 0);
}
wxString wxStyledTextCtrl::GetCurLine(int* linePos) {
int len = LineLength(GetCurrentLine());
if (!len) {
if (linePos) *linePos = 0;
return wxEmptyString;
}
wxMemoryBuffer mbuf(len+1);
char* buf = (char*)mbuf.GetWriteBuf(len+1);
int pos = SendMsg(2027, len+1, (long)buf);
mbuf.UngetWriteBuf(len);
mbuf.AppendByte(0);
if (linePos) *linePos = pos;
return stc2wx(buf, len);
}
int wxStyledTextCtrl::GetEndStyled() {
return SendMsg(2028, 0, 0);
}
void wxStyledTextCtrl::ConvertEOLs(int eolMode) {
SendMsg(2029, eolMode, 0);
}
int wxStyledTextCtrl::GetEOLMode() {
return SendMsg(2030, 0, 0);
}
void wxStyledTextCtrl::SetEOLMode(int eolMode) {
SendMsg(2031, eolMode, 0);
}
void wxStyledTextCtrl::StartStyling(int pos, int mask) {
SendMsg(2032, pos, mask);
}
void wxStyledTextCtrl::SetStyling(int length, int style) {
SendMsg(2033, length, style);
}
bool wxStyledTextCtrl::GetBufferedDraw() {
return SendMsg(2034, 0, 0) != 0;
}
void wxStyledTextCtrl::SetBufferedDraw(bool buffered) {
SendMsg(2035, buffered, 0);
}
void wxStyledTextCtrl::SetTabWidth(int tabWidth) {
SendMsg(2036, tabWidth, 0);
}
int wxStyledTextCtrl::GetTabWidth() {
return SendMsg(2121, 0, 0);
}
void wxStyledTextCtrl::SetCodePage(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(2037, codePage);
}
void wxStyledTextCtrl::MarkerDefine(int markerNumber, int markerSymbol,
const wxColour& foreground,
const wxColour& background)
{
SendMsg(2040, markerNumber, markerSymbol);
if (foreground.Ok())
MarkerSetForeground(markerNumber, foreground);
if (background.Ok())
MarkerSetBackground(markerNumber, background);
}
void wxStyledTextCtrl::MarkerSetForeground(int markerNumber, const wxColour& fore) {
SendMsg(2041, markerNumber, wxColourAsLong(fore));
}
void wxStyledTextCtrl::MarkerSetBackground(int markerNumber, const wxColour& back) {
SendMsg(2042, markerNumber, wxColourAsLong(back));
}
int wxStyledTextCtrl::MarkerAdd(int line, int markerNumber) {
return SendMsg(2043, line, markerNumber);
}
void wxStyledTextCtrl::MarkerDelete(int line, int markerNumber) {
SendMsg(2044, line, markerNumber);
}
void wxStyledTextCtrl::MarkerDeleteAll(int markerNumber) {
SendMsg(2045, markerNumber, 0);
}
int wxStyledTextCtrl::MarkerGet(int line) {
return SendMsg(2046, line, 0);
}
int wxStyledTextCtrl::MarkerNext(int lineStart, int markerMask) {
return SendMsg(2047, lineStart, markerMask);
}
int wxStyledTextCtrl::MarkerPrevious(int lineStart, int markerMask) {
return SendMsg(2048, lineStart, markerMask);
}
void wxStyledTextCtrl::MarkerDefineBitmap(int markerNumber, const wxBitmap& bmp)
{
wxMemoryOutputStream strm;
wxImage img = bmp.ConvertToImage();
if (img.HasAlpha())
img.ConvertAlphaToMask();
img.SaveFile(strm, wxBITMAP_TYPE_XPM);
size_t len = strm.GetSize();
char* buff = new char[len+1];
strm.CopyTo(buff, len);
buff[len] = 0;
SendMsg(2049, markerNumber, (long)buff);
delete [] buff;
}
void wxStyledTextCtrl::MarkerAddSet(int line, int set) {
SendMsg(2466, line, set);
}
void wxStyledTextCtrl::MarkerSetAlpha(int markerNumber, int alpha) {
SendMsg(2476, markerNumber, alpha);
}
void wxStyledTextCtrl::SetMarginType(int margin, int marginType) {
SendMsg(2240, margin, marginType);
}
int wxStyledTextCtrl::GetMarginType(int margin) {
return SendMsg(2241, margin, 0);
}
void wxStyledTextCtrl::SetMarginWidth(int margin, int pixelWidth) {
SendMsg(2242, margin, pixelWidth);
}
int wxStyledTextCtrl::GetMarginWidth(int margin) {
return SendMsg(2243, margin, 0);
}
void wxStyledTextCtrl::SetMarginMask(int margin, int mask) {
SendMsg(2244, margin, mask);
}
int wxStyledTextCtrl::GetMarginMask(int margin) {
return SendMsg(2245, margin, 0);
}
void wxStyledTextCtrl::SetMarginSensitive(int margin, bool sensitive) {
SendMsg(2246, margin, sensitive);
}
bool wxStyledTextCtrl::GetMarginSensitive(int margin) {
return SendMsg(2247, margin, 0) != 0;
}
void wxStyledTextCtrl::StyleClearAll() {
SendMsg(2050, 0, 0);
}
void wxStyledTextCtrl::StyleSetForeground(int style, const wxColour& fore) {
SendMsg(2051, style, wxColourAsLong(fore));
}
void wxStyledTextCtrl::StyleSetBackground(int style, const wxColour& back) {
SendMsg(2052, style, wxColourAsLong(back));
}
void wxStyledTextCtrl::StyleSetBold(int style, bool bold) {
SendMsg(2053, style, bold);
}
void wxStyledTextCtrl::StyleSetItalic(int style, bool italic) {
SendMsg(2054, style, italic);
}
void wxStyledTextCtrl::StyleSetSize(int style, int sizePoints) {
SendMsg(2055, style, sizePoints);
}
void wxStyledTextCtrl::StyleSetFaceName(int style, const wxString& fontName) {
SendMsg(2056, style, (long)(const char*)wx2stcz(fontName));
}
void wxStyledTextCtrl::StyleSetEOLFilled(int style, bool filled) {
SendMsg(2057, style, filled);
}
void wxStyledTextCtrl::StyleResetDefault() {
SendMsg(2058, 0, 0);
}
void wxStyledTextCtrl::StyleSetUnderline(int style, bool underline) {
SendMsg(2059, style, underline);
}
void wxStyledTextCtrl::StyleSetCase(int style, int caseForce) {
SendMsg(2060, style, caseForce);
}
void wxStyledTextCtrl::StyleSetHotSpot(int style, bool hotspot) {
SendMsg(2409, style, hotspot);
}
void wxStyledTextCtrl::SetSelForeground(bool useSetting, const wxColour& fore) {
SendMsg(2067, useSetting, wxColourAsLong(fore));
}
void wxStyledTextCtrl::SetSelBackground(bool useSetting, const wxColour& back) {
SendMsg(2068, useSetting, wxColourAsLong(back));
}
int wxStyledTextCtrl::GetSelAlpha() {
return SendMsg(2477, 0, 0);
}
void wxStyledTextCtrl::SetSelAlpha(int alpha) {
SendMsg(2478, alpha, 0);
}
void wxStyledTextCtrl::SetCaretForeground(const wxColour& fore) {
SendMsg(2069, wxColourAsLong(fore), 0);
}
void wxStyledTextCtrl::CmdKeyAssign(int key, int modifiers, int cmd) {
SendMsg(2070, MAKELONG(key, modifiers), cmd);
}
void wxStyledTextCtrl::CmdKeyClear(int key, int modifiers) {
SendMsg(2071, MAKELONG(key, modifiers));
}
void wxStyledTextCtrl::CmdKeyClearAll() {
SendMsg(2072, 0, 0);
}
void wxStyledTextCtrl::SetStyleBytes(int length, char* styleBytes) {
SendMsg(2073, length, (long)styleBytes);
}
void wxStyledTextCtrl::StyleSetVisible(int style, bool visible) {
SendMsg(2074, style, visible);
}
int wxStyledTextCtrl::GetCaretPeriod() {
return SendMsg(2075, 0, 0);
}
void wxStyledTextCtrl::SetCaretPeriod(int periodMilliseconds) {
SendMsg(2076, periodMilliseconds, 0);
}
void wxStyledTextCtrl::SetWordChars(const wxString& characters) {
SendMsg(2077, 0, (long)(const char*)wx2stcz(characters));
}
void wxStyledTextCtrl::BeginUndoAction() {
SendMsg(2078, 0, 0);
}
void wxStyledTextCtrl::EndUndoAction() {
SendMsg(2079, 0, 0);
}
void wxStyledTextCtrl::IndicatorSetStyle(int indic, int style) {
SendMsg(2080, indic, style);
}
int wxStyledTextCtrl::IndicatorGetStyle(int indic) {
return SendMsg(2081, indic, 0);
}
void wxStyledTextCtrl::IndicatorSetForeground(int indic, const wxColour& fore) {
SendMsg(2082, indic, wxColourAsLong(fore));
}
wxColour wxStyledTextCtrl::IndicatorGetForeground(int indic) {
long c = SendMsg(2083, indic, 0);
return wxColourFromLong(c);
}
void wxStyledTextCtrl::SetWhitespaceForeground(bool useSetting, const wxColour& fore) {
SendMsg(2084, useSetting, wxColourAsLong(fore));
}
void wxStyledTextCtrl::SetWhitespaceBackground(bool useSetting, const wxColour& back) {
SendMsg(2085, useSetting, wxColourAsLong(back));
}
void wxStyledTextCtrl::SetStyleBits(int bits) {
SendMsg(2090, bits, 0);
}
int wxStyledTextCtrl::GetStyleBits() {
return SendMsg(2091, 0, 0);
}
void wxStyledTextCtrl::SetLineState(int line, int state) {
SendMsg(2092, line, state);
}
int wxStyledTextCtrl::GetLineState(int line) {
return SendMsg(2093, line, 0);
}
int wxStyledTextCtrl::GetMaxLineState() {
return SendMsg(2094, 0, 0);
}
bool wxStyledTextCtrl::GetCaretLineVisible() {
return SendMsg(2095, 0, 0) != 0;
}
void wxStyledTextCtrl::SetCaretLineVisible(bool show) {
SendMsg(2096, show, 0);
}
wxColour wxStyledTextCtrl::GetCaretLineBackground() {
long c = SendMsg(2097, 0, 0);
return wxColourFromLong(c);
}
void wxStyledTextCtrl::SetCaretLineBackground(const wxColour& back) {
SendMsg(2098, wxColourAsLong(back), 0);
}
void wxStyledTextCtrl::StyleSetChangeable(int style, bool changeable) {
SendMsg(2099, style, changeable);
}
void wxStyledTextCtrl::AutoCompShow(int lenEntered, const wxString& itemList) {
SendMsg(2100, lenEntered, (long)(const char*)wx2stcz(itemList));
}
void wxStyledTextCtrl::AutoCompCancel() {
SendMsg(2101, 0, 0);
}
bool wxStyledTextCtrl::AutoCompActive() {
return SendMsg(2102, 0, 0) != 0;
}
int wxStyledTextCtrl::AutoCompPosStart() {
return SendMsg(2103, 0, 0);
}
void wxStyledTextCtrl::AutoCompComplete() {
SendMsg(2104, 0, 0);
}
void wxStyledTextCtrl::AutoCompStops(const wxString& characterSet) {
SendMsg(2105, 0, (long)(const char*)wx2stcz(characterSet));
}
void wxStyledTextCtrl::AutoCompSetSeparator(int separatorCharacter) {
SendMsg(2106, separatorCharacter, 0);
}
int wxStyledTextCtrl::AutoCompGetSeparator() {
return SendMsg(2107, 0, 0);
}
void wxStyledTextCtrl::AutoCompSelect(const wxString& text) {
SendMsg(2108, 0, (long)(const char*)wx2stcz(text));
}
void wxStyledTextCtrl::AutoCompSetCancelAtStart(bool cancel) {
SendMsg(2110, cancel, 0);
}
bool wxStyledTextCtrl::AutoCompGetCancelAtStart() {
return SendMsg(2111, 0, 0) != 0;
}
void wxStyledTextCtrl::AutoCompSetFillUps(const wxString& characterSet) {
SendMsg(2112, 0, (long)(const char*)wx2stcz(characterSet));
}
void wxStyledTextCtrl::AutoCompSetChooseSingle(bool chooseSingle) {
SendMsg(2113, chooseSingle, 0);
}
bool wxStyledTextCtrl::AutoCompGetChooseSingle() {
return SendMsg(2114, 0, 0) != 0;
}
void wxStyledTextCtrl::AutoCompSetIgnoreCase(bool ignoreCase) {
SendMsg(2115, ignoreCase, 0);
}
bool wxStyledTextCtrl::AutoCompGetIgnoreCase() {
return SendMsg(2116, 0, 0) != 0;
}
void wxStyledTextCtrl::UserListShow(int listType, const wxString& itemList) {
SendMsg(2117, listType, (long)(const char*)wx2stcz(itemList));
}
void wxStyledTextCtrl::AutoCompSetAutoHide(bool autoHide) {
SendMsg(2118, autoHide, 0);
}
bool wxStyledTextCtrl::AutoCompGetAutoHide() {
return SendMsg(2119, 0, 0) != 0;
}
void wxStyledTextCtrl::AutoCompSetDropRestOfWord(bool dropRestOfWord) {
SendMsg(2270, dropRestOfWord, 0);
}
bool wxStyledTextCtrl::AutoCompGetDropRestOfWord() {
return SendMsg(2271, 0, 0) != 0;
}
void wxStyledTextCtrl::RegisterImage(int type, const wxBitmap& bmp)
{
wxMemoryOutputStream strm;
wxImage img = bmp.ConvertToImage();
if (img.HasAlpha())
img.ConvertAlphaToMask();
img.SaveFile(strm, wxBITMAP_TYPE_XPM);
size_t len = strm.GetSize();
char* buff = new char[len+1];
strm.CopyTo(buff, len);
buff[len] = 0;
SendMsg(2405, type, (long)buff);
delete [] buff;
}
void wxStyledTextCtrl::ClearRegisteredImages() {
SendMsg(2408, 0, 0);
}
int wxStyledTextCtrl::AutoCompGetTypeSeparator() {
return SendMsg(2285, 0, 0);
}
void wxStyledTextCtrl::AutoCompSetTypeSeparator(int separatorCharacter) {
SendMsg(2286, separatorCharacter, 0);
}
void wxStyledTextCtrl::AutoCompSetMaxWidth(int characterCount) {
SendMsg(2208, characterCount, 0);
}
int wxStyledTextCtrl::AutoCompGetMaxWidth() {
return SendMsg(2209, 0, 0);
}
void wxStyledTextCtrl::AutoCompSetMaxHeight(int rowCount) {
SendMsg(2210, rowCount, 0);
}
int wxStyledTextCtrl::AutoCompGetMaxHeight() {
return SendMsg(2211, 0, 0);
}
void wxStyledTextCtrl::SetIndent(int indentSize) {
SendMsg(2122, indentSize, 0);
}
int wxStyledTextCtrl::GetIndent() {
return SendMsg(2123, 0, 0);
}
void wxStyledTextCtrl::SetUseTabs(bool useTabs) {
SendMsg(2124, useTabs, 0);
}
bool wxStyledTextCtrl::GetUseTabs() {
return SendMsg(2125, 0, 0) != 0;
}
void wxStyledTextCtrl::SetLineIndentation(int line, int indentSize) {
SendMsg(2126, line, indentSize);
}
int wxStyledTextCtrl::GetLineIndentation(int line) {
return SendMsg(2127, line, 0);
}
int wxStyledTextCtrl::GetLineIndentPosition(int line) {
return SendMsg(2128, line, 0);
}
int wxStyledTextCtrl::GetColumn(int pos) {
return SendMsg(2129, pos, 0);
}
void wxStyledTextCtrl::SetUseHorizontalScrollBar(bool show) {
SendMsg(2130, show, 0);
}
bool wxStyledTextCtrl::GetUseHorizontalScrollBar() {
return SendMsg(2131, 0, 0) != 0;
}
void wxStyledTextCtrl::SetIndentationGuides(bool show) {
SendMsg(2132, show, 0);
}
bool wxStyledTextCtrl::GetIndentationGuides() {
return SendMsg(2133, 0, 0) != 0;
}
void wxStyledTextCtrl::SetHighlightGuide(int column) {
SendMsg(2134, column, 0);
}
int wxStyledTextCtrl::GetHighlightGuide() {
return SendMsg(2135, 0, 0);
}
int wxStyledTextCtrl::GetLineEndPosition(int line) {
return SendMsg(2136, line, 0);
}
int wxStyledTextCtrl::GetCodePage() {
return SendMsg(2137, 0, 0);
}
wxColour wxStyledTextCtrl::GetCaretForeground() {
long c = SendMsg(2138, 0, 0);
return wxColourFromLong(c);
}
bool wxStyledTextCtrl::GetReadOnly() {
return SendMsg(2140, 0, 0) != 0;
}
void wxStyledTextCtrl::SetCurrentPos(int pos) {
SendMsg(2141, pos, 0);
}
void wxStyledTextCtrl::SetSelectionStart(int pos) {
SendMsg(2142, pos, 0);
}
int wxStyledTextCtrl::GetSelectionStart() {
return SendMsg(2143, 0, 0);
}
void wxStyledTextCtrl::SetSelectionEnd(int pos) {
SendMsg(2144, pos, 0);
}
int wxStyledTextCtrl::GetSelectionEnd() {
return SendMsg(2145, 0, 0);
}
void wxStyledTextCtrl::SetPrintMagnification(int magnification) {
SendMsg(2146, magnification, 0);
}
int wxStyledTextCtrl::GetPrintMagnification() {
return SendMsg(2147, 0, 0);
}
void wxStyledTextCtrl::SetPrintColourMode(int mode) {
SendMsg(2148, mode, 0);
}
int wxStyledTextCtrl::GetPrintColourMode() {
return SendMsg(2149, 0, 0);
}
int wxStyledTextCtrl::FindText(int minPos, int maxPos,
const wxString& text,
int flags)
{
TextToFind ft;
ft.chrg.cpMin = minPos;
ft.chrg.cpMax = maxPos;
wxWX2MBbuf buf = (wxWX2MBbuf)wx2stcz(text);
ft.lpstrText = (char*)(const char*)buf;
return SendMsg(2150, flags, (long)&ft);
}
int wxStyledTextCtrl::FormatRange(bool doDraw,
int startPos,
int endPos,
wxDC* draw,
wxDC* target,
wxRect renderRect,
wxRect pageRect)
{
RangeToFormat fr;
if (endPos < startPos) {
int temp = startPos;
startPos = endPos;
endPos = temp;
}
fr.hdc = draw;
fr.hdcTarget = target;
fr.rc.top = renderRect.GetTop();
fr.rc.left = renderRect.GetLeft();
fr.rc.right = renderRect.GetRight();
fr.rc.bottom = renderRect.GetBottom();
fr.rcPage.top = pageRect.GetTop();
fr.rcPage.left = pageRect.GetLeft();
fr.rcPage.right = pageRect.GetRight();
fr.rcPage.bottom = pageRect.GetBottom();
fr.chrg.cpMin = startPos;
fr.chrg.cpMax = endPos;
return SendMsg(2151, doDraw, (long)&fr);
}
int wxStyledTextCtrl::GetFirstVisibleLine() {
return SendMsg(2152, 0, 0);
}
wxString wxStyledTextCtrl::GetLine(int line)
{
int len = LineLength(line);
if (!len) return wxEmptyString;
wxMemoryBuffer mbuf(len+1);
char* buf = (char*)mbuf.GetWriteBuf(len+1);
SendMsg(2153, line, (long)buf);
mbuf.UngetWriteBuf(len);
mbuf.AppendByte(0);
return stc2wx(buf, len);
}
int wxStyledTextCtrl::GetLineCount() {
return SendMsg(2154, 0, 0);
}
void wxStyledTextCtrl::SetMarginLeft(int pixelWidth) {
SendMsg(2155, 0, pixelWidth);
}
int wxStyledTextCtrl::GetMarginLeft() {
return SendMsg(2156, 0, 0);
}
void wxStyledTextCtrl::SetMarginRight(int pixelWidth) {
SendMsg(2157, 0, pixelWidth);
}
int wxStyledTextCtrl::GetMarginRight() {
return SendMsg(2158, 0, 0);
}
bool wxStyledTextCtrl::GetModify() {
return SendMsg(2159, 0, 0) != 0;
}
void wxStyledTextCtrl::SetSelection(int start, int end) {
SendMsg(2160, start, end);
}
wxString wxStyledTextCtrl::GetSelectedText()
{
int start;
int end;
GetSelection(&start, &end);
int len = end - start;
if (!len) return wxEmptyString;
wxMemoryBuffer mbuf(len+2);
char* buf = (char*)mbuf.GetWriteBuf(len+1);
SendMsg(2161, 0, (long)buf);
mbuf.UngetWriteBuf(len);
mbuf.AppendByte(0);
return stc2wx(buf, len);
}
wxString wxStyledTextCtrl::GetTextRange(int startPos, int endPos)
{
if (endPos < startPos) {
int temp = startPos;
startPos = endPos;
endPos = temp;
}
int len = endPos - startPos;
if (!len) return wxEmptyString;
wxMemoryBuffer mbuf(len+1);
char* buf = (char*)mbuf.GetWriteBuf(len);
TextRange tr;
tr.lpstrText = buf;
tr.chrg.cpMin = startPos;
tr.chrg.cpMax = endPos;
SendMsg(2162, 0, (long)&tr);
mbuf.UngetWriteBuf(len);
mbuf.AppendByte(0);
return stc2wx(buf, len);
}
void wxStyledTextCtrl::HideSelection(bool normal) {
SendMsg(2163, normal, 0);
}
int wxStyledTextCtrl::LineFromPosition(int pos) {
return SendMsg(2166, pos, 0);
}
int wxStyledTextCtrl::PositionFromLine(int line) {
return SendMsg(2167, line, 0);
}
void wxStyledTextCtrl::LineScroll(int columns, int lines) {
SendMsg(2168, columns, lines);
}
void wxStyledTextCtrl::EnsureCaretVisible() {
SendMsg(2169, 0, 0);
}
void wxStyledTextCtrl::ReplaceSelection(const wxString& text) {
SendMsg(2170, 0, (long)(const char*)wx2stcz(text));
}
void wxStyledTextCtrl::SetReadOnly(bool readOnly) {
SendMsg(2171, readOnly, 0);
}
bool wxStyledTextCtrl::CanPaste() {
return SendMsg(2173, 0, 0) != 0;
}
bool wxStyledTextCtrl::CanUndo() {
return SendMsg(2174, 0, 0) != 0;
}
void wxStyledTextCtrl::EmptyUndoBuffer() {
SendMsg(2175, 0, 0);
}
void wxStyledTextCtrl::Undo() {
SendMsg(2176, 0, 0);
}
void wxStyledTextCtrl::Cut() {
SendMsg(2177, 0, 0);
}
void wxStyledTextCtrl::Copy() {
SendMsg(2178, 0, 0);
}
void wxStyledTextCtrl::Paste() {
SendMsg(2179, 0, 0);
}
void wxStyledTextCtrl::Clear() {
SendMsg(2180, 0, 0);
}
void wxStyledTextCtrl::SetText(const wxString& text) {
SendMsg(2181, 0, (long)(const char*)wx2stcz(text));
}
wxString wxStyledTextCtrl::GetText()
{
int len = GetTextLength();
wxMemoryBuffer mbuf(len+1);
char* buf = (char*)mbuf.GetWriteBuf(len+1);
SendMsg(2182, len+1, (long)buf);
mbuf.UngetWriteBuf(len);
mbuf.AppendByte(0);
return stc2wx(buf, len);
}
int wxStyledTextCtrl::GetTextLength() {
return SendMsg(2183, 0, 0);
}
void wxStyledTextCtrl::SetOvertype(bool overtype) {
SendMsg(2186, overtype, 0);
}
bool wxStyledTextCtrl::GetOvertype() {
return SendMsg(2187, 0, 0) != 0;
}
void wxStyledTextCtrl::SetCaretWidth(int pixelWidth) {
SendMsg(2188, pixelWidth, 0);
}
int wxStyledTextCtrl::GetCaretWidth() {
return SendMsg(2189, 0, 0);
}
void wxStyledTextCtrl::SetTargetStart(int pos) {
SendMsg(2190, pos, 0);
}
int wxStyledTextCtrl::GetTargetStart() {
return SendMsg(2191, 0, 0);
}
void wxStyledTextCtrl::SetTargetEnd(int pos) {
SendMsg(2192, pos, 0);
}
int wxStyledTextCtrl::GetTargetEnd() {
return SendMsg(2193, 0, 0);
}
int wxStyledTextCtrl::ReplaceTarget(const wxString& text) {
size_t buflen;
wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(text, buflen);
return SendMsg(2194, buflen, (long)(const char*)buf);
}
int wxStyledTextCtrl::ReplaceTargetRE(const wxString& text) {
size_t buflen;
wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(text, buflen);
return SendMsg(2195, buflen, (long)(const char*)buf);
}
int wxStyledTextCtrl::SearchInTarget(const wxString& text) {
size_t buflen;
wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(text, buflen);
return SendMsg(2197, buflen, (long)(const char*)buf);
}
void wxStyledTextCtrl::SetSearchFlags(int flags) {
SendMsg(2198, flags, 0);
}
int wxStyledTextCtrl::GetSearchFlags() {
return SendMsg(2199, 0, 0);
}
void wxStyledTextCtrl::CallTipShow(int pos, const wxString& definition) {
SendMsg(2200, pos, (long)(const char*)wx2stcz(definition));
}
void wxStyledTextCtrl::CallTipCancel() {
SendMsg(2201, 0, 0);
}
bool wxStyledTextCtrl::CallTipActive() {
return SendMsg(2202, 0, 0) != 0;
}
int wxStyledTextCtrl::CallTipPosAtStart() {
return SendMsg(2203, 0, 0);
}
void wxStyledTextCtrl::CallTipSetHighlight(int start, int end) {
SendMsg(2204, start, end);
}
void wxStyledTextCtrl::CallTipSetBackground(const wxColour& back) {
SendMsg(2205, wxColourAsLong(back), 0);
}
void wxStyledTextCtrl::CallTipSetForeground(const wxColour& fore) {
SendMsg(2206, wxColourAsLong(fore), 0);
}
void wxStyledTextCtrl::CallTipSetForegroundHighlight(const wxColour& fore) {
SendMsg(2207, wxColourAsLong(fore), 0);
}
void wxStyledTextCtrl::CallTipUseStyle(int tabSize) {
SendMsg(2212, tabSize, 0);
}
int wxStyledTextCtrl::VisibleFromDocLine(int line) {
return SendMsg(2220, line, 0);
}
int wxStyledTextCtrl::DocLineFromVisible(int lineDisplay) {
return SendMsg(2221, lineDisplay, 0);
}
int wxStyledTextCtrl::WrapCount(int line) {
return SendMsg(2235, line, 0);
}
void wxStyledTextCtrl::SetFoldLevel(int line, int level) {
SendMsg(2222, line, level);
}
int wxStyledTextCtrl::GetFoldLevel(int line) {
return SendMsg(2223, line, 0);
}
int wxStyledTextCtrl::GetLastChild(int line, int level) {
return SendMsg(2224, line, level);
}
int wxStyledTextCtrl::GetFoldParent(int line) {
return SendMsg(2225, line, 0);
}
void wxStyledTextCtrl::ShowLines(int lineStart, int lineEnd) {
SendMsg(2226, lineStart, lineEnd);
}
void wxStyledTextCtrl::HideLines(int lineStart, int lineEnd) {
SendMsg(2227, lineStart, lineEnd);
}
bool wxStyledTextCtrl::GetLineVisible(int line) {
return SendMsg(2228, line, 0) != 0;
}
void wxStyledTextCtrl::SetFoldExpanded(int line, bool expanded) {
SendMsg(2229, line, expanded);
}
bool wxStyledTextCtrl::GetFoldExpanded(int line) {
return SendMsg(2230, line, 0) != 0;
}
void wxStyledTextCtrl::ToggleFold(int line) {
SendMsg(2231, line, 0);
}
void wxStyledTextCtrl::EnsureVisible(int line) {
SendMsg(2232, line, 0);
}
void wxStyledTextCtrl::SetFoldFlags(int flags) {
SendMsg(2233, flags, 0);
}
void wxStyledTextCtrl::EnsureVisibleEnforcePolicy(int line) {
SendMsg(2234, line, 0);
}
void wxStyledTextCtrl::SetTabIndents(bool tabIndents) {
SendMsg(2260, tabIndents, 0);
}
bool wxStyledTextCtrl::GetTabIndents() {
return SendMsg(2261, 0, 0) != 0;
}
void wxStyledTextCtrl::SetBackSpaceUnIndents(bool bsUnIndents) {
SendMsg(2262, bsUnIndents, 0);
}
bool wxStyledTextCtrl::GetBackSpaceUnIndents() {
return SendMsg(2263, 0, 0) != 0;
}
void wxStyledTextCtrl::SetMouseDwellTime(int periodMilliseconds) {
SendMsg(2264, periodMilliseconds, 0);
}
int wxStyledTextCtrl::GetMouseDwellTime() {
return SendMsg(2265, 0, 0);
}
int wxStyledTextCtrl::WordStartPosition(int pos, bool onlyWordCharacters) {
return SendMsg(2266, pos, onlyWordCharacters);
}
int wxStyledTextCtrl::WordEndPosition(int pos, bool onlyWordCharacters) {
return SendMsg(2267, pos, onlyWordCharacters);
}
void wxStyledTextCtrl::SetWrapMode(int mode) {
SendMsg(2268, mode, 0);
}
int wxStyledTextCtrl::GetWrapMode() {
return SendMsg(2269, 0, 0);
}
void wxStyledTextCtrl::SetWrapVisualFlags(int wrapVisualFlags) {
SendMsg(2460, wrapVisualFlags, 0);
}
int wxStyledTextCtrl::GetWrapVisualFlags() {
return SendMsg(2461, 0, 0);
}
void wxStyledTextCtrl::SetWrapVisualFlagsLocation(int wrapVisualFlagsLocation) {
SendMsg(2462, wrapVisualFlagsLocation, 0);
}
int wxStyledTextCtrl::GetWrapVisualFlagsLocation() {
return SendMsg(2463, 0, 0);
}
void wxStyledTextCtrl::SetWrapStartIndent(int indent) {
SendMsg(2464, indent, 0);
}
int wxStyledTextCtrl::GetWrapStartIndent() {
return SendMsg(2465, 0, 0);
}
void wxStyledTextCtrl::SetLayoutCache(int mode) {
SendMsg(2272, mode, 0);
}
int wxStyledTextCtrl::GetLayoutCache() {
return SendMsg(2273, 0, 0);
}
void wxStyledTextCtrl::SetScrollWidth(int pixelWidth) {
SendMsg(2274, pixelWidth, 0);
}
int wxStyledTextCtrl::GetScrollWidth() {
return SendMsg(2275, 0, 0);
}
int wxStyledTextCtrl::TextWidth(int style, const wxString& text) {
return SendMsg(2276, style, (long)(const char*)wx2stcz(text));
}
void wxStyledTextCtrl::SetEndAtLastLine(bool endAtLastLine) {
SendMsg(2277, endAtLastLine, 0);
}
bool wxStyledTextCtrl::GetEndAtLastLine() {
return SendMsg(2278, 0, 0) != 0;
}
int wxStyledTextCtrl::TextHeight(int line) {
return SendMsg(2279, line, 0);
}
void wxStyledTextCtrl::SetUseVerticalScrollBar(bool show) {
SendMsg(2280, show, 0);
}
bool wxStyledTextCtrl::GetUseVerticalScrollBar() {
return SendMsg(2281, 0, 0) != 0;
}
void wxStyledTextCtrl::AppendText(const wxString& text) {
size_t buflen;
wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(text, buflen);
SendMsg(SCI_APPENDTEXT, buflen, (long)(const char*)buf);
}
bool wxStyledTextCtrl::GetTwoPhaseDraw() {
return SendMsg(SCI_GETTWOPHASEDRAW, 0, 0) != 0;
}
void wxStyledTextCtrl::SetTwoPhaseDraw(bool twoPhase) {
SendMsg(SCI_SETTWOPHASEDRAW, twoPhase, 0);
}
void wxStyledTextCtrl::TargetFromSelection() {
SendMsg(2287, 0, 0);
}
void wxStyledTextCtrl::LinesJoin() {
SendMsg(2288, 0, 0);
}
void wxStyledTextCtrl::LinesSplit(int pixelWidth) {
SendMsg(2289, pixelWidth, 0);
}
void wxStyledTextCtrl::SetFoldMarginColour(bool useSetting, const wxColour& back) {
SendMsg(2290, useSetting, wxColourAsLong(back));
}
void wxStyledTextCtrl::SetFoldMarginHiColour(bool useSetting, const wxColour& fore) {
SendMsg(2291, useSetting, wxColourAsLong(fore));
}
void wxStyledTextCtrl::LineDown() {
SendMsg(2300, 0, 0);
}
void wxStyledTextCtrl::LineDownExtend() {
SendMsg(2301, 0, 0);
}
void wxStyledTextCtrl::LineUp() {
SendMsg(2302, 0, 0);
}
void wxStyledTextCtrl::LineUpExtend() {
SendMsg(2303, 0, 0);
}
void wxStyledTextCtrl::CharLeft() {
SendMsg(2304, 0, 0);
}
void wxStyledTextCtrl::CharLeftExtend() {
SendMsg(2305, 0, 0);
}
void wxStyledTextCtrl::CharRight() {
SendMsg(2306, 0, 0);
}
void wxStyledTextCtrl::CharRightExtend() {
SendMsg(2307, 0, 0);
}
void wxStyledTextCtrl::WordLeft() {
SendMsg(2308, 0, 0);
}
void wxStyledTextCtrl::WordLeftExtend() {
SendMsg(2309, 0, 0);
}
void wxStyledTextCtrl::WordRight() {
SendMsg(2310, 0, 0);
}
void wxStyledTextCtrl::WordRightExtend() {
SendMsg(2311, 0, 0);
}
void wxStyledTextCtrl::Home() {
SendMsg(2312, 0, 0);
}
void wxStyledTextCtrl::HomeExtend() {
SendMsg(2313, 0, 0);
}
void wxStyledTextCtrl::LineEnd() {
SendMsg(2314, 0, 0);
}
void wxStyledTextCtrl::LineEndExtend() {
SendMsg(2315, 0, 0);
}
void wxStyledTextCtrl::DocumentStart() {
SendMsg(2316, 0, 0);
}
void wxStyledTextCtrl::DocumentStartExtend() {
SendMsg(2317, 0, 0);
}
void wxStyledTextCtrl::DocumentEnd() {
SendMsg(2318, 0, 0);
}
void wxStyledTextCtrl::DocumentEndExtend() {
SendMsg(2319, 0, 0);
}
void wxStyledTextCtrl::PageUp() {
SendMsg(2320, 0, 0);
}
void wxStyledTextCtrl::PageUpExtend() {
SendMsg(2321, 0, 0);
}
void wxStyledTextCtrl::PageDown() {
SendMsg(2322, 0, 0);
}
void wxStyledTextCtrl::PageDownExtend() {
SendMsg(2323, 0, 0);
}
void wxStyledTextCtrl::EditToggleOvertype() {
SendMsg(2324, 0, 0);
}
void wxStyledTextCtrl::Cancel() {
SendMsg(2325, 0, 0);
}
void wxStyledTextCtrl::DeleteBack() {
SendMsg(2326, 0, 0);
}
void wxStyledTextCtrl::Tab() {
SendMsg(2327, 0, 0);
}
void wxStyledTextCtrl::BackTab() {
SendMsg(2328, 0, 0);
}
void wxStyledTextCtrl::NewLine() {
SendMsg(2329, 0, 0);
}
void wxStyledTextCtrl::FormFeed() {
SendMsg(2330, 0, 0);
}
void wxStyledTextCtrl::VCHome() {
SendMsg(2331, 0, 0);
}
void wxStyledTextCtrl::VCHomeExtend() {
SendMsg(2332, 0, 0);
}
void wxStyledTextCtrl::ZoomIn() {
SendMsg(2333, 0, 0);
}
void wxStyledTextCtrl::ZoomOut() {
SendMsg(2334, 0, 0);
}
void wxStyledTextCtrl::DelWordLeft() {
SendMsg(2335, 0, 0);
}
void wxStyledTextCtrl::DelWordRight() {
SendMsg(2336, 0, 0);
}
void wxStyledTextCtrl::LineCut() {
SendMsg(2337, 0, 0);
}
void wxStyledTextCtrl::LineDelete() {
SendMsg(2338, 0, 0);
}
void wxStyledTextCtrl::LineTranspose() {
SendMsg(2339, 0, 0);
}
void wxStyledTextCtrl::LineDuplicate() {
SendMsg(2404, 0, 0);
}
void wxStyledTextCtrl::LowerCase() {
SendMsg(2340, 0, 0);
}
void wxStyledTextCtrl::UpperCase() {
SendMsg(2341, 0, 0);
}
void wxStyledTextCtrl::LineScrollDown() {
SendMsg(2342, 0, 0);
}
void wxStyledTextCtrl::LineScrollUp() {
SendMsg(2343, 0, 0);
}
void wxStyledTextCtrl::DeleteBackNotLine() {
SendMsg(2344, 0, 0);
}
void wxStyledTextCtrl::HomeDisplay() {
SendMsg(2345, 0, 0);
}
void wxStyledTextCtrl::HomeDisplayExtend() {
SendMsg(2346, 0, 0);
}
void wxStyledTextCtrl::LineEndDisplay() {
SendMsg(2347, 0, 0);
}
void wxStyledTextCtrl::LineEndDisplayExtend() {
SendMsg(2348, 0, 0);
}
void wxStyledTextCtrl::HomeWrap() {
SendMsg(2349, 0, 0);
}
void wxStyledTextCtrl::HomeWrapExtend() {
SendMsg(2450, 0, 0);
}
void wxStyledTextCtrl::LineEndWrap() {
SendMsg(2451, 0, 0);
}
void wxStyledTextCtrl::LineEndWrapExtend() {
SendMsg(2452, 0, 0);
}
void wxStyledTextCtrl::VCHomeWrap() {
SendMsg(2453, 0, 0);
}
void wxStyledTextCtrl::VCHomeWrapExtend() {
SendMsg(2454, 0, 0);
}
void wxStyledTextCtrl::LineCopy() {
SendMsg(2455, 0, 0);
}
void wxStyledTextCtrl::MoveCaretInsideView() {
SendMsg(2401, 0, 0);
}
int wxStyledTextCtrl::LineLength(int line) {
return SendMsg(2350, line, 0);
}
void wxStyledTextCtrl::BraceHighlight(int pos1, int pos2) {
SendMsg(2351, pos1, pos2);
}
void wxStyledTextCtrl::BraceBadLight(int pos) {
SendMsg(2352, pos, 0);
}
int wxStyledTextCtrl::BraceMatch(int pos) {
return SendMsg(2353, pos, 0);
}
bool wxStyledTextCtrl::GetViewEOL() {
return SendMsg(2355, 0, 0) != 0;
}
void wxStyledTextCtrl::SetViewEOL(bool visible) {
SendMsg(2356, visible, 0);
}
void* wxStyledTextCtrl::GetDocPointer() {
return (void*)SendMsg(2357);
}
void wxStyledTextCtrl::SetDocPointer(void* docPointer) {
SendMsg(2358, 0, (long)docPointer);
}
void wxStyledTextCtrl::SetModEventMask(int mask) {
SendMsg(2359, mask, 0);
}
int wxStyledTextCtrl::GetEdgeColumn() {
return SendMsg(2360, 0, 0);
}
void wxStyledTextCtrl::SetEdgeColumn(int column) {
SendMsg(2361, column, 0);
}
int wxStyledTextCtrl::GetEdgeMode() {
return SendMsg(2362, 0, 0);
}
void wxStyledTextCtrl::SetEdgeMode(int mode) {
SendMsg(2363, mode, 0);
}
wxColour wxStyledTextCtrl::GetEdgeColour() {
long c = SendMsg(2364, 0, 0);
return wxColourFromLong(c);
}
void wxStyledTextCtrl::SetEdgeColour(const wxColour& edgeColour) {
SendMsg(2365, wxColourAsLong(edgeColour), 0);
}
void wxStyledTextCtrl::SearchAnchor() {
SendMsg(2366, 0, 0);
}
int wxStyledTextCtrl::SearchNext(int flags, const wxString& text) {
return SendMsg(2367, flags, (long)(const char*)wx2stcz(text));
}
int wxStyledTextCtrl::SearchPrev(int flags, const wxString& text) {
return SendMsg(2368, flags, (long)(const char*)wx2stcz(text));
}
int wxStyledTextCtrl::LinesOnScreen() {
return SendMsg(2370, 0, 0);
}
void wxStyledTextCtrl::UsePopUp(bool allowPopUp) {
SendMsg(2371, allowPopUp, 0);
}
bool wxStyledTextCtrl::SelectionIsRectangle() {
return SendMsg(2372, 0, 0) != 0;
}
void wxStyledTextCtrl::SetZoom(int zoom) {
SendMsg(2373, zoom, 0);
}
int wxStyledTextCtrl::GetZoom() {
return SendMsg(2374, 0, 0);
}
void* wxStyledTextCtrl::CreateDocument() {
return (void*)SendMsg(2375);
}
void wxStyledTextCtrl::AddRefDocument(void* docPointer) {
SendMsg(2376, 0, (long)docPointer);
}
void wxStyledTextCtrl::ReleaseDocument(void* docPointer) {
SendMsg(2377, 0, (long)docPointer);
}
int wxStyledTextCtrl::GetModEventMask() {
return SendMsg(2378, 0, 0);
}
void wxStyledTextCtrl::SetSTCFocus(bool focus) {
SendMsg(2380, focus, 0);
}
bool wxStyledTextCtrl::GetSTCFocus() {
return SendMsg(2381, 0, 0) != 0;
}
void wxStyledTextCtrl::SetStatus(int statusCode) {
SendMsg(2382, statusCode, 0);
}
int wxStyledTextCtrl::GetStatus() {
return SendMsg(2383, 0, 0);
}
void wxStyledTextCtrl::SetMouseDownCaptures(bool captures) {
SendMsg(2384, captures, 0);
}
bool wxStyledTextCtrl::GetMouseDownCaptures() {
return SendMsg(2385, 0, 0) != 0;
}
void wxStyledTextCtrl::SetSTCCursor(int cursorType) {
SendMsg(2386, cursorType, 0);
}
int wxStyledTextCtrl::GetSTCCursor() {
return SendMsg(2387, 0, 0);
}
void wxStyledTextCtrl::SetControlCharSymbol(int symbol) {
SendMsg(2388, symbol, 0);
}
int wxStyledTextCtrl::GetControlCharSymbol() {
return SendMsg(2389, 0, 0);
}
void wxStyledTextCtrl::WordPartLeft() {
SendMsg(2390, 0, 0);
}
void wxStyledTextCtrl::WordPartLeftExtend() {
SendMsg(2391, 0, 0);
}
void wxStyledTextCtrl::WordPartRight() {
SendMsg(2392, 0, 0);
}
void wxStyledTextCtrl::WordPartRightExtend() {
SendMsg(2393, 0, 0);
}
void wxStyledTextCtrl::SetVisiblePolicy(int visiblePolicy, int visibleSlop) {
SendMsg(2394, visiblePolicy, visibleSlop);
}
void wxStyledTextCtrl::DelLineLeft() {
SendMsg(2395, 0, 0);
}
void wxStyledTextCtrl::DelLineRight() {
SendMsg(2396, 0, 0);
}
void wxStyledTextCtrl::SetXOffset(int newOffset) {
SendMsg(2397, newOffset, 0);
}
int wxStyledTextCtrl::GetXOffset() {
return SendMsg(2398, 0, 0);
}
void wxStyledTextCtrl::ChooseCaretX() {
SendMsg(2399, 0, 0);
}
void wxStyledTextCtrl::SetXCaretPolicy(int caretPolicy, int caretSlop) {
SendMsg(2402, caretPolicy, caretSlop);
}
void wxStyledTextCtrl::SetYCaretPolicy(int caretPolicy, int caretSlop) {
SendMsg(2403, caretPolicy, caretSlop);
}
void wxStyledTextCtrl::SetPrintWrapMode(int mode) {
SendMsg(2406, mode, 0);
}
int wxStyledTextCtrl::GetPrintWrapMode() {
return SendMsg(2407, 0, 0);
}
void wxStyledTextCtrl::SetHotspotActiveForeground(bool useSetting, const wxColour& fore) {
SendMsg(2410, useSetting, wxColourAsLong(fore));
}
void wxStyledTextCtrl::SetHotspotActiveBackground(bool useSetting, const wxColour& back) {
SendMsg(2411, useSetting, wxColourAsLong(back));
}
void wxStyledTextCtrl::SetHotspotActiveUnderline(bool underline) {
SendMsg(2412, underline, 0);
}
void wxStyledTextCtrl::SetHotspotSingleLine(bool singleLine) {
SendMsg(2421, singleLine, 0);
}
void wxStyledTextCtrl::ParaDown() {
SendMsg(2413, 0, 0);
}
void wxStyledTextCtrl::ParaDownExtend() {
SendMsg(2414, 0, 0);
}
void wxStyledTextCtrl::ParaUp() {
SendMsg(2415, 0, 0);
}
void wxStyledTextCtrl::ParaUpExtend() {
SendMsg(2416, 0, 0);
}
int wxStyledTextCtrl::PositionBefore(int pos) {
return SendMsg(2417, pos, 0);
}
int wxStyledTextCtrl::PositionAfter(int pos) {
return SendMsg(2418, pos, 0);
}
void wxStyledTextCtrl::CopyRange(int start, int end) {
SendMsg(2419, start, end);
}
void wxStyledTextCtrl::CopyText(int length, const wxString& text) {
SendMsg(2420, length, (long)(const char*)wx2stcz(text));
}
void wxStyledTextCtrl::SetSelectionMode(int mode) {
SendMsg(2422, mode, 0);
}
int wxStyledTextCtrl::GetSelectionMode() {
return SendMsg(2423, 0, 0);
}
int wxStyledTextCtrl::GetLineSelStartPosition(int line) {
return SendMsg(2424, line, 0);
}
int wxStyledTextCtrl::GetLineSelEndPosition(int line) {
return SendMsg(2425, line, 0);
}
void wxStyledTextCtrl::LineDownRectExtend() {
SendMsg(2426, 0, 0);
}
void wxStyledTextCtrl::LineUpRectExtend() {
SendMsg(2427, 0, 0);
}
void wxStyledTextCtrl::CharLeftRectExtend() {
SendMsg(2428, 0, 0);
}
void wxStyledTextCtrl::CharRightRectExtend() {
SendMsg(2429, 0, 0);
}
void wxStyledTextCtrl::HomeRectExtend() {
SendMsg(2430, 0, 0);
}
void wxStyledTextCtrl::VCHomeRectExtend() {
SendMsg(2431, 0, 0);
}
void wxStyledTextCtrl::LineEndRectExtend() {
SendMsg(2432, 0, 0);
}
void wxStyledTextCtrl::PageUpRectExtend() {
SendMsg(2433, 0, 0);
}
void wxStyledTextCtrl::PageDownRectExtend() {
SendMsg(2434, 0, 0);
}
void wxStyledTextCtrl::StutteredPageUp() {
SendMsg(2435, 0, 0);
}
void wxStyledTextCtrl::StutteredPageUpExtend() {
SendMsg(2436, 0, 0);
}
void wxStyledTextCtrl::StutteredPageDown() {
SendMsg(2437, 0, 0);
}
void wxStyledTextCtrl::StutteredPageDownExtend() {
SendMsg(2438, 0, 0);
}
void wxStyledTextCtrl::WordLeftEnd() {
SendMsg(2439, 0, 0);
}
void wxStyledTextCtrl::WordLeftEndExtend() {
SendMsg(2440, 0, 0);
}
void wxStyledTextCtrl::WordRightEnd() {
SendMsg(2441, 0, 0);
}
void wxStyledTextCtrl::WordRightEndExtend() {
SendMsg(2442, 0, 0);
}
void wxStyledTextCtrl::SetWhitespaceChars(const wxString& characters) {
SendMsg(2443, 0, (long)(const char*)wx2stcz(characters));
}
void wxStyledTextCtrl::SetCharsDefault() {
SendMsg(2444, 0, 0);
}
int wxStyledTextCtrl::AutoCompGetCurrent() {
return SendMsg(2445, 0, 0);
}
void wxStyledTextCtrl::Allocate(int bytes) {
SendMsg(2446, bytes, 0);
}
int wxStyledTextCtrl::FindColumn(int line, int column) {
return SendMsg(2456, line, column);
}
bool wxStyledTextCtrl::GetCaretSticky() {
return SendMsg(2457, 0, 0) != 0;
}
void wxStyledTextCtrl::SetCaretSticky(bool useCaretStickyBehaviour) {
SendMsg(2458, useCaretStickyBehaviour, 0);
}
void wxStyledTextCtrl::ToggleCaretSticky() {
SendMsg(2459, 0, 0);
}
void wxStyledTextCtrl::SetPasteConvertEndings(bool convert) {
SendMsg(2467, convert, 0);
}
bool wxStyledTextCtrl::GetPasteConvertEndings() {
return SendMsg(2468, 0, 0) != 0;
}
void wxStyledTextCtrl::SelectionDuplicate() {
SendMsg(2469, 0, 0);
}
void wxStyledTextCtrl::SetCaretLineBackAlpha(int alpha) {
SendMsg(2470, alpha, 0);
}
int wxStyledTextCtrl::GetCaretLineBackAlpha() {
return SendMsg(2471, 0, 0);
}
void wxStyledTextCtrl::StartRecord() {
SendMsg(3001, 0, 0);
}
void wxStyledTextCtrl::StopRecord() {
SendMsg(3002, 0, 0);
}
void wxStyledTextCtrl::SetLexer(int lexer) {
SendMsg(4001, lexer, 0);
}
int wxStyledTextCtrl::GetLexer() {
return SendMsg(4002, 0, 0);
}
void wxStyledTextCtrl::Colourise(int start, int end) {
SendMsg(4003, start, end);
}
void wxStyledTextCtrl::SetProperty(const wxString& key, const wxString& value) {
SendMsg(4004, (long)(const char*)wx2stcz(key), (long)(const char*)wx2stcz(value));
}
void wxStyledTextCtrl::SetKeyWords(int keywordSet, const wxString& keyWords) {
SendMsg(4005, keywordSet, (long)(const char*)wx2stcz(keyWords));
}
void wxStyledTextCtrl::SetLexerLanguage(const wxString& language) {
SendMsg(4006, 0, (long)(const char*)wx2stcz(language));
}
wxString wxStyledTextCtrl::GetProperty(const wxString& key)
{
int len = SendMsg(SCI_GETPROPERTY, (long)(const char*)wx2stcz(key), (long)NULL);
if (!len) return wxEmptyString;
wxMemoryBuffer mbuf(len+1);
char* buf = (char*)mbuf.GetWriteBuf(len+1);
SendMsg(4008, (long)(const char*)wx2stcz(key), (long)buf);
mbuf.UngetWriteBuf(len);
mbuf.AppendByte(0);
return stc2wx(buf, len);
}
wxString wxStyledTextCtrl::GetPropertyExpanded(const wxString& key)
{
int len = SendMsg(SCI_GETPROPERTYEXPANDED, (long)(const char*)wx2stcz(key), (long)NULL);
if (!len) return wxEmptyString;
wxMemoryBuffer mbuf(len+1);
char* buf = (char*)mbuf.GetWriteBuf(len+1);
SendMsg(4009, (long)(const char*)wx2stcz(key), (long)buf);
mbuf.UngetWriteBuf(len);
mbuf.AppendByte(0);
return stc2wx(buf, len);
}
int wxStyledTextCtrl::GetPropertyInt(const wxString& key) {
return SendMsg(4010, (long)(const char*)wx2stcz(key), 0);
}
int wxStyledTextCtrl::GetStyleBitsNeeded() {
return SendMsg(4011, 0, 0);
}
int wxStyledTextCtrl::GetCurrentLine() {
int line = LineFromPosition(GetCurrentPos());
return line;
}
void wxStyledTextCtrl::StyleSetSpec(int styleNum, const wxString& spec)
{
wxStringTokenizer tkz(spec, wxT(","));
while (tkz.HasMoreTokens()) {
wxString token = tkz.GetNextToken();
wxString option = token.BeforeFirst(':');
wxString val = token.AfterFirst(':');
if (option == wxT("bold"))
StyleSetBold(styleNum, true);
else if (option == wxT("italic"))
StyleSetItalic(styleNum, true);
else if (option == wxT("underline"))
StyleSetUnderline(styleNum, true);
else if (option == wxT("eol"))
StyleSetEOLFilled(styleNum, true);
else if (option == wxT("size")) {
long points;
if (val.ToLong(&points))
StyleSetSize(styleNum, points);
}
else if (option == wxT("face"))
StyleSetFaceName(styleNum, val);
else if (option == wxT("fore"))
StyleSetForeground(styleNum, wxColourFromSpec(val));
else if (option == wxT("back"))
StyleSetBackground(styleNum, wxColourFromSpec(val));
}
}
void wxStyledTextCtrl::StyleSetFont(int styleNum, wxFont& font) {
#ifdef __WXGTK__
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;
bool italic = font.GetStyle() != wxNORMAL;
bool under = font.GetUnderlined();
wxFontEncoding encoding = font.GetEncoding();
StyleSetFontAttr(styleNum, size, faceName, bold, italic, under, encoding);
}
void wxStyledTextCtrl::StyleSetFontAttr(int styleNum, int size,
const wxString& faceName,
bool bold, bool italic,
bool underline,
wxFontEncoding encoding)
{
StyleSetSize(styleNum, size);
StyleSetFaceName(styleNum, faceName);
StyleSetBold(styleNum, bold);
StyleSetItalic(styleNum, italic);
StyleSetUnderline(styleNum, underline);
StyleSetFontEncoding(styleNum, encoding);
}
void wxStyledTextCtrl::StyleSetCharacterSet(int style, int characterSet)
{
wxFontEncoding encoding;
switch (characterSet) {
default:
case wxSTC_CHARSET_ANSI:
case wxSTC_CHARSET_DEFAULT:
encoding = wxFONTENCODING_DEFAULT;
break;
case wxSTC_CHARSET_BALTIC:
encoding = wxFONTENCODING_ISO8859_13;
break;
case wxSTC_CHARSET_CHINESEBIG5:
encoding = wxFONTENCODING_CP950;
break;
case wxSTC_CHARSET_EASTEUROPE:
encoding = wxFONTENCODING_ISO8859_2;
break;
case wxSTC_CHARSET_GB2312:
encoding = wxFONTENCODING_CP936;
break;
case wxSTC_CHARSET_GREEK:
encoding = wxFONTENCODING_ISO8859_7;
break;
case wxSTC_CHARSET_HANGUL:
encoding = wxFONTENCODING_CP949;
break;
case wxSTC_CHARSET_MAC:
encoding = wxFONTENCODING_DEFAULT;
break;
case wxSTC_CHARSET_OEM:
encoding = wxFONTENCODING_DEFAULT;
break;
case wxSTC_CHARSET_RUSSIAN:
encoding = wxFONTENCODING_KOI8;
break;
case wxSTC_CHARSET_SHIFTJIS:
encoding = wxFONTENCODING_CP932;
break;
case wxSTC_CHARSET_SYMBOL:
encoding = wxFONTENCODING_DEFAULT;
break;
case wxSTC_CHARSET_TURKISH:
encoding = wxFONTENCODING_ISO8859_9;
break;
case wxSTC_CHARSET_JOHAB:
encoding = wxFONTENCODING_DEFAULT;
break;
case wxSTC_CHARSET_HEBREW:
encoding = wxFONTENCODING_ISO8859_8;
break;
case wxSTC_CHARSET_ARABIC:
encoding = wxFONTENCODING_ISO8859_6;
break;
case wxSTC_CHARSET_VIETNAMESE:
encoding = wxFONTENCODING_DEFAULT;
break;
case wxSTC_CHARSET_THAI:
encoding = wxFONTENCODING_ISO8859_11;
break;
case wxSTC_CHARSET_CYRILLIC:
encoding = wxFONTENCODING_ISO8859_5;
break;
case wxSTC_CHARSET_8859_15:
encoding = wxFONTENCODING_ISO8859_15;;
break;
}
SendMsg(SCI_STYLESETCHARACTERSET, style, encoding+1);
}
void wxStyledTextCtrl::StyleSetFontEncoding(int style, wxFontEncoding encoding)
{
SendMsg(SCI_STYLESETCHARACTERSET, style, encoding+1);
}
void wxStyledTextCtrl::CmdKeyExecute(int cmd) {
SendMsg(cmd);
}
void wxStyledTextCtrl::SetMargins(int left, int right) {
SetMarginLeft(left);
SetMarginRight(right);
}
void wxStyledTextCtrl::GetSelection(int* startPos, int* endPos) {
if (startPos != NULL)
*startPos = SendMsg(SCI_GETSELECTIONSTART);
if (endPos != NULL)
*endPos = SendMsg(SCI_GETSELECTIONEND);
}
wxPoint wxStyledTextCtrl::PointFromPosition(int pos) {
int x = SendMsg(SCI_POINTXFROMPOSITION, 0, pos);
int y = SendMsg(SCI_POINTYFROMPOSITION, 0, pos);
return wxPoint(x, y);
}
void wxStyledTextCtrl::ScrollToLine(int line) {
m_swx->DoScrollToLine(line);
}
void wxStyledTextCtrl::ScrollToColumn(int column) {
m_swx->DoScrollToColumn(column);
}
bool wxStyledTextCtrl::SaveFile(const wxString& filename)
{
wxFile file(filename, wxFile::write);
if (!file.IsOpened())
return false;
bool success = file.Write(GetText(), *wxConvCurrent);
if (success)
SetSavePoint();
return success;
}
bool wxStyledTextCtrl::LoadFile(const wxString& filename)
{
bool success = false;
wxFile file(filename, wxFile::read);
if (file.IsOpened())
{
wxString contents;
ssize_t len = (ssize_t)file.Length();
if (len > 0)
{
#if wxUSE_UNICODE
wxMemoryBuffer buffer(len+1);
success = (file.Read(buffer.GetData(), len) == len);
if (success) {
((char*)buffer.GetData())[len] = 0;
contents = wxString(buffer, *wxConvCurrent, len);
}
#else
wxString buffer;
success = (file.Read(wxStringBuffer(buffer, len), len) == len);
contents = buffer;
#endif
}
else
{
if (len == 0)
success = true;
else
success = false;
}
if (success)
{
SetText(contents);
EmptyUndoBuffer();
SetSavePoint();
}
}
return success;
}
#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
void wxStyledTextCtrl::SetUseAntiAliasing(bool useAA) {
m_swx->SetUseAntiAliasing(useAA);
}
bool wxStyledTextCtrl::GetUseAntiAliasing() {
return m_swx->GetUseAntiAliasing();
}
void wxStyledTextCtrl::AddTextRaw(const char* text)
{
SendMsg(SCI_ADDTEXT, strlen(text), (long)text);
}
void wxStyledTextCtrl::AddTextRaw(const char* text, size_t textlen)
{
SendMsg(SCI_ADDTEXT, textlen, (long)text);
}
void wxStyledTextCtrl::InsertTextRaw(int pos, const char* text)
{
SendMsg(SCI_INSERTTEXT, pos, (long)text);
}
wxCharBuffer wxStyledTextCtrl::GetCurLineRaw(int* linePos)
{
int len = LineLength(GetCurrentLine());
if (!len) {
if (linePos) *linePos = 0;
wxCharBuffer empty;
return empty;
}
wxCharBuffer buf(len);
int pos = SendMsg(SCI_GETCURLINE, len, (long)buf.data());
if (linePos) *linePos = pos;
return buf;
}
wxCharBuffer wxStyledTextCtrl::GetLineRaw(int line)
{
int len = LineLength(line);
if (!len) {
wxCharBuffer empty;
return empty;
}
wxCharBuffer buf(len);
SendMsg(SCI_GETLINE, line, (long)buf.data());
return buf;
}
wxCharBuffer wxStyledTextCtrl::GetSelectedTextRaw()
{
int start;
int end;
GetSelection(&start, &end);
int len = end - start;
if (!len) {
wxCharBuffer empty;
return empty;
}
wxCharBuffer buf(len);
SendMsg(SCI_GETSELTEXT, 0, (long)buf.data());
return buf;
}
wxCharBuffer wxStyledTextCtrl::GetTextRangeRaw(int startPos, int endPos)
{
if (endPos < startPos) {
int temp = startPos;
startPos = endPos;
endPos = temp;
}
int len = endPos - startPos;
if (!len) {
wxCharBuffer empty;
return empty;
}
wxCharBuffer buf(len);
TextRange tr;
tr.lpstrText = buf.data();
tr.chrg.cpMin = startPos;
tr.chrg.cpMax = endPos;
SendMsg(SCI_GETTEXTRANGE, 0, (long)&tr);
return buf;
}
void wxStyledTextCtrl::SetTextRaw(const char* text)
{
SendMsg(SCI_SETTEXT, 0, (long)text);
}
wxCharBuffer wxStyledTextCtrl::GetTextRaw()
{
int len = GetTextLength();
wxCharBuffer buf(len+1);
SendMsg(SCI_GETTEXT, len+1, (long)buf.data());
return buf;
}
void wxStyledTextCtrl::AppendTextRaw(const char* text)
{
SendMsg(SCI_APPENDTEXT, strlen(text), (long)text);
}
void wxStyledTextCtrl::OnPaint(wxPaintEvent& WXUNUSED(evt)) {
wxPaintDC dc(this);
m_swx->DoPaint(&dc, GetUpdateRegion().GetBox());
}
void wxStyledTextCtrl::OnScrollWin(wxScrollWinEvent& evt) {
if (evt.GetOrientation() == wxHORIZONTAL)
m_swx->DoHScroll(evt.GetEventType(), evt.GetPosition());
else
m_swx->DoVScroll(evt.GetEventType(), evt.GetPosition());
}
void wxStyledTextCtrl::OnScroll(wxScrollEvent& evt) {
wxScrollBar* sb = wxDynamicCast(evt.GetEventObject(), wxScrollBar);
if (sb) {
if (sb->IsVertical())
m_swx->DoVScroll(evt.GetEventType(), evt.GetPosition());
else
m_swx->DoHScroll(evt.GetEventType(), evt.GetPosition());
}
}
void wxStyledTextCtrl::OnSize(wxSizeEvent& WXUNUSED(evt)) {
if (m_swx) {
wxSize sz = GetClientSize();
m_swx->DoSize(sz.x, sz.y);
}
}
void wxStyledTextCtrl::OnMouseLeftDown(wxMouseEvent& evt) {
SetFocus();
wxPoint pt = evt.GetPosition();
m_swx->DoLeftButtonDown(Point(pt.x, pt.y), m_stopWatch.Time(),
evt.ShiftDown(), evt.ControlDown(), evt.AltDown());
}
void wxStyledTextCtrl::OnMouseMove(wxMouseEvent& evt) {
wxPoint pt = evt.GetPosition();
m_swx->DoLeftButtonMove(Point(pt.x, pt.y));
}
void wxStyledTextCtrl::OnMouseLeftUp(wxMouseEvent& evt) {
wxPoint pt = evt.GetPosition();
m_swx->DoLeftButtonUp(Point(pt.x, pt.y), m_stopWatch.Time(),
evt.ControlDown());
}
void wxStyledTextCtrl::OnMouseRightUp(wxMouseEvent& evt) {
wxPoint pt = evt.GetPosition();
m_swx->DoContextMenu(Point(pt.x, pt.y));
}
void wxStyledTextCtrl::OnMouseMiddleUp(wxMouseEvent& evt) {
wxPoint pt = evt.GetPosition();
m_swx->DoMiddleButtonUp(Point(pt.x, pt.y));
}
void wxStyledTextCtrl::OnContextMenu(wxContextMenuEvent& evt) {
wxPoint pt = evt.GetPosition();
ScreenToClient(&pt.x, &pt.y);
wxHitTest ht = this->HitTest(pt);
if (ht != wxHT_WINDOW_INSIDE) {
pt = this->PointFromPosition(this->GetCurrentPos());
}
m_swx->DoContextMenu(Point(pt.x, pt.y));
}
void wxStyledTextCtrl::OnMouseWheel(wxMouseEvent& evt) {
m_swx->DoMouseWheel(evt.GetWheelRotation(),
evt.GetWheelDelta(),
evt.GetLinesPerAction(),
evt.ControlDown(),
evt.IsPageScroll());
}
void wxStyledTextCtrl::OnChar(wxKeyEvent& evt) {
bool ctrl = evt.ControlDown();
#ifdef __WXMAC__
bool alt = false;
#else
bool alt = evt.AltDown();
#endif
bool skip = ((ctrl || alt) && ! (ctrl && alt));
if (!m_lastKeyDownConsumed && !skip) {
#if wxUSE_UNICODE
int key = evt.GetUnicodeKey();
bool keyOk = true;
if (key <= 127) {
key = evt.GetKeyCode();
keyOk = (key <= 127);
}
if (keyOk) {
m_swx->DoAddChar(key);
return;
}
#else
int key = evt.GetKeyCode();
if (key <= WXK_START || key > WXK_COMMAND) {
m_swx->DoAddChar(key);
return;
}
#endif
}
evt.Skip();
}
void wxStyledTextCtrl::OnKeyDown(wxKeyEvent& evt) {
int processed = m_swx->DoKeyDown(evt, &m_lastKeyDownConsumed);
if (!processed && !m_lastKeyDownConsumed)
evt.Skip();
}
void wxStyledTextCtrl::OnLoseFocus(wxFocusEvent& evt) {
m_swx->DoLoseFocus();
evt.Skip();
}
void wxStyledTextCtrl::OnGainFocus(wxFocusEvent& evt) {
m_swx->DoGainFocus();
evt.Skip();
}
void wxStyledTextCtrl::OnSysColourChanged(wxSysColourChangedEvent& WXUNUSED(evt)) {
m_swx->DoSysColourChange();
}
void wxStyledTextCtrl::OnEraseBackground(wxEraseEvent& WXUNUSED(evt)) {
}
void wxStyledTextCtrl::OnMenu(wxCommandEvent& evt) {
m_swx->DoCommand(evt.GetId());
}
void wxStyledTextCtrl::OnListBox(wxCommandEvent& WXUNUSED(evt)) {
m_swx->DoOnListBox();
}
void wxStyledTextCtrl::OnIdle(wxIdleEvent& evt) {
m_swx->DoOnIdle(evt);
}
wxSize wxStyledTextCtrl::DoGetBestSize() const
{
return wxSize(200,100);
}
void wxStyledTextCtrl::NotifyChange() {
wxStyledTextEvent evt(wxEVT_STC_CHANGE, GetId());
evt.SetEventObject(this);
GetEventHandler()->ProcessEvent(evt);
}
static void SetEventText(wxStyledTextEvent& evt, const char* text,
size_t length) {
if(!text) return;
evt.SetText(stc2wx(text, length));
}
void wxStyledTextCtrl::NotifyParent(SCNotification* _scn) {
SCNotification& scn = *_scn;
wxStyledTextEvent evt(0, GetId());
evt.SetEventObject(this);
evt.SetPosition(scn.position);
evt.SetKey(scn.ch);
evt.SetModifiers(scn.modifiers);
switch (scn.nmhdr.code) {
case SCN_STYLENEEDED:
evt.SetEventType(wxEVT_STC_STYLENEEDED);
break;
case SCN_CHARADDED:
evt.SetEventType(wxEVT_STC_CHARADDED);
break;
case SCN_SAVEPOINTREACHED:
evt.SetEventType(wxEVT_STC_SAVEPOINTREACHED);
break;
case SCN_SAVEPOINTLEFT:
evt.SetEventType(wxEVT_STC_SAVEPOINTLEFT);
break;
case SCN_MODIFYATTEMPTRO:
evt.SetEventType(wxEVT_STC_ROMODIFYATTEMPT);
break;
case SCN_KEY:
evt.SetEventType(wxEVT_STC_KEY);
break;
case SCN_DOUBLECLICK:
evt.SetEventType(wxEVT_STC_DOUBLECLICK);
break;
case SCN_UPDATEUI:
evt.SetEventType(wxEVT_STC_UPDATEUI);
break;
case SCN_MODIFIED:
evt.SetEventType(wxEVT_STC_MODIFIED);
evt.SetModificationType(scn.modificationType);
SetEventText(evt, scn.text, scn.length);
evt.SetLength(scn.length);
evt.SetLinesAdded(scn.linesAdded);
evt.SetLine(scn.line);
evt.SetFoldLevelNow(scn.foldLevelNow);
evt.SetFoldLevelPrev(scn.foldLevelPrev);
break;
case SCN_MACRORECORD:
evt.SetEventType(wxEVT_STC_MACRORECORD);
evt.SetMessage(scn.message);
evt.SetWParam(scn.wParam);
evt.SetLParam(scn.lParam);
break;
case SCN_MARGINCLICK:
evt.SetEventType(wxEVT_STC_MARGINCLICK);
evt.SetMargin(scn.margin);
break;
case SCN_NEEDSHOWN:
evt.SetEventType(wxEVT_STC_NEEDSHOWN);
evt.SetLength(scn.length);
break;
case SCN_PAINTED:
evt.SetEventType(wxEVT_STC_PAINTED);
break;
case SCN_AUTOCSELECTION:
evt.SetEventType(wxEVT_STC_AUTOCOMP_SELECTION);
evt.SetListType(scn.listType);
SetEventText(evt, scn.text, strlen(scn.text));
evt.SetPosition(scn.lParam);
break;
case SCN_USERLISTSELECTION:
evt.SetEventType(wxEVT_STC_USERLISTSELECTION);
evt.SetListType(scn.listType);
SetEventText(evt, scn.text, strlen(scn.text));
evt.SetPosition(scn.lParam);
break;
case SCN_URIDROPPED:
evt.SetEventType(wxEVT_STC_URIDROPPED);
SetEventText(evt, scn.text, strlen(scn.text));
break;
case SCN_DWELLSTART:
evt.SetEventType(wxEVT_STC_DWELLSTART);
evt.SetX(scn.x);
evt.SetY(scn.y);
break;
case SCN_DWELLEND:
evt.SetEventType(wxEVT_STC_DWELLEND);
evt.SetX(scn.x);
evt.SetY(scn.y);
break;
case SCN_ZOOM:
evt.SetEventType(wxEVT_STC_ZOOM);
break;
case SCN_HOTSPOTCLICK:
evt.SetEventType(wxEVT_STC_HOTSPOT_CLICK);
break;
case SCN_HOTSPOTDOUBLECLICK:
evt.SetEventType(wxEVT_STC_HOTSPOT_DCLICK);
break;
case SCN_CALLTIPCLICK:
evt.SetEventType(wxEVT_STC_CALLTIP_CLICK);
break;
default:
return;
}
GetEventHandler()->ProcessEvent(evt);
}
wxStyledTextEvent::wxStyledTextEvent(wxEventType commandType, int id)
: wxCommandEvent(commandType, id)
{
m_position = 0;
m_key = 0;
m_modifiers = 0;
m_modificationType = 0;
m_length = 0;
m_linesAdded = 0;
m_line = 0;
m_foldLevelNow = 0;
m_foldLevelPrev = 0;
m_margin = 0;
m_message = 0;
m_wParam = 0;
m_lParam = 0;
m_listType = 0;
m_x = 0;
m_y = 0;
m_dragAllowMove = false;
#if wxUSE_DRAG_AND_DROP
m_dragResult = wxDragNone;
#endif
}
bool wxStyledTextEvent::GetShift() const { return (m_modifiers & SCI_SHIFT) != 0; }
bool wxStyledTextEvent::GetControl() const { return (m_modifiers & SCI_CTRL) != 0; }
bool wxStyledTextEvent::GetAlt() const { return (m_modifiers & SCI_ALT) != 0; }
wxStyledTextEvent::wxStyledTextEvent(const wxStyledTextEvent& event):
wxCommandEvent(event)
{
m_position = event.m_position;
m_key = event.m_key;
m_modifiers = event.m_modifiers;
m_modificationType = event.m_modificationType;
m_text = event.m_text;
m_length = event.m_length;
m_linesAdded = event.m_linesAdded;
m_line = event.m_line;
m_foldLevelNow = event.m_foldLevelNow;
m_foldLevelPrev = event.m_foldLevelPrev;
m_margin = event.m_margin;
m_message = event.m_message;
m_wParam = event.m_wParam;
m_lParam = event.m_lParam;
m_listType = event.m_listType;
m_x = event.m_x;
m_y = event.m_y;
m_dragText = event.m_dragText;
m_dragAllowMove =event.m_dragAllowMove;
#if wxUSE_DRAG_AND_DROP
m_dragResult = event.m_dragResult;
#endif
}