attempts at making wxSocket work with wxBase - it doesn't work but

already compiles :-|


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@6288 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2000-02-25 16:21:53 +00:00
parent 2f4ef631af
commit 52a07708c4
7 changed files with 75 additions and 14 deletions

View File

@@ -322,18 +322,18 @@ extern bool WXDLLEXPORT wxYield();
// Yield to other apps/messages // Yield to other apps/messages
extern void WXDLLEXPORT wxWakeUpIdle(); extern void WXDLLEXPORT wxWakeUpIdle();
#if wxUSE_GUI
// Post a message to the given eventhandler which will be processed during the // Post a message to the given eventhandler which will be processed during the
// next event loop iteration // next event loop iteration
inline void WXDLLEXPORT wxPostEvent(wxEvtHandler *dest, wxEvent& event) inline void WXDLLEXPORT wxPostEvent(wxEvtHandler *dest, wxEvent& event)
{ {
wxCHECK_RET( dest, wxT("need an object to post event to in wxPostEvent") ); wxCHECK_RET( dest, wxT("need an object to post event to in wxPostEvent") );
#if wxUSE_GUI
dest->AddPendingEvent(event); dest->AddPendingEvent(event);
} #else
dest->ProcessEvent(event);
#endif // wxUSE_GUI #endif // wxUSE_GUI
}
// console applications may avoid using DECLARE_APP and IMPLEMENT_APP macros // console applications may avoid using DECLARE_APP and IMPLEMENT_APP macros
// and call these functions instead at the program startup and termination // and call these functions instead at the program startup and termination

View File

@@ -117,6 +117,8 @@ protected:
void DoShowModal(); void DoShowModal();
private: private:
wxWindow *m_oldFocus;
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
}; };

View File

@@ -22,6 +22,8 @@
#include "wx/longlong.h" #include "wx/longlong.h"
#include "wx/event.h" #include "wx/event.h"
#if wxUSE_GUI
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// wxTimer // wxTimer
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@@ -121,6 +123,37 @@ protected:
#include "wx/stubs/timer.h" #include "wx/stubs/timer.h"
#endif #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 // wxTimerEvent
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@@ -148,6 +181,8 @@ typedef void (wxEvtHandler::*wxTimerEventFunction)(wxTimerEvent&);
#define EVT_TIMER(id, func) { wxEVT_TIMER, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTimerEventFunction) & func, NULL}, #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 // wxStopWatch: measure time intervals with up to 1ms resolution
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------

View File

@@ -35,7 +35,10 @@
#include "wx/module.h" #include "wx/module.h"
#include "wx/log.h" #include "wx/log.h"
#include "wx/intl.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/sckaddr.h"
#include "wx/socket.h" #include "wx/socket.h"
@@ -548,6 +551,8 @@ wxSocketBase& wxSocketBase::Discard()
// timeout elapses. The polling loop calls PROCESS_EVENTS(), so // timeout elapses. The polling loop calls PROCESS_EVENTS(), so
// this won't block the GUI. // this won't block the GUI.
#if wxUSE_GUI
class _wxSocketInternalTimer: public wxTimer class _wxSocketInternalTimer: public wxTimer
{ {
public: public:
@@ -560,11 +565,17 @@ public:
} }
}; };
#endif // wxUSE_GUI
bool wxSocketBase::_Wait(long seconds, long milliseconds, bool wxSocketBase::_Wait(long seconds, long milliseconds,
wxSocketEventFlags flags) wxSocketEventFlags flags)
{ {
GSocketEventFlags result; GSocketEventFlags result;
#if wxUSE_GUI
_wxSocketInternalTimer timer; _wxSocketInternalTimer timer;
wxTimerRunner runTimer(timer);
#endif // wxUSE_GUI
long timeout; long timeout;
int state = -1; int state = -1;
@@ -584,9 +595,11 @@ bool wxSocketBase::_Wait(long seconds, long milliseconds,
// Activate timer // Activate timer
if (timeout) if (timeout)
{ {
#if wxUSE_GUI
timer.m_state = &state; timer.m_state = &state;
timer.m_new_val = 0; timer.m_new_val = 0;
timer.Start((int)timeout, TRUE); runTimer.Start((int)timeout, TRUE);
#endif // wxUSE_GUI
} }
// Active polling (without using events) // Active polling (without using events)
@@ -608,7 +621,6 @@ bool wxSocketBase::_Wait(long seconds, long milliseconds,
// Incoming connection (server) or connection established (client) // Incoming connection (server) or connection established (client)
if (result & GSOCK_CONNECTION_FLAG) if (result & GSOCK_CONNECTION_FLAG)
{ {
timer.Stop();
m_connected = TRUE; m_connected = TRUE;
m_establishing = FALSE; m_establishing = FALSE;
return TRUE; return TRUE;
@@ -617,14 +629,12 @@ bool wxSocketBase::_Wait(long seconds, long milliseconds,
// Data available or output buffer ready // Data available or output buffer ready
if ((result & GSOCK_INPUT_FLAG) || (result & GSOCK_OUTPUT_FLAG)) if ((result & GSOCK_INPUT_FLAG) || (result & GSOCK_OUTPUT_FLAG))
{ {
timer.Stop();
return TRUE; return TRUE;
} }
// Connection lost // Connection lost
if (result & GSOCK_LOST_FLAG) if (result & GSOCK_LOST_FLAG)
{ {
timer.Stop();
m_connected = FALSE; m_connected = FALSE;
m_establishing = FALSE; m_establishing = FALSE;
return (flags & GSOCK_LOST_FLAG); return (flags & GSOCK_LOST_FLAG);
@@ -637,7 +647,6 @@ bool wxSocketBase::_Wait(long seconds, long milliseconds,
PROCESS_EVENTS(); PROCESS_EVENTS();
} }
timer.Stop();
return FALSE; return FALSE;
} }
@@ -872,11 +881,13 @@ void wxSocketBase::OnRequest(wxSocketNotify req_evt)
event.m_skevt = req_evt; event.m_skevt = req_evt;
if (m_evt_handler) if (m_evt_handler)
{
#if USE_DELAYED_EVENTS #if USE_DELAYED_EVENTS
wxPostEvent(m_evt_handler, event); wxPostEvent(m_evt_handler, event);
#else #else
ProcessEvent(event); ProcessEvent(event);
#endif #endif
}
OldOnNotify(req_evt); OldOnNotify(req_evt);
if (m_cbk) if (m_cbk)

View File

@@ -61,7 +61,9 @@
// wxWin macros // wxWin macros
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
IMPLEMENT_DYNAMIC_CLASS(wxTimerEvent, wxEvent) #if wxUSE_GUI
IMPLEMENT_DYNAMIC_CLASS(wxTimerEvent, wxEvent)
#endif // wxUSE_GUI
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// macros // macros
@@ -88,6 +90,8 @@ wxLongLong wxGetLocalTimeMillis();
// implementation // implementation
// ============================================================================ // ============================================================================
#if wxUSE_GUI
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// wxTimerBase // wxTimerBase
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@@ -102,6 +106,8 @@ void wxTimerBase::Notify()
(void)m_owner->ProcessEvent(event); (void)m_owner->ProcessEvent(event);
} }
#endif // wxUSE_GUI
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// wxStopWatch // wxStopWatch
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------

View File

@@ -70,8 +70,6 @@ wxWindowList wxModelessWindows;
// all modal dialogs currently shown // all modal dialogs currently shown
static wxWindowList wxModalDialogs; static wxWindowList wxModalDialogs;
static wxWindow *m_oldFocus;
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// wxWin macros // wxWin macros
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@@ -100,6 +98,7 @@ END_EVENT_TABLE()
wxDialog::wxDialog() wxDialog::wxDialog()
{ {
m_oldFocus = (wxWindow *)NULL;
m_isShown = FALSE; m_isShown = FALSE;
SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE)); SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE));

View File

@@ -53,7 +53,6 @@ struct sockaddr_un {
#endif #endif
#include <signal.h> #include <signal.h>
#ifndef SOCKLEN_T #ifndef SOCKLEN_T
#ifdef VMS #ifdef VMS
@@ -102,6 +101,15 @@ struct sockaddr_un {
#endif /* __GSOCKET_STANDALONE__ */ #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 */ /* Global initialisers */