// Yield to other apps/messages
extern void WXDLLEXPORT wxWakeUpIdle();
-#if wxUSE_GUI
-
// Post a message to the given eventhandler which will be processed during the
// next event loop iteration
inline void WXDLLEXPORT wxPostEvent(wxEvtHandler *dest, wxEvent& event)
{
wxCHECK_RET( dest, wxT("need an object to post event to in wxPostEvent") );
+#if wxUSE_GUI
dest->AddPendingEvent(event);
-}
-
+#else
+ dest->ProcessEvent(event);
#endif // wxUSE_GUI
+}
// console applications may avoid using DECLARE_APP and IMPLEMENT_APP macros
// and call these functions instead at the program startup and termination
void DoShowModal();
private:
+ wxWindow *m_oldFocus;
+
DECLARE_EVENT_TABLE()
};
#include "wx/longlong.h"
#include "wx/event.h"
+#if wxUSE_GUI
+
// ----------------------------------------------------------------------------
// wxTimer
// ----------------------------------------------------------------------------
#include "wx/stubs/timer.h"
#endif
+// ----------------------------------------------------------------------------
+// wxTimerRunner: starts the timer in its ctor, stops in the dtor
+// ----------------------------------------------------------------------------
+
+class WXDLLEXPORT wxTimerRunner
+{
+public:
+ wxTimerRunner(wxTimer& timer) : m_timer(timer) { }
+ wxTimerRunner(wxTimer& timer, int milli, bool oneShot = FALSE)
+ : m_timer(timer)
+ {
+ m_timer.Start(milli, oneShot);
+ }
+
+ void Start(int milli, bool oneShot = FALSE)
+ {
+ m_timer.Start(milli, oneShot);
+ }
+
+ ~wxTimerRunner()
+ {
+ if ( m_timer.IsRunning() )
+ {
+ m_timer.Stop();
+ }
+ }
+
+private:
+ wxTimer& m_timer;
+};
+
// ----------------------------------------------------------------------------
// wxTimerEvent
// ----------------------------------------------------------------------------
#define EVT_TIMER(id, func) { wxEVT_TIMER, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTimerEventFunction) & func, NULL},
+#endif // wxUSE_GUI
+
// ----------------------------------------------------------------------------
// wxStopWatch: measure time intervals with up to 1ms resolution
// ----------------------------------------------------------------------------
#include "wx/module.h"
#include "wx/log.h"
#include "wx/intl.h"
-#include "wx/gdicmn.h" // for wxPendingDelete
+
+#if wxUSE_GUI
+ #include "wx/gdicmn.h" // for wxPendingDelete
+#endif // wxUSE_GUI
#include "wx/sckaddr.h"
#include "wx/socket.h"
// timeout elapses. The polling loop calls PROCESS_EVENTS(), so
// this won't block the GUI.
+#if wxUSE_GUI
+
class _wxSocketInternalTimer: public wxTimer
{
public:
}
};
+#endif // wxUSE_GUI
+
bool wxSocketBase::_Wait(long seconds, long milliseconds,
wxSocketEventFlags flags)
{
GSocketEventFlags result;
+#if wxUSE_GUI
_wxSocketInternalTimer timer;
+ wxTimerRunner runTimer(timer);
+#endif // wxUSE_GUI
+
long timeout;
int state = -1;
// Activate timer
if (timeout)
{
+#if wxUSE_GUI
timer.m_state = &state;
timer.m_new_val = 0;
- timer.Start((int)timeout, TRUE);
+ runTimer.Start((int)timeout, TRUE);
+#endif // wxUSE_GUI
}
// Active polling (without using events)
// Incoming connection (server) or connection established (client)
if (result & GSOCK_CONNECTION_FLAG)
{
- timer.Stop();
m_connected = TRUE;
m_establishing = FALSE;
return TRUE;
// Data available or output buffer ready
if ((result & GSOCK_INPUT_FLAG) || (result & GSOCK_OUTPUT_FLAG))
{
- timer.Stop();
return TRUE;
}
// Connection lost
if (result & GSOCK_LOST_FLAG)
{
- timer.Stop();
m_connected = FALSE;
m_establishing = FALSE;
return (flags & GSOCK_LOST_FLAG);
PROCESS_EVENTS();
}
- timer.Stop();
return FALSE;
}
event.m_skevt = req_evt;
if (m_evt_handler)
+ {
#if USE_DELAYED_EVENTS
wxPostEvent(m_evt_handler, event);
#else
ProcessEvent(event);
#endif
+ }
OldOnNotify(req_evt);
if (m_cbk)
// wxWin macros
// ----------------------------------------------------------------------------
-IMPLEMENT_DYNAMIC_CLASS(wxTimerEvent, wxEvent)
+#if wxUSE_GUI
+ IMPLEMENT_DYNAMIC_CLASS(wxTimerEvent, wxEvent)
+#endif // wxUSE_GUI
// ----------------------------------------------------------------------------
// macros
// implementation
// ============================================================================
+#if wxUSE_GUI
+
// ----------------------------------------------------------------------------
// wxTimerBase
// ----------------------------------------------------------------------------
(void)m_owner->ProcessEvent(event);
}
+#endif // wxUSE_GUI
+
// ----------------------------------------------------------------------------
// wxStopWatch
// ----------------------------------------------------------------------------
// all modal dialogs currently shown
static wxWindowList wxModalDialogs;
-static wxWindow *m_oldFocus;
-
// ----------------------------------------------------------------------------
// wxWin macros
// ----------------------------------------------------------------------------
wxDialog::wxDialog()
{
+ m_oldFocus = (wxWindow *)NULL;
m_isShown = FALSE;
SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE));
#endif
#include <signal.h>
-
#ifndef SOCKLEN_T
#ifdef VMS
#endif /* __GSOCKET_STANDALONE__ */
+/* redefine some GUI-only functions to do nothing in console mode */
+#if defined(wxUSE_GUI) && !wxUSE_GUI
+ #define _GSocket_GUI_Init(socket)
+ #define _GSocket_GUI_Destroy(socket)
+ #define _GSocket_Enable_Events(socket)
+ #define _GSocket_Disable_Events(socket)
+ #define _GSocket_Install_Callback(socket, event)
+ #define _GSocket_Uninstall_Callback(socket, event)
+#endif // wxUSE_GUI
/* Global initialisers */