From 16a2477b74aa06480e3525c36ee2624bf5a5a608 Mon Sep 17 00:00:00 2001 From: Markus Gans Date: Sat, 19 Dec 2015 20:49:01 +0100 Subject: [PATCH] Add delOwnTimer() for FObject --- src/fapp.cpp | 8 ++++---- src/fbutton.cpp | 2 +- src/flineedit.cpp | 8 ++++---- src/flistbox.cpp | 14 +++++++------- src/fmenubar.cpp | 2 ++ src/fobject.cpp | 27 ++++++++++++++++++++++++++- src/fobject.h | 1 + test/ui.cpp | 8 ++++---- test/watch.cpp | 2 +- 9 files changed, 50 insertions(+), 22 deletions(-) diff --git a/src/fapp.cpp b/src/fapp.cpp index c6ebcca6..1e6cc52f 100644 --- a/src/fapp.cpp +++ b/src/fapp.cpp @@ -987,11 +987,11 @@ void FApplication::processMouseEvent() FWindow::raiseWindow (FWindow::getActiveWindow()); FWindow::getActiveWindow()->getFocusWidget()->setFocus(); FWindow::getActiveWindow()->redraw(); - if ( statusBar() ) - statusBar()->drawMessage(); - updateTerminal(); - flush_out(); } + if ( statusBar() ) + statusBar()->drawMessage(); + updateTerminal(); + flush_out(); } } diff --git a/src/fbutton.cpp b/src/fbutton.cpp index 427ec73d..292440db 100644 --- a/src/fbutton.cpp +++ b/src/fbutton.cpp @@ -52,7 +52,7 @@ FButton::FButton (const FString& txt, FWidget* parent) FButton::~FButton() // destructor { delAccelerator(); - delAllTimer(); + delOwnTimer(); } diff --git a/src/flineedit.cpp b/src/flineedit.cpp index 67a25614..53335edf 100644 --- a/src/flineedit.cpp +++ b/src/flineedit.cpp @@ -578,7 +578,7 @@ void FLineEdit::onMouseUp (FMouseEvent*) { if ( dragScroll != FLineEdit::noScroll ) { - delAllTimer(); + delOwnTimer(); dragScroll = FLineEdit::noScroll; scrollTimer = false; } @@ -618,7 +618,7 @@ void FLineEdit::onMouseMove (FMouseEvent* ev) } if ( offset == 0 ) { - delAllTimer(); + delOwnTimer(); dragScroll = FLineEdit::noScroll; } } @@ -633,14 +633,14 @@ void FLineEdit::onMouseMove (FMouseEvent* ev) } if ( offset == len-width+2 ) { - delAllTimer(); + delOwnTimer(); dragScroll = FLineEdit::noScroll; } } else { // no dragging - delAllTimer(); + delOwnTimer(); scrollTimer = false; dragScroll = FLineEdit::noScroll; } diff --git a/src/flistbox.cpp b/src/flistbox.cpp index fc940760..6d499b9c 100644 --- a/src/flistbox.cpp +++ b/src/flistbox.cpp @@ -80,7 +80,7 @@ FListBox::FListBox(FWidget* parent) //---------------------------------------------------------------------- FListBox::~FListBox() // destructor { - delAllTimer(); + delOwnTimer(); delete VBar; delete HBar; } @@ -972,7 +972,7 @@ void FListBox::onMouseUp (FMouseEvent* ev) { if ( dragScroll != FListBox::noScroll ) { - delAllTimer(); + delOwnTimer(); dragScroll = FListBox::noScroll; scrollDistance = 1; scrollTimer = false; @@ -1077,7 +1077,7 @@ void FListBox::onMouseMove (FMouseEvent* ev) } if ( current == 1 ) { - delAllTimer(); + delOwnTimer(); dragScroll = FListBox::noScroll; } } @@ -1097,14 +1097,14 @@ void FListBox::onMouseMove (FMouseEvent* ev) } if ( current == int(count()) ) { - delAllTimer(); + delOwnTimer(); dragScroll = FListBox::noScroll; } } else { // no dragging - delAllTimer(); + delOwnTimer(); scrollTimer = false; scrollDistance = 1; dragScroll = FListBox::noScroll; @@ -1239,7 +1239,7 @@ void FListBox::onWheel (FWheelEvent* ev) if ( dragScroll != FListBox::noScroll ) { - delAllTimer(); + delOwnTimer(); scrollTimer = false; scrollDistance = 1; dragScroll = FListBox::noScroll; @@ -1316,7 +1316,7 @@ void FListBox::onFocusOut (FFocusEvent*) statusBar()->clearMessage(); statusBar()->drawMessage(); } - delAllTimer(); + delOwnTimer(); inc_search.clear(); } diff --git a/src/fmenubar.cpp b/src/fmenubar.cpp index 6c2be1c9..8906856c 100644 --- a/src/fmenubar.cpp +++ b/src/fmenubar.cpp @@ -545,6 +545,8 @@ void FMenuBar::onMouseDown (FMouseEvent* ev) mouse_down = false; if ( ! itemlist.empty() ) leaveMenuBar(); + if ( statusBar() ) + statusBar()->clearMessage(); return; } diff --git a/src/fobject.cpp b/src/fobject.cpp index d67c3c0a..d60995a3 100644 --- a/src/fobject.cpp +++ b/src/fobject.cpp @@ -39,7 +39,7 @@ FObject::~FObject() // destructor if ( parentObj ) parentObj->delChild(this); - delAllTimer(); // delete all timers of this object + delOwnTimer(); // delete all timers of this object if ( ! has_parent && timer_list ) { @@ -201,6 +201,31 @@ bool FObject::delTimer (int id) return false; } +//---------------------------------------------------------------------- +bool FObject::delOwnTimer() +{ + FObject::TimerList::iterator iter, end; + + if ( ! timer_list ) + return false; + if ( timer_list->empty() ) + return false; + + modify_timer = true; + iter = timer_list->begin(); + + while ( iter != timer_list->end() ) + { + if ( (*iter).object == this ) + iter = timer_list->erase(iter); + else + ++iter; + } + modify_timer = false; + + return true; +} + //---------------------------------------------------------------------- bool FObject::delAllTimer() { diff --git a/src/fobject.h b/src/fobject.h index d2f18095..6b888174 100644 --- a/src/fobject.h +++ b/src/fobject.h @@ -83,6 +83,7 @@ class FObject static void getCurrentTime (timeval&); int addTimer (int); bool delTimer (int); + bool delOwnTimer(); bool delAllTimer(); virtual bool event (FEvent*); diff --git a/test/ui.cpp b/test/ui.cpp index 9842810d..93a6e3e6 100644 --- a/test/ui.cpp +++ b/test/ui.cpp @@ -95,7 +95,7 @@ ProgressDialog::ProgressDialog (FWidget* parent) //---------------------------------------------------------------------- ProgressDialog::~ProgressDialog() { - delAllTimer(); + delOwnTimer(); delCallback(quit); delCallback(more); delCallback(reset); @@ -120,7 +120,7 @@ void ProgressDialog::onTimer (FTimerEvent*) if ( p == 100 ) { - delAllTimer(); + delOwnTimer(); activateWindow(); raiseWindow(); reset->setEnable(); @@ -807,14 +807,14 @@ int main (int argc, char* argv[]) } FApplication app(argc, argv); - app.setXTermTitle ("The FINAL CUT 0.1.1 (C) 2015 by Markus Gans"); + app.setXTermTitle ("The FINAL CUT 0.2.0 (C) 2015 by Markus Gans"); //app.setEncoding("VT100"); //app.setTermGeometry(94,30); //app.setNewFont(); MyDialog d(&app); - d.setText ("The FINAL CUT 0.1.1 (C) 2015 by Markus Gans"); + d.setText ("The FINAL CUT 0.2.0 (C) 2015 by Markus Gans"); d.setGeometry (int((app.getWidth()-56)/2), 2, 56, app.getHeight()-4); d.setShadow(); diff --git a/test/watch.cpp b/test/watch.cpp index 85cb6d52..c3d06b1b 100644 --- a/test/watch.cpp +++ b/test/watch.cpp @@ -104,7 +104,7 @@ watch::watch (FWidget* parent) //---------------------------------------------------------------------- watch::~watch() { - delAllTimer(); + delOwnTimer(); } //----------------------------------------------------------------------