]> git.saurik.com Git - wxWidgets.git/blame - src/msw/basemsw.cpp
add a simple benchmark for wx and iconv converters benchmarking
[wxWidgets.git] / src / msw / basemsw.cpp
CommitLineData
e2478fde
VZ
1///////////////////////////////////////////////////////////////////////////////
2// Name: msw/basemsw.cpp
3// Purpose: misc stuff only used in console applications under MSW
4// Author: Vadim Zeitlin
5// Modified by:
6// Created: 22.06.2003
7// RCS-ID: $Id$
8// Copyright: (c) 2003 Vadim Zeitlin <vadim@wxwindows.org>
65571936 9// License: wxWindows licence
e2478fde
VZ
10///////////////////////////////////////////////////////////////////////////////
11
12// ============================================================================
13// declarations
14// ============================================================================
15
16// ----------------------------------------------------------------------------
17// headers
18// ----------------------------------------------------------------------------
19
20// for compilers that support precompilation, includes "wx.h".
21#include "wx/wxprec.h"
22
23#ifdef __BORLANDC__
24 #pragma hdrstop
25#endif
26
27#ifndef WX_PRECOMP
28#endif //WX_PRECOMP
29
30#include "wx/apptrait.h"
b46b1d59 31#include "wx/evtloop.h"
c2ca375c 32#include "wx/msw/private/timer.h"
548bf4b7
MB
33// MBN: this is a workaround for MSVC 5: if it is not #included in
34// some wxBase file, wxRecursionGuard methods won't be exported from
35// wxBase.dll, and MSVC 5 will give linker errors
36#include "wx/recguard.h"
e2478fde 37
4081eb6f 38#include "wx/crt.h"
e2478fde
VZ
39#include "wx/msw/private.h"
40
535920ff
VZ
41// ============================================================================
42// wxAppTraits implementation
43// ============================================================================
44
2804f77d
VZ
45GSocketManager *wxAppTraits::ms_manager = NULL;
46
535920ff
VZ
47WXDWORD wxAppTraits::DoSimpleWaitForThread(WXHANDLE hThread)
48{
49 return ::WaitForSingleObject((HANDLE)hThread, INFINITE);
50}
51
e2478fde
VZ
52// ============================================================================
53// wxConsoleAppTraits implementation
54// ============================================================================
55
56void wxConsoleAppTraits::AlwaysYield()
57{
686ecd15
VZ
58 // we need to use special logic to deal with WM_PAINT: as this pseudo
59 // message is generated automatically as long as there are invalidated
60 // windows belonging to this thread, we'd never return if we waited here
61 // until we have no more of them left. OTOH, this message is always the
62 // last one in the queue, so we can safely return as soon as we detect it
e2478fde
VZ
63 MSG msg;
64 while ( ::PeekMessage(&msg, NULL, 0, 0, PM_REMOVE) )
686ecd15
VZ
65 {
66 if ( msg.message == WM_PAINT )
67 break;
68 }
e2478fde
VZ
69}
70
71void *wxConsoleAppTraits::BeforeChildWaitLoop()
72{
73 // nothing to do here
74 return NULL;
75}
76
77void wxConsoleAppTraits::AfterChildWaitLoop(void * WXUNUSED(data))
78{
79 // nothing to do here
80}
81
82bool wxConsoleAppTraits::DoMessageFromThreadWait()
83{
84 // nothing to process here
85 return true;
86}
87
a8ff046b
VZ
88#if wxUSE_TIMER
89
b46b1d59 90wxTimerImpl *wxConsoleAppTraits::CreateTimerImpl(wxTimer *timer)
c2ca375c
VZ
91{
92 return new wxMSWTimerImpl(timer);
93}
94
a8ff046b
VZ
95#endif // wxUSE_TIMER
96
2ddff00c 97wxEventLoopBase *wxConsoleAppTraits::CreateEventLoop()
b46b1d59 98{
e0f88b1a 99#if wxUSE_CONSOLE_EVENTLOOP
b46b1d59 100 return new wxEventLoop();
e0f88b1a
VZ
101#else // !wxUSE_CONSOLE_EVENTLOOP
102 return NULL;
103#endif // wxUSE_CONSOLE_EVENTLOOP/!wxUSE_CONSOLE_EVENTLOOP
b46b1d59 104}
c2ca375c 105
a8ff046b 106
e570a44b
VZ
107WXDWORD wxConsoleAppTraits::WaitForThread(WXHANDLE hThread)
108{
535920ff 109 return DoSimpleWaitForThread(hThread);
e570a44b
VZ
110}
111
784ee7d5
VZ
112bool wxConsoleAppTraits::WriteToStderr(const wxString& text)
113{
114 return wxFprintf(stderr, "%s", text) != -1;
115}