home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / listpm7.zip / timeshow.hpp < prev    next >
C/C++ Source or Header  |  1999-06-12  |  3KB  |  87 lines

  1. /*
  2.     listPM list files under Presentation Manager. Uses Open Class Libarary.
  3.     Copyright (C) 1998,1999  Paul Elliott
  4.  
  5.     This program is free software; you can redistribute it and/or modify
  6.     it under the terms of the GNU General Public License as published by
  7.     the Free Software Foundation; either version 2 of the License, or
  8.     (at your option) any later version.
  9.  
  10.     This program is distributed in the hope that it will be useful,
  11.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13.     GNU General Public License for more details.
  14.  
  15.     You should have received a copy of the GNU General Public License
  16.     along with this program; if not, write to the Free Software
  17.     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18.  
  19.     Paul Elliott
  20.     PMB # 181
  21.     11900 Metric Blvd Ste. J
  22.     Austin Tx 78758-3117
  23.     pelliott@io.com
  24. */
  25. // timshow.hpp
  26.  
  27. #ifndef TIMESHOW
  28. #define TIMESHOW
  29.  
  30. #include <iframe.hpp>
  31. #include <itimer.hpp>
  32.  
  33. // This class shows a window modally for a time, then closes it
  34. // and returns after timer expires or user closes it.
  35.  
  36. // shows a window for a specified time.
  37.  
  38. class TimShow
  39. {
  40.     private:
  41.         IFrameWindow&     window;       // remember window to show.
  42.         ITimer       timer;             // timer to use.
  43.  
  44.         // closes the window when called by timer.
  45.         void expire( unsigned long interval )
  46.         {
  47.              window.close();
  48.         };
  49.  
  50.         // Allow timer system access to expire.
  51.         friend class ITimerMemberFn<TimShow>;
  52.  
  53.     public:
  54.         // cnsturct a TimShow
  55.         TimShow( IFrameWindow& window):
  56.         window(window),                // save the window.
  57.         timer()                        // save the timer.
  58.         {};
  59.  
  60.         ~TimShow() { timer.stop(); };  //  stop timer when destroyed.
  61.  
  62.         // show the window.
  63.         virtual IFrameWindow& show( const unsigned long interval)
  64.         {
  65.              // start the timer.
  66.              timer.start( new ITimerMemberFn<TimShow>(*this,&TimShow::expire),
  67.                           interval );
  68.  
  69.              // display the window.
  70.              window.showModally();
  71.  
  72.              // stop the timer.
  73.              timer.stop();
  74.  
  75.              return window;            // allow next call
  76.         };
  77.  
  78.         // construct then start.
  79.         TimShow( IFrameWindow& window,const unsigned long interval):
  80.         window(window),
  81.         timer()
  82.         {
  83.            show(interval);
  84.         };
  85. };
  86. #endif // timeshow
  87.