mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-31 01:59:52 -06:00
Import r67258 of the wxWidgets trunk, which I expect will before
long become wxWidgets 2.9.2, which in turn is expected to be the last 2.9 release before the 3.0 stable release. Since the full wxWidgets distribution is rather large, I have imported only the parts that we use, on a subdirectory basis: art include/wx/*.* include/wx/aui include/wx/cocoa include/wx/generic include/wx/gtk include/wx/meta include/wx/msw include/wx/osx include/wx/persist include/wx/private include/wx/protocol include/wx/unix src/aui src/common src/generic src/gtk src/msw src/osx src/unix git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@7380 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
54
Externals/wxWidgets3/include/wx/private/fd.h
vendored
Normal file
54
Externals/wxWidgets3/include/wx/private/fd.h
vendored
Normal file
@ -0,0 +1,54 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/private/fd.h
|
||||
// Purpose: private stuff for working with file descriptors
|
||||
// Author: Vadim Zeitlin
|
||||
// Created: 2008-11-23 (moved from wx/unix/private.h)
|
||||
// RCS-ID: $Id: fd.h 62790 2009-12-06 02:29:42Z VZ $
|
||||
// Copyright: (c) 2008 Vadim Zeitlin <vadim@wxwidgets.org>
|
||||
// Licence: wxWindows licence
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_PRIVATE_FD_H_
|
||||
#define _WX_PRIVATE_FD_H_
|
||||
|
||||
// standard Linux headers produce many warnings when used with icc so define
|
||||
// our own replacements for FD_XXX macros
|
||||
#if defined(__INTELC__) && defined(__LINUX__)
|
||||
inline void wxFD_ZERO(fd_set *fds)
|
||||
{
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable:593)
|
||||
FD_ZERO(fds);
|
||||
#pragma warning(pop)
|
||||
}
|
||||
|
||||
inline void wxFD_SET(int fd, fd_set *fds)
|
||||
{
|
||||
#pragma warning(push, 1)
|
||||
#pragma warning(disable:1469)
|
||||
FD_SET(fd, fds);
|
||||
#pragma warning(pop)
|
||||
}
|
||||
|
||||
inline bool wxFD_ISSET(int fd, fd_set *fds)
|
||||
{
|
||||
#pragma warning(push, 1)
|
||||
#pragma warning(disable:1469)
|
||||
return FD_ISSET(fd, fds);
|
||||
#pragma warning(pop)
|
||||
}
|
||||
inline void wxFD_CLR(int fd, fd_set *fds)
|
||||
{
|
||||
#pragma warning(push, 1)
|
||||
#pragma warning(disable:1469)
|
||||
FD_CLR(fd, fds);
|
||||
#pragma warning(pop)
|
||||
}
|
||||
#else // !__INTELC__
|
||||
#define wxFD_ZERO(fds) FD_ZERO(fds)
|
||||
#define wxFD_SET(fd, fds) FD_SET(fd, fds)
|
||||
#define wxFD_ISSET(fd, fds) FD_ISSET(fd, fds)
|
||||
#define wxFD_CLR(fd, fds) FD_CLR(fd, fds)
|
||||
#endif // __INTELC__/!__INTELC__
|
||||
|
||||
#endif // _WX_PRIVATE_FD_H_
|
119
Externals/wxWidgets3/include/wx/private/fdiodispatcher.h
vendored
Normal file
119
Externals/wxWidgets3/include/wx/private/fdiodispatcher.h
vendored
Normal file
@ -0,0 +1,119 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/private/fdiodispatcher.h
|
||||
// Purpose: classes for dispatching IO notifications for file descriptors
|
||||
// Authors: Lukasz Michalski
|
||||
// Created: December 2006
|
||||
// Copyright: (c) Lukasz Michalski
|
||||
// RCS-ID: $Id: fdiodispatcher.h 61686 2009-08-17 23:02:29Z VZ $
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_PRIVATE_FDIODISPATCHER_H_
|
||||
#define _WX_PRIVATE_FDIODISPATCHER_H_
|
||||
|
||||
#include "wx/hashmap.h"
|
||||
#include "wx/private/fdiohandler.h"
|
||||
|
||||
// those flags describes sets where descriptor should be added
|
||||
enum wxFDIODispatcherEntryFlags
|
||||
{
|
||||
wxFDIO_INPUT = 1,
|
||||
wxFDIO_OUTPUT = 2,
|
||||
wxFDIO_EXCEPTION = 4,
|
||||
wxFDIO_ALL = wxFDIO_INPUT | wxFDIO_OUTPUT | wxFDIO_EXCEPTION
|
||||
};
|
||||
|
||||
// base class for wxSelectDispatcher and wxEpollDispatcher
|
||||
class WXDLLIMPEXP_BASE wxFDIODispatcher
|
||||
{
|
||||
public:
|
||||
enum { TIMEOUT_INFINITE = -1 };
|
||||
|
||||
// return the global dispatcher to be used for IO events, can be NULL only
|
||||
// if wxSelectDispatcher wasn't compiled into the library at all as
|
||||
// creating it never fails
|
||||
//
|
||||
// don't delete the returned pointer
|
||||
static wxFDIODispatcher *Get();
|
||||
|
||||
// if we have any registered handlers, check for any pending events to them
|
||||
// and dispatch them -- this is used from wxX11 and wxDFB event loops
|
||||
// implementation
|
||||
static void DispatchPending();
|
||||
|
||||
// register handler for the given descriptor with the dispatcher, return
|
||||
// true on success or false on error
|
||||
virtual bool RegisterFD(int fd, wxFDIOHandler *handler, int flags) = 0;
|
||||
|
||||
// modify descriptor flags or handler, return true on success
|
||||
virtual bool ModifyFD(int fd, wxFDIOHandler *handler, int flags) = 0;
|
||||
|
||||
// unregister descriptor previously registered with RegisterFD()
|
||||
virtual bool UnregisterFD(int fd) = 0;
|
||||
|
||||
// check if any events are currently available without dispatching them
|
||||
virtual bool HasPending() const = 0;
|
||||
|
||||
// wait for an event for at most timeout milliseconds and process it;
|
||||
// return the number of events processed (possibly 0 if timeout expired) or
|
||||
// -1 if an error occurred
|
||||
virtual int Dispatch(int timeout = TIMEOUT_INFINITE) = 0;
|
||||
|
||||
virtual ~wxFDIODispatcher() { }
|
||||
};
|
||||
|
||||
//entry for wxFDIOHandlerMap
|
||||
struct wxFDIOHandlerEntry
|
||||
{
|
||||
wxFDIOHandlerEntry()
|
||||
{
|
||||
}
|
||||
|
||||
wxFDIOHandlerEntry(wxFDIOHandler *handler_, int flags_)
|
||||
: handler(handler_),
|
||||
flags(flags_)
|
||||
{
|
||||
}
|
||||
|
||||
wxFDIOHandler *handler;
|
||||
int flags;
|
||||
};
|
||||
|
||||
// this hash is used to map file descriptors to their handlers
|
||||
WX_DECLARE_HASH_MAP(
|
||||
int,
|
||||
wxFDIOHandlerEntry,
|
||||
wxIntegerHash,
|
||||
wxIntegerEqual,
|
||||
wxFDIOHandlerMap
|
||||
);
|
||||
|
||||
// FDIODispatcher that holds map fd <-> FDIOHandler, this should be used if
|
||||
// this map isn't maintained elsewhere already as it is usually needed anyhow
|
||||
//
|
||||
// notice that all functions for FD management have implementation
|
||||
// in the base class and should be called from the derived classes
|
||||
class WXDLLIMPEXP_BASE wxMappedFDIODispatcher : public wxFDIODispatcher
|
||||
{
|
||||
public:
|
||||
// find the handler for the given fd, return NULL if none
|
||||
wxFDIOHandler *FindHandler(int fd) const;
|
||||
|
||||
// register handler for the given descriptor with the dispatcher, return
|
||||
// true on success or false on error
|
||||
virtual bool RegisterFD(int fd, wxFDIOHandler *handler, int flags);
|
||||
|
||||
// modify descriptor flags or handler, return true on success
|
||||
virtual bool ModifyFD(int fd, wxFDIOHandler *handler, int flags);
|
||||
|
||||
// unregister descriptor previously registered with RegisterFD()
|
||||
virtual bool UnregisterFD(int fd);
|
||||
|
||||
virtual ~wxMappedFDIODispatcher() { }
|
||||
|
||||
protected:
|
||||
// the fd -> handler map containing all the registered handlers
|
||||
wxFDIOHandlerMap m_handlers;
|
||||
};
|
||||
|
||||
#endif // _WX_PRIVATE_FDIODISPATCHER_H_
|
54
Externals/wxWidgets3/include/wx/private/fdiohandler.h
vendored
Normal file
54
Externals/wxWidgets3/include/wx/private/fdiohandler.h
vendored
Normal file
@ -0,0 +1,54 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/private/fdiohandler.h
|
||||
// Purpose: declares wxFDIOHandler class
|
||||
// Author: Vadim Zeitlin
|
||||
// Created: 2009-08-17
|
||||
// RCS-ID: $Id: fdiohandler.h 64140 2010-04-25 21:33:16Z FM $
|
||||
// Copyright: (c) 2009 Vadim Zeitlin <vadim@wxwidgets.org>
|
||||
// Licence: wxWindows licence
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_PRIVATE_FDIOHANDLER_H_
|
||||
#define _WX_PRIVATE_FDIOHANDLER_H_
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxFDIOHandler: interface used to process events on file descriptors
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class wxFDIOHandler
|
||||
{
|
||||
public:
|
||||
wxFDIOHandler() { m_regmask = 0; }
|
||||
|
||||
// called when descriptor is available for non-blocking read
|
||||
virtual void OnReadWaiting() = 0;
|
||||
|
||||
// called when descriptor is available for non-blocking write
|
||||
virtual void OnWriteWaiting() = 0;
|
||||
|
||||
// called when there is exception on descriptor
|
||||
virtual void OnExceptionWaiting() = 0;
|
||||
|
||||
// called to check if the handler is still valid, only used by
|
||||
// wxSocketImplUnix currently
|
||||
virtual bool IsOk() const { return true; }
|
||||
|
||||
|
||||
// get/set the mask of events for which we're currently registered for:
|
||||
// it's a combination of wxFDIO_{INPUT,OUTPUT,EXCEPTION}
|
||||
int GetRegisteredEvents() const { return m_regmask; }
|
||||
void SetRegisteredEvent(int flag) { m_regmask |= flag; }
|
||||
void ClearRegisteredEvent(int flag) { m_regmask &= ~flag; }
|
||||
|
||||
|
||||
// virtual dtor for the base class
|
||||
virtual ~wxFDIOHandler() { }
|
||||
|
||||
private:
|
||||
int m_regmask;
|
||||
|
||||
wxDECLARE_NO_COPY_CLASS(wxFDIOHandler);
|
||||
};
|
||||
|
||||
#endif // _WX_PRIVATE_FDIOHANDLER_H_
|
||||
|
43
Externals/wxWidgets3/include/wx/private/fdiomanager.h
vendored
Normal file
43
Externals/wxWidgets3/include/wx/private/fdiomanager.h
vendored
Normal file
@ -0,0 +1,43 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/private/fdiomanager.h
|
||||
// Purpose: declaration of wxFDIOManager
|
||||
// Author: Vadim Zeitlin
|
||||
// Created: 2009-08-17
|
||||
// RCS-ID: $Id: fdiomanager.h 64140 2010-04-25 21:33:16Z FM $
|
||||
// Copyright: (c) 2009 Vadim Zeitlin <vadim@wxwidgets.org>
|
||||
// Licence: wxWindows licence
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_PRIVATE_FDIOMANAGER_H_
|
||||
#define _WX_PRIVATE_FDIOMANAGER_H_
|
||||
|
||||
#include "wx/private/fdiohandler.h"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxFDIOManager: register or unregister wxFDIOHandlers
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// currently only used in wxGTK and wxMotif, see wx/unix/apptrait.h
|
||||
|
||||
class wxFDIOManager
|
||||
{
|
||||
public:
|
||||
// identifies either input or output direction
|
||||
//
|
||||
// NB: the values of this enum shouldn't change
|
||||
enum Direction
|
||||
{
|
||||
INPUT,
|
||||
OUTPUT
|
||||
};
|
||||
|
||||
// start or stop monitoring the events on the given file descriptor
|
||||
virtual int AddInput(wxFDIOHandler *handler, int fd, Direction d) = 0;
|
||||
virtual void RemoveInput(wxFDIOHandler *handler, int fd, Direction d) = 0;
|
||||
|
||||
// empty but virtual dtor for the base class
|
||||
virtual ~wxFDIOManager() { }
|
||||
};
|
||||
|
||||
#endif // _WX_PRIVATE_FDIOMANAGER_H_
|
||||
|
83
Externals/wxWidgets3/include/wx/private/fileback.h
vendored
Normal file
83
Externals/wxWidgets3/include/wx/private/fileback.h
vendored
Normal file
@ -0,0 +1,83 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/private/fileback.h
|
||||
// Purpose: Back an input stream with memory or a file
|
||||
// Author: Mike Wetherell
|
||||
// RCS-ID: $Id: fileback.h 64943 2010-07-13 13:29:58Z VZ $
|
||||
// Copyright: (c) 2006 Mike Wetherell
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_FILEBACK_H__
|
||||
#define _WX_FILEBACK_H__
|
||||
|
||||
#include "wx/defs.h"
|
||||
|
||||
#if wxUSE_FILESYSTEM
|
||||
|
||||
#include "wx/stream.h"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Backs an input stream with memory or a file to make it seekable.
|
||||
//
|
||||
// One or more wxBackedInputStreams can be used to read it's data. The data is
|
||||
// reference counted, so stays alive until the last wxBackingFile or
|
||||
// wxBackedInputStream using it is destroyed.
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class WXDLLIMPEXP_BASE wxBackingFile
|
||||
{
|
||||
public:
|
||||
enum { DefaultBufSize = 16384 };
|
||||
|
||||
// Takes ownership of stream. If the stream is smaller than bufsize, the
|
||||
// backing file is never created and the backing is done with memory.
|
||||
wxBackingFile(wxInputStream *stream,
|
||||
size_t bufsize = DefaultBufSize,
|
||||
const wxString& prefix = wxT("wxbf"));
|
||||
|
||||
wxBackingFile() : m_impl(NULL) { }
|
||||
~wxBackingFile();
|
||||
|
||||
wxBackingFile(const wxBackingFile& backer);
|
||||
wxBackingFile& operator=(const wxBackingFile& backer);
|
||||
|
||||
operator bool() const { return m_impl != NULL; }
|
||||
|
||||
private:
|
||||
class wxBackingFileImpl *m_impl;
|
||||
friend class wxBackedInputStream;
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// An input stream to read from a wxBackingFile.
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class WXDLLIMPEXP_BASE wxBackedInputStream : public wxInputStream
|
||||
{
|
||||
public:
|
||||
wxBackedInputStream(const wxBackingFile& backer);
|
||||
|
||||
// If the length of the backer's parent stream is unknown then GetLength()
|
||||
// returns wxInvalidOffset until the parent has been read to the end.
|
||||
wxFileOffset GetLength() const;
|
||||
|
||||
// Returns the length, reading the parent stream to the end if necessary.
|
||||
wxFileOffset FindLength() const;
|
||||
|
||||
bool IsSeekable() const { return true; }
|
||||
|
||||
protected:
|
||||
size_t OnSysRead(void *buffer, size_t size);
|
||||
wxFileOffset OnSysSeek(wxFileOffset pos, wxSeekMode mode);
|
||||
wxFileOffset OnSysTell() const;
|
||||
|
||||
private:
|
||||
wxBackingFile m_backer;
|
||||
wxFileOffset m_pos;
|
||||
|
||||
wxDECLARE_NO_COPY_CLASS(wxBackedInputStream);
|
||||
};
|
||||
|
||||
#endif // wxUSE_FILESYSTEM
|
||||
|
||||
#endif // _WX_FILEBACK_H__
|
56
Externals/wxWidgets3/include/wx/private/filename.h
vendored
Normal file
56
Externals/wxWidgets3/include/wx/private/filename.h
vendored
Normal file
@ -0,0 +1,56 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/private/filename.h
|
||||
// Purpose: Internal declarations for src/common/filename.cpp
|
||||
// Author: Mike Wetherell
|
||||
// Modified by:
|
||||
// Created: 2006-10-22
|
||||
// RCS-ID: $Id: filename.h 64943 2010-07-13 13:29:58Z VZ $
|
||||
// Copyright: (c) 2006 Mike Wetherell
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_PRIVATE_FILENAME_H_
|
||||
#define _WX_PRIVATE_FILENAME_H_
|
||||
|
||||
#include "wx/file.h"
|
||||
#include "wx/ffile.h"
|
||||
|
||||
// Self deleting temp files aren't supported on all platforms. Therefore
|
||||
// rather than let these be in the API, they can be used internally to
|
||||
// implement classes (e.g. wxTempFileStream), that will do the clean up when
|
||||
// the OS doesn't support it.
|
||||
|
||||
// Same usage as wxFileName::CreateTempFileName() with the extra parameter
|
||||
// deleteOnClose. *deleteOnClose true on entry requests a file created with a
|
||||
// delete on close flag, on exit the value of *deleteOnClose indicates whether
|
||||
// available.
|
||||
|
||||
#if wxUSE_FILE
|
||||
wxString wxCreateTempFileName(const wxString& prefix,
|
||||
wxFile *fileTemp,
|
||||
bool *deleteOnClose = NULL);
|
||||
#endif
|
||||
|
||||
#if wxUSE_FFILE
|
||||
wxString wxCreateTempFileName(const wxString& prefix,
|
||||
wxFFile *fileTemp,
|
||||
bool *deleteOnClose = NULL);
|
||||
#endif
|
||||
|
||||
// Returns an open temp file, if possible either an unlinked open file or one
|
||||
// that will delete on close. Only returns the filename if neither was
|
||||
// possible, so that the caller can delete the file when done.
|
||||
|
||||
#if wxUSE_FILE
|
||||
bool wxCreateTempFile(const wxString& prefix,
|
||||
wxFile *fileTemp,
|
||||
wxString *name);
|
||||
#endif
|
||||
|
||||
#if wxUSE_FFILE
|
||||
bool wxCreateTempFile(const wxString& prefix,
|
||||
wxFFile *fileTemp,
|
||||
wxString *name);
|
||||
#endif
|
||||
|
||||
#endif // _WX_PRIVATE_FILENAME_H_
|
117
Externals/wxWidgets3/include/wx/private/flagscheck.h
vendored
Normal file
117
Externals/wxWidgets3/include/wx/private/flagscheck.h
vendored
Normal file
@ -0,0 +1,117 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/private/flagscheck.h
|
||||
// Purpose: helpers for checking that (bit)flags don't overlap
|
||||
// Author: Vaclav Slavik
|
||||
// Created: 2008-02-21
|
||||
// RCS-ID: $Id: flagscheck.h 59016 2009-02-19 05:34:25Z PC $
|
||||
// Copyright: (c) 2008 Vaclav Slavik
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_PRIVATE_FLAGSCHECK_H_
|
||||
#define _WX_PRIVATE_FLAGSCHECK_H_
|
||||
|
||||
#include "wx/debug.h"
|
||||
|
||||
// IBM xlC 8 can't parse the template syntax
|
||||
#if !defined(__IBMCPP__)
|
||||
|
||||
#include "wx/meta/if.h"
|
||||
|
||||
namespace wxPrivate
|
||||
{
|
||||
|
||||
// These templates are used to implement wxADD_FLAG macro below.
|
||||
//
|
||||
// The idea is that we want to trigger *compilation* error if the flags
|
||||
// overlap, not just runtime assert failure. We can't implement the check
|
||||
// using just a simple logical operation, we need checks equivalent to this
|
||||
// code:
|
||||
//
|
||||
// mask = wxFLAG_1;
|
||||
// assert( (mask & wxFLAG_2) == 0 ); // no overlap
|
||||
// mask |= wxFLAG_3;
|
||||
// assert( (mask & wxFLAG_3) == 0 ); // no overlap
|
||||
// mask |= wxFLAG_3;
|
||||
// ...
|
||||
//
|
||||
// This can be done at compilation time by using templates metaprogramming
|
||||
// technique that makes the compiler carry on the computation.
|
||||
//
|
||||
// NB: If any of this doesn't compile with your compiler and would be too
|
||||
// hard to make work, it's probably best to disable this code and replace
|
||||
// the macros below with empty stubs, this isn't anything critical.
|
||||
|
||||
template<int val> struct FlagsHaveConflictingValues
|
||||
{
|
||||
// no value here - triggers compilation error
|
||||
};
|
||||
|
||||
template<int val> struct FlagValue
|
||||
{
|
||||
enum { value = val };
|
||||
};
|
||||
|
||||
// This template adds its template parameter integer 'add' to another integer
|
||||
// 'all' and produces their OR-combination (all | add). The result is "stored"
|
||||
// as constant SafelyAddToMask<>::value. Combination of many flags is achieved
|
||||
// by chaining parameter lists: the 'add' parameter is value member of
|
||||
// another (different) SafelyAddToMask<> instantiation.
|
||||
template<int all, int add> struct SafelyAddToMask
|
||||
{
|
||||
// This typedefs ensures that no flags in the list conflict. If there's
|
||||
// any overlap between the already constructed part of the mask ('all')
|
||||
// and the value being added to it ('add'), the test that is wxIf<>'s
|
||||
// first parameter will be non-zero and so Added value will be
|
||||
// FlagsHaveConflictingValues<add>. The next statement will try to use
|
||||
// AddedValue::value, but there's no such thing in
|
||||
// FlagsHaveConflictingValues<> and so compilation will fail.
|
||||
typedef typename wxIf<(all & add) == 0,
|
||||
FlagValue<add>,
|
||||
FlagsHaveConflictingValues<add> >::value
|
||||
AddedValue;
|
||||
|
||||
enum { value = all | AddedValue::value };
|
||||
};
|
||||
|
||||
} // wxPrivate namespace
|
||||
|
||||
|
||||
|
||||
// This macro is used to ensure that no two flags that can be combined in
|
||||
// the same integer value have overlapping bits. This is sometimes not entirely
|
||||
// trivial to ensure, for example in wxWindow styles or flags for wxSizerItem
|
||||
// that span several enums, some of them used for multiple purposes.
|
||||
//
|
||||
// By constructing allowed flags mask using wxADD_FLAG macro and then using
|
||||
// this mask to check flags passed as arguments, you can ensure that
|
||||
//
|
||||
// a) if any of the allowed flags overlap, you will get compilation error
|
||||
// b) if invalid flag is used, there will be an assert at runtime
|
||||
//
|
||||
// Example usage:
|
||||
//
|
||||
// static const int SIZER_FLAGS_MASK =
|
||||
// wxADD_FLAG(wxCENTRE,
|
||||
// wxADD_FLAG(wxHORIZONTAL,
|
||||
// wxADD_FLAG(wxVERTICAL,
|
||||
// ...
|
||||
// 0))...);
|
||||
//
|
||||
// And wherever flags are used:
|
||||
//
|
||||
// wxASSERT_VALID_FLAG( m_flag, SIZER_FLAGS_MASK );
|
||||
|
||||
#define wxADD_FLAG(f, others) \
|
||||
::wxPrivate::SafelyAddToMask<f, others>::value
|
||||
|
||||
#else
|
||||
#define wxADD_FLAG(f, others) (f | others)
|
||||
#endif
|
||||
|
||||
// Checks if flags value 'f' is within the mask of allowed values
|
||||
#define wxASSERT_VALID_FLAGS(f, mask) \
|
||||
wxASSERT_MSG( (f & mask) == f, \
|
||||
"invalid flag: not within " #mask )
|
||||
|
||||
#endif // _WX_PRIVATE_FLAGSCHECK_H_
|
250
Externals/wxWidgets3/include/wx/private/fontmgr.h
vendored
Normal file
250
Externals/wxWidgets3/include/wx/private/fontmgr.h
vendored
Normal file
@ -0,0 +1,250 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/private/fontmgr.h
|
||||
// Purpose: font management for ports that don't have their own
|
||||
// Author: Vaclav Slavik
|
||||
// Created: 2006-11-18
|
||||
// RCS-ID: $Id: fontmgr.h 62349 2009-10-09 13:04:59Z VZ $
|
||||
// Copyright: (c) 2001-2002 SciTech Software, Inc. (www.scitechsoft.com)
|
||||
// (c) 2006 REA Elektronik GmbH
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_PRIVATE_FONTMGR_H_
|
||||
#define _WX_PRIVATE_FONTMGR_H_
|
||||
|
||||
#include "wx/list.h"
|
||||
#include "wx/fontutil.h"
|
||||
|
||||
class wxFontsManager;
|
||||
class wxFontInstance;
|
||||
class wxFontInstanceList;
|
||||
class wxFontFace;
|
||||
class wxFontBundle;
|
||||
class wxFontBundleHash;
|
||||
class wxFontMgrFontRefData;
|
||||
|
||||
WX_DECLARE_LIST(wxFontBundle, wxFontBundleList);
|
||||
|
||||
/**
|
||||
This class represents single font face with set parameters (point size,
|
||||
antialiasing).
|
||||
*/
|
||||
class wxFontInstanceBase
|
||||
{
|
||||
protected:
|
||||
wxFontInstanceBase(float ptSize, bool aa) : m_ptSize(ptSize), m_aa(aa) {}
|
||||
virtual ~wxFontInstanceBase() {}
|
||||
|
||||
public:
|
||||
float GetPointSize() const { return m_ptSize; }
|
||||
bool IsAntiAliased() const { return m_aa; }
|
||||
|
||||
protected:
|
||||
float m_ptSize;
|
||||
bool m_aa;
|
||||
};
|
||||
|
||||
|
||||
/// This class represents loaded font face (bundle+weight+italics).
|
||||
class wxFontFaceBase
|
||||
{
|
||||
protected:
|
||||
/// Ctor. Creates object with reference count = 0, Acquire() must be
|
||||
/// called after the object is created.
|
||||
wxFontFaceBase();
|
||||
virtual ~wxFontFaceBase();
|
||||
|
||||
public:
|
||||
/// Increases reference count of the face
|
||||
virtual void Acquire();
|
||||
|
||||
/**
|
||||
Decreases reference count of the face. Call this when you no longer
|
||||
use the object returned by wxFontBundle. Note that this doesn't destroy
|
||||
the object, but only optionally shuts it down, so it's possible to
|
||||
call Acquire() and Release() more than once.
|
||||
*/
|
||||
virtual void Release();
|
||||
|
||||
/**
|
||||
Returns instance of the font at given size.
|
||||
|
||||
@param ptSize point size of the font to create; note that this is
|
||||
a float and not integer, it should be wxFont's point
|
||||
size multipled by wxDC's scale factor
|
||||
@param aa should the font be antialiased?
|
||||
*/
|
||||
virtual wxFontInstance *GetFontInstance(float ptSize, bool aa);
|
||||
|
||||
protected:
|
||||
/// Called to create a new instance of the font by GetFontInstance() if
|
||||
/// it wasn't found it cache.
|
||||
virtual wxFontInstance *CreateFontInstance(float ptSize, bool aa) = 0;
|
||||
|
||||
protected:
|
||||
unsigned m_refCnt;
|
||||
wxFontInstanceList *m_instances;
|
||||
};
|
||||
|
||||
/**
|
||||
This class represents font bundle. Font bundle is set of faces that have
|
||||
the same name, but differ in weight and italics.
|
||||
*/
|
||||
class wxFontBundleBase
|
||||
{
|
||||
public:
|
||||
wxFontBundleBase();
|
||||
virtual ~wxFontBundleBase();
|
||||
|
||||
/// Returns name of the bundle
|
||||
virtual wxString GetName() const = 0;
|
||||
|
||||
/// Returns true if the font is fixe-width
|
||||
virtual bool IsFixed() const = 0;
|
||||
|
||||
/// Type of faces in the bundle
|
||||
enum FaceType
|
||||
{
|
||||
// NB: values of these constants are set so that it's possible to
|
||||
// make OR-combinations of them and still get valid enum element
|
||||
FaceType_Regular = 0,
|
||||
FaceType_Italic = 1,
|
||||
FaceType_Bold = 2,
|
||||
FaceType_BoldItalic = FaceType_Italic | FaceType_Bold,
|
||||
|
||||
FaceType_Max
|
||||
};
|
||||
|
||||
/// Returns true if the given face is available
|
||||
bool HasFace(FaceType type) const { return m_faces[type] != NULL; }
|
||||
|
||||
/**
|
||||
Returns font face object that can be used to render font of given type.
|
||||
|
||||
Note that this method can only be called if HasFace(type) returns true.
|
||||
|
||||
Acquire() was called on the returned object, you must call Release()
|
||||
when you stop using it.
|
||||
*/
|
||||
wxFontFace *GetFace(FaceType type) const;
|
||||
|
||||
/**
|
||||
Returns font face object that can be used to render given font.
|
||||
|
||||
Acquire() was called on the returned object, you must call Release()
|
||||
when you stop using it.
|
||||
*/
|
||||
wxFontFace *GetFaceForFont(const wxFontMgrFontRefData& font) const;
|
||||
|
||||
protected:
|
||||
wxFontFace *m_faces[FaceType_Max];
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
Base class for wxFontsManager class, which manages the list of all
|
||||
available fonts and their loaded instances.
|
||||
*/
|
||||
class wxFontsManagerBase
|
||||
{
|
||||
protected:
|
||||
wxFontsManagerBase();
|
||||
virtual ~wxFontsManagerBase();
|
||||
|
||||
public:
|
||||
/// Returns the font manager singleton, creating it if it doesn't exist
|
||||
static wxFontsManager *Get();
|
||||
|
||||
/// Called by wxApp to shut down the manager
|
||||
static void CleanUp();
|
||||
|
||||
/// Returns list of all available font bundles
|
||||
const wxFontBundleList& GetBundles() const { return *m_list; }
|
||||
|
||||
/**
|
||||
Returns object representing font bundle with the given name.
|
||||
|
||||
The returned object is owned by wxFontsManager, you must not delete it.
|
||||
*/
|
||||
wxFontBundle *GetBundle(const wxString& name) const;
|
||||
|
||||
/**
|
||||
Returns object representing font bundle that can be used to render
|
||||
given font.
|
||||
|
||||
The returned object is owned by wxFontsManager, you must not delete it.
|
||||
*/
|
||||
wxFontBundle *GetBundleForFont(const wxFontMgrFontRefData& font) const;
|
||||
|
||||
/// This method must be called by derived
|
||||
void AddBundle(wxFontBundle *bundle);
|
||||
|
||||
/// Returns default facename for given wxFont family
|
||||
virtual wxString GetDefaultFacename(wxFontFamily family) const = 0;
|
||||
|
||||
private:
|
||||
wxFontBundleHash *m_hash;
|
||||
wxFontBundleList *m_list;
|
||||
|
||||
protected:
|
||||
static wxFontsManager *ms_instance;
|
||||
};
|
||||
|
||||
|
||||
|
||||
#if defined(__WXMGL__)
|
||||
#include "wx/mgl/private/fontmgr.h"
|
||||
#elif defined(__WXDFB__)
|
||||
#include "wx/dfb/private/fontmgr.h"
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/// wxFontMgrFontRefData implementation using wxFontsManager classes
|
||||
class wxFontMgrFontRefData : public wxGDIRefData
|
||||
{
|
||||
public:
|
||||
wxFontMgrFontRefData(int size = wxDEFAULT,
|
||||
wxFontFamily family = wxFONTFAMILY_DEFAULT,
|
||||
wxFontStyle style = wxFONTSTYLE_NORMAL,
|
||||
wxFontWeight weight = wxFONTWEIGHT_NORMAL,
|
||||
bool underlined = false,
|
||||
const wxString& faceName = wxEmptyString,
|
||||
wxFontEncoding encoding = wxFONTENCODING_DEFAULT);
|
||||
wxFontMgrFontRefData(const wxFontMgrFontRefData& data);
|
||||
~wxFontMgrFontRefData();
|
||||
|
||||
wxFontBundle *GetFontBundle() const;
|
||||
wxFontInstance *GetFontInstance(float scale, bool antialiased) const;
|
||||
|
||||
bool IsFixedWidth() const { return GetFontBundle()->IsFixed(); }
|
||||
|
||||
const wxNativeFontInfo *GetNativeFontInfo() const { return &m_info; }
|
||||
|
||||
int GetPointSize() const { return m_info.pointSize; }
|
||||
wxString GetFaceName() const { return m_info.faceName; }
|
||||
wxFontFamily GetFamily() const { return m_info.family; }
|
||||
wxFontStyle GetStyle() const { return m_info.style; }
|
||||
wxFontWeight GetWeight() const { return m_info.weight; }
|
||||
bool GetUnderlined() const { return m_info.underlined; }
|
||||
wxFontEncoding GetEncoding() const { return m_info.encoding; }
|
||||
|
||||
void SetPointSize(int pointSize);
|
||||
void SetFamily(wxFontFamily family);
|
||||
void SetStyle(wxFontStyle style);
|
||||
void SetWeight(wxFontWeight weight);
|
||||
void SetFaceName(const wxString& faceName);
|
||||
void SetUnderlined(bool underlined);
|
||||
void SetEncoding(wxFontEncoding encoding);
|
||||
|
||||
private:
|
||||
void EnsureValidFont();
|
||||
|
||||
wxNativeFontInfo m_info;
|
||||
|
||||
wxFontFace *m_fontFace;
|
||||
wxFontBundle *m_fontBundle;
|
||||
bool m_fontValid;
|
||||
};
|
||||
|
||||
#endif // _WX_PRIVATE_FONTMGR_H_
|
92
Externals/wxWidgets3/include/wx/private/fswatcher.h
vendored
Normal file
92
Externals/wxWidgets3/include/wx/private/fswatcher.h
vendored
Normal file
@ -0,0 +1,92 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/private/fswatcher.h
|
||||
// Purpose: File system watcher impl classes
|
||||
// Author: Bartosz Bekier
|
||||
// Created: 2009-05-26
|
||||
// RCS-ID: $Id: fswatcher.h 62475 2009-10-22 11:36:35Z VZ $
|
||||
// Copyright: (c) 2009 Bartosz Bekier <bartosz.bekier@gmail.com>
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef WX_PRIVATE_FSWATCHER_H_
|
||||
#define WX_PRIVATE_FSWATCHER_H_
|
||||
|
||||
#include "wx/sharedptr.h"
|
||||
|
||||
#ifdef wxHAS_INOTIFY
|
||||
class wxFSWatchEntryUnix;
|
||||
#define wxFSWatchEntry wxFSWatchEntryUnix
|
||||
WX_DECLARE_STRING_HASH_MAP(wxSharedPtr<wxFSWatchEntry>,wxFSWatchEntries);
|
||||
#include "wx/unix/private/fswatcher_inotify.h"
|
||||
#elif defined(wxHAS_KQUEUE)
|
||||
class wxFSWatchEntryKq;
|
||||
#define wxFSWatchEntry wxFSWatchEntryKq
|
||||
WX_DECLARE_STRING_HASH_MAP(wxSharedPtr<wxFSWatchEntry>,wxFSWatchEntries);
|
||||
#include "wx/unix/private/fswatcher_kqueue.h"
|
||||
#elif defined(__WXMSW__)
|
||||
class wxFSWatchEntryMSW;
|
||||
#define wxFSWatchEntry wxFSWatchEntryMSW
|
||||
WX_DECLARE_STRING_HASH_MAP(wxSharedPtr<wxFSWatchEntry>,wxFSWatchEntries);
|
||||
#include "wx/msw/private/fswatcher.h"
|
||||
#else
|
||||
#define wxFSWatchEntry wxFSWatchEntryPolling
|
||||
#endif
|
||||
|
||||
class wxFSWatcherImpl
|
||||
{
|
||||
public:
|
||||
wxFSWatcherImpl(wxFileSystemWatcherBase* watcher) :
|
||||
m_watcher(watcher)
|
||||
{
|
||||
}
|
||||
|
||||
virtual ~wxFSWatcherImpl()
|
||||
{
|
||||
(void) RemoveAll();
|
||||
}
|
||||
|
||||
virtual bool Init() = 0;
|
||||
|
||||
virtual bool Add(const wxFSWatchInfo& winfo)
|
||||
{
|
||||
wxCHECK_MSG( m_watches.find(winfo.GetPath()) == m_watches.end(), false,
|
||||
"Path '%s' is already watched");
|
||||
|
||||
// construct watch entry
|
||||
wxSharedPtr<wxFSWatchEntry> watch(new wxFSWatchEntry(winfo));
|
||||
|
||||
if (!DoAdd(watch))
|
||||
return false;
|
||||
|
||||
// add watch to our map (always succeedes, checked above)
|
||||
wxFSWatchEntries::value_type val(watch->GetPath(), watch);
|
||||
return m_watches.insert(val).second;
|
||||
}
|
||||
|
||||
virtual bool Remove(const wxFSWatchInfo& winfo)
|
||||
{
|
||||
wxFSWatchEntries::iterator it = m_watches.find(winfo.GetPath());
|
||||
wxCHECK_MSG( it != m_watches.end(), false, "Path '%s' is not watched");
|
||||
|
||||
wxSharedPtr<wxFSWatchEntry> watch = it->second;
|
||||
m_watches.erase(it);
|
||||
return DoRemove(watch);
|
||||
}
|
||||
|
||||
virtual bool RemoveAll()
|
||||
{
|
||||
m_watches.clear();
|
||||
return true;
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual bool DoAdd(wxSharedPtr<wxFSWatchEntry> watch) = 0;
|
||||
|
||||
virtual bool DoRemove(wxSharedPtr<wxFSWatchEntry> watch) = 0;
|
||||
|
||||
wxFSWatchEntries m_watches;
|
||||
wxFileSystemWatcherBase* m_watcher;
|
||||
};
|
||||
|
||||
|
||||
#endif /* WX_PRIVATE_FSWATCHER_H_ */
|
157
Externals/wxWidgets3/include/wx/private/graphics.h
vendored
Normal file
157
Externals/wxWidgets3/include/wx/private/graphics.h
vendored
Normal file
@ -0,0 +1,157 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/private/graphics.h
|
||||
// Purpose: private graphics context header
|
||||
// Author: Stefan Csomor
|
||||
// Modified by:
|
||||
// Created:
|
||||
// Copyright: (c) Stefan Csomor
|
||||
// RCS-ID: $Id: graphics.h 67232 2011-03-18 15:10:15Z DS $
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_GRAPHICS_PRIVATE_H_
|
||||
#define _WX_GRAPHICS_PRIVATE_H_
|
||||
|
||||
#if wxUSE_GRAPHICS_CONTEXT
|
||||
|
||||
#include "wx/graphics.h"
|
||||
|
||||
class WXDLLIMPEXP_CORE wxGraphicsObjectRefData : public wxObjectRefData
|
||||
{
|
||||
public :
|
||||
wxGraphicsObjectRefData( wxGraphicsRenderer* renderer );
|
||||
wxGraphicsObjectRefData( const wxGraphicsObjectRefData* data );
|
||||
wxGraphicsRenderer* GetRenderer() const ;
|
||||
virtual wxGraphicsObjectRefData* Clone() const ;
|
||||
|
||||
protected :
|
||||
wxGraphicsRenderer* m_renderer;
|
||||
} ;
|
||||
|
||||
class WXDLLIMPEXP_CORE wxGraphicsMatrixData : public wxGraphicsObjectRefData
|
||||
{
|
||||
public :
|
||||
wxGraphicsMatrixData( wxGraphicsRenderer* renderer) :
|
||||
wxGraphicsObjectRefData(renderer) {}
|
||||
|
||||
virtual ~wxGraphicsMatrixData() {}
|
||||
|
||||
// concatenates the matrix
|
||||
virtual void Concat( const wxGraphicsMatrixData *t ) = 0;
|
||||
|
||||
// sets the matrix to the respective values
|
||||
virtual void Set(wxDouble a=1.0, wxDouble b=0.0, wxDouble c=0.0, wxDouble d=1.0,
|
||||
wxDouble tx=0.0, wxDouble ty=0.0) = 0;
|
||||
|
||||
// gets the component valuess of the matrix
|
||||
virtual void Get(wxDouble* a=NULL, wxDouble* b=NULL, wxDouble* c=NULL,
|
||||
wxDouble* d=NULL, wxDouble* tx=NULL, wxDouble* ty=NULL) const = 0;
|
||||
|
||||
// makes this the inverse matrix
|
||||
virtual void Invert() = 0;
|
||||
|
||||
// returns true if the elements of the transformation matrix are equal ?
|
||||
virtual bool IsEqual( const wxGraphicsMatrixData* t) const = 0;
|
||||
|
||||
// return true if this is the identity matrix
|
||||
virtual bool IsIdentity() const = 0;
|
||||
|
||||
//
|
||||
// transformation
|
||||
//
|
||||
|
||||
// add the translation to this matrix
|
||||
virtual void Translate( wxDouble dx , wxDouble dy ) = 0;
|
||||
|
||||
// add the scale to this matrix
|
||||
virtual void Scale( wxDouble xScale , wxDouble yScale ) = 0;
|
||||
|
||||
// add the rotation to this matrix (radians)
|
||||
virtual void Rotate( wxDouble angle ) = 0;
|
||||
|
||||
//
|
||||
// apply the transforms
|
||||
//
|
||||
|
||||
// applies that matrix to the point
|
||||
virtual void TransformPoint( wxDouble *x, wxDouble *y ) const = 0;
|
||||
|
||||
// applies the matrix except for translations
|
||||
virtual void TransformDistance( wxDouble *dx, wxDouble *dy ) const =0;
|
||||
|
||||
// returns the native representation
|
||||
virtual void * GetNativeMatrix() const = 0;
|
||||
} ;
|
||||
|
||||
class WXDLLIMPEXP_CORE wxGraphicsPathData : public wxGraphicsObjectRefData
|
||||
{
|
||||
public :
|
||||
wxGraphicsPathData(wxGraphicsRenderer* renderer) : wxGraphicsObjectRefData(renderer) {}
|
||||
virtual ~wxGraphicsPathData() {}
|
||||
|
||||
//
|
||||
// These are the path primitives from which everything else can be constructed
|
||||
//
|
||||
|
||||
// begins a new subpath at (x,y)
|
||||
virtual void MoveToPoint( wxDouble x, wxDouble y ) = 0;
|
||||
|
||||
// adds a straight line from the current point to (x,y)
|
||||
virtual void AddLineToPoint( wxDouble x, wxDouble y ) = 0;
|
||||
|
||||
// adds a cubic Bezier curve from the current point, using two control points and an end point
|
||||
virtual void AddCurveToPoint( wxDouble cx1, wxDouble cy1, wxDouble cx2, wxDouble cy2, wxDouble x, wxDouble y ) = 0;
|
||||
|
||||
// adds another path
|
||||
virtual void AddPath( const wxGraphicsPathData* path ) =0;
|
||||
|
||||
// closes the current sub-path
|
||||
virtual void CloseSubpath() = 0;
|
||||
|
||||
// gets the last point of the current path, (0,0) if not yet set
|
||||
virtual void GetCurrentPoint( wxDouble* x, wxDouble* y) const = 0;
|
||||
|
||||
// adds an arc of a circle centering at (x,y) with radius (r) from startAngle to endAngle
|
||||
virtual void AddArc( wxDouble x, wxDouble y, wxDouble r, wxDouble startAngle, wxDouble endAngle, bool clockwise ) = 0;
|
||||
|
||||
//
|
||||
// These are convenience functions which - if not available natively will be assembled
|
||||
// using the primitives from above
|
||||
//
|
||||
|
||||
// adds a quadratic Bezier curve from the current point, using a control point and an end point
|
||||
virtual void AddQuadCurveToPoint( wxDouble cx, wxDouble cy, wxDouble x, wxDouble y );
|
||||
|
||||
// appends a rectangle as a new closed subpath
|
||||
virtual void AddRectangle( wxDouble x, wxDouble y, wxDouble w, wxDouble h );
|
||||
|
||||
// appends an ellipsis as a new closed subpath fitting the passed rectangle
|
||||
virtual void AddCircle( wxDouble x, wxDouble y, wxDouble r );
|
||||
|
||||
// appends a an arc to two tangents connecting (current) to (x1,y1) and (x1,y1) to (x2,y2), also a straight line from (current) to (x1,y1)
|
||||
virtual void AddArcToPoint( wxDouble x1, wxDouble y1 , wxDouble x2, wxDouble y2, wxDouble r ) ;
|
||||
|
||||
// appends an ellipse
|
||||
virtual void AddEllipse( wxDouble x, wxDouble y, wxDouble w, wxDouble h);
|
||||
|
||||
// appends a rounded rectangle
|
||||
virtual void AddRoundedRectangle( wxDouble x, wxDouble y, wxDouble w, wxDouble h, wxDouble radius);
|
||||
|
||||
// returns the native path
|
||||
virtual void * GetNativePath() const = 0;
|
||||
|
||||
// give the native path returned by GetNativePath() back (there might be some deallocations necessary)
|
||||
virtual void UnGetNativePath(void *p) const= 0;
|
||||
|
||||
// transforms each point of this path by the matrix
|
||||
virtual void Transform( const wxGraphicsMatrixData* matrix ) =0;
|
||||
|
||||
// gets the bounding box enclosing all points (possibly including control points)
|
||||
virtual void GetBox(wxDouble *x, wxDouble *y, wxDouble *w, wxDouble *h) const=0;
|
||||
|
||||
virtual bool Contains( wxDouble x, wxDouble y, wxPolygonFillMode fillStyle = wxODDEVEN_RULE) const=0;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#endif // _WX_GRAPHICS_PRIVATE_H_
|
177
Externals/wxWidgets3/include/wx/private/markupparser.h
vendored
Normal file
177
Externals/wxWidgets3/include/wx/private/markupparser.h
vendored
Normal file
@ -0,0 +1,177 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/private/markupparser.h
|
||||
// Purpose: Classes for parsing simple markup.
|
||||
// Author: Vadim Zeitlin
|
||||
// Created: 2011-02-16
|
||||
// RCS-ID: $Id: markupparser.h 67076 2011-02-27 18:36:52Z VZ $
|
||||
// Copyright: (c) 2011 Vadim Zeitlin <vadim@wxwidgets.org>
|
||||
// Licence: wxWindows licence
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_PRIVATE_MARKUPPARSER_H_
|
||||
#define _WX_PRIVATE_MARKUPPARSER_H_
|
||||
|
||||
#include "wx/string.h"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxMarkupSpanAttributes: information about attributes for a markup span.
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
struct wxMarkupSpanAttributes
|
||||
{
|
||||
enum OptionalBool
|
||||
{
|
||||
Unspecified = -1,
|
||||
No,
|
||||
Yes
|
||||
};
|
||||
|
||||
wxMarkupSpanAttributes()
|
||||
{
|
||||
m_sizeKind = Size_Unspecified;
|
||||
|
||||
m_isBold =
|
||||
m_isItalic =
|
||||
m_isUnderlined =
|
||||
m_isStrikethrough = Unspecified;
|
||||
}
|
||||
|
||||
// If a string is empty, it means that the corresponding attribute is not
|
||||
// set.
|
||||
wxString m_fgCol,
|
||||
m_bgCol,
|
||||
m_fontFace;
|
||||
|
||||
// There are many ways of specifying the size. First of all, the size may
|
||||
// be relative in which case m_fontSize is either -1 or +1 meaning that
|
||||
// it's one step smaller or larger than the current font. Second, it may be
|
||||
// absolute in which case m_fontSize contains either the size in 1024th of
|
||||
// a point (Pango convention) or its values are in [-3, 3] interval and map
|
||||
// to [xx-small, xx-large] CSS-like font size specification. And finally it
|
||||
// may be not specified at all, of course, in which case the value of
|
||||
// m_fontSize doesn't matter and it shouldn't be used.
|
||||
enum
|
||||
{
|
||||
Size_Unspecified,
|
||||
Size_Relative,
|
||||
Size_Symbolic,
|
||||
Size_PointParts
|
||||
} m_sizeKind;
|
||||
int m_fontSize;
|
||||
|
||||
// If the value is Unspecified, the attribute wasn't given.
|
||||
OptionalBool m_isBold,
|
||||
m_isItalic,
|
||||
m_isUnderlined,
|
||||
m_isStrikethrough;
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxMarkupParserOutput: gathers the results of parsing markup.
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// A class deriving directly from this one needs to implement all the pure
|
||||
// virtual functions below but as the handling of all simple tags (bold, italic
|
||||
// &c) is often very similar, it is usually more convenient to inherit from
|
||||
// wxMarkupParserFontOutput defined in wx/private/markupparserfont.h instead.
|
||||
class wxMarkupParserOutput
|
||||
{
|
||||
public:
|
||||
wxMarkupParserOutput() { }
|
||||
virtual ~wxMarkupParserOutput() { }
|
||||
|
||||
// Virtual functions called by wxMarkupParser while parsing the markup.
|
||||
|
||||
// Called for a run of normal text.
|
||||
virtual void OnText(const wxString& text) = 0;
|
||||
|
||||
// These functions correspond to the simple tags without parameters.
|
||||
virtual void OnBoldStart() = 0;
|
||||
virtual void OnBoldEnd() = 0;
|
||||
|
||||
virtual void OnItalicStart() = 0;
|
||||
virtual void OnItalicEnd() = 0;
|
||||
|
||||
virtual void OnUnderlinedStart() = 0;
|
||||
virtual void OnUnderlinedEnd() = 0;
|
||||
|
||||
virtual void OnStrikethroughStart() = 0;
|
||||
virtual void OnStrikethroughEnd() = 0;
|
||||
|
||||
virtual void OnBigStart() = 0;
|
||||
virtual void OnBigEnd() = 0;
|
||||
|
||||
virtual void OnSmallStart() = 0;
|
||||
virtual void OnSmallEnd() = 0;
|
||||
|
||||
virtual void OnTeletypeStart() = 0;
|
||||
virtual void OnTeletypeEnd() = 0;
|
||||
|
||||
// The generic span start and end functions.
|
||||
virtual void OnSpanStart(const wxMarkupSpanAttributes& attrs) = 0;
|
||||
virtual void OnSpanEnd(const wxMarkupSpanAttributes& attrs) = 0;
|
||||
|
||||
private:
|
||||
wxDECLARE_NO_COPY_CLASS(wxMarkupParserOutput);
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxMarkupParser: parses the given markup text into wxMarkupParserOutput.
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class WXDLLIMPEXP_CORE wxMarkupParser
|
||||
{
|
||||
public:
|
||||
// Initialize the parser with the object that will receive parsing results.
|
||||
// This object lifetime must be greater than ours.
|
||||
explicit wxMarkupParser(wxMarkupParserOutput& output)
|
||||
: m_output(output)
|
||||
{
|
||||
}
|
||||
|
||||
// Parse the entire string and call wxMarkupParserOutput methods.
|
||||
//
|
||||
// Return true if the string was successfully parsed or false if it failed
|
||||
// (presumably because of syntax errors in the markup).
|
||||
bool Parse(const wxString& text);
|
||||
|
||||
// Quote a normal string, not meant to be interpreted as markup, so that it
|
||||
// produces the same string when parsed as markup. This means, for example,
|
||||
// replacing '<' in the input string with "<" to prevent them from being
|
||||
// interpreted as tag opening characters.
|
||||
static wxString Quote(const wxString& text);
|
||||
|
||||
// Strip markup from a string, i.e. simply remove all tags and replace
|
||||
// XML entities with their values (or with "&&" in case of "&" to
|
||||
// prevent it from being interpreted as mnemonic marker).
|
||||
static wxString Strip(const wxString& text);
|
||||
|
||||
private:
|
||||
// Simple struct combining the name of a tag and its attributes.
|
||||
struct TagAndAttrs
|
||||
{
|
||||
TagAndAttrs(const wxString& name_) : name(name_) { }
|
||||
|
||||
wxString name;
|
||||
wxMarkupSpanAttributes attrs;
|
||||
};
|
||||
|
||||
// Call the wxMarkupParserOutput method corresponding to the given tag.
|
||||
//
|
||||
// Return false if the tag doesn't match any of the known ones.
|
||||
bool OutputTag(const TagAndAttrs& tagAndAttrs, bool start);
|
||||
|
||||
// Parse the attributes and fill the provided TagAndAttrs object with the
|
||||
// information about them. Does nothing if attrs string is empty.
|
||||
//
|
||||
// Returns empty string on success of a [fragment of an] error message if
|
||||
// we failed to parse the attributes.
|
||||
wxString ParseAttrs(wxString attrs, TagAndAttrs& tagAndAttrs);
|
||||
|
||||
|
||||
wxMarkupParserOutput& m_output;
|
||||
|
||||
wxDECLARE_NO_COPY_CLASS(wxMarkupParser);
|
||||
};
|
||||
|
||||
#endif // _WX_PRIVATE_MARKUPPARSER_H_
|
232
Externals/wxWidgets3/include/wx/private/markupparserattr.h
vendored
Normal file
232
Externals/wxWidgets3/include/wx/private/markupparserattr.h
vendored
Normal file
@ -0,0 +1,232 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/private/markupparserattr.h
|
||||
// Purpose: Classes mapping markup attributes to wxFont/wxColour.
|
||||
// Author: Vadim Zeitlin
|
||||
// Created: 2011-02-18
|
||||
// RCS-ID: $Id: markupparserattr.h 67073 2011-02-27 14:01:36Z VZ $
|
||||
// Copyright: (c) 2011 Vadim Zeitlin <vadim@wxwidgets.org>
|
||||
// Licence: wxWindows licence
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_PRIVATE_MARKUPPARSERATTR_H_
|
||||
#define _WX_PRIVATE_MARKUPPARSERATTR_H_
|
||||
|
||||
#include "wx/private/markupparser.h"
|
||||
|
||||
#include "wx/stack.h"
|
||||
|
||||
#include "wx/colour.h"
|
||||
#include "wx/font.h"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxMarkupParserAttrOutput: simplified wxFont-using version of the above.
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// This class assumes that wxFont and wxColour are used to perform all the
|
||||
// markup tags and implements the base class virtual functions in terms of
|
||||
// OnAttr{Start,End}() only.
|
||||
//
|
||||
// Notice that you still must implement OnText() inherited from the base class
|
||||
// when deriving from this one.
|
||||
class wxMarkupParserAttrOutput : public wxMarkupParserOutput
|
||||
{
|
||||
public:
|
||||
// A simple container of font and colours.
|
||||
struct Attr
|
||||
{
|
||||
Attr(const wxFont& font_,
|
||||
const wxColour& foreground_ = wxColour(),
|
||||
const wxColour& background_ = wxColour())
|
||||
: font(font_), foreground(foreground_), background(background_)
|
||||
{
|
||||
}
|
||||
|
||||
wxFont font;
|
||||
wxColour foreground,
|
||||
background;
|
||||
};
|
||||
|
||||
|
||||
// This object must be initialized with the font and colours to use
|
||||
// initially, i.e. the ones used before any tags in the string.
|
||||
wxMarkupParserAttrOutput(const wxFont& font,
|
||||
const wxColour& foreground,
|
||||
const wxColour& background)
|
||||
{
|
||||
m_attrs.push(Attr(font, foreground, background));
|
||||
}
|
||||
|
||||
// Indicates the change of the font and/or colours used. Any of the
|
||||
// fields of the argument may be invalid indicating that the corresponding
|
||||
// attribute didn't actually change.
|
||||
virtual void OnAttrStart(const Attr& attr) = 0;
|
||||
|
||||
// Indicates the end of the region affected by the given attributes
|
||||
// (the same ones that were passed to the matching OnAttrStart(), use
|
||||
// GetAttr() to get the ones that will be used from now on).
|
||||
virtual void OnAttrEnd(const Attr& attr) = 0;
|
||||
|
||||
|
||||
// Implement all pure virtual methods inherited from the base class in
|
||||
// terms of our own ones.
|
||||
virtual void OnBoldStart() { DoChangeFont(&wxFont::Bold); }
|
||||
virtual void OnBoldEnd() { DoEndAttr(); }
|
||||
|
||||
virtual void OnItalicStart() { DoChangeFont(&wxFont::Italic); }
|
||||
virtual void OnItalicEnd() { DoEndAttr(); }
|
||||
|
||||
virtual void OnUnderlinedStart() { DoChangeFont(&wxFont::Underlined); }
|
||||
virtual void OnUnderlinedEnd() { DoEndAttr(); }
|
||||
|
||||
virtual void OnStrikethroughStart() { } // TODO: No support in wxFont yet.
|
||||
virtual void OnStrikethroughEnd() { }
|
||||
|
||||
virtual void OnBigStart() { DoChangeFont(&wxFont::Larger); }
|
||||
virtual void OnBigEnd() { DoEndAttr(); }
|
||||
|
||||
virtual void OnSmallStart() { DoChangeFont(&wxFont::Smaller); }
|
||||
virtual void OnSmallEnd() { DoEndAttr(); }
|
||||
|
||||
virtual void OnTeletypeStart()
|
||||
{
|
||||
wxFont font(GetFont());
|
||||
font.SetFamily(wxFONTFAMILY_TELETYPE);
|
||||
DoSetFont(font);
|
||||
}
|
||||
virtual void OnTeletypeEnd() { DoEndAttr(); }
|
||||
|
||||
virtual void OnSpanStart(const wxMarkupSpanAttributes& spanAttr)
|
||||
{
|
||||
wxFont font(GetFont());
|
||||
if ( !spanAttr.m_fontFace.empty() )
|
||||
font.SetFaceName(spanAttr.m_fontFace);
|
||||
|
||||
FontModifier<wxFontWeight>()(spanAttr.m_isBold,
|
||||
font, &wxFont::SetWeight,
|
||||
wxFONTWEIGHT_NORMAL, wxFONTWEIGHT_BOLD);
|
||||
|
||||
FontModifier<wxFontStyle>()(spanAttr.m_isItalic,
|
||||
font, &wxFont::SetStyle,
|
||||
wxFONTSTYLE_NORMAL, wxFONTSTYLE_ITALIC);
|
||||
|
||||
FontModifier<bool>()(spanAttr.m_isUnderlined,
|
||||
font, &wxFont::SetUnderlined,
|
||||
false, true);
|
||||
|
||||
// TODO: No support for strike-through yet.
|
||||
|
||||
switch ( spanAttr.m_sizeKind )
|
||||
{
|
||||
case wxMarkupSpanAttributes::Size_Unspecified:
|
||||
break;
|
||||
|
||||
case wxMarkupSpanAttributes::Size_Relative:
|
||||
if ( spanAttr.m_fontSize > 0 )
|
||||
font.MakeLarger();
|
||||
else
|
||||
font.MakeSmaller();
|
||||
break;
|
||||
|
||||
case wxMarkupSpanAttributes::Size_Symbolic:
|
||||
// The values of font size intentionally coincide with the
|
||||
// values of wxFontSymbolicSize enum elements so simply cast
|
||||
// one to the other.
|
||||
font.SetSymbolicSize(
|
||||
static_cast<wxFontSymbolicSize>(spanAttr.m_fontSize)
|
||||
);
|
||||
break;
|
||||
|
||||
case wxMarkupSpanAttributes::Size_PointParts:
|
||||
font.SetPointSize((spanAttr.m_fontSize + 1023)/1024);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
const Attr attr(font, spanAttr.m_fgCol, spanAttr.m_bgCol);
|
||||
OnAttrStart(attr);
|
||||
|
||||
m_attrs.push(attr);
|
||||
}
|
||||
|
||||
virtual void OnSpanEnd(const wxMarkupSpanAttributes& WXUNUSED(spanAttr))
|
||||
{
|
||||
DoEndAttr();
|
||||
}
|
||||
|
||||
protected:
|
||||
// Get the current attributes, i.e. the ones that should be used for
|
||||
// rendering (or measuring or whatever) the text at the current position in
|
||||
// the string.
|
||||
//
|
||||
// It may be called from OnAttrStart() to get the old attributes used
|
||||
// before and from OnAttrEnd() to get the new attributes that will be used
|
||||
// from now on but is mostly meant to be used from overridden OnText()
|
||||
// implementations.
|
||||
const Attr& GetAttr() const { return m_attrs.top(); }
|
||||
|
||||
// A shortcut for accessing the font of the current attribute.
|
||||
const wxFont& GetFont() const { return GetAttr().font; }
|
||||
|
||||
private:
|
||||
// Change only the font to the given one. Call OnAttrStart() to notify
|
||||
// about the change and update the attributes stack.
|
||||
void DoSetFont(const wxFont& font)
|
||||
{
|
||||
const Attr attr(font);
|
||||
|
||||
OnAttrStart(attr);
|
||||
|
||||
m_attrs.push(attr);
|
||||
}
|
||||
|
||||
// Apply the given function to the font currently on top of the font stack,
|
||||
// push the new font on the stack and call OnAttrStart() with it.
|
||||
void DoChangeFont(wxFont (wxFont::*func)() const)
|
||||
{
|
||||
DoSetFont((GetFont().*func)());
|
||||
}
|
||||
|
||||
void DoEndAttr()
|
||||
{
|
||||
const Attr attr(m_attrs.top());
|
||||
m_attrs.pop();
|
||||
|
||||
OnAttrEnd(attr);
|
||||
}
|
||||
|
||||
// A helper class used to apply the given function to a wxFont object
|
||||
// depending on the value of an OptionalBool.
|
||||
template <typename T>
|
||||
struct FontModifier
|
||||
{
|
||||
FontModifier() { }
|
||||
|
||||
void operator()(wxMarkupSpanAttributes::OptionalBool isIt,
|
||||
wxFont& font,
|
||||
void (wxFont::*func)(T),
|
||||
T noValue,
|
||||
T yesValue)
|
||||
{
|
||||
switch ( isIt )
|
||||
{
|
||||
case wxMarkupSpanAttributes::Unspecified:
|
||||
break;
|
||||
|
||||
case wxMarkupSpanAttributes::No:
|
||||
(font.*func)(noValue);
|
||||
break;
|
||||
|
||||
case wxMarkupSpanAttributes::Yes:
|
||||
(font.*func)(yesValue);
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
wxStack<Attr> m_attrs;
|
||||
|
||||
wxDECLARE_NO_COPY_CLASS(wxMarkupParserAttrOutput);
|
||||
};
|
||||
|
||||
#endif // _WX_PRIVATE_MARKUPPARSERATTR_H_
|
67
Externals/wxWidgets3/include/wx/private/overlay.h
vendored
Normal file
67
Externals/wxWidgets3/include/wx/private/overlay.h
vendored
Normal file
@ -0,0 +1,67 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/private/overlay.h
|
||||
// Purpose: wxOverlayImpl declaration
|
||||
// Author: Stefan Csomor
|
||||
// Modified by:
|
||||
// Created: 2006-10-20
|
||||
// RCS-ID: $Id: overlay.h 54125 2008-06-11 19:17:41Z SC $
|
||||
// Copyright: (c) wxWidgets team
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_PRIVATE_OVERLAY_H_
|
||||
#define _WX_PRIVATE_OVERLAY_H_
|
||||
|
||||
#include "wx/overlay.h"
|
||||
|
||||
#ifdef wxHAS_NATIVE_OVERLAY
|
||||
|
||||
#if defined(__WXMAC__)
|
||||
#include "wx/osx/carbon/private/overlay.h"
|
||||
#elif defined(__WXDFB__)
|
||||
#include "wx/dfb/private/overlay.h"
|
||||
#else
|
||||
#error "unknown native wxOverlay implementation"
|
||||
#endif
|
||||
|
||||
#else // !wxHAS_NATIVE_OVERLAY
|
||||
|
||||
#include "wx/bitmap.h"
|
||||
|
||||
class WXDLLIMPEXP_FWD_CORE wxWindow;
|
||||
|
||||
// generic implementation of wxOverlay
|
||||
class wxOverlayImpl
|
||||
{
|
||||
public:
|
||||
wxOverlayImpl();
|
||||
~wxOverlayImpl();
|
||||
|
||||
|
||||
// clears the overlay without restoring the former state
|
||||
// to be done eg when the window content has been changed and repainted
|
||||
void Reset();
|
||||
|
||||
// returns true if it has been setup
|
||||
bool IsOk();
|
||||
|
||||
void Init(wxDC* dc, int x , int y , int width , int height);
|
||||
|
||||
void BeginDrawing(wxDC* dc);
|
||||
|
||||
void EndDrawing(wxDC* dc);
|
||||
|
||||
void Clear(wxDC* dc);
|
||||
|
||||
private:
|
||||
wxBitmap m_bmpSaved ;
|
||||
int m_x ;
|
||||
int m_y ;
|
||||
int m_width ;
|
||||
int m_height ;
|
||||
wxWindow* m_window ;
|
||||
};
|
||||
|
||||
#endif // wxHAS_NATIVE_OVERLAY/!wxHAS_NATIVE_OVERLAY
|
||||
|
||||
#endif // _WX_PRIVATE_OVERLAY_H_
|
324
Externals/wxWidgets3/include/wx/private/sckaddr.h
vendored
Normal file
324
Externals/wxWidgets3/include/wx/private/sckaddr.h
vendored
Normal file
@ -0,0 +1,324 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/private/sckaddr.h
|
||||
// Purpose: wxSockAddressImpl
|
||||
// Author: Vadim Zeitlin
|
||||
// Created: 2008-12-28
|
||||
// RCS-ID: $Id: sckaddr.h 67254 2011-03-20 00:14:35Z DS $
|
||||
// Copyright: (c) 2008 Vadim Zeitlin <vadim@wxwidgets.org>
|
||||
// Licence: wxWindows licence
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_PRIVATE_SOCKADDR_H_
|
||||
#define _WX_PRIVATE_SOCKADDR_H_
|
||||
|
||||
#ifdef __WXMSW__
|
||||
#include "wx/msw/wrapwin.h"
|
||||
|
||||
#if wxUSE_IPV6
|
||||
#include <ws2tcpip.h>
|
||||
#endif
|
||||
#elif defined(__VMS__)
|
||||
#include <socket.h>
|
||||
|
||||
struct sockaddr_un
|
||||
{
|
||||
u_char sun_len; /* sockaddr len including null */
|
||||
u_char sun_family; /* AF_UNIX */
|
||||
char sun_path[108]; /* path name (gag) */
|
||||
};
|
||||
#include <in.h>
|
||||
#else // generic Unix
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <sys/un.h>
|
||||
#endif // platform
|
||||
|
||||
#include <stdlib.h> // for calloc()
|
||||
|
||||
// this is a wrapper for sockaddr_storage if it's available or just sockaddr
|
||||
// otherwise
|
||||
union wxSockAddressStorage
|
||||
{
|
||||
#if wxUSE_IPV6
|
||||
sockaddr_storage addr_storage;
|
||||
#endif
|
||||
sockaddr addr;
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// helpers for wxSockAddressImpl
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// helper class mapping sockaddr_xxx types to corresponding AF_XXX values
|
||||
//
|
||||
// FIXME-VC6: we could leave the template undefined if not for VC6 which
|
||||
// absolutely does need to have a generic version defining the
|
||||
// template "interface" to compile the code below
|
||||
template <class T> struct AddressFamily { enum { value = AF_UNSPEC }; };
|
||||
|
||||
template <> struct AddressFamily<sockaddr_in> { enum { value = AF_INET }; };
|
||||
|
||||
#if wxUSE_IPV6
|
||||
template <> struct AddressFamily<sockaddr_in6> { enum { value = AF_INET6 }; };
|
||||
#endif // wxUSE_IPV6
|
||||
|
||||
#ifdef wxHAS_UNIX_DOMAIN_SOCKETS
|
||||
template <> struct AddressFamily<sockaddr_un> { enum { value = AF_UNIX }; };
|
||||
#endif // wxHAS_UNIX_DOMAIN_SOCKETS
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxSockAddressImpl
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// Represents a socket endpoint, e.g. an (address, port) pair for PF_INET
|
||||
// sockets. It can be initialized from an existing sockaddr struct and also
|
||||
// provides access to sockaddr stored internally so that it can be easily used
|
||||
// with e.g. connect(2).
|
||||
//
|
||||
// This class also performs (synchronous, hence potentially long) name lookups
|
||||
// if necessary, i.e. if the host name strings don't contain addresses in
|
||||
// numerical form (quad dotted for IPv4 or standard hexadecimal for IPv6).
|
||||
// Notice that internally the potentially Unicode host names are encoded as
|
||||
// UTF-8 before being passed to the lookup function but the host names should
|
||||
// really be ASCII anyhow.
|
||||
class wxSockAddressImpl
|
||||
{
|
||||
public:
|
||||
// as this is passed to socket() it should be a PF_XXX and not AF_XXX (even
|
||||
// though they're the same in practice)
|
||||
enum Family
|
||||
{
|
||||
FAMILY_INET = PF_INET,
|
||||
#if wxUSE_IPV6
|
||||
FAMILY_INET6 = PF_INET6,
|
||||
#endif
|
||||
#ifdef wxHAS_UNIX_DOMAIN_SOCKETS
|
||||
FAMILY_UNIX = PF_UNIX,
|
||||
#endif
|
||||
FAMILY_UNSPEC = PF_UNSPEC
|
||||
};
|
||||
|
||||
// default ctor creates uninitialized object, use one of CreateXXX() below
|
||||
wxSockAddressImpl()
|
||||
{
|
||||
InitUnspec();
|
||||
}
|
||||
|
||||
// ctor from an existing sockaddr
|
||||
wxSockAddressImpl(const sockaddr& addr, int len)
|
||||
{
|
||||
switch ( addr.sa_family )
|
||||
{
|
||||
case PF_INET:
|
||||
#if wxUSE_IPV6
|
||||
case PF_INET6:
|
||||
#endif
|
||||
#ifdef wxHAS_UNIX_DOMAIN_SOCKETS
|
||||
case PF_UNIX:
|
||||
#endif
|
||||
m_family = static_cast<Family>(addr.sa_family);
|
||||
break;
|
||||
|
||||
default:
|
||||
wxFAIL_MSG( "unsupported socket address family" );
|
||||
InitUnspec();
|
||||
return;
|
||||
}
|
||||
|
||||
InitFromSockaddr(addr, len);
|
||||
}
|
||||
|
||||
// copy ctor and assignment operators
|
||||
wxSockAddressImpl(const wxSockAddressImpl& other)
|
||||
{
|
||||
InitFromOther(other);
|
||||
}
|
||||
|
||||
wxSockAddressImpl& operator=(const wxSockAddressImpl& other)
|
||||
{
|
||||
if (this != &other)
|
||||
{
|
||||
free(m_addr);
|
||||
InitFromOther(other);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
// dtor frees the memory used by m_addr
|
||||
~wxSockAddressImpl()
|
||||
{
|
||||
free(m_addr);
|
||||
}
|
||||
|
||||
|
||||
// reset the address to the initial uninitialized state
|
||||
void Clear()
|
||||
{
|
||||
free(m_addr);
|
||||
|
||||
InitUnspec();
|
||||
}
|
||||
|
||||
// initialize the address to be of specific address family, it must be
|
||||
// currently uninitialized (you may call Clear() to achieve this)
|
||||
void CreateINET();
|
||||
void CreateINET6();
|
||||
#ifdef wxHAS_UNIX_DOMAIN_SOCKETS
|
||||
void CreateUnix();
|
||||
#endif // wxHAS_UNIX_DOMAIN_SOCKETS
|
||||
void Create(Family family)
|
||||
{
|
||||
switch ( family )
|
||||
{
|
||||
case FAMILY_INET:
|
||||
CreateINET();
|
||||
break;
|
||||
|
||||
#if wxUSE_IPV6
|
||||
case FAMILY_INET6:
|
||||
CreateINET6();
|
||||
break;
|
||||
#endif // wxUSE_IPV6
|
||||
|
||||
#ifdef wxHAS_UNIX_DOMAIN_SOCKETS
|
||||
case FAMILY_UNIX:
|
||||
CreateUnix();
|
||||
break;
|
||||
#endif // wxHAS_UNIX_DOMAIN_SOCKETS
|
||||
|
||||
default:
|
||||
wxFAIL_MSG( "unsupported socket address family" );
|
||||
}
|
||||
}
|
||||
|
||||
// simple accessors
|
||||
Family GetFamily() const { return m_family; }
|
||||
bool Is(Family family) const { return m_family == family; }
|
||||
bool IsOk() const { return m_family != FAMILY_UNSPEC; }
|
||||
const sockaddr *GetAddr() const { return m_addr; }
|
||||
sockaddr *GetWritableAddr() { return m_addr; }
|
||||
int GetLen() const { return m_len; }
|
||||
|
||||
// accessors for INET or INET6 address families
|
||||
#if wxUSE_IPV6
|
||||
#define CALL_IPV4_OR_6(func, args) \
|
||||
Is(FAMILY_INET6) ? func##6(args) : func##4(args)
|
||||
#define CALL_IPV4_OR_6_VOID(func) \
|
||||
Is(FAMILY_INET6) ? func##6() : func##4()
|
||||
#else
|
||||
#define CALL_IPV4_OR_6(func, args) func##4(args)
|
||||
#define CALL_IPV4_OR_6_VOID(func) func##4()
|
||||
#endif // IPv6 support on/off
|
||||
|
||||
wxString GetHostName() const;
|
||||
bool SetHostName(const wxString& name)
|
||||
{
|
||||
return CALL_IPV4_OR_6(SetHostName, (name));
|
||||
}
|
||||
|
||||
wxUint16 GetPort() const { return CALL_IPV4_OR_6_VOID(GetPort); }
|
||||
bool SetPort(wxUint16 port) { return CALL_IPV4_OR_6(SetPort, (port)); }
|
||||
bool SetPortName(const wxString& name, const char *protocol);
|
||||
|
||||
bool SetToAnyAddress() { return CALL_IPV4_OR_6_VOID(SetToAnyAddress); }
|
||||
|
||||
#undef CALL_IPV4_OR_6
|
||||
|
||||
// accessors for INET addresses only
|
||||
bool GetHostAddress(wxUint32 *address) const;
|
||||
bool SetHostAddress(wxUint32 address);
|
||||
|
||||
bool SetToBroadcastAddress() { return SetHostAddress(INADDR_BROADCAST); }
|
||||
|
||||
// accessors for INET6 addresses only
|
||||
#if wxUSE_IPV6
|
||||
bool GetHostAddress(in6_addr *address) const;
|
||||
bool SetHostAddress(const in6_addr& address);
|
||||
#endif // wxUSE_IPV6
|
||||
|
||||
#ifdef wxHAS_UNIX_DOMAIN_SOCKETS
|
||||
// methods valid for Unix address family addresses only
|
||||
bool SetPath(const wxString& path);
|
||||
wxString GetPath() const;
|
||||
#endif // wxHAS_UNIX_DOMAIN_SOCKETS
|
||||
|
||||
private:
|
||||
void DoAlloc(int len)
|
||||
{
|
||||
m_addr = static_cast<sockaddr *>(calloc(1, len));
|
||||
m_len = len;
|
||||
}
|
||||
|
||||
// FIXME-VC6: VC6 doesn't grok Foo<T>() call syntax so we need the extra
|
||||
// dummy parameter of type T, use the macros in sckaddr.cpp to
|
||||
// hide it
|
||||
template <class T>
|
||||
T *Alloc(T *)
|
||||
{
|
||||
DoAlloc(sizeof(T));
|
||||
|
||||
return reinterpret_cast<T *>(m_addr);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
T *Get(T *) const
|
||||
{
|
||||
wxCHECK_MSG( static_cast<int>(m_family) == AddressFamily<T>::value,
|
||||
NULL,
|
||||
"socket address family mismatch" );
|
||||
|
||||
return reinterpret_cast<T *>(m_addr);
|
||||
}
|
||||
|
||||
void InitUnspec()
|
||||
{
|
||||
m_family = FAMILY_UNSPEC;
|
||||
m_addr = NULL;
|
||||
m_len = 0;
|
||||
}
|
||||
|
||||
void InitFromSockaddr(const sockaddr& addr, int len)
|
||||
{
|
||||
DoAlloc(len);
|
||||
memcpy(m_addr, &addr, len);
|
||||
}
|
||||
|
||||
void InitFromOther(const wxSockAddressImpl& other)
|
||||
{
|
||||
m_family = other.m_family;
|
||||
|
||||
if ( other.m_addr )
|
||||
{
|
||||
InitFromSockaddr(*other.m_addr, other.m_len);
|
||||
}
|
||||
else // no address to copy
|
||||
{
|
||||
m_addr = NULL;
|
||||
m_len = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// IPv4/6 implementations of public functions
|
||||
bool SetHostName4(const wxString& name);
|
||||
|
||||
bool SetPort4(wxUint16 port);
|
||||
wxUint16 GetPort4() const;
|
||||
|
||||
bool SetToAnyAddress4() { return SetHostAddress(INADDR_ANY); }
|
||||
|
||||
#if wxUSE_IPV6
|
||||
bool SetHostName6(const wxString& name);
|
||||
|
||||
bool SetPort6(wxUint16 port);
|
||||
wxUint16 GetPort6() const;
|
||||
|
||||
bool SetToAnyAddress6();
|
||||
#endif // wxUSE_IPV6
|
||||
|
||||
Family m_family;
|
||||
sockaddr *m_addr;
|
||||
int m_len;
|
||||
};
|
||||
|
||||
#endif // _WX_PRIVATE_SOCKADDR_H_
|
127
Externals/wxWidgets3/include/wx/private/selectdispatcher.h
vendored
Normal file
127
Externals/wxWidgets3/include/wx/private/selectdispatcher.h
vendored
Normal file
@ -0,0 +1,127 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/private/selectdispatcher.h
|
||||
// Purpose: wxSelectDispatcher class
|
||||
// Authors: Lukasz Michalski and Vadim Zeitlin
|
||||
// Created: December 2006
|
||||
// Copyright: (c) Lukasz Michalski
|
||||
// RCS-ID: $Id: selectdispatcher.h 63716 2010-03-20 12:45:28Z VZ $
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_PRIVATE_SELECTDISPATCHER_H_
|
||||
#define _WX_PRIVATE_SELECTDISPATCHER_H_
|
||||
|
||||
#include "wx/defs.h"
|
||||
|
||||
#if wxUSE_SELECT_DISPATCHER
|
||||
|
||||
#if defined(HAVE_SYS_SELECT_H) || defined(__WATCOMC__)
|
||||
#include <sys/time.h>
|
||||
#include <sys/select.h>
|
||||
#endif
|
||||
|
||||
#ifdef __WATCOMC__
|
||||
#include <types.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <tcpustd.h>
|
||||
#else
|
||||
#include <sys/types.h>
|
||||
#endif
|
||||
|
||||
#include "wx/private/fdiodispatcher.h"
|
||||
|
||||
// helper class storing all the select() fd sets
|
||||
class WXDLLIMPEXP_BASE wxSelectSets
|
||||
{
|
||||
public:
|
||||
// ctor zeroes out all fd_sets
|
||||
wxSelectSets();
|
||||
|
||||
// default copy ctor, assignment operator and dtor are ok
|
||||
|
||||
|
||||
// return true if fd appears in any of the sets
|
||||
bool HasFD(int fd) const;
|
||||
|
||||
// add or remove FD to our sets depending on whether flags contains
|
||||
// wxFDIO_INPUT/OUTPUT/EXCEPTION bits
|
||||
bool SetFD(int fd, int flags);
|
||||
|
||||
// same as SetFD() except it unsets the bits set in the flags for the given
|
||||
// fd
|
||||
bool ClearFD(int fd)
|
||||
{
|
||||
return SetFD(fd, 0);
|
||||
}
|
||||
|
||||
|
||||
// call select() with our sets: the other parameters are the same as for
|
||||
// select() itself
|
||||
int Select(int nfds, struct timeval *tv);
|
||||
|
||||
// call the handler methods corresponding to the sets having this fd if it
|
||||
// is present in any set and return true if it is
|
||||
bool Handle(int fd, wxFDIOHandler& handler) const;
|
||||
|
||||
private:
|
||||
typedef void (wxFDIOHandler::*Callback)();
|
||||
|
||||
// the FD sets indices
|
||||
enum
|
||||
{
|
||||
Read,
|
||||
Write,
|
||||
Except,
|
||||
Max
|
||||
};
|
||||
|
||||
// the sets used with select()
|
||||
fd_set m_fds[Max];
|
||||
|
||||
// the wxFDIO_XXX flags, functions and names (used for debug messages only)
|
||||
// corresponding to the FD sets above
|
||||
static int ms_flags[Max];
|
||||
static const char *ms_names[Max];
|
||||
static Callback ms_handlers[Max];
|
||||
};
|
||||
|
||||
class WXDLLIMPEXP_BASE wxSelectDispatcher : public wxMappedFDIODispatcher
|
||||
{
|
||||
public:
|
||||
// default ctor
|
||||
wxSelectDispatcher() { m_maxFD = -1; }
|
||||
|
||||
// implement pure virtual methods of the base class
|
||||
virtual bool RegisterFD(int fd, wxFDIOHandler *handler, int flags = wxFDIO_ALL);
|
||||
virtual bool ModifyFD(int fd, wxFDIOHandler *handler, int flags = wxFDIO_ALL);
|
||||
virtual bool UnregisterFD(int fd);
|
||||
virtual bool HasPending() const;
|
||||
virtual int Dispatch(int timeout = TIMEOUT_INFINITE);
|
||||
|
||||
private:
|
||||
// common part of RegisterFD() and ModifyFD()
|
||||
bool DoUpdateFDAndHandler(int fd, wxFDIOHandler *handler, int flags);
|
||||
|
||||
// call the handlers for the fds present in the given sets, return the
|
||||
// number of handlers we called
|
||||
int ProcessSets(const wxSelectSets& sets);
|
||||
|
||||
// helper of ProcessSets(): call the handler if its fd is in the set
|
||||
void DoProcessFD(int fd, const fd_set& fds, wxFDIOHandler *handler,
|
||||
const char *name);
|
||||
|
||||
// common part of HasPending() and Dispatch(): calls select() with the
|
||||
// specified timeout
|
||||
int DoSelect(wxSelectSets& sets, int timeout) const;
|
||||
|
||||
|
||||
// the select sets containing all the registered fds
|
||||
wxSelectSets m_sets;
|
||||
|
||||
// the highest registered fd value or -1 if none
|
||||
int m_maxFD;
|
||||
};
|
||||
|
||||
#endif // wxUSE_SELECT_DISPATCHER
|
||||
|
||||
#endif // _WX_PRIVATE_SOCKETEVTDISPATCH_H_
|
378
Externals/wxWidgets3/include/wx/private/socket.h
vendored
Normal file
378
Externals/wxWidgets3/include/wx/private/socket.h
vendored
Normal file
@ -0,0 +1,378 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/private/socket.h
|
||||
// Purpose: wxSocketImpl and related declarations
|
||||
// Authors: Guilhem Lavaux, Vadim Zeitlin
|
||||
// Created: April 1997
|
||||
// RCS-ID: $Id: socket.h 61675 2009-08-16 23:13:45Z VZ $
|
||||
// Copyright: (c) 1997 Guilhem Lavaux
|
||||
// (c) 2008 Vadim Zeitlin
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/*
|
||||
Brief overview of different socket classes:
|
||||
|
||||
- wxSocketBase is the public class representing a socket ("Base" here
|
||||
refers to the fact that wxSocketClient and wxSocketServer are derived
|
||||
from it and predates the convention of using "Base" for common base
|
||||
classes for platform-specific classes in wxWidgets) with implementation
|
||||
common to all platforms and forwarding methods whose implementation
|
||||
differs between platforms to wxSocketImpl which it contains.
|
||||
|
||||
- wxSocketImpl is actually just an abstract base class having only code
|
||||
common to all platforms, the concrete implementation classes derive from
|
||||
it and are created by wxSocketImpl::Create().
|
||||
|
||||
- Some socket operations have different implementations in console-mode and
|
||||
GUI applications. wxSocketManager class exists to abstract this in such
|
||||
way that console applications (using wxBase) don't depend on wxNet. An
|
||||
object of this class is made available via wxApp and GUI applications set
|
||||
up a different kind of global socket manager from console ones.
|
||||
|
||||
TODO: it looks like wxSocketManager could be eliminated by providing
|
||||
methods for registering/unregistering sockets directly in
|
||||
wxEventLoop.
|
||||
*/
|
||||
|
||||
#ifndef _WX_PRIVATE_SOCKET_H_
|
||||
#define _WX_PRIVATE_SOCKET_H_
|
||||
|
||||
#include "wx/defs.h"
|
||||
|
||||
#if wxUSE_SOCKETS
|
||||
|
||||
#include "wx/socket.h"
|
||||
#include "wx/private/sckaddr.h"
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
/*
|
||||
Including sys/types.h under Cygwin results in the warnings about "fd_set
|
||||
having been defined in sys/types.h" when winsock.h is included later and
|
||||
doesn't seem to be necessary anyhow. It's not needed under Mac neither.
|
||||
*/
|
||||
#if !defined(__WXMAC__) && !defined(__CYGWIN__) && !defined(__WXWINCE__)
|
||||
#include <sys/types.h>
|
||||
#endif
|
||||
|
||||
#ifdef __WXWINCE__
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
|
||||
// include the header defining timeval: under Windows this struct is used only
|
||||
// with sockets so we need to include winsock.h which we do via windows.h
|
||||
#ifdef __WXMSW__
|
||||
#include "wx/msw/wrapwin.h"
|
||||
#else
|
||||
#include <sys/time.h> // for timeval
|
||||
#endif
|
||||
|
||||
// these definitions are for MSW when we don't use configure, otherwise these
|
||||
// symbols are defined by configure
|
||||
#ifndef WX_SOCKLEN_T
|
||||
#define WX_SOCKLEN_T int
|
||||
#endif
|
||||
|
||||
#ifndef SOCKOPTLEN_T
|
||||
#define SOCKOPTLEN_T int
|
||||
#endif
|
||||
|
||||
// define some symbols which winsock.h defines but traditional BSD headers
|
||||
// don't
|
||||
#ifndef __WXMSW__
|
||||
#define SOCKET int
|
||||
#endif
|
||||
|
||||
#ifndef INVALID_SOCKET
|
||||
#define INVALID_SOCKET (-1)
|
||||
#endif
|
||||
|
||||
#ifndef SOCKET_ERROR
|
||||
#define SOCKET_ERROR (-1)
|
||||
#endif
|
||||
|
||||
typedef int wxSocketEventFlags;
|
||||
|
||||
class wxSocketImpl;
|
||||
|
||||
/*
|
||||
Class providing hooks abstracting the differences between console and GUI
|
||||
applications for socket code.
|
||||
|
||||
We also have different implementations of this class for different platforms
|
||||
allowing us to keep more things in the common code but the main reason for
|
||||
its existence is that we want the same socket code work differently
|
||||
depending on whether it's used from a console or a GUI program. This is
|
||||
achieved by implementing the virtual methods of this class differently in
|
||||
the objects returned by wxConsoleAppTraits::GetSocketManager() and the same
|
||||
method in wxGUIAppTraits.
|
||||
*/
|
||||
class wxSocketManager
|
||||
{
|
||||
public:
|
||||
// set the manager to use, we don't take ownership of it
|
||||
//
|
||||
// this should be called before creating the first wxSocket object,
|
||||
// otherwise the manager returned by wxAppTraits::GetSocketManager() will
|
||||
// be used
|
||||
static void Set(wxSocketManager *manager);
|
||||
|
||||
// return the manager to use
|
||||
//
|
||||
// this initializes the manager at first use
|
||||
static wxSocketManager *Get()
|
||||
{
|
||||
if ( !ms_manager )
|
||||
Init();
|
||||
|
||||
return ms_manager;
|
||||
}
|
||||
|
||||
// called before the first wxSocket is created and should do the
|
||||
// initializations needed in order to use the network
|
||||
//
|
||||
// return true if initialized successfully; if this returns false sockets
|
||||
// can't be used at all
|
||||
virtual bool OnInit() = 0;
|
||||
|
||||
// undo the initializations of OnInit()
|
||||
virtual void OnExit() = 0;
|
||||
|
||||
|
||||
// create the socket implementation object matching this manager
|
||||
virtual wxSocketImpl *CreateSocket(wxSocketBase& wxsocket) = 0;
|
||||
|
||||
// these functions enable or disable monitoring of the given socket for the
|
||||
// specified events inside the currently running event loop (but notice
|
||||
// that both BSD and Winsock implementations actually use socket->m_server
|
||||
// value to determine what exactly should be monitored so it needs to be
|
||||
// set before calling these functions)
|
||||
//
|
||||
// the default event value is used just for the convenience of wxMSW
|
||||
// implementation which doesn't use this parameter anyhow, it doesn't make
|
||||
// sense to pass wxSOCKET_LOST for the Unix implementation which does use
|
||||
// this parameter
|
||||
virtual void Install_Callback(wxSocketImpl *socket,
|
||||
wxSocketNotify event = wxSOCKET_LOST) = 0;
|
||||
virtual void Uninstall_Callback(wxSocketImpl *socket,
|
||||
wxSocketNotify event = wxSOCKET_LOST) = 0;
|
||||
|
||||
virtual ~wxSocketManager() { }
|
||||
|
||||
private:
|
||||
// get the manager to use if we don't have it yet
|
||||
static void Init();
|
||||
|
||||
static wxSocketManager *ms_manager;
|
||||
};
|
||||
|
||||
/*
|
||||
Base class for all socket implementations providing functionality common to
|
||||
BSD and Winsock sockets.
|
||||
|
||||
Objects of this class are not created directly but only via the factory
|
||||
function wxSocketManager::CreateSocket().
|
||||
*/
|
||||
class wxSocketImpl
|
||||
{
|
||||
public:
|
||||
virtual ~wxSocketImpl();
|
||||
|
||||
// set various socket properties: all of those can only be called before
|
||||
// creating the socket
|
||||
void SetTimeout(unsigned long millisec);
|
||||
void SetReusable() { m_reusable = true; }
|
||||
void SetBroadcast() { m_broadcast = true; }
|
||||
void DontDoBind() { m_dobind = false; }
|
||||
void SetInitialSocketBuffers(int recv, int send)
|
||||
{
|
||||
m_initialRecvBufferSize = recv;
|
||||
m_initialSendBufferSize = send;
|
||||
}
|
||||
|
||||
wxSocketError SetLocal(const wxSockAddressImpl& address);
|
||||
wxSocketError SetPeer(const wxSockAddressImpl& address);
|
||||
|
||||
// accessors
|
||||
// ---------
|
||||
|
||||
bool IsServer() const { return m_server; }
|
||||
|
||||
const wxSockAddressImpl& GetLocal(); // non const as may update m_local
|
||||
const wxSockAddressImpl& GetPeer() const { return m_peer; }
|
||||
|
||||
wxSocketError GetError() const { return m_error; }
|
||||
bool IsOk() const { return m_error == wxSOCKET_NOERROR; }
|
||||
|
||||
// get the error code corresponding to the last operation
|
||||
virtual wxSocketError GetLastError() const = 0;
|
||||
|
||||
|
||||
// creating/closing the socket
|
||||
// --------------------------
|
||||
|
||||
// notice that SetLocal() must be called before creating the socket using
|
||||
// any of the functions below
|
||||
//
|
||||
// all of Create() functions return wxSOCKET_NOERROR if the operation
|
||||
// completed successfully or one of:
|
||||
// wxSOCKET_INVSOCK - the socket is in use.
|
||||
// wxSOCKET_INVADDR - the local (server) or peer (client) address has not
|
||||
// been set.
|
||||
// wxSOCKET_IOERR - any other error.
|
||||
|
||||
// create a socket listening on the local address specified by SetLocal()
|
||||
// (notice that DontDoBind() is ignored by this function)
|
||||
wxSocketError CreateServer();
|
||||
|
||||
// create a socket connected to the peer address specified by SetPeer()
|
||||
// (notice that DontDoBind() is ignored by this function)
|
||||
//
|
||||
// this function may return wxSOCKET_WOULDBLOCK in addition to the return
|
||||
// values listed above if wait is false
|
||||
wxSocketError CreateClient(bool wait);
|
||||
|
||||
// create (and bind unless DontDoBind() had been called) an UDP socket
|
||||
// associated with the given local address
|
||||
wxSocketError CreateUDP();
|
||||
|
||||
// may be called whether the socket was created or not, calls DoClose() if
|
||||
// it was indeed created
|
||||
void Close();
|
||||
|
||||
// shuts down the writing end of the socket and closes it, this is a more
|
||||
// graceful way to close
|
||||
//
|
||||
// does nothing if the socket wasn't created
|
||||
void Shutdown();
|
||||
|
||||
|
||||
// IO operations
|
||||
// -------------
|
||||
|
||||
// basic IO, work for both TCP and UDP sockets
|
||||
//
|
||||
// return the number of bytes read/written (possibly 0) or -1 on error
|
||||
int Read(void *buffer, int size);
|
||||
int Write(const void *buffer, int size);
|
||||
|
||||
// basically a wrapper for select(): returns the condition of the socket,
|
||||
// blocking for not longer than timeout if it is specified (otherwise just
|
||||
// poll without blocking at all)
|
||||
//
|
||||
// flags defines what kind of conditions we're interested in, the return
|
||||
// value is composed of a (possibly empty) subset of the bits set in flags
|
||||
wxSocketEventFlags Select(wxSocketEventFlags flags,
|
||||
const timeval *timeout = NULL);
|
||||
|
||||
// convenient wrapper calling Select() with our default timeout
|
||||
wxSocketEventFlags SelectWithTimeout(wxSocketEventFlags flags)
|
||||
{
|
||||
return Select(flags, &m_timeout);
|
||||
}
|
||||
|
||||
// just a wrapper for accept(): it is called to create a new wxSocketImpl
|
||||
// corresponding to a new server connection represented by the given
|
||||
// wxSocketBase, returns NULL on error (including immediately if there are
|
||||
// no pending connections as our sockets are non-blocking)
|
||||
wxSocketImpl *Accept(wxSocketBase& wxsocket);
|
||||
|
||||
|
||||
// notifications
|
||||
// -------------
|
||||
|
||||
// notify m_wxsocket about the given socket event by calling its (inaptly
|
||||
// named) OnRequest() method
|
||||
void NotifyOnStateChange(wxSocketNotify event);
|
||||
|
||||
// called after reading/writing the data from/to the socket and should
|
||||
// enable back the wxSOCKET_INPUT/OUTPUT_FLAG notifications if they were
|
||||
// turned off when this data was first detected
|
||||
virtual void ReenableEvents(wxSocketEventFlags flags) = 0;
|
||||
|
||||
// TODO: make these fields protected and provide accessors for those of
|
||||
// them that wxSocketBase really needs
|
||||
//protected:
|
||||
SOCKET m_fd;
|
||||
|
||||
int m_initialRecvBufferSize;
|
||||
int m_initialSendBufferSize;
|
||||
|
||||
wxSockAddressImpl m_local,
|
||||
m_peer;
|
||||
wxSocketError m_error;
|
||||
|
||||
bool m_stream;
|
||||
bool m_establishing;
|
||||
bool m_reusable;
|
||||
bool m_broadcast;
|
||||
bool m_dobind;
|
||||
|
||||
struct timeval m_timeout;
|
||||
|
||||
protected:
|
||||
wxSocketImpl(wxSocketBase& wxsocket);
|
||||
|
||||
// true if we're a listening stream socket
|
||||
bool m_server;
|
||||
|
||||
private:
|
||||
// called by Close() if we have a valid m_fd
|
||||
virtual void DoClose() = 0;
|
||||
|
||||
// put this socket into non-blocking mode and enable monitoring this socket
|
||||
// as part of the event loop
|
||||
virtual void UnblockAndRegisterWithEventLoop() = 0;
|
||||
|
||||
// check that the socket wasn't created yet and that the given address
|
||||
// (either m_local or m_peer depending on the socket kind) is valid and
|
||||
// set m_error and return false if this is not the case
|
||||
bool PreCreateCheck(const wxSockAddressImpl& addr);
|
||||
|
||||
// set the given socket option: this just wraps setsockopt(SOL_SOCKET)
|
||||
int SetSocketOption(int optname, int optval)
|
||||
{
|
||||
// although modern Unix systems use "const void *" for the 4th
|
||||
// parameter here, old systems and Winsock still use "const char *"
|
||||
return setsockopt(m_fd, SOL_SOCKET, optname,
|
||||
reinterpret_cast<const char *>(&optval),
|
||||
sizeof(optval));
|
||||
}
|
||||
|
||||
// set the given socket option to true value: this is an even simpler
|
||||
// wrapper for setsockopt(SOL_SOCKET) for boolean options
|
||||
int EnableSocketOption(int optname)
|
||||
{
|
||||
return SetSocketOption(optname, 1);
|
||||
}
|
||||
|
||||
// apply the options to the (just created) socket and register it with the
|
||||
// event loop by calling UnblockAndRegisterWithEventLoop()
|
||||
void PostCreation();
|
||||
|
||||
// update local address after binding/connecting
|
||||
wxSocketError UpdateLocalAddress();
|
||||
|
||||
// functions used to implement Read/Write()
|
||||
int RecvStream(void *buffer, int size);
|
||||
int RecvDgram(void *buffer, int size);
|
||||
int SendStream(const void *buffer, int size);
|
||||
int SendDgram(const void *buffer, int size);
|
||||
|
||||
|
||||
// set in ctor and never changed except that it's reset to NULL when the
|
||||
// socket is shut down
|
||||
wxSocketBase *m_wxsocket;
|
||||
|
||||
wxDECLARE_NO_COPY_CLASS(wxSocketImpl);
|
||||
};
|
||||
|
||||
#if defined(__WXMSW__)
|
||||
#include "wx/msw/private/sockmsw.h"
|
||||
#else
|
||||
#include "wx/unix/private/sockunix.h"
|
||||
#endif
|
||||
|
||||
#endif /* wxUSE_SOCKETS */
|
||||
|
||||
#endif /* _WX_PRIVATE_SOCKET_H_ */
|
54
Externals/wxWidgets3/include/wx/private/threadinfo.h
vendored
Normal file
54
Externals/wxWidgets3/include/wx/private/threadinfo.h
vendored
Normal file
@ -0,0 +1,54 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/private/threadinfo.h
|
||||
// Purpose: declaration of wxThreadSpecificInfo: thread-specific information
|
||||
// Author: Vadim Zeitlin
|
||||
// Created: 2009-07-13
|
||||
// RCS-ID: $Id: threadinfo.h 67232 2011-03-18 15:10:15Z DS $
|
||||
// Copyright: (c) 2009 Vadim Zeitlin <vadim@wxwidgets.org>
|
||||
// Licence: wxWindows licence
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_PRIVATE_THREADINFO_H_
|
||||
#define _WX_PRIVATE_THREADINFO_H_
|
||||
|
||||
#if wxUSE_THREADS
|
||||
|
||||
#include "wx/tls.h"
|
||||
|
||||
class WXDLLIMPEXP_FWD_BASE wxLog;
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxThreadSpecificInfo: contains all thread-specific information used by wx
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// currently the only thread-specific information we use is the active wxLog
|
||||
// target but more could be added in the future (e.g. current wxLocale would be
|
||||
// a likely candidate) and we will group all of them in this struct to avoid
|
||||
// consuming more TLS slots than necessary as there is only a limited number of
|
||||
// them
|
||||
|
||||
// NB: this must be a POD to be stored in TLS
|
||||
struct wxThreadSpecificInfo
|
||||
{
|
||||
// the thread-specific logger or NULL if the thread is using the global one
|
||||
// (this is not used for the main thread which always uses the global
|
||||
// logger)
|
||||
wxLog *logger;
|
||||
|
||||
// true if logging is currently disabled for this thread (this is also not
|
||||
// used for the main thread which uses wxLog::ms_doLog)
|
||||
//
|
||||
// NB: we use a counter-intuitive "disabled" flag instead of "enabled" one
|
||||
// because the default, for 0-initialized struct, should be to enable
|
||||
// logging
|
||||
bool loggingDisabled;
|
||||
};
|
||||
|
||||
// currently this is defined in src/common/log.cpp
|
||||
extern wxTLS_TYPE(wxThreadSpecificInfo) wxThreadInfoVar;
|
||||
#define wxThreadInfo wxTLS_VALUE(wxThreadInfoVar)
|
||||
|
||||
#endif // wxUSE_THREADS
|
||||
|
||||
#endif // _WX_PRIVATE_THREADINFO_H_
|
||||
|
73
Externals/wxWidgets3/include/wx/private/timer.h
vendored
Normal file
73
Externals/wxWidgets3/include/wx/private/timer.h
vendored
Normal file
@ -0,0 +1,73 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/private/timer.h
|
||||
// Purpose: Base class for wxTimer implementations
|
||||
// Author: Lukasz Michalski <lmichalski@sf.net>
|
||||
// Created: 31.10.2006
|
||||
// RCS-ID: $Id: timer.h 67254 2011-03-20 00:14:35Z DS $
|
||||
// Copyright: (c) 2006-2007 wxWidgets dev team
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_TIMERIMPL_H_BASE_
|
||||
#define _WX_TIMERIMPL_H_BASE_
|
||||
|
||||
#include "wx/defs.h"
|
||||
#include "wx/event.h"
|
||||
#include "wx/timer.h"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxTimerImpl: abstract base class for wxTimer implementations
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class WXDLLIMPEXP_BASE wxTimerImpl
|
||||
{
|
||||
public:
|
||||
// default ctor, SetOwner() must be called after it (wxTimer does it)
|
||||
wxTimerImpl(wxTimer *owner);
|
||||
|
||||
// this must be called initially but may be also called later
|
||||
void SetOwner(wxEvtHandler *owner, int timerid);
|
||||
|
||||
// empty but virtual base class dtor, the caller is responsible for
|
||||
// stopping the timer before it's destroyed (it can't be done from here as
|
||||
// it's too late)
|
||||
virtual ~wxTimerImpl() { }
|
||||
|
||||
|
||||
// start the timer. When overriding call base version first.
|
||||
virtual bool Start(int milliseconds = -1, bool oneShot = false);
|
||||
|
||||
// stop the timer, only called if the timer is really running (unlike
|
||||
// wxTimer::Stop())
|
||||
virtual void Stop() = 0;
|
||||
|
||||
// return true if the timer is running
|
||||
virtual bool IsRunning() const = 0;
|
||||
|
||||
// this should be called by the port-specific code when the timer expires
|
||||
virtual void Notify() { m_timer->Notify(); }
|
||||
|
||||
// the default implementation of wxTimer::Notify(): generate a wxEVT_TIMER
|
||||
void SendEvent();
|
||||
|
||||
|
||||
// accessors for wxTimer:
|
||||
wxEvtHandler *GetOwner() const { return m_owner; }
|
||||
int GetId() const { return m_idTimer; }
|
||||
int GetInterval() const { return m_milli; }
|
||||
bool IsOneShot() const { return m_oneShot; }
|
||||
|
||||
protected:
|
||||
wxTimer *m_timer;
|
||||
|
||||
wxEvtHandler *m_owner;
|
||||
|
||||
int m_idTimer; // id passed to wxTimerEvent
|
||||
int m_milli; // the timer interval
|
||||
bool m_oneShot; // true if one shot
|
||||
|
||||
|
||||
wxDECLARE_NO_COPY_CLASS(wxTimerImpl);
|
||||
};
|
||||
|
||||
#endif // _WX_TIMERIMPL_H_BASE_
|
39
Externals/wxWidgets3/include/wx/private/window.h
vendored
Normal file
39
Externals/wxWidgets3/include/wx/private/window.h
vendored
Normal file
@ -0,0 +1,39 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/private/window.h
|
||||
// Purpose: misc wxWindow helpers
|
||||
// Author: Vaclav Slavik
|
||||
// Created: 2010-01-21
|
||||
// RCS-ID: $Id: window.h 63251 2010-01-24 11:51:09Z VS $
|
||||
// Copyright: (c) 2010 Vaclav Slavik
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_PRIVATE_WINDOW_H_
|
||||
#define _WX_PRIVATE_WINDOW_H_
|
||||
|
||||
#include "wx/gdicmn.h"
|
||||
|
||||
namespace wxPrivate
|
||||
{
|
||||
|
||||
// Windows' computes dialog units using average character width over upper-
|
||||
// and lower-case ASCII alphabet and not using the average character width
|
||||
// metadata stored in the font; see
|
||||
// http://support.microsoft.com/default.aspx/kb/145994 for detailed discussion.
|
||||
//
|
||||
// This helper function computes font dimensions in the same way. It works with
|
||||
// either wxDC or wxWindow argument.
|
||||
template<typename T>
|
||||
inline wxSize GetAverageASCIILetterSize(const T& of_what)
|
||||
{
|
||||
const wxStringCharType *TEXT_TO_MEASURE =
|
||||
wxS("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz");
|
||||
|
||||
wxSize s = of_what.GetTextExtent(TEXT_TO_MEASURE);
|
||||
s.x = (s.x / 26 + 1) / 2;
|
||||
return s;
|
||||
}
|
||||
|
||||
} // namespace wxPrivate
|
||||
|
||||
#endif // _WX_PRIVATE_WINDOW_H_
|
940
Externals/wxWidgets3/include/wx/private/wxprintf.h
vendored
Normal file
940
Externals/wxWidgets3/include/wx/private/wxprintf.h
vendored
Normal file
@ -0,0 +1,940 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/private/wxprintf.h
|
||||
// Purpose: wxWidgets wxPrintf() implementation
|
||||
// Author: Ove Kaven
|
||||
// Modified by: Ron Lee, Francesco Montorsi
|
||||
// Created: 09/04/99
|
||||
// RCS-ID: $Id: wxprintf.h 65690 2010-09-30 14:30:35Z VZ $
|
||||
// Copyright: (c) wxWidgets copyright
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_PRIVATE_WXPRINTF_H_
|
||||
#define _WX_PRIVATE_WXPRINTF_H_
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// headers and macros
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
#include "wx/crt.h"
|
||||
#include "wx/log.h"
|
||||
#include "wx/utils.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#if defined(__MWERKS__) && __MSL__ >= 0x6000
|
||||
namespace std {}
|
||||
using namespace std ;
|
||||
#endif
|
||||
|
||||
// prefer snprintf over sprintf
|
||||
#if defined(__VISUALC__) || \
|
||||
(defined(__BORLANDC__) && __BORLANDC__ >= 0x540)
|
||||
#define system_sprintf(buff, max, flags, data) \
|
||||
::_snprintf(buff, max, flags, data)
|
||||
#elif defined(HAVE_SNPRINTF)
|
||||
#define system_sprintf(buff, max, flags, data) \
|
||||
::snprintf(buff, max, flags, data)
|
||||
#else // NB: at least sprintf() should always be available
|
||||
// since 'max' is not used in this case, wxVsnprintf() should always
|
||||
// ensure that 'buff' is big enough for all common needs
|
||||
// (see wxMAX_SVNPRINTF_FLAGBUFFER_LEN and wxMAX_SVNPRINTF_SCRATCHBUFFER_LEN)
|
||||
#define system_sprintf(buff, max, flags, data) \
|
||||
::sprintf(buff, flags, data)
|
||||
|
||||
#define SYSTEM_SPRINTF_IS_UNSAFE
|
||||
#endif
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// printf format string parsing
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
// some limits of our implementation
|
||||
#define wxMAX_SVNPRINTF_ARGUMENTS 64
|
||||
#define wxMAX_SVNPRINTF_FLAGBUFFER_LEN 32
|
||||
#define wxMAX_SVNPRINTF_SCRATCHBUFFER_LEN 512
|
||||
|
||||
|
||||
// the conversion specifiers accepted by wxCRT_VsnprintfW
|
||||
enum wxPrintfArgType
|
||||
{
|
||||
wxPAT_INVALID = -1,
|
||||
|
||||
wxPAT_INT, // %d, %i, %o, %u, %x, %X
|
||||
wxPAT_LONGINT, // %ld, etc
|
||||
#ifdef wxLongLong_t
|
||||
wxPAT_LONGLONGINT, // %Ld, etc
|
||||
#endif
|
||||
wxPAT_SIZET, // %zd, etc
|
||||
|
||||
wxPAT_DOUBLE, // %e, %E, %f, %g, %G
|
||||
wxPAT_LONGDOUBLE, // %le, etc
|
||||
|
||||
wxPAT_POINTER, // %p
|
||||
|
||||
wxPAT_CHAR, // %hc (in ANSI mode: %c, too)
|
||||
wxPAT_WCHAR, // %lc (in Unicode mode: %c, too)
|
||||
|
||||
wxPAT_PCHAR, // %s (related to a char *)
|
||||
wxPAT_PWCHAR, // %s (related to a wchar_t *)
|
||||
|
||||
wxPAT_NINT, // %n
|
||||
wxPAT_NSHORTINT, // %hn
|
||||
wxPAT_NLONGINT, // %ln
|
||||
|
||||
wxPAT_STAR // '*' used for width or precision
|
||||
};
|
||||
|
||||
// an argument passed to wxCRT_VsnprintfW
|
||||
union wxPrintfArg
|
||||
{
|
||||
int pad_int; // %d, %i, %o, %u, %x, %X
|
||||
long int pad_longint; // %ld, etc
|
||||
#ifdef wxLongLong_t
|
||||
wxLongLong_t pad_longlongint; // %Ld, etc
|
||||
#endif
|
||||
size_t pad_sizet; // %zd, etc
|
||||
|
||||
double pad_double; // %e, %E, %f, %g, %G
|
||||
long double pad_longdouble; // %le, etc
|
||||
|
||||
void *pad_pointer; // %p
|
||||
|
||||
char pad_char; // %hc (in ANSI mode: %c, too)
|
||||
wchar_t pad_wchar; // %lc (in Unicode mode: %c, too)
|
||||
|
||||
void *pad_str; // %s
|
||||
|
||||
int *pad_nint; // %n
|
||||
short int *pad_nshortint; // %hn
|
||||
long int *pad_nlongint; // %ln
|
||||
};
|
||||
|
||||
// helper for converting string into either char* or wchar_t* depending
|
||||
// on the type of wxPrintfConvSpec<T> instantiation:
|
||||
template<typename CharType> struct wxPrintfStringHelper {};
|
||||
|
||||
template<> struct wxPrintfStringHelper<char>
|
||||
{
|
||||
typedef const wxWX2MBbuf ConvertedType;
|
||||
static ConvertedType Convert(const wxString& s) { return s.mb_str(); }
|
||||
};
|
||||
|
||||
template<> struct wxPrintfStringHelper<wchar_t>
|
||||
{
|
||||
typedef const wxWX2WCbuf ConvertedType;
|
||||
static ConvertedType Convert(const wxString& s) { return s.wc_str(); }
|
||||
};
|
||||
|
||||
|
||||
// Contains parsed data relative to a conversion specifier given to
|
||||
// wxCRT_VsnprintfW and parsed from the format string
|
||||
// NOTE: in C++ there is almost no difference between struct & classes thus
|
||||
// there is no performance gain by using a struct here...
|
||||
template<typename CharType>
|
||||
class wxPrintfConvSpec
|
||||
{
|
||||
public:
|
||||
|
||||
// the position of the argument relative to this conversion specifier
|
||||
size_t m_pos;
|
||||
|
||||
// the type of this conversion specifier
|
||||
wxPrintfArgType m_type;
|
||||
|
||||
// the minimum and maximum width
|
||||
// when one of this var is set to -1 it means: use the following argument
|
||||
// in the stack as minimum/maximum width for this conversion specifier
|
||||
int m_nMinWidth, m_nMaxWidth;
|
||||
|
||||
// does the argument need to the be aligned to left ?
|
||||
bool m_bAlignLeft;
|
||||
|
||||
// pointer to the '%' of this conversion specifier in the format string
|
||||
// NOTE: this points somewhere in the string given to the Parse() function -
|
||||
// it's task of the caller ensure that memory is still valid !
|
||||
const CharType *m_pArgPos;
|
||||
|
||||
// pointer to the last character of this conversion specifier in the
|
||||
// format string
|
||||
// NOTE: this points somewhere in the string given to the Parse() function -
|
||||
// it's task of the caller ensure that memory is still valid !
|
||||
const CharType *m_pArgEnd;
|
||||
|
||||
// a little buffer where formatting flags like #+\.hlqLz are stored by Parse()
|
||||
// for use in Process()
|
||||
char m_szFlags[wxMAX_SVNPRINTF_FLAGBUFFER_LEN];
|
||||
|
||||
|
||||
public:
|
||||
|
||||
// we don't declare this as a constructor otherwise it would be called
|
||||
// automatically and we don't want this: to be optimized, wxCRT_VsnprintfW
|
||||
// calls this function only on really-used instances of this class.
|
||||
void Init();
|
||||
|
||||
// Parses the first conversion specifier in the given string, which must
|
||||
// begin with a '%'. Returns false if the first '%' does not introduce a
|
||||
// (valid) conversion specifier and thus should be ignored.
|
||||
bool Parse(const CharType *format);
|
||||
|
||||
// Process this conversion specifier and puts the result in the given
|
||||
// buffer. Returns the number of characters written in 'buf' or -1 if
|
||||
// there's not enough space.
|
||||
int Process(CharType *buf, size_t lenMax, wxPrintfArg *p, size_t written);
|
||||
|
||||
// Loads the argument of this conversion specifier from given va_list.
|
||||
bool LoadArg(wxPrintfArg *p, va_list &argptr);
|
||||
|
||||
private:
|
||||
// An helper function of LoadArg() which is used to handle the '*' flag
|
||||
void ReplaceAsteriskWith(int w);
|
||||
};
|
||||
|
||||
template<typename CharType>
|
||||
void wxPrintfConvSpec<CharType>::Init()
|
||||
{
|
||||
m_nMinWidth = 0;
|
||||
m_nMaxWidth = 0xFFFF;
|
||||
m_pos = 0;
|
||||
m_bAlignLeft = false;
|
||||
m_pArgPos = m_pArgEnd = NULL;
|
||||
m_type = wxPAT_INVALID;
|
||||
|
||||
memset(m_szFlags, 0, sizeof(m_szFlags));
|
||||
// this character will never be removed from m_szFlags array and
|
||||
// is important when calling sprintf() in wxPrintfConvSpec::Process() !
|
||||
m_szFlags[0] = '%';
|
||||
}
|
||||
|
||||
template<typename CharType>
|
||||
bool wxPrintfConvSpec<CharType>::Parse(const CharType *format)
|
||||
{
|
||||
bool done = false;
|
||||
|
||||
// temporary parse data
|
||||
size_t flagofs = 1;
|
||||
bool in_prec, // true if we found the dot in some previous iteration
|
||||
prec_dot; // true if the dot has been already added to m_szFlags
|
||||
int ilen = 0;
|
||||
|
||||
m_bAlignLeft = in_prec = prec_dot = false;
|
||||
m_pArgPos = m_pArgEnd = format;
|
||||
do
|
||||
{
|
||||
#define CHECK_PREC \
|
||||
if (in_prec && !prec_dot) \
|
||||
{ \
|
||||
m_szFlags[flagofs++] = '.'; \
|
||||
prec_dot = true; \
|
||||
}
|
||||
|
||||
// what follows '%'?
|
||||
const CharType ch = *(++m_pArgEnd);
|
||||
switch ( ch )
|
||||
{
|
||||
case wxT('\0'):
|
||||
return false; // not really an argument
|
||||
|
||||
case wxT('%'):
|
||||
return false; // not really an argument
|
||||
|
||||
case wxT('#'):
|
||||
case wxT('0'):
|
||||
case wxT(' '):
|
||||
case wxT('+'):
|
||||
case wxT('\''):
|
||||
CHECK_PREC
|
||||
m_szFlags[flagofs++] = char(ch);
|
||||
break;
|
||||
|
||||
case wxT('-'):
|
||||
CHECK_PREC
|
||||
m_bAlignLeft = true;
|
||||
m_szFlags[flagofs++] = char(ch);
|
||||
break;
|
||||
|
||||
case wxT('.'):
|
||||
// don't use CHECK_PREC here to avoid warning about the value
|
||||
// assigned to prec_dot inside it being never used (because
|
||||
// overwritten just below) from Borland in release build
|
||||
if (in_prec && !prec_dot)
|
||||
m_szFlags[flagofs++] = '.';
|
||||
in_prec = true;
|
||||
prec_dot = false;
|
||||
m_nMaxWidth = 0;
|
||||
// dot will be auto-added to m_szFlags if non-negative
|
||||
// number follows
|
||||
break;
|
||||
|
||||
case wxT('h'):
|
||||
ilen = -1;
|
||||
CHECK_PREC
|
||||
m_szFlags[flagofs++] = char(ch);
|
||||
break;
|
||||
|
||||
case wxT('l'):
|
||||
// NB: it's safe to use flagofs-1 as flagofs always start from 1
|
||||
if (m_szFlags[flagofs-1] == 'l') // 'll' modifier is the same as 'L' or 'q'
|
||||
ilen = 2;
|
||||
else
|
||||
ilen = 1;
|
||||
CHECK_PREC
|
||||
m_szFlags[flagofs++] = char(ch);
|
||||
break;
|
||||
|
||||
case wxT('q'):
|
||||
case wxT('L'):
|
||||
ilen = 2;
|
||||
CHECK_PREC
|
||||
m_szFlags[flagofs++] = char(ch);
|
||||
break;
|
||||
#ifdef __WXMSW__
|
||||
// under Windows we support the special '%I64' notation as longlong
|
||||
// integer conversion specifier for MSVC compatibility
|
||||
// (it behaves exactly as '%lli' or '%Li' or '%qi')
|
||||
case wxT('I'):
|
||||
if (*(m_pArgEnd+1) == wxT('6') &&
|
||||
*(m_pArgEnd+2) == wxT('4'))
|
||||
{
|
||||
m_pArgEnd++;
|
||||
m_pArgEnd++;
|
||||
|
||||
ilen = 2;
|
||||
CHECK_PREC
|
||||
m_szFlags[flagofs++] = char(ch);
|
||||
m_szFlags[flagofs++] = '6';
|
||||
m_szFlags[flagofs++] = '4';
|
||||
break;
|
||||
}
|
||||
// else: fall-through, 'I' is MSVC equivalent of C99 'z'
|
||||
#endif // __WXMSW__
|
||||
|
||||
case wxT('z'):
|
||||
case wxT('Z'):
|
||||
// 'z' is C99 standard for size_t and ptrdiff_t, 'Z' was used
|
||||
// for this purpose in libc5 and by wx <= 2.8
|
||||
ilen = 3;
|
||||
CHECK_PREC
|
||||
m_szFlags[flagofs++] = char(ch);
|
||||
break;
|
||||
|
||||
case wxT('*'):
|
||||
if (in_prec)
|
||||
{
|
||||
CHECK_PREC
|
||||
|
||||
// tell Process() to use the next argument
|
||||
// in the stack as maxwidth...
|
||||
m_nMaxWidth = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
// tell Process() to use the next argument
|
||||
// in the stack as minwidth...
|
||||
m_nMinWidth = -1;
|
||||
}
|
||||
|
||||
// save the * in our formatting buffer...
|
||||
// will be replaced later by Process()
|
||||
m_szFlags[flagofs++] = char(ch);
|
||||
break;
|
||||
|
||||
case wxT('1'): case wxT('2'): case wxT('3'):
|
||||
case wxT('4'): case wxT('5'): case wxT('6'):
|
||||
case wxT('7'): case wxT('8'): case wxT('9'):
|
||||
{
|
||||
int len = 0;
|
||||
CHECK_PREC
|
||||
while ( (*m_pArgEnd >= CharType('0')) &&
|
||||
(*m_pArgEnd <= CharType('9')) )
|
||||
{
|
||||
m_szFlags[flagofs++] = char(*m_pArgEnd);
|
||||
len = len*10 + (*m_pArgEnd - wxT('0'));
|
||||
m_pArgEnd++;
|
||||
}
|
||||
|
||||
if (in_prec)
|
||||
m_nMaxWidth = len;
|
||||
else
|
||||
m_nMinWidth = len;
|
||||
|
||||
m_pArgEnd--; // the main loop pre-increments n again
|
||||
}
|
||||
break;
|
||||
|
||||
case wxT('$'): // a positional parameter (e.g. %2$s) ?
|
||||
{
|
||||
if (m_nMinWidth <= 0)
|
||||
break; // ignore this formatting flag as no
|
||||
// numbers are preceding it
|
||||
|
||||
// remove from m_szFlags all digits previously added
|
||||
do {
|
||||
flagofs--;
|
||||
} while (m_szFlags[flagofs] >= '1' &&
|
||||
m_szFlags[flagofs] <= '9');
|
||||
|
||||
// re-adjust the offset making it point to the
|
||||
// next free char of m_szFlags
|
||||
flagofs++;
|
||||
|
||||
m_pos = m_nMinWidth;
|
||||
m_nMinWidth = 0;
|
||||
}
|
||||
break;
|
||||
|
||||
case wxT('d'):
|
||||
case wxT('i'):
|
||||
case wxT('o'):
|
||||
case wxT('u'):
|
||||
case wxT('x'):
|
||||
case wxT('X'):
|
||||
CHECK_PREC
|
||||
m_szFlags[flagofs++] = char(ch);
|
||||
if (ilen == 0)
|
||||
m_type = wxPAT_INT;
|
||||
else if (ilen == -1)
|
||||
// NB: 'short int' value passed through '...'
|
||||
// is promoted to 'int', so we have to get
|
||||
// an int from stack even if we need a short
|
||||
m_type = wxPAT_INT;
|
||||
else if (ilen == 1)
|
||||
m_type = wxPAT_LONGINT;
|
||||
else if (ilen == 2)
|
||||
#ifdef wxLongLong_t
|
||||
m_type = wxPAT_LONGLONGINT;
|
||||
#else // !wxLongLong_t
|
||||
m_type = wxPAT_LONGINT;
|
||||
#endif // wxLongLong_t/!wxLongLong_t
|
||||
else if (ilen == 3)
|
||||
m_type = wxPAT_SIZET;
|
||||
done = true;
|
||||
break;
|
||||
|
||||
case wxT('e'):
|
||||
case wxT('E'):
|
||||
case wxT('f'):
|
||||
case wxT('g'):
|
||||
case wxT('G'):
|
||||
CHECK_PREC
|
||||
m_szFlags[flagofs++] = char(ch);
|
||||
if (ilen == 2)
|
||||
m_type = wxPAT_LONGDOUBLE;
|
||||
else
|
||||
m_type = wxPAT_DOUBLE;
|
||||
done = true;
|
||||
break;
|
||||
|
||||
case wxT('p'):
|
||||
m_type = wxPAT_POINTER;
|
||||
m_szFlags[flagofs++] = char(ch);
|
||||
done = true;
|
||||
break;
|
||||
|
||||
case wxT('c'):
|
||||
if (ilen == -1)
|
||||
{
|
||||
// in Unicode mode %hc == ANSI character
|
||||
// and in ANSI mode, %hc == %c == ANSI...
|
||||
m_type = wxPAT_CHAR;
|
||||
}
|
||||
else if (ilen == 1)
|
||||
{
|
||||
// in ANSI mode %lc == Unicode character
|
||||
// and in Unicode mode, %lc == %c == Unicode...
|
||||
m_type = wxPAT_WCHAR;
|
||||
}
|
||||
else
|
||||
{
|
||||
#if wxUSE_UNICODE
|
||||
// in Unicode mode, %c == Unicode character
|
||||
m_type = wxPAT_WCHAR;
|
||||
#else
|
||||
// in ANSI mode, %c == ANSI character
|
||||
m_type = wxPAT_CHAR;
|
||||
#endif
|
||||
}
|
||||
done = true;
|
||||
break;
|
||||
|
||||
case wxT('s'):
|
||||
if (ilen == -1)
|
||||
{
|
||||
// Unicode mode wx extension: we'll let %hs mean non-Unicode
|
||||
// strings (when in ANSI mode, %s == %hs == ANSI string)
|
||||
m_type = wxPAT_PCHAR;
|
||||
}
|
||||
else if (ilen == 1)
|
||||
{
|
||||
// in Unicode mode, %ls == %s == Unicode string
|
||||
// in ANSI mode, %ls == Unicode string
|
||||
m_type = wxPAT_PWCHAR;
|
||||
}
|
||||
else
|
||||
{
|
||||
#if wxUSE_UNICODE
|
||||
m_type = wxPAT_PWCHAR;
|
||||
#else
|
||||
m_type = wxPAT_PCHAR;
|
||||
#endif
|
||||
}
|
||||
done = true;
|
||||
break;
|
||||
|
||||
case wxT('n'):
|
||||
if (ilen == 0)
|
||||
m_type = wxPAT_NINT;
|
||||
else if (ilen == -1)
|
||||
m_type = wxPAT_NSHORTINT;
|
||||
else if (ilen >= 1)
|
||||
m_type = wxPAT_NLONGINT;
|
||||
done = true;
|
||||
break;
|
||||
|
||||
default:
|
||||
// bad format, don't consider this an argument;
|
||||
// leave it unchanged
|
||||
return false;
|
||||
}
|
||||
|
||||
if (flagofs == wxMAX_SVNPRINTF_FLAGBUFFER_LEN)
|
||||
{
|
||||
wxLogDebug(wxT("Too many flags specified for a single conversion specifier!"));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
while (!done);
|
||||
|
||||
return true; // parsing was successful
|
||||
}
|
||||
|
||||
template<typename CharType>
|
||||
void wxPrintfConvSpec<CharType>::ReplaceAsteriskWith(int width)
|
||||
{
|
||||
char temp[wxMAX_SVNPRINTF_FLAGBUFFER_LEN];
|
||||
|
||||
// find the first * in our flag buffer
|
||||
char *pwidth = strchr(m_szFlags, '*');
|
||||
wxCHECK_RET(pwidth, wxT("field width must be specified"));
|
||||
|
||||
// save what follows the * (the +1 is to skip the asterisk itself!)
|
||||
strcpy(temp, pwidth+1);
|
||||
if (width < 0)
|
||||
{
|
||||
pwidth[0] = wxT('-');
|
||||
pwidth++;
|
||||
}
|
||||
|
||||
// replace * with the actual integer given as width
|
||||
#ifndef SYSTEM_SPRINTF_IS_UNSAFE
|
||||
int maxlen = (m_szFlags + wxMAX_SVNPRINTF_FLAGBUFFER_LEN - pwidth) /
|
||||
sizeof(*m_szFlags);
|
||||
#endif
|
||||
int offset = system_sprintf(pwidth, maxlen, "%d", abs(width));
|
||||
|
||||
// restore after the expanded * what was following it
|
||||
strcpy(pwidth+offset, temp);
|
||||
}
|
||||
|
||||
template<typename CharType>
|
||||
bool wxPrintfConvSpec<CharType>::LoadArg(wxPrintfArg *p, va_list &argptr)
|
||||
{
|
||||
// did the '*' width/precision specifier was used ?
|
||||
if (m_nMaxWidth == -1)
|
||||
{
|
||||
// take the maxwidth specifier from the stack
|
||||
m_nMaxWidth = va_arg(argptr, int);
|
||||
if (m_nMaxWidth < 0)
|
||||
m_nMaxWidth = 0;
|
||||
else
|
||||
ReplaceAsteriskWith(m_nMaxWidth);
|
||||
}
|
||||
|
||||
if (m_nMinWidth == -1)
|
||||
{
|
||||
// take the minwidth specifier from the stack
|
||||
m_nMinWidth = va_arg(argptr, int);
|
||||
|
||||
ReplaceAsteriskWith(m_nMinWidth);
|
||||
if (m_nMinWidth < 0)
|
||||
{
|
||||
m_bAlignLeft = !m_bAlignLeft;
|
||||
m_nMinWidth = -m_nMinWidth;
|
||||
}
|
||||
}
|
||||
|
||||
switch (m_type) {
|
||||
case wxPAT_INT:
|
||||
p->pad_int = va_arg(argptr, int);
|
||||
break;
|
||||
case wxPAT_LONGINT:
|
||||
p->pad_longint = va_arg(argptr, long int);
|
||||
break;
|
||||
#ifdef wxLongLong_t
|
||||
case wxPAT_LONGLONGINT:
|
||||
p->pad_longlongint = va_arg(argptr, wxLongLong_t);
|
||||
break;
|
||||
#endif // wxLongLong_t
|
||||
case wxPAT_SIZET:
|
||||
p->pad_sizet = va_arg(argptr, size_t);
|
||||
break;
|
||||
case wxPAT_DOUBLE:
|
||||
p->pad_double = va_arg(argptr, double);
|
||||
break;
|
||||
case wxPAT_LONGDOUBLE:
|
||||
p->pad_longdouble = va_arg(argptr, long double);
|
||||
break;
|
||||
case wxPAT_POINTER:
|
||||
p->pad_pointer = va_arg(argptr, void *);
|
||||
break;
|
||||
|
||||
case wxPAT_CHAR:
|
||||
p->pad_char = (char)va_arg(argptr, int); // char is promoted to int when passed through '...'
|
||||
break;
|
||||
case wxPAT_WCHAR:
|
||||
p->pad_wchar = (wchar_t)va_arg(argptr, int); // char is promoted to int when passed through '...'
|
||||
break;
|
||||
|
||||
case wxPAT_PCHAR:
|
||||
case wxPAT_PWCHAR:
|
||||
p->pad_str = va_arg(argptr, void *);
|
||||
break;
|
||||
|
||||
case wxPAT_NINT:
|
||||
p->pad_nint = va_arg(argptr, int *);
|
||||
break;
|
||||
case wxPAT_NSHORTINT:
|
||||
p->pad_nshortint = va_arg(argptr, short int *);
|
||||
break;
|
||||
case wxPAT_NLONGINT:
|
||||
p->pad_nlongint = va_arg(argptr, long int *);
|
||||
break;
|
||||
|
||||
case wxPAT_STAR:
|
||||
// this will be handled as part of the next argument
|
||||
return true;
|
||||
|
||||
case wxPAT_INVALID:
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
return true; // loading was successful
|
||||
}
|
||||
|
||||
template<typename CharType>
|
||||
int wxPrintfConvSpec<CharType>::Process(CharType *buf, size_t lenMax, wxPrintfArg *p, size_t written)
|
||||
{
|
||||
// buffer to avoid dynamic memory allocation each time for small strings;
|
||||
// note that this buffer is used only to hold results of number formatting,
|
||||
// %s directly writes user's string in buf, without using szScratch
|
||||
char szScratch[wxMAX_SVNPRINTF_SCRATCHBUFFER_LEN];
|
||||
size_t lenScratch = 0, lenCur = 0;
|
||||
|
||||
#define APPEND_CH(ch) \
|
||||
{ \
|
||||
if ( lenCur == lenMax ) \
|
||||
return -1; \
|
||||
\
|
||||
buf[lenCur++] = ch; \
|
||||
}
|
||||
|
||||
switch ( m_type )
|
||||
{
|
||||
case wxPAT_INT:
|
||||
lenScratch = system_sprintf(szScratch, wxMAX_SVNPRINTF_SCRATCHBUFFER_LEN, m_szFlags, p->pad_int);
|
||||
break;
|
||||
|
||||
case wxPAT_LONGINT:
|
||||
lenScratch = system_sprintf(szScratch, wxMAX_SVNPRINTF_SCRATCHBUFFER_LEN, m_szFlags, p->pad_longint);
|
||||
break;
|
||||
|
||||
#ifdef wxLongLong_t
|
||||
case wxPAT_LONGLONGINT:
|
||||
lenScratch = system_sprintf(szScratch, wxMAX_SVNPRINTF_SCRATCHBUFFER_LEN, m_szFlags, p->pad_longlongint);
|
||||
break;
|
||||
#endif // SIZEOF_LONG_LONG
|
||||
|
||||
case wxPAT_SIZET:
|
||||
lenScratch = system_sprintf(szScratch, wxMAX_SVNPRINTF_SCRATCHBUFFER_LEN, m_szFlags, p->pad_sizet);
|
||||
break;
|
||||
|
||||
case wxPAT_LONGDOUBLE:
|
||||
lenScratch = system_sprintf(szScratch, wxMAX_SVNPRINTF_SCRATCHBUFFER_LEN, m_szFlags, p->pad_longdouble);
|
||||
break;
|
||||
|
||||
case wxPAT_DOUBLE:
|
||||
lenScratch = system_sprintf(szScratch, wxMAX_SVNPRINTF_SCRATCHBUFFER_LEN, m_szFlags, p->pad_double);
|
||||
break;
|
||||
|
||||
case wxPAT_POINTER:
|
||||
lenScratch = system_sprintf(szScratch, wxMAX_SVNPRINTF_SCRATCHBUFFER_LEN, m_szFlags, p->pad_pointer);
|
||||
break;
|
||||
|
||||
case wxPAT_CHAR:
|
||||
case wxPAT_WCHAR:
|
||||
{
|
||||
wxUniChar ch;
|
||||
if (m_type == wxPAT_CHAR)
|
||||
ch = p->pad_char;
|
||||
else // m_type == wxPAT_WCHAR
|
||||
ch = p->pad_wchar;
|
||||
|
||||
CharType val = ch;
|
||||
|
||||
size_t i;
|
||||
|
||||
if (!m_bAlignLeft)
|
||||
for (i = 1; i < (size_t)m_nMinWidth; i++)
|
||||
APPEND_CH(wxT(' '));
|
||||
|
||||
APPEND_CH(val);
|
||||
|
||||
if (m_bAlignLeft)
|
||||
for (i = 1; i < (size_t)m_nMinWidth; i++)
|
||||
APPEND_CH(wxT(' '));
|
||||
}
|
||||
break;
|
||||
|
||||
case wxPAT_PCHAR:
|
||||
case wxPAT_PWCHAR:
|
||||
{
|
||||
wxString s;
|
||||
if ( !p->pad_str )
|
||||
{
|
||||
if ( m_nMaxWidth >= 6 )
|
||||
s = wxT("(null)");
|
||||
}
|
||||
else if (m_type == wxPAT_PCHAR)
|
||||
s.assign(static_cast<const char *>(p->pad_str));
|
||||
else // m_type == wxPAT_PWCHAR
|
||||
s.assign(static_cast<const wchar_t *>(p->pad_str));
|
||||
|
||||
typename wxPrintfStringHelper<CharType>::ConvertedType strbuf(
|
||||
wxPrintfStringHelper<CharType>::Convert(s));
|
||||
|
||||
// at this point we are sure that m_nMaxWidth is positive or
|
||||
// null (see top of wxPrintfConvSpec::LoadArg)
|
||||
int len = wxMin((unsigned int)m_nMaxWidth, wxStrlen(strbuf));
|
||||
|
||||
int i;
|
||||
|
||||
if (!m_bAlignLeft)
|
||||
{
|
||||
for (i = len; i < m_nMinWidth; i++)
|
||||
APPEND_CH(wxT(' '));
|
||||
}
|
||||
|
||||
len = wxMin((unsigned int)len, lenMax-lenCur);
|
||||
wxStrncpy(buf+lenCur, strbuf, len);
|
||||
lenCur += len;
|
||||
|
||||
if (m_bAlignLeft)
|
||||
{
|
||||
for (i = len; i < m_nMinWidth; i++)
|
||||
APPEND_CH(wxT(' '));
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case wxPAT_NINT:
|
||||
*p->pad_nint = written;
|
||||
break;
|
||||
|
||||
case wxPAT_NSHORTINT:
|
||||
*p->pad_nshortint = (short int)written;
|
||||
break;
|
||||
|
||||
case wxPAT_NLONGINT:
|
||||
*p->pad_nlongint = written;
|
||||
break;
|
||||
|
||||
case wxPAT_INVALID:
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
|
||||
// if we used system's sprintf() then we now need to append the s_szScratch
|
||||
// buffer to the given one...
|
||||
switch (m_type)
|
||||
{
|
||||
case wxPAT_INT:
|
||||
case wxPAT_LONGINT:
|
||||
#ifdef wxLongLong_t
|
||||
case wxPAT_LONGLONGINT:
|
||||
#endif
|
||||
case wxPAT_SIZET:
|
||||
case wxPAT_LONGDOUBLE:
|
||||
case wxPAT_DOUBLE:
|
||||
case wxPAT_POINTER:
|
||||
wxASSERT(lenScratch < wxMAX_SVNPRINTF_SCRATCHBUFFER_LEN);
|
||||
// NB: 1) we can compare lenMax (for CharType*, i.e. possibly
|
||||
// wchar_t*) with lenScratch (char*) because this code is
|
||||
// formatting integers and that will have the same length
|
||||
// even in UTF-8 (the only case when char* length may be
|
||||
// more than wchar_t* length of the same string)
|
||||
// 2) wxStrncpy converts the 2nd argument to 1st argument's
|
||||
// type transparently if their types differ, so this code
|
||||
// works for both instantiations
|
||||
if (lenMax < lenScratch)
|
||||
{
|
||||
// fill output buffer and then return -1
|
||||
wxStrncpy(buf, szScratch, lenMax);
|
||||
return -1;
|
||||
}
|
||||
wxStrncpy(buf, szScratch, lenScratch);
|
||||
lenCur += lenScratch;
|
||||
break;
|
||||
|
||||
default:
|
||||
break; // all other cases were completed previously
|
||||
}
|
||||
|
||||
return lenCur;
|
||||
}
|
||||
|
||||
|
||||
// helper that parses format string
|
||||
template<typename CharType>
|
||||
struct wxPrintfConvSpecParser
|
||||
{
|
||||
typedef wxPrintfConvSpec<CharType> ConvSpec;
|
||||
|
||||
wxPrintfConvSpecParser(const CharType *fmt)
|
||||
{
|
||||
nargs = 0;
|
||||
posarg_present =
|
||||
nonposarg_present = false;
|
||||
|
||||
memset(pspec, 0, sizeof(pspec));
|
||||
|
||||
// parse the format string
|
||||
for ( const CharType *toparse = fmt; *toparse != wxT('\0'); toparse++ )
|
||||
{
|
||||
// skip everything except format specifications
|
||||
if ( *toparse != '%' )
|
||||
continue;
|
||||
|
||||
// also skip escaped percent signs
|
||||
if ( toparse[1] == '%' )
|
||||
{
|
||||
toparse++;
|
||||
continue;
|
||||
}
|
||||
|
||||
ConvSpec *spec = &specs[nargs];
|
||||
spec->Init();
|
||||
|
||||
// attempt to parse this format specification
|
||||
if ( !spec->Parse(toparse) )
|
||||
continue;
|
||||
|
||||
// advance to the end of this specifier
|
||||
toparse = spec->m_pArgEnd;
|
||||
|
||||
// special handling for specifications including asterisks: we need
|
||||
// to reserve an extra slot (or two if asterisks were used for both
|
||||
// width and precision) in specs array in this case
|
||||
if ( const char *f = strchr(spec->m_szFlags, '*') )
|
||||
{
|
||||
unsigned numAsterisks = 1;
|
||||
if ( strchr(++f, '*') )
|
||||
numAsterisks++;
|
||||
|
||||
for ( unsigned n = 0; n < numAsterisks; n++ )
|
||||
{
|
||||
if ( nargs++ == wxMAX_SVNPRINTF_ARGUMENTS )
|
||||
break;
|
||||
|
||||
// TODO: we need to support specifiers of the form "%2$*1$s"
|
||||
// (this is the same as "%*s") as if any positional arguments
|
||||
// are used all asterisks must be positional as well but this
|
||||
// requires a lot of changes in this code (basically we'd need
|
||||
// to rewrite Parse() to return "*" and conversion itself as
|
||||
// separate entries)
|
||||
if ( posarg_present )
|
||||
{
|
||||
wxFAIL_MSG
|
||||
(
|
||||
wxString::Format
|
||||
(
|
||||
"Format string \"%s\" uses both positional "
|
||||
"parameters and '*' but this is not currently "
|
||||
"supported by this implementation, sorry.",
|
||||
fmt
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
specs[nargs] = *spec;
|
||||
|
||||
// make an entry for '*' and point to it from pspec
|
||||
spec->Init();
|
||||
spec->m_type = wxPAT_STAR;
|
||||
pspec[nargs - 1] = spec;
|
||||
|
||||
spec = &specs[nargs];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// check if this is a positional or normal argument
|
||||
if ( spec->m_pos > 0 )
|
||||
{
|
||||
// the positional arguments start from number 1 so we need
|
||||
// to adjust the index
|
||||
spec->m_pos--;
|
||||
posarg_present = true;
|
||||
}
|
||||
else // not a positional argument...
|
||||
{
|
||||
spec->m_pos = nargs;
|
||||
nonposarg_present = true;
|
||||
}
|
||||
|
||||
// this conversion specifier is tied to the pos-th argument...
|
||||
pspec[spec->m_pos] = spec;
|
||||
|
||||
if ( nargs++ == wxMAX_SVNPRINTF_ARGUMENTS )
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
// warn if we lost any arguments (the program probably will crash
|
||||
// anyhow because of stack corruption...)
|
||||
if ( nargs == wxMAX_SVNPRINTF_ARGUMENTS )
|
||||
{
|
||||
wxFAIL_MSG
|
||||
(
|
||||
wxString::Format
|
||||
(
|
||||
"wxVsnprintf() currently supports only %d arguments, "
|
||||
"but format string \"%s\" defines more of them.\n"
|
||||
"You need to change wxMAX_SVNPRINTF_ARGUMENTS and "
|
||||
"recompile if more are really needed.",
|
||||
fmt, wxMAX_SVNPRINTF_ARGUMENTS
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// total number of valid elements in specs
|
||||
unsigned nargs;
|
||||
|
||||
// all format specifications in this format string in order of their
|
||||
// appearance (which may be different from arguments order)
|
||||
ConvSpec specs[wxMAX_SVNPRINTF_ARGUMENTS];
|
||||
|
||||
// pointer to specs array element for the N-th argument
|
||||
ConvSpec *pspec[wxMAX_SVNPRINTF_ARGUMENTS];
|
||||
|
||||
// true if any positional/non-positional parameters are used
|
||||
bool posarg_present,
|
||||
nonposarg_present;
|
||||
};
|
||||
|
||||
#undef APPEND_CH
|
||||
#undef CHECK_PREC
|
||||
|
||||
#endif // _WX_PRIVATE_WXPRINTF_H_
|
Reference in New Issue
Block a user