cleanup - reformat

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@36879 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
David Surovell
2006-01-15 07:20:59 +00:00
parent 619996567a
commit f3078f075b
8 changed files with 1109 additions and 1103 deletions

View File

@@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////////
// Name: socket.cpp
// Name: src/mac/carbon/cfsocket.cpp
// Purpose: Socket handler classes
// Authors: Guilhem Lavaux, Guillermo Rodriguez Garcia
// Created: April 1997
@@ -9,11 +9,6 @@
// License: see wxWindows licence
/////////////////////////////////////////////////////////////////////////////
// ==========================================================================
// Declarations
// ==========================================================================
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
@@ -47,11 +42,9 @@
// DLL options compatibility check:
#include "wx/build.h"
WX_CHECK_BUILD_OPTIONS("wxNet")
// --------------------------------------------------------------------------
// macros and constants
// --------------------------------------------------------------------------
// discard buffer
#define MAX_DISCARD_SIZE (10 * 1024)
@@ -81,9 +74,6 @@ WX_CHECK_BUILD_OPTIONS("wxNet")
#define wxTRACE_Socket _T("wxSocket")
// --------------------------------------------------------------------------
// wxWin macros
// --------------------------------------------------------------------------
IMPLEMENT_CLASS(wxSocketBase, wxObject)
IMPLEMENT_CLASS(wxSocketServer, wxSocketBase)
@@ -123,8 +113,7 @@ struct _GSocket
int m_establishing;
unsigned long m_timeout;
/* Callbacks */
// Callbacks
GSocketEventFlags m_detected;
GSocketCallback m_cbacks[GSOCK_MAX_EVENT];
char *m_data[GSOCK_MAX_EVENT];
@@ -184,18 +173,18 @@ bool wxSocketBase::Initialize()
{
m_countInit--;
return FALSE;
return false;
}
#endif
}
return TRUE;
return true;
}
void wxSocketBase::Shutdown()
{
// 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 0
@@ -219,10 +208,10 @@ void wxSocketBase::Init()
m_establishing =
m_reading =
m_writing =
m_error = FALSE;
m_error = false;
m_lcount = 0;
m_timeout = 600;
m_beingDeleted = FALSE;
m_beingDeleted = false;
// pushback buffer
m_unread = NULL;
@@ -233,7 +222,7 @@ void wxSocketBase::Init()
m_id = -1;
m_handler = NULL;
m_clientData = NULL;
m_notify = FALSE;
m_notify = false;
m_eventmask = 0;
if ( !IsInitialized() )
@@ -285,13 +274,13 @@ bool wxSocketBase::Destroy()
// Delayed destruction: the socket will be deleted during the next
// idle loop iteration. This ensures that all pending events have
// been processed.
m_beingDeleted = TRUE;
m_beingDeleted = true;
// Shutdown and close the socket
Close();
// Supress events from now on
Notify(FALSE);
Notify(false);
// schedule this object for deletion
wxAppTraits *traits = wxTheApp ? wxTheApp->GetTraits() : NULL;
@@ -306,7 +295,7 @@ bool wxSocketBase::Destroy()
delete this;
}
return TRUE;
return true;
}
// --------------------------------------------------------------------------
@@ -324,19 +313,18 @@ bool wxSocketBase::Close()
InterruptWait();
if (m_socket)
{
GSocket_Shutdown(m_socket);
}
m_connected = FALSE;
m_establishing = FALSE;
return TRUE;
m_connected = false;
m_establishing = false;
return true;
}
wxSocketBase& wxSocketBase::Read(void* buffer, wxUint32 nbytes)
{
// Mask read events
m_reading = TRUE;
m_reading = true;
m_lcount = _Read(buffer, nbytes);
@@ -347,7 +335,7 @@ wxSocketBase& wxSocketBase::Read(void* buffer, wxUint32 nbytes)
m_error = (m_lcount == 0);
// Allow read events from now on
m_reading = FALSE;
m_reading = false;
return *this;
}
@@ -357,7 +345,7 @@ wxUint32 wxSocketBase::_Read(void* buffer, wxUint32 nbytes)
int total = 0;
// Try the pushback buffer first
total = GetPushback(buffer, nbytes, FALSE);
total = GetPushback(buffer, nbytes, false);
nbytes -= total;
buffer = (char *)buffer + total;
@@ -389,7 +377,7 @@ wxUint32 wxSocketBase::_Read(void* buffer, wxUint32 nbytes)
}
else
{
bool more = TRUE;
bool more = true;
while (more)
{
@@ -425,13 +413,14 @@ wxSocketBase& wxSocketBase::ReadMsg(void* buffer, wxUint32 nbytes)
{
unsigned char sig[4];
unsigned char len[4];
} msg;
}
msg;
// Mask read events
m_reading = TRUE;
m_reading = true;
total = 0;
error = TRUE;
error = true;
old_flags = m_flags;
SetFlags((m_flags & wxSOCKET_BLOCK) | wxSOCKET_WAITALL);
@@ -445,7 +434,7 @@ wxSocketBase& wxSocketBase::ReadMsg(void* buffer, wxUint32 nbytes)
if (sig != 0xfeeddead)
{
wxLogWarning(_("wxSocket: invalid signature in ReadMsg."));
wxLogWarning( wxT("wxSocket: invalid signature in ReadMsg.") );
goto exit;
}
@@ -499,17 +488,17 @@ wxSocketBase& wxSocketBase::ReadMsg(void* buffer, wxUint32 nbytes)
if (sig != 0xdeadfeed)
{
wxLogWarning(_("wxSocket: invalid signature in ReadMsg."));
wxLogWarning( wxT("wxSocket: invalid signature in ReadMsg.") );
goto exit;
}
// everything was OK
error = FALSE;
error = false;
exit:
m_error = error;
m_lcount = total;
m_reading = FALSE;
m_reading = false;
SetFlags(old_flags);
return *this;
@@ -518,7 +507,7 @@ exit:
wxSocketBase& wxSocketBase::Peek(void* buffer, wxUint32 nbytes)
{
// Mask read events
m_reading = TRUE;
m_reading = true;
m_lcount = _Read(buffer, nbytes);
Pushback(buffer, m_lcount);
@@ -530,7 +519,7 @@ wxSocketBase& wxSocketBase::Peek(void* buffer, wxUint32 nbytes)
m_error = (m_lcount == 0);
// Allow read events again
m_reading = FALSE;
m_reading = false;
return *this;
}
@@ -538,7 +527,7 @@ wxSocketBase& wxSocketBase::Peek(void* buffer, wxUint32 nbytes)
wxSocketBase& wxSocketBase::Write(const void *buffer, wxUint32 nbytes)
{
// Mask write events
m_writing = TRUE;
m_writing = true;
m_lcount = _Write(buffer, nbytes);
@@ -549,7 +538,7 @@ wxSocketBase& wxSocketBase::Write(const void *buffer, wxUint32 nbytes)
m_error = (m_lcount == 0);
// Allow write events again
m_writing = FALSE;
m_writing = false;
return *this;
}
@@ -580,7 +569,7 @@ wxUint32 wxSocketBase::_Write(const void *buffer, wxUint32 nbytes)
}
else
{
bool more = TRUE;
bool more = true;
while (more)
{
@@ -615,12 +604,13 @@ wxSocketBase& wxSocketBase::WriteMsg(const void *buffer, wxUint32 nbytes)
{
unsigned char sig[4];
unsigned char len[4];
} msg;
}
msg;
// Mask write events
m_writing = TRUE;
m_writing = true;
error = TRUE;
error = true;
total = 0;
SetFlags((m_flags & wxSOCKET_BLOCK) | wxSOCKET_WAITALL);
@@ -652,12 +642,12 @@ wxSocketBase& wxSocketBase::WriteMsg(const void *buffer, wxUint32 nbytes)
goto exit;
// everything was OK
error = FALSE;
error = false;
exit:
m_error = error;
m_lcount = total;
m_writing = FALSE;
m_writing = false;
return *this;
}
@@ -667,7 +657,7 @@ wxSocketBase& wxSocketBase::Unread(const void *buffer, wxUint32 nbytes)
if (nbytes != 0)
Pushback(buffer, nbytes);
m_error = FALSE;
m_error = false;
m_lcount = nbytes;
return *this;
@@ -680,7 +670,7 @@ wxSocketBase& wxSocketBase::Discard()
wxUint32 total = 0;
// Mask read events
m_reading = TRUE;
m_reading = true;
SetFlags(wxSOCKET_NOWAIT);
@@ -693,10 +683,10 @@ wxSocketBase& wxSocketBase::Discard()
delete[] buffer;
m_lcount = total;
m_error = FALSE;
m_error = false;
// Allow read events again
m_reading = FALSE;
m_reading = false;
return *this;
}
@@ -715,16 +705,15 @@ bool wxSocketBase::_Wait(long seconds,
long milliseconds,
wxSocketEventFlags flags)
{
GSocketEventFlags result;
long timeout;
// Set this to TRUE to interrupt ongoing waits
m_interrupt = FALSE;
// Set this to true to interrupt ongoing waits
m_interrupt = false;
// Check for valid socket
if (!m_socket)
return FALSE;
return false;
// Check for valid timeout value.
if (seconds != -1)
@@ -747,7 +736,7 @@ bool wxSocketBase::_Wait(long seconds,
// we are just polling). Also, if just polling, do not yield.
wxStopWatch chrono;
bool done = FALSE;
bool done = false;
while (!done)
{
@@ -756,33 +745,35 @@ bool wxSocketBase::_Wait(long seconds,
// Incoming connection (server) or connection established (client)
if (result & GSOCK_CONNECTION_FLAG)
{
m_connected = TRUE;
m_establishing = FALSE;
return TRUE;
m_connected = true;
m_establishing = false;
return true;
}
// Data available or output buffer ready
if ((result & GSOCK_INPUT_FLAG) || (result & GSOCK_OUTPUT_FLAG))
{
return TRUE;
return true;
}
// Connection lost
if (result & GSOCK_LOST_FLAG)
{
m_connected = FALSE;
m_establishing = FALSE;
m_connected = false;
m_establishing = false;
return (flags & GSOCK_LOST_FLAG) != 0;
}
// Wait more?
if ((!timeout) || (chrono.Time() > timeout) || (m_interrupt))
done = TRUE;
done = true;
else
PROCESS_EVENTS();
}
return FALSE;
return false;
}
bool wxSocketBase::Wait(long seconds, long milliseconds)
@@ -797,15 +788,14 @@ bool wxSocketBase::WaitForRead(long seconds, long milliseconds)
{
// Check pushback buffer before entering _Wait
if (m_unread)
return TRUE;
return true;
// Note that GSOCK_INPUT_LOST has to be explicitly passed to
// _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.
return _Wait(seconds, milliseconds, GSOCK_INPUT_FLAG |
GSOCK_LOST_FLAG);
return _Wait(seconds, milliseconds, GSOCK_INPUT_FLAG | GSOCK_LOST_FLAG);
}
bool wxSocketBase::WaitForWrite(long seconds, long milliseconds)
@@ -831,19 +821,19 @@ bool wxSocketBase::GetPeer(wxSockAddress& addr_man) const
GAddress *peer;
if (!m_socket)
return FALSE;
return false;
peer = GSocket_GetPeer(m_socket);
// copying a null address would just trigger an assert anyway
if (!peer)
return FALSE;
return false;
addr_man.SetAddress(peer);
GAddress_destroy(peer);
return TRUE;
return true;
}
bool wxSocketBase::GetLocal(wxSockAddress& addr_man) const
@@ -852,13 +842,14 @@ bool wxSocketBase::GetLocal(wxSockAddress& addr_man) const
GAddress *local;
if (!m_socket)
return FALSE;
return false;
local = GSocket_GetLocal(m_socket);
addr_man.SetAddress(local);
GAddress_destroy(local);
#endif
return TRUE;
return true;
}
//
@@ -961,8 +952,8 @@ void wxSocketBase::OnRequest(wxSocketNotify notification)
switch (notification)
{
case wxSOCKET_CONNECTION:
m_establishing = FALSE;
m_connected = TRUE;
m_establishing = false;
m_connected = true;
break;
// If we are in the middle of a R/W operation, do not
@@ -980,8 +971,8 @@ void wxSocketBase::OnRequest(wxSocketNotify notification)
break;
case wxSOCKET_LOST:
m_connected = FALSE;
m_establishing = FALSE;
m_connected = false;
m_establishing = false;
break;
default:
@@ -994,12 +985,24 @@ void wxSocketBase::OnRequest(wxSocketNotify notification)
wxUnusedVar(flag);
switch (notification)
{
case GSOCK_INPUT: flag = GSOCK_INPUT_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;
case GSOCK_INPUT:
flag = GSOCK_INPUT_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:
wxLogWarning(_("wxSocket: unknown event!."));
wxLogWarning( wxT("wxSocket: unknown event!") );
return;
}
@@ -1039,7 +1042,8 @@ void wxSocketBase::SetEventHandler(wxEvtHandler& handler, int id)
void wxSocketBase::Pushback(const void *buffer, wxUint32 size)
{
if (!size) return;
if (!size)
return;
if (m_unread == NULL)
m_unread = malloc(size);
@@ -1097,13 +1101,13 @@ wxSocketServer::wxSocketServer(wxSockAddress& addr_man,
wxSocketFlags flags)
: wxSocketBase(flags, wxSOCKET_SERVER)
{
wxLogTrace( wxTRACE_Socket, _T("Opening wxSocketServer") );
wxLogTrace( wxTRACE_Socket, wxT("Opening wxSocketServer") );
m_socket = GSocket_new();
if (!m_socket)
{
wxLogTrace( wxTRACE_Socket, _T("*** GSocket_new failed") );
wxLogTrace( wxTRACE_Socket, wxT("*** GSocket_new failed") );
return;
}
@@ -1116,7 +1120,7 @@ wxSocketServer::wxSocketServer(wxSockAddress& addr_man,
GSocket_destroy(m_socket);
m_socket = NULL;
wxLogTrace( wxTRACE_Socket, _T("*** GSocket_SetServer failed") );
wxLogTrace( wxTRACE_Socket, wxT("*** GSocket_SetServer failed") );
return;
}
@@ -1136,9 +1140,9 @@ bool wxSocketServer::AcceptWith(wxSocketBase& sock, bool wait)
GSocket *child_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
// again.
@@ -1152,18 +1156,19 @@ bool wxSocketServer::AcceptWith(wxSocketBase& sock, bool wait)
GSocket_SetNonBlocking(m_socket, 0);
if (!child_socket)
return FALSE;
return false;
sock.m_type = wxSOCKET_BASE;
sock.m_socket = child_socket;
sock.m_connected = TRUE;
sock.m_connected = true;
GSocket_SetTimeout(sock.m_socket, sock.m_timeout * 1000);
GSocket_SetCallback(sock.m_socket, GSOCK_INPUT_FLAG | GSOCK_OUTPUT_FLAG |
GSOCK_LOST_FLAG | GSOCK_CONNECTION_FLAG,
wx_socket_callback, (char *)&sock);
#endif
return TRUE;
return true;
}
wxSocketBase *wxSocketServer::Accept(bool wait)
@@ -1219,18 +1224,18 @@ bool wxSocketClient::Connect(wxSockAddress& addr_man, bool wait)
}
m_socket = GSocket_new();
m_connected = FALSE;
m_establishing = FALSE;
m_connected = false;
m_establishing = false;
if (!m_socket)
return FALSE;
return false;
GSocket_SetTimeout(m_socket, m_timeout * 1000);
GSocket_SetCallback(m_socket, GSOCK_INPUT_FLAG | GSOCK_OUTPUT_FLAG |
GSOCK_LOST_FLAG | GSOCK_CONNECTION_FLAG,
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
// again.
@@ -1246,25 +1251,24 @@ bool wxSocketClient::Connect(wxSockAddress& addr_man, bool wait)
if (err != GSOCK_NOERROR)
{
if (err == GSOCK_WOULDBLOCK)
m_establishing = TRUE;
m_establishing = true;
return FALSE;
return false;
}
m_connected = TRUE;
return TRUE;
m_connected = true;
return true;
}
bool wxSocketClient::WaitOnConnect(long seconds, long milliseconds)
{
if (m_connected) // Already connected
return TRUE;
return true;
if (!m_establishing || !m_socket) // No connection in progress
return FALSE;
return false;
return _Wait(seconds, milliseconds, GSOCK_CONNECTION_FLAG |
GSOCK_LOST_FLAG);
return _Wait(seconds, milliseconds, GSOCK_CONNECTION_FLAG | GSOCK_LOST_FLAG);
}
// ==========================================================================
@@ -1294,8 +1298,8 @@ wxDatagramSocket::wxDatagramSocket( wxSockAddress& addr,
}
// Initialize all stuff
m_connected = FALSE;
m_establishing = FALSE;
m_connected = false;
m_establishing = false;
GSocket_SetTimeout( m_socket, m_timeout );
GSocket_SetCallback( m_socket, GSOCK_INPUT_FLAG | GSOCK_OUTPUT_FLAG |
GSOCK_LOST_FLAG | GSOCK_CONNECTION_FLAG,
@@ -1392,6 +1396,7 @@ GAddress *GAddress_copy(GAddress *address)
free(addr2);
return NULL;
}
memcpy(addr2->m_addr, address->m_addr, addr2->m_len);
}
@@ -1431,14 +1436,17 @@ GSocketError _GAddress_translate_from(GAddress *address,
case AF_INET:
address->m_family = GSOCK_INET;
break;
case AF_UNIX:
address->m_family = GSOCK_UNIX;
break;
#ifdef AF_INET6
case AF_INET6:
address->m_family = GSOCK_INET6;
break;
#endif
default:
{
address->m_error = GSOCK_INVOP;
@@ -1457,6 +1465,7 @@ GSocketError _GAddress_translate_from(GAddress *address,
address->m_error = GSOCK_MEMERR;
return GSOCK_MEMERR;
}
memcpy(address->m_addr, addr, len);
return GSOCK_NOERROR;
@@ -1514,12 +1523,11 @@ GSocketError GAddress_INET_SetHostName(GAddress *address, const char *hostname)
struct in_addr *addr;
assert( address != NULL );
CHECK_ADDRESS( address, INET );
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 (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 )
{
#else
/* Use gethostbyname by default */
// Use gethostbyname by default
#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)
#endif
{
#endif
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)
{
/* Reset to invalid address */
// Reset to invalid address
addr->s_addr = INADDR_NONE;
address->m_error = 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);
addr->s_addr = array_addr[0].s_addr;
}
return GSOCK_NOERROR;
}
@@ -1561,7 +1570,6 @@ GSocketError GAddress_INET_SetHostAddress(GAddress *address,
struct in_addr *addr;
assert( address != NULL );
CHECK_ADDRESS( address, INET );
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);
if (!se)
{
/* the cast to int suppresses compiler warnings about subscript having the
type char */
// the cast to int suppresses compiler warnings
// about subscript having the type char
if (isdigit((int)port[0]))
{
int port_int;
@@ -1667,6 +1675,7 @@ unsigned short GAddress_INET_GetPort(GAddress *address)
CHECK_ADDRESS_RETVAL( address, INET, 0 );
addr = (struct sockaddr_in *)address->m_addr;
return ntohs(addr->sin_port);
}
@@ -1701,7 +1710,6 @@ GSocketError GAddress_UNIX_SetPath(GAddress *address, const char *path)
struct sockaddr_un *addr;
assert( address != NULL );
CHECK_ADDRESS( address, UNIX );
addr = ((struct sockaddr_un *)address->m_addr);
@@ -1746,14 +1754,14 @@ GSocketError GSocket_SetLocal(GSocket *socket, GAddress *address)
{
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))
{
socket->m_error = GSOCK_INVSOCK;
return GSOCK_INVSOCK;
}
/* check address */
// check address
if (address == NULL || address->m_family == GSOCK_NOFAMILY)
{
socket->m_error = GSOCK_INVADDR;
@@ -1772,7 +1780,7 @@ GSocketError GSocket_SetPeer(GSocket *socket, GAddress *address)
{
assert(socket != NULL);
/* check address */
// check address
if (address == NULL || address->m_family == GSOCK_NOFAMILY)
{
socket->m_error = GSOCK_INVADDR;
@@ -1796,11 +1804,11 @@ GAddress *GSocket_GetLocal(GSocket *socket)
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)
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)
{
socket->m_error = GSOCK_INVSOCK;
@@ -1813,7 +1821,7 @@ GAddress *GSocket_GetLocal(GSocket *socket)
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();
if (address == NULL)
{
@@ -1836,17 +1844,13 @@ GAddress *GSocket_GetPeer(GSocket *socket)
{
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)
return GAddress_copy(socket->m_peer);
return NULL;
}
//
//
//
GSocket *GSocket_new(void)
{
@@ -1862,19 +1866,20 @@ GSocket *GSocket_new(void)
{
socket->m_cbacks[i] = NULL;
}
socket->m_detected = 0;
socket->m_local = NULL;
socket->m_peer = NULL;
socket->m_error = GSOCK_NOERROR;
socket->m_non_blocking = FALSE ;
socket->m_stream = TRUE;
// socket->m_oriented = TRUE;
socket->m_server = FALSE;
socket->m_establishing = FALSE;
socket->m_non_blocking = false ;
socket->m_stream = true;
// socket->m_oriented = true;
socket->m_server = false;
socket->m_establishing = false;
socket->m_timeout = 10 * 60 * 1000;
/* 10 minutes * 60 sec * 1000 millisec */
// 10 minutes * 60 sec * 1000 millisec
socket->m_cfSocket = NULL ;
socket->m_runLoopSource = NULL ;
@@ -1894,6 +1899,7 @@ void GSocket_close(GSocket *socket)
CFRelease( socket->m_readStream ) ;
socket->m_readStream = NULL ;
}
if ( socket->m_writeStream )
{
CFWriteStreamClose(socket->m_writeStream);
@@ -1912,7 +1918,7 @@ void GSocket_Shutdown(GSocket *socket)
{
GSocket_close( socket );
/* Disable GUI callbacks */
// Disable GUI callbacks
for (int evt = 0; evt < GSOCK_MAX_EVENT; evt++)
socket->m_cbacks[evt] = NULL;
@@ -1923,18 +1929,18 @@ void GSocket_destroy(GSocket *socket)
{
assert( socket != NULL );
/* Check that the socket is really shutdowned */
// Check that the socket is really shut down
if (socket->m_fd != INVALID_SOCKET)
GSocket_Shutdown(socket);
/* Destroy private addresses */
// Destroy private addresses
if (socket->m_local)
GAddress_destroy(socket->m_local);
if (socket->m_peer)
GAddress_destroy(socket->m_peer);
/* Destroy the socket itself */
// Destroy the socket itself
free(socket);
}
@@ -1954,11 +1960,11 @@ GSocketError GSocket_Connect(GSocket *socket, GSocketStream stream)
return GSOCK_INVADDR;
}
/* Streamed or dgram socket? */
// Streamed or dgram socket?
socket->m_stream = (stream == GSOCK_STREAMED);
socket->m_oriented = TRUE;
socket->m_server = FALSE;
socket->m_establishing = FALSE;
socket->m_oriented = true;
socket->m_server = false;
socket->m_establishing = false;
GSocketError returnErr = GSOCK_NOERROR ;
CFSocketError err ;
@@ -2008,10 +2014,11 @@ GSocketError GSocket_Connect(GSocket *socket, GSocketStream stream)
socket->m_error = GSOCK_TIMEDOUT ;
return GSOCK_TIMEDOUT ;
}
// we don't know whether a connect in progress will be issued like this
if ( err != kCFSocketTimeout && socket->m_non_blocking )
{
socket->m_establishing = TRUE;
socket->m_establishing = true;
socket->m_error = GSOCK_WOULDBLOCK;
return GSOCK_WOULDBLOCK;
}
@@ -2027,8 +2034,8 @@ GSocketError GSocket_Connect(GSocket *socket, GSocketStream stream)
/* Flags */
/* GSocket_SetNonBlocking:
* Sets the socket to non-blocking mode. All IO calls will return
* immediately.
* Sets the socket to non-blocking mode.
* All IO calls will return immediately.
*/
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;
}
/* GSocket_SetTimeout:
/*
* GSocket_SetTimeout:
* Sets the timeout for blocking calls. Time is expressed in
* milliseconds.
*/
@@ -2147,16 +2155,20 @@ void _GSocket_Install_Callback(GSocket *socket, GSocketEvent event)
else
c = kCFSocketConnectCallBack;
break;
case GSOCK_LOST:
case GSOCK_INPUT:
c = kCFSocketReadCallBack;
break;
case GSOCK_OUTPUT:
c = kCFSocketWriteCallBack;
break;
default:
c = 0;
}
CFSocketEnableCallBacks(socket->m_cfSocket, c);
}
@@ -2171,16 +2183,21 @@ void _GSocket_Uninstall_Callback(GSocket *socket, GSocketEvent event)
else
c = kCFSocketConnectCallBack;
break;
case GSOCK_LOST:
case GSOCK_INPUT:
c = kCFSocketReadCallBack;
break;
case GSOCK_OUTPUT:
c = kCFSocketWriteCallBack;
break;
default:
c = 0;
break;
}
CFSocketDisableCallBacks(socket->m_cfSocket, c);
}
@@ -2215,14 +2232,17 @@ void wxMacCFSocketCallback(CFSocketRef s, CFSocketCallBackType callbackType,
CALL_CALLBACK( socket , GSOCK_CONNECTION ) ;
}
break;
case kCFSocketReadCallBack:
CALL_CALLBACK( socket , GSOCK_INPUT ) ;
break;
case kCFSocketWriteCallBack:
CALL_CALLBACK( socket , GSOCK_OUTPUT ) ;
break;
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);
ret = CFWriteStreamWrite( socket->m_writeStream , (UInt8*) buffer , size ) ;
return ret;
}
GSocketEventFlags GSocket_Select(GSocket *socket, GSocketEventFlags flags)
{
assert( socket != NULL );
return flags & socket->m_detected;
}
@@ -2262,7 +2284,7 @@ public:
virtual bool OnInit()
{
// wxSocketBase will call GSocket_Init() itself when/if needed
return TRUE;
return true;
}
virtual void OnExit()

View File

@@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////////
// Name: checkbox.cpp
// Name: src/mac/carbon/checkbox.cpp
// Purpose: wxCheckBox
// Author: Stefan Csomor
// Modified by:

View File

@@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////////
// Name: cursor.cpp
// Name: src/mac/carbon/cursor.cpp
// Purpose: wxCursor class
// Author: Stefan Csomor
// Modified by:
@@ -19,14 +19,17 @@
#include "wx/mac/private.h"
IMPLEMENT_DYNAMIC_CLASS(wxCursor, wxBitmap)
class WXDLLEXPORT wxCursorRefData: public wxBitmapRefData
{
DECLARE_NO_COPY_CLASS(wxCursorRefData)
friend class WXDLLEXPORT wxBitmap;
friend class WXDLLEXPORT wxCursor;
public:
wxCursorRefData();
~wxCursorRefData();
@@ -191,6 +194,7 @@ CursHandle wxGetStockCursor( int number )
wxASSERT_MSG( number >= 0 && number <=kwxCursorLast , wxT("invalid stock cursor id") ) ;
CursHandle c = (CursHandle) NewHandle( sizeof(Cursor) ) ;
memcpy( *c, &gMacCursors[number], sizeof(Cursor) ) ;
return c ;
}
@@ -222,7 +226,6 @@ wxCursorRefData::~wxCursorRefData()
}
}
// Cursors
wxCursor::wxCursor()
{
}
@@ -252,14 +255,14 @@ wxCursor::wxCursor(char **bits)
bool wxCursor::CreateFromXpm(const char **bits)
{
#if wxUSE_IMAGE
wxCHECK_MSG( bits != NULL, FALSE, wxT("invalid cursor data") )
wxCHECK_MSG( bits != NULL, false, wxT("invalid cursor data") )
wxXPMDecoder decoder;
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 ) ;
return TRUE;
return true;
#else
return FALSE;
return false;
#endif
}
@@ -277,17 +280,20 @@ short GetCTabIndex( CTabHandle colors , RGBColor *col )
{
short retval = 0 ;
unsigned long bestdiff = 0xFFFF ;
for ( int i = 0 ; i < (**colors).ctSize ; ++i )
{
unsigned long diff = abs(col->red - (**colors).ctTable[i].rgb.red ) +
abs(col->green - (**colors).ctTable[i].rgb.green ) +
abs(col->blue - (**colors).ctTable[i].rgb.blue ) ;
if ( diff < bestdiff )
{
bestdiff = diff ;
retval = (**colors).ctTable[i].value ;
}
}
return retval ;
}
@@ -307,7 +313,7 @@ void wxCursor::CreateFromImage(const wxImage & image)
wxASSERT_MSG( hotSpotX >= 0 && hotSpotX < image_w &&
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
@@ -331,7 +337,6 @@ void wxCursor::CreateFromImage(const wxImage & image)
unsigned char * rgbBits = image16.GetData();
bool bHasMask = image16.HasMask() ;
PixMapHandle pm = (PixMapHandle) NewHandleClear( sizeof(PixMap) ) ;
short extent = 16 ;
short bytesPerPixel = 1 ;
@@ -340,11 +345,13 @@ void wxCursor::CreateFromImage(const wxImage & image)
CCrsrHandle ch = (CCrsrHandle) NewHandleClear( sizeof(CCrsr) ) ;
CTabHandle newColors = GetCTable( 8 ) ;
HandToHand( (Handle *) &newColors );
// set the values to the indices
for ( int i = 0 ; i < (**newColors).ctSize ; ++i )
{
(**newColors).ctTable[i].value = i ;
}
HLock( (Handle)ch );
(**ch).crsrType = 0x8001; // color cursors
(**ch).crsrMap = pm;
@@ -356,8 +363,8 @@ void wxCursor::CreateFromImage(const wxImage & image)
(**pm).pmVersion = 0;
(**pm).packType = 0;
(**pm).packSize = 0;
(**pm).hRes = 0x00480000; /* 72 DPI default res */
(**pm).vRes = 0x00480000; /* 72 DPI default res */
(**pm).hRes = 0x00480000; // 72 DPI default res
(**pm).vRes = 0x00480000; // 72 DPI default res
(**pm).pixelSize = depth;
(**pm).pixelType = 0;
(**pm).cmpCount = 1;
@@ -380,10 +387,10 @@ void wxCursor::CreateFromImage(const wxImage & image)
unsigned char mr = image16.GetMaskRed() ;
unsigned char mg = image16.GetMaskGreen() ;
unsigned char mb = image16.GetMaskBlue() ;
for ( int y = 0 ; y < h ; ++y )
{
short rowbits = 0 ;
short maskbits = 0 ;
short rowbits = 0, maskbits = 0 ;
for ( int x = 0 ; x < w ; ++x )
{
@@ -401,23 +408,23 @@ void wxCursor::CreateFromImage(const wxImage & image)
else
{
if ( (int)r + (int)g + (int)b < 0x0200 )
{
rowbits |= ( 1 << (15 - x) ) ;
}
maskbits |= ( 1 << (15 - x) ) ;
col = *((RGBColor*) wxColor( r , g , b ).GetPixel()) ;
}
*((*(**ch).crsrData) + y * bytesPerRow + x) =
GetCTabIndex( newColors , &col) ;
}
(**ch).crsr1Data[y] = rowbits ;
(**ch).crsrMask[y] = maskbits ;
}
if ( !bHasMask )
{
memcpy( (**ch).crsrMask , (**ch).crsr1Data , sizeof( Bits16) ) ;
}
HUnlock( (Handle)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 ;
OSType theType ;
GetResInfo( resHandle , &theId , &theType , theName ) ;
ReleaseResource( resHandle ) ;
M_CURSORDATA->m_hCursor = GetCCursor( theId ) ;
if ( M_CURSORDATA->m_hCursor )
M_CURSORDATA->m_isColorCursor = true ;
@@ -452,8 +461,10 @@ wxCursor::wxCursor(const wxString& cursor_file, long flags, int hotSpotX, int ho
{
short theId = -1 ;
OSType theType ;
GetResInfo( resHandle , &theId , &theType , theName ) ;
ReleaseResource( resHandle ) ;
M_CURSORDATA->m_hCursor = GetCursor( theId ) ;
if ( M_CURSORDATA->m_hCursor )
M_CURSORDATA->m_releaseHandle = true ;
@@ -486,105 +497,91 @@ wxCursor::wxCursor(int cursor_type)
case wxCURSOR_COPY_ARROW:
M_CURSORDATA->m_themeCursor = kThemeCopyArrowCursor;
break;
case wxCURSOR_WAIT:
M_CURSORDATA->m_themeCursor = kThemeWatchCursor;
break;
case wxCURSOR_IBEAM:
M_CURSORDATA->m_themeCursor = kThemeIBeamCursor;
break;
case wxCURSOR_CROSS:
M_CURSORDATA->m_themeCursor = kThemeCrossCursor;
break;
case wxCURSOR_SIZENWSE:
{
M_CURSORDATA->m_hCursor = wxGetStockCursor(kwxCursorSizeNWSE);
}
break;
case wxCURSOR_SIZENESW:
{
M_CURSORDATA->m_hCursor = wxGetStockCursor(kwxCursorSizeNESW);
}
break;
case wxCURSOR_SIZEWE:
{
M_CURSORDATA->m_themeCursor = kThemeResizeLeftRightCursor;
}
break;
case wxCURSOR_SIZENS:
{
M_CURSORDATA->m_hCursor = wxGetStockCursor(kwxCursorSizeNS);
}
break;
case wxCURSOR_SIZING:
{
M_CURSORDATA->m_hCursor = wxGetStockCursor(kwxCursorSize);
}
break;
case wxCURSOR_HAND:
{
M_CURSORDATA->m_themeCursor = kThemePointingHandCursor;
}
break;
case wxCURSOR_BULLSEYE:
{
M_CURSORDATA->m_hCursor = wxGetStockCursor(kwxCursorBullseye);
}
break;
case wxCURSOR_PENCIL:
{
M_CURSORDATA->m_hCursor = wxGetStockCursor(kwxCursorPencil);
}
break;
case wxCURSOR_MAGNIFIER:
{
M_CURSORDATA->m_hCursor = wxGetStockCursor(kwxCursorMagnifier);
}
break;
case wxCURSOR_NO_ENTRY:
{
M_CURSORDATA->m_hCursor = wxGetStockCursor(kwxCursorNoEntry);
}
break;
case wxCURSOR_WATCH:
{
M_CURSORDATA->m_themeCursor = kThemeWatchCursor;
break;
}
case wxCURSOR_PAINT_BRUSH:
{
M_CURSORDATA->m_hCursor = wxGetStockCursor(kwxCursorPaintBrush);
break;
}
case wxCURSOR_POINT_LEFT:
{
M_CURSORDATA->m_hCursor = wxGetStockCursor(kwxCursorPointLeft);
break;
}
case wxCURSOR_POINT_RIGHT:
{
M_CURSORDATA->m_hCursor = wxGetStockCursor(kwxCursorPointRight);
break;
}
case wxCURSOR_QUESTION_ARROW:
{
M_CURSORDATA->m_hCursor = wxGetStockCursor(kwxCursorQuestionArrow);
break;
}
case wxCURSOR_BLANK:
{
M_CURSORDATA->m_hCursor = wxGetStockCursor(kwxCursorBlank);
break;
}
case wxCURSOR_RIGHT_ARROW:
{
M_CURSORDATA->m_hCursor = wxGetStockCursor(kwxCursorRightArrow);
break;
}
case wxCURSOR_SPRAYCAN:
{
M_CURSORDATA->m_hCursor = wxGetStockCursor(kwxCursorRoller);
break;
}
case wxCURSOR_CHAR:
case wxCURSOR_ARROW:
case wxCURSOR_LEFT_BUTTON:
@@ -594,6 +591,7 @@ wxCursor::wxCursor(int cursor_type)
M_CURSORDATA->m_themeCursor = kThemeArrowCursor;
break;
}
if ( M_CURSORDATA->m_themeCursor == -1 )
M_CURSORDATA->m_releaseHandle = true;
}
@@ -627,5 +625,3 @@ void wxSetCursor(const wxCursor& cursor)
{
cursor.MacInstall() ;
}

View File

@@ -19,22 +19,17 @@
#include "wx/tokenzr.h"
#include "wx/filename.h"
#ifndef __DARWIN__
#include "PLStringFuncs.h"
#endif
IMPLEMENT_CLASS(wxFileDialog, wxFileDialogBase)
// begin wxmac
#include "wx/mac/private.h"
#ifndef __DARWIN__
#include <Navigation.h>
#include "PLStringFuncs.h"
#endif
#include "MoreFilesX.h"
IMPLEMENT_CLASS(wxFileDialog, wxFileDialogBase)
extern bool gUseNavServices;
// 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
// so we can see if the selection has changed
struct OpenUserDataRec {
struct OpenUserDataRec
{
int currentfilter ;
bool saveMode ;
wxArrayString name ;
@@ -63,14 +59,14 @@ static pascal void NavEventProc(
static NavEventUPP sStandardNavEventFilter = NewNavEventUPP(NavEventProc);
static pascal void
NavEventProc(
static pascal void NavEventProc(
NavEventCallbackMessage inSelector,
NavCBRecPtr ioParams,
NavCallBackUserData ioUserData )
{
OpenUserDataRec * data = ( OpenUserDataRec *) ioUserData ;
if (inSelector == kNavCBEvent) {
if (inSelector == kNavCBEvent)
{
}
else if ( inSelector == kNavCBStart )
{
@@ -122,7 +118,6 @@ NavEventProc(
}
}
void MakeUserDataRec(OpenUserDataRec *myData , const wxString& filter )
{
myData->menuitems = NULL ;
@@ -135,17 +130,21 @@ void MakeUserDataRec(OpenUserDataRec *myData , const wxString& filter )
int filterIndex = 0;
bool isName = true ;
wxString current ;
for ( unsigned int i = 0; i < filter2.Len() ; i++ )
{
if ( filter2.GetChar(i) == wxT('|') )
{
if( isName ) {
if ( isName )
{
myData->name.Add( current ) ;
}
else {
else
{
myData->extensions.Add( current.MakeUpper() ) ;
++filterIndex ;
}
isName = !isName ;
current = wxEmptyString ;
}
@@ -170,29 +169,24 @@ void MakeUserDataRec(OpenUserDataRec *myData , const wxString& filter )
const size_t extCount = myData->extensions.GetCount();
for ( size_t i = 0 ; i < extCount; i++ )
{
wxUint32 fileType;
wxUint32 creator;
wxUint32 fileType, creator;
wxString extension = myData->extensions[i];
// Remove leading '*'
if (extension.GetChar(0) == '*')
extension = extension.Mid(1); // Remove leading *
extension = extension.Mid( 1 );
// Remove leading '.'
if (extension.GetChar(0) == '.')
{
extension = extension.Mid(1); // Remove leading .
}
extension = extension.Mid( 1 );
if (wxFileName::MacFindDefaultTypeAndCreator( extension, &fileType, &creator ))
{
myData->filtermactypes.Add( (OSType)fileType );
}
else
{
myData->filtermactypes.Add( '****' ); // We'll fail safe if it's not recognized
}
}
}
}
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 false ;
}
return true ;
}
@@ -256,7 +252,8 @@ static pascal Boolean CrossPlatformFileFilter(CInfoPBPtr myCInfoPBPtr, void *dat
// 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,
long style, const wxPoint& pos)
: wxFileDialogBase(parent, message, defaultDir, defaultFileName, wildCard, style, pos)
@@ -268,8 +265,7 @@ pascal Boolean CrossPlatformFilterCallback (
AEDesc *theItem,
void *info,
void *callBackUD,
NavFilterModes filterMode
)
NavFilterModes filterMode )
{
bool display = true;
OpenUserDataRecPtr data = (OpenUserDataRecPtr) callBackUD ;
@@ -303,6 +299,7 @@ int wxFileDialog::ShowModal()
{
OSErr err;
NavDialogCreationOptions dialogCreateOptions;
// set default options
::NavGetDefaultDialogCreationOptions(&dialogCreateOptions);
@@ -341,12 +338,10 @@ int wxFileDialog::ShowModal()
{
myData.saveMode = true;
if (!numFilters)
{
dialogCreateOptions.optionFlags |= kNavNoTypePopup;
}
dialogCreateOptions.optionFlags |= kNavDontAutoTranslate;
dialogCreateOptions.optionFlags |= kNavDontAddTranslateItems;
if (!numFilters)
dialogCreateOptions.optionFlags |= kNavNoTypePopup;
// The extension is important
if (numFilters < 2)
@@ -354,25 +349,25 @@ int wxFileDialog::ShowModal()
#if TARGET_API_MAC_OSX
if (!(m_dialogStyle & wxOVERWRITE_PROMPT))
{
dialogCreateOptions.optionFlags |= kNavDontConfirmReplacement;
}
#endif
err = ::NavCreatePutFileDialog(&dialogCreateOptions,
// Suppresses the 'Default' (top) menu item
kNavGenericSignature, kNavGenericSignature,
err = ::NavCreatePutFileDialog(
&dialogCreateOptions,
kNavGenericSignature, // Suppresses the 'Default' (top) menu item
kNavGenericSignature,
sStandardNavEventFilter,
&myData, // for defaultLocation
&dialog );
}
else
{
//let people select bundles/programs in dialogs
// let the user select bundles/programs in dialogs
dialogCreateOptions.optionFlags |= kNavSupportPackages;
navFilterUPP = NewNavObjectFilterUPP(CrossPlatformFilterCallback);
err = ::NavCreateGetFileDialog(&dialogCreateOptions,
err = ::NavCreateGetFileDialog(
&dialogCreateOptions,
NULL, // NavTypeListHandle
sStandardNavEventFilter,
NULL, // NavPreviewUPP
@@ -402,14 +397,14 @@ int wxFileDialog::ShowModal()
Size actualSize;
FSRef theFSRef;
wxString thePath ;
long count;
m_filterIndex = myData.currentfilter;
long count;
::AECountItems( &navReply.selection, &count );
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 );
if (err != noErr)
break;
@@ -424,16 +419,19 @@ int wxFileDialog::ShowModal()
::NavDisposeReply(&navReply);
return wxID_CANCEL;
}
m_path = thePath;
m_paths.Add(m_path);
m_fileName = wxFileNameFromPath(m_path);
m_fileNames.Add(m_fileName);
}
// set these to the first hit
m_path = m_paths[0];
m_fileName = wxFileNameFromPath(m_path);
m_dir = wxPathOnly(m_path);
}
::NavDisposeReply(&navReply);
return (err == noErr) ? wxID_OK : wxID_CANCEL;

View File

@@ -9,15 +9,6 @@
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
// ============================================================================
// declarations
// ============================================================================
// ----------------------------------------------------------------------------
// headers
// ----------------------------------------------------------------------------
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
@@ -28,32 +19,24 @@
#include "wx/string.h"
#include "wx/log.h"
#include "wx/intl.h"
#endif //WX_PRECOMP
#endif
#include "wx/fontutil.h"
#include "wx/fontmap.h"
#include "wx/encinfo.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 )
{
wxStringTokenizer tokenizer(s, _T(";"));
wxStringTokenizer tokenizer(s, wxT(";"));
facename = tokenizer.GetNextToken();
if ( !facename )
return FALSE;
return false;
wxString tmp = tokenizer.GetNextToken();
if ( !tmp )
@@ -64,23 +47,19 @@ bool wxNativeEncodingInfo::FromString(const wxString& s)
}
else
{
if ( wxSscanf(tmp, _T("%u"), &charset) != 1 )
{
if ( wxSscanf( tmp, wxT("%u"), &charset ) != 1 )
// should be a number!
return FALSE;
}
return false;
}
return TRUE;
return true;
}
wxString wxNativeEncodingInfo::ToString() const
{
wxString s(facename);
if ( charset != 0 )
{
s << _T(';') << charset;
}
s << wxT(';') << charset;
return s;
}
@@ -89,19 +68,16 @@ wxString wxNativeEncodingInfo::ToString() const
// helper functions
// ----------------------------------------------------------------------------
bool wxGetNativeFontEncoding(wxFontEncoding encoding,
wxNativeEncodingInfo *info)
bool wxGetNativeFontEncoding( wxFontEncoding encoding, wxNativeEncodingInfo *info )
{
wxCHECK_MSG( info, FALSE, _T("bad pointer in wxGetNativeFontEncoding") );
wxCHECK_MSG( info, false, wxT("bad pointer in wxGetNativeFontEncoding") );
if ( encoding == wxFONTENCODING_DEFAULT )
{
encoding = wxFont::GetDefaultEncoding();
}
info->encoding = encoding;
return TRUE;
return true;
}
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
return true;
}

File diff suppressed because it is too large Load Diff