virtual int Type() { return wxSockAddress::IPV4; }
virtual wxSockAddress *Clone() const;
-
+
bool operator==(wxIPV4address& addr);
private:
// IPV6 name formats
//
// hostname
- // 3ffe:ffff:0100:f101:0210:a4ff:fee3:9566
+ // 3ffe:ffff:0100:f101:0210:a4ff:fee3:9566
// compact (base85) Itu&-ZQ82s>J%s99FJXT
// compressed format ::1
// ipv4 mapped ::ffff:1.2.3.4
// any (0000:0000:0000:0000:0000:0000:0000:0000 (::))
virtual bool AnyAddress();
- // 3ffe:ffff:0100:f101:0210:a4ff:fee3:9566
+ // 3ffe:ffff:0100:f101:0210:a4ff:fee3:9566
virtual wxString IPAddress() const;
virtual wxString Hostname() const;
virtual bool Disconnect(void);
// Callbacks to BOTH - override at will
- // Default behaviour is to delete connection and return TRUE
- virtual bool OnDisconnect(void) { delete this; return TRUE; }
+ // Default behaviour is to delete connection and return true
+ virtual bool OnDisconnect(void) { delete this; return true; }
// To enable the compressor (NOTE: not implemented!)
void Compress(bool on);
wxTCPServer();
virtual ~wxTCPServer();
- // Returns FALSE on error (e.g. port number is already in use)
+ // Returns false on error (e.g. port number is already in use)
virtual bool Create(const wxString& serverName);
// Callbacks to SERVER - override at will
// ScopeGuardImplBase but gcc 2.8 which is still used for OS/2 doesn't
// support member templates and so we must make it global
template <typename ScopeGuardImpl>
- void OnScopeExit(ScopeGuardImpl& guard)
+ void OnScopeExit(ScopeGuardImpl& guard)
{
if ( !guard.WasDismissed() )
{
{
}
} // namespace wxPrivate
-
+
// ============================================================================
// wxScopeGuard for functions and functors
// ============================================================================
protected:
~wxScopeGuardImplBase() { }
- wxScopeGuardImplBase(const wxScopeGuardImplBase& other)
+ wxScopeGuardImplBase(const wxScopeGuardImplBase& other)
: m_wasDismissed(other.m_wasDismissed)
{
other.Dismiss();
wxScopeGuardImpl0& operator=(const wxScopeGuardImpl0&);
};
-template <typename F>
+template <typename F>
inline wxScopeGuardImpl0<F> wxMakeGuard(F fun)
{
return wxScopeGuardImpl0<F>::MakeGuard(fun);
wxScopeGuardImpl1& operator=(const wxScopeGuardImpl1&);
};
-template <typename F, typename P1>
+template <typename F, typename P1>
inline wxScopeGuardImpl1<F, P1> wxMakeGuard(F fun, P1 p1)
{
return wxScopeGuardImpl1<F, P1>::MakeGuard(fun, p1);
void Execute() { (m_obj.*m_memfun)(m_p1); }
protected:
- wxObjScopeGuardImpl1(Obj& obj, MemFun memFun, P1 p1)
+ wxObjScopeGuardImpl1(Obj& obj, MemFun memFun, P1 p1)
: m_obj(obj), m_memfun(memFun), m_p1(p1) { }
Obj& m_obj;
void Execute() { (m_obj.*m_memfun)(m_p1, m_p2); }
protected:
- wxObjScopeGuardImpl2(Obj& obj, MemFun memFun, P1 p1, P2 p2)
+ wxObjScopeGuardImpl2(Obj& obj, MemFun memFun, P1 p1, P2 p2)
: m_obj(obj), m_memfun(memFun), m_p1(p1), m_p2(p2) { }
Obj& m_obj;
virtual void SetThumbPosition(int viewStart) = 0;
virtual void SetScrollbar(int position, int thumbSize,
int range, int pageSize,
- bool refresh = TRUE) = 0;
+ bool refresh = true) = 0;
private:
DECLARE_NO_COPY_CLASS(wxScrollBarBase)
virtual void SetScrollbars(int pixelsPerUnitX, int pixelsPerUnitY,
int noUnitsX, int noUnitsY,
int xPos = 0, int yPos = 0,
- bool noRefresh = FALSE );
+ bool noRefresh = false );
// scroll to the given (in logical coords) position
virtual void Scroll(int x, int y);
virtual void GetScrollPixelsPerUnit(int *pixelsPerUnitX,
int *pixelsPerUnitY) const;
- // Enable/disable Windows scrolling in either direction. If TRUE, wxWidgets
+ // Enable/disable Windows scrolling in either direction. If true, wxWidgets
// scrolls the canvas and only a bit of the canvas is invalidated; no
- // Clear() is necessary. If FALSE, the whole canvas is invalidated and a
+ // Clear() is necessary. If false, the whole canvas is invalidated and a
// Clear() is necessary. Disable for when the scroll increment is used to
// actually scroll a non-constant distance
virtual void EnableScrolling(bool x_scrolling, bool y_scrolling);
// stop the timer, so it will be called repeatedly and will typically
// return different values depending on the current mouse position
//
- // the base class version just returns TRUE
+ // the base class version just returns true
virtual bool SendAutoScrollEvents(wxScrollWinEvent& event) const;
// the methods to be called from the window event handlers
public:
wxScrolledWindow() { }
wxScrolledWindow(wxWindow *parent,
- wxWindowID winid = -1,
+ wxWindowID winid = wxID_ANY,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxScrolledWindowStyle,
void SetItemCount(size_t count) { m_count = count; }
// special case of SetItemCount(0)
- void Clear() { m_itemsSel.Clear(); m_count = 0; m_defaultState = FALSE; }
+ void Clear() { m_itemsSel.Clear(); m_count = 0; m_defaultState = false; }
// must be called when a new item is inserted/added
void OnItemAdd(size_t WXUNUSED(item)) { wxFAIL_MSG( _T("TODO") ); }
// select one item, use SelectRange() insted if possible!
//
// returns true if the items selection really changed
- bool SelectItem(size_t item, bool select = TRUE);
+ bool SelectItem(size_t item, bool select = true);
// select the range of items
//
// (meaning that too many items changed state to bother counting them
// individually)
bool SelectRange(size_t itemFrom, size_t itemTo,
- bool select = TRUE,
+ bool select = true,
wxArrayInt *itemsChanged = NULL);
// return true if the given item is selected
private:
// (re)init
- void Init() { m_defaultState = FALSE; }
+ void Init() { m_defaultState = false; }
// the total number of items we handle
size_t m_count;
- // the default state: normally, FALSE (i.e. off) but maybe set to TRUE if
+ // the default state: normally, false (i.e. off) but maybe set to true if
// there are more selected items than non selected ones - this allows to
// handle selection of all items efficiently
bool m_defaultState;
// path is optional and is ignored under Win32 and used as the directory to
// create the lock file in under Unix (default is wxGetHomeDir())
//
- // returns FALSE if initialization failed, it doesn't mean that another
+ // returns false if initialization failed, it doesn't mean that another
// instance is running - use IsAnotherRunning() to check it
bool Create(const wxString& name, const wxString& path = wxEmptyString);
wxSocketBase& Write(const void *buffer, wxUint32 nbytes);
wxSocketBase& WriteMsg(const void *buffer, wxUint32 nbytes);
- void InterruptWait() { m_interrupt = TRUE; };
+ void InterruptWait() { m_interrupt = true; };
bool Wait(long seconds = -1, long milliseconds = 0);
bool WaitForRead(long seconds = -1, long milliseconds = 0);
bool WaitForWrite(long seconds = -1, long milliseconds = 0);
// event handling
void *GetClientData() const { return m_clientData; }
void SetClientData(void *data) { m_clientData = data; }
- void SetEventHandler(wxEvtHandler& handler, int id = -1);
+ void SetEventHandler(wxEvtHandler& handler, int id = wxID_ANY);
void SetNotify(wxSocketEventFlags flags);
void Notify(bool notify);
public:
wxSocketServer(wxSockAddress& addr, wxSocketFlags flags = wxSOCKET_NONE);
- wxSocketBase* Accept(bool wait = TRUE);
- bool AcceptWith(wxSocketBase& socket, bool wait = TRUE);
+ wxSocketBase* Accept(bool wait = true);
+ bool AcceptWith(wxSocketBase& socket, bool wait = true);
bool WaitForAccept(long seconds = -1, long milliseconds = 0);
wxSocketClient(wxSocketFlags flags = wxSOCKET_NONE);
virtual ~wxSocketClient();
- virtual bool Connect(wxSockAddress& addr, bool wait = TRUE);
+ virtual bool Connect(wxSockAddress& addr, bool wait = true);
bool WaitOnConnect(long seconds = -1, long milliseconds = 0);
typedef void (wxEvtHandler::*wxSocketEventFunction)(wxSocketEvent&);
#define EVT_SOCKET(id, func) \
- DECLARE_EVENT_TABLE_ENTRY( wxEVT_SOCKET, id, -1, \
+ DECLARE_EVENT_TABLE_ENTRY( wxEVT_SOCKET, id, wxID_ANY, \
(wxObjectEventFunction) (wxEventFunction) wxStaticCastEvent( wxSocketEventFunction, & func ), \
(wxObject *) NULL ),
// Created: 2004/02/01
// RCS-ID: $Id$
// Copyright: (c) 2004, Vaclav Slavik
-// Licence: wxWindows licence
+// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_SOUND_H_BASE_
// ----------------------------------------------------------------------------
// Flags for wxSound::Play
-
+
// NB: We can't use enum because there would be ambiguity between the
// two Play() prototypes when called without explicit parameters
// if WXWIN_COMPATIBILITY_2_4.
// Plays sound from filename:
static bool Play(const wxString& filename, unsigned flags = wxSOUND_ASYNC);
-
+
protected:
virtual bool DoPlay(unsigned flags) const = 0;
};
// macros for handling spin events
#define EVT_SPIN_UP(winid, func) \
- DECLARE_EVENT_TABLE_ENTRY( wxEVT_SCROLL_LINEUP, winid, -1, (wxObjectEventFunction) (wxEventFunction) wxStaticCastEvent( wxSpinEventFunction, & func ), NULL ),
+ DECLARE_EVENT_TABLE_ENTRY( wxEVT_SCROLL_LINEUP, winid, wxID_ANY, (wxObjectEventFunction) (wxEventFunction) wxStaticCastEvent( wxSpinEventFunction, & func ), NULL ),
#define EVT_SPIN_DOWN(winid, func) \
- DECLARE_EVENT_TABLE_ENTRY( wxEVT_SCROLL_LINEDOWN, winid, -1, (wxObjectEventFunction) (wxEventFunction) wxStaticCastEvent( wxSpinEventFunction, & func ), NULL ),
+ DECLARE_EVENT_TABLE_ENTRY( wxEVT_SCROLL_LINEDOWN, winid, wxID_ANY, (wxObjectEventFunction) (wxEventFunction) wxStaticCastEvent( wxSpinEventFunction, & func ), NULL ),
#define EVT_SPIN(winid, func) \
- DECLARE_EVENT_TABLE_ENTRY( wxEVT_SCROLL_THUMBTRACK, winid, -1, (wxObjectEventFunction) (wxEventFunction) wxStaticCastEvent( wxSpinEventFunction, & func ), NULL ),
+ DECLARE_EVENT_TABLE_ENTRY( wxEVT_SCROLL_THUMBTRACK, winid, wxID_ANY, (wxObjectEventFunction) (wxEventFunction) wxStaticCastEvent( wxSpinEventFunction, & func ), NULL ),
#endif // wxUSE_SPINBTN
#endif // platform
#define EVT_SPINCTRL(id, fn) \
- DECLARE_EVENT_TABLE_ENTRY( wxEVT_COMMAND_SPINCTRL_UPDATED, id, -1, (wxObjectEventFunction) (wxEventFunction) wxStaticCastEvent( wxSpinEventFunction, & fn ), (wxObject *) NULL ),
+ DECLARE_EVENT_TABLE_ENTRY( wxEVT_COMMAND_SPINCTRL_UPDATED, id, wxID_ANY, (wxObjectEventFunction) (wxEventFunction) wxStaticCastEvent( wxSpinEventFunction, & fn ), (wxObject *) NULL ),
#endif // _WX_SPINCTRL_H_
#define WX_DECLARE_STACK(obj, cls)\
class cls : public wxVectorBase\
{\
- WX_DECLARE_VECTORBASE(obj, cls);\
+ WX_DECLARE_VECTORBASE(obj, cls);\
public:\
- void push(const obj& o)\
- {\
- bool rc = Alloc(size() + 1);\
- wxASSERT(rc);\
- Append(new obj(o));\
- };\
+ void push(const obj& o)\
+ {\
+ bool rc = Alloc(size() + 1);\
+ wxASSERT(rc);\
+ Append(new obj(o));\
+ };\
\
- void pop()\
- {\
- RemoveAt(size() - 1);\
- };\
+ void pop()\
+ {\
+ RemoveAt(size() - 1);\
+ };\
\
- obj& top()\
- {\
- return *(obj *) GetItem(size() - 1);\
- };\
- const obj& top() const\
- {\
- return *(obj *) GetItem(size() - 1);\
- };\
+ obj& top()\
+ {\
+ return *(obj *) GetItem(size() - 1);\
+ };\
+ const obj& top() const\
+ {\
+ return *(obj *) GetItem(size() - 1);\
+ };\
}
#endif // _WX_STACK_H_
public:
wxStaticBitmapBase() { }
virtual ~wxStaticBitmapBase();
-
+
// our interface
virtual void SetIcon(const wxIcon& icon) = 0;
virtual void SetBitmap(const wxBitmap& bitmap) = 0;
virtual wxBitmap GetBitmap() const = 0;
// overriden base class virtuals
- virtual bool AcceptsFocus() const { return FALSE; }
+ virtual bool AcceptsFocus() const { return false; }
protected:
virtual wxSize DoGetBestSize() const;
wxSize sizeReal(size);
if ( IsVertical() )
{
- if ( size.x == -1 )
+ if ( size.x == wxDefaultCoord )
sizeReal.x = GetDefaultSize();
}
else
{
- if ( size.y == -1 )
+ if ( size.y == wxDefaultCoord )
sizeReal.y = GetDefaultSize();
}
// field styles
// ------------
- // Set the field style. Use either wxSB_NORMAL (default) for a standard 3D
- // border around a field, wxSB_FLAT for no border around a field, so that it
+ // Set the field style. Use either wxSB_NORMAL (default) for a standard 3D
+ // border around a field, wxSB_FLAT for no border around a field, so that it
// appears flat or wxSB_POPOUT to make the field appear raised.
// Setting field styles only works on wxMSW
virtual void SetStatusStyles(int n, const int styles[]);
virtual int GetBorderY() const = 0;
// don't want status bars to accept the focus at all
- virtual bool AcceptsFocus() const { return FALSE; }
+ virtual bool AcceptsFocus() const { return false; }
protected:
// set the widths array to NULL
// width otherwise
int *m_statusWidths;
- // the styles of the fields
+ // the styles of the fields
int *m_statusStyles;
// stacks of previous values for PushStatusText/PopStatusText
// Gets elapsed milliseconds since last wxStartTimer or wxGetElapsedTime
// -- DEPRECATED: use wxStopWatch instead
-long WXDLLIMPEXP_BASE wxGetElapsedTime(bool resetTimer = TRUE);
+long WXDLLIMPEXP_BASE wxGetElapsedTime(bool resetTimer = true);
#endif // wxUSE_LONGLONG
// all the requested data or not
virtual size_t LastRead() const { return wxStreamBase::m_lastcount; }
- // returns TRUE if some data is available in the stream right now, so that
+ // returns true if some data is available in the stream right now, so that
// calling Read() wouldn't block
virtual bool CanRead() const;
// put back the specified character in the stream
//
- // returns TRUE if ok, FALSE on error
+ // returns true if ok, false on error
bool Ungetch(char c);
wxCountingOutputStream();
size_t GetSize() const;
- bool Ok() const { return TRUE; }
+ bool Ok() const { return true; }
protected:
virtual size_t OnSysWrite(const void *buffer, size_t size);
void ResetBuffer();
// NB: the buffer must always be allocated with malloc() if takeOwn is
- // TRUE as it will be deallocated by free()
- void SetBufferIO(void *start, void *end, bool takeOwnership = FALSE);
- void SetBufferIO(void *start, size_t len, bool takeOwnership = FALSE);
+ // true as it will be deallocated by free()
+ void SetBufferIO(void *start, void *end, bool takeOwnership = false);
+ void SetBufferIO(void *start, size_t len, bool takeOwnership = false);
void SetBufferIO(size_t bufsize);
void *GetBufferStart() const { return m_buffer_start; }
void *GetBufferEnd() const { return m_buffer_end; }
size_t Len() const { return length(); }
// string contains any characters?
bool IsEmpty() const { return empty(); }
- // empty string is "FALSE", so !str will return TRUE
+ // empty string is "false", so !str will return true
bool operator!() const { return IsEmpty(); }
// truncate the string to given length
wxString& Truncate(size_t uiLen);
int CmpNoCase(const wxChar *psz) const { return wxStricmp(c_str(), psz); }
// test for the string equality, either considering case or not
// (if compareWithCase then the case matters)
- bool IsSameAs(const wxChar *psz, bool compareWithCase = TRUE) const
+ bool IsSameAs(const wxChar *psz, bool compareWithCase = true) const
{ return (compareWithCase ? Cmp(psz) : CmpNoCase(psz)) == 0; }
- // comparison with a signle character: returns TRUE if equal
- bool IsSameAs(wxChar c, bool compareWithCase = TRUE) const
+ // comparison with a signle character: returns true if equal
+ bool IsSameAs(wxChar c, bool compareWithCase = true) const
{
return (length() == 1) && (compareWithCase ? GetChar(0u) == c
: wxToupper(GetChar(0u)) == wxToupper(c));
// check that the string starts with prefix and return the rest of the
// string in the provided pointer if it is not NULL, otherwise return
- // FALSE
+ // false
bool StartsWith(const wxChar *prefix, wxString *rest = NULL) const;
// get first nCount characters
// trimming/padding whitespace (either side) and truncating
// remove spaces from left or from right (default) side
- wxString& Trim(bool bFromRight = TRUE);
+ wxString& Trim(bool bFromRight = true);
// add nCount copies chPad in the beginning or at the end (default)
- wxString& Pad(size_t nCount, wxChar chPad = wxT(' '), bool bFromRight = TRUE);
+ wxString& Pad(size_t nCount, wxChar chPad = wxT(' '), bool bFromRight = true);
// searching and replacing
// searching (return starting index, or -1 if not found)
- int Find(wxChar ch, bool bFromEnd = FALSE) const; // like strchr/strrchr
+ int Find(wxChar ch, bool bFromEnd = false) const; // like strchr/strrchr
// searching (return starting index, or -1 if not found)
int Find(const wxChar *pszSub) const; // like strstr
// replace first (or all of bReplaceAll) occurences of substring with
// another string, returns the number of replacements made
size_t Replace(const wxChar *szOld,
const wxChar *szNew,
- bool bReplaceAll = TRUE);
+ bool bReplaceAll = true);
// check if the string contents matches a mask containing '*' and '?'
bool Matches(const wxChar *szMask) const;
- // conversion to numbers: all functions return TRUE only if the whole
+ // conversion to numbers: all functions return true only if the whole
// string is a number and put the value of this number into the pointer
// provided, the base is the numeric base in which the conversion should be
// done and must be comprised between 2 and 36 or be 0 in which case the
int First( const wxChar ch ) const { return Find(ch); }
int First( const wxChar* psz ) const { return Find(psz); }
int First( const wxString &str ) const { return Find(str); }
- int Last( const wxChar ch ) const { return Find(ch, TRUE); }
- bool Contains(const wxString& str) const { return Find(str) != -1; }
+ int Last( const wxChar ch ) const { return Find(ch, true); }
+ bool Contains(const wxString& str) const { return Find(str) != wxNOT_FOUND; }
// use IsEmpty()
bool IsNull() const { return IsEmpty(); }
// Created: 2001-07-10
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
-// Licence: wxWindows licence
+// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_SYSOPT_H_
if (name == wxT(""))
{
wxLogWarning( _("Trying to solve a NULL hostname: giving up") );
- return FALSE;
+ return false;
}
m_origHostname = name;
return (GAddress_INET_SetHostName(m_address, name.mb_str()) == GSOCK_NOERROR);
}
wxString wxIPV4address::IPAddress() const
-{
- unsigned long raw = GAddress_INET_GetHostAddress(m_address);
- return wxString::Format(
- _T("%u.%u.%u.%u"),
- (unsigned char)((raw>>24) & 0xff),
- (unsigned char)((raw>>16) & 0xff),
- (unsigned char)((raw>>8) & 0xff),
- (unsigned char)(raw & 0xff)
- );
+{
+ unsigned long raw = GAddress_INET_GetHostAddress(m_address);
+ return wxString::Format(
+ _T("%u.%u.%u.%u"),
+ (unsigned char)((raw>>24) & 0xff),
+ (unsigned char)((raw>>16) & 0xff),
+ (unsigned char)((raw>>8) & 0xff),
+ (unsigned char)(raw & 0xff)
+ );
}
bool wxIPV4address::operator==(wxIPV4address& addr)
{
- if(Hostname().Cmp(addr.Hostname().c_str()) == 0 && Service() == addr.Service()) return true;
- return false;
+ if(Hostname().Cmp(addr.Hostname().c_str()) == 0 && Service() == addr.Service()) return true;
+ return false;
}
#if wxUSE_IPV6
if (name == wxT(""))
{
wxLogWarning( _("Trying to solve a NULL hostname: giving up") );
- return FALSE;
+ return false;
}
return (GAddress_INET_SetHostName(m_address, name.mb_str()) == GSOCK_NOERROR);
}
bool wxIPV6address::Hostname(unsigned char[16] WXUNUSED(addr))
{
- return TRUE;
+ return true;
}
bool wxIPV6address::Service(const wxString& name)
}
wxString wxIPV6address::IPAddress() const
-{
- unsigned long raw = GAddress_INET_GetHostAddress(m_address);
- return wxString::Format(
- _T("%u.%u.%u.%u"),
- (unsigned char)((raw>>24) & 0xff),
- (unsigned char)((raw>>16) & 0xff),
- (unsigned char)((raw>>8) & 0xff),
- (unsigned char)(raw & 0xff)
- );
+{
+ unsigned long raw = GAddress_INET_GetHostAddress(m_address);
+ return wxString::Format(
+ _T("%u.%u.%u.%u"),
+ (unsigned char)((raw>>24) & 0xff),
+ (unsigned char)((raw>>16) & 0xff),
+ (unsigned char)((raw>>8) & 0xff),
+ (unsigned char)(raw & 0xff)
+ );
}
wxString wxIPV6address::Hostname() const
path[0] = 0;
GAddress_UNIX_GetPath(m_address, path, 1024);
-
+
return wxString::FromAscii(path);
}
#include "wx/protocol/file.h"
IMPLEMENT_DYNAMIC_CLASS(wxFileProto, wxProtocol)
-IMPLEMENT_PROTOCOL(wxFileProto, wxT("file"), NULL, FALSE)
+IMPLEMENT_PROTOCOL(wxFileProto, wxT("file"), NULL, false)
wxFileProto::wxFileProto()
: wxProtocol()
client->SetEventHandler(*gs_handler, _CLIENT_ONREQUEST_ID);
client->SetClientData(connection);
client->SetNotify(wxSOCKET_INPUT_FLAG | wxSOCKET_LOST_FLAG);
- client->Notify(TRUE);
+ client->Notify(true);
return connection;
}
else
wxSockAddress *addr = GetAddressFromName(serverName);
if ( !addr )
- return FALSE;
+ return false;
#ifdef __UNIX_LIKE__
mode_t umaskOld;
{
delete addr;
- return FALSE;
+ return false;
}
// also set the umask to prevent the others from reading our file
m_server->Destroy();
m_server = NULL;
- return FALSE;
+ return false;
}
m_server->SetEventHandler(*gs_handler, _SERVER_ONREQUEST_ID);
m_server->SetClientData(this);
m_server->SetNotify(wxSOCKET_CONNECTION_FLAG);
- m_server->Notify(TRUE);
+ m_server->Notify(true);
- return TRUE;
+ return true;
}
wxTCPServer::~wxTCPServer()
bool wxTCPConnection::Disconnect ()
{
if ( !GetConnected() )
- return TRUE;
+ return true;
// Send the the disconnect message to the peer.
m_codeco->Write8(IPC_DISCONNECT);
- m_sock->Notify(FALSE);
+ m_sock->Notify(false);
m_sock->Close();
- SetConnected(FALSE);
+ SetConnected(false);
- return TRUE;
+ return true;
}
bool wxTCPConnection::Execute(const wxChar *data, int size, wxIPCFormat format)
{
if (!m_sock->IsConnected())
- return FALSE;
+ return false;
// Prepare EXECUTE message
m_codeco->Write8(IPC_EXECUTE);
m_codeco->Write32(size);
m_sockstrm->Write(data, size);
- return TRUE;
+ return true;
}
wxChar *wxTCPConnection::Request (const wxString& item, int *size, wxIPCFormat format)
bool wxTCPConnection::Poke (const wxString& item, wxChar *data, int size, wxIPCFormat format)
{
if (!m_sock->IsConnected())
- return FALSE;
+ return false;
m_codeco->Write8(IPC_POKE);
m_codeco->WriteString(item);
m_codeco->Write32(size);
m_sockstrm->Write(data, size);
- return TRUE;
+ return true;
}
bool wxTCPConnection::StartAdvise (const wxString& item)
int ret;
if (!m_sock->IsConnected())
- return FALSE;
+ return false;
m_codeco->Write8(IPC_ADVISE_START);
m_codeco->WriteString(item);
ret = m_codeci->Read8();
if (ret != IPC_FAIL)
- return TRUE;
+ return true;
else
- return FALSE;
+ return false;
}
bool wxTCPConnection::StopAdvise (const wxString& item)
int msg;
if (!m_sock->IsConnected())
- return FALSE;
+ return false;
m_codeco->Write8(IPC_ADVISE_STOP);
m_codeco->WriteString(item);
msg = m_codeci->Read8();
if (msg != IPC_FAIL)
- return TRUE;
+ return true;
else
- return FALSE;
+ return false;
}
// Calls that SERVER can make
wxChar *data, int size, wxIPCFormat format)
{
if (!m_sock->IsConnected())
- return FALSE;
+ return false;
m_codeco->Write8(IPC_ADVISE);
m_codeco->WriteString(item);
m_codeco->Write32(size);
m_sockstrm->Write(data, size);
- return TRUE;
+ return true;
}
// --------------------------------------------------------------------------
// We lost the connection: destroy everything
if (evt == wxSOCKET_LOST)
{
- sock->Notify(FALSE);
+ sock->Notify(false);
sock->Close();
connection->OnDisconnect();
return;
}
case IPC_DISCONNECT:
{
- sock->Notify(FALSE);
+ sock->Notify(false);
sock->Close();
- connection->SetConnected(FALSE);
+ connection->SetConnected(false);
connection->OnDisconnect();
break;
}
sock->SetEventHandler(*gs_handler, _CLIENT_ONREQUEST_ID);
sock->SetClientData(new_connection);
sock->SetNotify(wxSOCKET_INPUT_FLAG | wxSOCKET_LOST_FLAG);
- sock->Notify(TRUE);
+ sock->Notify(true);
return;
}
else
DECLARE_DYNAMIC_CLASS(wxTCPEventHandlerModule)
public:
- bool OnInit() { gs_handler = new wxTCPEventHandler(); return TRUE; }
+ bool OnInit() { gs_handler = new wxTCPEventHandler(); return true; }
void OnExit() { wxDELETE(gs_handler); }
};
int x = GetMetric( wxSYS_SCREEN_X );
ms_screen = wxSYS_SCREEN_DESKTOP;
-
+
if (x < 800)
ms_screen = wxSYS_SCREEN_SMALL;
-
+
if (x < 640)
ms_screen = wxSYS_SCREEN_PDA;
-
+
if (x < 200)
ms_screen = wxSYS_SCREEN_TINY;
-
+
// This is probably a bug, but VNC seems to report 0
if (x < 10)
ms_screen = wxSYS_SCREEN_DESKTOP;
return ms_screen;
}
-
+
void wxSystemSettings::SetScreenType( wxSystemScreenType screen )
{
ms_screen = screen;
// Limit the size if sizeMax != wxDefaultSize
- if ( size.x > sizeMax.x && sizeMax.x != -1 )
+ if ( size.x > sizeMax.x && sizeMax.x != wxDefaultCoord )
size.x = sizeMax.x;
- if ( size.y > sizeMax.y && sizeMax.y != -1 )
+ if ( size.y > sizeMax.y && sizeMax.y != wxDefaultCoord )
size.y = sizeMax.y;
return size;
// Limit the size if sizeMax != wxDefaultSize
- if ( size.x > sizeMax.x && sizeMax.x != -1 )
+ if ( size.x > sizeMax.x && sizeMax.x != wxDefaultCoord )
size.x = sizeMax.x;
- if ( size.y > sizeMax.y && sizeMax.y != -1 )
+ if ( size.y > sizeMax.y && sizeMax.y != wxDefaultCoord )
size.y = sizeMax.y;
return size;
{
m_countInit--;
- return FALSE;
+ return false;
}
}
- return TRUE;
+ return true;
}
void wxSocketBase::Shutdown()
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;
m_unrd_cur = 0;
// events
- m_id = -1;
+ m_id = wxID_ANY;
m_handler = NULL;
m_clientData = NULL;
- m_notify = FALSE;
+ m_notify = false;
m_eventmask = 0;
if ( !IsInitialized() )
// 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;
delete this;
}
- return TRUE;
+ return true;
}
// --------------------------------------------------------------------------
m_socket->Shutdown();
}
- 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);
m_error = (m_lcount == 0);
// Allow read events from now on
- m_reading = FALSE;
+ m_reading = false;
return *this;
}
int total;
// Try the pushback buffer first
- total = GetPushback(buffer, nbytes, FALSE);
+ total = GetPushback(buffer, nbytes, false);
nbytes -= total;
buffer = (char *)buffer + total;
}
else
{
- bool more = TRUE;
+ bool more = true;
while (more)
{
} 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);
}
// 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;
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);
m_error = (m_lcount == 0);
// Allow read events again
- m_reading = FALSE;
+ m_reading = false;
return *this;
}
wxSocketBase& wxSocketBase::Write(const void *buffer, wxUint32 nbytes)
{
// Mask write events
- m_writing = TRUE;
+ m_writing = true;
m_lcount = _Write(buffer, nbytes);
m_error = (m_lcount == 0);
// Allow write events again
- m_writing = FALSE;
+ m_writing = false;
return *this;
}
}
else
{
- bool more = TRUE;
+ bool more = true;
while (more)
{
} msg;
// Mask write events
- m_writing = TRUE;
+ m_writing = true;
- error = TRUE;
+ error = true;
total = 0;
SetFlags((m_flags & wxSOCKET_BLOCK) | wxSOCKET_WAITALL);
goto exit;
// everything was OK
- error = FALSE;
+ error = false;
exit:
m_error = error;
m_lcount = total;
- m_writing = FALSE;
+ m_writing = false;
return *this;
}
if (nbytes != 0)
Pushback(buffer, nbytes);
- m_error = FALSE;
+ m_error = false;
m_lcount = nbytes;
return *this;
wxUint32 total = 0;
// Mask read events
- m_reading = TRUE;
+ m_reading = true;
SetFlags(wxSOCKET_NOWAIT);
delete[] buffer;
m_lcount = total;
- m_error = FALSE;
+ m_error = false;
// Allow read events again
- m_reading = FALSE;
+ m_reading = false;
return *this;
}
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)
// we are just polling). Also, if just polling, do not yield.
wxStopWatch chrono;
- bool done = FALSE;
+ bool done = false;
while (!done)
{
// 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)
{
// 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 |
GAddress *peer;
if (!m_socket)
- return FALSE;
+ return false;
peer = m_socket->GetPeer();
// 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
GAddress *local;
if (!m_socket)
- return FALSE;
+ return false;
local = m_socket->GetLocal();
addr_man.SetAddress(local);
GAddress_destroy(local);
- return TRUE;
+ return true;
}
//
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
break;
case wxSOCKET_LOST:
- m_connected = FALSE;
- m_establishing = FALSE;
+ m_connected = false;
+ m_establishing = false;
break;
default:
// Setup the socket as server
m_socket->SetLocal(addr_man.GetAddress());
-
+
if (GetFlags() & wxSOCKET_REUSEADDR) {
m_socket->SetReusable();
}
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.
m_socket->SetNonBlocking(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;
sock.m_socket->SetTimeout(sock.m_timeout * 1000);
sock.m_socket->SetCallback(GSOCK_INPUT_FLAG | GSOCK_OUTPUT_FLAG |
GSOCK_LOST_FLAG | GSOCK_CONNECTION_FLAG,
wx_socket_callback, (char *)&sock);
- return TRUE;
+ return true;
}
wxSocketBase *wxSocketServer::Accept(bool wait)
if (m_socket->GetSockOpt(level, optname, optval, optlen)
!= GSOCK_NOERROR)
{
- return FALSE;
+ return false;
}
- return TRUE;
+ return true;
}
bool wxSocketBase::SetOption(int level, int optname, const void *optval,
if (m_socket->SetSockOpt(level, optname, optval, optlen)
!= GSOCK_NOERROR)
{
- return FALSE;
+ return false;
}
- return TRUE;
+ return true;
}
// ==========================================================================
}
m_socket = GSocket_new();
- m_connected = FALSE;
- m_establishing = FALSE;
+ m_connected = false;
+ m_establishing = false;
if (!m_socket)
- return FALSE;
+ return false;
m_socket->SetTimeout(m_timeout * 1000);
m_socket->SetCallback(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.
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);
}
// Initialize all stuff
- m_connected = FALSE;
- m_establishing = FALSE;
+ m_connected = false;
+ m_establishing = false;
m_socket->SetTimeout( m_timeout );
m_socket->SetCallback( GSOCK_INPUT_FLAG | GSOCK_OUTPUT_FLAG |
GSOCK_LOST_FLAG | GSOCK_CONNECTION_FLAG,
virtual bool OnInit()
{
// wxSocketBase will call GSocket_Init() itself when/if needed
- return TRUE;
+ return true;
}
virtual void OnExit()
{
wxCHECK_RET( number > 0, _T("invalid field number in SetFieldsCount") );
- bool refresh = FALSE;
+ bool refresh = false;
if ( number != m_nFields )
{
ReinitWidths();
- refresh = TRUE;
+ refresh = true;
}
//else: keep the old m_statusWidths if we had them
SetStatusWidths(number, widths);
// already done from SetStatusWidths()
- refresh = FALSE;
+ refresh = false;
}
if ( refresh )
};
#undef STOCKITEM
-
+
return wxEmptyString;
}
if (label == stock)
return true;
-
+
stock.Replace(_T("&"), wxEmptyString);
if (label == stock)
return true;
-
+
return false;
}
#define STOCKITEM(wx,gtk) \
case wx: \
return gtk;
-
+
#define STOCKITEM_MISSING(wx) \
case wx: \
return NULL;
};
#undef STOCKITEM
-
+
return NULL;
}
wxLongLong now( nowft.dwHighDateTime, nowft.dwLowDateTime ); // time in 100 nanoseconds
return ( now - then ) / 10000.0; // time from 00:00:00 Jan 1st 1970 to now in milliseconds
-
+
#elif defined(HAVE_GETTIMEOFDAY)
struct timeval tp;
if ( wxGetTimeOfDay(&tp, (struct timezone *)NULL) != -1 )
val *= tp.time;
return (val + tp.millitm);
#elif defined(__WXMAC__)
-
+
static UInt64 gMilliAtStart = 0;
Nanoseconds upTime = AbsoluteToNanoseconds( UpTime() );
#ifdef wxHAVE_WIN32_MB2WC
// from utils.cpp
-#if wxUSE_FONTMAP
+#if wxUSE_FONTMAP
extern WXDLLIMPEXP_BASE long wxCharsetToCodepage(const wxChar *charset);
extern WXDLLIMPEXP_BASE long wxEncodingToCodepage(wxFontEncoding encoding);
#endif
quality approximations such as turning "1/2" symbol (U+00BD) into
"1" for the code pages which don't have it and we, obviously, want
to avoid this at any price
-
+
the trouble is that this function does it _silently_, i.e. it won't
even tell us whether it did or not... Win98/2000 and higher provide
WC_NO_BEST_FIT_CHARS but it doesn't work for the older systems and
wxMBConv_mac(const wxChar* name)
{
- Init( wxMacGetSystemEncFromFontEnc(wxFontMapper::Get()->CharsetToEncoding(name, FALSE) ) ) ;
+ Init( wxMacGetSystemEncFromFontEnc(wxFontMapper::Get()->CharsetToEncoding(name, false) ) ) ;
}
wxMBConv_mac(wxFontEncoding encoding)
{
- Init( wxMacGetSystemEncFromFontEnc(encoding) );
- }
-
- ~wxMBConv_mac()
- {
- OSStatus status = noErr ;
- status = TECDisposeConverter(m_MB2WC_converter);
- status = TECDisposeConverter(m_WC2MB_converter);
- }
-
-
- void Init( TextEncodingBase encoding)
- {
- OSStatus status = noErr ;
- m_char_encoding = encoding ;
- m_unicode_encoding = CreateTextEncoding(kTextEncodingUnicodeDefault,0,kUnicode16BitFormat) ;
-
- status = TECCreateConverter(&m_MB2WC_converter,
- m_char_encoding,
- m_unicode_encoding);
- status = TECCreateConverter(&m_WC2MB_converter,
- m_unicode_encoding,
- m_char_encoding);
- }
-
+ Init( wxMacGetSystemEncFromFontEnc(encoding) );
+ }
+
+ ~wxMBConv_mac()
+ {
+ OSStatus status = noErr ;
+ status = TECDisposeConverter(m_MB2WC_converter);
+ status = TECDisposeConverter(m_WC2MB_converter);
+ }
+
+
+ void Init( TextEncodingBase encoding)
+ {
+ OSStatus status = noErr ;
+ m_char_encoding = encoding ;
+ m_unicode_encoding = CreateTextEncoding(kTextEncodingUnicodeDefault,0,kUnicode16BitFormat) ;
+
+ status = TECCreateConverter(&m_MB2WC_converter,
+ m_char_encoding,
+ m_unicode_encoding);
+ status = TECCreateConverter(&m_WC2MB_converter,
+ m_unicode_encoding,
+ m_char_encoding);
+ }
+
size_t MB2WC(wchar_t *buf, const char *psz, size_t n) const
{
- OSStatus status = noErr ;
- ByteCount byteOutLen ;
- ByteCount byteInLen = strlen(psz) ;
- wchar_t *tbuf = NULL ;
- UniChar* ubuf = NULL ;
- size_t res = 0 ;
-
- if (buf == NULL)
- {
- n = byteInLen ;
- tbuf = (wchar_t*) malloc( n * SIZEOF_WCHAR_T) ;
- }
- ByteCount byteBufferLen = n * sizeof( UniChar ) ;
+ OSStatus status = noErr ;
+ ByteCount byteOutLen ;
+ ByteCount byteInLen = strlen(psz) ;
+ wchar_t *tbuf = NULL ;
+ UniChar* ubuf = NULL ;
+ size_t res = 0 ;
+
+ if (buf == NULL)
+ {
+ n = byteInLen ;
+ tbuf = (wchar_t*) malloc( n * SIZEOF_WCHAR_T) ;
+ }
+ ByteCount byteBufferLen = n * sizeof( UniChar ) ;
#if SIZEOF_WCHAR_T == 4
- ubuf = (UniChar*) malloc( byteBufferLen + 2 ) ;
+ ubuf = (UniChar*) malloc( byteBufferLen + 2 ) ;
#else
- ubuf = (UniChar*) (buf ? buf : tbuf) ;
+ ubuf = (UniChar*) (buf ? buf : tbuf) ;
#endif
- status = TECConvertText(m_MB2WC_converter, (ConstTextPtr) psz , byteInLen, &byteInLen,
- (TextPtr) ubuf , byteBufferLen, &byteOutLen);
+ status = TECConvertText(m_MB2WC_converter, (ConstTextPtr) psz , byteInLen, &byteInLen,
+ (TextPtr) ubuf , byteBufferLen, &byteOutLen);
#if SIZEOF_WCHAR_T == 4
// we have to terminate here, because n might be larger for the trailing zero, and if UniChar
// is not properly terminated we get random characters at the end
ubuf[byteOutLen / sizeof( UniChar ) ] = 0 ;
- wxMBConvUTF16BE converter ;
- res = converter.MB2WC( (buf ? buf : tbuf) , (const char*)ubuf , n ) ;
- free( ubuf ) ;
+ wxMBConvUTF16BE converter ;
+ res = converter.MB2WC( (buf ? buf : tbuf) , (const char*)ubuf , n ) ;
+ free( ubuf ) ;
#else
- res = byteOutLen / sizeof( UniChar ) ;
+ res = byteOutLen / sizeof( UniChar ) ;
#endif
- if ( buf == NULL )
- free(tbuf) ;
+ if ( buf == NULL )
+ free(tbuf) ;
if ( buf && res < n)
buf[res] = 0;
- return res ;
+ return res ;
}
size_t WC2MB(char *buf, const wchar_t *psz, size_t n) const
- {
- OSStatus status = noErr ;
- ByteCount byteOutLen ;
- ByteCount byteInLen = wxWcslen(psz) * SIZEOF_WCHAR_T ;
-
- char *tbuf = NULL ;
-
- if (buf == NULL)
- {
- // worst case
- n = byteInLen * 2 ;
- tbuf = (char*) malloc( n ) ;
- }
-
- ByteCount byteBufferLen = n ;
- UniChar* ubuf = NULL ;
+ {
+ OSStatus status = noErr ;
+ ByteCount byteOutLen ;
+ ByteCount byteInLen = wxWcslen(psz) * SIZEOF_WCHAR_T ;
+
+ char *tbuf = NULL ;
+
+ if (buf == NULL)
+ {
+ // worst case
+ n = byteInLen * 2 ;
+ tbuf = (char*) malloc( n ) ;
+ }
+
+ ByteCount byteBufferLen = n ;
+ UniChar* ubuf = NULL ;
#if SIZEOF_WCHAR_T == 4
- wxMBConvUTF16BE converter ;
- size_t unicharlen = converter.WC2MB( NULL , psz , 0 ) ;
- byteInLen = unicharlen ;
- ubuf = (UniChar*) malloc( byteInLen + 2 ) ;
- converter.WC2MB( (char*) ubuf , psz, unicharlen + 2 ) ;
+ wxMBConvUTF16BE converter ;
+ size_t unicharlen = converter.WC2MB( NULL , psz , 0 ) ;
+ byteInLen = unicharlen ;
+ ubuf = (UniChar*) malloc( byteInLen + 2 ) ;
+ converter.WC2MB( (char*) ubuf , psz, unicharlen + 2 ) ;
#else
- ubuf = (UniChar*) psz ;
+ ubuf = (UniChar*) psz ;
#endif
- status = TECConvertText(m_WC2MB_converter, (ConstTextPtr) ubuf , byteInLen, &byteInLen,
- (TextPtr) (buf ? buf : tbuf) , byteBufferLen, &byteOutLen);
+ status = TECConvertText(m_WC2MB_converter, (ConstTextPtr) ubuf , byteInLen, &byteInLen,
+ (TextPtr) (buf ? buf : tbuf) , byteBufferLen, &byteOutLen);
#if SIZEOF_WCHAR_T == 4
- free( ubuf ) ;
+ free( ubuf ) ;
#endif
- if ( buf == NULL )
- free(tbuf) ;
+ if ( buf == NULL )
+ free(tbuf) ;
- size_t res = byteOutLen ;
+ size_t res = byteOutLen ;
if ( buf && res < n)
buf[res] = 0;
- return res ;
+ return res ;
}
bool IsOk() const
{ return m_MB2WC_converter != NULL && m_WC2MB_converter != NULL ; }
private:
- TECObjectRef m_MB2WC_converter ;
- TECObjectRef m_WC2MB_converter ;
-
- TextEncodingBase m_char_encoding ;
- TextEncodingBase m_unicode_encoding ;
+ TECObjectRef m_MB2WC_converter ;
+ TECObjectRef m_WC2MB_converter ;
+
+ TextEncodingBase m_char_encoding ;
+ TextEncodingBase m_unicode_encoding ;
};
#endif // defined(__WXMAC__) && defined(TARGET_CARBON)
#endif
}
#endif // wxHAVE_WIN32_MB2WC
-#if defined(__WXMAC__)
- {
- if ( m_name || ( m_encoding < wxFONTENCODING_UTF16BE ) )
- {
-
- wxMBConv_mac *conv = m_name ? new wxMBConv_mac(m_name)
- : new wxMBConv_mac(m_encoding);
- if ( conv->IsOk() )
- return conv;
-
- delete conv;
- }
+#if defined(__WXMAC__)
+ {
+ if ( m_name || ( m_encoding < wxFONTENCODING_UTF16BE ) )
+ {
+
+ wxMBConv_mac *conv = m_name ? new wxMBConv_mac(m_name)
+ : new wxMBConv_mac(m_encoding);
+ if ( conv->IsOk() )
+ return conv;
+
+ delete conv;
+ }
}
#endif
// step (2)
m_buffer_size = 0;
// if we are going to allocate the buffer, we should free it later as well
- m_destroybuf = TRUE;
+ m_destroybuf = true;
}
void wxStreamBuffer::Init()
{
InitBuffer();
- m_fixed = TRUE;
+ m_fixed = true;
}
wxStreamBuffer::wxStreamBuffer(BufMode mode)
m_stream = NULL;
m_mode = mode;
- m_flushable = FALSE;
+ m_flushable = false;
}
wxStreamBuffer::wxStreamBuffer(wxStreamBase& stream, BufMode mode)
m_stream = &stream;
m_mode = mode;
- m_flushable = TRUE;
+ m_flushable = true;
}
wxStreamBuffer::wxStreamBuffer(const wxStreamBuffer& buffer)
m_flushable = buffer.m_flushable;
m_stream = buffer.m_stream;
m_mode = buffer.m_mode;
- m_destroybuf = FALSE;
+ m_destroybuf = false;
}
void wxStreamBuffer::FreeBuffer()
if ( bufsize )
{
- SetBufferIO(malloc(bufsize), bufsize, TRUE /* take ownership */);
+ SetBufferIO(malloc(bufsize), bufsize, true /* take ownership */);
}
else // no buffer size => no buffer
{
{
wxInputStream *inStream = GetInputStream();
- // It's legal to have no stream, so we don't complain about it just return FALSE
+ // It's legal to have no stream, so we don't complain about it just return false
if ( !inStream )
- return FALSE;
+ return false;
size_t count = inStream->OnSysRead(m_buffer_start, m_buffer_size);
if ( !count )
- return FALSE;
+ return false;
m_buffer_end = m_buffer_start + count;
m_buffer_pos = m_buffer_start;
- return TRUE;
+ return true;
}
// write the buffer contents to the stream (only for write buffers)
bool wxStreamBuffer::FlushBuffer()
{
- wxCHECK_MSG( m_flushable, FALSE, _T("can't flush this buffer") );
+ wxCHECK_MSG( m_flushable, false, _T("can't flush this buffer") );
// FIXME: what is this check for? (VZ)
if ( m_buffer_pos == m_buffer_start )
- return FALSE;
+ return false;
wxOutputStream *outStream = GetOutputStream();
- wxCHECK_MSG( outStream, FALSE, _T("should have a stream in wxStreamBuffer") );
+ wxCHECK_MSG( outStream, false, _T("should have a stream in wxStreamBuffer") );
size_t current = m_buffer_pos - m_buffer_start;
size_t count = outStream->OnSysWrite(m_buffer_start, current);
if ( count != current )
- return FALSE;
+ return false;
m_buffer_pos = m_buffer_start;
- return TRUE;
+ return true;
}
size_t wxStreamBuffer::GetDataLeft()
if (!ptrback)
return 0;
- // Eof() shouldn't return TRUE any longer
+ // Eof() shouldn't return true any longer
if ( m_lasterror == wxSTREAM_EOF )
m_lasterror = wxSTREAM_NO_ERROR;
if ( pData == NULL ) {
// allocation failures are handled by the caller
- return FALSE;
+ return false;
}
pData->nRefs = 1;
pData->nAllocLength = nLen + EXTRA_ALLOC;
m_pchData = pData->data(); // data starts after wxStringData
m_pchData[nLen] = wxT('\0');
- return TRUE;
+ return true;
}
// must be called before changing this string
size_t nLen = pData->nDataLength;
if ( !AllocBuffer(nLen) ) {
// allocation failures are handled by the caller
- return FALSE;
+ return false;
}
memcpy(m_pchData, pData->data(), nLen*sizeof(wxChar));
}
wxASSERT( !GetStringData()->IsShared() ); // we must be the only owner
- return TRUE;
+ return true;
}
// must be called before replacing contents of this string
pData->Unlock();
if ( !AllocBuffer(nLen) ) {
// allocation failures are handled by the caller
- return FALSE;
+ return false;
}
}
else {
if ( pData == NULL ) {
// allocation failures are handled by the caller
// keep previous data since reallocation failed
- return FALSE;
+ return false;
}
pData->nAllocLength = nLen;
wxASSERT( !GetStringData()->IsShared() ); // we must be the only owner
- return TRUE;
+ return true;
}
wxStringBase& wxStringBase::append(size_t n, wxChar ch)
if ( pData == NULL ) {
// allocation failure handled by caller
- return FALSE;
+ return false;
}
pData->nRefs = 1;
size_t nOldLen = pData->nDataLength;
if ( !AllocBuffer(nLen) ) {
// allocation failure handled by caller
- return FALSE;
+ return false;
}
memcpy(m_pchData, pData->data(), nOldLen*sizeof(wxChar));
}
if ( pData == NULL ) {
// allocation failure handled by caller
// keep previous data since reallocation failed
- return FALSE;
+ return false;
}
// it's not important if the pointer changed or not (the check for this
}
}
//else: we've already got enough
- return TRUE;
+ return true;
}
-
+
wxStringBase::iterator wxStringBase::begin()
{
if (length() > 0)
}
} while ( cursor-- > c_str() );
}
-
+
return npos;
}
else {
if ( !AllocBeforeWrite(nSrcLen) ) {
// allocation failure handled by caller
- return FALSE;
+ return false;
}
memcpy(m_pchData, pszSrcData, nSrcLen*sizeof(wxChar));
GetStringData()->nDataLength = nSrcLen;
m_pchData[nSrcLen] = wxT('\0');
}
- return TRUE;
+ return true;
}
// ---------------------------------------------------------------------------
wxStringData* pOldData = GetStringData();
if ( !AllocBuffer(nNewLen) ) {
// allocation failure handled by caller
- return FALSE;
+ return false;
}
memcpy(m_pchData, pOldData->data(), nLen*sizeof(wxChar));
pOldData->Unlock();
// we have to grow the buffer
if ( capacity() < nNewLen ) {
// allocation failure handled by caller
- return FALSE;
+ return false;
}
}
else {
GetStringData()->nDataLength = nNewLen; // and fix the length
}
//else: the string to append was empty
- return TRUE;
+ return true;
}
// ---------------------------------------------------------------------------
else {
if ( !dest.AllocBuffer(nCopyLen) ) {
// allocation failure handled by caller
- return FALSE;
+ return false;
}
memcpy(dest.m_pchData, m_pchData + nCopyIndex, nCopyLen*sizeof(wxChar));
}
- return TRUE;
+ return true;
}
#endif // !wxUSE_STL
inBuf = tmp;
psz = inBuf.data();
}
-
+
// first get the size of the buffer we need
size_t nLen;
if ( psz )
inBuf = tmp;
pwz = inBuf.data();
}
-
+
// first get the size of the buffer we need
size_t nLen;
if ( pwz )
}
wxASSERT( GetStringData()->nRefs == 1 );
- GetStringData()->Validate(FALSE);
+ GetStringData()->Validate(false);
return m_pchData;
}
void wxString::UngetWriteBuf()
{
GetStringData()->nDataLength = wxStrlen(m_pchData);
- GetStringData()->Validate(TRUE);
+ GetStringData()->Validate(true);
}
void wxString::UngetWriteBuf(size_t nLen)
{
GetStringData()->nDataLength = nLen;
- GetStringData()->Validate(TRUE);
+ GetStringData()->Validate(true);
}
#endif
}
// check that the string starts with prefix and return the rest of the string
-// in the provided pointer if it is not NULL, otherwise return FALSE
+// in the provided pointer if it is not NULL, otherwise return false
bool wxString::StartsWith(const wxChar *prefix, wxString *rest) const
{
wxASSERT_MSG( prefix, _T("invalid parameter in wxString::StartsWith") );
if ( *prefix++ != *p++ )
{
// no match
- return FALSE;
+ return false;
}
}
*rest = p;
}
- return TRUE;
+ return true;
}
// extract nCount last (rightmost) characters
wxString wxString::AfterLast(wxChar ch) const
{
wxString str;
- int iPos = Find(ch, TRUE);
+ int iPos = Find(ch, true);
if ( iPos == wxNOT_FOUND )
str = *this;
else
wxString wxString::BeforeLast(wxChar ch) const
{
wxString str;
- int iPos = Find(ch, TRUE);
+ int iPos = Find(ch, true);
if ( iPos != wxNOT_FOUND && iPos != 0 )
str = wxString(c_str(), iPos);
{
const wxChar *s = (const wxChar*) *this;
while(*s){
- if(!isascii(*s)) return(FALSE);
+ if(!isascii(*s)) return(false);
s++;
}
- return(TRUE);
+ return(true);
}
bool wxString::IsWord() const
{
const wxChar *s = (const wxChar*) *this;
while(*s){
- if(!wxIsalpha(*s)) return(FALSE);
+ if(!wxIsalpha(*s)) return(false);
s++;
}
- return(TRUE);
+ return(true);
}
bool wxString::IsNumber() const
if (wxStrlen(s))
if ((s[0] == '-') || (s[0] == '+')) s++;
while(*s){
- if(!wxIsdigit(*s)) return(FALSE);
+ if(!wxIsdigit(*s)) return(false);
s++;
}
- return(TRUE);
+ return(true);
}
wxString wxString::Strip(stripType w) const
{
wxString s = *this;
- if ( w & leading ) s.Trim(FALSE);
- if ( w & trailing ) s.Trim(TRUE);
+ if ( w & leading ) s.Trim(false);
+ if ( w & trailing ) s.Trim(true);
return s;
}
// trimming and padding
// ---------------------------------------------------------------------------
-// some compilers (VC++ 6.0 not to name them) return TRUE for a call to
+// some compilers (VC++ 6.0 not to name them) return true for a call to
// isspace('ê') in the C locale which seems to be broken to me, but we have to
// live with this by checking that the character is a 7 bit one - even if this
// may fail to detect some spaces (I don't know if Unicode doesn't have
bool wxString::ToLong(long *val, int base) const
{
- wxCHECK_MSG( val, FALSE, _T("NULL pointer in wxString::ToLong") );
+ wxCHECK_MSG( val, false, _T("NULL pointer in wxString::ToLong") );
wxASSERT_MSG( !base || (base > 1 && base <= 36), _T("invalid base") );
const wxChar *start = c_str();
wxChar *end;
*val = wxStrtol(start, &end, base);
- // return TRUE only if scan was stopped by the terminating NUL and if the
+ // return true only if scan was stopped by the terminating NUL and if the
// string was not empty to start with
return !*end && (end != start);
}
bool wxString::ToULong(unsigned long *val, int base) const
{
- wxCHECK_MSG( val, FALSE, _T("NULL pointer in wxString::ToULong") );
+ wxCHECK_MSG( val, false, _T("NULL pointer in wxString::ToULong") );
wxASSERT_MSG( !base || (base > 1 && base <= 36), _T("invalid base") );
const wxChar *start = c_str();
wxChar *end;
*val = wxStrtoul(start, &end, base);
- // return TRUE only if scan was stopped by the terminating NUL and if the
+ // return true only if scan was stopped by the terminating NUL and if the
// string was not empty to start with
return !*end && (end != start);
}
bool wxString::ToDouble(double *val) const
{
- wxCHECK_MSG( val, FALSE, _T("NULL pointer in wxString::ToDouble") );
+ wxCHECK_MSG( val, false, _T("NULL pointer in wxString::ToDouble") );
const wxChar *start = c_str();
wxChar *end;
*val = wxStrtod(start, &end);
- // return TRUE only if scan was stopped by the terminating NUL and if the
+ // return true only if scan was stopped by the terminating NUL and if the
// string was not empty to start with
return !*end && (end != start);
}
// misc other operations
// ----------------------------------------------------------------------------
-// returns TRUE if the string matches the pattern which may contain '*' and
+// returns true if the string matches the pattern which may contain '*' and
// '?' metacharacters (as usual, '?' matches any character and '*' any number
// of them)
bool wxString::Matches(const wxChar *pszMask) const
switch ( *pszMask ) {
case wxT('?'):
if ( *pszTxt == wxT('\0') )
- return FALSE;
+ return false;
// pszTxt and pszMask will be incremented in the loop statement
// if there is nothing more, match
if ( *pszMask == wxT('\0') )
- return TRUE;
+ return true;
// are there any other metacharacters in the mask?
size_t uiLenMask;
wxString strToMatch(pszMask, uiLenMask);
const wxChar* pMatch = wxStrstr(pszTxt, strToMatch);
if ( pMatch == NULL )
- return FALSE;
+ return false;
// -1 to compensate "++" in the loop
pszTxt = pMatch + uiLenMask - 1;
default:
if ( *pszMask != *pszTxt )
- return FALSE;
+ return false;
break;
}
}
// match only if nothing left
if ( *pszTxt == wxT('\0') )
- return TRUE;
+ return true;
// if we failed to match, backtrack if we can
if ( pszLastStarInText ) {
goto match;
}
- return FALSE;
+ return false;
#endif // wxUSE_REGEX/!wxUSE_REGEX
}
++first;
}
-}
+}
// expand the array
void wxArrayString::SetCount(size_t count)
// if we don't use the compare function, this flag tells us if we sort the
// array in ascending or descending order
-static bool gs_sortAscending = TRUE;
+static bool gs_sortAscending = true;
// function which is called by quick sort
extern "C" int wxC_CALLING_CONV // LINKAGEMODE
bool wxArrayString::operator==(const wxArrayString& a) const
{
if ( m_nCount != a.m_nCount )
- return FALSE;
+ return false;
for ( size_t n = 0; n < m_nCount; n++ )
{
if ( Item(n) != a[n] )
- return FALSE;
+ return false;
}
- return TRUE;
+ return true;
}
#endif // !wxUSE_STL
// Created: 2001-07-10
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
-// Licence: wxWindows licence
+// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
// ============================================================================
bool wxSystemOptionsModule::OnInit()
{
- return TRUE;
+ return true;
}
void wxSystemOptionsModule::OnExit()
// Option functions (arbitrary name/value mapping)
void wxSystemOptions::SetOption(const wxString& name, const wxString& value)
{
- int idx = wxSystemOptionsModule::sm_optionNames.Index(name, FALSE);
+ int idx = wxSystemOptionsModule::sm_optionNames.Index(name, false);
if (idx == wxNOT_FOUND)
{
wxSystemOptionsModule::sm_optionNames.Add(name);
wxString wxSystemOptions::GetOption(const wxString& name)
{
- int idx = wxSystemOptionsModule::sm_optionNames.Index(name, FALSE);
+ int idx = wxSystemOptionsModule::sm_optionNames.Index(name, false);
if (idx == wxNOT_FOUND)
return wxEmptyString;
else
bool wxSystemOptions::HasOption(const wxString& name)
{
- return (wxSystemOptionsModule::sm_optionNames.Index(name, FALSE) != wxNOT_FOUND);
+ return (wxSystemOptionsModule::sm_optionNames.Index(name, false) != wxNOT_FOUND);
}
#endif