home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / listpm4.zip / source / timeshow.hpp < prev    next >
C/C++ Source or Header  |  1998-04-22  |  3KB  |  86 lines

  1. /*
  2.     listPM list files under Presentation Manager. Uses Open Class Libarary.
  3.     Copyright (C) 1998  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.     11900 Metric Blvd #J-181
  21.     Austin Tx 78758-3117
  22.     pelliott@io.com
  23. */
  24. // timshow.hpp
  25.  
  26. #ifndef TIMESHOW
  27. #define TIMESHOW
  28.  
  29. #include <iframe.hpp>
  30. #include <itimer.hpp>
  31.  
  32. // This class shows a window modally for a time, then closes it
  33. // and returns after timer expires or user closes it.
  34.  
  35. // shows a window for a specified time.
  36.  
  37. class TimShow
  38. {
  39.     private:
  40.         IFrameWindow&     window;       // remember window to show.
  41.         ITimer       timer;             // timer to use.
  42.  
  43.         // closes the window when called by timer.
  44.         void expire( unsigned long interval )
  45.         {
  46.              window.close();
  47.         };
  48.  
  49.         // Allow timer system access to expire.
  50.         friend class ITimerMemberFn<TimShow>;
  51.  
  52.     public:
  53.         // cnsturct a TimShow
  54.         TimShow( IFrameWindow& window):
  55.         window(window),                // save the window.
  56.         timer()                        // save the timer.
  57.         {};
  58.  
  59.         ~TimShow() { timer.stop(); };  //  stop timer when destroyed.
  60.  
  61.         // show the window.
  62.         virtual IFrameWindow& show( const unsigned long interval)
  63.         {
  64.              // start the timer.
  65.              timer.start( new ITimerMemberFn<TimShow>(*this,TimShow::expire),
  66.                           interval );
  67.  
  68.              // display the window.
  69.              window.showModally();
  70.  
  71.              // stop the timer.
  72.              timer.stop();
  73.  
  74.              return window;            // allow next call
  75.         };
  76.  
  77.         // construct then start.
  78.         TimShow( IFrameWindow& window,const unsigned long interval):
  79.         window(window),
  80.         timer()
  81.         {
  82.            show(interval);
  83.         };
  84. };
  85. #endif // timeshow
  86.