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:
Soren Jorvang
2011-03-20 18:05:19 +00:00
parent 205637ccc3
commit d14efe561b
1945 changed files with 694474 additions and 0 deletions

View File

@ -0,0 +1,55 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/unix/app.h
// Purpose: wxAppConsole implementation for Unix
// Author: Lukasz Michalski
// Created: 28/01/2005
// RCS-ID: $Id: app.h 56994 2008-11-28 12:47:07Z VZ $
// Copyright: (c) Lukasz Michalski
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
//Ensure that sigset_t is being defined
#include <signal.h>
// wxApp subclass implementing event processing for console applications
class WXDLLIMPEXP_BASE wxAppConsole : public wxAppConsoleBase
{
public:
// override base class initialization
virtual bool Initialize(int& argc, wxChar** argv);
// Unix-specific: Unix signal handling
// -----------------------------------
// type of the function which can be registered as signal handler: notice
// that it isn't really a signal handler, i.e. it's not subject to the
// usual signal handlers constraints, because it is called later from
// CheckSignal() and not when the signal really occurs
typedef void (*SignalHandler)(int);
// Set signal handler for the given signal, SIG_DFL or SIG_IGN can be used
// instead of a function pointer
//
// Return true if handler was installed, false on error
bool SetSignalHandler(int signal, SignalHandler handler);
// Check if any Unix signals arrived since the last call and execute
// handlers for them
void CheckSignal();
private:
// signal handler set up by SetSignalHandler() for all signals we handle,
// it just adds the signal to m_signalsCaught -- the real processing is
// done later, when CheckSignal() is called
static void HandleSignal(int signal);
// signals for which HandleSignal() had been called (reset from
// CheckSignal())
sigset_t m_signalsCaught;
// the signal handlers
WX_DECLARE_HASH_MAP(int, SignalHandler, wxIntegerHash, wxIntegerEqual, SignalHandlerHash);
SignalHandlerHash m_signalHandlerHash;
};

View File

@ -0,0 +1,67 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/unix/apptbase.h
// Purpose: declaration of wxAppTraits for Unix systems
// Author: Vadim Zeitlin
// Modified by:
// Created: 23.06.2003
// RCS-ID: $Id: apptbase.h 61688 2009-08-17 23:02:46Z VZ $
// Copyright: (c) 2003 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_UNIX_APPTBASE_H_
#define _WX_UNIX_APPTBASE_H_
struct wxEndProcessData;
struct wxExecuteData;
class wxFDIOManager;
// ----------------------------------------------------------------------------
// wxAppTraits: the Unix version adds extra hooks needed by Unix code
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_BASE wxAppTraits : public wxAppTraitsBase
{
public:
// wxExecute() support methods
// ---------------------------
// wait for the process termination, return whatever wxExecute() must
// return
//
// base class implementation handles all cases except wxEXEC_SYNC without
// wxEXEC_NOEVENTS one which is implemented at the GUI level
virtual int WaitForChild(wxExecuteData& execData);
// integrate the monitoring of the given fd with the port-specific event
// loop: when this fd, which corresponds to a dummy pipe opened between the
// parent and child processes, is closed by the child, the parent is
// notified about this via a call to wxHandleProcessTermination() function
//
// the default implementation uses wxFDIODispatcher and so is suitable for
// the console applications or ports which don't have any specific event
// loop
virtual int AddProcessCallback(wxEndProcessData *data, int fd);
#if wxUSE_SOCKETS
// return a pointer to the object which should be used to integrate
// monitoring of the file descriptors to the event loop (currently this is
// used for the sockets only but should be used for arbitrary event loop
// sources in the future)
//
// this object may be different for the console and GUI applications
//
// the pointer is not deleted by the caller as normally it points to a
// static variable
virtual wxFDIOManager *GetFDIOManager();
#endif // wxUSE_SOCKETS
protected:
// a helper for the implementation of WaitForChild() in wxGUIAppTraits:
// checks the streams used for redirected IO in execData and returns true
// if there is any activity in them
bool CheckForRedirectedIO(wxExecuteData& execData);
};
#endif // _WX_UNIX_APPTBASE_H_

View File

@ -0,0 +1,100 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/unix/apptrait.h
// Purpose: standard implementations of wxAppTraits for Unix
// Author: Vadim Zeitlin
// Modified by:
// Created: 23.06.2003
// RCS-ID: $Id: apptrait.h 61688 2009-08-17 23:02:46Z VZ $
// Copyright: (c) 2003 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_UNIX_APPTRAIT_H_
#define _WX_UNIX_APPTRAIT_H_
// ----------------------------------------------------------------------------
// wxGUI/ConsoleAppTraits: must derive from wxAppTraits, not wxAppTraitsBase
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_BASE wxConsoleAppTraits : public wxConsoleAppTraitsBase
{
public:
#if wxUSE_CONSOLE_EVENTLOOP
virtual wxEventLoopBase *CreateEventLoop();
#endif // wxUSE_CONSOLE_EVENTLOOP
#if wxUSE_TIMER
virtual wxTimerImpl *CreateTimerImpl(wxTimer *timer);
#endif
};
#if wxUSE_GUI
// GTK+ and Motif integrate sockets and child processes monitoring directly in
// their main loop, the other Unix ports do it at wxEventLoop level and so use
// the non-GUI traits and don't need anything here
//
// TODO: Should we use XtAddInput() for wxX11 too? Or, vice versa, if there is
// no advantage in doing this compared to the generic way currently used
// by wxX11, should we continue to use GTK/Motif-specific stuff?
#if defined(__WXGTK__) || defined(__WXMOTIF__)
#define wxHAS_GUI_FDIOMANAGER
#define wxHAS_GUI_PROCESS_CALLBACKS
#endif // ports using wxFDIOManager
#if defined(__WXMAC__)
#define wxHAS_GUI_PROCESS_CALLBACKS
#define wxHAS_GUI_SOCKET_MANAGER
#endif
class WXDLLIMPEXP_CORE wxGUIAppTraits : public wxGUIAppTraitsBase
{
public:
virtual wxEventLoopBase *CreateEventLoop();
virtual int WaitForChild(wxExecuteData& execData);
#ifdef wxHAS_GUI_PROCESS_CALLBACKS
virtual int AddProcessCallback(wxEndProcessData *data, int fd);
#endif
#if wxUSE_TIMER
virtual wxTimerImpl *CreateTimerImpl(wxTimer *timer);
#endif
#if wxUSE_THREADS && defined(__WXGTK20__)
virtual void MutexGuiEnter();
virtual void MutexGuiLeave();
#endif
#if (defined(__WXMAC__) || defined(__WXCOCOA__)) && wxUSE_STDPATHS
virtual wxStandardPaths& GetStandardPaths();
#endif
virtual wxPortId GetToolkitVersion(int *majVer = NULL, int *minVer = NULL) const;
#if defined(__WXGTK__) && wxUSE_INTL
virtual void SetLocale();
#endif // __WXGTK__
#ifdef __WXGTK20__
virtual wxString GetDesktopEnvironment() const;
virtual wxString GetStandardCmdLineOptions(wxArrayString& names,
wxArrayString& desc) const;
#endif // __WXGTK20____
#if defined(__WXGTK20__)
virtual bool ShowAssertDialog(const wxString& msg);
#endif
#if wxUSE_SOCKETS
#ifdef wxHAS_GUI_SOCKET_MANAGER
virtual wxSocketManager *GetSocketManager();
#endif
#ifdef wxHAS_GUI_FDIOMANAGER
virtual wxFDIOManager *GetFDIOManager();
#endif
#endif // wxUSE_SOCKETS
};
#endif // wxUSE_GUI
#endif // _WX_UNIX_APPTRAIT_H_

View File

@ -0,0 +1,44 @@
/*
* Name: wx/unix/chkconf.h
* Purpose: Unix-specific config settings consistency checks
* Author: Vadim Zeitlin
* Created: 2007-07-14
* RCS-ID: $Id: chkconf.h 63306 2010-01-29 13:07:26Z VZ $
* Copyright: (c) 2007 Vadim Zeitlin <vadim@wxwidgets.org>
* Licence: wxWindows licence
*/
/* THIS IS A C FILE, DON'T USE C++ FEATURES (IN PARTICULAR COMMENTS) IN IT */
#if wxUSE_CONSOLE_EVENTLOOP
# if !wxUSE_SELECT_DISPATCHER && !wxUSE_EPOLL_DISPATCHER
# ifdef wxABORT_ON_CONFIG_ERROR
# error "wxSelect/EpollDispatcher needed for console event loop"
# else
# undef wxUSE_SELECT_DISPATCHER
# define wxUSE_SELECT_DISPATCHER 1
# endif
# endif
#endif /* wxUSE_CONSOLE_EVENTLOOP */
#if wxUSE_FSWATCHER
# if !defined(wxHAS_INOTIFY) && !defined(wxHAS_KQUEUE)
# ifdef wxABORT_ON_CONFIG_ERROR
# error "wxFileSystemWatcher requires either inotify() or kqueue()"
# else
# undef wxUSE_FSWATCHER
# define wxUSE_FSWATCHER 0
# endif
# endif
#endif /* wxUSE_FSWATCHER */
#if wxUSE_GSTREAMER
# if !wxUSE_THREADS
# ifdef wxABORT_ON_CONFIG_ERROR
# error "GStreamer requires threads"
# else
# undef wxUSE_GSTREAMER
# define wxUSE_GSTREAMER 0
# endif
# endif
#endif /* wxUSE_GSTREAMER */

View File

@ -0,0 +1,69 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/unix/evtloop.h
// Purpose: declares wxEventLoop class
// Author: Lukasz Michalski (lm@zork.pl)
// Created: 2007-05-07
// RCS-ID: $Id: evtloop.h 65680 2010-09-30 11:44:45Z VZ $
// Copyright: (c) 2007 Lukasz Michalski
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_UNIX_EVTLOOP_H_
#define _WX_UNIX_EVTLOOP_H_
#if wxUSE_CONSOLE_EVENTLOOP
// ----------------------------------------------------------------------------
// wxConsoleEventLoop
// ----------------------------------------------------------------------------
class wxFDIODispatcher;
class wxUnixEventLoopSource;
namespace wxPrivate
{
class PipeIOHandler;
}
class WXDLLIMPEXP_BASE wxConsoleEventLoop
#ifdef __WXOSX__
: public wxCFEventLoop
#else
: public wxEventLoopManual
#endif
{
public:
// initialize the event loop, use IsOk() to check if we were successful
wxConsoleEventLoop();
virtual ~wxConsoleEventLoop();
// implement base class pure virtuals
virtual bool Pending() const;
virtual bool Dispatch();
virtual int DispatchTimeout(unsigned long timeout);
virtual void WakeUp();
virtual bool IsOk() const { return m_dispatcher != NULL; }
virtual bool YieldFor(long WXUNUSED(eventsToProcess)) { return true; }
#if wxUSE_EVENTLOOP_SOURCE
virtual wxEventLoopSource *
AddSourceForFD(int fd, wxEventLoopSourceHandler *handler, int flags);
#endif // wxUSE_EVENTLOOP_SOURCE
protected:
virtual void OnNextIteration();
private:
// pipe used for wake up messages: when a child thread wants to wake up
// the event loop in the main thread it writes to this pipe
wxPrivate::PipeIOHandler *m_wakeupPipe;
// either wxSelectDispatcher or wxEpollDispatcher
wxFDIODispatcher *m_dispatcher;
wxDECLARE_NO_COPY_CLASS(wxConsoleEventLoop);
};
#endif // wxUSE_CONSOLE_EVENTLOOP
#endif // _WX_UNIX_EVTLOOP_H_

View File

@ -0,0 +1,49 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/unix/evtloopsrc.h
// Purpose: wxUnixEventLoopSource class
// Author: Vadim Zeitlin
// Created: 2009-10-21
// RCS-ID: $Id: evtloopsrc.h 64140 2010-04-25 21:33:16Z FM $
// Copyright: (c) 2009 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_UNIX_EVTLOOPSRC_H_
#define _WX_UNIX_EVTLOOPSRC_H_
class wxFDIODispatcher;
class wxFDIOHandler;
// ----------------------------------------------------------------------------
// wxUnixEventLoopSource: wxEventLoopSource for Unix-like toolkits using fds
// ----------------------------------------------------------------------------
class wxUnixEventLoopSource : public wxEventLoopSource
{
public:
// dispatcher and fdioHandler are only used here to allow us to unregister
// from the event loop when we're destroyed
wxUnixEventLoopSource(wxFDIODispatcher *dispatcher,
wxFDIOHandler *fdioHandler,
int fd,
wxEventLoopSourceHandler *handler,
int flags)
: wxEventLoopSource(handler, flags),
m_dispatcher(dispatcher),
m_fdioHandler(fdioHandler),
m_fd(fd)
{
}
virtual ~wxUnixEventLoopSource();
private:
wxFDIODispatcher * const m_dispatcher;
wxFDIOHandler * const m_fdioHandler;
const int m_fd;
wxDECLARE_NO_COPY_CLASS(wxUnixEventLoopSource);
};
#endif // _WX_UNIX_EVTLOOPSRC_H_

View File

@ -0,0 +1,94 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/unix/execute.h
// Purpose: private details of wxExecute() implementation
// Author: Vadim Zeitlin
// Id: $Id: execute.h 67254 2011-03-20 00:14:35Z DS $
// Copyright: (c) 1998 Robert Roebling, Julian Smart, Vadim Zeitlin
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_UNIX_EXECUTE_H
#define _WX_UNIX_EXECUTE_H
#include "wx/unix/pipe.h"
class WXDLLIMPEXP_FWD_BASE wxProcess;
class wxStreamTempInputBuffer;
struct wxEndProcessData
{
wxEndProcessData()
{
pid =
tag =
exitcode = -1;
process = NULL;
async = false;
}
int pid; // pid of the process
int tag; // port dependent value
wxProcess *process; // if !NULL: notified on process termination
int exitcode; // the exit code
bool async; // if true, delete us on process termination
};
// struct in which information is passed from wxExecute() to wxAppTraits
// methods
struct wxExecuteData
{
wxExecuteData()
{
flags =
pid = 0;
process = NULL;
#if wxUSE_STREAMS
bufOut =
bufErr = NULL;
fdOut =
fdErr = wxPipe::INVALID_FD;
#endif // wxUSE_STREAMS
}
// get the FD corresponding to the read end of the process end detection
// pipe and close the write one
int GetEndProcReadFD()
{
const int fd = pipeEndProcDetect.Detach(wxPipe::Read);
pipeEndProcDetect.Close();
return fd;
}
// wxExecute() flags
int flags;
// the pid of the child process
int pid;
// the associated process object or NULL
wxProcess *process;
// pipe used for end process detection
wxPipe pipeEndProcDetect;
#if wxUSE_STREAMS
// the input buffer bufOut is connected to stdout, this is why it is
// called bufOut and not bufIn
wxStreamTempInputBuffer *bufOut,
*bufErr;
// the corresponding FDs, -1 if not redirected
int fdOut,
fdErr;
#endif // wxUSE_STREAMS
};
// this function is called when the process terminates from port specific
// callback function and is common to all ports (src/unix/utilsunx.cpp)
extern WXDLLIMPEXP_BASE void wxHandleProcessTermination(wxEndProcessData *proc_data);
#endif // _WX_UNIX_EXECUTE_H

View File

@ -0,0 +1,37 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/unix/fontutil.h
// Purpose: font-related helper functions for Unix/X11
// Author: Vadim Zeitlin
// Modified by:
// Created: 05.11.99
// RCS-ID: $Id: fontutil.h 58227 2009-01-19 13:55:27Z VZ $
// Copyright: (c) wxWidgets team
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_UNIX_FONTUTIL_H_
#define _WX_UNIX_FONTUTIL_H_
#ifdef __X__
typedef WXFontStructPtr wxNativeFont;
#elif defined(__WXGTK__)
typedef GdkFont *wxNativeFont;
#else
#error "Unsupported toolkit"
#endif
// returns the handle of the nearest available font or 0
extern wxNativeFont
wxLoadQueryNearestFont(int pointSize,
int family,
int style,
int weight,
bool underlined,
const wxString &facename,
wxFontEncoding encoding,
wxString* xFontName = NULL);
// returns the font specified by the given XLFD
extern wxNativeFont wxLoadFont(const wxString& fontSpec);
#endif // _WX_UNIX_FONTUTIL_H_

View File

@ -0,0 +1,35 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/unix/fswatcher_inotify.h
// Purpose: wxInotifyFileSystemWatcher
// Author: Bartosz Bekier
// Created: 2009-05-26
// RCS-ID: $Id: fswatcher_inotify.h 62474 2009-10-22 11:35:43Z VZ $
// Copyright: (c) 2009 Bartosz Bekier <bartosz.bekier@gmail.com>
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_FSWATCHER_UNIX_H_
#define _WX_FSWATCHER_UNIX_H_
#include "wx/defs.h"
#if wxUSE_FSWATCHER
class WXDLLIMPEXP_BASE wxInotifyFileSystemWatcher :
public wxFileSystemWatcherBase
{
public:
wxInotifyFileSystemWatcher();
wxInotifyFileSystemWatcher(const wxFileName& path,
int events = wxFSW_EVENT_ALL);
virtual ~wxInotifyFileSystemWatcher();
protected:
bool Init();
};
#endif
#endif /* _WX_FSWATCHER_UNIX_H_ */

View File

@ -0,0 +1,35 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/unix/fswatcher_kqueue.h
// Purpose: wxKqueueFileSystemWatcher
// Author: Bartosz Bekier
// Created: 2009-05-26
// RCS-ID: $Id: fswatcher_kqueue.h 62474 2009-10-22 11:35:43Z VZ $
// Copyright: (c) 2009 Bartosz Bekier <bartosz.bekier@gmail.com>
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_FSWATCHER_KQUEUE_H_
#define _WX_FSWATCHER_KQUEUE_H_
#include "wx/defs.h"
#if wxUSE_FSWATCHER
class WXDLLIMPEXP_BASE wxKqueueFileSystemWatcher :
public wxFileSystemWatcherBase
{
public:
wxKqueueFileSystemWatcher();
wxKqueueFileSystemWatcher(const wxFileName& path,
int events = wxFSW_EVENT_ALL);
virtual ~wxKqueueFileSystemWatcher();
protected:
bool Init();
};
#endif
#endif /* _WX_FSWATCHER_OSX_H_ */

View File

@ -0,0 +1,165 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/unix/glx11.h
// Purpose: class common for all X11-based wxGLCanvas implementations
// Author: Vadim Zeitlin
// Created: 2007-04-15
// RCS-ID: $Id: glx11.h 54022 2008-06-08 00:12:12Z VZ $
// Copyright: (c) 2007 Vadim Zeitlin <vadim@wxwindows.org>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_UNIX_GLX11_H_
#define _WX_UNIX_GLX11_H_
#include <GL/glx.h>
// ----------------------------------------------------------------------------
// wxGLContext
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_GL wxGLContext : public wxGLContextBase
{
public:
wxGLContext(wxGLCanvas *win, const wxGLContext *other = NULL);
virtual ~wxGLContext();
virtual bool SetCurrent(const wxGLCanvas& win) const;
private:
// attach context to the drawable or unset it (if NULL)
static bool MakeCurrent(GLXDrawable drawable, GLXContext context);
GLXContext m_glContext;
DECLARE_CLASS(wxGLContext)
};
// ----------------------------------------------------------------------------
// wxGLCanvasX11
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_GL wxGLCanvasX11 : public wxGLCanvasBase
{
public:
// initialization and dtor
// -----------------------
// default ctor doesn't do anything, InitVisual() must be called
wxGLCanvasX11();
// initializes the XVisualInfo corresponding to the given attributes
bool InitVisual(const int *attribList);
// frees XVisualInfo info
virtual ~wxGLCanvasX11();
// implement wxGLCanvasBase methods
// --------------------------------
virtual bool SwapBuffers();
// X11-specific methods
// --------------------
// return GLX version: 13 means 1.3 &c
static int GetGLXVersion();
// return true if multisample extension is available
static bool IsGLXMultiSampleAvailable();
// get the X11 handle of this window
virtual Window GetXWindow() const = 0;
// override some wxWindow methods
// ------------------------------
// return true only if the window is realized: OpenGL context can't be
// created until we are
virtual bool IsShownOnScreen() const;
// implementation only from now on
// -------------------------------
// get the GLXFBConfig/XVisualInfo we use
GLXFBConfig *GetGLXFBConfig() const { return m_fbc; }
XVisualInfo *GetXVisualInfo() const { return m_vi; }
// initialize the global default GL visual, return false if matching visual
// not found
static bool InitDefaultVisualInfo(const int *attribList);
// get the default GL X11 visual (may be NULL, shouldn't be freed by caller)
static XVisualInfo *GetDefaultXVisualInfo() { return ms_glVisualInfo; }
// free the global GL visual, called by wxGLApp
static void FreeDefaultVisualInfo();
// initializes XVisualInfo (in any case) and, if supported, GLXFBConfig
//
// returns false if XVisualInfo couldn't be initialized, otherwise caller
// is responsible for freeing the pointers
static bool InitXVisualInfo(const int *attribList,
GLXFBConfig **pFBC, XVisualInfo **pXVisual);
private:
// fills in glattrs with attributes defined by wxattrs which must be
// 0-terminated if it is non-NULL
//
// n is the max size of glattrs, false is returned if we overflow it, it
// should be at least 16 to accommodate the default attributes
static bool ConvertWXAttrsToGL(const int *wxattrs, int *glattrs, size_t n);
// this is only used if it's supported i.e. if GL >= 1.3
GLXFBConfig *m_fbc;
// used for all GL versions, obtained from GLXFBConfig for GL >= 1.3
XVisualInfo *m_vi;
// the global/default versions of the above
static GLXFBConfig *ms_glFBCInfo;
static XVisualInfo *ms_glVisualInfo;
};
// ----------------------------------------------------------------------------
// wxGLApp
// ----------------------------------------------------------------------------
// this is used in wx/glcanvas.h, prevent it from defining a generic wxGLApp
#define wxGL_APP_DEFINED
class WXDLLIMPEXP_GL wxGLApp : public wxGLAppBase
{
public:
wxGLApp() : wxGLAppBase() { }
// implement wxGLAppBase method
virtual bool InitGLVisual(const int *attribList)
{
return wxGLCanvasX11::InitDefaultVisualInfo(attribList);
}
// and implement this wxGTK::wxApp method too
virtual void *GetXVisualInfo()
{
return wxGLCanvasX11::GetDefaultXVisualInfo();
}
// and override this wxApp method to clean up
virtual int OnExit()
{
wxGLCanvasX11::FreeDefaultVisualInfo();
return wxGLAppBase::OnExit();
}
private:
DECLARE_DYNAMIC_CLASS(wxGLApp)
};
#endif // _WX_UNIX_GLX11_H_

View File

@ -0,0 +1,95 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/unix/joystick.h
// Purpose: wxJoystick class
// Author: Guilhem Lavaux
// Modified by:
// Created: 01/02/97
// RCS-ID: $Id: joystick.h 50443 2007-12-03 02:55:14Z PC $
// Copyright: (c) Guilhem Lavaux
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_UNIX_JOYSTICK_H_
#define _WX_UNIX_JOYSTICK_H_
#include "wx/event.h"
class WXDLLIMPEXP_FWD_CORE wxJoystickThread;
class WXDLLIMPEXP_ADV wxJoystick: public wxObject
{
DECLARE_DYNAMIC_CLASS(wxJoystick)
public:
/*
* Public interface
*/
wxJoystick(int joystick = wxJOYSTICK1);
virtual ~wxJoystick();
// Attributes
////////////////////////////////////////////////////////////////////////////
wxPoint GetPosition() const;
int GetPosition(unsigned axis) const;
bool GetButtonState(unsigned button) const;
int GetZPosition() const;
int GetButtonState() const;
int GetPOVPosition() const;
int GetPOVCTSPosition() const;
int GetRudderPosition() const;
int GetUPosition() const;
int GetVPosition() const;
int GetMovementThreshold() const;
void SetMovementThreshold(int threshold) ;
// Capabilities
////////////////////////////////////////////////////////////////////////////
bool IsOk() const; // Checks that the joystick is functioning
static int GetNumberJoysticks() ;
int GetManufacturerId() const ;
int GetProductId() const ;
wxString GetProductName() const ;
int GetXMin() const;
int GetYMin() const;
int GetZMin() const;
int GetXMax() const;
int GetYMax() const;
int GetZMax() const;
int GetNumberButtons() const;
int GetNumberAxes() const;
int GetMaxButtons() const;
int GetMaxAxes() const;
int GetPollingMin() const;
int GetPollingMax() const;
int GetRudderMin() const;
int GetRudderMax() const;
int GetUMin() const;
int GetUMax() const;
int GetVMin() const;
int GetVMax() const;
bool HasRudder() const;
bool HasZ() const;
bool HasU() const;
bool HasV() const;
bool HasPOV() const;
bool HasPOV4Dir() const;
bool HasPOVCTS() const;
// Operations
////////////////////////////////////////////////////////////////////////////
// pollingFreq = 0 means that movement events are sent when above the threshold.
// If pollingFreq > 0, events are received every this many milliseconds.
bool SetCapture(wxWindow* win, int pollingFreq = 0);
bool ReleaseCapture();
protected:
int m_device;
int m_joystick;
wxJoystickThread* m_thread;
};
#endif // _WX_UNIX_JOYSTICK_H_

View File

@ -0,0 +1,174 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/unix/mimetype.h
// Purpose: classes and functions to manage MIME types
// Author: Vadim Zeitlin
// Modified by:
// Created: 23.09.98
// RCS-ID: $Id: mimetype.h 62356 2009-10-09 17:39:19Z PC $
// Copyright: (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
// Licence: wxWindows licence (part of wxExtra library)
/////////////////////////////////////////////////////////////////////////////
#ifndef _MIMETYPE_IMPL_H
#define _MIMETYPE_IMPL_H
#include "wx/mimetype.h"
#if wxUSE_MIMETYPE
class wxMimeTypeCommands;
WX_DEFINE_ARRAY_PTR(wxMimeTypeCommands *, wxMimeCommandsArray);
// this is the real wxMimeTypesManager for Unix
class WXDLLIMPEXP_BASE wxMimeTypesManagerImpl
{
public:
// ctor and dtor
wxMimeTypesManagerImpl();
virtual ~wxMimeTypesManagerImpl();
// load all data into memory - done when it is needed for the first time
void Initialize(int mailcapStyles = wxMAILCAP_ALL,
const wxString& extraDir = wxEmptyString);
// and delete the data here
void ClearData();
// implement containing class functions
wxFileType *GetFileTypeFromExtension(const wxString& ext);
wxFileType *GetFileTypeFromMimeType(const wxString& mimeType);
size_t EnumAllFileTypes(wxArrayString& mimetypes);
void AddFallback(const wxFileTypeInfo& filetype);
// add information about the given mimetype
void AddMimeTypeInfo(const wxString& mimetype,
const wxString& extensions,
const wxString& description);
void AddMailcapInfo(const wxString& strType,
const wxString& strOpenCmd,
const wxString& strPrintCmd,
const wxString& strTest,
const wxString& strDesc);
// add a new record to the user .mailcap/.mime.types files
wxFileType *Associate(const wxFileTypeInfo& ftInfo);
// remove association
bool Unassociate(wxFileType *ft);
// accessors
// get the string containing space separated extensions for the given
// file type
wxString GetExtension(size_t index) { return m_aExtensions[index]; }
protected:
void InitIfNeeded();
wxArrayString m_aTypes, // MIME types
m_aDescriptions, // descriptions (just some text)
m_aExtensions, // space separated list of extensions
m_aIcons; // Icon filenames
// verb=command pairs for this file type
wxMimeCommandsArray m_aEntries;
// are we initialized?
bool m_initialized;
wxString GetCommand(const wxString &verb, size_t nIndex) const;
// Read XDG *.desktop file
void LoadXDGApp(const wxString& filename);
// Scan XDG directory
void LoadXDGAppsFilesFromDir(const wxString& dirname);
// Load XDG globs files
void LoadXDGGlobs(const wxString& filename);
// functions used to do associations
virtual int AddToMimeData(const wxString& strType,
const wxString& strIcon,
wxMimeTypeCommands *entry,
const wxArrayString& strExtensions,
const wxString& strDesc,
bool replaceExisting = true);
virtual bool DoAssociation(const wxString& strType,
const wxString& strIcon,
wxMimeTypeCommands *entry,
const wxArrayString& strExtensions,
const wxString& strDesc);
// give it access to m_aXXX variables
friend class WXDLLIMPEXP_FWD_BASE wxFileTypeImpl;
};
class WXDLLIMPEXP_BASE wxFileTypeImpl
{
public:
// initialization functions
// this is used to construct a list of mimetypes which match;
// if built with GetFileTypeFromMimetype index 0 has the exact match and
// index 1 the type / * match
// if built with GetFileTypeFromExtension, index 0 has the mimetype for
// the first extension found, index 1 for the second and so on
void Init(wxMimeTypesManagerImpl *manager, size_t index)
{ m_manager = manager; m_index.Add(index); }
// accessors
bool GetExtensions(wxArrayString& extensions);
bool GetMimeType(wxString *mimeType) const
{ *mimeType = m_manager->m_aTypes[m_index[0]]; return true; }
bool GetMimeTypes(wxArrayString& mimeTypes) const;
bool GetIcon(wxIconLocation *iconLoc) const;
bool GetDescription(wxString *desc) const
{ *desc = m_manager->m_aDescriptions[m_index[0]]; return true; }
bool GetOpenCommand(wxString *openCmd,
const wxFileType::MessageParameters& params) const
{
*openCmd = GetExpandedCommand(wxT("open"), params);
return (! openCmd -> IsEmpty() );
}
bool GetPrintCommand(wxString *printCmd,
const wxFileType::MessageParameters& params) const
{
*printCmd = GetExpandedCommand(wxT("print"), params);
return (! printCmd -> IsEmpty() );
}
// return the number of commands defined for this file type, 0 if none
size_t GetAllCommands(wxArrayString *verbs, wxArrayString *commands,
const wxFileType::MessageParameters& params) const;
// remove the record for this file type
// probably a mistake to come here, use wxMimeTypesManager.Unassociate (ft) instead
bool Unassociate(wxFileType *ft)
{
return m_manager->Unassociate(ft);
}
// set an arbitrary command, ask confirmation if it already exists and
// overwriteprompt is TRUE
bool SetCommand(const wxString& cmd, const wxString& verb, bool overwriteprompt = true);
bool SetDefaultIcon(const wxString& strIcon = wxEmptyString, int index = 0);
private:
wxString
GetExpandedCommand(const wxString & verb,
const wxFileType::MessageParameters& params) const;
wxMimeTypesManagerImpl *m_manager;
wxArrayInt m_index; // in the wxMimeTypesManagerImpl arrays
};
#endif // wxUSE_MIMETYPE
#endif // _MIMETYPE_IMPL_H

View File

@ -0,0 +1,138 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/unix/pipe.h
// Purpose: wxPipe class
// Author: Vadim Zeitlin
// Modified by:
// Created: 24.06.2003 (extracted from src/unix/utilsunx.cpp)
// RCS-ID: $Id: pipe.h 66152 2010-11-14 14:04:37Z VZ $
// Copyright: (c) 2003 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_UNIX_PIPE_H_
#define _WX_UNIX_PIPE_H_
#include <unistd.h>
#include "wx/log.h"
#include "wx/intl.h"
// ----------------------------------------------------------------------------
// wxPipe: this class encapsulates pipe() system call
// ----------------------------------------------------------------------------
class wxPipe
{
public:
// the symbolic names for the pipe ends
enum Direction
{
Read,
Write
};
enum
{
INVALID_FD = -1
};
// default ctor doesn't do anything
wxPipe() { m_fds[Read] = m_fds[Write] = INVALID_FD; }
// create the pipe, return TRUE if ok, FALSE on error
bool Create()
{
if ( pipe(m_fds) == -1 )
{
wxLogSysError(_("Pipe creation failed"));
return false;
}
return true;
}
// switch the given end of the pipe to non-blocking IO
bool MakeNonBlocking(Direction which)
{
const int flags = fcntl(m_fds[which], F_GETFL, 0);
if ( flags == -1 )
return false;
return fcntl(m_fds[which], F_SETFL, flags | O_NONBLOCK) == 0;
}
// return TRUE if we were created successfully
bool IsOk() const { return m_fds[Read] != INVALID_FD; }
// return the descriptor for one of the pipe ends
int operator[](Direction which) const { return m_fds[which]; }
// detach a descriptor, meaning that the pipe dtor won't close it, and
// return it
int Detach(Direction which)
{
int fd = m_fds[which];
m_fds[which] = INVALID_FD;
return fd;
}
// close the pipe descriptors
void Close()
{
for ( size_t n = 0; n < WXSIZEOF(m_fds); n++ )
{
if ( m_fds[n] != INVALID_FD )
{
close(m_fds[n]);
m_fds[n] = INVALID_FD;
}
}
}
// dtor closes the pipe descriptors
~wxPipe() { Close(); }
private:
int m_fds[2];
};
#if wxUSE_STREAMS && wxUSE_FILE
#include "wx/wfstream.h"
// ----------------------------------------------------------------------------
// wxPipeInputStream: stream for reading from a pipe
// ----------------------------------------------------------------------------
class wxPipeInputStream : public wxFileInputStream
{
public:
wxPipeInputStream(int fd) : wxFileInputStream(fd) { }
// return TRUE if the pipe is still opened
bool IsOpened() const { return !Eof(); }
// return TRUE if we have anything to read, don't block
virtual bool CanRead() const;
};
// ----------------------------------------------------------------------------
// wxPipeOutputStream: stream for writing to a pipe
// ----------------------------------------------------------------------------
class wxPipeOutputStream : public wxFileOutputStream
{
public:
wxPipeOutputStream(int fd) : wxFileOutputStream(fd) { }
// Override the base class version to ignore "pipe full" errors: this is
// not an error for this class.
size_t OnSysWrite(const void *buffer, size_t size);
};
#endif // wxUSE_STREAMS && wxUSE_FILE
#endif // _WX_UNIX_PIPE_H_

View File

@ -0,0 +1,20 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/unix/private.h
// Purpose: miscellaneous private things for Unix wx ports
// Author: Vadim Zeitlin
// Created: 2005-09-25
// RCS-ID: $Id: private.h 56927 2008-11-23 01:52:20Z VZ $
// Copyright: (c) 2005 Vadim Zeitlin <vadim@wxwindows.org>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_UNIX_PRIVATE_H_
#define _WX_UNIX_PRIVATE_H_
// this file is currently empty as its original contents was moved to
// include/wx/private/fd.h but let's keep it for now in case we need it for
// something again in the future
#include "wx/private/fd.h"
#endif // _WX_UNIX_PRIVATE_H_

View File

@ -0,0 +1,54 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/unix/private/epolldispatcher.h
// Purpose: wxEpollDispatcher class
// Authors: Lukasz Michalski
// Created: April 2007
// Copyright: (c) Lukasz Michalski
// RCS-ID: $Id: epolldispatcher.h 67254 2011-03-20 00:14:35Z DS $
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_PRIVATE_EPOLLDISPATCHER_H_
#define _WX_PRIVATE_EPOLLDISPATCHER_H_
#include "wx/defs.h"
#ifdef wxUSE_EPOLL_DISPATCHER
#include "wx/private/fdiodispatcher.h"
struct epoll_event;
class WXDLLIMPEXP_BASE wxEpollDispatcher : public wxFDIODispatcher
{
public:
// create a new instance of this class, can return NULL if
// epoll() is not supported on this system
//
// the caller should delete the returned pointer
static wxEpollDispatcher *Create();
virtual ~wxEpollDispatcher();
// implement base class pure virtual methods
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:
// ctor is private, use Create()
wxEpollDispatcher(int epollDescriptor);
// common part of HasPending() and Dispatch(): calls epoll_wait() with the
// given timeout
int DoPoll(epoll_event *events, int numEvents, int timeout) const;
int m_epollDescriptor;
};
#endif // wxUSE_EPOLL_DISPATCHER
#endif // _WX_PRIVATE_SOCKETEVTDISPATCH_H_

View File

@ -0,0 +1,28 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/unix/private/fdiounix.h
// Purpose: wxFDIOManagerUnix class used by console Unix applications
// Author: Vadim Zeitlin
// Created: 2009-08-17
// RCS-ID: $Id: fdiounix.h 64140 2010-04-25 21:33:16Z FM $
// Copyright: (c) 2009 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _UNIX_PRIVATE_FDIOUNIX_H_
#define _UNIX_PRIVATE_FDIOUNIX_H_
#include "wx/private/fdiomanager.h"
// ----------------------------------------------------------------------------
// wxFDIOManagerUnix: implement wxFDIOManager interface using wxFDIODispatcher
// ----------------------------------------------------------------------------
class wxFDIOManagerUnix : public wxFDIOManager
{
public:
virtual int AddInput(wxFDIOHandler *handler, int fd, Direction d);
virtual void RemoveInput(wxFDIOHandler *handler, int fd, Direction d);
};
#endif // _UNIX_PRIVATE_FDIOUNIX_H_

View File

@ -0,0 +1,72 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/unix/private/fswatcher_inotify.h
// Purpose: File system watcher impl classes
// Author: Bartosz Bekier
// Created: 2009-05-26
// RCS-ID: $Id: fswatcher_inotify.h 62475 2009-10-22 11:36:35Z VZ $
// Copyright: (c) 2009 Bartosz Bekier <bartosz.bekier@gmail.com>
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef WX_UNIX_PRIVATE_FSWATCHER_INOTIFY_H_
#define WX_UNIX_PRIVATE_FSWATCHER_INOTIFY_H_
#include "wx/filename.h"
#include "wx/evtloopsrc.h"
// ============================================================================
// wxFSWatcherEntry implementation & helper declarations
// ============================================================================
class wxFSWatcherImplUNIX;
class wxFSWatchEntry : public wxFSWatchInfo
{
public:
wxFSWatchEntry(const wxFSWatchInfo& winfo) :
wxFSWatchInfo(winfo)
{
}
int GetWatchDescriptor() const
{
return m_wd;
}
void SetWatchDescriptor(int wd)
{
m_wd = wd;
}
private:
int m_wd;
wxDECLARE_NO_COPY_CLASS(wxFSWatchEntry);
};
// ============================================================================
// wxFSWSourceHandler helper class
// ============================================================================
class wxFSWatcherImplUnix;
/**
* Handler for handling i/o from inotify descriptor
*/
class wxFSWSourceHandler : public wxEventLoopSourceHandler
{
public:
wxFSWSourceHandler(wxFSWatcherImplUnix* service) :
m_service(service)
{ }
virtual void OnReadWaiting();
virtual void OnWriteWaiting();
virtual void OnExceptionWaiting();
protected:
wxFSWatcherImplUnix* m_service;
};
#endif /* WX_UNIX_PRIVATE_FSWATCHER_INOTIFY_H_ */

View File

@ -0,0 +1,109 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/unix/private/fswatcher_kqueue.h
// Purpose: File system watcher impl classes
// Author: Bartosz Bekier
// Created: 2009-05-26
// RCS-ID: $Id: fswatcher_kqueue.h 62475 2009-10-22 11:36:35Z VZ $
// Copyright: (c) 2009 Bartosz Bekier <bartosz.bekier@gmail.com>
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef WX_UNIX_PRIVATE_FSWATCHER_KQUEUE_H_
#define WX_UNIX_PRIVATE_FSWATCHER_KQUEUE_H_
#include <fcntl.h>
#include <unistd.h>
#include "wx/dir.h"
#include "wx/debug.h"
#include "wx/arrstr.h"
// ============================================================================
// wxFSWatcherEntry implementation & helper declarations
// ============================================================================
class wxFSWatcherImplKqueue;
class wxFSWatchEntryKq : public wxFSWatchInfo
{
public:
struct wxDirState
{
wxDirState(const wxFSWatchInfo& winfo)
{
if (!wxDir::Exists(winfo.GetPath()))
return;
wxDir dir(winfo.GetPath());
wxCHECK_RET( dir.IsOpened(),
wxString::Format("Unable to open dir '%s'", winfo.GetPath()));
wxString filename;
bool ret = dir.GetFirst(&filename);
while (ret)
{
files.push_back(filename);
ret = dir.GetNext(&filename);
}
}
wxSortedArrayString files;
};
wxFSWatchEntryKq(const wxFSWatchInfo& winfo) :
wxFSWatchInfo(winfo), m_lastState(winfo)
{
m_fd = wxOpen(m_path, O_RDONLY, 0);
if (m_fd == -1)
{
wxLogSysError(_("Unable to open path '%s'"), m_path);
}
}
virtual ~wxFSWatchEntryKq()
{
(void) Close();
}
bool Close()
{
if (!IsOk())
return false;
int ret = close(m_fd);
if (ret == -1)
{
wxLogSysError(_("Unable to close path '%s'"), m_path);
}
m_fd = -1;
return ret != -1;
}
bool IsOk() const
{
return m_fd != -1;
}
int GetFileDescriptor() const
{
return m_fd;
}
void RefreshState()
{
m_lastState = wxDirState(*this);
}
const wxDirState& GetLastState() const
{
return m_lastState;
}
private:
int m_fd;
wxDirState m_lastState;
wxDECLARE_NO_COPY_CLASS(wxFSWatchEntryKq);
};
#endif /* WX_UNIX_PRIVATE_FSWATCHER_KQUEUE_H_ */

View File

@ -0,0 +1,145 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/unix/private/sockunix.h
// Purpose: wxSocketImpl implementation for Unix systems
// Authors: Guilhem Lavaux, Vadim Zeitlin
// Created: April 1997
// RCS-ID: $Id: sockunix.h 65581 2010-09-21 11:56:53Z VZ $
// Copyright: (c) 1997 Guilhem Lavaux
// (c) 2008 Vadim Zeitlin
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_UNIX_GSOCKUNX_H_
#define _WX_UNIX_GSOCKUNX_H_
#include <unistd.h>
#include <sys/ioctl.h>
// Under older (Open)Solaris versions FIONBIO is declared in this header only.
// In the newer versions it's included by sys/ioctl.h but it's simpler to just
// include it always instead of testing for whether it is or not.
#ifdef __SOLARIS__
#include <sys/filio.h>
#endif
#include "wx/private/fdiomanager.h"
class wxSocketImplUnix : public wxSocketImpl,
public wxFDIOHandler
{
public:
wxSocketImplUnix(wxSocketBase& wxsocket)
: wxSocketImpl(wxsocket)
{
m_fds[0] =
m_fds[1] = -1;
}
virtual wxSocketError GetLastError() const;
virtual void ReenableEvents(wxSocketEventFlags flags)
{
// enable the notifications about input/output being available again in
// case they were disabled by OnRead/WriteWaiting()
//
// notice that we'd like to enable the events here only if there is
// nothing more left on the socket right now as otherwise we're going
// to get a "ready for whatever" notification immediately (well, during
// the next event loop iteration) and disable the event back again
// which is rather inefficient but unfortunately doing it like this
// doesn't work because the existing code (e.g. src/common/sckipc.cpp)
// expects to keep getting notifications about the data available from
// the socket even if it didn't read all the data the last time, so we
// absolutely have to continue generating them
EnableEvents(flags);
}
// wxFDIOHandler methods
virtual void OnReadWaiting();
virtual void OnWriteWaiting();
virtual void OnExceptionWaiting();
virtual bool IsOk() const { return m_fd != INVALID_SOCKET; }
private:
virtual void DoClose()
{
DisableEvents();
close(m_fd);
}
virtual void UnblockAndRegisterWithEventLoop()
{
int trueArg = 1;
ioctl(m_fd, FIONBIO, &trueArg);
EnableEvents();
}
// enable or disable notifications for socket input/output events
void EnableEvents(int flags = wxSOCKET_INPUT_FLAG | wxSOCKET_OUTPUT_FLAG)
{ DoEnableEvents(flags, true); }
void DisableEvents(int flags = wxSOCKET_INPUT_FLAG | wxSOCKET_OUTPUT_FLAG)
{ DoEnableEvents(flags, false); }
// really enable or disable socket input/output events
void DoEnableEvents(int flags, bool enable);
protected:
// descriptors for input and output event notification channels associated
// with the socket
int m_fds[2];
private:
// notify the associated wxSocket about a change in socket state and shut
// down the socket if the event is wxSOCKET_LOST
void OnStateChange(wxSocketNotify event);
// check if there is any input available, return 1 if yes, 0 if no or -1 on
// error
int CheckForInput();
// give it access to our m_fds
friend class wxSocketFDBasedManager;
};
// A version of wxSocketManager which uses FDs for socket IO: it is used by
// Unix console applications and some X11-like ports (wxGTK and wxMotif but not
// wxX11 currently) which implement their own port-specific wxFDIOManagers
class wxSocketFDBasedManager : public wxSocketManager
{
public:
wxSocketFDBasedManager()
{
m_fdioManager = NULL;
}
virtual bool OnInit();
virtual void OnExit() { }
virtual wxSocketImpl *CreateSocket(wxSocketBase& wxsocket)
{
return new wxSocketImplUnix(wxsocket);
}
virtual void Install_Callback(wxSocketImpl *socket_, wxSocketNotify event);
virtual void Uninstall_Callback(wxSocketImpl *socket_, wxSocketNotify event);
protected:
// get the FD index corresponding to the given wxSocketNotify
wxFDIOManager::Direction
GetDirForEvent(wxSocketImpl *socket, wxSocketNotify event);
// access the FDs we store
int& FD(wxSocketImplUnix *socket, wxFDIOManager::Direction d)
{
return socket->m_fds[d];
}
wxFDIOManager *m_fdioManager;
wxDECLARE_NO_COPY_CLASS(wxSocketFDBasedManager);
};
#endif /* _WX_UNIX_GSOCKUNX_H_ */

View File

@ -0,0 +1,145 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/unix/private/timer.h
// Purpose: wxTimer for wxBase (unix)
// Author: Lukasz Michalski
// Created: 15/01/2005
// RCS-ID: $Id: timer.h 61508 2009-07-23 20:30:22Z VZ $
// Copyright: (c) Lukasz Michalski
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_UNIX_PRIVATE_TIMER_H_
#define _WX_UNIX_PRIVATE_TIMER_H_
#if wxUSE_TIMER
#include "wx/private/timer.h"
// the type used for milliseconds is large enough for microseconds too but
// introduce a synonym for it to avoid confusion
typedef wxMilliClock_t wxUsecClock_t;
// ----------------------------------------------------------------------------
// wxTimer implementation class for Unix platforms
// ----------------------------------------------------------------------------
// NB: we have to export at least this symbol from the shared library, because
// it's used by wxDFB's wxCore
class WXDLLIMPEXP_BASE wxUnixTimerImpl : public wxTimerImpl
{
public:
wxUnixTimerImpl(wxTimer *timer);
virtual ~wxUnixTimerImpl();
virtual bool IsRunning() const;
virtual bool Start(int milliseconds = -1, bool oneShot = false);
virtual void Stop();
// for wxTimerScheduler only: resets the internal flag indicating that the
// timer is running
void MarkStopped()
{
wxASSERT_MSG( m_isRunning, wxT("stopping non-running timer?") );
m_isRunning = false;
}
private:
bool m_isRunning;
};
// ----------------------------------------------------------------------------
// wxTimerSchedule: information about a single timer, used by wxTimerScheduler
// ----------------------------------------------------------------------------
struct wxTimerSchedule
{
wxTimerSchedule(wxUnixTimerImpl *timer, wxUsecClock_t expiration)
: m_timer(timer),
m_expiration(expiration)
{
}
// the timer itself (we don't own this pointer)
wxUnixTimerImpl *m_timer;
// the time of its next expiration, in usec
wxUsecClock_t m_expiration;
};
// the linked list of all active timers, we keep it sorted by expiration time
WX_DECLARE_LIST(wxTimerSchedule, wxTimerList);
// ----------------------------------------------------------------------------
// wxTimerScheduler: class responsible for updating all timers
// ----------------------------------------------------------------------------
class wxTimerScheduler
{
public:
// get the unique timer scheduler instance
static wxTimerScheduler& Get()
{
if ( !ms_instance )
ms_instance = new wxTimerScheduler;
return *ms_instance;
}
// must be called on shutdown to delete the global timer scheduler
static void Shutdown()
{
if ( ms_instance )
{
delete ms_instance;
ms_instance = NULL;
}
}
// adds timer which should expire at the given absolute time to the list
void AddTimer(wxUnixTimerImpl *timer, wxUsecClock_t expiration);
// remove timer from the list, called automatically from timer dtor
void RemoveTimer(wxUnixTimerImpl *timer);
// the functions below are used by the event loop implementation to monitor
// and notify timers:
// if this function returns true, the time remaining until the next time
// expiration is returned in the provided parameter (always positive or 0)
//
// it returns false if there are no timers
bool GetNext(wxUsecClock_t *remaining) const;
// trigger the timer event for all timers which have expired, return true
// if any did
bool NotifyExpired();
private:
// ctor and dtor are private, this is a singleton class only created by
// Get() and destroyed by Shutdown()
wxTimerScheduler() { }
~wxTimerScheduler();
// add the given timer schedule to the list in the right place
//
// we take ownership of the pointer "s" which must be heap-allocated
void DoAddTimer(wxTimerSchedule *s);
// the list of all currently active timers sorted by expiration
wxTimerList m_timers;
static wxTimerScheduler *ms_instance;
};
// this helper function currently only exists for Unix platforms but could be
// moved to wx/stopwatch.h if it turns out to be useful elsewhere
//
// returns the number of microseconds since the Epoch
extern wxUsecClock_t wxGetLocalTimeUsec();
#endif // wxUSE_TIMER
#endif // _WX_UNIX_PRIVATE_TIMER_H_

View File

@ -0,0 +1,161 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/unix/sound.h
// Purpose: wxSound class
// Author: Julian Smart, Vaclav Slavik
// Modified by:
// Created: 25/10/98
// RCS-ID: $Id: sound.h 47254 2007-07-09 10:09:52Z VS $
// Copyright: (c) Julian Smart, Vaclav Slavik
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_SOUND_H_
#define _WX_SOUND_H_
#include "wx/defs.h"
#if wxUSE_SOUND
#include "wx/object.h"
// ----------------------------------------------------------------------------
// wxSound: simple audio playback class
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_FWD_ADV wxSoundBackend;
class WXDLLIMPEXP_FWD_ADV wxSound;
class WXDLLIMPEXP_FWD_BASE wxDynamicLibrary;
/// Sound data, as loaded from .wav file:
class WXDLLIMPEXP_ADV wxSoundData
{
public:
wxSoundData() : m_refCnt(1) {}
void IncRef();
void DecRef();
// .wav header information:
unsigned m_channels; // num of channels (mono:1, stereo:2)
unsigned m_samplingRate;
unsigned m_bitsPerSample; // if 8, then m_data contains unsigned 8bit
// samples (wxUint8), if 16 then signed 16bit
// (wxInt16)
unsigned m_samples; // length in samples:
// wave data:
size_t m_dataBytes;
wxUint8 *m_data; // m_dataBytes bytes of data
private:
~wxSoundData();
unsigned m_refCnt;
wxUint8 *m_dataWithHeader; // ditto, but prefixed with .wav header
friend class wxSound;
};
/// Simple sound class:
class WXDLLIMPEXP_ADV wxSound : public wxSoundBase
{
public:
wxSound();
wxSound(const wxString& fileName, bool isResource = false);
wxSound(int size, const wxByte* data);
virtual ~wxSound();
// Create from resource or file
bool Create(const wxString& fileName, bool isResource = false);
// Create from data
bool Create(int size, const wxByte* data);
bool IsOk() const { return m_data != NULL; }
// Stop playing any sound
static void Stop();
// Returns true if a sound is being played
static bool IsPlaying();
// for internal use
static void UnloadBackend();
protected:
bool DoPlay(unsigned flags) const;
static void EnsureBackend();
void Free();
bool LoadWAV(const wxUint8 *data, size_t length, bool copyData);
static wxSoundBackend *ms_backend;
#if wxUSE_LIBSDL && wxUSE_PLUGINS
// FIXME - temporary, until we have plugins architecture
static wxDynamicLibrary *ms_backendSDL;
#endif
private:
wxSoundData *m_data;
};
// ----------------------------------------------------------------------------
// wxSoundBackend:
// ----------------------------------------------------------------------------
// This is interface to sound playing implementation. There are multiple
// sound architectures in use on Unix platforms and wxWidgets can use several
// of them for playback, depending on their availability at runtime; hence
// the need for backends. This class is for use by wxWidgets and people writing
// additional backends only, it is _not_ for use by applications!
// Structure that holds playback status information
struct wxSoundPlaybackStatus
{
// playback is in progress
bool m_playing;
// main thread called wxSound::Stop()
bool m_stopRequested;
};
// Audio backend interface
class WXDLLIMPEXP_ADV wxSoundBackend
{
public:
virtual ~wxSoundBackend() {}
// Returns the name of the backend (e.g. "Open Sound System")
virtual wxString GetName() const = 0;
// Returns priority (higher priority backends are tried first)
virtual int GetPriority() const = 0;
// Checks if the backend's audio system is available and the backend can
// be used for playback
virtual bool IsAvailable() const = 0;
// Returns true if the backend is capable of playing sound asynchronously.
// If false, then wxWidgets creates a playback thread and handles async
// playback, otherwise it is left up to the backend (will usually be more
// effective).
virtual bool HasNativeAsyncPlayback() const = 0;
// Plays the sound. flags are same flags as those passed to wxSound::Play.
// The function should periodically check the value of
// status->m_stopRequested and terminate if it is set to true (it may
// be modified by another thread)
virtual bool Play(wxSoundData *data, unsigned flags,
volatile wxSoundPlaybackStatus *status) = 0;
// Stops playback (if something is played).
virtual void Stop() = 0;
// Returns true if the backend is playing anything at the moment.
// (This method is never called for backends that don't support async
// playback.)
virtual bool IsPlaying() const = 0;
};
#endif // wxUSE_SOUND
#endif // _WX_SOUND_H_

View File

@ -0,0 +1,99 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/unix/stackwalk.h
// Purpose: declaration of wxStackWalker for Unix
// Author: Vadim Zeitlin
// Modified by:
// Created: 2005-01-19
// RCS-ID: $Id: stackwalk.h 58093 2009-01-14 14:38:00Z FM $
// Copyright: (c) 2005 Vadim Zeitlin <vadim@wxwindows.org>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_UNIX_STACKWALK_H_
#define _WX_UNIX_STACKWALK_H_
// ----------------------------------------------------------------------------
// wxStackFrame
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_BASE wxStackFrame : public wxStackFrameBase
{
friend class wxStackWalker;
public:
// arguments are the stack depth of this frame, its address and the return
// value of backtrace_symbols() for it
//
// NB: we don't copy syminfo pointer so it should have lifetime at least as
// long as ours
wxStackFrame(size_t level = 0, void *address = NULL, const char *syminfo = NULL)
: wxStackFrameBase(level, address)
{
m_syminfo = syminfo;
}
protected:
virtual void OnGetName();
// optimized for the 2 step initialization done by wxStackWalker
void Set(const wxString &name, const wxString &filename, const char* syminfo,
size_t level, size_t numLine, void *address)
{
m_level = level;
m_name = name;
m_filename = filename;
m_syminfo = syminfo;
m_line = numLine;
m_address = address;
}
private:
const char *m_syminfo;
};
// ----------------------------------------------------------------------------
// wxStackWalker
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_BASE wxStackWalker : public wxStackWalkerBase
{
public:
// we need the full path to the program executable to be able to use
// addr2line, normally we can retrieve it from wxTheApp but if wxTheApp
// doesn't exist or doesn't have the correct value, the path may be given
// explicitly
wxStackWalker(const char *argv0 = NULL)
{
ms_exepath = wxString::FromAscii(argv0);
}
~wxStackWalker()
{
FreeStack();
}
virtual void Walk(size_t skip = 1, size_t maxDepth = wxSTACKWALKER_MAX_DEPTH);
#if wxUSE_ON_FATAL_EXCEPTION
virtual void WalkFromException(size_t maxDepth = wxSTACKWALKER_MAX_DEPTH) { Walk(2, maxDepth); }
#endif // wxUSE_ON_FATAL_EXCEPTION
static const wxString& GetExePath() { return ms_exepath; }
// these two may be used to save the stack at some point (fast operation)
// and then process it later (slow operation)
void SaveStack(size_t maxDepth);
void ProcessFrames(size_t skip);
void FreeStack();
private:
int InitFrames(wxStackFrame *arr, size_t n, void **addresses, char **syminfo);
static wxString ms_exepath;
static void *ms_addresses[];
static char **ms_symbols;
static int m_depth;
};
#endif // _WX_UNIX_STACKWALK_H_

View File

@ -0,0 +1,59 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/unix/stdpaths.h
// Purpose: wxStandardPaths for Unix systems
// Author: Vadim Zeitlin
// Modified by:
// Created: 2004-10-19
// RCS-ID: $Id: stdpaths.h 53094 2008-04-08 13:52:39Z JS $
// Copyright: (c) 2004 Vadim Zeitlin <vadim@wxwindows.org>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_UNIX_STDPATHS_H_
#define _WX_UNIX_STDPATHS_H_
// ----------------------------------------------------------------------------
// wxStandardPaths
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_BASE wxStandardPaths : public wxStandardPathsBase
{
public:
// tries to determine the installation prefix automatically (Linux only right
// now) and returns /usr/local if it failed
void DetectPrefix();
// set the program installation directory which is /usr/local by default
//
// under some systems (currently only Linux) the program directory can be
// determined automatically but for portable programs you should always set
// it explicitly
void SetInstallPrefix(const wxString& prefix);
// get the program installation prefix
//
// if the prefix had been previously by SetInstallPrefix, returns that
// value, otherwise calls DetectPrefix()
wxString GetInstallPrefix() const;
// implement base class pure virtuals
virtual wxString GetExecutablePath() const;
virtual wxString GetConfigDir() const;
virtual wxString GetUserConfigDir() const;
virtual wxString GetDataDir() const;
virtual wxString GetLocalDataDir() const;
virtual wxString GetUserDataDir() const;
virtual wxString GetPluginsDir() const;
virtual wxString GetLocalizedResourcesDir(const wxString& lang,
ResourceCat category) const;
#ifndef __VMS
virtual wxString GetDocumentsDir() const;
#endif
private:
wxString m_prefix;
};
#endif // _WX_UNIX_STDPATHS_H_

View File

@ -0,0 +1,41 @@
/////////////////////////////////////////////////////////////////////////
// File: wx/unix/taskbarx11.h
// Purpose: Defines wxTaskBarIcon class for most common X11 desktops
// Author: Vaclav Slavik
// Modified by:
// Created: 04/04/2003
// RCS-ID: $Id: taskbarx11.h 62789 2009-12-05 19:57:58Z PC $
// Copyright: (c) Vaclav Slavik, 2003
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////
#ifndef _WX_UNIX_TASKBAR_H_
#define _WX_UNIX_TASKBAR_H_
class WXDLLIMPEXP_FWD_ADV wxTaskBarIconArea;
class WXDLLIMPEXP_ADV wxTaskBarIcon: public wxTaskBarIconBase
{
public:
wxTaskBarIcon();
virtual ~wxTaskBarIcon();
// Accessors:
bool IsOk() const;
bool IsIconInstalled() const;
// Operations:
bool SetIcon(const wxIcon& icon, const wxString& tooltip = wxEmptyString);
bool RemoveIcon();
bool PopupMenu(wxMenu *menu);
protected:
wxTaskBarIconArea *m_iconWnd;
private:
void OnDestroy(wxWindowDestroyEvent&);
DECLARE_DYNAMIC_CLASS(wxTaskBarIcon)
};
#endif // _WX_UNIX_TASKBAR_H_

View File

@ -0,0 +1,66 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/unix/tls.h
// Purpose: Pthreads implementation of wxTlsValue<>
// Author: Vadim Zeitlin
// Created: 2008-08-08
// RCS-ID: $Id: tls.h 63653 2010-03-08 12:21:58Z VS $
// Copyright: (c) 2008 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_UNIX_TLS_H_
#define _WX_UNIX_TLS_H_
#include <pthread.h>
// ----------------------------------------------------------------------------
// wxTlsKey is a helper class encapsulating the TLS value index
// ----------------------------------------------------------------------------
class wxTlsKey
{
public:
// ctor allocates a new key and possibly registering a destructor function
// for it
wxTlsKey(wxTlsDestructorFunction destructor)
{
m_destructor = destructor;
if ( pthread_key_create(&m_key, destructor) != 0 )
m_key = 0;
}
// return true if the key was successfully allocated
bool IsOk() const { return m_key != 0; }
// get the key value, there is no error return
void *Get() const
{
return pthread_getspecific(m_key);
}
// change the key value, return true if ok
bool Set(void *value)
{
void *old = Get();
if ( old )
m_destructor(old);
return pthread_setspecific(m_key, value) == 0;
}
// free the key
~wxTlsKey()
{
if ( IsOk() )
pthread_key_delete(m_key);
}
private:
wxTlsDestructorFunction m_destructor;
pthread_key_t m_key;
wxDECLARE_NO_COPY_CLASS(wxTlsKey);
};
#endif // _WX_UNIX_TLS_H_

View File

@ -0,0 +1,79 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/unix/utilsx11.h
// Purpose: Miscellaneous X11 functions
// Author: Mattia Barbon, Vaclav Slavik, Vadim Zeitlin
// Modified by:
// Created: 25.03.02
// RCS-ID: $Id: utilsx11.h 65397 2010-08-24 11:23:22Z JJ $
// Copyright: (c) wxWidgets team
// (c) 2010 Vadim Zeitlin
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_UNIX_UTILSX11_H_
#define _WX_UNIX_UTILSX11_H_
#include "wx/defs.h"
#include "wx/gdicmn.h"
#include <X11/Xlib.h>
// NB: Content of this header is for wxWidgets' private use! It is not
// part of public API and may be modified or even disappear in the future!
#if defined(__WXMOTIF__) || defined(__WXGTK__) || defined(__WXX11__)
#if defined(__WXGTK__)
typedef void WXDisplay;
typedef void* WXWindow;
#endif
typedef unsigned long WXKeySym;
int wxCharCodeXToWX(WXKeySym keySym);
WXKeySym wxCharCodeWXToX(int id);
class wxIconBundle;
void wxSetIconsX11( WXDisplay* display, WXWindow window,
const wxIconBundle& ib );
enum wxX11FullScreenMethod
{
wxX11_FS_AUTODETECT = 0,
wxX11_FS_WMSPEC,
wxX11_FS_KDE,
wxX11_FS_GENERIC
};
wxX11FullScreenMethod wxGetFullScreenMethodX11(WXDisplay* display,
WXWindow rootWindow);
void wxSetFullScreenStateX11(WXDisplay* display, WXWindow rootWindow,
WXWindow window, bool show, wxRect *origSize,
wxX11FullScreenMethod method);
// Class wrapping X11 Display: it opens it in ctor and closes it in dtor.
class wxX11Display
{
public:
wxX11Display() { m_dpy = XOpenDisplay(NULL); }
~wxX11Display() { if ( m_dpy ) XCloseDisplay(m_dpy); }
operator Display *() const { return m_dpy; }
// Using DefaultRootWindow() with an object of wxX11Display class doesn't
// compile because it is a macro which tries to cast wxX11Display so
// provide a convenient helper.
Window DefaultRoot() const { return DefaultRootWindow(m_dpy); }
private:
Display *m_dpy;
wxDECLARE_NO_COPY_CLASS(wxX11Display);
};
#endif // __WXMOTIF__, __WXGTK__, __WXX11__
#endif // _WX_UNIX_UTILSX11_H_