////////////////////////////////////////////////////////////////////////////
// Name: stc.cpp
-// Purpose: A wxWindows implementation of Scintilla. This class is the
+// Purpose: A wxWidgets implementation of Scintilla. This class is the
// one meant to be used directly by wx applications. It does not
// derive directly from the Scintilla classes, but instead
// delegates most things to the real Scintilla class.
DEFINE_EVENT_TYPE( wxEVT_STC_MACRORECORD )
DEFINE_EVENT_TYPE( wxEVT_STC_MARGINCLICK )
DEFINE_EVENT_TYPE( wxEVT_STC_NEEDSHOWN )
-DEFINE_EVENT_TYPE( wxEVT_STC_POSCHANGED )
DEFINE_EVENT_TYPE( wxEVT_STC_PAINTED )
DEFINE_EVENT_TYPE( wxEVT_STC_USERLISTSELECTION )
DEFINE_EVENT_TYPE( wxEVT_STC_URIDROPPED )
// Put Scintilla into unicode (UTF-8) mode
SetCodePage(wxSTC_CP_UTF8);
#endif
+
+ SetBestFittingSize(size);
}
if (len > 0)
{
#if wxUSE_UNICODE
- wxMemoryBuffer buffer(len);
+ wxMemoryBuffer buffer(len+1);
success = (file.Read(buffer.GetData(), len) == len);
- contents = wxString(buffer, *wxConvCurrent);
+ if (success) {
+ ((char*)buffer.GetData())[len] = 0;
+ contents = wxString(buffer, *wxConvCurrent, len);
+ }
#else
wxString buffer;
success = (file.Read(wxStringBuffer(buffer, len), len) == len);
void wxStyledTextCtrl::OnContextMenu(wxContextMenuEvent& evt) {
wxPoint pt = evt.GetPosition();
ScreenToClient(&pt.x, &pt.y);
+ /*
+ Show context menu at event point if it's within the window,
+ or at caret location if not
+ */
+ wxHitTest ht = this->HitTest(pt);
+ if (ht != wxHT_WINDOW_INSIDE) {
+ pt = this->PointFromPosition(this->GetCurrentPos());
+ }
m_swx->DoContextMenu(Point(pt.x, pt.y));
}
// printf("OnChar key:%%d consumed:%%d ctrl:%%d alt:%%d skip:%%d\n",
// key, m_lastKeyDownConsumed, ctrl, alt, skip);
- if ( (key <= WXK_START || key > WXK_NUMPAD_DIVIDE) &&
+ if ( (key <= WXK_START || key > WXK_COMMAND) &&
!m_lastKeyDownConsumed && !skip) {
m_swx->DoAddChar(key);
return;
}
-void wxStyledTextCtrl::OnLoseFocus(wxFocusEvent& WXUNUSED(evt)) {
+void wxStyledTextCtrl::OnLoseFocus(wxFocusEvent& evt) {
m_swx->DoLoseFocus();
+ evt.Skip();
}
-void wxStyledTextCtrl::OnGainFocus(wxFocusEvent& WXUNUSED(evt)) {
+void wxStyledTextCtrl::OnGainFocus(wxFocusEvent& evt) {
m_swx->DoGainFocus();
+ evt.Skip();
}
}
+wxSize wxStyledTextCtrl::DoGetBestSize() const
+{
+ // What would be the best size for a wxSTC?
+ // Just give a reasonable minimum until something else can be figured out.
+ return wxSize(200,100);
+}
+
+
//----------------------------------------------------------------------
// Turn notifications from Scintilla into events