m_swx = new ScintillaWX(this);
m_stopWatch.Start();
m_lastKeyDownConsumed = false;
+ m_lastWheelTimestamp = 0;
m_vScrollBar = NULL;
m_hScrollBar = NULL;
#if wxUSE_UNICODE
}
// Are there any redoable actions in the undo history?
-bool wxStyledTextCtrl::CanRedo()
+bool wxStyledTextCtrl::CanRedo() const
{
return SendMsg(2016, 0, 0) != 0;
}
}
// Find the position from a point within the window.
-int wxStyledTextCtrl::PositionFromPoint(wxPoint pt) {
+int wxStyledTextCtrl::PositionFromPoint(wxPoint pt) const {
return SendMsg(2022, pt.x, pt.y);
}
}
// Retrieve the contents of a line.
-wxString wxStyledTextCtrl::GetLine(int line) {
+wxString wxStyledTextCtrl::GetLine(int line) const {
int len = LineLength(line);
if (!len) return wxEmptyString;
}
// Retrieve the line containing a position.
-int wxStyledTextCtrl::LineFromPosition(int pos)
+int wxStyledTextCtrl::LineFromPosition(int pos) const
{
return SendMsg(2166, pos, 0);
}
// Retrieve the position at the start of a line.
-int wxStyledTextCtrl::PositionFromLine(int line)
+int wxStyledTextCtrl::PositionFromLine(int line) const
{
return SendMsg(2167, line, 0);
}
}
// Are there any undoable actions in the undo history?
-bool wxStyledTextCtrl::CanUndo()
+bool wxStyledTextCtrl::CanUndo() const
{
return SendMsg(2174, 0, 0) != 0;
}
}
// Retrieve all the text in the document.
-wxString wxStyledTextCtrl::GetText() {
+wxString wxStyledTextCtrl::GetText() const {
int len = GetTextLength();
wxMemoryBuffer mbuf(len+1); // leave room for the null...
char* buf = (char*)mbuf.GetWriteBuf(len+1);
}
// How many characters are on a line, not including end of line characters?
-int wxStyledTextCtrl::LineLength(int line)
+int wxStyledTextCtrl::LineLength(int line) const
{
return SendMsg(2350, line, 0);
}
}
+#if wxUSE_TEXTCTRL
+bool wxStyledTextCtrl::DoSaveFile(const wxString& filename, int WXUNUSED(fileType))
+#else
bool wxStyledTextCtrl::SaveFile(const wxString& filename)
+#endif
{
wxFile file(filename, wxFile::write);
return success;
}
+#if wxUSE_TEXTCTRL
+bool wxStyledTextCtrl::DoLoadFile(const wxString& filename, int WXUNUSED(fileType))
+#else
bool wxStyledTextCtrl::LoadFile(const wxString& filename)
+#endif
{
bool success = false;
wxFile file(filename, wxFile::read);
wxCharBuffer wxStyledTextCtrl::GetTextRaw()
{
- int len = GetTextLength();
- wxCharBuffer buf(len);
- SendMsg(SCI_GETTEXT, len, (long)buf.data());
+ int len = GetTextLength();
+ wxCharBuffer buf(len); // adds 1 for NUL automatically
+ SendMsg(SCI_GETTEXT, len + 1, (long)buf.data());
return buf;
}
}
-void wxStyledTextCtrl::OnMouseWheel(wxMouseEvent& evt) {
- m_swx->DoMouseWheel(evt.GetWheelRotation(),
- evt.GetWheelDelta(),
- evt.GetLinesPerAction(),
- evt.ControlDown(),
- evt.IsPageScroll());
+void wxStyledTextCtrl::OnMouseWheel(wxMouseEvent& evt)
+{
+ // prevent having an event queue with wheel events that cannot be processed
+ // reasonably fast (see ticket #9057)
+ if ( m_lastWheelTimestamp <= evt.GetTimestamp() )
+ {
+ m_lastWheelTimestamp = m_stopWatch.Time();
+ m_swx->DoMouseWheel(evt.GetWheelRotation(),
+ evt.GetWheelDelta(),
+ evt.GetLinesPerAction(),
+ evt.ControlDown(),
+ evt.IsPageScroll());
+ m_lastWheelTimestamp = m_stopWatch.Time() - m_lastWheelTimestamp;
+ m_lastWheelTimestamp += evt.GetTimestamp();
+ }
}