Add Scintilla FineTicker methods to wxSTC
Starting with version 3.5, Scintilla implemented a newer method for handling timers and used this method in its Windows, GTK+, Cocoa, and Qt ports. This patch attempts to bring the timer handling for wxSTC in line with those other ports. Closes #17949.
This commit is contained in:
parent
6c01707627
commit
33ad8063d6
@ -155,6 +155,7 @@ All (GUI):
|
||||
- Never restore size smaller than the best one in wxPersistentTLW.
|
||||
- Fix escaping/unescaping characters in wxLongStringProperty in wxPG (mikek).
|
||||
- Ensure that navigation order reflects layout of wxStdDialogButtonSizer.
|
||||
- Add Scintilla FineTicker methods to wxSTC (NewPagodi).
|
||||
|
||||
wxGTK:
|
||||
|
||||
|
@ -56,16 +56,18 @@
|
||||
|
||||
class wxSTCTimer : public wxTimer {
|
||||
public:
|
||||
wxSTCTimer(ScintillaWX* swx) {
|
||||
wxSTCTimer(ScintillaWX* swx, ScintillaWX::TickReason reason) {
|
||||
m_swx = swx;
|
||||
m_reason = reason;
|
||||
}
|
||||
|
||||
void Notify() wxOVERRIDE {
|
||||
m_swx->DoTick();
|
||||
m_swx->TickFor(m_reason);
|
||||
}
|
||||
|
||||
private:
|
||||
ScintillaWX* m_swx;
|
||||
ScintillaWX::TickReason m_reason;
|
||||
};
|
||||
|
||||
|
||||
@ -263,10 +265,19 @@ ScintillaWX::ScintillaWX(wxStyledTextCtrl* win) {
|
||||
#endif
|
||||
#endif // wxHAVE_STC_RECT_FORMAT
|
||||
|
||||
//A timer is needed for each member of TickReason enum except tickPlatform
|
||||
timers[tickCaret] = new wxSTCTimer(this,tickCaret);
|
||||
timers[tickScroll] = new wxSTCTimer(this,tickScroll);
|
||||
timers[tickWiden] = new wxSTCTimer(this,tickWiden);
|
||||
timers[tickDwell] = new wxSTCTimer(this,tickDwell);
|
||||
}
|
||||
|
||||
|
||||
ScintillaWX::~ScintillaWX() {
|
||||
for ( TimersHash::iterator i=timers.begin(); i!=timers.end(); ++i ) {
|
||||
delete i->second;
|
||||
}
|
||||
timers.clear();
|
||||
Finalise();
|
||||
}
|
||||
|
||||
@ -306,7 +317,6 @@ void ScintillaWX::Initialise() {
|
||||
|
||||
void ScintillaWX::Finalise() {
|
||||
ScintillaBase::Finalise();
|
||||
SetTicking(false);
|
||||
SetIdle(false);
|
||||
DestroySystemCaret();
|
||||
}
|
||||
@ -357,25 +367,6 @@ bool ScintillaWX::SetIdle(bool on) {
|
||||
}
|
||||
|
||||
|
||||
void ScintillaWX::SetTicking(bool on) {
|
||||
wxSTCTimer* steTimer;
|
||||
if (timer.ticking != on) {
|
||||
timer.ticking = on;
|
||||
if (timer.ticking) {
|
||||
steTimer = new wxSTCTimer(this);
|
||||
steTimer->Start(timer.tickSize);
|
||||
timer.tickerID = steTimer;
|
||||
} else {
|
||||
steTimer = (wxSTCTimer*)timer.tickerID;
|
||||
steTimer->Stop();
|
||||
delete steTimer;
|
||||
timer.tickerID = 0;
|
||||
}
|
||||
}
|
||||
timer.ticksToWait = caret.period;
|
||||
}
|
||||
|
||||
|
||||
void ScintillaWX::SetMouseCapture(bool on) {
|
||||
if (mouseDownCaptures) {
|
||||
if (on && !capturedMouse)
|
||||
@ -741,6 +732,36 @@ bool ScintillaWX::DestroySystemCaret() {
|
||||
#endif
|
||||
}
|
||||
|
||||
bool ScintillaWX::FineTickerAvailable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ScintillaWX::FineTickerRunning(TickReason reason) {
|
||||
bool running = false;
|
||||
TimersHash::iterator i = timers.find(reason);
|
||||
wxASSERT_MSG( i != timers.end(), "At least one TickReason is missing a timer.");
|
||||
if ( i != timers.end() ) {
|
||||
running = i->second->IsRunning();
|
||||
}
|
||||
return running;
|
||||
}
|
||||
|
||||
void ScintillaWX::FineTickerStart(TickReason reason, int millis,
|
||||
int WXUNUSED(tolerance)) {
|
||||
TimersHash::iterator i = timers.find(reason);
|
||||
wxASSERT_MSG( i != timers.end(), "At least one TickReason is missing a timer." );
|
||||
if ( i != timers.end() ) {
|
||||
i->second->Start(millis);
|
||||
}
|
||||
}
|
||||
|
||||
void ScintillaWX::FineTickerCancel(TickReason reason) {
|
||||
TimersHash::iterator i = timers.find(reason);
|
||||
wxASSERT_MSG( i != timers.end(), "At least one TickReason is missing a timer." );
|
||||
if ( i != timers.end() ) {
|
||||
i->second->Stop();
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
@ -971,7 +992,6 @@ void ScintillaWX::DoLoseFocus(){
|
||||
SetFocusState(false);
|
||||
focusEvent = false;
|
||||
DestroySystemCaret();
|
||||
SetTicking(false);
|
||||
}
|
||||
|
||||
void ScintillaWX::DoGainFocus(){
|
||||
@ -980,7 +1000,6 @@ void ScintillaWX::DoGainFocus(){
|
||||
focusEvent = false;
|
||||
DestroySystemCaret();
|
||||
CreateSystemCaret();
|
||||
SetTicking(true);
|
||||
}
|
||||
|
||||
void ScintillaWX::DoSysColourChange() {
|
||||
|
@ -86,7 +86,7 @@
|
||||
class WXDLLIMPEXP_FWD_CORE wxDC;
|
||||
class WXDLLIMPEXP_FWD_STC wxStyledTextCtrl; // forward
|
||||
class ScintillaWX;
|
||||
|
||||
class wxSTCTimer;
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Helper classes
|
||||
@ -121,7 +121,6 @@ public:
|
||||
virtual void Finalise() wxOVERRIDE;
|
||||
virtual void StartDrag() wxOVERRIDE;
|
||||
virtual bool SetIdle(bool on) wxOVERRIDE;
|
||||
virtual void SetTicking(bool on) wxOVERRIDE;
|
||||
virtual void SetMouseCapture(bool on) wxOVERRIDE;
|
||||
virtual bool HaveMouseCapture() wxOVERRIDE;
|
||||
virtual void ScrollText(int linesToMove) wxOVERRIDE;
|
||||
@ -149,6 +148,10 @@ public:
|
||||
virtual void CancelModes() wxOVERRIDE;
|
||||
|
||||
virtual void UpdateSystemCaret() wxOVERRIDE;
|
||||
virtual bool FineTickerAvailable() wxOVERRIDE;
|
||||
virtual bool FineTickerRunning(TickReason reason) wxOVERRIDE;
|
||||
virtual void FineTickerStart(TickReason reason, int millis, int tolerance) wxOVERRIDE;
|
||||
virtual void FineTickerCancel(TickReason reason) wxOVERRIDE;
|
||||
|
||||
// Event delegates
|
||||
void DoPaint(wxDC* dc, wxRect rect);
|
||||
@ -168,7 +171,6 @@ public:
|
||||
bool ctrlDown, bool isPageScroll);
|
||||
void DoAddChar(int key);
|
||||
int DoKeyDown(const wxKeyEvent& event, bool* consumed);
|
||||
void DoTick() { Tick(); }
|
||||
void DoOnIdle(wxIdleEvent& evt);
|
||||
|
||||
#if wxUSE_DRAG_AND_DROP
|
||||
@ -199,6 +201,9 @@ private:
|
||||
bool focusEvent;
|
||||
wxStyledTextCtrl* stc;
|
||||
|
||||
WX_DECLARE_HASH_MAP(TickReason, wxSTCTimer*, wxIntegerHash, wxIntegerEqual, TimersHash);
|
||||
TimersHash timers;
|
||||
|
||||
#if wxUSE_DRAG_AND_DROP
|
||||
wxSTCDropTarget* dropTarget;
|
||||
wxDragResult dragResult;
|
||||
@ -227,6 +232,7 @@ private:
|
||||
#endif
|
||||
|
||||
friend class wxSTCCallTip;
|
||||
friend class wxSTCTimer; // To get access to TickReason declaration
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
Loading…
Reference in New Issue
Block a user