home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / ocl150a.zip / OCL / Source / OTimer.cpp < prev    next >
C/C++ Source or Header  |  1996-08-12  |  3KB  |  135 lines

  1. // OCL - OS/2 Class Library
  2. // (c) Cubus 1995
  3. // All Rights Reserved
  4. // OTimer.cpp
  5.  
  6.  
  7. /*
  8.  * Redistribution and use in source and binary forms, with or without
  9.  * modification, are permitted provided that the following conditions
  10.  * are met:
  11.  * 1. Redistributions of source code must retain the above copyright
  12.  *    notice, this list of conditions and the following disclaimer.
  13.  * 2. Neither the name Cubus nor the name Team OCL may be used to
  14.  *    endorse or promote products derived from this software
  15.  *    without specific prior written permission.
  16.  * 3. See OCL.INF for a detailed copyright notice.
  17.  *
  18.  *              THIS SOFTWARE IS PROVIDED ``AS IS'' AND
  19.  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  20.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  21.  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  22.  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  23.  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  24.  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  25.  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  26.  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  27.  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  28.  * SUCH DAMAGE.
  29.  */
  30.  
  31. // $Header: W:/Projects/OCL/Source/rcs/OTimer.cpp 1.50 1996/08/11 23:49:33 B.STEIN Release $
  32.  
  33. #define __OCL_SOURCE__
  34.  
  35. #define OINCL_OSTRING
  36. #define OINCL_BASE
  37.  
  38. #include <ocl.hpp>
  39. #include <OTimer.hpp>
  40.  
  41.  
  42. OTimer::OTimer(HWND    notifyWin,
  43.                ULONG   id,
  44.                ULONG   timeout)
  45.   : isStarted(FALSE),
  46.     _id(id),
  47.     _timeout(timeout),
  48.     notifyHwnd(notifyWin)
  49.   {}
  50.  
  51. OTimer::OTimer(OFrame& notifyWin,
  52.                ULONG   id,
  53.                ULONG   timeout)
  54.   : isStarted(FALSE),
  55.     _id(id),
  56.     _timeout(timeout),
  57.     notifyHwnd(notifyWin.hwnd)
  58.   {}
  59.  
  60.  
  61. OTimer::OTimer(pOFrame notifyWin,
  62.                ULONG   id,
  63.                ULONG   timeout)
  64.   : isStarted(FALSE),
  65.     _id(id),
  66.     _timeout(timeout),
  67.     notifyHwnd(notifyWin->hwnd)
  68.   {}
  69.  
  70.  
  71. OTimer::~OTimer()
  72. {
  73.  if (isStarted) 
  74.    stop();
  75. }
  76.  
  77. PSZ OTimer::isOfType () const
  78. {
  79.  return("OTimer");
  80.  
  81.  
  82. OTimer& OTimer::start()
  83. {
  84.  WinStartTimer(OApp::current().anchor(), notifyHwnd, _id, _timeout);
  85.  return(*this);
  86. }
  87.  
  88.  
  89. OTimer& OTimer::start(ULONG timeout)
  90. {
  91.  _timeout = timeout;
  92.  WinStartTimer(OApp::current().anchor(), notifyHwnd, _id, _timeout);
  93.  return(*this);
  94. }
  95.  
  96.  
  97. OTimer& OTimer::stop()
  98. {
  99.  WinStopTimer(OApp::current().anchor(), notifyHwnd, _id);
  100.  return(*this);
  101. }
  102.  
  103. OTimer& OTimer::setId(ULONG id)
  104. {
  105.  _id = id;
  106.  return(*this);
  107. }
  108.  
  109. OTimer& OTimer::setTimeout(ULONG timeout)
  110. {
  111.  _timeout = timeout;
  112.  return(*this);
  113. }
  114.  
  115. OTimer& OTimer::setNotify(HWND notifyWin)
  116. {
  117.  notifyHwnd = notifyWin;
  118.  return(*this);
  119. }
  120.  
  121. OTimer& OTimer::setNotify(OFrame& notifyWin)
  122. {
  123.  notifyHwnd = notifyWin.hwnd;
  124.  return(*this);
  125. }
  126.  
  127. OTimer& OTimer::setNotify(pOFrame notifyWin)
  128. {
  129.  notifyHwnd = notifyWin->hwnd;
  130.  return(*this);
  131. }
  132.  
  133. // end of source
  134.