// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
-#include <ctype.h>
+// For compilers that support precompilation, includes "wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
-#include <wx/wx.h>
-#include <wx/tokenzr.h>
-#include <wx/mstream.h>
-#include <wx/image.h>
-#include <wx/file.h>
+#if wxUSE_STC
#include "wx/stc/stc.h"
+#include "wx/stc/private.h"
+
+#ifndef WX_PRECOMP
+ #include "wx/wx.h"
+#endif // WX_PRECOMP
+
+#include <ctype.h>
+
+#include "wx/tokenzr.h"
+#include "wx/mstream.h"
+#include "wx/image.h"
+#include "wx/file.h"
+
#include "ScintillaWX.h"
//----------------------------------------------------------------------
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 )
+DEFINE_EVENT_TYPE( wxEVT_STC_INDICATOR_CLICK )
+DEFINE_EVENT_TYPE( wxEVT_STC_INDICATOR_RELEASE )
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))
SetCodePage(wxSTC_CP_UTF8);
#endif
- SetBestFittingSize(size);
+ SetInitialSize(size);
// Reduces flicker on GTK+/X11
SetBackgroundStyle(wxBG_STYLE_CUSTOM);
+
+ // Make sure it can take the focus
+ SetCanFocus(true);
+
return true;
}
}
+// Get the font of a style
+wxFont wxStyledTextCtrl::StyleGetFont(int style) {
+ wxFont font;
+ font.SetPointSize(StyleGetSize(style));
+ font.SetFaceName(StyleGetFaceName(style));
+ if( StyleGetBold(style) )
+ font.SetWeight(wxFONTWEIGHT_BOLD);
+ else
+ font.SetWeight(wxFONTWEIGHT_NORMAL);
+
+ if( StyleGetItalic(style) )
+ font.SetStyle(wxFONTSTYLE_ITALIC);
+ else
+ font.SetStyle(wxFONTSTYLE_NORMAL);
+
+ return font;
+}
+
+
// Set style size, face, bold, italic, and underline attributes from
// a wxFont's attributes.
void wxStyledTextCtrl::StyleSetFont(int styleNum, wxFont& font) {
bool italic = font.GetStyle() != wxNORMAL;
bool under = font.GetUnderlined();
wxFontEncoding encoding = font.GetEncoding();
-
+
StyleSetFontAttr(styleNum, size, faceName, bold, italic, under, encoding);
}
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;
}
// We just have Scintilla track the wxFontEncoding for us. It gets used
if (!len) {
wxCharBuffer empty;
return empty;
- }
+ }
wxCharBuffer buf(len);
SendMsg(SCI_GETSELTEXT, 0, (long)buf.data());
if (!len) {
wxCharBuffer empty;
return empty;
- }
+ }
wxCharBuffer buf(len);
TextRange tr;
#endif
bool skip = ((ctrl || alt) && ! (ctrl && alt));
+#if wxUSE_UNICODE
+ // apparently if we don't do this, Unicode keys pressed after non-char
+ // ASCII ones (e.g. Enter, Tab) are not taken into account (patch 1615989)
+ if (m_lastKeyDownConsumed && evt.GetUnicodeKey() > 255)
+ m_lastKeyDownConsumed = false;
+#endif
+
if (!m_lastKeyDownConsumed && !skip) {
#if wxUSE_UNICODE
int key = evt.GetUnicodeKey();
}
#endif
}
-
+
evt.Skip();
}
size_t length) {
if(!text) return;
- // The unicode conversion MUST have a null byte to terminate the
- // string so move it into a buffer first and give it one.
- wxMemoryBuffer buf(length+1);
- buf.AppendData((void*)text, length);
- buf.AppendByte(0);
- evt.SetText(stc2wx(buf));
+ evt.SetText(stc2wx(text, length));
}
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_CALLTIP_CLICK);
break;
+ case SCN_INDICATORCLICK:
+ evt.SetEventType(wxEVT_STC_INDICATOR_CLICK);
+ break;
+
+ case SCN_INDICATORRELEASE:
+ evt.SetEventType(wxEVT_STC_INDICATOR_RELEASE);
+ break;
+
default:
return;
}
//----------------------------------------------------------------------
//----------------------------------------------------------------------
-
-
-
-
-
-
-
-
+#endif // wxUSE_STC