feisty meow concerns codebase 2.140
event_extensions.cpp
Go to the documentation of this file.
1#ifndef EVENT_EXTENSIONS_IMPLEMENTATION_FILE
2#define EVENT_EXTENSIONS_IMPLEMENTATION_FILE
3
4/*****************************************************************************\
5* *
6* Name : event_extensions *
7* Author : Chris Koeritz *
8* *
9*******************************************************************************
10* Copyright (c) 1995-$now By Author. This program is free software; you can *
11* redistribute it and/or modify it under the terms of the GNU General Public *
12* License as published by the Free Software Foundation; either version 2 of *
13* the License or (at your option) any later version. This is online at: *
14* http://www.fsf.org/copyleft/gpl.html *
15* Please send any updates to: fred@gruntose.com *
16\*****************************************************************************/
17
18#ifdef __WIN32__
19
20#include "event_extensions.h"
21
22#include <basis/guards.h>
23#include <basis/portable.h>
24#include <mechanisms/time_stamp.h>
25
26#include <mmsystem.h>
27
28bool event_extensions::poll()
29{
30 MSG message;
31 return poll(message);
32}
33
34bool event_extensions::poll(MSG &message)
35{
36 return windoze_helper::event_poll(message);
37/*
38 message.hwnd = 0;
39 message.message = 0;
40 message.wParam = 0;
41 message.lParam = 0;
42 if (PeekMessage(&message, NIL, 0, 0, PM_REMOVE)) {
43 TranslateMessage(&message);
44 DispatchMessage(&message);
45 }
46 return true;
47*/
48}
49
50bool event_extensions::poll(int wait)
51{
52 time_stamp start_time;
53 do {
54 MSG message;
55 if (!poll(message)) return false;
56 } while (wait && (time_stamp().value() - start_time.value() <= wait));
57 return true;
58}
59
60bool event_extensions::poll_on_message(window_handle handle, UINT look_for,
61 int wait, MSG &message)
62{
63 time_stamp start_time;
64 do {
65 bool okay = poll(message);
66 if (!okay) return false;
67 if ( (message.hwnd == handle) && (message.message == look_for) )
68 return true;
69 } while (time_stamp().value() - start_time.value() <= wait);
70 // keep going while time is left.
71 return false;
72}
73
74bool event_extensions::poll_on_message_and_wparam(window_handle handle,
75 UINT look_for, WPARAM look_also, int wait, MSG &message)
76{
77 time_stamp start_time;
78 do {
79 bool okay = poll(message);
80 if (!okay) return false;
81 if ( (message.hwnd == handle) && (message.wParam == look_also)
82 && (message.message == look_for) )
83 return true;
84 } while (time_stamp().value() - start_time.value() <= wait);
85 // keep going while time is left.
86 return false;
87}
88
89#endif
90
91
92#endif //EVENT_EXTENSIONS_IMPLEMENTATION_FILE
93
void * window_handle