cleanup - reformat
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@36879 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
// Name: socket.cpp
|
// Name: src/mac/carbon/cfsocket.cpp
|
||||||
// Purpose: Socket handler classes
|
// Purpose: Socket handler classes
|
||||||
// Authors: Guilhem Lavaux, Guillermo Rodriguez Garcia
|
// Authors: Guilhem Lavaux, Guillermo Rodriguez Garcia
|
||||||
// Created: April 1997
|
// Created: April 1997
|
||||||
@@ -9,11 +9,6 @@
|
|||||||
// License: see wxWindows licence
|
// License: see wxWindows licence
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
// ==========================================================================
|
|
||||||
// Declarations
|
|
||||||
// ==========================================================================
|
|
||||||
|
|
||||||
// For compilers that support precompilation, includes "wx.h".
|
|
||||||
#include "wx/wxprec.h"
|
#include "wx/wxprec.h"
|
||||||
|
|
||||||
#ifdef __BORLANDC__
|
#ifdef __BORLANDC__
|
||||||
@@ -47,11 +42,9 @@
|
|||||||
|
|
||||||
// DLL options compatibility check:
|
// DLL options compatibility check:
|
||||||
#include "wx/build.h"
|
#include "wx/build.h"
|
||||||
|
|
||||||
WX_CHECK_BUILD_OPTIONS("wxNet")
|
WX_CHECK_BUILD_OPTIONS("wxNet")
|
||||||
|
|
||||||
// --------------------------------------------------------------------------
|
|
||||||
// macros and constants
|
|
||||||
// --------------------------------------------------------------------------
|
|
||||||
|
|
||||||
// discard buffer
|
// discard buffer
|
||||||
#define MAX_DISCARD_SIZE (10 * 1024)
|
#define MAX_DISCARD_SIZE (10 * 1024)
|
||||||
@@ -81,9 +74,6 @@ WX_CHECK_BUILD_OPTIONS("wxNet")
|
|||||||
|
|
||||||
#define wxTRACE_Socket _T("wxSocket")
|
#define wxTRACE_Socket _T("wxSocket")
|
||||||
|
|
||||||
// --------------------------------------------------------------------------
|
|
||||||
// wxWin macros
|
|
||||||
// --------------------------------------------------------------------------
|
|
||||||
|
|
||||||
IMPLEMENT_CLASS(wxSocketBase, wxObject)
|
IMPLEMENT_CLASS(wxSocketBase, wxObject)
|
||||||
IMPLEMENT_CLASS(wxSocketServer, wxSocketBase)
|
IMPLEMENT_CLASS(wxSocketServer, wxSocketBase)
|
||||||
@@ -123,8 +113,7 @@ struct _GSocket
|
|||||||
int m_establishing;
|
int m_establishing;
|
||||||
unsigned long m_timeout;
|
unsigned long m_timeout;
|
||||||
|
|
||||||
|
// Callbacks
|
||||||
/* Callbacks */
|
|
||||||
GSocketEventFlags m_detected;
|
GSocketEventFlags m_detected;
|
||||||
GSocketCallback m_cbacks[GSOCK_MAX_EVENT];
|
GSocketCallback m_cbacks[GSOCK_MAX_EVENT];
|
||||||
char *m_data[GSOCK_MAX_EVENT];
|
char *m_data[GSOCK_MAX_EVENT];
|
||||||
@@ -184,18 +173,18 @@ bool wxSocketBase::Initialize()
|
|||||||
{
|
{
|
||||||
m_countInit--;
|
m_countInit--;
|
||||||
|
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxSocketBase::Shutdown()
|
void wxSocketBase::Shutdown()
|
||||||
{
|
{
|
||||||
// we should be initialized
|
// we should be initialized
|
||||||
wxASSERT_MSG( m_countInit, _T("extra call to Shutdown()") );
|
wxASSERT_MSG( m_countInit, wxT("extra call to Shutdown()") );
|
||||||
if ( !--m_countInit )
|
if ( !--m_countInit )
|
||||||
{
|
{
|
||||||
#if 0
|
#if 0
|
||||||
@@ -219,10 +208,10 @@ void wxSocketBase::Init()
|
|||||||
m_establishing =
|
m_establishing =
|
||||||
m_reading =
|
m_reading =
|
||||||
m_writing =
|
m_writing =
|
||||||
m_error = FALSE;
|
m_error = false;
|
||||||
m_lcount = 0;
|
m_lcount = 0;
|
||||||
m_timeout = 600;
|
m_timeout = 600;
|
||||||
m_beingDeleted = FALSE;
|
m_beingDeleted = false;
|
||||||
|
|
||||||
// pushback buffer
|
// pushback buffer
|
||||||
m_unread = NULL;
|
m_unread = NULL;
|
||||||
@@ -233,7 +222,7 @@ void wxSocketBase::Init()
|
|||||||
m_id = -1;
|
m_id = -1;
|
||||||
m_handler = NULL;
|
m_handler = NULL;
|
||||||
m_clientData = NULL;
|
m_clientData = NULL;
|
||||||
m_notify = FALSE;
|
m_notify = false;
|
||||||
m_eventmask = 0;
|
m_eventmask = 0;
|
||||||
|
|
||||||
if ( !IsInitialized() )
|
if ( !IsInitialized() )
|
||||||
@@ -285,13 +274,13 @@ bool wxSocketBase::Destroy()
|
|||||||
// Delayed destruction: the socket will be deleted during the next
|
// Delayed destruction: the socket will be deleted during the next
|
||||||
// idle loop iteration. This ensures that all pending events have
|
// idle loop iteration. This ensures that all pending events have
|
||||||
// been processed.
|
// been processed.
|
||||||
m_beingDeleted = TRUE;
|
m_beingDeleted = true;
|
||||||
|
|
||||||
// Shutdown and close the socket
|
// Shutdown and close the socket
|
||||||
Close();
|
Close();
|
||||||
|
|
||||||
// Supress events from now on
|
// Supress events from now on
|
||||||
Notify(FALSE);
|
Notify(false);
|
||||||
|
|
||||||
// schedule this object for deletion
|
// schedule this object for deletion
|
||||||
wxAppTraits *traits = wxTheApp ? wxTheApp->GetTraits() : NULL;
|
wxAppTraits *traits = wxTheApp ? wxTheApp->GetTraits() : NULL;
|
||||||
@@ -306,7 +295,7 @@ bool wxSocketBase::Destroy()
|
|||||||
delete this;
|
delete this;
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------------
|
// --------------------------------------------------------------------------
|
||||||
@@ -324,19 +313,18 @@ bool wxSocketBase::Close()
|
|||||||
InterruptWait();
|
InterruptWait();
|
||||||
|
|
||||||
if (m_socket)
|
if (m_socket)
|
||||||
{
|
|
||||||
GSocket_Shutdown(m_socket);
|
GSocket_Shutdown(m_socket);
|
||||||
}
|
|
||||||
|
|
||||||
m_connected = FALSE;
|
m_connected = false;
|
||||||
m_establishing = FALSE;
|
m_establishing = false;
|
||||||
return TRUE;
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxSocketBase& wxSocketBase::Read(void* buffer, wxUint32 nbytes)
|
wxSocketBase& wxSocketBase::Read(void* buffer, wxUint32 nbytes)
|
||||||
{
|
{
|
||||||
// Mask read events
|
// Mask read events
|
||||||
m_reading = TRUE;
|
m_reading = true;
|
||||||
|
|
||||||
m_lcount = _Read(buffer, nbytes);
|
m_lcount = _Read(buffer, nbytes);
|
||||||
|
|
||||||
@@ -347,7 +335,7 @@ wxSocketBase& wxSocketBase::Read(void* buffer, wxUint32 nbytes)
|
|||||||
m_error = (m_lcount == 0);
|
m_error = (m_lcount == 0);
|
||||||
|
|
||||||
// Allow read events from now on
|
// Allow read events from now on
|
||||||
m_reading = FALSE;
|
m_reading = false;
|
||||||
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
@@ -357,7 +345,7 @@ wxUint32 wxSocketBase::_Read(void* buffer, wxUint32 nbytes)
|
|||||||
int total = 0;
|
int total = 0;
|
||||||
|
|
||||||
// Try the pushback buffer first
|
// Try the pushback buffer first
|
||||||
total = GetPushback(buffer, nbytes, FALSE);
|
total = GetPushback(buffer, nbytes, false);
|
||||||
nbytes -= total;
|
nbytes -= total;
|
||||||
buffer = (char *)buffer + total;
|
buffer = (char *)buffer + total;
|
||||||
|
|
||||||
@@ -389,7 +377,7 @@ wxUint32 wxSocketBase::_Read(void* buffer, wxUint32 nbytes)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
bool more = TRUE;
|
bool more = true;
|
||||||
|
|
||||||
while (more)
|
while (more)
|
||||||
{
|
{
|
||||||
@@ -425,13 +413,14 @@ wxSocketBase& wxSocketBase::ReadMsg(void* buffer, wxUint32 nbytes)
|
|||||||
{
|
{
|
||||||
unsigned char sig[4];
|
unsigned char sig[4];
|
||||||
unsigned char len[4];
|
unsigned char len[4];
|
||||||
} msg;
|
}
|
||||||
|
msg;
|
||||||
|
|
||||||
// Mask read events
|
// Mask read events
|
||||||
m_reading = TRUE;
|
m_reading = true;
|
||||||
|
|
||||||
total = 0;
|
total = 0;
|
||||||
error = TRUE;
|
error = true;
|
||||||
old_flags = m_flags;
|
old_flags = m_flags;
|
||||||
SetFlags((m_flags & wxSOCKET_BLOCK) | wxSOCKET_WAITALL);
|
SetFlags((m_flags & wxSOCKET_BLOCK) | wxSOCKET_WAITALL);
|
||||||
|
|
||||||
@@ -445,7 +434,7 @@ wxSocketBase& wxSocketBase::ReadMsg(void* buffer, wxUint32 nbytes)
|
|||||||
|
|
||||||
if (sig != 0xfeeddead)
|
if (sig != 0xfeeddead)
|
||||||
{
|
{
|
||||||
wxLogWarning(_("wxSocket: invalid signature in ReadMsg."));
|
wxLogWarning( wxT("wxSocket: invalid signature in ReadMsg.") );
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -499,17 +488,17 @@ wxSocketBase& wxSocketBase::ReadMsg(void* buffer, wxUint32 nbytes)
|
|||||||
|
|
||||||
if (sig != 0xdeadfeed)
|
if (sig != 0xdeadfeed)
|
||||||
{
|
{
|
||||||
wxLogWarning(_("wxSocket: invalid signature in ReadMsg."));
|
wxLogWarning( wxT("wxSocket: invalid signature in ReadMsg.") );
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
// everything was OK
|
// everything was OK
|
||||||
error = FALSE;
|
error = false;
|
||||||
|
|
||||||
exit:
|
exit:
|
||||||
m_error = error;
|
m_error = error;
|
||||||
m_lcount = total;
|
m_lcount = total;
|
||||||
m_reading = FALSE;
|
m_reading = false;
|
||||||
SetFlags(old_flags);
|
SetFlags(old_flags);
|
||||||
|
|
||||||
return *this;
|
return *this;
|
||||||
@@ -518,7 +507,7 @@ exit:
|
|||||||
wxSocketBase& wxSocketBase::Peek(void* buffer, wxUint32 nbytes)
|
wxSocketBase& wxSocketBase::Peek(void* buffer, wxUint32 nbytes)
|
||||||
{
|
{
|
||||||
// Mask read events
|
// Mask read events
|
||||||
m_reading = TRUE;
|
m_reading = true;
|
||||||
|
|
||||||
m_lcount = _Read(buffer, nbytes);
|
m_lcount = _Read(buffer, nbytes);
|
||||||
Pushback(buffer, m_lcount);
|
Pushback(buffer, m_lcount);
|
||||||
@@ -530,7 +519,7 @@ wxSocketBase& wxSocketBase::Peek(void* buffer, wxUint32 nbytes)
|
|||||||
m_error = (m_lcount == 0);
|
m_error = (m_lcount == 0);
|
||||||
|
|
||||||
// Allow read events again
|
// Allow read events again
|
||||||
m_reading = FALSE;
|
m_reading = false;
|
||||||
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
@@ -538,7 +527,7 @@ wxSocketBase& wxSocketBase::Peek(void* buffer, wxUint32 nbytes)
|
|||||||
wxSocketBase& wxSocketBase::Write(const void *buffer, wxUint32 nbytes)
|
wxSocketBase& wxSocketBase::Write(const void *buffer, wxUint32 nbytes)
|
||||||
{
|
{
|
||||||
// Mask write events
|
// Mask write events
|
||||||
m_writing = TRUE;
|
m_writing = true;
|
||||||
|
|
||||||
m_lcount = _Write(buffer, nbytes);
|
m_lcount = _Write(buffer, nbytes);
|
||||||
|
|
||||||
@@ -549,7 +538,7 @@ wxSocketBase& wxSocketBase::Write(const void *buffer, wxUint32 nbytes)
|
|||||||
m_error = (m_lcount == 0);
|
m_error = (m_lcount == 0);
|
||||||
|
|
||||||
// Allow write events again
|
// Allow write events again
|
||||||
m_writing = FALSE;
|
m_writing = false;
|
||||||
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
@@ -580,7 +569,7 @@ wxUint32 wxSocketBase::_Write(const void *buffer, wxUint32 nbytes)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
bool more = TRUE;
|
bool more = true;
|
||||||
|
|
||||||
while (more)
|
while (more)
|
||||||
{
|
{
|
||||||
@@ -615,12 +604,13 @@ wxSocketBase& wxSocketBase::WriteMsg(const void *buffer, wxUint32 nbytes)
|
|||||||
{
|
{
|
||||||
unsigned char sig[4];
|
unsigned char sig[4];
|
||||||
unsigned char len[4];
|
unsigned char len[4];
|
||||||
} msg;
|
}
|
||||||
|
msg;
|
||||||
|
|
||||||
// Mask write events
|
// Mask write events
|
||||||
m_writing = TRUE;
|
m_writing = true;
|
||||||
|
|
||||||
error = TRUE;
|
error = true;
|
||||||
total = 0;
|
total = 0;
|
||||||
SetFlags((m_flags & wxSOCKET_BLOCK) | wxSOCKET_WAITALL);
|
SetFlags((m_flags & wxSOCKET_BLOCK) | wxSOCKET_WAITALL);
|
||||||
|
|
||||||
@@ -652,12 +642,12 @@ wxSocketBase& wxSocketBase::WriteMsg(const void *buffer, wxUint32 nbytes)
|
|||||||
goto exit;
|
goto exit;
|
||||||
|
|
||||||
// everything was OK
|
// everything was OK
|
||||||
error = FALSE;
|
error = false;
|
||||||
|
|
||||||
exit:
|
exit:
|
||||||
m_error = error;
|
m_error = error;
|
||||||
m_lcount = total;
|
m_lcount = total;
|
||||||
m_writing = FALSE;
|
m_writing = false;
|
||||||
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
@@ -667,7 +657,7 @@ wxSocketBase& wxSocketBase::Unread(const void *buffer, wxUint32 nbytes)
|
|||||||
if (nbytes != 0)
|
if (nbytes != 0)
|
||||||
Pushback(buffer, nbytes);
|
Pushback(buffer, nbytes);
|
||||||
|
|
||||||
m_error = FALSE;
|
m_error = false;
|
||||||
m_lcount = nbytes;
|
m_lcount = nbytes;
|
||||||
|
|
||||||
return *this;
|
return *this;
|
||||||
@@ -680,7 +670,7 @@ wxSocketBase& wxSocketBase::Discard()
|
|||||||
wxUint32 total = 0;
|
wxUint32 total = 0;
|
||||||
|
|
||||||
// Mask read events
|
// Mask read events
|
||||||
m_reading = TRUE;
|
m_reading = true;
|
||||||
|
|
||||||
SetFlags(wxSOCKET_NOWAIT);
|
SetFlags(wxSOCKET_NOWAIT);
|
||||||
|
|
||||||
@@ -693,10 +683,10 @@ wxSocketBase& wxSocketBase::Discard()
|
|||||||
|
|
||||||
delete[] buffer;
|
delete[] buffer;
|
||||||
m_lcount = total;
|
m_lcount = total;
|
||||||
m_error = FALSE;
|
m_error = false;
|
||||||
|
|
||||||
// Allow read events again
|
// Allow read events again
|
||||||
m_reading = FALSE;
|
m_reading = false;
|
||||||
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
@@ -715,16 +705,15 @@ bool wxSocketBase::_Wait(long seconds,
|
|||||||
long milliseconds,
|
long milliseconds,
|
||||||
wxSocketEventFlags flags)
|
wxSocketEventFlags flags)
|
||||||
{
|
{
|
||||||
|
|
||||||
GSocketEventFlags result;
|
GSocketEventFlags result;
|
||||||
long timeout;
|
long timeout;
|
||||||
|
|
||||||
// Set this to TRUE to interrupt ongoing waits
|
// Set this to true to interrupt ongoing waits
|
||||||
m_interrupt = FALSE;
|
m_interrupt = false;
|
||||||
|
|
||||||
// Check for valid socket
|
// Check for valid socket
|
||||||
if (!m_socket)
|
if (!m_socket)
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
// Check for valid timeout value.
|
// Check for valid timeout value.
|
||||||
if (seconds != -1)
|
if (seconds != -1)
|
||||||
@@ -747,7 +736,7 @@ bool wxSocketBase::_Wait(long seconds,
|
|||||||
// we are just polling). Also, if just polling, do not yield.
|
// we are just polling). Also, if just polling, do not yield.
|
||||||
|
|
||||||
wxStopWatch chrono;
|
wxStopWatch chrono;
|
||||||
bool done = FALSE;
|
bool done = false;
|
||||||
|
|
||||||
while (!done)
|
while (!done)
|
||||||
{
|
{
|
||||||
@@ -756,33 +745,35 @@ bool wxSocketBase::_Wait(long seconds,
|
|||||||
// Incoming connection (server) or connection established (client)
|
// Incoming connection (server) or connection established (client)
|
||||||
if (result & GSOCK_CONNECTION_FLAG)
|
if (result & GSOCK_CONNECTION_FLAG)
|
||||||
{
|
{
|
||||||
m_connected = TRUE;
|
m_connected = true;
|
||||||
m_establishing = FALSE;
|
m_establishing = false;
|
||||||
return TRUE;
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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))
|
||||||
{
|
{
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Connection lost
|
// Connection lost
|
||||||
if (result & GSOCK_LOST_FLAG)
|
if (result & GSOCK_LOST_FLAG)
|
||||||
{
|
{
|
||||||
m_connected = FALSE;
|
m_connected = false;
|
||||||
m_establishing = FALSE;
|
m_establishing = false;
|
||||||
|
|
||||||
return (flags & GSOCK_LOST_FLAG) != 0;
|
return (flags & GSOCK_LOST_FLAG) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Wait more?
|
// Wait more?
|
||||||
if ((!timeout) || (chrono.Time() > timeout) || (m_interrupt))
|
if ((!timeout) || (chrono.Time() > timeout) || (m_interrupt))
|
||||||
done = TRUE;
|
done = true;
|
||||||
else
|
else
|
||||||
PROCESS_EVENTS();
|
PROCESS_EVENTS();
|
||||||
}
|
}
|
||||||
|
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxSocketBase::Wait(long seconds, long milliseconds)
|
bool wxSocketBase::Wait(long seconds, long milliseconds)
|
||||||
@@ -797,15 +788,14 @@ bool wxSocketBase::WaitForRead(long seconds, long milliseconds)
|
|||||||
{
|
{
|
||||||
// Check pushback buffer before entering _Wait
|
// Check pushback buffer before entering _Wait
|
||||||
if (m_unread)
|
if (m_unread)
|
||||||
return TRUE;
|
return true;
|
||||||
|
|
||||||
// Note that GSOCK_INPUT_LOST has to be explicitly passed to
|
// Note that GSOCK_INPUT_LOST has to be explicitly passed to
|
||||||
// _Wait becuase of the semantics of WaitForRead: a return
|
// _Wait becuase of the semantics of WaitForRead: a return
|
||||||
// value of TRUE means that a GSocket_Read call will return
|
// value of true means that a GSocket_Read call will return
|
||||||
// immediately, not that there is actually data to read.
|
// immediately, not that there is actually data to read.
|
||||||
|
|
||||||
return _Wait(seconds, milliseconds, GSOCK_INPUT_FLAG |
|
return _Wait(seconds, milliseconds, GSOCK_INPUT_FLAG | GSOCK_LOST_FLAG);
|
||||||
GSOCK_LOST_FLAG);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxSocketBase::WaitForWrite(long seconds, long milliseconds)
|
bool wxSocketBase::WaitForWrite(long seconds, long milliseconds)
|
||||||
@@ -831,19 +821,19 @@ bool wxSocketBase::GetPeer(wxSockAddress& addr_man) const
|
|||||||
GAddress *peer;
|
GAddress *peer;
|
||||||
|
|
||||||
if (!m_socket)
|
if (!m_socket)
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
peer = GSocket_GetPeer(m_socket);
|
peer = GSocket_GetPeer(m_socket);
|
||||||
|
|
||||||
// copying a null address would just trigger an assert anyway
|
// copying a null address would just trigger an assert anyway
|
||||||
|
|
||||||
if (!peer)
|
if (!peer)
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
addr_man.SetAddress(peer);
|
addr_man.SetAddress(peer);
|
||||||
GAddress_destroy(peer);
|
GAddress_destroy(peer);
|
||||||
|
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxSocketBase::GetLocal(wxSockAddress& addr_man) const
|
bool wxSocketBase::GetLocal(wxSockAddress& addr_man) const
|
||||||
@@ -852,13 +842,14 @@ bool wxSocketBase::GetLocal(wxSockAddress& addr_man) const
|
|||||||
GAddress *local;
|
GAddress *local;
|
||||||
|
|
||||||
if (!m_socket)
|
if (!m_socket)
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
local = GSocket_GetLocal(m_socket);
|
local = GSocket_GetLocal(m_socket);
|
||||||
addr_man.SetAddress(local);
|
addr_man.SetAddress(local);
|
||||||
GAddress_destroy(local);
|
GAddress_destroy(local);
|
||||||
#endif
|
#endif
|
||||||
return TRUE;
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -961,8 +952,8 @@ void wxSocketBase::OnRequest(wxSocketNotify notification)
|
|||||||
switch (notification)
|
switch (notification)
|
||||||
{
|
{
|
||||||
case wxSOCKET_CONNECTION:
|
case wxSOCKET_CONNECTION:
|
||||||
m_establishing = FALSE;
|
m_establishing = false;
|
||||||
m_connected = TRUE;
|
m_connected = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// If we are in the middle of a R/W operation, do not
|
// If we are in the middle of a R/W operation, do not
|
||||||
@@ -980,8 +971,8 @@ void wxSocketBase::OnRequest(wxSocketNotify notification)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case wxSOCKET_LOST:
|
case wxSOCKET_LOST:
|
||||||
m_connected = FALSE;
|
m_connected = false;
|
||||||
m_establishing = FALSE;
|
m_establishing = false;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@@ -994,12 +985,24 @@ void wxSocketBase::OnRequest(wxSocketNotify notification)
|
|||||||
wxUnusedVar(flag);
|
wxUnusedVar(flag);
|
||||||
switch (notification)
|
switch (notification)
|
||||||
{
|
{
|
||||||
case GSOCK_INPUT: flag = GSOCK_INPUT_FLAG; break;
|
case GSOCK_INPUT:
|
||||||
case GSOCK_OUTPUT: flag = GSOCK_OUTPUT_FLAG; break;
|
flag = GSOCK_INPUT_FLAG;
|
||||||
case GSOCK_CONNECTION: flag = GSOCK_CONNECTION_FLAG; break;
|
break;
|
||||||
case GSOCK_LOST: flag = GSOCK_LOST_FLAG; break;
|
|
||||||
|
case GSOCK_OUTPUT:
|
||||||
|
flag = GSOCK_OUTPUT_FLAG;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case GSOCK_CONNECTION:
|
||||||
|
flag = GSOCK_CONNECTION_FLAG;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case GSOCK_LOST:
|
||||||
|
flag = GSOCK_LOST_FLAG;
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
wxLogWarning(_("wxSocket: unknown event!."));
|
wxLogWarning( wxT("wxSocket: unknown event!") );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1039,7 +1042,8 @@ void wxSocketBase::SetEventHandler(wxEvtHandler& handler, int id)
|
|||||||
|
|
||||||
void wxSocketBase::Pushback(const void *buffer, wxUint32 size)
|
void wxSocketBase::Pushback(const void *buffer, wxUint32 size)
|
||||||
{
|
{
|
||||||
if (!size) return;
|
if (!size)
|
||||||
|
return;
|
||||||
|
|
||||||
if (m_unread == NULL)
|
if (m_unread == NULL)
|
||||||
m_unread = malloc(size);
|
m_unread = malloc(size);
|
||||||
@@ -1097,13 +1101,13 @@ wxSocketServer::wxSocketServer(wxSockAddress& addr_man,
|
|||||||
wxSocketFlags flags)
|
wxSocketFlags flags)
|
||||||
: wxSocketBase(flags, wxSOCKET_SERVER)
|
: wxSocketBase(flags, wxSOCKET_SERVER)
|
||||||
{
|
{
|
||||||
wxLogTrace( wxTRACE_Socket, _T("Opening wxSocketServer") );
|
wxLogTrace( wxTRACE_Socket, wxT("Opening wxSocketServer") );
|
||||||
|
|
||||||
m_socket = GSocket_new();
|
m_socket = GSocket_new();
|
||||||
|
|
||||||
if (!m_socket)
|
if (!m_socket)
|
||||||
{
|
{
|
||||||
wxLogTrace( wxTRACE_Socket, _T("*** GSocket_new failed") );
|
wxLogTrace( wxTRACE_Socket, wxT("*** GSocket_new failed") );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1116,7 +1120,7 @@ wxSocketServer::wxSocketServer(wxSockAddress& addr_man,
|
|||||||
GSocket_destroy(m_socket);
|
GSocket_destroy(m_socket);
|
||||||
m_socket = NULL;
|
m_socket = NULL;
|
||||||
|
|
||||||
wxLogTrace( wxTRACE_Socket, _T("*** GSocket_SetServer failed") );
|
wxLogTrace( wxTRACE_Socket, wxT("*** GSocket_SetServer failed") );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1136,9 +1140,9 @@ bool wxSocketServer::AcceptWith(wxSocketBase& sock, bool wait)
|
|||||||
GSocket *child_socket;
|
GSocket *child_socket;
|
||||||
|
|
||||||
if (!m_socket)
|
if (!m_socket)
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
// If wait == FALSE, then the call should be nonblocking.
|
// If wait == false, then the call should be nonblocking.
|
||||||
// When we are finished, we put the socket to blocking mode
|
// When we are finished, we put the socket to blocking mode
|
||||||
// again.
|
// again.
|
||||||
|
|
||||||
@@ -1152,18 +1156,19 @@ bool wxSocketServer::AcceptWith(wxSocketBase& sock, bool wait)
|
|||||||
GSocket_SetNonBlocking(m_socket, 0);
|
GSocket_SetNonBlocking(m_socket, 0);
|
||||||
|
|
||||||
if (!child_socket)
|
if (!child_socket)
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
sock.m_type = wxSOCKET_BASE;
|
sock.m_type = wxSOCKET_BASE;
|
||||||
sock.m_socket = child_socket;
|
sock.m_socket = child_socket;
|
||||||
sock.m_connected = TRUE;
|
sock.m_connected = true;
|
||||||
|
|
||||||
GSocket_SetTimeout(sock.m_socket, sock.m_timeout * 1000);
|
GSocket_SetTimeout(sock.m_socket, sock.m_timeout * 1000);
|
||||||
GSocket_SetCallback(sock.m_socket, GSOCK_INPUT_FLAG | GSOCK_OUTPUT_FLAG |
|
GSocket_SetCallback(sock.m_socket, GSOCK_INPUT_FLAG | GSOCK_OUTPUT_FLAG |
|
||||||
GSOCK_LOST_FLAG | GSOCK_CONNECTION_FLAG,
|
GSOCK_LOST_FLAG | GSOCK_CONNECTION_FLAG,
|
||||||
wx_socket_callback, (char *)&sock);
|
wx_socket_callback, (char *)&sock);
|
||||||
#endif
|
#endif
|
||||||
return TRUE;
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxSocketBase *wxSocketServer::Accept(bool wait)
|
wxSocketBase *wxSocketServer::Accept(bool wait)
|
||||||
@@ -1219,18 +1224,18 @@ bool wxSocketClient::Connect(wxSockAddress& addr_man, bool wait)
|
|||||||
}
|
}
|
||||||
|
|
||||||
m_socket = GSocket_new();
|
m_socket = GSocket_new();
|
||||||
m_connected = FALSE;
|
m_connected = false;
|
||||||
m_establishing = FALSE;
|
m_establishing = false;
|
||||||
|
|
||||||
if (!m_socket)
|
if (!m_socket)
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
GSocket_SetTimeout(m_socket, m_timeout * 1000);
|
GSocket_SetTimeout(m_socket, m_timeout * 1000);
|
||||||
GSocket_SetCallback(m_socket, GSOCK_INPUT_FLAG | GSOCK_OUTPUT_FLAG |
|
GSocket_SetCallback(m_socket, GSOCK_INPUT_FLAG | GSOCK_OUTPUT_FLAG |
|
||||||
GSOCK_LOST_FLAG | GSOCK_CONNECTION_FLAG,
|
GSOCK_LOST_FLAG | GSOCK_CONNECTION_FLAG,
|
||||||
wx_socket_callback, (char *)this);
|
wx_socket_callback, (char *)this);
|
||||||
|
|
||||||
// If wait == FALSE, then the call should be nonblocking.
|
// If wait == false, then the call should be nonblocking.
|
||||||
// When we are finished, we put the socket to blocking mode
|
// When we are finished, we put the socket to blocking mode
|
||||||
// again.
|
// again.
|
||||||
|
|
||||||
@@ -1246,25 +1251,24 @@ bool wxSocketClient::Connect(wxSockAddress& addr_man, bool wait)
|
|||||||
if (err != GSOCK_NOERROR)
|
if (err != GSOCK_NOERROR)
|
||||||
{
|
{
|
||||||
if (err == GSOCK_WOULDBLOCK)
|
if (err == GSOCK_WOULDBLOCK)
|
||||||
m_establishing = TRUE;
|
m_establishing = true;
|
||||||
|
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_connected = TRUE;
|
m_connected = true;
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxSocketClient::WaitOnConnect(long seconds, long milliseconds)
|
bool wxSocketClient::WaitOnConnect(long seconds, long milliseconds)
|
||||||
{
|
{
|
||||||
if (m_connected) // Already connected
|
if (m_connected) // Already connected
|
||||||
return TRUE;
|
return true;
|
||||||
|
|
||||||
if (!m_establishing || !m_socket) // No connection in progress
|
if (!m_establishing || !m_socket) // No connection in progress
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
return _Wait(seconds, milliseconds, GSOCK_CONNECTION_FLAG |
|
return _Wait(seconds, milliseconds, GSOCK_CONNECTION_FLAG | GSOCK_LOST_FLAG);
|
||||||
GSOCK_LOST_FLAG);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ==========================================================================
|
// ==========================================================================
|
||||||
@@ -1294,8 +1298,8 @@ wxDatagramSocket::wxDatagramSocket( wxSockAddress& addr,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Initialize all stuff
|
// Initialize all stuff
|
||||||
m_connected = FALSE;
|
m_connected = false;
|
||||||
m_establishing = FALSE;
|
m_establishing = false;
|
||||||
GSocket_SetTimeout( m_socket, m_timeout );
|
GSocket_SetTimeout( m_socket, m_timeout );
|
||||||
GSocket_SetCallback( m_socket, GSOCK_INPUT_FLAG | GSOCK_OUTPUT_FLAG |
|
GSocket_SetCallback( m_socket, GSOCK_INPUT_FLAG | GSOCK_OUTPUT_FLAG |
|
||||||
GSOCK_LOST_FLAG | GSOCK_CONNECTION_FLAG,
|
GSOCK_LOST_FLAG | GSOCK_CONNECTION_FLAG,
|
||||||
@@ -1392,6 +1396,7 @@ GAddress *GAddress_copy(GAddress *address)
|
|||||||
free(addr2);
|
free(addr2);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(addr2->m_addr, address->m_addr, addr2->m_len);
|
memcpy(addr2->m_addr, address->m_addr, addr2->m_len);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1431,14 +1436,17 @@ GSocketError _GAddress_translate_from(GAddress *address,
|
|||||||
case AF_INET:
|
case AF_INET:
|
||||||
address->m_family = GSOCK_INET;
|
address->m_family = GSOCK_INET;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case AF_UNIX:
|
case AF_UNIX:
|
||||||
address->m_family = GSOCK_UNIX;
|
address->m_family = GSOCK_UNIX;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
#ifdef AF_INET6
|
#ifdef AF_INET6
|
||||||
case AF_INET6:
|
case AF_INET6:
|
||||||
address->m_family = GSOCK_INET6;
|
address->m_family = GSOCK_INET6;
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
address->m_error = GSOCK_INVOP;
|
address->m_error = GSOCK_INVOP;
|
||||||
@@ -1457,6 +1465,7 @@ GSocketError _GAddress_translate_from(GAddress *address,
|
|||||||
address->m_error = GSOCK_MEMERR;
|
address->m_error = GSOCK_MEMERR;
|
||||||
return GSOCK_MEMERR;
|
return GSOCK_MEMERR;
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(address->m_addr, addr, len);
|
memcpy(address->m_addr, addr, len);
|
||||||
|
|
||||||
return GSOCK_NOERROR;
|
return GSOCK_NOERROR;
|
||||||
@@ -1514,12 +1523,11 @@ GSocketError GAddress_INET_SetHostName(GAddress *address, const char *hostname)
|
|||||||
struct in_addr *addr;
|
struct in_addr *addr;
|
||||||
|
|
||||||
assert( address != NULL );
|
assert( address != NULL );
|
||||||
|
|
||||||
CHECK_ADDRESS( address, INET );
|
CHECK_ADDRESS( address, INET );
|
||||||
|
|
||||||
addr = &(((struct sockaddr_in *)address->m_addr)->sin_addr);
|
addr = &(((struct sockaddr_in *)address->m_addr)->sin_addr);
|
||||||
|
|
||||||
/* If it is a numeric host name, convert it now */
|
// If it is a numeric host name, convert it now
|
||||||
#if defined(HAVE_INET_ATON)
|
#if defined(HAVE_INET_ATON)
|
||||||
if (inet_aton(hostname, addr) == 0)
|
if (inet_aton(hostname, addr) == 0)
|
||||||
{
|
{
|
||||||
@@ -1527,19 +1535,19 @@ GSocketError GAddress_INET_SetHostName(GAddress *address, const char *hostname)
|
|||||||
if ( (addr->s_addr = inet_addr(hostname)) == -1 )
|
if ( (addr->s_addr = inet_addr(hostname)) == -1 )
|
||||||
{
|
{
|
||||||
#else
|
#else
|
||||||
/* Use gethostbyname by default */
|
// Use gethostbyname by default
|
||||||
#ifndef __WXMAC__
|
#ifndef __WXMAC__
|
||||||
int val = 1; /* VA doesn't like constants in conditional expressions */
|
int val = 1; // VA doesn't like constants in conditional expressions
|
||||||
if (val)
|
if (val)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
#endif
|
#endif
|
||||||
struct in_addr *array_addr;
|
struct in_addr *array_addr;
|
||||||
|
|
||||||
/* It is a real name, we solve it */
|
// It is a real name, we solve it
|
||||||
if ((he = gethostbyname(hostname)) == NULL)
|
if ((he = gethostbyname(hostname)) == NULL)
|
||||||
{
|
{
|
||||||
/* Reset to invalid address */
|
// Reset to invalid address
|
||||||
addr->s_addr = INADDR_NONE;
|
addr->s_addr = INADDR_NONE;
|
||||||
address->m_error = GSOCK_NOHOST;
|
address->m_error = GSOCK_NOHOST;
|
||||||
return GSOCK_NOHOST;
|
return GSOCK_NOHOST;
|
||||||
@@ -1547,6 +1555,7 @@ GSocketError GAddress_INET_SetHostName(GAddress *address, const char *hostname)
|
|||||||
array_addr = (struct in_addr *) *(he->h_addr_list);
|
array_addr = (struct in_addr *) *(he->h_addr_list);
|
||||||
addr->s_addr = array_addr[0].s_addr;
|
addr->s_addr = array_addr[0].s_addr;
|
||||||
}
|
}
|
||||||
|
|
||||||
return GSOCK_NOERROR;
|
return GSOCK_NOERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1561,7 +1570,6 @@ GSocketError GAddress_INET_SetHostAddress(GAddress *address,
|
|||||||
struct in_addr *addr;
|
struct in_addr *addr;
|
||||||
|
|
||||||
assert( address != NULL );
|
assert( address != NULL );
|
||||||
|
|
||||||
CHECK_ADDRESS( address, INET );
|
CHECK_ADDRESS( address, INET );
|
||||||
|
|
||||||
addr = &(((struct sockaddr_in *)address->m_addr)->sin_addr);
|
addr = &(((struct sockaddr_in *)address->m_addr)->sin_addr);
|
||||||
@@ -1588,8 +1596,8 @@ GSocketError GAddress_INET_SetPortName(GAddress *address, const char *port,
|
|||||||
se = getservbyname(port, protocol);
|
se = getservbyname(port, protocol);
|
||||||
if (!se)
|
if (!se)
|
||||||
{
|
{
|
||||||
/* the cast to int suppresses compiler warnings about subscript having the
|
// the cast to int suppresses compiler warnings
|
||||||
type char */
|
// about subscript having the type char
|
||||||
if (isdigit((int)port[0]))
|
if (isdigit((int)port[0]))
|
||||||
{
|
{
|
||||||
int port_int;
|
int port_int;
|
||||||
@@ -1667,6 +1675,7 @@ unsigned short GAddress_INET_GetPort(GAddress *address)
|
|||||||
CHECK_ADDRESS_RETVAL( address, INET, 0 );
|
CHECK_ADDRESS_RETVAL( address, INET, 0 );
|
||||||
|
|
||||||
addr = (struct sockaddr_in *)address->m_addr;
|
addr = (struct sockaddr_in *)address->m_addr;
|
||||||
|
|
||||||
return ntohs(addr->sin_port);
|
return ntohs(addr->sin_port);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1701,7 +1710,6 @@ GSocketError GAddress_UNIX_SetPath(GAddress *address, const char *path)
|
|||||||
struct sockaddr_un *addr;
|
struct sockaddr_un *addr;
|
||||||
|
|
||||||
assert( address != NULL );
|
assert( address != NULL );
|
||||||
|
|
||||||
CHECK_ADDRESS( address, UNIX );
|
CHECK_ADDRESS( address, UNIX );
|
||||||
|
|
||||||
addr = ((struct sockaddr_un *)address->m_addr);
|
addr = ((struct sockaddr_un *)address->m_addr);
|
||||||
@@ -1746,14 +1754,14 @@ GSocketError GSocket_SetLocal(GSocket *socket, GAddress *address)
|
|||||||
{
|
{
|
||||||
assert( socket != NULL );
|
assert( socket != NULL );
|
||||||
|
|
||||||
/* the socket must be initialized, or it must be a server */
|
// the socket must be initialized, or it must be a server
|
||||||
if ((socket->m_fd != INVALID_SOCKET && !socket->m_server))
|
if ((socket->m_fd != INVALID_SOCKET && !socket->m_server))
|
||||||
{
|
{
|
||||||
socket->m_error = GSOCK_INVSOCK;
|
socket->m_error = GSOCK_INVSOCK;
|
||||||
return GSOCK_INVSOCK;
|
return GSOCK_INVSOCK;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* check address */
|
// check address
|
||||||
if (address == NULL || address->m_family == GSOCK_NOFAMILY)
|
if (address == NULL || address->m_family == GSOCK_NOFAMILY)
|
||||||
{
|
{
|
||||||
socket->m_error = GSOCK_INVADDR;
|
socket->m_error = GSOCK_INVADDR;
|
||||||
@@ -1772,7 +1780,7 @@ GSocketError GSocket_SetPeer(GSocket *socket, GAddress *address)
|
|||||||
{
|
{
|
||||||
assert(socket != NULL);
|
assert(socket != NULL);
|
||||||
|
|
||||||
/* check address */
|
// check address
|
||||||
if (address == NULL || address->m_family == GSOCK_NOFAMILY)
|
if (address == NULL || address->m_family == GSOCK_NOFAMILY)
|
||||||
{
|
{
|
||||||
socket->m_error = GSOCK_INVADDR;
|
socket->m_error = GSOCK_INVADDR;
|
||||||
@@ -1796,11 +1804,11 @@ GAddress *GSocket_GetLocal(GSocket *socket)
|
|||||||
|
|
||||||
assert( socket != NULL );
|
assert( socket != NULL );
|
||||||
|
|
||||||
/* try to get it from the m_local var first */
|
// try to get it from the m_local var first
|
||||||
if (socket->m_local)
|
if (socket->m_local)
|
||||||
return GAddress_copy(socket->m_local);
|
return GAddress_copy(socket->m_local);
|
||||||
|
|
||||||
/* else, if the socket is initialized, try getsockname */
|
// else, if the socket is initialized, try getsockname
|
||||||
if (socket->m_fd == INVALID_SOCKET)
|
if (socket->m_fd == INVALID_SOCKET)
|
||||||
{
|
{
|
||||||
socket->m_error = GSOCK_INVSOCK;
|
socket->m_error = GSOCK_INVSOCK;
|
||||||
@@ -1813,7 +1821,7 @@ GAddress *GSocket_GetLocal(GSocket *socket)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* got a valid address from getsockname, create a GAddress object */
|
// got a valid address from getsockname, create a GAddress object
|
||||||
address = GAddress_new();
|
address = GAddress_new();
|
||||||
if (address == NULL)
|
if (address == NULL)
|
||||||
{
|
{
|
||||||
@@ -1836,17 +1844,13 @@ GAddress *GSocket_GetPeer(GSocket *socket)
|
|||||||
{
|
{
|
||||||
assert(socket != NULL);
|
assert(socket != NULL);
|
||||||
|
|
||||||
/* try to get it from the m_peer var */
|
// try to get it from the m_peer var
|
||||||
if (socket->m_peer)
|
if (socket->m_peer)
|
||||||
return GAddress_copy(socket->m_peer);
|
return GAddress_copy(socket->m_peer);
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
|
|
||||||
|
|
||||||
GSocket *GSocket_new(void)
|
GSocket *GSocket_new(void)
|
||||||
{
|
{
|
||||||
@@ -1862,19 +1866,20 @@ GSocket *GSocket_new(void)
|
|||||||
{
|
{
|
||||||
socket->m_cbacks[i] = NULL;
|
socket->m_cbacks[i] = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
socket->m_detected = 0;
|
socket->m_detected = 0;
|
||||||
|
|
||||||
socket->m_local = NULL;
|
socket->m_local = NULL;
|
||||||
socket->m_peer = NULL;
|
socket->m_peer = NULL;
|
||||||
socket->m_error = GSOCK_NOERROR;
|
socket->m_error = GSOCK_NOERROR;
|
||||||
|
|
||||||
socket->m_non_blocking = FALSE ;
|
socket->m_non_blocking = false ;
|
||||||
socket->m_stream = TRUE;
|
socket->m_stream = true;
|
||||||
// socket->m_oriented = TRUE;
|
// socket->m_oriented = true;
|
||||||
socket->m_server = FALSE;
|
socket->m_server = false;
|
||||||
socket->m_establishing = FALSE;
|
socket->m_establishing = false;
|
||||||
socket->m_timeout = 10 * 60 * 1000;
|
socket->m_timeout = 10 * 60 * 1000;
|
||||||
/* 10 minutes * 60 sec * 1000 millisec */
|
// 10 minutes * 60 sec * 1000 millisec
|
||||||
|
|
||||||
socket->m_cfSocket = NULL ;
|
socket->m_cfSocket = NULL ;
|
||||||
socket->m_runLoopSource = NULL ;
|
socket->m_runLoopSource = NULL ;
|
||||||
@@ -1894,6 +1899,7 @@ void GSocket_close(GSocket *socket)
|
|||||||
CFRelease( socket->m_readStream ) ;
|
CFRelease( socket->m_readStream ) ;
|
||||||
socket->m_readStream = NULL ;
|
socket->m_readStream = NULL ;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( socket->m_writeStream )
|
if ( socket->m_writeStream )
|
||||||
{
|
{
|
||||||
CFWriteStreamClose(socket->m_writeStream);
|
CFWriteStreamClose(socket->m_writeStream);
|
||||||
@@ -1912,7 +1918,7 @@ void GSocket_Shutdown(GSocket *socket)
|
|||||||
{
|
{
|
||||||
GSocket_close( socket );
|
GSocket_close( socket );
|
||||||
|
|
||||||
/* Disable GUI callbacks */
|
// Disable GUI callbacks
|
||||||
for (int evt = 0; evt < GSOCK_MAX_EVENT; evt++)
|
for (int evt = 0; evt < GSOCK_MAX_EVENT; evt++)
|
||||||
socket->m_cbacks[evt] = NULL;
|
socket->m_cbacks[evt] = NULL;
|
||||||
|
|
||||||
@@ -1923,18 +1929,18 @@ void GSocket_destroy(GSocket *socket)
|
|||||||
{
|
{
|
||||||
assert( socket != NULL );
|
assert( socket != NULL );
|
||||||
|
|
||||||
/* Check that the socket is really shutdowned */
|
// Check that the socket is really shut down
|
||||||
if (socket->m_fd != INVALID_SOCKET)
|
if (socket->m_fd != INVALID_SOCKET)
|
||||||
GSocket_Shutdown(socket);
|
GSocket_Shutdown(socket);
|
||||||
|
|
||||||
/* Destroy private addresses */
|
// Destroy private addresses
|
||||||
if (socket->m_local)
|
if (socket->m_local)
|
||||||
GAddress_destroy(socket->m_local);
|
GAddress_destroy(socket->m_local);
|
||||||
|
|
||||||
if (socket->m_peer)
|
if (socket->m_peer)
|
||||||
GAddress_destroy(socket->m_peer);
|
GAddress_destroy(socket->m_peer);
|
||||||
|
|
||||||
/* Destroy the socket itself */
|
// Destroy the socket itself
|
||||||
free(socket);
|
free(socket);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1954,11 +1960,11 @@ GSocketError GSocket_Connect(GSocket *socket, GSocketStream stream)
|
|||||||
return GSOCK_INVADDR;
|
return GSOCK_INVADDR;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Streamed or dgram socket? */
|
// Streamed or dgram socket?
|
||||||
socket->m_stream = (stream == GSOCK_STREAMED);
|
socket->m_stream = (stream == GSOCK_STREAMED);
|
||||||
socket->m_oriented = TRUE;
|
socket->m_oriented = true;
|
||||||
socket->m_server = FALSE;
|
socket->m_server = false;
|
||||||
socket->m_establishing = FALSE;
|
socket->m_establishing = false;
|
||||||
|
|
||||||
GSocketError returnErr = GSOCK_NOERROR ;
|
GSocketError returnErr = GSOCK_NOERROR ;
|
||||||
CFSocketError err ;
|
CFSocketError err ;
|
||||||
@@ -2008,10 +2014,11 @@ GSocketError GSocket_Connect(GSocket *socket, GSocketStream stream)
|
|||||||
socket->m_error = GSOCK_TIMEDOUT ;
|
socket->m_error = GSOCK_TIMEDOUT ;
|
||||||
return GSOCK_TIMEDOUT ;
|
return GSOCK_TIMEDOUT ;
|
||||||
}
|
}
|
||||||
|
|
||||||
// we don't know whether a connect in progress will be issued like this
|
// we don't know whether a connect in progress will be issued like this
|
||||||
if ( err != kCFSocketTimeout && socket->m_non_blocking )
|
if ( err != kCFSocketTimeout && socket->m_non_blocking )
|
||||||
{
|
{
|
||||||
socket->m_establishing = TRUE;
|
socket->m_establishing = true;
|
||||||
socket->m_error = GSOCK_WOULDBLOCK;
|
socket->m_error = GSOCK_WOULDBLOCK;
|
||||||
return GSOCK_WOULDBLOCK;
|
return GSOCK_WOULDBLOCK;
|
||||||
}
|
}
|
||||||
@@ -2027,8 +2034,8 @@ GSocketError GSocket_Connect(GSocket *socket, GSocketStream stream)
|
|||||||
/* Flags */
|
/* Flags */
|
||||||
|
|
||||||
/* GSocket_SetNonBlocking:
|
/* GSocket_SetNonBlocking:
|
||||||
* Sets the socket to non-blocking mode. All IO calls will return
|
* Sets the socket to non-blocking mode.
|
||||||
* immediately.
|
* All IO calls will return immediately.
|
||||||
*/
|
*/
|
||||||
void GSocket_SetNonBlocking(GSocket *socket, int non_block)
|
void GSocket_SetNonBlocking(GSocket *socket, int non_block)
|
||||||
{
|
{
|
||||||
@@ -2039,7 +2046,8 @@ void GSocket_SetNonBlocking(GSocket *socket, int non_block)
|
|||||||
socket->m_non_blocking = non_block;
|
socket->m_non_blocking = non_block;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* GSocket_SetTimeout:
|
/*
|
||||||
|
* GSocket_SetTimeout:
|
||||||
* Sets the timeout for blocking calls. Time is expressed in
|
* Sets the timeout for blocking calls. Time is expressed in
|
||||||
* milliseconds.
|
* milliseconds.
|
||||||
*/
|
*/
|
||||||
@@ -2147,16 +2155,20 @@ void _GSocket_Install_Callback(GSocket *socket, GSocketEvent event)
|
|||||||
else
|
else
|
||||||
c = kCFSocketConnectCallBack;
|
c = kCFSocketConnectCallBack;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GSOCK_LOST:
|
case GSOCK_LOST:
|
||||||
case GSOCK_INPUT:
|
case GSOCK_INPUT:
|
||||||
c = kCFSocketReadCallBack;
|
c = kCFSocketReadCallBack;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GSOCK_OUTPUT:
|
case GSOCK_OUTPUT:
|
||||||
c = kCFSocketWriteCallBack;
|
c = kCFSocketWriteCallBack;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
c = 0;
|
c = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
CFSocketEnableCallBacks(socket->m_cfSocket, c);
|
CFSocketEnableCallBacks(socket->m_cfSocket, c);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2171,16 +2183,21 @@ void _GSocket_Uninstall_Callback(GSocket *socket, GSocketEvent event)
|
|||||||
else
|
else
|
||||||
c = kCFSocketConnectCallBack;
|
c = kCFSocketConnectCallBack;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GSOCK_LOST:
|
case GSOCK_LOST:
|
||||||
case GSOCK_INPUT:
|
case GSOCK_INPUT:
|
||||||
c = kCFSocketReadCallBack;
|
c = kCFSocketReadCallBack;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GSOCK_OUTPUT:
|
case GSOCK_OUTPUT:
|
||||||
c = kCFSocketWriteCallBack;
|
c = kCFSocketWriteCallBack;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
c = 0;
|
c = 0;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
CFSocketDisableCallBacks(socket->m_cfSocket, c);
|
CFSocketDisableCallBacks(socket->m_cfSocket, c);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2215,14 +2232,17 @@ void wxMacCFSocketCallback(CFSocketRef s, CFSocketCallBackType callbackType,
|
|||||||
CALL_CALLBACK( socket , GSOCK_CONNECTION ) ;
|
CALL_CALLBACK( socket , GSOCK_CONNECTION ) ;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case kCFSocketReadCallBack:
|
case kCFSocketReadCallBack:
|
||||||
CALL_CALLBACK( socket , GSOCK_INPUT ) ;
|
CALL_CALLBACK( socket , GSOCK_INPUT ) ;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case kCFSocketWriteCallBack:
|
case kCFSocketWriteCallBack:
|
||||||
CALL_CALLBACK( socket , GSOCK_OUTPUT ) ;
|
CALL_CALLBACK( socket , GSOCK_OUTPUT ) ;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break; /* We shouldn't get here. */
|
break; // We shouldn't get here.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2243,12 +2263,14 @@ int GSocket_Write(GSocket *socket, const char *buffer, int size)
|
|||||||
|
|
||||||
assert(socket != NULL);
|
assert(socket != NULL);
|
||||||
ret = CFWriteStreamWrite( socket->m_writeStream , (UInt8*) buffer , size ) ;
|
ret = CFWriteStreamWrite( socket->m_writeStream , (UInt8*) buffer , size ) ;
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
GSocketEventFlags GSocket_Select(GSocket *socket, GSocketEventFlags flags)
|
GSocketEventFlags GSocket_Select(GSocket *socket, GSocketEventFlags flags)
|
||||||
{
|
{
|
||||||
assert( socket != NULL );
|
assert( socket != NULL );
|
||||||
|
|
||||||
return flags & socket->m_detected;
|
return flags & socket->m_detected;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2262,7 +2284,7 @@ public:
|
|||||||
virtual bool OnInit()
|
virtual bool OnInit()
|
||||||
{
|
{
|
||||||
// wxSocketBase will call GSocket_Init() itself when/if needed
|
// wxSocketBase will call GSocket_Init() itself when/if needed
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void OnExit()
|
virtual void OnExit()
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
// Name: checkbox.cpp
|
// Name: src/mac/carbon/checkbox.cpp
|
||||||
// Purpose: wxCheckBox
|
// Purpose: wxCheckBox
|
||||||
// Author: Stefan Csomor
|
// Author: Stefan Csomor
|
||||||
// Modified by:
|
// Modified by:
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
// Name: cursor.cpp
|
// Name: src/mac/carbon/cursor.cpp
|
||||||
// Purpose: wxCursor class
|
// Purpose: wxCursor class
|
||||||
// Author: Stefan Csomor
|
// Author: Stefan Csomor
|
||||||
// Modified by:
|
// Modified by:
|
||||||
@@ -19,14 +19,17 @@
|
|||||||
|
|
||||||
#include "wx/mac/private.h"
|
#include "wx/mac/private.h"
|
||||||
|
|
||||||
|
|
||||||
IMPLEMENT_DYNAMIC_CLASS(wxCursor, wxBitmap)
|
IMPLEMENT_DYNAMIC_CLASS(wxCursor, wxBitmap)
|
||||||
|
|
||||||
|
|
||||||
class WXDLLEXPORT wxCursorRefData: public wxBitmapRefData
|
class WXDLLEXPORT wxCursorRefData: public wxBitmapRefData
|
||||||
{
|
{
|
||||||
DECLARE_NO_COPY_CLASS(wxCursorRefData)
|
DECLARE_NO_COPY_CLASS(wxCursorRefData)
|
||||||
|
|
||||||
friend class WXDLLEXPORT wxBitmap;
|
friend class WXDLLEXPORT wxBitmap;
|
||||||
friend class WXDLLEXPORT wxCursor;
|
friend class WXDLLEXPORT wxCursor;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
wxCursorRefData();
|
wxCursorRefData();
|
||||||
~wxCursorRefData();
|
~wxCursorRefData();
|
||||||
@@ -191,6 +194,7 @@ CursHandle wxGetStockCursor( int number )
|
|||||||
wxASSERT_MSG( number >= 0 && number <=kwxCursorLast , wxT("invalid stock cursor id") ) ;
|
wxASSERT_MSG( number >= 0 && number <=kwxCursorLast , wxT("invalid stock cursor id") ) ;
|
||||||
CursHandle c = (CursHandle) NewHandle( sizeof(Cursor) ) ;
|
CursHandle c = (CursHandle) NewHandle( sizeof(Cursor) ) ;
|
||||||
memcpy( *c, &gMacCursors[number], sizeof(Cursor) ) ;
|
memcpy( *c, &gMacCursors[number], sizeof(Cursor) ) ;
|
||||||
|
|
||||||
return c ;
|
return c ;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -222,7 +226,6 @@ wxCursorRefData::~wxCursorRefData()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cursors
|
|
||||||
wxCursor::wxCursor()
|
wxCursor::wxCursor()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -252,14 +255,14 @@ wxCursor::wxCursor(char **bits)
|
|||||||
bool wxCursor::CreateFromXpm(const char **bits)
|
bool wxCursor::CreateFromXpm(const char **bits)
|
||||||
{
|
{
|
||||||
#if wxUSE_IMAGE
|
#if wxUSE_IMAGE
|
||||||
wxCHECK_MSG( bits != NULL, FALSE, wxT("invalid cursor data") )
|
wxCHECK_MSG( bits != NULL, false, wxT("invalid cursor data") )
|
||||||
wxXPMDecoder decoder;
|
wxXPMDecoder decoder;
|
||||||
wxImage img = decoder.ReadData(bits);
|
wxImage img = decoder.ReadData(bits);
|
||||||
wxCHECK_MSG( img.Ok(), FALSE, wxT("invalid cursor data") )
|
wxCHECK_MSG( img.Ok(), false, wxT("invalid cursor data") )
|
||||||
CreateFromImage( img ) ;
|
CreateFromImage( img ) ;
|
||||||
return TRUE;
|
return true;
|
||||||
#else
|
#else
|
||||||
return FALSE;
|
return false;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -277,17 +280,20 @@ short GetCTabIndex( CTabHandle colors , RGBColor *col )
|
|||||||
{
|
{
|
||||||
short retval = 0 ;
|
short retval = 0 ;
|
||||||
unsigned long bestdiff = 0xFFFF ;
|
unsigned long bestdiff = 0xFFFF ;
|
||||||
|
|
||||||
for ( int i = 0 ; i < (**colors).ctSize ; ++i )
|
for ( int i = 0 ; i < (**colors).ctSize ; ++i )
|
||||||
{
|
{
|
||||||
unsigned long diff = abs(col->red - (**colors).ctTable[i].rgb.red ) +
|
unsigned long diff = abs(col->red - (**colors).ctTable[i].rgb.red ) +
|
||||||
abs(col->green - (**colors).ctTable[i].rgb.green ) +
|
abs(col->green - (**colors).ctTable[i].rgb.green ) +
|
||||||
abs(col->blue - (**colors).ctTable[i].rgb.blue ) ;
|
abs(col->blue - (**colors).ctTable[i].rgb.blue ) ;
|
||||||
|
|
||||||
if ( diff < bestdiff )
|
if ( diff < bestdiff )
|
||||||
{
|
{
|
||||||
bestdiff = diff ;
|
bestdiff = diff ;
|
||||||
retval = (**colors).ctTable[i].value ;
|
retval = (**colors).ctTable[i].value ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return retval ;
|
return retval ;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -307,7 +313,7 @@ void wxCursor::CreateFromImage(const wxImage & image)
|
|||||||
|
|
||||||
wxASSERT_MSG( hotSpotX >= 0 && hotSpotX < image_w &&
|
wxASSERT_MSG( hotSpotX >= 0 && hotSpotX < image_w &&
|
||||||
hotSpotY >= 0 && hotSpotY < image_h,
|
hotSpotY >= 0 && hotSpotY < image_h,
|
||||||
_T("invalid cursor hot spot coordinates") );
|
wxT("invalid cursor hot spot coordinates") );
|
||||||
|
|
||||||
wxImage image16(image); // final image of correct size
|
wxImage image16(image); // final image of correct size
|
||||||
|
|
||||||
@@ -331,7 +337,6 @@ void wxCursor::CreateFromImage(const wxImage & image)
|
|||||||
unsigned char * rgbBits = image16.GetData();
|
unsigned char * rgbBits = image16.GetData();
|
||||||
bool bHasMask = image16.HasMask() ;
|
bool bHasMask = image16.HasMask() ;
|
||||||
|
|
||||||
|
|
||||||
PixMapHandle pm = (PixMapHandle) NewHandleClear( sizeof(PixMap) ) ;
|
PixMapHandle pm = (PixMapHandle) NewHandleClear( sizeof(PixMap) ) ;
|
||||||
short extent = 16 ;
|
short extent = 16 ;
|
||||||
short bytesPerPixel = 1 ;
|
short bytesPerPixel = 1 ;
|
||||||
@@ -340,11 +345,13 @@ void wxCursor::CreateFromImage(const wxImage & image)
|
|||||||
CCrsrHandle ch = (CCrsrHandle) NewHandleClear( sizeof(CCrsr) ) ;
|
CCrsrHandle ch = (CCrsrHandle) NewHandleClear( sizeof(CCrsr) ) ;
|
||||||
CTabHandle newColors = GetCTable( 8 ) ;
|
CTabHandle newColors = GetCTable( 8 ) ;
|
||||||
HandToHand( (Handle *) &newColors );
|
HandToHand( (Handle *) &newColors );
|
||||||
|
|
||||||
// set the values to the indices
|
// set the values to the indices
|
||||||
for ( int i = 0 ; i < (**newColors).ctSize ; ++i )
|
for ( int i = 0 ; i < (**newColors).ctSize ; ++i )
|
||||||
{
|
{
|
||||||
(**newColors).ctTable[i].value = i ;
|
(**newColors).ctTable[i].value = i ;
|
||||||
}
|
}
|
||||||
|
|
||||||
HLock( (Handle)ch );
|
HLock( (Handle)ch );
|
||||||
(**ch).crsrType = 0x8001; // color cursors
|
(**ch).crsrType = 0x8001; // color cursors
|
||||||
(**ch).crsrMap = pm;
|
(**ch).crsrMap = pm;
|
||||||
@@ -356,8 +363,8 @@ void wxCursor::CreateFromImage(const wxImage & image)
|
|||||||
(**pm).pmVersion = 0;
|
(**pm).pmVersion = 0;
|
||||||
(**pm).packType = 0;
|
(**pm).packType = 0;
|
||||||
(**pm).packSize = 0;
|
(**pm).packSize = 0;
|
||||||
(**pm).hRes = 0x00480000; /* 72 DPI default res */
|
(**pm).hRes = 0x00480000; // 72 DPI default res
|
||||||
(**pm).vRes = 0x00480000; /* 72 DPI default res */
|
(**pm).vRes = 0x00480000; // 72 DPI default res
|
||||||
(**pm).pixelSize = depth;
|
(**pm).pixelSize = depth;
|
||||||
(**pm).pixelType = 0;
|
(**pm).pixelType = 0;
|
||||||
(**pm).cmpCount = 1;
|
(**pm).cmpCount = 1;
|
||||||
@@ -380,10 +387,10 @@ void wxCursor::CreateFromImage(const wxImage & image)
|
|||||||
unsigned char mr = image16.GetMaskRed() ;
|
unsigned char mr = image16.GetMaskRed() ;
|
||||||
unsigned char mg = image16.GetMaskGreen() ;
|
unsigned char mg = image16.GetMaskGreen() ;
|
||||||
unsigned char mb = image16.GetMaskBlue() ;
|
unsigned char mb = image16.GetMaskBlue() ;
|
||||||
|
|
||||||
for ( int y = 0 ; y < h ; ++y )
|
for ( int y = 0 ; y < h ; ++y )
|
||||||
{
|
{
|
||||||
short rowbits = 0 ;
|
short rowbits = 0, maskbits = 0 ;
|
||||||
short maskbits = 0 ;
|
|
||||||
|
|
||||||
for ( int x = 0 ; x < w ; ++x )
|
for ( int x = 0 ; x < w ; ++x )
|
||||||
{
|
{
|
||||||
@@ -401,23 +408,23 @@ void wxCursor::CreateFromImage(const wxImage & image)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ( (int)r + (int)g + (int)b < 0x0200 )
|
if ( (int)r + (int)g + (int)b < 0x0200 )
|
||||||
{
|
|
||||||
rowbits |= ( 1 << (15 - x) ) ;
|
rowbits |= ( 1 << (15 - x) ) ;
|
||||||
}
|
|
||||||
maskbits |= ( 1 << (15 - x) ) ;
|
maskbits |= ( 1 << (15 - x) ) ;
|
||||||
|
|
||||||
col = *((RGBColor*) wxColor( r , g , b ).GetPixel()) ;
|
col = *((RGBColor*) wxColor( r , g , b ).GetPixel()) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
*((*(**ch).crsrData) + y * bytesPerRow + x) =
|
*((*(**ch).crsrData) + y * bytesPerRow + x) =
|
||||||
GetCTabIndex( newColors , &col) ;
|
GetCTabIndex( newColors , &col) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
(**ch).crsr1Data[y] = rowbits ;
|
(**ch).crsr1Data[y] = rowbits ;
|
||||||
(**ch).crsrMask[y] = maskbits ;
|
(**ch).crsrMask[y] = maskbits ;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !bHasMask )
|
if ( !bHasMask )
|
||||||
{
|
|
||||||
memcpy( (**ch).crsrMask , (**ch).crsr1Data , sizeof( Bits16) ) ;
|
memcpy( (**ch).crsrMask , (**ch).crsr1Data , sizeof( Bits16) ) ;
|
||||||
}
|
|
||||||
|
|
||||||
HUnlock( (Handle)ch ) ;
|
HUnlock( (Handle)ch ) ;
|
||||||
M_CURSORDATA->m_hCursor = ch ;
|
M_CURSORDATA->m_hCursor = ch ;
|
||||||
@@ -439,8 +446,10 @@ wxCursor::wxCursor(const wxString& cursor_file, long flags, int hotSpotX, int ho
|
|||||||
{
|
{
|
||||||
short theId = -1 ;
|
short theId = -1 ;
|
||||||
OSType theType ;
|
OSType theType ;
|
||||||
|
|
||||||
GetResInfo( resHandle , &theId , &theType , theName ) ;
|
GetResInfo( resHandle , &theId , &theType , theName ) ;
|
||||||
ReleaseResource( resHandle ) ;
|
ReleaseResource( resHandle ) ;
|
||||||
|
|
||||||
M_CURSORDATA->m_hCursor = GetCCursor( theId ) ;
|
M_CURSORDATA->m_hCursor = GetCCursor( theId ) ;
|
||||||
if ( M_CURSORDATA->m_hCursor )
|
if ( M_CURSORDATA->m_hCursor )
|
||||||
M_CURSORDATA->m_isColorCursor = true ;
|
M_CURSORDATA->m_isColorCursor = true ;
|
||||||
@@ -452,8 +461,10 @@ wxCursor::wxCursor(const wxString& cursor_file, long flags, int hotSpotX, int ho
|
|||||||
{
|
{
|
||||||
short theId = -1 ;
|
short theId = -1 ;
|
||||||
OSType theType ;
|
OSType theType ;
|
||||||
|
|
||||||
GetResInfo( resHandle , &theId , &theType , theName ) ;
|
GetResInfo( resHandle , &theId , &theType , theName ) ;
|
||||||
ReleaseResource( resHandle ) ;
|
ReleaseResource( resHandle ) ;
|
||||||
|
|
||||||
M_CURSORDATA->m_hCursor = GetCursor( theId ) ;
|
M_CURSORDATA->m_hCursor = GetCursor( theId ) ;
|
||||||
if ( M_CURSORDATA->m_hCursor )
|
if ( M_CURSORDATA->m_hCursor )
|
||||||
M_CURSORDATA->m_releaseHandle = true ;
|
M_CURSORDATA->m_releaseHandle = true ;
|
||||||
@@ -486,105 +497,91 @@ wxCursor::wxCursor(int cursor_type)
|
|||||||
case wxCURSOR_COPY_ARROW:
|
case wxCURSOR_COPY_ARROW:
|
||||||
M_CURSORDATA->m_themeCursor = kThemeCopyArrowCursor;
|
M_CURSORDATA->m_themeCursor = kThemeCopyArrowCursor;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case wxCURSOR_WAIT:
|
case wxCURSOR_WAIT:
|
||||||
M_CURSORDATA->m_themeCursor = kThemeWatchCursor;
|
M_CURSORDATA->m_themeCursor = kThemeWatchCursor;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case wxCURSOR_IBEAM:
|
case wxCURSOR_IBEAM:
|
||||||
M_CURSORDATA->m_themeCursor = kThemeIBeamCursor;
|
M_CURSORDATA->m_themeCursor = kThemeIBeamCursor;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case wxCURSOR_CROSS:
|
case wxCURSOR_CROSS:
|
||||||
M_CURSORDATA->m_themeCursor = kThemeCrossCursor;
|
M_CURSORDATA->m_themeCursor = kThemeCrossCursor;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case wxCURSOR_SIZENWSE:
|
case wxCURSOR_SIZENWSE:
|
||||||
{
|
|
||||||
M_CURSORDATA->m_hCursor = wxGetStockCursor(kwxCursorSizeNWSE);
|
M_CURSORDATA->m_hCursor = wxGetStockCursor(kwxCursorSizeNWSE);
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case wxCURSOR_SIZENESW:
|
case wxCURSOR_SIZENESW:
|
||||||
{
|
|
||||||
M_CURSORDATA->m_hCursor = wxGetStockCursor(kwxCursorSizeNESW);
|
M_CURSORDATA->m_hCursor = wxGetStockCursor(kwxCursorSizeNESW);
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case wxCURSOR_SIZEWE:
|
case wxCURSOR_SIZEWE:
|
||||||
{
|
|
||||||
M_CURSORDATA->m_themeCursor = kThemeResizeLeftRightCursor;
|
M_CURSORDATA->m_themeCursor = kThemeResizeLeftRightCursor;
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case wxCURSOR_SIZENS:
|
case wxCURSOR_SIZENS:
|
||||||
{
|
|
||||||
M_CURSORDATA->m_hCursor = wxGetStockCursor(kwxCursorSizeNS);
|
M_CURSORDATA->m_hCursor = wxGetStockCursor(kwxCursorSizeNS);
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case wxCURSOR_SIZING:
|
case wxCURSOR_SIZING:
|
||||||
{
|
|
||||||
M_CURSORDATA->m_hCursor = wxGetStockCursor(kwxCursorSize);
|
M_CURSORDATA->m_hCursor = wxGetStockCursor(kwxCursorSize);
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case wxCURSOR_HAND:
|
case wxCURSOR_HAND:
|
||||||
{
|
|
||||||
M_CURSORDATA->m_themeCursor = kThemePointingHandCursor;
|
M_CURSORDATA->m_themeCursor = kThemePointingHandCursor;
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case wxCURSOR_BULLSEYE:
|
case wxCURSOR_BULLSEYE:
|
||||||
{
|
|
||||||
M_CURSORDATA->m_hCursor = wxGetStockCursor(kwxCursorBullseye);
|
M_CURSORDATA->m_hCursor = wxGetStockCursor(kwxCursorBullseye);
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case wxCURSOR_PENCIL:
|
case wxCURSOR_PENCIL:
|
||||||
{
|
|
||||||
M_CURSORDATA->m_hCursor = wxGetStockCursor(kwxCursorPencil);
|
M_CURSORDATA->m_hCursor = wxGetStockCursor(kwxCursorPencil);
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case wxCURSOR_MAGNIFIER:
|
case wxCURSOR_MAGNIFIER:
|
||||||
{
|
|
||||||
M_CURSORDATA->m_hCursor = wxGetStockCursor(kwxCursorMagnifier);
|
M_CURSORDATA->m_hCursor = wxGetStockCursor(kwxCursorMagnifier);
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case wxCURSOR_NO_ENTRY:
|
case wxCURSOR_NO_ENTRY:
|
||||||
{
|
|
||||||
M_CURSORDATA->m_hCursor = wxGetStockCursor(kwxCursorNoEntry);
|
M_CURSORDATA->m_hCursor = wxGetStockCursor(kwxCursorNoEntry);
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case wxCURSOR_WATCH:
|
case wxCURSOR_WATCH:
|
||||||
{
|
|
||||||
M_CURSORDATA->m_themeCursor = kThemeWatchCursor;
|
M_CURSORDATA->m_themeCursor = kThemeWatchCursor;
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
case wxCURSOR_PAINT_BRUSH:
|
case wxCURSOR_PAINT_BRUSH:
|
||||||
{
|
|
||||||
M_CURSORDATA->m_hCursor = wxGetStockCursor(kwxCursorPaintBrush);
|
M_CURSORDATA->m_hCursor = wxGetStockCursor(kwxCursorPaintBrush);
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
case wxCURSOR_POINT_LEFT:
|
case wxCURSOR_POINT_LEFT:
|
||||||
{
|
|
||||||
M_CURSORDATA->m_hCursor = wxGetStockCursor(kwxCursorPointLeft);
|
M_CURSORDATA->m_hCursor = wxGetStockCursor(kwxCursorPointLeft);
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
case wxCURSOR_POINT_RIGHT:
|
case wxCURSOR_POINT_RIGHT:
|
||||||
{
|
|
||||||
M_CURSORDATA->m_hCursor = wxGetStockCursor(kwxCursorPointRight);
|
M_CURSORDATA->m_hCursor = wxGetStockCursor(kwxCursorPointRight);
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
case wxCURSOR_QUESTION_ARROW:
|
case wxCURSOR_QUESTION_ARROW:
|
||||||
{
|
|
||||||
M_CURSORDATA->m_hCursor = wxGetStockCursor(kwxCursorQuestionArrow);
|
M_CURSORDATA->m_hCursor = wxGetStockCursor(kwxCursorQuestionArrow);
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
case wxCURSOR_BLANK:
|
case wxCURSOR_BLANK:
|
||||||
{
|
|
||||||
M_CURSORDATA->m_hCursor = wxGetStockCursor(kwxCursorBlank);
|
M_CURSORDATA->m_hCursor = wxGetStockCursor(kwxCursorBlank);
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
case wxCURSOR_RIGHT_ARROW:
|
case wxCURSOR_RIGHT_ARROW:
|
||||||
{
|
|
||||||
M_CURSORDATA->m_hCursor = wxGetStockCursor(kwxCursorRightArrow);
|
M_CURSORDATA->m_hCursor = wxGetStockCursor(kwxCursorRightArrow);
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
case wxCURSOR_SPRAYCAN:
|
case wxCURSOR_SPRAYCAN:
|
||||||
{
|
|
||||||
M_CURSORDATA->m_hCursor = wxGetStockCursor(kwxCursorRoller);
|
M_CURSORDATA->m_hCursor = wxGetStockCursor(kwxCursorRoller);
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
case wxCURSOR_CHAR:
|
case wxCURSOR_CHAR:
|
||||||
case wxCURSOR_ARROW:
|
case wxCURSOR_ARROW:
|
||||||
case wxCURSOR_LEFT_BUTTON:
|
case wxCURSOR_LEFT_BUTTON:
|
||||||
@@ -594,6 +591,7 @@ wxCursor::wxCursor(int cursor_type)
|
|||||||
M_CURSORDATA->m_themeCursor = kThemeArrowCursor;
|
M_CURSORDATA->m_themeCursor = kThemeArrowCursor;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( M_CURSORDATA->m_themeCursor == -1 )
|
if ( M_CURSORDATA->m_themeCursor == -1 )
|
||||||
M_CURSORDATA->m_releaseHandle = true;
|
M_CURSORDATA->m_releaseHandle = true;
|
||||||
}
|
}
|
||||||
@@ -627,5 +625,3 @@ void wxSetCursor(const wxCursor& cursor)
|
|||||||
{
|
{
|
||||||
cursor.MacInstall() ;
|
cursor.MacInstall() ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -19,22 +19,17 @@
|
|||||||
#include "wx/tokenzr.h"
|
#include "wx/tokenzr.h"
|
||||||
#include "wx/filename.h"
|
#include "wx/filename.h"
|
||||||
|
|
||||||
#ifndef __DARWIN__
|
|
||||||
#include "PLStringFuncs.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
IMPLEMENT_CLASS(wxFileDialog, wxFileDialogBase)
|
|
||||||
|
|
||||||
// begin wxmac
|
|
||||||
|
|
||||||
#include "wx/mac/private.h"
|
#include "wx/mac/private.h"
|
||||||
|
|
||||||
#ifndef __DARWIN__
|
#ifndef __DARWIN__
|
||||||
#include <Navigation.h>
|
#include <Navigation.h>
|
||||||
|
#include "PLStringFuncs.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "MoreFilesX.h"
|
#include "MoreFilesX.h"
|
||||||
|
|
||||||
|
IMPLEMENT_CLASS(wxFileDialog, wxFileDialogBase)
|
||||||
|
|
||||||
extern bool gUseNavServices;
|
extern bool gUseNavServices;
|
||||||
|
|
||||||
// the data we need to pass to our standard file hook routine
|
// the data we need to pass to our standard file hook routine
|
||||||
@@ -43,7 +38,8 @@ extern bool gUseNavServices ;
|
|||||||
// and a copy of the "previous" file spec of the reply record
|
// and a copy of the "previous" file spec of the reply record
|
||||||
// so we can see if the selection has changed
|
// so we can see if the selection has changed
|
||||||
|
|
||||||
struct OpenUserDataRec {
|
struct OpenUserDataRec
|
||||||
|
{
|
||||||
int currentfilter ;
|
int currentfilter ;
|
||||||
bool saveMode ;
|
bool saveMode ;
|
||||||
wxArrayString name ;
|
wxArrayString name ;
|
||||||
@@ -63,14 +59,14 @@ static pascal void NavEventProc(
|
|||||||
|
|
||||||
static NavEventUPP sStandardNavEventFilter = NewNavEventUPP(NavEventProc);
|
static NavEventUPP sStandardNavEventFilter = NewNavEventUPP(NavEventProc);
|
||||||
|
|
||||||
static pascal void
|
static pascal void NavEventProc(
|
||||||
NavEventProc(
|
|
||||||
NavEventCallbackMessage inSelector,
|
NavEventCallbackMessage inSelector,
|
||||||
NavCBRecPtr ioParams,
|
NavCBRecPtr ioParams,
|
||||||
NavCallBackUserData ioUserData )
|
NavCallBackUserData ioUserData )
|
||||||
{
|
{
|
||||||
OpenUserDataRec * data = ( OpenUserDataRec *) ioUserData ;
|
OpenUserDataRec * data = ( OpenUserDataRec *) ioUserData ;
|
||||||
if (inSelector == kNavCBEvent) {
|
if (inSelector == kNavCBEvent)
|
||||||
|
{
|
||||||
}
|
}
|
||||||
else if ( inSelector == kNavCBStart )
|
else if ( inSelector == kNavCBStart )
|
||||||
{
|
{
|
||||||
@@ -122,7 +118,6 @@ NavEventProc(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MakeUserDataRec(OpenUserDataRec *myData , const wxString& filter )
|
void MakeUserDataRec(OpenUserDataRec *myData , const wxString& filter )
|
||||||
{
|
{
|
||||||
myData->menuitems = NULL ;
|
myData->menuitems = NULL ;
|
||||||
@@ -135,17 +130,21 @@ void MakeUserDataRec(OpenUserDataRec *myData , const wxString& filter )
|
|||||||
int filterIndex = 0;
|
int filterIndex = 0;
|
||||||
bool isName = true ;
|
bool isName = true ;
|
||||||
wxString current ;
|
wxString current ;
|
||||||
|
|
||||||
for ( unsigned int i = 0; i < filter2.Len() ; i++ )
|
for ( unsigned int i = 0; i < filter2.Len() ; i++ )
|
||||||
{
|
{
|
||||||
if ( filter2.GetChar(i) == wxT('|') )
|
if ( filter2.GetChar(i) == wxT('|') )
|
||||||
{
|
{
|
||||||
if( isName ) {
|
if ( isName )
|
||||||
|
{
|
||||||
myData->name.Add( current ) ;
|
myData->name.Add( current ) ;
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
myData->extensions.Add( current.MakeUpper() ) ;
|
myData->extensions.Add( current.MakeUpper() ) ;
|
||||||
++filterIndex ;
|
++filterIndex ;
|
||||||
}
|
}
|
||||||
|
|
||||||
isName = !isName ;
|
isName = !isName ;
|
||||||
current = wxEmptyString ;
|
current = wxEmptyString ;
|
||||||
}
|
}
|
||||||
@@ -170,29 +169,24 @@ void MakeUserDataRec(OpenUserDataRec *myData , const wxString& filter )
|
|||||||
const size_t extCount = myData->extensions.GetCount();
|
const size_t extCount = myData->extensions.GetCount();
|
||||||
for ( size_t i = 0 ; i < extCount; i++ )
|
for ( size_t i = 0 ; i < extCount; i++ )
|
||||||
{
|
{
|
||||||
wxUint32 fileType;
|
wxUint32 fileType, creator;
|
||||||
wxUint32 creator;
|
|
||||||
wxString extension = myData->extensions[i];
|
wxString extension = myData->extensions[i];
|
||||||
|
|
||||||
|
// Remove leading '*'
|
||||||
if (extension.GetChar(0) == '*')
|
if (extension.GetChar(0) == '*')
|
||||||
extension = extension.Mid(1); // Remove leading *
|
extension = extension.Mid( 1 );
|
||||||
|
|
||||||
|
// Remove leading '.'
|
||||||
if (extension.GetChar(0) == '.')
|
if (extension.GetChar(0) == '.')
|
||||||
{
|
extension = extension.Mid( 1 );
|
||||||
extension = extension.Mid(1); // Remove leading .
|
|
||||||
}
|
|
||||||
|
|
||||||
if (wxFileName::MacFindDefaultTypeAndCreator( extension, &fileType, &creator ))
|
if (wxFileName::MacFindDefaultTypeAndCreator( extension, &fileType, &creator ))
|
||||||
{
|
|
||||||
myData->filtermactypes.Add( (OSType)fileType );
|
myData->filtermactypes.Add( (OSType)fileType );
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
|
||||||
myData->filtermactypes.Add( '****' ); // We'll fail safe if it's not recognized
|
myData->filtermactypes.Add( '****' ); // We'll fail safe if it's not recognized
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
static Boolean CheckFile( const wxString &filename , OSType type , OpenUserDataRecPtr data)
|
static Boolean CheckFile( const wxString &filename , OSType type , OpenUserDataRecPtr data)
|
||||||
{
|
{
|
||||||
@@ -221,8 +215,10 @@ static Boolean CheckFile( const wxString &filename , OSType type , OpenUserDataR
|
|||||||
return true ;
|
return true ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false ;
|
return false ;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true ;
|
return true ;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -256,7 +252,8 @@ static pascal Boolean CrossPlatformFileFilter(CInfoPBPtr myCInfoPBPtr, void *dat
|
|||||||
|
|
||||||
// end wxmac
|
// end wxmac
|
||||||
|
|
||||||
wxFileDialog::wxFileDialog(wxWindow *parent, const wxString& message,
|
wxFileDialog::wxFileDialog(
|
||||||
|
wxWindow *parent, const wxString& message,
|
||||||
const wxString& defaultDir, const wxString& defaultFileName, const wxString& wildCard,
|
const wxString& defaultDir, const wxString& defaultFileName, const wxString& wildCard,
|
||||||
long style, const wxPoint& pos)
|
long style, const wxPoint& pos)
|
||||||
: wxFileDialogBase(parent, message, defaultDir, defaultFileName, wildCard, style, pos)
|
: wxFileDialogBase(parent, message, defaultDir, defaultFileName, wildCard, style, pos)
|
||||||
@@ -268,8 +265,7 @@ pascal Boolean CrossPlatformFilterCallback (
|
|||||||
AEDesc *theItem,
|
AEDesc *theItem,
|
||||||
void *info,
|
void *info,
|
||||||
void *callBackUD,
|
void *callBackUD,
|
||||||
NavFilterModes filterMode
|
NavFilterModes filterMode )
|
||||||
)
|
|
||||||
{
|
{
|
||||||
bool display = true;
|
bool display = true;
|
||||||
OpenUserDataRecPtr data = (OpenUserDataRecPtr) callBackUD ;
|
OpenUserDataRecPtr data = (OpenUserDataRecPtr) callBackUD ;
|
||||||
@@ -303,6 +299,7 @@ int wxFileDialog::ShowModal()
|
|||||||
{
|
{
|
||||||
OSErr err;
|
OSErr err;
|
||||||
NavDialogCreationOptions dialogCreateOptions;
|
NavDialogCreationOptions dialogCreateOptions;
|
||||||
|
|
||||||
// set default options
|
// set default options
|
||||||
::NavGetDefaultDialogCreationOptions(&dialogCreateOptions);
|
::NavGetDefaultDialogCreationOptions(&dialogCreateOptions);
|
||||||
|
|
||||||
@@ -341,12 +338,10 @@ int wxFileDialog::ShowModal()
|
|||||||
{
|
{
|
||||||
myData.saveMode = true;
|
myData.saveMode = true;
|
||||||
|
|
||||||
if (!numFilters)
|
|
||||||
{
|
|
||||||
dialogCreateOptions.optionFlags |= kNavNoTypePopup;
|
|
||||||
}
|
|
||||||
dialogCreateOptions.optionFlags |= kNavDontAutoTranslate;
|
dialogCreateOptions.optionFlags |= kNavDontAutoTranslate;
|
||||||
dialogCreateOptions.optionFlags |= kNavDontAddTranslateItems;
|
dialogCreateOptions.optionFlags |= kNavDontAddTranslateItems;
|
||||||
|
if (!numFilters)
|
||||||
|
dialogCreateOptions.optionFlags |= kNavNoTypePopup;
|
||||||
|
|
||||||
// The extension is important
|
// The extension is important
|
||||||
if (numFilters < 2)
|
if (numFilters < 2)
|
||||||
@@ -354,25 +349,25 @@ int wxFileDialog::ShowModal()
|
|||||||
|
|
||||||
#if TARGET_API_MAC_OSX
|
#if TARGET_API_MAC_OSX
|
||||||
if (!(m_dialogStyle & wxOVERWRITE_PROMPT))
|
if (!(m_dialogStyle & wxOVERWRITE_PROMPT))
|
||||||
{
|
|
||||||
dialogCreateOptions.optionFlags |= kNavDontConfirmReplacement;
|
dialogCreateOptions.optionFlags |= kNavDontConfirmReplacement;
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
err = ::NavCreatePutFileDialog(&dialogCreateOptions,
|
|
||||||
// Suppresses the 'Default' (top) menu item
|
err = ::NavCreatePutFileDialog(
|
||||||
kNavGenericSignature, kNavGenericSignature,
|
&dialogCreateOptions,
|
||||||
|
kNavGenericSignature, // Suppresses the 'Default' (top) menu item
|
||||||
|
kNavGenericSignature,
|
||||||
sStandardNavEventFilter,
|
sStandardNavEventFilter,
|
||||||
&myData, // for defaultLocation
|
&myData, // for defaultLocation
|
||||||
&dialog );
|
&dialog );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
// let the user select bundles/programs in dialogs
|
||||||
//let people select bundles/programs in dialogs
|
|
||||||
dialogCreateOptions.optionFlags |= kNavSupportPackages;
|
dialogCreateOptions.optionFlags |= kNavSupportPackages;
|
||||||
|
|
||||||
navFilterUPP = NewNavObjectFilterUPP(CrossPlatformFilterCallback);
|
navFilterUPP = NewNavObjectFilterUPP(CrossPlatformFilterCallback);
|
||||||
err = ::NavCreateGetFileDialog(&dialogCreateOptions,
|
err = ::NavCreateGetFileDialog(
|
||||||
|
&dialogCreateOptions,
|
||||||
NULL, // NavTypeListHandle
|
NULL, // NavTypeListHandle
|
||||||
sStandardNavEventFilter,
|
sStandardNavEventFilter,
|
||||||
NULL, // NavPreviewUPP
|
NULL, // NavPreviewUPP
|
||||||
@@ -402,14 +397,14 @@ int wxFileDialog::ShowModal()
|
|||||||
Size actualSize;
|
Size actualSize;
|
||||||
FSRef theFSRef;
|
FSRef theFSRef;
|
||||||
wxString thePath ;
|
wxString thePath ;
|
||||||
|
long count;
|
||||||
|
|
||||||
m_filterIndex = myData.currentfilter;
|
m_filterIndex = myData.currentfilter;
|
||||||
|
|
||||||
long count;
|
|
||||||
::AECountItems( &navReply.selection, &count );
|
::AECountItems( &navReply.selection, &count );
|
||||||
for (long i = 1; i <= count; ++i)
|
for (long i = 1; i <= count; ++i)
|
||||||
{
|
{
|
||||||
err = ::AEGetNthPtr(&(navReply.selection), i, typeFSRef, &theKeyword, &actualType,
|
err = ::AEGetNthPtr(
|
||||||
|
&(navReply.selection), i, typeFSRef, &theKeyword, &actualType,
|
||||||
&theFSRef, sizeof(theFSRef), &actualSize );
|
&theFSRef, sizeof(theFSRef), &actualSize );
|
||||||
if (err != noErr)
|
if (err != noErr)
|
||||||
break;
|
break;
|
||||||
@@ -424,16 +419,19 @@ int wxFileDialog::ShowModal()
|
|||||||
::NavDisposeReply(&navReply);
|
::NavDisposeReply(&navReply);
|
||||||
return wxID_CANCEL;
|
return wxID_CANCEL;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_path = thePath;
|
m_path = thePath;
|
||||||
m_paths.Add(m_path);
|
m_paths.Add(m_path);
|
||||||
m_fileName = wxFileNameFromPath(m_path);
|
m_fileName = wxFileNameFromPath(m_path);
|
||||||
m_fileNames.Add(m_fileName);
|
m_fileNames.Add(m_fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
// set these to the first hit
|
// set these to the first hit
|
||||||
m_path = m_paths[0];
|
m_path = m_paths[0];
|
||||||
m_fileName = wxFileNameFromPath(m_path);
|
m_fileName = wxFileNameFromPath(m_path);
|
||||||
m_dir = wxPathOnly(m_path);
|
m_dir = wxPathOnly(m_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
::NavDisposeReply(&navReply);
|
::NavDisposeReply(&navReply);
|
||||||
|
|
||||||
return (err == noErr) ? wxID_OK : wxID_CANCEL;
|
return (err == noErr) ? wxID_OK : wxID_CANCEL;
|
||||||
|
|||||||
@@ -9,15 +9,6 @@
|
|||||||
// Licence: wxWindows licence
|
// Licence: wxWindows licence
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
// ============================================================================
|
|
||||||
// declarations
|
|
||||||
// ============================================================================
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
|
||||||
// headers
|
|
||||||
// ----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
// For compilers that support precompilation, includes "wx.h".
|
|
||||||
#include "wx/wxprec.h"
|
#include "wx/wxprec.h"
|
||||||
|
|
||||||
#ifdef __BORLANDC__
|
#ifdef __BORLANDC__
|
||||||
@@ -28,32 +19,24 @@
|
|||||||
#include "wx/string.h"
|
#include "wx/string.h"
|
||||||
#include "wx/log.h"
|
#include "wx/log.h"
|
||||||
#include "wx/intl.h"
|
#include "wx/intl.h"
|
||||||
#endif //WX_PRECOMP
|
#endif
|
||||||
|
|
||||||
#include "wx/fontutil.h"
|
#include "wx/fontutil.h"
|
||||||
#include "wx/fontmap.h"
|
#include "wx/fontmap.h"
|
||||||
#include "wx/encinfo.h"
|
#include "wx/encinfo.h"
|
||||||
|
|
||||||
#include "wx/tokenzr.h"
|
#include "wx/tokenzr.h"
|
||||||
|
|
||||||
// ============================================================================
|
|
||||||
// implementation
|
|
||||||
// ============================================================================
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
|
||||||
// wxNativeEncodingInfo
|
|
||||||
// ----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
// convert to/from the string representation: format is
|
|
||||||
// facename[;charset]
|
|
||||||
|
|
||||||
|
// convert to/from the string representation:
|
||||||
|
// format is facename[;charset]
|
||||||
|
//
|
||||||
bool wxNativeEncodingInfo::FromString( const wxString& s )
|
bool wxNativeEncodingInfo::FromString( const wxString& s )
|
||||||
{
|
{
|
||||||
wxStringTokenizer tokenizer(s, _T(";"));
|
wxStringTokenizer tokenizer(s, wxT(";"));
|
||||||
|
|
||||||
facename = tokenizer.GetNextToken();
|
facename = tokenizer.GetNextToken();
|
||||||
if ( !facename )
|
if ( !facename )
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
wxString tmp = tokenizer.GetNextToken();
|
wxString tmp = tokenizer.GetNextToken();
|
||||||
if ( !tmp )
|
if ( !tmp )
|
||||||
@@ -64,23 +47,19 @@ bool wxNativeEncodingInfo::FromString(const wxString& s)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ( wxSscanf(tmp, _T("%u"), &charset) != 1 )
|
if ( wxSscanf( tmp, wxT("%u"), &charset ) != 1 )
|
||||||
{
|
|
||||||
// should be a number!
|
// should be a number!
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxString wxNativeEncodingInfo::ToString() const
|
wxString wxNativeEncodingInfo::ToString() const
|
||||||
{
|
{
|
||||||
wxString s(facename);
|
wxString s(facename);
|
||||||
if ( charset != 0 )
|
if ( charset != 0 )
|
||||||
{
|
s << wxT(';') << charset;
|
||||||
s << _T(';') << charset;
|
|
||||||
}
|
|
||||||
|
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
@@ -89,19 +68,16 @@ wxString wxNativeEncodingInfo::ToString() const
|
|||||||
// helper functions
|
// helper functions
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
bool wxGetNativeFontEncoding(wxFontEncoding encoding,
|
bool wxGetNativeFontEncoding( wxFontEncoding encoding, wxNativeEncodingInfo *info )
|
||||||
wxNativeEncodingInfo *info)
|
|
||||||
{
|
{
|
||||||
wxCHECK_MSG( info, FALSE, _T("bad pointer in wxGetNativeFontEncoding") );
|
wxCHECK_MSG( info, false, wxT("bad pointer in wxGetNativeFontEncoding") );
|
||||||
|
|
||||||
if ( encoding == wxFONTENCODING_DEFAULT )
|
if ( encoding == wxFONTENCODING_DEFAULT )
|
||||||
{
|
|
||||||
encoding = wxFont::GetDefaultEncoding();
|
encoding = wxFont::GetDefaultEncoding();
|
||||||
}
|
|
||||||
|
|
||||||
info->encoding = encoding;
|
info->encoding = encoding;
|
||||||
|
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxTestFontEncoding( const wxNativeEncodingInfo& info )
|
bool wxTestFontEncoding( const wxNativeEncodingInfo& info )
|
||||||
@@ -109,5 +85,3 @@ bool wxTestFontEncoding(const wxNativeEncodingInfo& info)
|
|||||||
// basically we should be able to support every encoding via the OS
|
// basically we should be able to support every encoding via the OS
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user