From 7c60222510bc5e197b12f153c4bf05db66cb0f4a Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Wed, 3 Jul 2013 00:24:10 +0000 Subject: [PATCH] Add wxTimer::StartOnce(). This is a simple wrapper for wxTimer::Start(timeout, wxTIMER_ONE_SHOT) but is often more readable and is definitely better than Start(timeout, true) which many people still use in spite of wxTIMER_ONE_SHOT existence. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@74330 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/changes.txt | 1 + include/wx/timer.h | 4 ++++ interface/wx/timer.h | 13 ++++++++++++- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/docs/changes.txt b/docs/changes.txt index 5c06bad248..4a4e8018fb 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -597,6 +597,7 @@ All: - Add IEEE 754 single/double precision support to wxDataStream classes (net147). - Add wxVector<>::const_reverse_iterator (troelsk). - Fix thread-safety issue in wxSharedPtr<> (plorkyeran). +- Add wxTimer::StartOnce(). - Add Nepali translation (Him Prasad Gautam). All (GUI): diff --git a/include/wx/timer.h b/include/wx/timer.h index 0b9a63b082..035b299359 100644 --- a/include/wx/timer.h +++ b/include/wx/timer.h @@ -81,6 +81,10 @@ public: // timer if it is already running virtual bool Start(int milliseconds = -1, bool oneShot = false); + // start the timer for one iteration only, this is just a simple wrapper + // for Start() + bool StartOnce(int milliseconds = -1) { return Start(milliseconds, true); } + // stop the timer, does nothing if the timer is not running virtual void Stop(); diff --git a/interface/wx/timer.h b/interface/wx/timer.h index ba5e2394a9..123c626fd6 100644 --- a/interface/wx/timer.h +++ b/interface/wx/timer.h @@ -128,10 +128,21 @@ public: To make your code more readable you may also use the following symbolic constants: - wxTIMER_CONTINUOUS: Start a normal, continuously running, timer - wxTIMER_ONE_SHOT: Start a one shot timer + Alternatively, use StartOnce(). + If the timer was already running, it will be stopped by this method before restarting it. */ - virtual bool Start(int milliseconds = -1, bool oneShot = false); + virtual bool Start(int milliseconds = -1, bool oneShot = wxTIMER_CONTINUOUS); + + /** + Starts the timer for a once-only notification. + + This is a simple wrapper for Start() with @c wxTIMER_ONE_SHOT parameter. + + @since 2.9.5 + */ + bool StartOnce(int milliseconds = -1); /** Stops the timer. -- 2.45.2