event_extensions.cpp

Go to the documentation of this file.
00001 #ifndef EVENT_EXTENSIONS_IMPLEMENTATION_FILE
00002 #define EVENT_EXTENSIONS_IMPLEMENTATION_FILE
00003 
00004 /*****************************************************************************\
00005 *                                                                             *
00006 *  Name   : event_extensions                                                  *
00007 *  Author : Chris Koeritz                                                     *
00008 *                                                                             *
00009 *******************************************************************************
00010 * Copyright (c) 1995-$now By Author.  This program is free software; you can  *
00011 * redistribute it and/or modify it under the terms of the GNU General Public  *
00012 * License as published by the Free Software Foundation; either version 2 of   *
00013 * the License or (at your option) any later version.  This is online at:      *
00014 *     http://www.fsf.org/copyleft/gpl.html                                    *
00015 * Please send any updates to: fred@gruntose.com                               *
00016 \*****************************************************************************/
00017 
00018 #ifdef __WIN32__
00019 
00020 #include "event_extensions.h"
00021 
00022 #include <basis/guards.h>
00023 #include <basis/portable.h>
00024 #include <mechanisms/time_stamp.h>
00025 
00026 #include <mmsystem.h>
00027 
00028 bool event_extensions::poll()
00029 {
00030   MSG message;
00031   return poll(message);
00032 }
00033 
00034 bool event_extensions::poll(MSG &message)
00035 {
00036   return portable::event_poll(message);
00037 /*
00038   message.hwnd = 0;
00039   message.message = 0;
00040   message.wParam = 0;
00041   message.lParam = 0;
00042   if (PeekMessage(&message, NIL, 0, 0, PM_REMOVE)) {
00043     TranslateMessage(&message);
00044     DispatchMessage(&message);
00045   }
00046   return true;
00047 */
00048 }
00049 
00050 bool event_extensions::poll(int wait)
00051 {
00052   time_stamp start_time;
00053   do {
00054     MSG message;
00055     if (!poll(message)) return false;
00056   } while (wait && (time_stamp().value() - start_time.value() <= wait));
00057   return true;
00058 }
00059 
00060 bool event_extensions::poll_on_message(window_handle handle, UINT look_for,
00061     int wait, MSG &message)
00062 {
00063   time_stamp start_time;
00064   do {
00065     bool okay = poll(message);
00066     if (!okay) return false;
00067     if ( (message.hwnd == handle) && (message.message == look_for) )
00068       return true;
00069   } while (time_stamp().value() - start_time.value() <= wait);
00070     // keep going while time is left.
00071   return false;
00072 }
00073 
00074 bool event_extensions::poll_on_message_and_wparam(window_handle handle,
00075     UINT look_for, WPARAM look_also, int wait, MSG &message)
00076 {
00077   time_stamp start_time;
00078   do {
00079     bool okay = poll(message);
00080     if (!okay) return false;
00081     if ( (message.hwnd == handle) && (message.wParam == look_also)
00082           && (message.message == look_for) )
00083       return true;
00084   } while (time_stamp().value() - start_time.value() <= wait);
00085     // keep going while time is left.
00086   return false;
00087 }
00088 
00089 #endif
00090 
00091 
00092 #endif //EVENT_EXTENSIONS_IMPLEMENTATION_FILE
00093 

Generated on Fri Nov 28 04:29:22 2008 for HOOPLE Libraries by  doxygen 1.5.1