Compare commits

..

1 Commits

Author SHA1 Message Date
Bryan Petty
5335e9ae5e This commit was manufactured by cvs2svn to create tag
'LAST_WITH_IFDEF_QT'.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/tags/LAST_WITH_IFDEF_QT@11451 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2001-08-24 12:20:07 +00:00
138 changed files with 9800 additions and 24585 deletions

123
include/wx/accel.h Normal file
View File

@@ -0,0 +1,123 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/accel.h
// Purpose: wxAcceleratorEntry and wxAcceleratorTable classes
// Author: Julian Smart, Robert Roebling, Vadim Zeitlin
// Modified by:
// Created: 31.05.01 (extracted from other files)
// RCS-ID: $Id$
// Copyright: (c) wxWindows team
// Licence: wxWindows license
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_ACCEL_H_BASE_
#define _WX_ACCEL_H_BASE_
#include "wx/defs.h"
#if wxUSE_ACCEL
#include "wx/object.h"
class WXDLLEXPORT wxAcceleratorTable;
class WXDLLEXPORT wxMenuItem;
class WXDLLEXPORT wxKeyEvent;
// ----------------------------------------------------------------------------
// constants
// ----------------------------------------------------------------------------
// wxAcceleratorEntry flags
enum
{
wxACCEL_NORMAL = 0x0000, // no modifiers
wxACCEL_ALT = 0x0001, // hold Alt key down
wxACCEL_CTRL = 0x0002, // hold Ctrl key down
wxACCEL_SHIFT = 0x0004 // hold Shift key down
};
// ----------------------------------------------------------------------------
// an entry in wxAcceleratorTable corresponds to one accelerator
// ----------------------------------------------------------------------------
class WXDLLEXPORT wxAcceleratorEntry
{
public:
wxAcceleratorEntry(int flags = 0, int keyCode = 0, int cmd = 0,
wxMenuItem *item = NULL)
{
Set(flags, keyCode, cmd, item);
}
void Set(int flags, int keyCode, int cmd, wxMenuItem *item = NULL)
{
m_flags = flags;
m_keyCode = keyCode;
m_command = cmd;
m_item = item;
}
void SetMenuItem(wxMenuItem *item) { m_item = item; }
int GetFlags() const { return m_flags; }
int GetKeyCode() const { return m_keyCode; }
int GetCommand() const { return m_command; }
wxMenuItem *GetMenuItem() const { return m_item; }
bool operator==(const wxAcceleratorEntry& entry) const
{
return m_flags == entry.m_flags &&
m_keyCode == entry.m_keyCode &&
m_command == entry.m_command &&
m_item == entry.m_item;
}
bool operator!=(const wxAcceleratorEntry& entry) const
{ return !(*this == entry); }
#ifdef __WXMOTIF__
// Implementation use only
bool MatchesEvent(const wxKeyEvent& event) const ;
#endif
private:
int m_flags; // combination of wxACCEL_XXX constants
int m_keyCode; // ASCII or virtual keycode
int m_command; // Command id to generate
// the menu item this entry corresponds to, may be NULL
wxMenuItem *m_item;
// for compatibility with old code, use accessors now!
friend class WXDLLEXPORT wxMenu;
};
// ----------------------------------------------------------------------------
// include wxAcceleratorTable class declaration, it is only used by the library
// and so doesn't have any published user visible interface
// ----------------------------------------------------------------------------
#if defined(__WXUNIVERSAL__)
#include "wx/generic/accel.h"
#elif defined(__WXMSW__)
#include "wx/msw/accel.h"
#elif defined(__WXMOTIF__)
#include "wx/motif/accel.h"
#elif defined(__WXGTK__)
#include "wx/gtk/accel.h"
#elif defined(__WXQT__)
#include "wx/qt/accel.h"
#elif defined(__WXMAC__)
#include "wx/mac/accel.h"
#elif defined(__WXPM__)
#include "wx/os2/accel.h"
#elif defined(__WXSTUBS__)
#include "wx/stubs/accel.h"
#endif
WXDLLEXPORT_DATA(extern wxAcceleratorTable) wxNullAcceleratorTable;
#endif // wxUSE_ACCEL
#endif
// _WX_ACCEL_H_BASE_

512
include/wx/app.h Normal file
View File

@@ -0,0 +1,512 @@
/////////////////////////////////////////////////////////////////////////////
// Name: app.h
// Purpose: wxAppBase class and macros used for declaration of wxApp
// derived class in the user code
// Author: Julian Smart
// Modified by:
// Created: 01/02/97
// RCS-ID: $Id$
// Copyright: (c) Julian Smart and Markus Holzem
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_APP_H_BASE_
#define _WX_APP_H_BASE_
#ifdef __GNUG__
#pragma interface "appbase.h"
#endif
// ----------------------------------------------------------------------------
// typedefs
// ----------------------------------------------------------------------------
#if (defined(__WXMSW__) && !defined(__WXMICROWIN__)) || defined (__WXPM__)
class WXDLLEXPORT wxApp;
typedef wxApp* (*wxAppInitializerFunction)();
#else
// returning wxApp* won't work with gcc
#include "wx/object.h"
typedef wxObject* (*wxAppInitializerFunction)();
#endif
class WXDLLEXPORT wxCmdLineParser;
// ----------------------------------------------------------------------------
// headers we have to include here
// ----------------------------------------------------------------------------
#include "wx/event.h" // for the base class
#if wxUSE_GUI
#include "wx/window.h" // for wxTopLevelWindows
#endif // wxUSE_GUI
#if wxUSE_LOG
#include "wx/log.h"
#endif
// ----------------------------------------------------------------------------
// constants
// ----------------------------------------------------------------------------
static const int wxPRINT_WINDOWS = 1;
static const int wxPRINT_POSTSCRIPT = 2;
// ----------------------------------------------------------------------------
// the common part of wxApp implementations for all platforms
// ----------------------------------------------------------------------------
class WXDLLEXPORT wxAppBase : public wxEvtHandler
{
public:
wxAppBase();
// the virtual functions which may/must be overridden in the derived class
// -----------------------------------------------------------------------
#ifdef __DARWIN__
virtual ~wxAppBase() { }
#endif
// called during the program initialization, returning FALSE from here
// prevents the program from continuing - it's a good place to create
// the top level program window and return TRUE.
//
// Override: always in GUI application, rarely in console ones.
virtual bool OnInit();
#if wxUSE_GUI
// a platform-dependent version of OnInit(): the code here is likely to
// depend on the toolkit. default version does nothing.
//
// Override: rarely.
virtual bool OnInitGui();
#endif // wxUSE_GUI
// called to start program execution - the default version just enters
// the main GUI loop in which events are received and processed until
// the last window is not deleted (if GetExitOnFrameDelete) or
// ExitMainLoop() is called. In console mode programs, the execution
// of the program really starts here
//
// Override: rarely in GUI applications, always in console ones.
#if wxUSE_GUI
virtual int OnRun() { return MainLoop(); };
#else // !GUI
virtual int OnRun() = 0;
#endif // wxUSE_GUI
// called after the main loop termination. This is a good place for
// cleaning up (it may be too late in dtor) and is also useful if you
// want to return some non-default exit code - this is just the return
// value of this method.
//
// Override: often.
virtual int OnExit();
// called when a fatal exception occurs, this function should take care
// not to do anything which might provoke a nested exception! It may be
// overridden if you wish to react somehow in non-default way (core
// dump under Unix, application crash under Windows) to fatal program
// errors, however extreme care should be taken if you don't want this
// function to crash.
//
// Override: rarely.
virtual void OnFatalException() { }
// the worker functions - usually not used directly by the user code
// -----------------------------------------------------------------
#if wxUSE_GUI
// execute the main GUI loop, the function returns when the loop ends
virtual int MainLoop() = 0;
// exit the main GUI loop during the next iteration (i.e. it does not
// stop the program immediately!)
virtual void ExitMainLoop() = 0;
// returns TRUE if the program is initialized
virtual bool Initialized() = 0;
// returns TRUE if there are unprocessed events in the event queue
virtual bool Pending() = 0;
// process the first event in the event queue (blocks until an event
// apperas if there are none currently)
virtual void Dispatch() = 0;
#endif // wxUSE_GUI
// application info: name, description, vendor
// -------------------------------------------
// NB: all these should be set by the application itself, there are no
// reasonable default except for the application name which is taken to
// be argv[0]
// set/get the application name
wxString GetAppName() const
{
if ( !m_appName )
return m_className;
else
return m_appName;
}
void SetAppName(const wxString& name) { m_appName = name; }
// set/get the app class name
wxString GetClassName() const { return m_className; }
void SetClassName(const wxString& name) { m_className = name; }
// set/get the vendor name
const wxString& GetVendorName() const { return m_vendorName; }
void SetVendorName(const wxString& name) { m_vendorName = name; }
#if wxUSE_GUI
// top level window functions
// --------------------------
// return TRUE if our app has focus
virtual bool IsActive() const { return m_isActive; }
// set the "main" top level window
void SetTopWindow(wxWindow *win) { m_topWindow = win; }
// return the "main" top level window (if it hadn't been set previously
// with SetTopWindow(), will return just some top level window and, if
// there are none, will return NULL)
virtual wxWindow *GetTopWindow() const
{
if (m_topWindow)
return m_topWindow;
else if (wxTopLevelWindows.GetCount() > 0)
return wxTopLevelWindows.GetFirst()->GetData();
else
return (wxWindow *)NULL;
}
// control the exit behaviour: by default, the program will exit the
// main loop (and so, usually, terminate) when the last top-level
// program window is deleted. Beware that if you disabel this (with
// SetExitOnFrameDelete(FALSE)), you'll have to call ExitMainLoop()
// explicitly from somewhere.
void SetExitOnFrameDelete(bool flag) { m_exitOnFrameDelete = flag; }
bool GetExitOnFrameDelete() const { return m_exitOnFrameDelete; }
#endif // wxUSE_GUI
// cmd line parsing stuff
// ----------------------
// all of these methods may be overridden in the derived class to
// customize the command line parsing (by default only a few standard
// options are handled)
//
// you also need to call wxApp::OnInit() from YourApp::OnInit() for all
// this to work
#if wxUSE_CMDLINE_PARSER
// this one is called from OnInit() to add all supported options
// to the given parser
virtual void OnInitCmdLine(wxCmdLineParser& parser);
// called after successfully parsing the command line, return TRUE
// to continue and FALSE to exit
virtual bool OnCmdLineParsed(wxCmdLineParser& parser);
// called if "--help" option was specified, return TRUE to continue
// and FALSE to exit
virtual bool OnCmdLineHelp(wxCmdLineParser& parser);
// called if incorrect command line options were given, return
// FALSE to abort and TRUE to continue
virtual bool OnCmdLineError(wxCmdLineParser& parser);
#endif // wxUSE_CMDLINE_PARSER
// miscellaneous customization functions
// -------------------------------------
#if wxUSE_LOG
// override this function to create default log target of arbitrary
// user-defined class (default implementation creates a wxLogGui
// object) - this log object is used by default by all wxLogXXX()
// functions.
virtual wxLog *CreateLogTarget()
#if wxUSE_GUI && wxUSE_LOGGUI && !defined(__WXMICROWIN__)
{ return new wxLogGui; }
#else // !GUI
{ return new wxLogStderr; }
#endif // wxUSE_GUI
#endif // wxUSE_LOG
#if wxUSE_GUI
// get the standard icon used by wxWin dialogs - this allows the user
// to customize the standard dialogs. The 'which' parameter is one of
// wxICON_XXX values
virtual wxIcon GetStdIcon(int which) const = 0;
// VZ: what does this do exactly?
void SetWantDebugOutput( bool flag ) { m_wantDebugOutput = flag; }
bool GetWantDebugOutput() const { return m_wantDebugOutput; }
// set use of best visual flag (see below)
void SetUseBestVisual( bool flag ) { m_useBestVisual = flag; }
bool GetUseBestVisual() const { return m_useBestVisual; }
// set/get printing mode: see wxPRINT_XXX constants.
//
// default behaviour is the normal one for Unix: always use PostScript
// printing.
virtual void SetPrintMode(int WXUNUSED(mode)) { }
int GetPrintMode() const { return wxPRINT_POSTSCRIPT; }
// called by toolkit-specific code to set the app status: active (we have
// focus) or not and also the last window which had focus before we were
// deactivated
virtual void SetActive(bool isActive, wxWindow *lastFocus);
#endif // wxUSE_GUI
// debugging support
// -----------------
// this function is called when an assert failure occurs, the base class
// version does the normal processing (i.e. shows the usual assert failure
// dialog box)
#ifdef __WXDEBUG__
virtual void OnAssert(const wxChar *file, int line, const wxChar *msg);
#endif // __WXDEBUG__
// implementation only from now on
// -------------------------------
// helpers for dynamic wxApp construction
static void SetInitializerFunction(wxAppInitializerFunction fn)
{ m_appInitFn = fn; }
static wxAppInitializerFunction GetInitializerFunction()
{ return m_appInitFn; }
// process all events in the wxPendingEvents list
virtual void ProcessPendingEvents();
// access to the command line arguments
int argc;
wxChar **argv;
protected:
// function used for dynamic wxApp creation
static wxAppInitializerFunction m_appInitFn;
// application info (must be set from the user code)
wxString m_vendorName, // vendor name (ACME Inc)
m_appName, // app name
m_className; // class name
// TRUE if the application wants to get debug output
bool m_wantDebugOutput;
#if wxUSE_GUI
// the main top level window - may be NULL
wxWindow *m_topWindow;
// if TRUE, exit the main loop when the last top level window is deleted
bool m_exitOnFrameDelete;
// TRUE if the apps whats to use the best visual on systems where
// more than one are available (Sun, SGI, XFree86 4.0 ?)
bool m_useBestVisual;
// does any of our windows has focus?
bool m_isActive;
#endif // wxUSE_GUI
};
// ----------------------------------------------------------------------------
// now include the declaration of the real class
// ----------------------------------------------------------------------------
#if wxUSE_GUI
#if defined(__WXMSW__)
#include "wx/msw/app.h"
#elif defined(__WXMOTIF__)
#include "wx/motif/app.h"
#elif defined(__WXMGL__)
#include "wx/mgl/app.h"
#elif defined(__WXQT__)
#include "wx/qt/app.h"
#elif defined(__WXGTK__)
#include "wx/gtk/app.h"
#elif defined(__WXMAC__)
#include "wx/mac/app.h"
#elif defined(__WXPM__)
#include "wx/os2/app.h"
#elif defined(__WXSTUBS__)
#include "wx/stubs/app.h"
#endif
#else // !GUI
// can't use typedef because wxApp forward declared as a class
class WXDLLEXPORT wxApp : public wxAppBase
{
};
#endif // GUI/!GUI
// ----------------------------------------------------------------------------
// the global data
// ----------------------------------------------------------------------------
// the one and only application object - use of wxTheApp in application code
// is discouraged, consider using DECLARE_APP() after which you may call
// wxGetApp() which will return the object of the correct type (i.e. MyApp and
// not wxApp)
WXDLLEXPORT_DATA(extern wxApp*) wxTheApp;
// ----------------------------------------------------------------------------
// global functions
// ----------------------------------------------------------------------------
// event loop related functions only work in GUI programs
// ------------------------------------------------------
// Force an exit from main loop
extern void WXDLLEXPORT wxExit();
// Yield to other apps/messages
extern bool WXDLLEXPORT wxYield();
// Yield to other apps/messages
extern void WXDLLEXPORT wxWakeUpIdle();
// Post a message to the given eventhandler which will be processed during the
// next event loop iteration
inline void wxPostEvent(wxEvtHandler *dest, wxEvent& event)
{
wxCHECK_RET( dest, wxT("need an object to post event to in wxPostEvent") );
#if wxUSE_GUI
dest->AddPendingEvent(event);
#else
dest->ProcessEvent(event);
#endif // wxUSE_GUI
}
// console applications may avoid using DECLARE_APP and IMPLEMENT_APP macros
// and call these functions instead at the program startup and termination
// -------------------------------------------------------------------------
#if !wxUSE_GUI
// initialize the library (may be called as many times as needed, but each
// call to wxInitialize() must be matched by wxUninitialize())
extern bool WXDLLEXPORT wxInitialize();
// clean up - the library can't be used any more after the last call to
// wxUninitialize()
extern void WXDLLEXPORT wxUninitialize();
// create an object of this class on stack to initialize/cleanup thel ibrary
// automatically
class WXDLLEXPORT wxInitializer
{
public:
// initialize the library
wxInitializer() { m_ok = wxInitialize(); }
// has the initialization been successful? (explicit test)
bool IsOk() const { return m_ok; }
// has the initialization been successful? (implicit test)
operator bool() const { return m_ok; }
// dtor only does clean up if we initialized the library properly
~wxInitializer() { if ( m_ok ) wxUninitialize(); }
private:
bool m_ok;
};
#endif // !wxUSE_GUI
// ----------------------------------------------------------------------------
// macros for dynamic creation of the application object
// ----------------------------------------------------------------------------
// Having a global instance of this class allows wxApp to be aware of the app
// creator function. wxApp can then call this function to create a new app
// object. Convoluted, but necessary.
class WXDLLEXPORT wxAppInitializer
{
public:
wxAppInitializer(wxAppInitializerFunction fn)
{ wxApp::SetInitializerFunction(fn); }
};
// Here's a macro you can use if your compiler really, really wants main() to
// be in your main program (e.g. hello.cpp). Now IMPLEMENT_APP should add this
// code if required.
#if !wxUSE_GUI || defined(__WXMOTIF__) || defined(__WXGTK__) || defined(__WXPM__) || defined(__WXMGL__)
#define IMPLEMENT_WXWIN_MAIN \
extern int wxEntry( int argc, char *argv[] ); \
int main(int argc, char *argv[]) { return wxEntry(argc, argv); }
#elif defined(__WXMAC__) && defined(__UNIX__)
// wxMac seems to have a specific wxEntry prototype
#define IMPLEMENT_WXWIN_MAIN \
extern int wxEntry( int argc, char *argv[], bool enterLoop = 1 ); \
int main(int argc, char *argv[]) { return wxEntry(argc, argv); }
#elif defined(__WXMSW__) && defined(WXUSINGDLL)
// NT defines APIENTRY, 3.x not
#if !defined(WXAPIENTRY)
#define WXAPIENTRY WXFAR wxSTDCALL
#endif
#include <windows.h>
#include "wx/msw/winundef.h"
#define IMPLEMENT_WXWIN_MAIN \
extern "C" int WXAPIENTRY WinMain(HINSTANCE hInstance,\
HINSTANCE hPrevInstance,\
LPSTR m_lpCmdLine, int nCmdShow)\
{\
return wxEntry((WXHINSTANCE) hInstance,\
(WXHINSTANCE) hPrevInstance,\
m_lpCmdLine, nCmdShow);\
}
#else
#define IMPLEMENT_WXWIN_MAIN
#endif
#ifdef __WXUNIVERSAL__
#include "wx/univ/theme.h"
#define IMPLEMENT_WX_THEME_SUPPORT \
WX_USE_THEME(win32); \
WX_USE_THEME(gtk);
#else
#define IMPLEMENT_WX_THEME_SUPPORT
#endif
// Use this macro if you want to define your own main() or WinMain() function
// and call wxEntry() from there.
#define IMPLEMENT_APP_NO_MAIN(appname) \
wxApp *wxCreateApp() { return new appname; } \
wxAppInitializer wxTheAppInitializer((wxAppInitializerFunction) wxCreateApp); \
appname& wxGetApp() { return *(appname *)wxTheApp; }
// Same as IMPLEMENT_APP() normally but doesn't include themes support in
// wxUniversal builds
#define IMPLEMENT_APP_NO_THEMES(appname) \
IMPLEMENT_APP_NO_MAIN(appname) \
IMPLEMENT_WXWIN_MAIN
// Use this macro exactly once, the argument is the name of the wxApp-derived
// class which is the class of your application.
#define IMPLEMENT_APP(appname) \
IMPLEMENT_APP_NO_THEMES(appname) \
IMPLEMENT_WX_THEME_SUPPORT
// this macro can be used multiple times and just allows you to use wxGetApp()
// function
#define DECLARE_APP(appname) extern appname& wxGetApp();
#endif
// _WX_APP_H_BASE_

175
include/wx/bitmap.h Normal file
View File

@@ -0,0 +1,175 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/bitmap.h
// Purpose: wxBitmap class interface
// Author: Vaclav Slavik
// Modified by:
// Created: 22.04.01
// RCS-ID: $Id$
// Copyright: (c) wxWindows team
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_BITMAP_H_BASE_
#define _WX_BITMAP_H_BASE_
// ----------------------------------------------------------------------------
// headers
// ----------------------------------------------------------------------------
#ifdef __GNUG__
#pragma interface "bitmapbase.h"
#endif
#include "wx/defs.h"
#include "wx/object.h"
#include "wx/string.h"
#include "wx/gdiobj.h"
#include "wx/gdicmn.h" // for wxBitmapType
class WXDLLEXPORT wxBitmap;
class WXDLLEXPORT wxBitmapHandler;
class WXDLLEXPORT wxImage;
class WXDLLEXPORT wxMask;
class WXDLLEXPORT wxPalette;
#if defined(__WXMGL__) || defined(__WXMAC__)
// Only used by some ports
// FIXME -- make all ports (but MSW which uses wxGDIImage) use these base classes
// ----------------------------------------------------------------------------
// wxBitmapHandler: class which knows how to create/load/save bitmaps in
// different formats
// ----------------------------------------------------------------------------
class WXDLLEXPORT wxBitmapHandlerBase : public wxObject
{
public:
wxBitmapHandlerBase()
{
m_type = wxBITMAP_TYPE_INVALID;
}
virtual ~wxBitmapHandlerBase() { }
virtual bool Create(wxBitmap *bitmap, void *data, long flags,
int width, int height, int depth = 1) = 0;
virtual bool LoadFile(wxBitmap *bitmap, const wxString& name, long flags,
int desiredWidth, int desiredHeight) = 0;
virtual bool SaveFile(const wxBitmap *bitmap, const wxString& name,
int type, const wxPalette *palette = NULL) = 0;
void SetName(const wxString& name) { m_name = name; }
void SetExtension(const wxString& ext) { m_extension = ext; }
void SetType(wxBitmapType type) { m_type = type; }
wxString GetName() const { return m_name; }
wxString GetExtension() const { return m_extension; }
wxBitmapType GetType() const { return m_type; }
protected:
wxString m_name;
wxString m_extension;
wxBitmapType m_type;
DECLARE_ABSTRACT_CLASS(wxBitmapHandlerBase)
};
class WXDLLEXPORT wxBitmapBase : public wxGDIObject
{
public:
wxBitmapBase() : wxGDIObject() {}
virtual ~wxBitmapBase() {}
/*
Derived class must implement these:
wxBitmap();
wxBitmap(int width, int height, int depth = -1);
wxBitmap(const char bits[], int width, int height, int depth = 1);
wxBitmap(const char **bits);
wxBitmap(char **bits);
wxBitmap(const wxBitmap& bmp);
wxBitmap(const wxString &filename, wxBitmapType type = wxBITMAP_TYPE_XPM);
wxBitmap(const wxImage& image, int depth = -1);
wxBitmap& operator = (const wxBitmap& bmp);
bool operator == (const wxBitmap& bmp) const;
bool operator != (const wxBitmap& bmp) const;
bool Create(int width, int height, int depth = -1);
static void InitStandardHandlers();
*/
virtual bool Ok() const = 0;
virtual int GetHeight() const = 0;
virtual int GetWidth() const = 0;
virtual int GetDepth() const = 0;
virtual wxImage ConvertToImage() const = 0;
virtual wxMask *GetMask() const = 0;
virtual void SetMask(wxMask *mask) = 0;
virtual wxBitmap GetSubBitmap(const wxRect& rect) const = 0;
virtual bool SaveFile(const wxString &name, wxBitmapType type,
const wxPalette *palette = (wxPalette *)NULL) const = 0;
virtual bool LoadFile(const wxString &name, wxBitmapType type) = 0;
virtual wxPalette *GetPalette() const = 0;
virtual void SetPalette(const wxPalette& palette) = 0;
#if WXWIN_COMPATIBILITY
wxPalette *GetColourMap() const { return GetPalette(); }
void SetColourMap(wxPalette *cmap) { SetPalette(*cmap); };
#endif // WXWIN_COMPATIBILITY
// copies the contents and mask of the given (colour) icon to the bitmap
virtual bool CopyFromIcon(const wxIcon& icon) = 0;
// implementation:
virtual void SetHeight(int height) = 0;
virtual void SetWidth(int width) = 0;
virtual void SetDepth(int depth) = 0;
// Format handling
static inline wxList& GetHandlers() { return sm_handlers; }
static void AddHandler(wxBitmapHandlerBase *handler);
static void InsertHandler(wxBitmapHandlerBase *handler);
static bool RemoveHandler(const wxString& name);
static wxBitmapHandler *FindHandler(const wxString& name);
static wxBitmapHandler *FindHandler(const wxString& extension, wxBitmapType bitmapType);
static wxBitmapHandler *FindHandler(wxBitmapType bitmapType);
//static void InitStandardHandlers();
// (wxBitmap must implement this one)
static void CleanUpHandlers();
protected:
static wxList sm_handlers;
DECLARE_ABSTRACT_CLASS(wxBitmapBase)
};
#endif
#if defined(__WXMSW__)
#include "wx/msw/bitmap.h"
#elif defined(__WXMOTIF__)
#include "wx/motif/bitmap.h"
#elif defined(__WXGTK__)
#include "wx/gtk/bitmap.h"
#elif defined(__WXMGL__)
#include "wx/mgl/bitmap.h"
#elif defined(__WXQT__)
#include "wx/qt/bitmap.h"
#elif defined(__WXMAC__)
#include "wx/mac/bitmap.h"
#elif defined(__WXPM__)
#include "wx/os2/bitmap.h"
#elif defined(__WXSTUBS__)
#include "wx/stubs/bitmap.h"
#endif
#endif
// _WX_BITMAP_H_BASE_

98
include/wx/bmpbuttn.h Normal file
View File

@@ -0,0 +1,98 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/bmpbutton.h
// Purpose: wxBitmapButton class interface
// Author: Vadim Zeitlin
// Modified by:
// Created: 25.08.00
// RCS-ID: $Id$
// Copyright: (c) 2000 Vadim Zeitlin
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_BMPBUTTON_H_BASE_
#define _WX_BMPBUTTON_H_BASE_
#if wxUSE_BMPBUTTON
#include "wx/bitmap.h"
#include "wx/button.h"
WXDLLEXPORT_DATA(extern const wxChar*) wxButtonNameStr;
// ----------------------------------------------------------------------------
// wxBitmapButton: a button which shows bitmaps instead of the usual string.
// It has different bitmaps for different states (focused/disabled/pressed)
// ----------------------------------------------------------------------------
class WXDLLEXPORT wxBitmapButtonBase : public wxButton
{
public:
wxBitmapButtonBase() { m_marginX = m_marginY = 0; }
// set the bitmaps
void SetBitmapLabel(const wxBitmap& bitmap)
{ m_bmpNormal = bitmap; OnSetBitmap(); }
void SetBitmapSelected(const wxBitmap& sel)
{ m_bmpSelected = sel; OnSetBitmap(); };
void SetBitmapFocus(const wxBitmap& focus)
{ m_bmpFocus = focus; OnSetBitmap(); };
void SetBitmapDisabled(const wxBitmap& disabled)
{ m_bmpDisabled = disabled; OnSetBitmap(); };
void SetLabel(const wxBitmap& bitmap)
{ SetBitmapLabel(bitmap); }
// retrieve the bitmaps
const wxBitmap& GetBitmapLabel() const { return m_bmpNormal; }
const wxBitmap& GetBitmapSelected() const { return m_bmpSelected; }
const wxBitmap& GetBitmapFocus() const { return m_bmpFocus; }
const wxBitmap& GetBitmapDisabled() const { return m_bmpDisabled; }
wxBitmap& GetBitmapLabel() { return m_bmpNormal; }
wxBitmap& GetBitmapSelected() { return m_bmpSelected; }
wxBitmap& GetBitmapFocus() { return m_bmpFocus; }
wxBitmap& GetBitmapDisabled() { return m_bmpDisabled; }
// set/get the margins around the button
virtual void SetMargins(int x, int y) { m_marginX = x; m_marginY = y; }
int GetMarginX() const { return m_marginX; }
int GetMarginY() const { return m_marginY; }
protected:
// function called when any of the bitmaps changes
virtual void OnSetBitmap() { }
// the bitmaps for various states
wxBitmap m_bmpNormal,
m_bmpSelected,
m_bmpFocus,
m_bmpDisabled;
// the margins around the bitmap
int m_marginX,
m_marginY;
private:
// Prevent Virtual function hiding warnings
void SetLabel(const wxString& rsLabel)
{ wxWindowBase::SetLabel(rsLabel); }
};
#if defined(__WXUNIVERSAL__)
#include "wx/univ/bmpbuttn.h"
#elif defined(__WXMSW__)
#include "wx/msw/bmpbuttn.h"
#elif defined(__WXMOTIF__)
#include "wx/motif/bmpbuttn.h"
#elif defined(__WXGTK__)
#include "wx/gtk/bmpbuttn.h"
#elif defined(__WXQT__)
#include "wx/qt/bmpbuttn.h"
#elif defined(__WXMAC__)
#include "wx/mac/bmpbuttn.h"
#elif defined(__WXPM__)
#include "wx/os2/bmpbuttn.h"
#elif defined(__WXSTUBS__)
#include "wx/stubs/bmpbuttn.h"
#endif
#endif // wxUSE_BMPBUTTON
#endif // _WX_BMPBUTTON_H_BASE_

23
include/wx/brush.h Normal file
View File

@@ -0,0 +1,23 @@
#ifndef _WX_BRUSH_H_BASE_
#define _WX_BRUSH_H_BASE_
#if defined(__WXMSW__)
#include "wx/msw/brush.h"
#elif defined(__WXMOTIF__)
#include "wx/motif/brush.h"
#elif defined(__WXGTK__)
#include "wx/gtk/brush.h"
#elif defined(__WXMGL__)
#include "wx/mgl/brush.h"
#elif defined(__WXQT__)
#include "wx/qt/brush.h"
#elif defined(__WXMAC__)
#include "wx/mac/brush.h"
#elif defined(__WXPM__)
#include "wx/os2/brush.h"
#elif defined(__WXSTUBS__)
#include "wx/stubs/brush.h"
#endif
#endif
// _WX_BRUSH_H_BASE_

82
include/wx/button.h Normal file
View File

@@ -0,0 +1,82 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/button.h
// Purpose: wxButtonBase class
// Author: Vadim Zetlin
// Modified by:
// Created: 15.08.00
// RCS-ID: $Id$
// Copyright: (c) Vadim Zetlin
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_BUTTON_H_BASE_
#define _WX_BUTTON_H_BASE_
#if wxUSE_BUTTON
// ----------------------------------------------------------------------------
// wxButton flags
// ----------------------------------------------------------------------------
// all these flags are obsolete
#define wxBU_NOAUTODRAW 0x0000
#define wxBU_AUTODRAW 0x0004
#define wxBU_LEFT 0x0040
#define wxBU_TOP 0x0080
#define wxBU_RIGHT 0x0100
#define wxBU_BOTTOM 0x0200
// by default, the buttons will be created with some (system dependent)
// minimal size to make them look nicer, giving this style will make them as
// small as possible
#define wxBU_EXACTFIT 0x0001
#include "wx/control.h"
class WXDLLEXPORT wxBitmap;
WXDLLEXPORT_DATA(extern const wxChar*) wxButtonNameStr;
// ----------------------------------------------------------------------------
// wxButton: a push button
// ----------------------------------------------------------------------------
class WXDLLEXPORT wxButtonBase : public wxControl
{
public:
// show the image in the button in addition to the label
virtual void SetImageLabel(const wxBitmap& WXUNUSED(bitmap)) { }
// set the margins around the image
virtual void SetImageMargins(wxCoord WXUNUSED(x), wxCoord WXUNUSED(y)) { }
// this wxButton method is called when the button becomes the default one
// on its panel
virtual void SetDefault() { }
// returns the default button size for this platform
static wxSize GetDefaultSize();
};
#if defined(__WXUNIVERSAL__)
#include "wx/univ/button.h"
#elif defined(__WXMSW__)
#include "wx/msw/button.h"
#elif defined(__WXMOTIF__)
#include "wx/motif/button.h"
#elif defined(__WXGTK__)
#include "wx/gtk/button.h"
#elif defined(__WXQT__)
#include "wx/qt/button.h"
#elif defined(__WXMAC__)
#include "wx/mac/button.h"
#elif defined(__WXPM__)
#include "wx/os2/button.h"
#elif defined(__WXSTUBS__)
#include "wx/stubs/button.h"
#endif
#endif // wxUSE_BUTTON
#endif
// _WX_BUTTON_H_BASE_

56
include/wx/checkbox.h Normal file
View File

@@ -0,0 +1,56 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/checkbox.h
// Purpose: wxCheckBox class interface
// Author: Vadim Zeitlin
// Modified by:
// Created: 07.09.00
// RCS-ID: $Id$
// Copyright: (c) wxWindows team
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_CHECKBOX_H_BASE_
#define _WX_CHECKBOX_H_BASE_
#if wxUSE_CHECKBOX
#include "wx/control.h"
WXDLLEXPORT_DATA(extern const wxChar*) wxCheckBoxNameStr;
// ----------------------------------------------------------------------------
// wxCheckBox: a control which shows a label and a box which may be checked
// ----------------------------------------------------------------------------
class WXDLLEXPORT wxCheckBoxBase : public wxControl
{
public:
// set/get the checked status of the listbox
virtual void SetValue(bool value) = 0;
virtual bool GetValue() const = 0;
bool IsChecked() const { return GetValue(); }
};
#if defined(__WXUNIVERSAL__)
#include "wx/univ/checkbox.h"
#elif defined(__WXMSW__)
#include "wx/msw/checkbox.h"
#elif defined(__WXMOTIF__)
#include "wx/motif/checkbox.h"
#elif defined(__WXGTK__)
#include "wx/gtk/checkbox.h"
#elif defined(__WXQT__)
#include "wx/qt/checkbox.h"
#elif defined(__WXMAC__)
#include "wx/mac/checkbox.h"
#elif defined(__WXPM__)
#include "wx/os2/checkbox.h"
#elif defined(__WXSTUBS__)
#include "wx/stubs/checkbox.h"
#endif
#endif // wxUSE_CHECKBOX
#endif
// _WX_CHECKBOX_H_BASE_

52
include/wx/checklst.h Normal file
View File

@@ -0,0 +1,52 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/checklst.h
// Purpose: wxCheckListBox class interface
// Author: Vadim Zeitlin
// Modified by:
// Created: 12.09.00
// RCS-ID: $Id$
// Copyright: (c) Vadim Zeitlin
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_CHECKLST_H_BASE_
#define _WX_CHECKLST_H_BASE_
#if wxUSE_CHECKLISTBOX
#include "wx/listbox.h"
// ----------------------------------------------------------------------------
// wxCheckListBox: a listbox whose items may be checked
// ----------------------------------------------------------------------------
class WXDLLEXPORT wxCheckListBoxBase : public wxListBox
{
public:
// check list box specific methods
virtual bool IsChecked(size_t item) const = 0;
virtual void Check(size_t item, bool check = TRUE) = 0;
};
#if defined(__WXUNIVERSAL__)
#include "wx/univ/checklst.h"
#elif defined(__WXMSW__)
#include "wx/msw/checklst.h"
#elif defined(__WXMOTIF__)
#include "wx/motif/checklst.h"
#elif defined(__WXGTK__)
#include "wx/gtk/checklst.h"
#elif defined(__WXQT__)
#include "wx/qt/checklst.h"
#elif defined(__WXMAC__)
#include "wx/mac/checklst.h"
#elif defined(__WXPM__)
#include "wx/os2/checklst.h"
#elif defined(__WXSTUBS__)
#include "wx/stubs/checklst.h"
#endif
#endif // wxUSE_CHECKLISTBOX
#endif
// _WX_CHECKLST_H_BASE_

85
include/wx/choice.h Normal file
View File

@@ -0,0 +1,85 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/choice.h
// Purpose: wxChoice class interface
// Author: Vadim Zeitlin
// Modified by:
// Created: 26.07.99
// RCS-ID: $Id$
// Copyright: (c) wxWindows team
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_CHOICE_H_BASE_
#define _WX_CHOICE_H_BASE_
// ----------------------------------------------------------------------------
// headers
// ----------------------------------------------------------------------------
#ifdef __GNUG__
#pragma interface "choicebase.h"
#endif
#if wxUSE_CHOICE
#include "wx/ctrlsub.h" // the base class
// ----------------------------------------------------------------------------
// global data
// ----------------------------------------------------------------------------
WXDLLEXPORT_DATA(extern const wxChar*) wxChoiceNameStr;
// ----------------------------------------------------------------------------
// wxChoice allows to select one of a non-modifiable list of strings
// ----------------------------------------------------------------------------
class WXDLLEXPORT wxChoiceBase : public wxControlWithItems
{
public:
// all generic methods are in wxControlWithItems
#ifdef __DARWIN__
virtual ~wxChoiceBase() {}
#endif
// single selection logic
virtual void SetSelection(int n) = 0;
virtual bool SetStringSelection(const wxString& s);
// don't override this
virtual void Select(int n) { SetSelection(n); }
// set/get the number of columns in the control (as they're not supporte on
// most platforms, they do nothing by default)
virtual void SetColumns(int WXUNUSED(n) = 1 ) { }
virtual int GetColumns() const { return 1 ; }
// emulate selecting the item event.GetInt()
void Command(wxCommandEvent& event);
};
// ----------------------------------------------------------------------------
// include the platform-dependent class definition
// ----------------------------------------------------------------------------
#if defined(__WXMSW__)
#include "wx/msw/choice.h"
#elif defined(__WXMOTIF__)
#include "wx/motif/choice.h"
#elif defined(__WXGTK__)
#include "wx/gtk/choice.h"
#elif defined(__WXQT__)
#include "wx/qt/choice.h"
#elif defined(__WXMAC__)
#include "wx/mac/choice.h"
#elif defined(__WXPM__)
#include "wx/os2/choice.h"
#elif defined(__WXSTUBS__)
#include "wx/stubs/choice.h"
#endif
#endif // wxUSE_CHOICE
#endif
// _WX_CHOICE_H_BASE_

142
include/wx/clipbrd.h Normal file
View File

@@ -0,0 +1,142 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/clipbrd.h
// Purpose: wxClipboad class and clipboard functions
// Author: Vadim Zeitlin
// Modified by:
// Created: 19.10.99
// RCS-ID: $Id$
// Copyright: (c) wxWindows Team
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_CLIPBRD_H_BASE_
#define _WX_CLIPBRD_H_BASE_
#ifdef __GNUG__
#pragma interface "clipboardbase.h"
#endif
#include "wx/defs.h"
#if wxUSE_CLIPBOARD
#include "wx/object.h"
#include "wx/wxchar.h"
class WXDLLEXPORT wxDataFormat;
class WXDLLEXPORT wxDataObject;
// ----------------------------------------------------------------------------
// wxClipboard represents the system clipboard. Normally, you should use
// wxTheClipboard which is a global pointer to the (unique) clipboard.
//
// Clipboard can be used to copy data to/paste data from. It works together
// with wxDataObject.
// ----------------------------------------------------------------------------
class WXDLLEXPORT wxClipboardBase : public wxObject
{
public:
wxClipboardBase();
// open the clipboard before Add/SetData() and GetData()
virtual bool Open() = 0;
// close the clipboard after Add/SetData() and GetData()
virtual void Close() = 0;
// query whether the clipboard is opened
virtual bool IsOpened() const = 0;
// add to the clipboard data
//
// NB: the clipboard owns the pointer and will delete it, so data must be
// allocated on the heap
virtual bool AddData( wxDataObject *data ) = 0;
// set the clipboard data, this is the same as Clear() followed by
// AddData()
virtual bool SetData( wxDataObject *data ) = 0;
// ask if data in correct format is available
virtual bool IsSupported( const wxDataFormat& format ) = 0;
// fill data with data on the clipboard (if available)
virtual bool GetData( wxDataObject& data ) = 0;
// clears wxTheClipboard and the system's clipboard if possible
virtual void Clear() = 0;
// flushes the clipboard: this means that the data which is currently on
// clipboard will stay available even after the application exits (possibly
// eating memory), otherwise the clipboard will be emptied on exit
virtual bool Flush() { return FALSE; }
// X11 has two clipboards which get selected by this call. Empty on MSW.
virtual void UsePrimarySelection( bool WXUNUSED(primary) = FALSE ) { }
};
// ----------------------------------------------------------------------------
// include platform-specific class declaration
// ----------------------------------------------------------------------------
#if defined(__WXMSW__)
#include "wx/msw/clipbrd.h"
#elif defined(__WXMOTIF__)
#include "wx/motif/clipbrd.h"
#elif defined(__WXGTK__)
#include "wx/gtk/clipbrd.h"
#elif defined(__WXMGL__)
#include "wx/mgl/clipbrd.h"
#elif defined(__WXQT__)
#include "wx/gtk/clipbrd.h"
#elif defined(__WXMAC__)
#include "wx/mac/clipbrd.h"
#elif defined(__WXPM__)
#include "wx/os2/clipbrd.h"
#elif defined(__WXSTUBS__)
#include "wx/stubs/clipbrd.h"
#endif
// ----------------------------------------------------------------------------
// globals
// ----------------------------------------------------------------------------
// The global clipboard object
WXDLLEXPORT_DATA(extern wxClipboard *) wxTheClipboard;
// ----------------------------------------------------------------------------
// helpful class for opening the clipboard and automatically closing it
// ----------------------------------------------------------------------------
class WXDLLEXPORT wxClipboardLocker
{
public:
wxClipboardLocker(wxClipboard *clipboard = (wxClipboard *)NULL)
{
m_clipboard = clipboard ? clipboard : wxTheClipboard;
if ( m_clipboard )
{
m_clipboard->Open();
}
}
bool operator!() const { return !m_clipboard->IsOpened(); }
~wxClipboardLocker()
{
if ( m_clipboard )
{
m_clipboard->Close();
}
}
private:
wxClipboard *m_clipboard;
};
#endif // wxUSE_CLIPBOARD
#endif // _WX_CLIPBRD_H_BASE_

25
include/wx/colour.h Normal file
View File

@@ -0,0 +1,25 @@
#ifndef _WX_COLOUR_H_BASE_
#define _WX_COLOUR_H_BASE_
#if defined(__WXMSW__)
#include "wx/msw/colour.h"
#elif defined(__WXMOTIF__)
#include "wx/motif/colour.h"
#elif defined(__WXGTK__)
#include "wx/gtk/colour.h"
#elif defined(__WXMGL__)
#include "wx/mgl/colour.h"
#elif defined(__WXQT__)
#include "wx/qt/colour.h"
#elif defined(__WXMAC__)
#include "wx/mac/colour.h"
#elif defined(__WXPM__)
#include "wx/os2/colour.h"
#elif defined(__WXSTUBS__)
#include "wx/stubs/colour.h"
#endif
#define wxColor wxColour
#endif
// _WX_COLOUR_H_BASE_

75
include/wx/combobox.h Normal file
View File

@@ -0,0 +1,75 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/combobox.h
// Purpose: wxComboBox declaration
// Author: Vadim Zeitlin
// Modified by:
// Created: 24.12.00
// RCS-ID: $Id$
// Copyright: (c) 1996-2000 wxWindows team
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_COMBOBOX_H_BASE_
#define _WX_COMBOBOX_H_BASE_
#include "wx/defs.h"
#if wxUSE_COMBOBOX
WXDLLEXPORT_DATA(extern const wxChar*) wxComboBoxNameStr;
// ----------------------------------------------------------------------------
// wxComboBoxBase: this interface defines the methods wxComboBox must implement
// ----------------------------------------------------------------------------
#include "wx/ctrlsub.h"
class WXDLLEXPORT wxComboBoxBase : public wxItemContainer
{
public:
// wxTextCtrl-like methods wxComboBox must implement
virtual wxString GetValue() const = 0;
virtual void SetValue(const wxString& value) = 0;
virtual void Copy() = 0;
virtual void Cut() = 0;
virtual void Paste() = 0;
virtual void SetInsertionPoint(long pos) = 0;
virtual long GetInsertionPoint() const = 0;
virtual long GetLastPosition() const = 0;
virtual void Replace(long from, long to, const wxString& value) = 0;
virtual void SetSelection(long from, long to) = 0;
virtual void SetEditable(bool editable) = 0;
virtual void SetInsertionPointEnd()
{ SetInsertionPoint(GetLastPosition()); }
virtual void Remove(long from, long to)
{ Replace(from, to, wxEmptyString); }
};
// ----------------------------------------------------------------------------
// include the platform-dependent header defining the real class
// ----------------------------------------------------------------------------
#if defined(__WXUNIVERSAL__)
#include "wx/univ/combobox.h"
#elif defined(__WXMSW__)
#include "wx/msw/combobox.h"
#elif defined(__WXMOTIF__)
#include "wx/motif/combobox.h"
#elif defined(__WXGTK__)
#include "wx/gtk/combobox.h"
#elif defined(__WXQT__)
#include "wx/qt/combobox.h"
#elif defined(__WXMAC__)
#include "wx/mac/combobox.h"
#elif defined(__WXPM__)
#include "wx/os2/combobox.h"
#elif defined(__WXSTUBS__)
#include "wx/stubs/combobox.h"
#endif
#endif // wxUSE_COMBOBOX
#endif
// _WX_COMBOBOX_H_BASE_

98
include/wx/control.h Normal file
View File

@@ -0,0 +1,98 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/control.h
// Purpose: wxControl common interface
// Author: Vadim Zeitlin
// Modified by:
// Created: 26.07.99
// RCS-ID: $Id$
// Copyright: (c) wxWindows team
// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_CONTROL_H_BASE_
#define _WX_CONTROL_H_BASE_
// ----------------------------------------------------------------------------
// headers
// ----------------------------------------------------------------------------
#ifdef __GNUG__
#pragma interface "controlbase.h"
#endif
#if wxUSE_CONTROLS
#include "wx/window.h" // base class
WXDLLEXPORT_DATA(extern const wxChar*) wxControlNameStr;
// ----------------------------------------------------------------------------
// wxControl is the base class for all controls
// ----------------------------------------------------------------------------
class WXDLLEXPORT wxControlBase : public wxWindow
{
public:
// Create() function adds the validator parameter
bool Create(wxWindow *parent, wxWindowID id,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxControlNameStr);
// simulates the event of given type (i.e. wxButton::Command() is just as
// if the button was clicked)
virtual void Command(wxCommandEvent &event);
// get the control alignment (left/right/centre, top/bottom/centre)
int GetAlignment() const { return m_windowStyle & wxALIGN_MASK; }
#ifdef __DARWIN__
virtual ~wxControlBase() { }
#endif
protected:
// creates the control (calls wxWindowBase::CreateBase inside) and adds it
// to the list of parents children
bool CreateControl(wxWindowBase *parent,
wxWindowID id,
const wxPoint& pos,
const wxSize& size,
long style,
const wxValidator& validator,
const wxString& name);
// inherit colour and font settings from the parent window
void InheritAttributes();
// initialize the common fields of wxCommandEvent
void InitCommandEvent(wxCommandEvent& event) const;
};
// ----------------------------------------------------------------------------
// include platform-dependent wxControl declarations
// ----------------------------------------------------------------------------
#if defined(__WXUNIVERSAL__)
#include "wx/univ/control.h"
#elif defined(__WXMSW__)
#include "wx/msw/control.h"
#elif defined(__WXMOTIF__)
#include "wx/motif/control.h"
#elif defined(__WXGTK__)
#include "wx/gtk/control.h"
#elif defined(__WXQT__)
#include "wx/qt/control.h"
#elif defined(__WXMAC__)
#include "wx/mac/control.h"
#elif defined(__WXPM__)
#include "wx/os2/control.h"
#elif defined(__WXSTUBS__)
#include "wx/stubs/control.h"
#endif
#endif // wxUSE_CONTROLS
#endif
// _WX_CONTROL_H_BASE_

60
include/wx/cursor.h Normal file
View File

@@ -0,0 +1,60 @@
#ifndef _WX_CURSOR_H_BASE_
#define _WX_CURSOR_H_BASE_
#if defined(__WXMSW__)
#include "wx/msw/cursor.h"
#elif defined(__WXMOTIF__)
#include "wx/motif/cursor.h"
#elif defined(__WXGTK__)
#include "wx/gtk/cursor.h"
#elif defined(__WXMGL__)
#include "wx/mgl/cursor.h"
#elif defined(__WXQT__)
#include "wx/qt/cursor.h"
#elif defined(__WXMAC__)
#include "wx/mac/cursor.h"
#elif defined(__WXPM__)
#include "wx/os2/cursor.h"
#elif defined(__WXSTUBS__)
#include "wx/stubs/cursor.h"
#endif
#include "wx/utils.h"
/* This is a small class which can be used by all ports
to temporarily suspend the busy cursor. Useful in modal
dialogs.
Actually that is not (any longer) quite true.. currently it is
only used in wxGTK Dialog::ShowModal() and now uses static
wxBusyCursor methods that are only implemented for wxGTK so far.
The BusyCursor handling code should probably be implemented in
common code somewhere instead of the separate implementations we
currently have. Also the name BusyCursorSuspender is a little
misleading since it doesn't actually suspend the BusyCursor, just
masks one that is already showing.
If another call to wxBeginBusyCursor is made while this is active
the Busy Cursor will again be shown. But at least now it doesn't
interfere with the state of wxIsBusy() -- RL
*/
class wxBusyCursorSuspender
{
public:
wxBusyCursorSuspender()
{
if( wxIsBusy() )
{
wxSetCursor( wxBusyCursor::GetStoredCursor() );
}
}
~wxBusyCursorSuspender()
{
if( wxIsBusy() )
{
wxSetCursor( wxBusyCursor::GetBusyCursor() );
}
}
};
#endif
// _WX_CURSOR_H_BASE_

467
include/wx/dataobj.h Normal file
View File

@@ -0,0 +1,467 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/dataobj.h
// Purpose: common data object classes
// Author: Vadim Zeitlin, Robert Roebling
// Modified by:
// Created: 26.05.99
// RCS-ID: $Id$
// Copyright: (c) wxWindows Team
// Licence: wxWindows license
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_DATAOBJ_H_BASE_
#define _WX_DATAOBJ_H_BASE_
#ifdef __GNUG__
#pragma interface "dataobjbase.h"
#endif
// ----------------------------------------------------------------------------
// headers
// ----------------------------------------------------------------------------
#include "wx/defs.h"
#include "wx/string.h"
#include "wx/bitmap.h"
#include "wx/list.h"
// ============================================================================
/*
Generic data transfer related classes. The class hierarchy is as follows:
- wxDataObject-
/ \
/ \
wxDataObjectSimple wxDataObjectComposite
/ | \
/ | \
wxTextDataObject | wxBitmapDataObject
|
wxCustomDataObject
*/
// ============================================================================
// ----------------------------------------------------------------------------
// wxDataFormat class is declared in platform-specific headers: it represents
// a format for data which may be either one of the standard ones (text,
// bitmap, ...) or a custom one which is then identified by a unique string.
// ----------------------------------------------------------------------------
/* the class interface looks like this (pseudo code):
class wxDataFormat
{
public:
typedef <integral type> NativeFormat;
wxDataFormat(NativeFormat format = wxDF_INVALID);
wxDataFormat(const wxChar *format);
wxDataFormat& operator=(NativeFormat format);
wxDataFormat& operator=(const wxDataFormat& format);
bool operator==(NativeFormat format) const;
bool operator!=(NativeFormat format) const;
void SetType(NativeFormat format);
NativeFormat GetType() const;
wxString GetId() const;
void SetId(const wxChar *format);
};
*/
#if defined(__WXMSW__)
#include "wx/msw/ole/dataform.h"
#elif defined(__WXMOTIF__)
#include "wx/motif/dataform.h"
#elif defined(__WXGTK__)
#include "wx/gtk/dataform.h"
#elif defined(__WXMAC__)
#include "wx/mac/dataform.h"
#elif defined(__WXPM__)
#include "wx/os2/dataform.h"
#endif
// the value for default argument to some functions (corresponds to
// wxDF_INVALID)
extern WXDLLEXPORT const wxDataFormat& wxFormatInvalid;
// ----------------------------------------------------------------------------
// wxDataObject represents a piece of data which knows which formats it
// supports and knows how to render itself in each of them - GetDataHere(),
// and how to restore data from the buffer (SetData()).
//
// Although this class may be used directly (i.e. custom classes may be
// derived from it), in many cases it might be simpler to use either
// wxDataObjectSimple or wxDataObjectComposite classes.
//
// A data object may be "read only", i.e. support only GetData() functions or
// "read-write", i.e. support both GetData() and SetData() (in principle, it
// might be "write only" too, but this is rare). Moreover, it doesn't have to
// support the same formats in Get() and Set() directions: for example, a data
// object containing JPEG image might accept BMPs in GetData() because JPEG
// image may be easily transformed into BMP but not in SetData(). Accordingly,
// all methods dealing with formats take an additional "direction" argument
// which is either SET or GET and which tells the function if the format needs
// to be supported by SetData() or GetDataHere().
// ----------------------------------------------------------------------------
class WXDLLEXPORT wxDataObjectBase
{
public:
enum Direction
{
Get = 0x01, // format is supported by GetDataHere()
Set = 0x02, // format is supported by SetData()
Both = 0x03 // format is supported by both (unused currently)
};
// this class is polymorphic, hence it needs a virtual dtor
virtual ~wxDataObjectBase();
// get the best suited format for rendering our data
virtual wxDataFormat GetPreferredFormat(Direction dir = Get) const = 0;
// get the number of formats we support
virtual size_t GetFormatCount(Direction dir = Get) const = 0;
// return all formats in the provided array (of size GetFormatCount())
virtual void GetAllFormats(wxDataFormat *formats,
Direction dir = Get) const = 0;
// get the (total) size of data for the given format
virtual size_t GetDataSize(const wxDataFormat& format) const = 0;
// copy raw data (in the specified format) to the provided buffer, return
// TRUE if data copied successfully, FALSE otherwise
virtual bool GetDataHere(const wxDataFormat& format, void *buf) const = 0;
// get data from the buffer of specified length (in the given format),
// return TRUE if the data was read successfully, FALSE otherwise
virtual bool SetData(const wxDataFormat& WXUNUSED(format),
size_t WXUNUSED(len), const void * WXUNUSED(buf))
{
return FALSE;
}
// returns TRUE if this format is supported
bool IsSupported(const wxDataFormat& format, Direction dir = Get) const;
};
// ----------------------------------------------------------------------------
// include the platform-specific declarations of wxDataObject
// ----------------------------------------------------------------------------
#if defined(__WXMSW__)
#include "wx/msw/ole/dataobj.h"
#elif defined(__WXMOTIF__)
#include "wx/motif/dataobj.h"
#elif defined(__WXGTK__)
#include "wx/gtk/dataobj.h"
#elif defined(__WXQT__)
#include "wx/qt/dnd.h"
#elif defined(__WXMAC__)
#include "wx/mac/dataobj.h"
#elif defined(__WXPM__)
#include "wx/os2/dataobj.h"
#elif defined(__WXSTUBS__)
#include "wx/stubs/dnd.h"
#endif
// ----------------------------------------------------------------------------
// wxDataObjectSimple is a wxDataObject which only supports one format (in
// both Get and Set directions, but you may return FALSE from GetDataHere() or
// SetData() if one of them is not supported). This is the simplest possible
// wxDataObject implementation.
//
// This is still an "abstract base class" (although it doesn't have any pure
// virtual functions), to use it you should derive from it and implement
// GetDataSize(), GetDataHere() and SetData() functions because the base class
// versions don't do anything - they just return "not implemented".
//
// This class should be used when you provide data in only one format (no
// conversion to/from other formats), either a standard or a custom one.
// Otherwise, you should use wxDataObjectComposite or wxDataObject directly.
// ----------------------------------------------------------------------------
class WXDLLEXPORT wxDataObjectSimple : public wxDataObject
{
public:
// ctor takes the format we support, but it can also be set later with
// SetFormat()
wxDataObjectSimple(const wxDataFormat& format = wxFormatInvalid)
: m_format(format)
{
}
// get/set the format we support
const wxDataFormat& GetFormat() const { return m_format; }
void SetFormat(const wxDataFormat& format) { m_format = format; }
// virtual functions to override in derived class (the base class versions
// just return "not implemented")
// -----------------------------------------------------------------------
// get the size of our data
virtual size_t GetDataSize() const
{ return 0; }
// copy our data to the buffer
virtual bool GetDataHere(void *WXUNUSED(buf)) const
{ return FALSE; }
// copy data from buffer to our data
virtual bool SetData(size_t WXUNUSED(len), const void *WXUNUSED(buf))
{ return FALSE; }
// implement base class pure virtuals
// ----------------------------------
virtual wxDataFormat GetPreferredFormat(wxDataObjectBase::Direction WXUNUSED(dir) = Get) const
{ return m_format; }
virtual size_t GetFormatCount(wxDataObjectBase::Direction WXUNUSED(dir) = Get) const
{ return 1; }
virtual void GetAllFormats(wxDataFormat *formats,
wxDataObjectBase::Direction WXUNUSED(dir) = Get) const
{ *formats = m_format; }
virtual size_t GetDataSize(const wxDataFormat& WXUNUSED(format)) const
{ return GetDataSize(); }
virtual bool GetDataHere(const wxDataFormat& WXUNUSED(format),
void *buf) const
{ return GetDataHere(buf); }
virtual bool SetData(const wxDataFormat& WXUNUSED(format),
size_t len, const void *buf)
{ return SetData(len, buf); }
private:
// the one and only format we support
wxDataFormat m_format;
};
// ----------------------------------------------------------------------------
// wxDataObjectComposite is the simplest way to implement wxDataObject
// supporting multiple formats. It contains several wxDataObjectSimple and
// supports all formats supported by any of them.
//
// This class shouldn't be (normally) derived from, but may be used directly.
// If you need more flexibility than what it provides, you should probably use
// wxDataObject directly.
// ----------------------------------------------------------------------------
WX_DECLARE_EXPORTED_LIST(wxDataObjectSimple, wxSimpleDataObjectList);
class WXDLLEXPORT wxDataObjectComposite : public wxDataObject
{
public:
// ctor
wxDataObjectComposite() { m_preferred = 0; }
// add data object (it will be deleted by wxDataObjectComposite, hence it
// must be allocated on the heap) whose format will become the preferred
// one if preferred == TRUE
void Add(wxDataObjectSimple *dataObject, bool preferred = FALSE);
// implement base class pure virtuals
// ----------------------------------
virtual wxDataFormat GetPreferredFormat(wxDataObjectBase::Direction dir = Get) const;
virtual size_t GetFormatCount(wxDataObjectBase::Direction dir = Get) const;
virtual void GetAllFormats(wxDataFormat *formats, wxDataObjectBase::Direction dir = Get) const;
virtual size_t GetDataSize(const wxDataFormat& format) const;
virtual bool GetDataHere(const wxDataFormat& format, void *buf) const;
virtual bool SetData(const wxDataFormat& format, size_t len, const void *buf);
protected:
// returns the pointer to the object which supports this format or NULL
wxDataObjectSimple *GetObject(const wxDataFormat& format) const;
private:
// the list of all (simple) data objects whose formats we support
wxSimpleDataObjectList m_dataObjects;
// the index of the preferred one (0 initially, so by default the first
// one is the preferred)
size_t m_preferred;
};
// ============================================================================
// Standard implementations of wxDataObjectSimple which can be used directly
// (i.e. without having to derive from them) for standard data type transfers.
//
// Note that although all of them can work with provided data, you can also
// override their virtual GetXXX() functions to only provide data on demand.
// ============================================================================
// ----------------------------------------------------------------------------
// wxTextDataObject contains text data
// ----------------------------------------------------------------------------
class WXDLLEXPORT wxTextDataObject : public wxDataObjectSimple
{
public:
// ctor: you can specify the text here or in SetText(), or override
// GetText()
wxTextDataObject(const wxString& text = wxEmptyString)
: wxDataObjectSimple(wxDF_TEXT), m_text(text)
{
}
// virtual functions which you may override if you want to provide text on
// demand only - otherwise, the trivial default versions will be used
virtual size_t GetTextLength() const { return m_text.Len() + 1; }
virtual wxString GetText() const { return m_text; }
virtual void SetText(const wxString& text) { m_text = text; }
// implement base class pure virtuals
// ----------------------------------
virtual size_t GetDataSize() const;
virtual bool GetDataHere(void *buf) const;
virtual bool SetData(size_t len, const void *buf);
private:
wxString m_text;
// virtual function hiding supression
size_t GetDataSize(const wxDataFormat& format) const
{ return(wxDataObjectSimple::GetDataSize(format)); }
bool GetDataHere(const wxDataFormat& format, void *pBuf) const
{ return(wxDataObjectSimple::GetDataHere(format, pBuf)); }
bool SetData(const wxDataFormat& format, size_t nLen, const void* pBuf)
{ return(wxDataObjectSimple::SetData(format, nLen, pBuf)); }
};
// ----------------------------------------------------------------------------
// wxBitmapDataObject contains a bitmap
// ----------------------------------------------------------------------------
class WXDLLEXPORT wxBitmapDataObjectBase : public wxDataObjectSimple
{
public:
// ctor: you can specify the bitmap here or in SetBitmap(), or override
// GetBitmap()
wxBitmapDataObjectBase(const wxBitmap& bitmap = wxNullBitmap)
: wxDataObjectSimple(wxDF_BITMAP), m_bitmap(bitmap)
{
}
// virtual functions which you may override if you want to provide data on
// demand only - otherwise, the trivial default versions will be used
virtual wxBitmap GetBitmap() const { return m_bitmap; }
virtual void SetBitmap(const wxBitmap& bitmap) { m_bitmap = bitmap; }
protected:
wxBitmap m_bitmap;
};
// ----------------------------------------------------------------------------
// wxFileDataObject contains a list of filenames
//
// NB: notice that this is a "write only" object, it can only be filled with
// data from drag and drop operation.
// ----------------------------------------------------------------------------
class WXDLLEXPORT wxFileDataObjectBase : public wxDataObjectSimple
{
public:
// ctor: use AddFile() later to fill the array
wxFileDataObjectBase() : wxDataObjectSimple(wxDF_FILENAME) { }
// get a reference to our array
const wxArrayString& GetFilenames() const { return m_filenames; }
// the Get() functions do nothing for us
virtual size_t GetDataSize() const { return 0; }
virtual bool GetDataHere(void *WXUNUSED(buf)) const { return FALSE; }
protected:
wxArrayString m_filenames;
private:
// Virtual function hiding supression
size_t GetDataSize(const wxDataFormat& format) const
{ return(wxDataObjectSimple::GetDataSize(format)); }
bool GetDataHere(const wxDataFormat& format, void* pBuf) const
{ return(wxDataObjectSimple::GetDataHere(format, pBuf)); }
};
// ----------------------------------------------------------------------------
// wxCustomDataObject contains arbitrary untyped user data.
//
// It is understood that this data can be copied bitwise.
// ----------------------------------------------------------------------------
class WXDLLEXPORT wxCustomDataObject : public wxDataObjectSimple
{
public:
// if you don't specify the format in the ctor, you can still use
// SetFormat() later
wxCustomDataObject(const wxDataFormat& format = wxFormatInvalid);
// the dtor calls Free()
virtual ~wxCustomDataObject();
// you can call SetData() to set m_data: it will make a copy of the data
// you pass - or you can use TakeData() which won't copy anything, but
// will take ownership of data (i.e. will call Free() on it later)
void TakeData(size_t size, void *data);
// this function is called to allocate "size" bytes of memory from
// SetData(). The default version uses operator new[].
virtual void *Alloc(size_t size);
// this function is called when the data is freed, you may override it to
// anything you want (or may be nothing at all). The default version calls
// operator delete[] on m_data
virtual void Free();
// get data: you may override these functions if you wish to provide data
// only when it's requested
virtual size_t GetSize() const { return m_size; }
virtual void *GetData() const { return m_data; }
// implement base class pure virtuals
// ----------------------------------
virtual size_t GetDataSize() const;
virtual bool GetDataHere(void *buf) const;
virtual bool SetData(size_t size, const void *buf);
private:
size_t m_size;
void *m_data;
// virtual function hiding supression
size_t GetDataSize(const wxDataFormat& format) const
{ return(wxDataObjectSimple::GetDataSize(format)); }
bool GetDataHere(const wxDataFormat& format, void* pBuf) const
{ return(wxDataObjectSimple::GetDataHere(format, pBuf)); }
bool SetData(const wxDataFormat& format, size_t nLen, const void* pBuf)
{ return(wxDataObjectSimple::SetData(format, nLen, pBuf)); }
};
// ----------------------------------------------------------------------------
// include platform-specific declarations of wxXXXBase classes
// ----------------------------------------------------------------------------
#if defined(__WXMSW__)
#include "wx/msw/ole/dataobj2.h"
// wxURLDataObject defined in msw/ole/dataobj2.h
#else // !__WXMSW__
#if defined(__WXGTK__)
#include "wx/gtk/dataobj2.h"
#elif defined(__WXMAC__)
#include "wx/mac/dataobj2.h"
#elif defined(__WXPM__)
#include "wx/os2/dataobj2.h"
#endif
// wxURLDataObject is simply wxTextDataObject with a different name
class WXDLLEXPORT wxURLDataObject : public wxTextDataObject
{
public:
wxString GetURL() const { return GetText(); }
};
#endif // __WXMSW__/!__WXMSW__
#endif // _WX_DATAOBJ_H_BASE_

812
include/wx/dc.h Normal file
View File

@@ -0,0 +1,812 @@
/////////////////////////////////////////////////////////////////////////////
// Name: dc.h
// Purpose: wxDC class
// Author: Vadim Zeitlin
// Modified by:
// Created: 05/25/99
// RCS-ID: $Id$
// Copyright: (c) wxWindows team
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_DC_H_BASE_
#define _WX_DC_H_BASE_
#ifdef __GNUG__
#pragma interface "dcbase.h"
#endif
// ----------------------------------------------------------------------------
// headers which we must include here
// ----------------------------------------------------------------------------
#include "wx/object.h" // the base class
#include "wx/cursor.h" // we have member variables of these classes
#include "wx/font.h" // so we can't do without them
#include "wx/colour.h"
#include "wx/brush.h"
#include "wx/pen.h"
#include "wx/palette.h"
#include "wx/list.h" // we use wxList in inline functions
class WXDLLEXPORT wxDCBase;
class WXDLLEXPORT wxDrawObject
{
public:
wxDrawObject()
{
ResetBoundingBox();
}
virtual ~wxDrawObject() { }
virtual void Draw(wxDCBase&) const { }
virtual void CalcBoundingBox(wxCoord x, wxCoord y)
{
if ( m_isBBoxValid )
{
if ( x < m_minX ) m_minX = x;
if ( y < m_minY ) m_minY = y;
if ( x > m_maxX ) m_maxX = x;
if ( y > m_maxY ) m_maxY = y;
}
else
{
m_isBBoxValid = TRUE;
m_minX = x;
m_minY = y;
m_maxX = x;
m_maxY = y;
}
}
void ResetBoundingBox()
{
m_isBBoxValid = FALSE;
m_minX = m_maxX = m_minY = m_maxY = 0;
}
// Get the final bounding box of the PostScript or Metafile picture.
wxCoord MinX() const { return m_minX; }
wxCoord MaxX() const { return m_maxX; }
wxCoord MinY() const { return m_minY; }
wxCoord MaxY() const { return m_maxY; }
//to define the type of object for derived objects
virtual int GetType()=0;
protected:
//for boundingbox calculation
bool m_isBBoxValid:1;
//for boundingbox calculation
wxCoord m_minX, m_minY, m_maxX, m_maxY;
};
// ---------------------------------------------------------------------------
// global variables
// ---------------------------------------------------------------------------
WXDLLEXPORT_DATA(extern int) wxPageNumber;
// ---------------------------------------------------------------------------
// wxDC is the device context - object on which any drawing is done
// ---------------------------------------------------------------------------
class WXDLLEXPORT wxDCBase : public wxObject
{
public:
wxDCBase()
{
m_clipping = FALSE;
m_ok = TRUE;
ResetBoundingBox();
m_signX = m_signY = 1;
m_logicalOriginX = m_logicalOriginY =
m_deviceOriginX = m_deviceOriginY = 0;
m_logicalScaleX = m_logicalScaleY =
m_userScaleX = m_userScaleY =
m_scaleX = m_scaleY = 1.0;
m_logicalFunction = wxCOPY;
m_backgroundMode = wxTRANSPARENT;
m_mappingMode = wxMM_TEXT;
m_backgroundBrush = *wxTRANSPARENT_BRUSH;
m_textForegroundColour = *wxBLACK;
m_textBackgroundColour = *wxWHITE;
m_colour = wxColourDisplay();
}
~wxDCBase() { }
virtual void BeginDrawing() { }
virtual void EndDrawing() { }
// graphic primitives
// ------------------
virtual void DrawObject(wxDrawObject* drawobject)
{
drawobject->Draw(*this);
CalcBoundingBox(drawobject->MinX(),drawobject->MinY());
CalcBoundingBox(drawobject->MaxX(),drawobject->MaxY());
}
void FloodFill(wxCoord x, wxCoord y, const wxColour& col,
int style = wxFLOOD_SURFACE)
{ DoFloodFill(x, y, col, style); }
void FloodFill(const wxPoint& pt, const wxColour& col,
int style = wxFLOOD_SURFACE)
{ DoFloodFill(pt.x, pt.y, col, style); }
bool GetPixel(wxCoord x, wxCoord y, wxColour *col) const
{ return DoGetPixel(x, y, col); }
bool GetPixel(const wxPoint& pt, wxColour *col) const
{ return DoGetPixel(pt.x, pt.y, col); }
void DrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2)
{ DoDrawLine(x1, y1, x2, y2); }
void DrawLine(const wxPoint& pt1, const wxPoint& pt2)
{ DoDrawLine(pt1.x, pt1.y, pt2.x, pt2.y); }
void CrossHair(wxCoord x, wxCoord y)
{ DoCrossHair(x, y); }
void CrossHair(const wxPoint& pt)
{ DoCrossHair(pt.x, pt.y); }
void DrawArc(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2,
wxCoord xc, wxCoord yc)
{ DoDrawArc(x1, y1, x2, y2, xc, yc); }
void DrawArc(const wxPoint& pt1, const wxPoint& pt2, const wxPoint& centre)
{ DoDrawArc(pt1.x, pt1.y, pt2.x, pt2.y, centre.x, centre.y); }
void DrawCheckMark(wxCoord x, wxCoord y,
wxCoord width, wxCoord height)
{ DoDrawCheckMark(x, y, width, height); }
void DrawCheckMark(const wxRect& rect)
{ DoDrawCheckMark(rect.x, rect.y, rect.width, rect.height); }
void DrawEllipticArc(wxCoord x, wxCoord y, wxCoord w, wxCoord h,
double sa, double ea)
{ DoDrawEllipticArc(x, y, w, h, sa, ea); }
void DrawEllipticArc(const wxPoint& pt, const wxSize& sz,
double sa, double ea)
{ DoDrawEllipticArc(pt.x, pt.y, sz.x, sz.y, sa, ea); }
void DrawPoint(wxCoord x, wxCoord y)
{ DoDrawPoint(x, y); }
void DrawPoint(const wxPoint& pt)
{ DoDrawPoint(pt.x, pt.y); }
void DrawLines(int n, wxPoint points[],
wxCoord xoffset = 0, wxCoord yoffset = 0)
{ DoDrawLines(n, points, xoffset, yoffset); }
void DrawLines(const wxList *list,
wxCoord xoffset = 0, wxCoord yoffset = 0);
void DrawPolygon(int n, wxPoint points[],
wxCoord xoffset = 0, wxCoord yoffset = 0,
int fillStyle = wxODDEVEN_RULE)
{ DoDrawPolygon(n, points, xoffset, yoffset, fillStyle); }
void DrawPolygon(const wxList *list,
wxCoord xoffset = 0, wxCoord yoffset = 0,
int fillStyle = wxODDEVEN_RULE);
void DrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
{ DoDrawRectangle(x, y, width, height); }
void DrawRectangle(const wxPoint& pt, const wxSize& sz)
{ DoDrawRectangle(pt.x, pt.y, sz.x, sz.y); }
void DrawRectangle(const wxRect& rect)
{ DoDrawRectangle(rect.x, rect.y, rect.width, rect.height); }
void DrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height,
double radius)
{ DoDrawRoundedRectangle(x, y, width, height, radius); }
void DrawRoundedRectangle(const wxPoint& pt, const wxSize& sz,
double radius)
{ DoDrawRoundedRectangle(pt.x, pt.y, sz.x, sz.y, radius); }
void DrawRoundedRectangle(const wxRect& r, double radius)
{ DoDrawRoundedRectangle(r.x, r.y, r.width, r.height, radius); }
void DrawCircle(wxCoord x, wxCoord y, wxCoord radius)
{ DoDrawEllipse(x - radius, y - radius, 2*radius, 2*radius); }
void DrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
{ DoDrawEllipse(x, y, width, height); }
void DrawEllipse(const wxPoint& pt, const wxSize& sz)
{ DoDrawEllipse(pt.x, pt.y, sz.x, sz.y); }
void DrawEllipse(const wxRect& rect)
{ DoDrawEllipse(rect.x, rect.y, rect.width, rect.height); }
void DrawIcon(const wxIcon& icon, wxCoord x, wxCoord y)
{ DoDrawIcon(icon, x, y); }
void DrawIcon(const wxIcon& icon, const wxPoint& pt)
{ DoDrawIcon(icon, pt.x, pt.y); }
void DrawBitmap(const wxBitmap &bmp, wxCoord x, wxCoord y,
bool useMask = FALSE)
{ DoDrawBitmap(bmp, x, y, useMask); }
void DrawBitmap(const wxBitmap &bmp, const wxPoint& pt,
bool useMask = FALSE)
{ DoDrawBitmap(bmp, pt.x, pt.y, useMask); }
void DrawText(const wxString& text, wxCoord x, wxCoord y)
{ DoDrawText(text, x, y); }
void DrawText(const wxString& text, const wxPoint& pt)
{ DoDrawText(text, pt.x, pt.y); }
void DrawRotatedText(const wxString& text, wxCoord x, wxCoord y, double angle)
{ DoDrawRotatedText(text, x, y, angle); }
void DrawRotatedText(const wxString& text, const wxPoint& pt, double angle)
{ DoDrawRotatedText(text, pt.x, pt.y, angle); }
// this version puts both optional bitmap and the text into the given
// rectangle and aligns is as specified by alignment parameter; it also
// will emphasize the character with the given index if it is != -1 and
// return the bounding rectangle if required
virtual void DrawLabel(const wxString& text,
const wxBitmap& image,
const wxRect& rect,
int alignment = wxALIGN_LEFT | wxALIGN_TOP,
int indexAccel = -1,
wxRect *rectBounding = NULL);
void DrawLabel(const wxString& text, const wxRect& rect,
int alignment = wxALIGN_LEFT | wxALIGN_TOP,
int indexAccel = -1)
{ DrawLabel(text, wxNullBitmap, rect, alignment, indexAccel); }
bool Blit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height,
wxDC *source, wxCoord xsrc, wxCoord ysrc,
int rop = wxCOPY, bool useMask = FALSE, wxCoord xsrcMask = -1, wxCoord ysrcMask = -1)
{
return DoBlit(xdest, ydest, width, height,
source, xsrc, ysrc, rop, useMask, xsrcMask, ysrcMask);
}
bool Blit(const wxPoint& destPt, const wxSize& sz,
wxDC *source, const wxPoint& srcPt,
int rop = wxCOPY, bool useMask = FALSE, const wxPoint& srcPtMask = wxPoint(-1, -1))
{
return DoBlit(destPt.x, destPt.y, sz.x, sz.y,
source, srcPt.x, srcPt.y, rop, useMask, srcPtMask.x, srcPtMask.y);
}
#if wxUSE_SPLINES
// TODO: this API needs fixing (wxPointList, why (!const) "wxList *"?)
void DrawSpline(wxCoord x1, wxCoord y1,
wxCoord x2, wxCoord y2,
wxCoord x3, wxCoord y3);
void DrawSpline(int n, wxPoint points[]);
void DrawSpline(wxList *points) { DoDrawSpline(points); }
#endif // wxUSE_SPLINES
// global DC operations
// --------------------
virtual void Clear() = 0;
virtual bool StartDoc(const wxString& WXUNUSED(message)) { return TRUE; }
virtual void EndDoc() { }
virtual void StartPage() { }
virtual void EndPage() { }
// set objects to use for drawing
// ------------------------------
virtual void SetFont(const wxFont& font) = 0;
virtual void SetPen(const wxPen& pen) = 0;
virtual void SetBrush(const wxBrush& brush) = 0;
virtual void SetBackground(const wxBrush& brush) = 0;
virtual void SetBackgroundMode(int mode) = 0;
virtual void SetPalette(const wxPalette& palette) = 0;
// clipping region
// ---------------
void SetClippingRegion(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
{ DoSetClippingRegion(x, y, width, height); }
void SetClippingRegion(const wxPoint& pt, const wxSize& sz)
{ DoSetClippingRegion(pt.x, pt.y, sz.x, sz.y); }
void SetClippingRegion(const wxRect& rect)
{ DoSetClippingRegion(rect.x, rect.y, rect.width, rect.height); }
void SetClippingRegion(const wxRegion& region)
{ DoSetClippingRegionAsRegion(region); }
virtual void DestroyClippingRegion() = 0;
void GetClippingBox(wxCoord *x, wxCoord *y, wxCoord *w, wxCoord *h) const
{ DoGetClippingBox(x, y, w, h); }
void GetClippingBox(wxRect& rect) const
{
// Necessary to use intermediate variables for 16-bit compilation
wxCoord x, y, w, h;
DoGetClippingBox(&x, &y, &w, &h);
rect.x = x; rect.y = y; rect.width = w; rect.height = h;
}
// text extent
// -----------
virtual wxCoord GetCharHeight() const = 0;
virtual wxCoord GetCharWidth() const = 0;
// only works for single line strings
void GetTextExtent(const wxString& string,
wxCoord *x, wxCoord *y,
wxCoord *descent = NULL,
wxCoord *externalLeading = NULL,
wxFont *theFont = NULL) const
{ DoGetTextExtent(string, x, y, descent, externalLeading, theFont); }
// works for single as well as multi-line strings
virtual void GetMultiLineTextExtent(const wxString& text,
wxCoord *width,
wxCoord *height,
wxCoord *heightLine = NULL,
wxFont *font = NULL);
// size and resolution
// -------------------
// in device units
void GetSize(int *width, int *height) const
{ DoGetSize(width, height); }
wxSize GetSize() const
{
int w, h;
DoGetSize(&w, &h);
return wxSize(w, h);
}
// in mm
void GetSizeMM(int* width, int* height) const
{ DoGetSizeMM(width, height); }
wxSize GetSizeMM() const
{
int w, h;
DoGetSizeMM(&w, &h);
return wxSize(w, h);
}
// coordinates conversions
// -----------------------
// This group of functions does actual conversion of the input, as you'd
// expect.
wxCoord DeviceToLogicalX(wxCoord x) const;
wxCoord DeviceToLogicalY(wxCoord y) const;
wxCoord DeviceToLogicalXRel(wxCoord x) const;
wxCoord DeviceToLogicalYRel(wxCoord y) const;
wxCoord LogicalToDeviceX(wxCoord x) const;
wxCoord LogicalToDeviceY(wxCoord y) const;
wxCoord LogicalToDeviceXRel(wxCoord x) const;
wxCoord LogicalToDeviceYRel(wxCoord y) const;
// query DC capabilities
// ---------------------
virtual bool CanDrawBitmap() const = 0;
virtual bool CanGetTextExtent() const = 0;
// colour depth
virtual int GetDepth() const = 0;
// Resolution in Pixels per inch
virtual wxSize GetPPI() const = 0;
virtual bool Ok() const { return m_ok; }
// accessors
// ---------
// const...
int GetBackgroundMode() const { return m_backgroundMode; }
const wxBrush& GetBackground() const { return m_backgroundBrush; }
const wxBrush& GetBrush() const { return m_brush; }
const wxFont& GetFont() const { return m_font; }
const wxPen& GetPen() const { return m_pen; }
const wxColour& GetTextBackground() const { return m_textBackgroundColour; }
const wxColour& GetTextForeground() const { return m_textForegroundColour; }
// ... and non const
wxBrush& GetBackground() { return m_backgroundBrush; }
wxBrush& GetBrush() { return m_brush; }
wxFont& GetFont() { return m_font; }
wxPen& GetPen() { return m_pen; }
wxColour& GetTextBackground() { return m_textBackgroundColour; }
wxColour& GetTextForeground() { return m_textForegroundColour; }
virtual void SetTextForeground(const wxColour& colour)
{ m_textForegroundColour = colour; }
virtual void SetTextBackground(const wxColour& colour)
{ m_textBackgroundColour = colour; }
int GetMapMode() const { return m_mappingMode; }
virtual void SetMapMode(int mode) = 0;
virtual void GetUserScale(double *x, double *y) const
{
if ( x ) *x = m_userScaleX;
if ( y ) *y = m_userScaleY;
}
virtual void SetUserScale(double x, double y) = 0;
virtual void GetLogicalScale(double *x, double *y)
{
if ( x ) *x = m_logicalScaleX;
if ( y ) *y = m_logicalScaleY;
}
virtual void SetLogicalScale(double x, double y)
{
m_logicalScaleX = x;
m_logicalScaleY = y;
}
void GetLogicalOrigin(wxCoord *x, wxCoord *y) const
{ DoGetLogicalOrigin(x, y); }
wxPoint GetLogicalOrigin() const
{ wxCoord x, y; DoGetLogicalOrigin(&x, &y); return wxPoint(x, y); }
virtual void SetLogicalOrigin(wxCoord x, wxCoord y) = 0;
void GetDeviceOrigin(wxCoord *x, wxCoord *y) const
{ DoGetDeviceOrigin(x, y); }
wxPoint GetDeviceOrigin() const
{ wxCoord x, y; DoGetDeviceOrigin(&x, &y); return wxPoint(x, y); }
virtual void SetDeviceOrigin(wxCoord x, wxCoord y) = 0;
virtual void SetAxisOrientation(bool xLeftRight, bool yBottomUp) = 0;
int GetLogicalFunction() const { return m_logicalFunction; }
virtual void SetLogicalFunction(int function) = 0;
// Sometimes we need to override optimization, e.g. if other software is
// drawing onto our surface and we can't be sure of who's done what.
//
// FIXME: is this (still) used?
virtual void SetOptimization(bool WXUNUSED(opt)) { }
virtual bool GetOptimization() { return FALSE; }
// Some platforms have a DC cache, which should be cleared
// at appropriate points such as after a series of DC operations.
// Put ClearCache in the wxDC implementation class, since it has to be
// static.
// static void ClearCache() ;
#if 0 // wxUSE_DC_CACHEING
static void EnableCache(bool cacheing) { sm_cacheing = cacheing; }
static bool CacheEnabled() { return sm_cacheing ; }
#endif
// bounding box
// ------------
virtual void CalcBoundingBox(wxCoord x, wxCoord y)
{
if ( m_isBBoxValid )
{
if ( x < m_minX ) m_minX = x;
if ( y < m_minY ) m_minY = y;
if ( x > m_maxX ) m_maxX = x;
if ( y > m_maxY ) m_maxY = y;
}
else
{
m_isBBoxValid = TRUE;
m_minX = x;
m_minY = y;
m_maxX = x;
m_maxY = y;
}
}
void ResetBoundingBox()
{
m_isBBoxValid = FALSE;
m_minX = m_maxX = m_minY = m_maxY = 0;
}
// Get the final bounding box of the PostScript or Metafile picture.
wxCoord MinX() const { return m_minX; }
wxCoord MaxX() const { return m_maxX; }
wxCoord MinY() const { return m_minY; }
wxCoord MaxY() const { return m_maxY; }
// misc old functions
// ------------------
// for compatibility with the old code when wxCoord was long everywhere
#ifndef __WIN16__
void GetTextExtent(const wxString& string,
long *x, long *y,
long *descent = NULL,
long *externalLeading = NULL,
wxFont *theFont = NULL) const
{
wxCoord x2, y2, descent2, externalLeading2;
DoGetTextExtent(string, &x2, &y2,
&descent2, &externalLeading2,
theFont);
if ( x )
*x = x2;
if ( y )
*y = y2;
if ( descent )
*descent = descent2;
if ( externalLeading )
*externalLeading = externalLeading2;
}
void GetLogicalOrigin(long *x, long *y) const
{
wxCoord x2, y2;
DoGetLogicalOrigin(&x2, &y2);
if ( x )
*x = x2;
if ( y )
*y = y2;
}
void GetDeviceOrigin(long *x, long *y) const
{
wxCoord x2, y2;
DoGetDeviceOrigin(&x2, &y2);
if ( x )
*x = x2;
if ( y )
*y = y2;
}
void GetClippingBox(long *x, long *y, long *w, long *h) const
{
wxCoord xx,yy,ww,hh;
DoGetClippingBox(&xx, &yy, &ww, &hh);
if (x) *x = xx;
if (y) *y = yy;
if (w) *w = ww;
if (h) *h = hh;
}
#endif // !Win16
#if WXWIN_COMPATIBILITY
virtual void SetColourMap(const wxPalette& palette) { SetPalette(palette); }
void GetTextExtent(const wxString& string, float *x, float *y,
float *descent = NULL, float *externalLeading = NULL,
wxFont *theFont = NULL, bool use16bit = FALSE) const ;
void GetSize(float* width, float* height) const { int w, h; GetSize(& w, & h); *width = w; *height = h; }
void GetSizeMM(float *width, float *height) const { long w, h; GetSizeMM(& w, & h); *width = (float) w; *height = (float) h; }
#endif // WXWIN_COMPATIBILITY
protected:
// the pure virtual functions which should be implemented by wxDC
virtual void DoFloodFill(wxCoord x, wxCoord y, const wxColour& col,
int style = wxFLOOD_SURFACE) = 0;
virtual bool DoGetPixel(wxCoord x, wxCoord y, wxColour *col) const = 0;
virtual void DoDrawPoint(wxCoord x, wxCoord y) = 0;
virtual void DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2) = 0;
virtual void DoDrawArc(wxCoord x1, wxCoord y1,
wxCoord x2, wxCoord y2,
wxCoord xc, wxCoord yc) = 0;
virtual void DoDrawCheckMark(wxCoord x, wxCoord y,
wxCoord width, wxCoord height);
virtual void DoDrawEllipticArc(wxCoord x, wxCoord y, wxCoord w, wxCoord h,
double sa, double ea) = 0;
virtual void DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height) = 0;
virtual void DoDrawRoundedRectangle(wxCoord x, wxCoord y,
wxCoord width, wxCoord height,
double radius) = 0;
virtual void DoDrawEllipse(wxCoord x, wxCoord y,
wxCoord width, wxCoord height) = 0;
virtual void DoCrossHair(wxCoord x, wxCoord y) = 0;
virtual void DoDrawIcon(const wxIcon& icon, wxCoord x, wxCoord y) = 0;
virtual void DoDrawBitmap(const wxBitmap &bmp, wxCoord x, wxCoord y,
bool useMask = FALSE) = 0;
virtual void DoDrawText(const wxString& text, wxCoord x, wxCoord y) = 0;
virtual void DoDrawRotatedText(const wxString& text,
wxCoord x, wxCoord y, double angle) = 0;
virtual bool DoBlit(wxCoord xdest, wxCoord ydest,
wxCoord width, wxCoord height,
wxDC *source, wxCoord xsrc, wxCoord ysrc,
int rop = wxCOPY, bool useMask = FALSE, wxCoord xsrcMask = -1, wxCoord ysrcMask = -1) = 0;
virtual void DoGetSize(int *width, int *height) const = 0;
virtual void DoGetSizeMM(int* width, int* height) const = 0;
virtual void DoDrawLines(int n, wxPoint points[],
wxCoord xoffset, wxCoord yoffset) = 0;
virtual void DoDrawPolygon(int n, wxPoint points[],
wxCoord xoffset, wxCoord yoffset,
int fillStyle = wxODDEVEN_RULE) = 0;
virtual void DoSetClippingRegionAsRegion(const wxRegion& region) = 0;
virtual void DoSetClippingRegion(wxCoord x, wxCoord y,
wxCoord width, wxCoord height) = 0;
// FIXME are these functions really different?
virtual void DoGetClippingRegion(wxCoord *x, wxCoord *y,
wxCoord *w, wxCoord *h)
{ DoGetClippingBox(x, y, w, h); }
virtual void DoGetClippingBox(wxCoord *x, wxCoord *y,
wxCoord *w, wxCoord *h) const
{
if ( m_clipping )
{
if ( x ) *x = m_clipX1;
if ( y ) *y = m_clipY1;
if ( w ) *w = m_clipX2 - m_clipX1;
if ( h ) *h = m_clipY2 - m_clipY1;
}
else
{
*x = *y = *w = *h = 0;
}
}
virtual void DoGetLogicalOrigin(wxCoord *x, wxCoord *y) const
{
if ( x ) *x = m_logicalOriginX;
if ( y ) *y = m_logicalOriginY;
}
virtual void DoGetDeviceOrigin(wxCoord *x, wxCoord *y) const
{
if ( x ) *x = m_deviceOriginX;
if ( y ) *y = m_deviceOriginY;
}
virtual void DoGetTextExtent(const wxString& string,
wxCoord *x, wxCoord *y,
wxCoord *descent = NULL,
wxCoord *externalLeading = NULL,
wxFont *theFont = NULL) const = 0;
#if wxUSE_SPLINES
virtual void DoDrawSpline(wxList *points);
#endif
protected:
// flags
bool m_colour:1;
bool m_ok:1;
bool m_clipping:1;
bool m_isInteractive:1;
bool m_isBBoxValid:1;
#if wxUSE_DC_CACHEING
// static bool sm_cacheing;
#endif
// coordinate system variables
// TODO short descriptions of what exactly they are would be nice...
wxCoord m_logicalOriginX, m_logicalOriginY;
wxCoord m_deviceOriginX, m_deviceOriginY;
double m_logicalScaleX, m_logicalScaleY;
double m_userScaleX, m_userScaleY;
double m_scaleX, m_scaleY;
// Used by SetAxisOrientation() to invert the axes
int m_signX, m_signY;
// bounding and clipping boxes
wxCoord m_minX, m_minY, m_maxX, m_maxY;
wxCoord m_clipX1, m_clipY1, m_clipX2, m_clipY2;
int m_logicalFunction;
int m_backgroundMode;
int m_mappingMode;
// GDI objects
wxPen m_pen;
wxBrush m_brush;
wxBrush m_backgroundBrush;
wxColour m_textForegroundColour;
wxColour m_textBackgroundColour;
wxFont m_font;
wxPalette m_palette;
private:
DECLARE_NO_COPY_CLASS(wxDCBase)
DECLARE_ABSTRACT_CLASS(wxDCBase)
};
// ----------------------------------------------------------------------------
// now include the declaration of wxDC class
// ----------------------------------------------------------------------------
#if defined(__WXMSW__)
#include "wx/msw/dc.h"
#elif defined(__WXMOTIF__)
#include "wx/motif/dc.h"
#elif defined(__WXGTK__)
#include "wx/gtk/dc.h"
#elif defined(__WXMGL__)
#include "wx/mgl/dc.h"
#elif defined(__WXQT__)
#include "wx/qt/dc.h"
#elif defined(__WXMAC__)
#include "wx/mac/dc.h"
#elif defined(__WXPM__)
#include "wx/os2/dc.h"
#elif defined(__WXSTUBS__)
#include "wx/stubs/dc.h"
#endif
// ----------------------------------------------------------------------------
// helper class: you can use it to temporarily change the DC text colour and
// restore it automatically when the object goes out of scope
// ----------------------------------------------------------------------------
class WXDLLEXPORT wxDCTextColourChanger
{
public:
wxDCTextColourChanger(wxDC& dc) : m_dc(dc) { }
~wxDCTextColourChanger()
{
if ( m_colFgOld.Ok() )
m_dc.SetTextForeground(m_colFgOld);
}
void Set(const wxColour& col)
{
if ( !m_colFgOld.Ok() )
m_colFgOld = m_dc.GetTextForeground();
m_dc.SetTextForeground(col);
}
private:
wxDC& m_dc;
wxColour m_colFgOld;
};
// ----------------------------------------------------------------------------
// another small helper class: sets the clipping region in its ctor and
// destroys it in the dtor
// ----------------------------------------------------------------------------
class WXDLLEXPORT wxDCClipper
{
public:
wxDCClipper(wxDC& dc, const wxRect& r) : m_dc(dc)
{ dc.SetClippingRegion(r.x, r.y, r.width, r.height); }
wxDCClipper(wxDC& dc, wxCoord x, wxCoord y, wxCoord w, wxCoord h) : m_dc(dc)
{ dc.SetClippingRegion(x, y, w, h); }
~wxDCClipper() { m_dc.DestroyClippingRegion(); }
private:
wxDC& m_dc;
};
#endif
// _WX_DC_H_BASE_

23
include/wx/dcclient.h Normal file
View File

@@ -0,0 +1,23 @@
#ifndef _WX_DCCLIENT_H_BASE_
#define _WX_DCCLIENT_H_BASE_
#if defined(__WXMSW__)
#include "wx/msw/dcclient.h"
#elif defined(__WXMOTIF__)
#include "wx/motif/dcclient.h"
#elif defined(__WXGTK__)
#include "wx/gtk/dcclient.h"
#elif defined(__WXMGL__)
#include "wx/mgl/dcclient.h"
#elif defined(__WXQT__)
#include "wx/qt/dcclient.h"
#elif defined(__WXMAC__)
#include "wx/mac/dcclient.h"
#elif defined(__WXPM__)
#include "wx/os2/dcclient.h"
#elif defined(__WXSTUBS__)
#include "wx/stubs/dcclient.h"
#endif
#endif
// _WX_DCCLIENT_H_BASE_

23
include/wx/dcmemory.h Normal file
View File

@@ -0,0 +1,23 @@
#ifndef _WX_DCMEMORY_H_BASE_
#define _WX_DCMEMORY_H_BASE_
#if defined(__WXMSW__)
#include "wx/msw/dcmemory.h"
#elif defined(__WXMOTIF__)
#include "wx/motif/dcmemory.h"
#elif defined(__WXGTK__)
#include "wx/gtk/dcmemory.h"
#elif defined(__WXMGL__)
#include "wx/mgl/dcmemory.h"
#elif defined(__WXQT__)
#include "wx/qt/dcmemory.h"
#elif defined(__WXMAC__)
#include "wx/mac/dcmemory.h"
#elif defined(__WXPM__)
#include "wx/os2/dcmemory.h"
#elif defined(__WXSTUBS__)
#include "wx/stubs/dcmemory.h"
#endif
#endif
// _WX_DCMEMORY_H_BASE_

23
include/wx/dcscreen.h Normal file
View File

@@ -0,0 +1,23 @@
#ifndef _WX_DCSCREEN_H_BASE_
#define _WX_DCSCREEN_H_BASE_
#if defined(__WXMSW__)
#include "wx/msw/dcscreen.h"
#elif defined(__WXMOTIF__)
#include "wx/motif/dcscreen.h"
#elif defined(__WXGTK__)
#include "wx/gtk/dcscreen.h"
#elif defined(__WXMGL__)
#include "wx/mgl/dcscreen.h"
#elif defined(__WXQT__)
#include "wx/qt/dcscreen.h"
#elif defined(__WXMAC__)
#include "wx/mac/dcscreen.h"
#elif defined(__WXPM__)
#include "wx/os2/dcscreen.h"
#elif defined(__WXSTUBS__)
#include "wx/stubs/dcscreen.h"
#endif
#endif
// _WX_DCSCREEN_H_BASE_

21
include/wx/dde.h Normal file
View File

@@ -0,0 +1,21 @@
#ifndef _WX_DDE_H_BASE_
#define _WX_DDE_H_BASE_
#if defined(__WXMSW__)
#include "wx/msw/dde.h"
#elif defined(__WXMOTIF__)
#include "wx/motif/dde.h"
#elif defined(__WXGTK__)
#include "wx/gtk/dde.h"
#elif defined(__WXQT__)
#include "wx/qt/dde.h"
#elif defined(__WXMAC__)
#include "wx/mac/dde.h"
#elif defined(__WXPM__)
#include "wx/os2/dde.h"
#elif defined(__WXSTUBS__)
#include "wx/stubs/dde.h"
#endif
#endif
// _WX_DDE_H_BASE_

2094
include/wx/defs.h Normal file

File diff suppressed because it is too large Load Diff

69
include/wx/dialog.h Normal file
View File

@@ -0,0 +1,69 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/dialog.h
// Purpose: wxDialogBase class
// Author: Vadim Zeitlin
// Modified by:
// Created: 29.06.99
// RCS-ID: $Id$
// Copyright: (c) Vadim Zeitlin
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_DIALOG_H_BASE_
#define _WX_DIALOG_H_BASE_
#ifdef __GNUG__
#pragma interface "dialogbase.h"
#endif
#include "wx/defs.h"
#include "wx/panel.h"
class WXDLLEXPORT wxDialogBase : public wxPanel
{
public:
#ifdef __DARWIN__
~wxDialogBase() { }
#endif
// the modal dialogs have a return code - usually the id of the last
// pressed button
void SetReturnCode(int returnCode) { m_returnCode = returnCode; }
int GetReturnCode() const { return m_returnCode; }
#if wxUSE_STATTEXT && wxUSE_TEXTCTRL
// splits text up at newlines and places the
// lines into a vertical wxBoxSizer
wxSizer *CreateTextSizer( const wxString &message );
#endif // wxUSE_STATTEXT && wxUSE_TEXTCTRL
#if wxUSE_BUTTON
// places buttons into a horizontal wxBoxSizer
wxSizer *CreateButtonSizer( long flags );
#endif // wxUSE_BUTTON
protected:
// the return code from modal dialog
int m_returnCode;
};
#if defined(__WXMSW__)
#include "wx/msw/dialog.h"
#elif defined(__WXMOTIF__)
#include "wx/motif/dialog.h"
#elif defined(__WXGTK__)
#include "wx/gtk/dialog.h"
#elif defined(__WXMGL__)
#include "wx/mgl/dialog.h"
// FIXME_MGL -- belongs to wxUniv
#elif defined(__WXQT__)
#include "wx/qt/dialog.h"
#elif defined(__WXMAC__)
#include "wx/mac/dialog.h"
#elif defined(__WXPM__)
#include "wx/os2/dialog.h"
#elif defined(__WXSTUBS__)
#include "wx/stubs/dialog.h"
#endif
#endif
// _WX_DIALOG_H_BASE_

41
include/wx/dirdlg.h Normal file
View File

@@ -0,0 +1,41 @@
#ifndef _WX_DIRDLG_H_BASE_
#define _WX_DIRDLG_H_BASE_
#if wxUSE_DIRDLG
// ----------------------------------------------------------------------------
// constants
// ----------------------------------------------------------------------------
WXDLLEXPORT_DATA(extern const wxChar*) wxDirDialogNameStr;
WXDLLEXPORT_DATA(extern const wxChar*) wxDirDialogDefaultFolderStr;
WXDLLEXPORT_DATA(extern const wxChar*) wxEmptyString;
#if defined(__WXMSW__)
#if defined(__WIN16__) || (defined(__GNUWIN32__) && !wxUSE_NORLANDER_HEADERS) || defined(__SALFORDC__)
#include "wx/generic/dirdlgg.h"
#else
#include "wx/msw/dirdlg.h"
#endif
#elif defined(__WXMOTIF__)
#include "wx/generic/dirdlgg.h"
#elif defined(__WXGTK__)
#include "wx/generic/dirdlgg.h"
#elif defined(__WXQT__)
#include "wx/qt/dirdlg.h"
#elif defined(__WXMAC__)
#ifdef __DARWIN__
#include "wx/generic/dirdlgg.h"
#else
#include "wx/mac/dirdlg.h"
#endif
#elif defined(__WXPM__)
#include "wx/os2/dirdlg.h"
#elif defined(__WXSTUBS__)
#include "wx/stubs/dirdlg.h"
#endif
#endif // wxUSE_DIRDLG
#endif
// _WX_DIRDLG_H_BASE_

232
include/wx/dnd.h Normal file
View File

@@ -0,0 +1,232 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/dnd.h
// Purpose: Drag and drop classes declarations
// Author: Vadim Zeitlin, Robert Roebling
// Modified by:
// Created: 26.05.99
// RCS-ID: $Id$
// Copyright: (c) wxWindows Team
// Licence: wxWindows license
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_DND_H_BASE_
#define _WX_DND_H_BASE_
#ifdef __GNUG__
#pragma interface "dndbase.h"
#endif
#include "wx/defs.h"
#if wxUSE_DRAG_AND_DROP
#include "wx/dataobj.h"
#include "wx/cursor.h"
// ----------------------------------------------------------------------------
// constants
// ----------------------------------------------------------------------------
// result of wxDropSource::DoDragDrop() call
enum wxDragResult
{
wxDragError, // error prevented the d&d operation from completing
wxDragNone, // drag target didn't accept the data
wxDragCopy, // the data was successfully copied
wxDragMove, // the data was successfully moved (MSW only)
wxDragCancel // the operation was cancelled by user (not an error)
};
inline WXDLLEXPORT bool wxIsDragResultOk(wxDragResult res)
{
return res == wxDragCopy || res == wxDragMove;
}
// ----------------------------------------------------------------------------
// wxDropSource is the object you need to create (and call DoDragDrop on it)
// to initiate a drag-and-drop operation
// ----------------------------------------------------------------------------
class WXDLLEXPORT wxDropSourceBase
{
public:
wxDropSourceBase(const wxCursor &cursorCopy = wxNullCursor,
const wxCursor &cursorMove = wxNullCursor,
const wxCursor &cursorStop = wxNullCursor)
: m_cursorCopy(cursorCopy),
m_cursorMove(cursorMove),
m_cursorStop(cursorStop)
{ m_data = (wxDataObject *)NULL; }
virtual ~wxDropSourceBase() { }
// set the data which is transfered by drag and drop
void SetData(wxDataObject& data)
{ m_data = &data; }
wxDataObject *GetDataObject()
{ return m_data; }
// set the icon corresponding to given drag result
void SetCursor(wxDragResult res, const wxCursor& cursor)
{
if ( res == wxDragCopy )
m_cursorCopy = cursor;
else if ( res == wxDragMove )
m_cursorMove = cursor;
else
m_cursorStop = cursor;
}
// start drag action, see enum wxDragResult for return value description
//
// if bAllowMove is TRUE, data can be moved, if not - only copied
virtual wxDragResult DoDragDrop(bool bAllowMove = FALSE) = 0;
// override to give feedback depending on the current operation result
// "effect" and return TRUE if you did something, FALSE to let the library
// give the default feedback
virtual bool GiveFeedback(wxDragResult WXUNUSED(effect)) { return FALSE; }
protected:
const wxCursor& GetCursor(wxDragResult res) const
{
if ( res == wxDragCopy )
return m_cursorCopy;
else if ( res == wxDragMove )
return m_cursorMove;
else
return m_cursorStop;
}
wxDataObject *m_data;
// the cursors to use for feedback
wxCursor m_cursorCopy, m_cursorMove, m_cursorStop;
};
// ----------------------------------------------------------------------------
// wxDropTarget should be associated with a window if it wants to be able to
// receive data via drag and drop.
//
// To use this class, you should derive from wxDropTarget and implement
// OnData() pure virtual method. You may also wish to override OnDrop() if you
// want to accept the data only inside some region of the window (this may
// avoid having to copy the data to this application which happens only when
// OnData() is called)
// ----------------------------------------------------------------------------
class WXDLLEXPORT wxDropTargetBase
{
public:
// ctor takes a pointer to heap-allocated wxDataObject which will be owned
// by wxDropTarget and deleted by it automatically. If you don't give it
// here, you can use SetDataObject() later.
wxDropTargetBase(wxDataObject *dataObject = (wxDataObject*)NULL)
{ m_dataObject = dataObject; }
// dtor deletes our data object
virtual ~wxDropTargetBase()
{ delete m_dataObject; }
// get/set the associated wxDataObject
wxDataObject *GetDataObject() const
{ return m_dataObject; }
void SetDataObject(wxDataObject *dataObject)
{ if (m_dataObject) delete m_dataObject;
m_dataObject = dataObject; }
// these functions are called when data is moved over position (x, y) and
// may return either wxDragCopy, wxDragMove or wxDragNone depending on
// what would happen if the data were dropped here.
//
// the last parameter is what would happen by default and is determined by
// the platform-specific logic (for example, under Windows it's wxDragCopy
// if Ctrl key is pressed and wxDragMove otherwise) except that it will
// always be wxDragNone if the carried data is in an unsupported format.
// called when the mouse enters the window (only once until OnLeave())
virtual wxDragResult OnEnter(wxCoord x, wxCoord y, wxDragResult def)
{ return OnDragOver(x, y, def); }
// called when the mouse moves in the window - shouldn't take long to
// execute or otherwise mouse movement would be too slow
virtual wxDragResult OnDragOver(wxCoord WXUNUSED(x), wxCoord WXUNUSED(y),
wxDragResult def)
{ return def; }
// called when mouse leaves the window: might be used to remove the
// feedback which was given in OnEnter()
virtual void OnLeave() { }
// this function is called when data is dropped at position (x, y) - if it
// returns TRUE, OnData() will be called immediately afterwards which will
// allow to retrieve the data dropped.
virtual bool OnDrop(wxCoord x, wxCoord y) = 0;
// called after OnDrop() returns TRUE: you will usually just call
// GetData() from here and, probably, also refresh something to update the
// new data and, finally, return the code indicating how did the operation
// complete (returning default value in case of success and wxDragError on
// failure is usually ok)
virtual wxDragResult OnData(wxCoord x, wxCoord y, wxDragResult def) = 0;
// may be called *only* from inside OnData() and will fill m_dataObject
// with the data from the drop source if it returns TRUE
virtual bool GetData() = 0;
protected:
wxDataObject *m_dataObject;
};
// ----------------------------------------------------------------------------
// include platform dependent class declarations
// ----------------------------------------------------------------------------
#if defined(__WXMSW__)
#include "wx/msw/ole/dropsrc.h"
#include "wx/msw/ole/droptgt.h"
#elif defined(__WXMOTIF__)
#include "wx/motif/dnd.h"
#elif defined(__WXGTK__)
#include "wx/gtk/dnd.h"
#elif defined(__WXQT__)
#include "wx/qt/dnd.h"
#elif defined(__WXMAC__)
#include "wx/mac/dnd.h"
#elif defined(__WXPM__)
#include "wx/os2/dnd.h"
#elif defined(__WXSTUBS__)
#include "wx/stubs/dnd.h"
#endif
// ----------------------------------------------------------------------------
// standard wxDropTarget implementations (implemented in common/dobjcmn.cpp)
// ----------------------------------------------------------------------------
// A simple wxDropTarget derived class for text data: you only need to
// override OnDropText() to get something working
class WXDLLEXPORT wxTextDropTarget : public wxDropTarget
{
public:
wxTextDropTarget();
virtual bool OnDropText(wxCoord x, wxCoord y, const wxString& text) = 0;
virtual wxDragResult OnData(wxCoord x, wxCoord y, wxDragResult def);
};
// A drop target which accepts files (dragged from File Manager or Explorer)
class WXDLLEXPORT wxFileDropTarget : public wxDropTarget
{
public:
wxFileDropTarget();
// parameters are the number of files and the array of file names
virtual bool OnDropFiles(wxCoord x, wxCoord y,
const wxArrayString& filenames) = 0;
virtual wxDragResult OnData(wxCoord x, wxCoord y, wxDragResult def);
};
#endif // wxUSE_DRAG_AND_DROP
#endif // _WX_DND_H_BASE_

50
include/wx/dragimag.h Normal file
View File

@@ -0,0 +1,50 @@
#ifndef _WX_DRAGIMAG_H_BASE_
#define _WX_DRAGIMAG_H_BASE_
#if wxUSE_DRAGIMAGE
#if defined(__WXMSW__)
#ifdef __WIN16__
#include "wx/generic/dragimgg.h"
#define wxDragImage wxGenericDragImage
#define sm_classwxDragImage sm_classwxGenericDragImage
#else
#include "wx/msw/dragimag.h"
#endif
#elif defined(__WXMOTIF__)
#include "wx/generic/dragimgg.h"
#define wxDragImage wxGenericDragImage
#define sm_classwxDragImage sm_classwxGenericDragImage
#elif defined(__WXGTK__)
#include "wx/generic/dragimgg.h"
#define wxDragImage wxGenericDragImage
#define sm_classwxDragImage sm_classwxGenericDragImage
#elif defined(__WXQT__)
#include "wx/generic/dragimgg.h"
#define wxDragImage wxGenericDragImage
#define sm_classwxDragImage sm_classwxGenericDragImage
#elif defined(__WXMAC__)
#include "wx/generic/dragimgg.h"
#define wxDragImage wxGenericDragImage
#define sm_classwxDragImage sm_classwxGenericDragImage
#elif defined(__WXPM__)
#include "wx/generic/dragimgg.h"
#define wxDragImage wxGenericDragImage
#define sm_classwxDragImage sm_classwxGenericDragImage
#elif defined(__WXSTUBS__)
#include "wx/generic/dragimgg.h"
#define wxDragImage wxGenericDragImage
#define sm_classwxDragImage sm_classwxGenericDragImage
#endif
#endif // wxUSE_DRAGIMAGE
#endif
// _WX_DRAGIMAG_H_BASE_

40
include/wx/filedlg.h Normal file
View File

@@ -0,0 +1,40 @@
#ifndef _WX_FILEDLG_H_BASE_
#define _WX_FILEDLG_H_BASE_
#if wxUSE_FILEDLG
enum
{
wxOPEN = 0x0001,
wxSAVE = 0x0002,
wxOVERWRITE_PROMPT = 0x0004,
wxHIDE_READONLY = 0x0008,
wxFILE_MUST_EXIST = 0x0010,
wxMULTIPLE = 0x0020,
wxCHANGE_DIR = 0x0040
};
#if defined(__WXMSW__)
#include "wx/msw/filedlg.h"
#elif defined(__WXMOTIF__)
#include "wx/motif/filedlg.h"
#elif defined(__WXGTK__)
#include "wx/generic/filedlgg.h"
#elif defined(__WXQT__)
#include "wx/qt/filedlg.h"
#elif defined(__WXMAC__)
#ifdef __DARWIN__
#include "wx/generic/filedlgg.h"
#else
#include "wx/mac/filedlg.h"
#endif
#elif defined(__WXPM__)
#include "wx/os2/filedlg.h"
#elif defined(__WXSTUBS__)
#include "wx/stubs/filedlg.h"
#endif
#endif // wxUSE_FILEDLG
#endif
// _WX_FILEDLG_H_BASE_

183
include/wx/font.h Normal file
View File

@@ -0,0 +1,183 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/font.h
// Purpose: wxFontBase class: the interface of wxFont
// Author: Vadim Zeitlin
// Modified by:
// Created: 20.09.99
// RCS-ID: $Id$
// Copyright: (c) wxWindows team
// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_FONT_H_BASE_
#define _WX_FONT_H_BASE_
#ifdef __GNUG__
#pragma interface "fontbase.h"
#endif
// ----------------------------------------------------------------------------
// headers
// ----------------------------------------------------------------------------
#include "wx/defs.h" // for wxDEFAULT &c
#include "wx/fontenc.h" // the font encoding constants
#include "wx/gdiobj.h" // the base class
// ----------------------------------------------------------------------------
// forward declarations
// ----------------------------------------------------------------------------
class WXDLLEXPORT wxFontData;
class WXDLLEXPORT wxFontBase;
class WXDLLEXPORT wxFont;
// ----------------------------------------------------------------------------
// font constants
// ----------------------------------------------------------------------------
// standard font families
enum wxFontFamily
{
wxFONTFAMILY_DEFAULT = wxDEFAULT,
wxFONTFAMILY_DECORATIVE = wxDECORATIVE,
wxFONTFAMILY_ROMAN = wxROMAN,
wxFONTFAMILY_SCRIPT = wxSCRIPT,
wxFONTFAMILY_SWISS = wxSWISS,
wxFONTFAMILY_MODERN = wxMODERN,
wxFONTFAMILY_TELETYPE = wxTELETYPE,
wxFONTFAMILY_MAX
};
// font styles
enum wxFontStyle
{
wxFONTSTYLE_NORMAL = wxNORMAL,
wxFONTSTYLE_ITALIC = wxITALIC,
wxFONTSTYLE_SLANT = wxSLANT,
wxFONTSTYLE_MAX
};
// font weights
enum wxFontWeight
{
wxFONTWEIGHT_NORMAL = wxNORMAL,
wxFONTWEIGHT_LIGHT = wxLIGHT,
wxFONTWEIGHT_BOLD = wxBOLD,
wxFONTWEIGHT_MAX
};
// ----------------------------------------------------------------------------
// wxFontBase represents a font object
// ----------------------------------------------------------------------------
class WXDLLEXPORT wxFontRefData;
struct WXDLLEXPORT wxNativeFontInfo;
class WXDLLEXPORT wxFontBase : public wxGDIObject
{
public:
// creator function
#ifdef __DARWIN__
virtual ~wxFontBase() { }
#endif
// from the font components
static wxFont *New(
int pointSize, // size of the font in points
int family, // see wxFontFamily enum
int style, // see wxFontStyle enum
int weight, // see wxFontWeight enum
bool underlined = FALSE, // not underlined by default
const wxString& face = wxEmptyString, // facename
wxFontEncoding encoding = wxFONTENCODING_DEFAULT); // ISO8859-X, ...
// from the (opaque) native font description object
static wxFont *New(const wxNativeFontInfo& nativeFontDesc);
// from the string representation of wxNativeFontInfo
static wxFont *New(const wxString& strNativeFontDesc);
// was the font successfully created?
bool Ok() const { return m_refData != NULL; }
// comparison
bool operator == (const wxFont& font) const;
bool operator != (const wxFont& font) const;
// accessors: get the font characteristics
virtual int GetPointSize() const = 0;
virtual int GetFamily() const = 0;
virtual int GetStyle() const = 0;
virtual int GetWeight() const = 0;
virtual bool GetUnderlined() const = 0;
virtual wxString GetFaceName() const = 0;
virtual wxFontEncoding GetEncoding() const = 0;
virtual wxNativeFontInfo *GetNativeFontInfo() const;
wxString GetNativeFontInfoDesc() const;
// change the font characteristics
virtual void SetPointSize( int pointSize ) = 0;
virtual void SetFamily( int family ) = 0;
virtual void SetStyle( int style ) = 0;
virtual void SetWeight( int weight ) = 0;
virtual void SetFaceName( const wxString& faceName ) = 0;
virtual void SetUnderlined( bool underlined ) = 0;
virtual void SetEncoding(wxFontEncoding encoding) = 0;
virtual void SetNativeFontInfo(const wxNativeFontInfo& info);
// VZ: there is no void SetNativeFontInfo(const wxString& info), needed?
// translate the fonts into human-readable string (i.e. GetStyleString()
// will return "wxITALIC" for an italic font, ...)
wxString GetFamilyString() const;
wxString GetStyleString() const;
wxString GetWeightString() const;
// the default encoding is used for creating all fonts with default
// encoding parameter
static wxFontEncoding GetDefaultEncoding()
{ return ms_encodingDefault; }
static void SetDefaultEncoding(wxFontEncoding encoding)
{ ms_encodingDefault = encoding; }
protected:
// get the internal data
wxFontRefData *GetFontData() const
{ return (wxFontRefData *)m_refData; }
private:
// the currently default encoding: by default, it's the default system
// encoding, but may be changed by the application using
// SetDefaultEncoding() to make all subsequent fonts created without
// specifing encoding parameter using this encoding
static wxFontEncoding ms_encodingDefault;
};
// include the real class declaration
#if defined(__WXMSW__)
#include "wx/msw/font.h"
#elif defined(__WXMOTIF__)
#include "wx/motif/font.h"
#elif defined(__WXGTK__)
#include "wx/gtk/font.h"
#elif defined(__WXMGL__)
#include "wx/mgl/font.h"
#elif defined(__WXQT__)
#include "wx/qt/font.h"
#elif defined(__WXMAC__)
#include "wx/mac/font.h"
#elif defined(__WXPM__)
#include "wx/os2/font.h"
#elif defined(__WXSTUBS__)
#include "wx/stubs/font.h"
#endif
// ----------------------------------------------------------------------------
// macros
// ----------------------------------------------------------------------------
#define M_FONTDATA GetFontData()
#endif
// _WX_FONT_H_BASE_

102
include/wx/gauge.h Normal file
View File

@@ -0,0 +1,102 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/gauge.h
// Purpose: wxGauge interface
// Author: Vadim Zeitlin
// Modified by:
// Created: 20.02.01
// RCS-ID: $Id$
// Copyright: (c) 1996-2001 wxWindows team
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_GAUGE_H_BASE_
#define _WX_GAUGE_H_BASE_
#ifdef __GNUG__
#pragma implementation "gaugebase.h"
#endif
#include "wx/defs.h"
#if wxUSE_GAUGE
#include "wx/control.h"
WXDLLEXPORT_DATA(extern const wxChar*) wxGaugeNameStr;
// ----------------------------------------------------------------------------
// wxGauge: a progress bar
// ----------------------------------------------------------------------------
class WXDLLEXPORT wxGaugeBase : public wxControl
{
public:
#ifdef __DARWIN__
virtual ~wxGaugeBase() { }
#endif
bool Create(wxWindow *parent,
wxWindowID id,
int range,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxGA_HORIZONTAL,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxGaugeNameStr);
// set/get the control range
virtual void SetRange(int range);
virtual int GetRange() const;
// position
virtual void SetValue(int pos);
virtual int GetValue() const;
// appearance params (not implemented for most ports)
virtual void SetShadowWidth(int w);
virtual int GetShadowWidth() const;
virtual void SetBezelFace(int w);
virtual int GetBezelFace() const;
// overriden base class virtuals
virtual bool AcceptsFocus() const { return FALSE; }
protected:
// the max position
int m_rangeMax;
// the current position
int m_gaugePos;
};
#if defined(__WXUNIVERSAL__)
#include "wx/univ/gauge.h"
#elif defined(__WXMSW__)
#ifdef __WIN95__
#include "wx/msw/gauge95.h"
#define wxGauge wxGauge95
#define sm_classwxGauge sm_classwxGauge95
#else // !__WIN95__
#include "wx/msw/gaugemsw.h"
#define wxGauge wxGaugeMSW
#define sm_classwxGauge sm_classwxGaugeMSW
#endif
#elif defined(__WXMOTIF__)
#include "wx/motif/gauge.h"
#elif defined(__WXGTK__)
#include "wx/gtk/gauge.h"
#elif defined(__WXQT__)
#include "wx/qt/gauge.h"
#elif defined(__WXMAC__)
#include "wx/mac/gauge.h"
#elif defined(__WXPM__)
#include "wx/os2/gauge.h"
#elif defined(__WXSTUBS__)
#include "wx/stubs/gauge.h"
#endif
#endif // wxUSE_GAUGE
#endif
// _WX_GAUGE_H_BASE_

23
include/wx/gdiobj.h Normal file
View File

@@ -0,0 +1,23 @@
#ifndef _WX_GDIOBJ_H_BASE_
#define _WX_GDIOBJ_H_BASE_
#if defined(__WXMSW__)
#include "wx/msw/gdiobj.h"
#elif defined(__WXMOTIF__)
#include "wx/motif/gdiobj.h"
#elif defined(__WXGTK__)
#include "wx/gtk/gdiobj.h"
#elif defined(__WXMGL__)
#include "wx/mgl/gdiobj.h"
#elif defined(__WXQT__)
#include "wx/qt/gdiobj.h"
#elif defined(__WXMAC__)
#include "wx/mac/gdiobj.h"
#elif defined(__WXPM__)
#include "wx/os2/gdiobj.h"
#elif defined(__WXSTUBS__)
#include "wx/stubs/gdiobj.h"
#endif
#endif
// _WX_GDIOBJ_H_BASE_

21
include/wx/glcanvas.h Normal file
View File

@@ -0,0 +1,21 @@
#ifndef _WX_GLCANVAS_H_BASE_
#define _WX_GLCANVAS_H_BASE_
#if defined(__WXMSW__)
#include "wx/msw/glcanvas.h"
#elif defined(__WXMOTIF__)
#include "wx/motif/glcanvas.h"
#elif defined(__WXGTK__)
#include "wx/gtk/glcanvas.h"
#elif defined(__WXQT__)
#include "wx/qt/glcanvas.h"
#elif defined(__WXMAC__)
#include "wx/mac/glcanvas.h"
#elif defined(__WXPM__)
#include "wx/os2/glcanvas.h"
#elif defined(__WXSTUBS__)
#include "wx/stubs/glcanvas.h"
#endif
#endif
// _WX_GLCANVAS_H_BASE_

29
include/wx/icon.h Normal file
View File

@@ -0,0 +1,29 @@
#ifndef _WX_ICON_H_BASE_
#define _WX_ICON_H_BASE_
/* Commenting out since duplicated in gdicmn.h
// this is for Unix (i.e. now for anything other than MSW)
#undef wxICON
#define wxICON(icon_name) wxIcon(icon_name##_xpm)
*/
#if defined(__WXMSW__)
#include "wx/msw/icon.h"
#elif defined(__WXMOTIF__)
#include "wx/motif/icon.h"
#elif defined(__WXGTK__)
#include "wx/gtk/icon.h"
#elif defined(__WXMGL__)
#include "wx/mgl/icon.h"
#elif defined(__WXQT__)
#include "wx/qt/icon.h"
#elif defined(__WXMAC__)
#include "wx/mac/icon.h"
#elif defined(__WXPM__)
#include "wx/os2/icon.h"
#elif defined(__WXSTUBS__)
#include "wx/stubs/icon.h"
#endif
#endif
// _WX_ICON_H_BASE_

149
include/wx/listbox.h Normal file
View File

@@ -0,0 +1,149 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/listbox.h
// Purpose: wxListBox class interface
// Author: Vadim Zeitlin
// Modified by:
// Created: 22.10.99
// RCS-ID: $Id$
// Copyright: (c) wxWindows team
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_LISTBOX_H_BASE_
#define _WX_LISTBOX_H_BASE_
// ----------------------------------------------------------------------------
// headers
// ----------------------------------------------------------------------------
#ifdef __GNUG__
#pragma interface "listboxbase.h"
#endif
#include "wx/defs.h"
#if wxUSE_LISTBOX
#include "wx/ctrlsub.h" // base class
// forward declarations are enough here
class WXDLLEXPORT wxArrayInt;
class WXDLLEXPORT wxArrayString;
// ----------------------------------------------------------------------------
// global data
// ----------------------------------------------------------------------------
WXDLLEXPORT_DATA(extern const wxChar*) wxListBoxNameStr;
// ----------------------------------------------------------------------------
// wxListBox interface is defined by the class wxListBoxBase
// ----------------------------------------------------------------------------
class WXDLLEXPORT wxListBoxBase : public wxControlWithItems
{
public:
// all generic methods are in wxControlWithItems, except for the following
// ones which are not yet implemented by wxChoice/wxCombobox
#ifdef __DARWIN__
virtual ~wxListBoxBase() { }
#endif
void Insert(const wxString& item, int pos)
{ DoInsert(item, pos); }
void Insert(const wxString& item, int pos, void *clientData)
{ DoInsert(item, pos); SetClientData(pos, clientData); }
void Insert(const wxString& item, int pos, wxClientData *clientData)
{ DoInsert(item, pos); SetClientObject(pos, clientData); }
void InsertItems(int nItems, const wxString *items, int pos);
void InsertItems(const wxArrayString& items, int pos)
{ DoInsertItems(items, pos); }
void Set(int n, const wxString* items, void **clientData = NULL);
void Set(const wxArrayString& items, void **clientData = NULL)
{ DoSetItems(items, clientData); }
// multiple selection logic
virtual bool IsSelected(int n) const = 0;
virtual void SetSelection(int n, bool select = TRUE) = 0;
virtual void Select(int n) { SetSelection(n, TRUE); }
void Deselect(int n) { SetSelection(n, FALSE); }
void DeselectAll(int itemToLeaveSelected = -1);
virtual bool SetStringSelection(const wxString& s, bool select = TRUE);
// works for single as well as multiple selection listboxes (unlike
// GetSelection which only works for listboxes with single selection)
virtual int GetSelections(wxArrayInt& aSelections) const = 0;
// set the specified item at the first visible item or scroll to max
// range.
void SetFirstItem(int n) { DoSetFirstItem(n); }
void SetFirstItem(const wxString& s);
// ensures that the given item is visible scrolling the listbox if
// necessary
virtual void EnsureVisible(int n);
// a combination of Append() and EnsureVisible(): appends the item to the
// listbox and ensures that it is visible i.e. not scrolled out of view
void AppendAndEnsureVisible(const wxString& s);
// return TRUE if the listbox allows multiple selection
bool HasMultipleSelection() const
{
return (m_windowStyle & wxLB_MULTIPLE) ||
(m_windowStyle & wxLB_EXTENDED);
}
// return TRUE if this listbox is sorted
bool IsSorted() const { return (m_windowStyle & wxLB_SORT) != 0; }
// emulate selecting or deselecting the item event.GetInt() (depending on
// event.GetExtraLong())
void Command(wxCommandEvent& event);
// compatibility - these functions are deprecated, use the new ones
// instead
bool Selected(int n) const { return IsSelected(n); }
protected:
// NB: due to wxGTK implementation details, DoInsert() is implemented
// using DoInsertItems() and not the other way round
void DoInsert(const wxString& item, int pos)
{ InsertItems(1, &item, pos); }
// to be implemented in derived classes
virtual void DoInsertItems(const wxArrayString& items, int pos) = 0;
virtual void DoSetItems(const wxArrayString& items, void **clientData) = 0;
virtual void DoSetFirstItem(int n) = 0;
};
// ----------------------------------------------------------------------------
// include the platform-specific class declaration
// ----------------------------------------------------------------------------
#if defined(__WXUNIVERSAL__)
#include "wx/univ/listbox.h"
#elif defined(__WXMSW__)
#include "wx/msw/listbox.h"
#elif defined(__WXMOTIF__)
#include "wx/motif/listbox.h"
#elif defined(__WXGTK__)
#include "wx/gtk/listbox.h"
#elif defined(__WXQT__)
#include "wx/qt/listbox.h"
#elif defined(__WXMAC__)
#include "wx/mac/listbox.h"
#elif defined(__WXPM__)
#include "wx/os2/listbox.h"
#elif defined(__WXSTUBS__)
#include "wx/stubs/listbox.h"
#endif
#endif // wxUSE_LISTBOX
#endif
// _WX_LISTBOX_H_BASE_

21
include/wx/mdi.h Normal file
View File

@@ -0,0 +1,21 @@
#ifndef _WX_MDI_H_BASE_
#define _WX_MDI_H_BASE_
#if defined(__WXMSW__)
#include "wx/msw/mdi.h"
#elif defined(__WXMOTIF__)
#include "wx/motif/mdi.h"
#elif defined(__WXGTK__)
#include "wx/gtk/mdi.h"
#elif defined(__WXQT__)
#include "wx/qt/mdi.h"
#elif defined(__WXMAC__)
#include "wx/mac/mdi.h"
#elif defined(__WXPM__)
#include "wx/os2/mdi.h"
#elif defined(__WXSTUBS__)
#include "wx/stubs/mdi.h"
#endif
#endif
// _WX_MDI_H_BASE_

468
include/wx/menu.h Normal file
View File

@@ -0,0 +1,468 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/menu.h
// Purpose: wxMenu and wxMenuBar classes
// Author: Vadim Zeitlin
// Modified by:
// Created: 26.10.99
// RCS-ID: $Id$
// Copyright: (c) wxWindows team
// Licence: wxWindows license
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_MENU_H_BASE_
#define _WX_MENU_H_BASE_
#ifdef __GNUG__
#pragma interface "menubase.h"
#endif
#if wxUSE_MENUS
// ----------------------------------------------------------------------------
// headers
// ----------------------------------------------------------------------------
#include "wx/list.h" // for "template" list classes
#include "wx/window.h" // base class for wxMenuBar
// also include this one to ensure compatibility with old code which only
// included wx/menu.h
#include "wx/menuitem.h"
class WXDLLEXPORT wxMenu;
class WXDLLEXPORT wxMenuBarBase;
class WXDLLEXPORT wxMenuBar;
class WXDLLEXPORT wxMenuItem;
// pseudo template list classes
WX_DECLARE_EXPORTED_LIST(wxMenu, wxMenuList);
WX_DECLARE_EXPORTED_LIST(wxMenuItem, wxMenuItemList);
// ----------------------------------------------------------------------------
// conditional compilation
// ----------------------------------------------------------------------------
// having callbacks in menus is a wxWin 1.6x feature which should be replaced
// with event tables in wxWin 2.xx code - however provide it because many
// people like it a lot by default
#ifndef wxUSE_MENU_CALLBACK
#if WXWIN_COMPATIBILITY_2
#define wxUSE_MENU_CALLBACK 1
#else
#define wxUSE_MENU_CALLBACK 0
#endif // WXWIN_COMPATIBILITY_2
#endif // !defined(wxUSE_MENU_CALLBACK)
// ----------------------------------------------------------------------------
// wxMenu
// ----------------------------------------------------------------------------
class WXDLLEXPORT wxMenuBase : public wxEvtHandler
{
public:
// create a menu
static wxMenu *New(const wxString& title = wxEmptyString, long style = 0);
// ctors
wxMenuBase(const wxString& title, long style = 0) : m_title(title)
{ Init(style); }
wxMenuBase(long style = 0)
{ Init(style); }
// dtor deletes all the menu items we own
virtual ~wxMenuBase();
// menu construction
// -----------------
// append a normal item to the menu
void Append(int id,
const wxString& text,
const wxString& help = wxEmptyString,
bool isCheckable = FALSE)
{
DoAppend(wxMenuItem::New((wxMenu *)this, id, text, help, isCheckable));
}
// append a separator to the menu
void AppendSeparator() { Append(wxID_SEPARATOR, wxEmptyString); }
// append a submenu
void Append(int id,
const wxString& text,
wxMenu *submenu,
const wxString& help = wxEmptyString)
{
DoAppend(wxMenuItem::New((wxMenu *)this, id, text, help, FALSE, submenu));
}
// the most generic form of Append() - append anything
void Append(wxMenuItem *item) { DoAppend(item); }
// insert a break in the menu (only works when appending the items, not
// inserting them)
virtual void Break() { }
// insert an item before given position
bool Insert(size_t pos, wxMenuItem *item);
void Insert(size_t pos,
int id,
const wxString& text,
const wxString& help = wxEmptyString,
bool isCheckable = FALSE)
{
Insert(pos, wxMenuItem::New((wxMenu *)this, id, text, help, isCheckable));
}
// insert a separator
void InsertSeparator(size_t pos)
{
Insert(pos, wxMenuItem::New((wxMenu *)this));
}
// insert a submenu
void Insert(size_t pos,
int id,
const wxString& text,
wxMenu *submenu,
const wxString& help = wxEmptyString)
{
Insert(pos, wxMenuItem::New((wxMenu *)this, id, text, help, FALSE, submenu));
}
// prepend an item to the menu
void Prepend(wxMenuItem *item)
{
Insert(0u, item);
}
void Prepend(int id,
const wxString& text,
const wxString& help = wxEmptyString,
bool isCheckable = FALSE)
{
Insert(0u, id, text, help, isCheckable);
}
// insert a separator
void PrependSeparator()
{
InsertSeparator(0u);
}
// insert a submenu
void Prepend(int id,
const wxString& text,
wxMenu *submenu,
const wxString& help = wxEmptyString)
{
Insert(0u, id, text, submenu, help);
}
// detach an item from the menu, but don't delete it so that it can be
// added back later (but if it's not, the caller is responsible for
// deleting it!)
wxMenuItem *Remove(int id) { return Remove(FindChildItem(id)); }
wxMenuItem *Remove(wxMenuItem *item);
// delete an item from the menu (submenus are not destroyed by this
// function, see Destroy)
bool Delete(int id) { return Delete(FindChildItem(id)); }
bool Delete(wxMenuItem *item);
// delete the item from menu and destroy it (if it's a submenu)
bool Destroy(int id) { return Destroy(FindChildItem(id)); }
bool Destroy(wxMenuItem *item);
// menu items access
// -----------------
// get the items
size_t GetMenuItemCount() const { return m_items.GetCount(); }
const wxMenuItemList& GetMenuItems() const { return m_items; }
wxMenuItemList& GetMenuItems() { return m_items; }
// search
virtual int FindItem(const wxString& item) const;
wxMenuItem* FindItem(int id, wxMenu **menu = NULL) const;
// get/set items attributes
void Enable(int id, bool enable);
bool IsEnabled(int id) const;
void Check(int id, bool check);
bool IsChecked(int id) const;
void SetLabel(int id, const wxString& label);
wxString GetLabel(int id) const;
virtual void SetHelpString(int id, const wxString& helpString);
virtual wxString GetHelpString(int id) const;
// misc accessors
// --------------
// the title
virtual void SetTitle(const wxString& title) { m_title = title; }
const wxString GetTitle() const { return m_title; }
// client data
void SetClientData(void* clientData) { m_clientData = clientData; }
void* GetClientData() const { return m_clientData; }
// event handler
void SetEventHandler(wxEvtHandler *handler) { m_eventHandler = handler; }
wxEvtHandler *GetEventHandler() const { return m_eventHandler; }
// invoking window
void SetInvokingWindow(wxWindow *win) { m_invokingWindow = win; }
wxWindow *GetInvokingWindow() const { return m_invokingWindow; }
// style
long GetStyle() const { return m_style; }
// implementation helpers
// ----------------------
// Updates the UI for a menu and all submenus recursively. source is the
// object that has the update event handlers defined for it. If NULL, the
// menu or associated window will be used.
void UpdateUI(wxEvtHandler* source = (wxEvtHandler*)NULL);
// get the menu bar this menu is attached to (may be NULL, always NULL for
// popup menus)
wxMenuBar *GetMenuBar() const { return m_menuBar; }
// called when the menu is attached/detached to/from a menu bar
virtual void Attach(wxMenuBarBase *menubar);
virtual void Detach();
// is the menu attached to a menu bar (or is it a popup one)?
bool IsAttached() const { return m_menuBar != NULL; }
// set/get the parent of this menu
void SetParent(wxMenu *parent) { m_menuParent = parent; }
wxMenu *GetParent() const { return m_menuParent; }
#if WXWIN_COMPATIBILITY
// compatibility: these functions are deprecated, use the new ones instead
bool Enabled(int id) const { return IsEnabled(id); }
bool Checked(int id) const { return IsChecked(id); }
wxMenuItem* FindItemForId(int itemId, wxMenu **itemMenu) const
{ return FindItem(itemId, itemMenu); }
wxList& GetItems() const { return (wxList &)m_items; }
#endif // WXWIN_COMPATIBILITY
#if wxUSE_MENU_CALLBACK || defined(__WXMOTIF__)
// wxWin 1.6x compatible menu event handling
wxFunction GetCallback() const { return m_callback; }
void Callback(const wxFunction func) { m_callback = func; }
wxFunction m_callback;
#endif // wxUSE_MENU_CALLBACK
// unlike FindItem(), this function doesn't recurse but only looks through
// our direct children and also may return the index of the found child if
// pos != NULL
wxMenuItem *FindChildItem(int id, size_t *pos = NULL) const;
// called to generate a wxCommandEvent, return TRUE if it was processed,
// FALSE otherwise
//
// the checked parameter may have boolean value or -1 for uncheckable items
bool SendEvent(int id, int checked = -1);
protected:
// virtuals to override in derived classes
// ---------------------------------------
virtual bool DoAppend(wxMenuItem *item);
virtual bool DoInsert(size_t pos, wxMenuItem *item);
virtual wxMenuItem *DoRemove(wxMenuItem *item);
virtual bool DoDelete(wxMenuItem *item);
virtual bool DoDestroy(wxMenuItem *item);
// helpers
// -------
// common part of all ctors
void Init(long style);
// associate the submenu with this menu
void AddSubMenu(wxMenu *submenu);
wxMenuBar *m_menuBar; // menubar we belong to or NULL
wxMenu *m_menuParent; // parent menu or NULL
wxString m_title; // the menu title or label
wxMenuItemList m_items; // the list of menu items
wxWindow *m_invokingWindow; // for popup menus
void *m_clientData; // associated with the menu
long m_style; // combination of wxMENU_XXX flags
wxEvtHandler *m_eventHandler; // a pluggable in event handler
};
// ----------------------------------------------------------------------------
// wxMenuBar
// ----------------------------------------------------------------------------
class WXDLLEXPORT wxMenuBarBase : public wxWindow
{
public:
// default ctor
wxMenuBarBase();
// dtor will delete all menus we own
virtual ~wxMenuBarBase();
// menu bar construction
// ---------------------
// append a menu to the end of menubar, return TRUE if ok
virtual bool Append(wxMenu *menu, const wxString& title);
// insert a menu before the given position into the menubar, return TRUE
// if inserted ok
virtual bool Insert(size_t pos, wxMenu *menu, const wxString& title);
// menu bar items access
// ---------------------
// get the number of menus in the menu bar
size_t GetMenuCount() const { return m_menus.GetCount(); }
// get the menu at given position
wxMenu *GetMenu(size_t pos) const;
// replace the menu at given position with another one, returns the
// previous menu (which should be deleted by the caller)
virtual wxMenu *Replace(size_t pos, wxMenu *menu, const wxString& title);
// delete the menu at given position from the menu bar, return the pointer
// to the menu (which should be deleted by the caller)
virtual wxMenu *Remove(size_t pos);
// enable or disable a submenu
virtual void EnableTop(size_t pos, bool enable) = 0;
// is the menu enabled?
virtual bool IsEnabledTop(size_t WXUNUSED(pos)) const { return TRUE; }
// get or change the label of the menu at given position
virtual void SetLabelTop(size_t pos, const wxString& label) = 0;
virtual wxString GetLabelTop(size_t pos) const = 0;
// item search
// -----------
// by menu and item names, returns wxNOT_FOUND if not found or id of the
// found item
virtual int FindMenuItem(const wxString& menu, const wxString& item) const;
// find item by id (in any menu), returns NULL if not found
//
// if menu is !NULL, it will be filled with wxMenu this item belongs to
virtual wxMenuItem* FindItem(int id, wxMenu **menu = NULL) const;
// find menu by its caption, return wxNOT_FOUND on failure
int FindMenu(const wxString& title) const;
// item access
// -----------
// all these functions just use FindItem() and then call an appropriate
// method on it
//
// NB: under MSW, these methods can only be used after the menubar had
// been attached to the frame
void Enable(int id, bool enable);
void Check(int id, bool check);
bool IsChecked(int id) const;
bool IsEnabled(int id) const;
void SetLabel(int id, const wxString &label);
wxString GetLabel(int id) const;
void SetHelpString(int id, const wxString& helpString);
wxString GetHelpString(int id) const;
// implementation helpers
// get the frame we are attached to (may return NULL)
wxFrame *GetFrame() const { return m_menuBarFrame; }
// returns TRUE if we're attached to a frame
bool IsAttached() const { return GetFrame() != NULL; }
// associate the menubar with the frame
virtual void Attach(wxFrame *frame);
// called before deleting the menubar normally
virtual void Detach();
// need to override these ones to avoid virtual function hiding
virtual bool Enable(bool enable = TRUE) { return wxWindow::Enable(enable); }
virtual void SetLabel(const wxString& s) { wxWindow::SetLabel(s); }
virtual wxString GetLabel() const { return wxWindow::GetLabel(); }
// don't want menu bars to accept the focus by tabbing to them
virtual bool AcceptsFocusFromKeyboard() const { return FALSE; }
// compatibility only: these functions are deprecated, use the new ones
// instead
#if WXWIN_COMPATIBILITY
bool Enabled(int id) const { return IsEnabled(id); }
bool Checked(int id) const { return IsChecked(id); }
wxMenuItem* FindMenuItemById(int id) const
{ return FindItem(id); }
wxMenuItem* FindItemForId(int id, wxMenu **menu = NULL) const
{ return FindItem(id, menu); }
#endif // WXWIN_COMPATIBILITY
protected:
// the list of all our menus
wxMenuList m_menus;
// the frame we are attached to (may be NULL)
wxFrame *m_menuBarFrame;
};
// ----------------------------------------------------------------------------
// include the real class declaration
// ----------------------------------------------------------------------------
#ifdef wxUSE_BASE_CLASSES_ONLY
#define wxMenuItem wxMenuItemBase
#else // !wxUSE_BASE_CLASSES_ONLY
#if defined(__WXUNIVERSAL__)
#include "wx/univ/menu.h"
#elif defined(__WXMSW__)
#include "wx/msw/menu.h"
#elif defined(__WXMOTIF__)
#include "wx/motif/menu.h"
#elif defined(__WXGTK__)
#include "wx/gtk/menu.h"
#elif defined(__WXQT__)
#include "wx/qt/menu.h"
#elif defined(__WXMAC__)
#include "wx/mac/menu.h"
#elif defined(__WXPM__)
#include "wx/os2/menu.h"
#elif defined(__WXSTUBS__)
#include "wx/stubs/menu.h"
#endif
#endif // wxUSE_BASE_CLASSES_ONLY/!wxUSE_BASE_CLASSES_ONLY
#endif // wxUSE_MENUS
#endif
// _WX_MENU_H_BASE_

157
include/wx/menuitem.h Normal file
View File

@@ -0,0 +1,157 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/menuitem.h
// Purpose: wxMenuItem class
// Author: Vadim Zeitlin
// Modified by:
// Created: 25.10.99
// RCS-ID: $Id$
// Copyright: (c) 1999 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
// Licence: wxWindows license
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_MENUITEM_H_BASE_
#define _WX_MENUITEM_H_BASE_
#if wxUSE_MENUS
// ----------------------------------------------------------------------------
// headers
// ----------------------------------------------------------------------------
#include "wx/object.h" // base class
// ----------------------------------------------------------------------------
// forward declarations
// ----------------------------------------------------------------------------
class WXDLLEXPORT wxAcceleratorEntry;
class WXDLLEXPORT wxMenuItem;
class WXDLLEXPORT wxMenu;
// ----------------------------------------------------------------------------
// wxMenuItem is an item in the menu which may be either a normal item, a sub
// menu or a separator
// ----------------------------------------------------------------------------
class WXDLLEXPORT wxMenuItemBase : public wxObject
{
public:
// creation
static wxMenuItem *New(wxMenu *parentMenu = (wxMenu *)NULL,
int id = wxID_SEPARATOR,
const wxString& text = wxEmptyString,
const wxString& help = wxEmptyString,
bool isCheckable = FALSE,
wxMenu *subMenu = (wxMenu *)NULL);
// destruction: wxMenuItem will delete its submenu
virtual ~wxMenuItemBase();
// the menu we're in
wxMenu *GetMenu() const { return m_parentMenu; }
// get/set id
void SetId(int id) { m_id = id; }
int GetId() const { return m_id; }
bool IsSeparator() const { return m_id == wxID_SEPARATOR; }
// the item's text (or name)
//
// NB: the item's text includes the accelerators and mnemonics info (if
// any), i.e. it may contain '&' or '_' or "\t..." and thus is
// different from the item's label which only contains the text shown
// in the menu
virtual void SetText(const wxString& str) { m_text = str; }
wxString GetLabel() const { return GetLabelFromText(m_text); }
const wxString& GetText() const { return m_text; }
// get the label from text (implemented in platform-specific code)
static wxString GetLabelFromText(const wxString& text);
// what kind of menu item we are
virtual void SetCheckable(bool checkable) { m_isCheckable = checkable; }
bool IsCheckable() const { return m_isCheckable; }
bool IsSubMenu() const { return m_subMenu != NULL; }
void SetSubMenu(wxMenu *menu) { m_subMenu = menu; }
wxMenu *GetSubMenu() const { return m_subMenu; }
// state
virtual void Enable(bool enable = TRUE) { m_isEnabled = enable; }
virtual bool IsEnabled() const { return m_isEnabled; }
virtual void Check(bool check = TRUE) { m_isChecked = check; }
virtual bool IsChecked() const { return m_isChecked; }
void Toggle() { Check(!m_isChecked); }
// help string (displayed in the status bar by default)
void SetHelp(const wxString& str) { m_help = str; }
const wxString& GetHelp() const { return m_help; }
#if wxUSE_ACCEL
// extract the accelerator from the given menu string, return NULL if none
// found
static wxAcceleratorEntry *GetAccelFromString(const wxString& label);
// get our accelerator or NULL (caller must delete the pointer)
virtual wxAcceleratorEntry *GetAccel() const;
// set the accel for this item - this may also be done indirectly with
// SetText()
virtual void SetAccel(wxAcceleratorEntry *accel);
#endif // wxUSE_ACCEL
// compatibility only, use new functions in the new code
void SetName(const wxString& str) { SetText(str); }
const wxString& GetName() const { return GetText(); }
protected:
int m_id; // numeric id of the item >= 0 or -1
wxMenu *m_parentMenu, // the menu we belong to
*m_subMenu; // our sub menu or NULL
wxString m_text, // label of the item
m_help; // the help string for the item
bool m_isCheckable; // can be checked?
bool m_isChecked; // is checked?
bool m_isEnabled; // is enabled?
// some compilers need a default constructor here, do not remove
wxMenuItemBase() { }
private:
// and, if we have one ctor, compiler won't generate a default copy one, so
// declare them ourselves - but don't implement as they shouldn't be used
wxMenuItemBase(const wxMenuItemBase& item);
wxMenuItemBase& operator=(const wxMenuItemBase& item);
};
// ----------------------------------------------------------------------------
// include the real class declaration
// ----------------------------------------------------------------------------
#ifdef wxUSE_BASE_CLASSES_ONLY
#define wxMenuItem wxMenuItemBase
#else // !wxUSE_BASE_CLASSES_ONLY
#if defined(__WXUNIVERSAL__)
#include "wx/univ/menuitem.h"
#elif defined(__WXMSW__)
#include "wx/msw/menuitem.h"
#elif defined(__WXMOTIF__)
#include "wx/motif/menuitem.h"
#elif defined(__WXGTK__)
#include "wx/gtk/menuitem.h"
#elif defined(__WXQT__)
#include "wx/qt/menuitem.h"
#elif defined(__WXMAC__)
#include "wx/mac/menuitem.h"
#elif defined(__WXPM__)
#include "wx/os2/menuitem.h"
#elif defined(__WXSTUBS__)
#include "wx/stubs/menuitem.h"
#endif
#endif // wxUSE_BASE_CLASSES_ONLY/!wxUSE_BASE_CLASSES_ONLY
#endif // wxUSE_MENUS
#endif
// _WX_MENUITEM_H_BASE_

37
include/wx/msgdlg.h Normal file
View File

@@ -0,0 +1,37 @@
#ifndef _WX_MSGDLG_H_BASE_
#define _WX_MSGDLG_H_BASE_
#if wxUSE_MSGDLG
#if defined(__WXUNIVERSAL__)
#include "wx/generic/msgdlgg.h"
#elif defined(__WXMSW__)
#include "wx/msw/msgdlg.h"
#elif defined(__WXMOTIF__)
#include "wx/motif/msgdlg.h"
#elif defined(__WXGTK__)
#include "wx/generic/msgdlgg.h"
#elif defined(__WXQT__)
#include "wx/generic/msgdlgg.h"
#elif defined(__WXMAC__)
#include "wx/mac/msgdlg.h"
#elif defined(__WXPM__)
#include "wx/os2/msgdlg.h"
#elif defined(__WXSTUBS__)
#include "wx/generic/msgdlgg.h"
#endif
// ----------------------------------------------------------------------------
// wxMessageBox: the simplest way to use wxMessageDialog
// ----------------------------------------------------------------------------
int WXDLLEXPORT wxMessageBox(const wxString& message,
const wxString& caption = wxMessageBoxCaptionStr,
long style = wxOK | wxCENTRE,
wxWindow *parent = NULL,
int x = -1, int y = -1);
#endif // wxUSE_MSGDLG
#endif
// _WX_MSGDLG_H_BASE_

289
include/wx/notebook.h Normal file
View File

@@ -0,0 +1,289 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/notebook.h
// Purpose: wxNotebook interface
// Author: Vadim Zeitlin
// Modified by:
// Created: 01.02.01
// RCS-ID: $Id$
// Copyright: (c) 1996-2000 wxWindows team
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_NOTEBOOK_H_BASE_
#define _WX_NOTEBOOK_H_BASE_
#ifdef __GNUG__
#pragma interface "notebookbase.h"
#endif
// ----------------------------------------------------------------------------
// headers
// ----------------------------------------------------------------------------
#include "wx/defs.h"
#if wxUSE_NOTEBOOK
#include "wx/control.h"
#include "wx/dynarray.h"
class WXDLLEXPORT wxImageList;
// ----------------------------------------------------------------------------
// types
// ----------------------------------------------------------------------------
// array of notebook pages
typedef wxWindow wxNotebookPage; // so far, any window can be a page
WX_DEFINE_EXPORTED_ARRAY(wxNotebookPage *, wxArrayPages);
#define wxNOTEBOOK_NAME _T("notebook")
// ----------------------------------------------------------------------------
// wxNotebookBase: define wxNotebook interface
// ----------------------------------------------------------------------------
class WXDLLEXPORT wxNotebookBase : public wxControl
{
public:
// ctor
wxNotebookBase()
{
Init();
}
// quasi ctor
bool Create(wxWindow *parent,
wxWindowID id,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
const wxString& name = wxNOTEBOOK_NAME);
// dtor
virtual ~wxNotebookBase();
// accessors
// ---------
// get number of pages in the dialog
int GetPageCount() const { return m_pages.GetCount(); }
// get the panel which represents the given page
wxNotebookPage *GetPage(int nPage) { return m_pages[nPage]; }
// get the currently selected page
virtual int GetSelection() const = 0;
// set/get the title of a page
virtual bool SetPageText(int nPage, const wxString& strText) = 0;
virtual wxString GetPageText(int nPage) const = 0;
// image list stuff: each page may have an image associated with it (all
// images belong to the same image list)
virtual void SetImageList(wxImageList* imageList);
// as SetImageList() but we will delete the image list ourselves
void AssignImageList(wxImageList* imageList);
// get pointer (may be NULL) to the associated image list
wxImageList* GetImageList() const { return m_imageList; }
// sets/returns item's image index in the current image list
virtual int GetPageImage(int nPage) const = 0;
virtual bool SetPageImage(int nPage, int nImage) = 0;
// get the number of rows for a control with wxNB_MULTILINE style (not all
// versions support it - they will always return 1 then)
virtual int GetRowCount() const { return 1; }
// set the size (the same for all pages)
virtual void SetPageSize(const wxSize& size) = 0;
// set the padding between tabs (in pixels)
virtual void SetPadding(const wxSize& padding) = 0;
// set the size of the tabs for wxNB_FIXEDWIDTH controls
virtual void SetTabSize(const wxSize& sz) = 0;
// calculate the size of the notebook from the size of its page
virtual wxSize CalcSizeFromPage(const wxSize& sizePage);
// operations
// ----------
// remove one page from the notebook and delete it
virtual bool DeletePage(int nPage);
// remove one page from the notebook, without deleting it
virtual bool RemovePage(int nPage) { return DoRemovePage(nPage) != NULL; }
// remove all pages and delete them
virtual bool DeleteAllPages() { WX_CLEAR_ARRAY(m_pages); return TRUE; }
// adds a new page to the notebook (it will be deleted by the notebook,
// don't delete it yourself) and make it the current one if bSelect
virtual bool AddPage(wxNotebookPage *pPage,
const wxString& strText,
bool bSelect = FALSE,
int imageId = -1)
{
return InsertPage(GetPageCount(), pPage, strText, bSelect, imageId);
}
// the same as AddPage(), but adds the page at the specified position
virtual bool InsertPage(int nPage,
wxNotebookPage *pPage,
const wxString& strText,
bool bSelect = FALSE,
int imageId = -1) = 0;
// set the currently selected page, return the index of the previously
// selected one (or -1 on error)
//
// NB: this function will _not_ generate wxEVT_NOTEBOOK_PAGE_xxx events
virtual int SetSelection(int nPage) = 0;
// cycle thru the tabs
void AdvanceSelection(bool forward = TRUE)
{
int nPage = GetNextPage(forward);
if ( nPage != -1 )
SetSelection(nPage);
}
protected:
// remove the page and return a pointer to it
virtual wxNotebookPage *DoRemovePage(int page);
// common part of all ctors
void Init();
// get the next page wrapping if we reached the end
int GetNextPage(bool forward) const;
wxArrayPages m_pages; // array of pages
wxImageList *m_imageList; // we can have an associated image list
bool m_ownsImageList; // true if we must delete m_imageList
};
// ----------------------------------------------------------------------------
// notebook event class (used by NOTEBOOK_PAGE_CHANGED/ING events)
// ----------------------------------------------------------------------------
class WXDLLEXPORT wxNotebookEvent : public wxNotifyEvent
{
public:
wxNotebookEvent(wxEventType commandType = wxEVT_NULL, int id = 0,
int nSel = -1, int nOldSel = -1)
: wxNotifyEvent(commandType, id)
{
m_nSel = nSel;
m_nOldSel = nOldSel;
}
// accessors
// the currently selected page (-1 if none)
int GetSelection() const { return m_nSel; }
void SetSelection(int nSel) { m_nSel = nSel; }
// the page that was selected before the change (-1 if none)
int GetOldSelection() const { return m_nOldSel; }
void SetOldSelection(int nOldSel) { m_nOldSel = nOldSel; }
private:
int m_nSel, // currently selected page
m_nOldSel; // previously selected page
DECLARE_DYNAMIC_CLASS(wxNotebookEvent)
};
// ----------------------------------------------------------------------------
// event types and macros for them
// ----------------------------------------------------------------------------
#if defined(__BORLANDC__) && defined(__WIN16__)
// For 16-bit BC++, these 2 would be identical otherwise (truncated)
#define wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED wxEVT_COMMAND_NB_PAGE_CHANGED
#define wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING wxEVT_COMMAND_NB_PAGE_CHANGING
#endif
BEGIN_DECLARE_EVENT_TYPES()
DECLARE_EVENT_TYPE(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED, 802)
DECLARE_EVENT_TYPE(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING, 803)
END_DECLARE_EVENT_TYPES()
typedef void (wxEvtHandler::*wxNotebookEventFunction)(wxNotebookEvent&);
// Truncation in 16-bit BC++ means we need to define these differently
#if defined(__BORLANDC__) && defined(__WIN16__)
#define EVT_NOTEBOOK_PAGE_CHANGED(id, fn) \
DECLARE_EVENT_TABLE_ENTRY( \
wxEVT_COMMAND_NB_PAGE_CHANGED, \
id, \
-1, \
(wxObjectEventFunction)(wxEventFunction)(wxNotebookEventFunction) &fn, \
NULL \
),
#define EVT_NOTEBOOK_PAGE_CHANGING(id, fn) \
DECLARE_EVENT_TABLE_ENTRY( \
wxEVT_COMMAND_NB_PAGE_CHANGING, \
id, \
-1, \
(wxObjectEventFunction)(wxEventFunction)(wxNotebookEventFunction) &fn, \
NULL \
),
#else
#define EVT_NOTEBOOK_PAGE_CHANGED(id, fn) \
DECLARE_EVENT_TABLE_ENTRY( \
wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED, \
id, \
-1, \
(wxObjectEventFunction)(wxEventFunction)(wxNotebookEventFunction) &fn, \
NULL \
),
#define EVT_NOTEBOOK_PAGE_CHANGING(id, fn) \
DECLARE_EVENT_TABLE_ENTRY( \
wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING, \
id, \
-1, \
(wxObjectEventFunction)(wxEventFunction)(wxNotebookEventFunction) &fn, \
NULL \
),
#endif
// ----------------------------------------------------------------------------
// wxNotebook class itself
// ----------------------------------------------------------------------------
#if defined(__WXUNIVERSAL__)
#include "wx/univ/notebook.h"
#elif defined(__WXMSW__)
#ifdef __WIN16__
#include "wx/generic/notebook.h"
#else
#include "wx/msw/notebook.h"
#endif
#elif defined(__WXMOTIF__)
#include "wx/generic/notebook.h"
#elif defined(__WXGTK__)
#include "wx/gtk/notebook.h"
#elif defined(__WXQT__)
#include "wx/qt/notebook.h"
#elif defined(__WXMAC__)
#include "wx/mac/notebook.h"
#elif defined(__WXPM__)
#include "wx/os2/notebook.h"
#elif defined(__WXSTUBS__)
#include "wx/stubs/notebook.h"
#endif
#endif // wxUSE_NOTEBOOK
#endif
// _WX_NOTEBOOK_H_BASE_

23
include/wx/palette.h Normal file
View File

@@ -0,0 +1,23 @@
#ifndef _WX_PALETTE_H_BASE_
#define _WX_PALETTE_H_BASE_
#if defined(__WXMSW__)
#include "wx/msw/palette.h"
#elif defined(__WXMOTIF__)
#include "wx/motif/palette.h"
#elif defined(__WXGTK__)
#include "wx/generic/paletteg.h"
#elif defined(__WXMGL__)
#include "wx/mgl/palette.h"
#elif defined(__WXQT__)
#include "wx/qt/palette.h"
#elif defined(__WXMAC__)
#include "wx/mac/palette.h"
#elif defined(__WXPM__)
#include "wx/os2/palette.h"
#elif defined(__WXSTUBS__)
#include "wx/stubs/palette.h"
#endif
#endif
// _WX_PALETTE_H_BASE_

23
include/wx/pen.h Normal file
View File

@@ -0,0 +1,23 @@
#ifndef _WX_PEN_H_BASE_
#define _WX_PEN_H_BASE_
#if defined(__WXMSW__)
#include "wx/msw/pen.h"
#elif defined(__WXMOTIF__)
#include "wx/motif/pen.h"
#elif defined(__WXGTK__)
#include "wx/gtk/pen.h"
#elif defined(__WXMGL__)
#include "wx/mgl/pen.h"
#elif defined(__WXQT__)
#include "wx/qt/pen.h"
#elif defined(__WXMAC__)
#include "wx/mac/pen.h"
#elif defined(__WXPM__)
#include "wx/os2/pen.h"
#elif defined(__WXSTUBS__)
#include "wx/stubs/pen.h"
#endif
#endif
// _WX_PEN_H_BASE_

32
include/wx/printdlg.h Normal file
View File

@@ -0,0 +1,32 @@
#ifndef _WX_PRINTDLG_H_BASE_
#define _WX_PRINTDLG_H_BASE_
#if defined(__WXMSW__)
#include "wx/msw/printdlg.h"
#elif defined(__WXMOTIF__)
#include "wx/generic/prntdlgg.h"
#elif defined(__WXGTK__)
#include "wx/generic/prntdlgg.h"
#elif defined(__WXQT__)
#include "wx/generic/prntdlgg.h"
#elif defined(__WXMAC__)
#include "wx/mac/printdlg.h"
#elif defined(__WXPM__)
#include "wx/generic/prntdlgg.h"
#elif defined(__WXSTUBS__)
#include "wx/generic/prntdlgg.h"
#endif
#if !defined(__WXMSW__) && !defined(__WXMAC__)
#define wxPrintDialog wxGenericPrintDialog
#define sm_classwxPrintDialog sm_classwxGenericPrintDialog
#define wxPrintSetupDialog wxGenericPrintSetupDialog
#define sm_classwxPrintSetupDialog sm_classwxGenericPrintSetupDialog
#define wxPageSetupDialog wxGenericPageSetupDialog
#define sm_classwxPageSetupDialog sm_classwxGenericPageSetupDialog
#endif
#endif
// _WX_PRINTDLG_H_BASE_

118
include/wx/radiobox.h Normal file
View File

@@ -0,0 +1,118 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/radiobox.h
// Purpose: wxRadioBox declaration
// Author: Vadim Zeitlin
// Modified by:
// Created: 10.09.00
// RCS-ID: $Id$
// Copyright: (c) wxWindows team
// Licence: wxWindows license
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_RADIOBOX_H_BASE_
#define _WX_RADIOBOX_H_BASE_
#ifdef __GNUG__
#pragma interface "radioboxbase.h"
#endif
#if wxUSE_RADIOBOX
#include "wx/control.h"
WXDLLEXPORT_DATA(extern const wxChar*) wxRadioBoxNameStr;
// ----------------------------------------------------------------------------
// wxRadioBoxBase is not a normal base class, but rather a mix-in because the
// real wxRadioBox derives from different classes on different platforms: for
// example, it is a wxStaticBox in wxUniv but not in wxMSW
// ----------------------------------------------------------------------------
class WXDLLEXPORT wxRadioBoxBase
{
public:
// selection
virtual void SetSelection(int n) = 0;
virtual int GetSelection() const = 0;
virtual wxString GetStringSelection() const
{
wxString s;
int sel = GetSelection();
if ( sel != wxNOT_FOUND )
s = GetString(sel);
return s;
}
virtual bool SetStringSelection(const wxString& s)
{
int sel = FindString(s);
if ( sel != wxNOT_FOUND )
{
SetSelection(sel);
return TRUE;
}
return FALSE;
}
// string access
virtual int GetCount() const = 0;
virtual int FindString(const wxString& s) const
{
int count = GetCount();
for ( int n = 0; n < count; n++ )
{
if ( GetString(n) == s )
return n;
}
return wxNOT_FOUND;
}
virtual wxString GetString(int n) const = 0;
virtual void SetString(int n, const wxString& label) = 0;
// change the individual radio button state
virtual void Enable(int n, bool enable = TRUE) = 0;
virtual void Show(int n, bool show = TRUE) = 0;
// layout parameters
virtual int GetColumnCount() const = 0;
virtual int GetRowCount() const = 0;
// return the item above/below/to the left/right of the given one
int GetNextItem(int item, wxDirection dir, long style) const;
// for compatibility only, don't use these methods in new code!
#if WXWIN_COMPATIBILITY_2_2
int Number() const { return GetCount(); }
wxString GetLabel(int n) const { return GetString(n); }
void SetLabel(int n, const wxString& label) { SetString(n, label); }
#endif // WXWIN_COMPATIBILITY_2_2
};
#if defined(__WXUNIVERSAL__)
#include "wx/univ/radiobox.h"
#elif defined(__WXMSW__)
#include "wx/msw/radiobox.h"
#elif defined(__WXMOTIF__)
#include "wx/motif/radiobox.h"
#elif defined(__WXGTK__)
#include "wx/gtk/radiobox.h"
#elif defined(__WXQT__)
#include "wx/qt/radiobox.h"
#elif defined(__WXMAC__)
#include "wx/mac/radiobox.h"
#elif defined(__WXPM__)
#include "wx/os2/radiobox.h"
#elif defined(__WXSTUBS__)
#include "wx/stubs/radiobox.h"
#endif
#endif // wxUSE_RADIOBOX
#endif
// _WX_RADIOBOX_H_BASE_

57
include/wx/radiobut.h Normal file
View File

@@ -0,0 +1,57 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/radiobut.h
// Purpose: wxRadioButton declaration
// Author: Vadim Zeitlin
// Modified by:
// Created: 07.09.00
// RCS-ID: $Id$
// Copyright: (c) wxWindows team
// Licence: wxWindows license
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_RADIOBUT_H_BASE_
#define _WX_RADIOBUT_H_BASE_
#if wxUSE_RADIOBTN
/*
There is no wxRadioButtonBase class as wxRadioButton interface is the same
as of wxCheckBox(Base), but under some platforms wxRadioButton really
derives from wxCheckBox and on the others it doesn't.
The pseudo-declaration of wxRadioButtonBase would look like this:
class wxRadioButtonBase : public ...
{
public:
virtual void SetValue(bool value);
virtual bool GetValue() const;
};
*/
#include "wx/control.h"
WXDLLEXPORT_DATA(extern const wxChar*) wxRadioButtonNameStr;
#if defined(__WXUNIVERSAL__)
#include "wx/univ/radiobut.h"
#elif defined(__WXMSW__)
#include "wx/msw/radiobut.h"
#elif defined(__WXMOTIF__)
#include "wx/motif/radiobut.h"
#elif defined(__WXGTK__)
#include "wx/gtk/radiobut.h"
#elif defined(__WXQT__)
#include "wx/qt/radiobut.h"
#elif defined(__WXMAC__)
#include "wx/mac/radiobut.h"
#elif defined(__WXPM__)
#include "wx/os2/radiobut.h"
#elif defined(__WXSTUBS__)
#include "wx/stubs/radiobut.h"
#endif
#endif // wxUSE_RADIOBTN
#endif
// _WX_RADIOBUT_H_BASE_

23
include/wx/region.h Normal file
View File

@@ -0,0 +1,23 @@
#ifndef _WX_REGION_H_BASE_
#define _WX_REGION_H_BASE_
#if defined(__WXMSW__)
#include "wx/msw/region.h"
#elif defined(__WXMOTIF__)
#include "wx/motif/region.h"
#elif defined(__WXGTK__)
#include "wx/gtk/region.h"
#elif defined(__WXMGL__)
#include "wx/mgl/region.h"
#elif defined(__WXQT__)
#include "wx/qt/region.h"
#elif defined(__WXMAC__)
#include "wx/mac/region.h"
#elif defined(__WXPM__)
#include "wx/os2/region.h"
#elif defined(__WXSTUBS__)
#include "wx/stubs/region.h"
#endif
#endif
// _WX_REGION_H_BASE_

62
include/wx/scrolbar.h Normal file
View File

@@ -0,0 +1,62 @@
#ifndef _WX_SCROLBAR_H_BASE_
#define _WX_SCROLBAR_H_BASE_
#if wxUSE_SCROLLBAR
#include "wx/control.h"
WXDLLEXPORT_DATA(extern const wxChar*) wxScrollBarNameStr;
// ----------------------------------------------------------------------------
// wxScrollBar: a scroll bar control
// ----------------------------------------------------------------------------
class WXDLLEXPORT wxScrollBarBase : public wxControl
{
public:
// scrollbar construction
bool Create(wxWindow *parent,
wxWindowID id,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxSB_HORIZONTAL,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxScrollBarNameStr);
// accessors
virtual int GetThumbPosition() const = 0;
virtual int GetThumbSize() const = 0;
virtual int GetPageSize() const = 0;
virtual int GetRange() const = 0;
bool IsVertical() const { return (m_windowStyle & wxVERTICAL) != 0; }
// operations
virtual void SetThumbPosition(int viewStart) = 0;
virtual void SetScrollbar(int position, int thumbSize,
int range, int pageSize,
bool refresh = TRUE) = 0;
};
#if defined(__WXUNIVERSAL__)
#include "wx/univ/scrolbar.h"
#elif defined(__WXMSW__)
#include "wx/msw/scrolbar.h"
#elif defined(__WXMOTIF__)
#include "wx/motif/scrolbar.h"
#elif defined(__WXGTK__)
#include "wx/gtk/scrolbar.h"
#elif defined(__WXQT__)
#include "wx/qt/scrolbar.h"
#elif defined(__WXMAC__)
#include "wx/mac/scrolbar.h"
#elif defined(__WXPM__)
#include "wx/os2/scrolbar.h"
#elif defined(__WXSTUBS__)
#include "wx/stubs/scrolbar.h"
#endif
#endif // wxUSE_SCROLLBAR
#endif
// _WX_SCROLBAR_H_BASE_

129
include/wx/settings.h Normal file
View File

@@ -0,0 +1,129 @@
/////////////////////////////////////////////////////////////////////////////
// Name: settings.h
// Purpose: wxSystemSettings defines; includes platform settings.h
// Author: Julian Smart
// Modified by:
// Created: 01/02/97
// RCS-ID: $Id$
// Copyright: (c) Julian Smart and Markus Holzem
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_SETTINGS_H_BASE_
#define _WX_SETTINGS_H_BASE_
#define wxSYS_WHITE_BRUSH 0
#define wxSYS_LTGRAY_BRUSH 1
#define wxSYS_GRAY_BRUSH 2
#define wxSYS_DKGRAY_BRUSH 3
#define wxSYS_BLACK_BRUSH 4
#define wxSYS_NULL_BRUSH 5
#define wxSYS_HOLLOW_BRUSH wxSYS_NULL_BRUSH
#define wxSYS_WHITE_PEN 6
#define wxSYS_BLACK_PEN 7
#define wxSYS_NULL_PEN 8
#define wxSYS_OEM_FIXED_FONT 10
#define wxSYS_ANSI_FIXED_FONT 11
#define wxSYS_ANSI_VAR_FONT 12
#define wxSYS_SYSTEM_FONT 13
#define wxSYS_DEVICE_DEFAULT_FONT 14
#define wxSYS_DEFAULT_PALETTE 15
#define wxSYS_SYSTEM_FIXED_FONT 16
#define wxSYS_DEFAULT_GUI_FONT 17
#define wxSYS_COLOUR_SCROLLBAR 0
#define wxSYS_COLOUR_BACKGROUND 1
#define wxSYS_COLOUR_ACTIVECAPTION 2
#define wxSYS_COLOUR_INACTIVECAPTION 3
#define wxSYS_COLOUR_MENU 4
#define wxSYS_COLOUR_WINDOW 5
#define wxSYS_COLOUR_WINDOWFRAME 6
#define wxSYS_COLOUR_MENUTEXT 7
#define wxSYS_COLOUR_WINDOWTEXT 8
#define wxSYS_COLOUR_CAPTIONTEXT 9
#define wxSYS_COLOUR_ACTIVEBORDER 10
#define wxSYS_COLOUR_INACTIVEBORDER 11
#define wxSYS_COLOUR_APPWORKSPACE 12
#define wxSYS_COLOUR_HIGHLIGHT 13
#define wxSYS_COLOUR_HIGHLIGHTTEXT 14
#define wxSYS_COLOUR_BTNFACE 15
#define wxSYS_COLOUR_BTNSHADOW 16
#define wxSYS_COLOUR_GRAYTEXT 17
#define wxSYS_COLOUR_BTNTEXT 18
#define wxSYS_COLOUR_INACTIVECAPTIONTEXT 19
#define wxSYS_COLOUR_BTNHIGHLIGHT 20
#define wxSYS_COLOUR_3DDKSHADOW 21
#define wxSYS_COLOUR_3DLIGHT 22
#define wxSYS_COLOUR_INFOTEXT 23
#define wxSYS_COLOUR_INFOBK 24
#define wxSYS_COLOUR_LISTBOX 25
#define wxSYS_COLOUR_DESKTOP wxSYS_COLOUR_BACKGROUND
#define wxSYS_COLOUR_3DFACE wxSYS_COLOUR_BTNFACE
#define wxSYS_COLOUR_3DSHADOW wxSYS_COLOUR_BTNSHADOW
#define wxSYS_COLOUR_3DHIGHLIGHT wxSYS_COLOUR_BTNHIGHLIGHT
#define wxSYS_COLOUR_3DHILIGHT wxSYS_COLOUR_BTNHIGHLIGHT
#define wxSYS_COLOUR_BTNHILIGHT wxSYS_COLOUR_BTNHIGHLIGHT
// Metrics
#define wxSYS_MOUSE_BUTTONS 1
#define wxSYS_BORDER_X 2
#define wxSYS_BORDER_Y 3
#define wxSYS_CURSOR_X 4
#define wxSYS_CURSOR_Y 5
#define wxSYS_DCLICK_X 6
#define wxSYS_DCLICK_Y 7
#define wxSYS_DRAG_X 8
#define wxSYS_DRAG_Y 9
#define wxSYS_EDGE_X 10
#define wxSYS_EDGE_Y 11
#define wxSYS_HSCROLL_ARROW_X 12
#define wxSYS_HSCROLL_ARROW_Y 13
#define wxSYS_HTHUMB_X 14
#define wxSYS_ICON_X 15
#define wxSYS_ICON_Y 16
#define wxSYS_ICONSPACING_X 17
#define wxSYS_ICONSPACING_Y 18
#define wxSYS_WINDOWMIN_X 19
#define wxSYS_WINDOWMIN_Y 20
#define wxSYS_SCREEN_X 21
#define wxSYS_SCREEN_Y 22
#define wxSYS_FRAMESIZE_X 23
#define wxSYS_FRAMESIZE_Y 24
#define wxSYS_SMALLICON_X 25
#define wxSYS_SMALLICON_Y 26
#define wxSYS_HSCROLL_Y 27
#define wxSYS_VSCROLL_X 28
#define wxSYS_VSCROLL_ARROW_X 29
#define wxSYS_VSCROLL_ARROW_Y 30
#define wxSYS_VTHUMB_Y 31
#define wxSYS_CAPTION_Y 32
#define wxSYS_MENU_Y 33
#define wxSYS_NETWORK_PRESENT 34
#define wxSYS_PENWINDOWS_PRESENT 35
#define wxSYS_SHOW_SOUNDS 36
#define wxSYS_SWAP_BUTTONS 37
#if defined(__WXMSW__)
#include "wx/msw/settings.h"
#elif defined(__WXMOTIF__)
#include "wx/motif/settings.h"
#elif defined(__WXGTK__)
#include "wx/gtk/settings.h"
#elif defined(__WXMGL__)
#include "wx/mgl/settings.h"
#elif defined(__WXQT__)
#include "wx/qt/settings.h"
#elif defined(__WXMAC__)
#include "wx/mac/settings.h"
#elif defined(__WXPM__)
#include "wx/os2/settings.h"
#elif defined(__WXSTUBS__)
#include "wx/stubs/settings.h"
#endif
#endif
// _WX_SETTINGS_H_BASE_

84
include/wx/setup.h Normal file
View File

@@ -0,0 +1,84 @@
/*
* The main configuration file for wxWindows.
*
* NB: this file can be included in .c files, so it must be compileable by a C
* compiler - use #ifdef __cplusplus for C++ specific features and avoid
* using C++ style comments
*/
#ifndef _WX_SETUP_H_BASE_
#define _WX_SETUP_H_BASE_
/* compatibility code, to be removed asap: */
#if !defined(__WXBASE__) && !defined(__WXMSW__) && !defined(__WXGTK__) && !defined(__WXMOTIF__) && !defined(__WXQT__) && !defined(__WXSTUBS__) && !defined(__WXMAC__) && !defined(__WXPM__)
#error No __WXxxx__ define set! Please define one of __WXBASE__,__WXGTK__,__WXMSW__,__WXMOTIF__,__WXMAC__,__WXQT__,__WXPM__,__WXSTUBS__
#endif
/*
wxUniversal is defined together with one of other ports, so test for it
first
*/
#ifdef __WXUNIVERSAL__
#if defined(__USE_WXCONFIG__) && defined(__WXDEBUG__)
#include "wx/univd/setup.h"
#else
#include "wx/univ/setup.h"
#endif
#elif defined(__WXBASE__)
#if defined(__USE_WXCONFIG__) && defined(__WXDEBUG__)
#include "wx/based/setup.h"
#else
#include "wx/base/setup.h"
#endif
#elif defined(__VMS)
#include "wx_root:[wxwindows]setup.h"
#elif defined(__WXMSW__)
#include "wx/msw/setup.h"
#elif defined(__WXMAC__)
#include "wx/mac/setup.h"
#elif defined(__WXQT__)
#if defined(__USE_WXCONFIG__) && defined(__WXDEBUG__)
#include "wx/qtd/setup.h"
#else
#include "wx/qt/setup.h"
#endif
#elif defined(__WXMOTIF__)
#if defined(__USE_WXCONFIG__) && defined(__WXDEBUG__)
#include "wx/motifd/setup.h"
#else
#include "wx/motif/setup.h"
#endif
#elif defined(__WXPM__)
#include "wx/os2/setup.h"
#elif defined(__WXSTUBS__)
#include "wx/stubs/setup.h"
#elif defined(__WXGTK__)
#if defined(__USE_WXCONFIG__) && defined(__WXDEBUG__)
#include "wx/gtkd/setup.h"
#else
#include "wx/gtk/setup.h"
#endif
#endif
#include "wx/chkconf.h"
/*
define some constants identifying wxWindows version in more details than
just the version number
*/
// wxLogChain class available
#define wxHAS_LOG_CHAIN
// define this when wxDC::Blit() respects SetDeviceOrigin() in wxGTK
#undef wxHAS_WORKING_GTK_DC_BLIT
#endif /* _WX_SETUP_H_BASE_ */

114
include/wx/slider.h Normal file
View File

@@ -0,0 +1,114 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/slider.h
// Purpose: wxSlider interface
// Author: Vadim Zeitlin
// Modified by:
// Created: 09.02.01
// RCS-ID: $Id$
// Copyright: (c) 1996-2001 wxWindows team
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_SLIDER_H_BASE_
#define _WX_SLIDER_H_BASE_
// ----------------------------------------------------------------------------
// headers
// ----------------------------------------------------------------------------
#include "wx/defs.h"
#if wxUSE_SLIDER
#include "wx/control.h"
WXDLLEXPORT_DATA(extern const wxChar*) wxSliderNameStr;
// ----------------------------------------------------------------------------
// wxSliderBase: define wxSlider interface
// ----------------------------------------------------------------------------
class WXDLLEXPORT wxSliderBase : public wxControl
{
public:
/* the ctor of the derived class should have the following form:
wxSlider(wxWindow *parent,
wxWindowID id,
int value, int minValue, int maxValue,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxSL_HORIZONTAL,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxSliderNameStr);
*/
// get/set the current slider value (should be in range)
virtual int GetValue() const = 0;
virtual void SetValue(int value) = 0;
// retrieve/change the range
virtual void SetRange(int minValue, int maxValue) = 0;
virtual int GetMin() const = 0;
virtual int GetMax() const = 0;
// the line/page size is the increment by which the slider moves when
// cursor arrow key/page up or down are pressed (clicking the mouse is like
// pressing PageUp/Down) and are by default set to 1 and 1/10 of the range
virtual void SetLineSize(int lineSize) = 0;
virtual void SetPageSize(int pageSize) = 0;
virtual int GetLineSize() const = 0;
virtual int GetPageSize() const = 0;
// these methods get/set the length of the slider pointer in pixels
virtual void SetThumbLength(int lenPixels) = 0;
virtual int GetThumbLength() const = 0;
// warning: most of subsequent methods are currently only implemented in
// wxMSW under Win95 and are silently ignored on other platforms
virtual void SetTickFreq(int WXUNUSED(n), int WXUNUSED(pos)) { }
virtual int GetTickFreq() const { return 0; }
virtual void ClearTicks() { }
virtual void SetTick(int WXUNUSED(tickPos)) { }
virtual void ClearSel() { }
virtual int GetSelEnd() const { return GetMin(); }
virtual int GetSelStart() const { return GetMax(); }
virtual void SetSelection(int WXUNUSED(min), int WXUNUSED(max)) { }
};
// ----------------------------------------------------------------------------
// include the real class declaration
// ----------------------------------------------------------------------------
#if defined(__WXUNIVERSAL__)
#include "wx/univ/slider.h"
#elif defined(__WXMSW__)
#ifdef __WIN95__
#include "wx/msw/slider95.h"
#define wxSlider wxSlider95
#define sm_classwxSlider sm_classwxSlider95
#else // Win16
#include "wx/msw/slidrmsw.h"
#define wxSlider wxSliderMSW
#define sm_classwxSlider sm_classwxSliderMSW
#endif // Win32/Win16
#elif defined(__WXMOTIF__)
#include "wx/motif/slider.h"
#elif defined(__WXGTK__)
#include "wx/gtk/slider.h"
#elif defined(__WXQT__)
#include "wx/qt/slider.h"
#elif defined(__WXMAC__)
#include "wx/mac/slider.h"
#elif defined(__WXPM__)
#include "wx/os2/slider.h"
#elif defined(__WXSTUBS__)
#include "wx/stubs/slider.h"
#endif
#endif // wxUSE_SLIDER
#endif
// _WX_SLIDER_H_BASE_

128
include/wx/spinbutt.h Normal file
View File

@@ -0,0 +1,128 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/spinbutt.h
// Purpose: wxSpinButtonBase class
// Author: Julian Smart, Vadim Zeitlin
// Modified by:
// Created: 23.07.99
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_SPINBUTT_H_BASE_
#define _WX_SPINBUTT_H_BASE_
// ----------------------------------------------------------------------------
// headers
// ----------------------------------------------------------------------------
#include "wx/defs.h"
#if wxUSE_SPINBTN
#include "wx/control.h"
#include "wx/event.h"
#define wxSPIN_BUTTON_NAME _T("wxSpinButton")
// ----------------------------------------------------------------------------
// The wxSpinButton is like a small scrollbar than is often placed next
// to a text control.
//
// Styles:
// wxSP_HORIZONTAL: horizontal spin button
// wxSP_VERTICAL: vertical spin button (the default)
// wxSP_ARROW_KEYS: arrow keys increment/decrement value
// wxSP_WRAP: value wraps at either end
// ----------------------------------------------------------------------------
class WXDLLEXPORT wxSpinButtonBase : public wxControl
{
public:
wxSpinButtonBase() { InitBase(); }
// accessors
virtual int GetValue() const = 0;
virtual int GetMin() const { return m_min; }
virtual int GetMax() const { return m_max; }
// operations
virtual void SetValue(int val) = 0;
virtual void SetRange(int minVal, int maxVal)
{
m_min = minVal;
m_max = maxVal;
}
// is this spin button vertically oriented?
bool IsVertical() const { return (m_windowStyle & wxSP_VERTICAL) != 0; }
protected:
// init the base part of the control
void InitBase()
{
m_min = 0;
m_max = 100;
}
// the range value
int m_min;
int m_max;
};
// ----------------------------------------------------------------------------
// include the declaration of the real class
// ----------------------------------------------------------------------------
#if defined(__WXUNIVERSAL__)
#include "wx/univ/spinbutt.h"
#elif defined(__WXMSW__) && defined(__WIN95__)
#include "wx/msw/spinbutt.h"
#elif defined(__WXMOTIF__)
#include "wx/motif/spinbutt.h"
#elif defined(__WXGTK__)
#include "wx/gtk/spinbutt.h"
#elif defined(__WXQT__)
#include "wx/qt/spinbutt.h"
#elif defined(__WXMAC__)
#include "wx/mac/spinbutt.h"
#elif defined(__WXPM__)
#include "wx/os2/spinbutt.h"
#elif defined(__WXSTUBS__)
#include "wx/stubs/spinbutt.h"
#endif
// ----------------------------------------------------------------------------
// the wxSpinButton event
// ----------------------------------------------------------------------------
class WXDLLEXPORT wxSpinEvent : public wxNotifyEvent
{
public:
wxSpinEvent(wxEventType commandType = wxEVT_NULL, int id = 0)
: wxNotifyEvent(commandType, id)
{
}
// get the current value of the control
int GetPosition() const { return m_commandInt; }
void SetPosition(int pos) { m_commandInt = pos; }
private:
DECLARE_DYNAMIC_CLASS(wxSpinEvent)
};
typedef void (wxEvtHandler::*wxSpinEventFunction)(wxSpinEvent&);
// macros for handling spin events
#define EVT_SPIN_UP(id, func) \
DECLARE_EVENT_TABLE_ENTRY( wxEVT_SCROLL_LINEUP, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxSpinEventFunction) & func, NULL ),
#define EVT_SPIN_DOWN(id, func) \
DECLARE_EVENT_TABLE_ENTRY( wxEVT_SCROLL_LINEDOWN, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxSpinEventFunction) & func, NULL ),
#define EVT_SPIN(id, func) \
DECLARE_EVENT_TABLE_ENTRY( wxEVT_SCROLL_THUMBTRACK, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxSpinEventFunction) & func, NULL ),
#endif // wxUSE_SPINBTN
#endif
// _WX_SPINBUTT_H_BASE_

70
include/wx/statbmp.h Normal file
View File

@@ -0,0 +1,70 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/statbmp.h
// Purpose: wxStaticBitmap class interface
// Author: Vadim Zeitlin
// Modified by:
// Created: 25.08.00
// RCS-ID: $Id$
// Copyright: (c) 2000 Vadim Zeitlin
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_STATBMP_H_BASE_
#define _WX_STATBMP_H_BASE_
#ifdef __GNUG__
#pragma interface "statbmpbase.h"
#endif
#if wxUSE_STATBMP
#include "wx/control.h"
#include "wx/bitmap.h"
class WXDLLEXPORT wxIcon;
class WXDLLEXPORT wxBitmap;
WXDLLEXPORT_DATA(extern const wxChar*) wxStaticBitmapNameStr;
// a control showing an icon or a bitmap
class WXDLLEXPORT wxStaticBitmapBase : public wxControl
{
public:
#ifdef __DARWIN__
~wxStaticBitmapBase() { }
#endif
// our interface
virtual void SetIcon(const wxIcon& icon) = 0;
virtual void SetBitmap(const wxBitmap& bitmap) = 0;
virtual wxBitmap GetBitmap() const = 0;
// overriden base class virtuals
virtual bool AcceptsFocus() const { return FALSE; }
protected:
virtual wxSize DoGetBestClientSize() const;
};
#if defined(__WXUNIVERSAL__)
#include "wx/univ/statbmp.h"
#elif defined(__WXMSW__)
#include "wx/msw/statbmp.h"
#elif defined(__WXMOTIF__)
#include "wx/motif/statbmp.h"
#elif defined(__WXGTK__)
#include "wx/gtk/statbmp.h"
#elif defined(__WXQT__)
#include "wx/qt/statbmp.h"
#elif defined(__WXMAC__)
#include "wx/mac/statbmp.h"
#elif defined(__WXPM__)
#include "wx/os2/statbmp.h"
#elif defined(__WXSTUBS__)
#include "wx/stubs/statbmp.h"
#endif
#endif // wxUSE_STATBMP
#endif
// _WX_STATBMP_H_BASE_

42
include/wx/statbox.h Normal file
View File

@@ -0,0 +1,42 @@
#ifndef _WX_STATBOX_H_BASE_
#define _WX_STATBOX_H_BASE_
#if wxUSE_STATBOX
#include "wx/control.h"
WXDLLEXPORT_DATA(extern const wxChar*) wxStaticBoxNameStr;
// ----------------------------------------------------------------------------
// wxStaticBox: a grouping box with a label
// ----------------------------------------------------------------------------
class WXDLLEXPORT wxStaticBoxBase : public wxControl
{
public:
// overriden base class virtuals
virtual bool AcceptsFocus() const { return FALSE; }
};
#if defined(__WXUNIVERSAL__)
#include "wx/univ/statbox.h"
#elif defined(__WXMSW__)
#include "wx/msw/statbox.h"
#elif defined(__WXMOTIF__)
#include "wx/motif/statbox.h"
#elif defined(__WXGTK__)
#include "wx/gtk/statbox.h"
#elif defined(__WXQT__)
#include "wx/qt/statbox.h"
#elif defined(__WXMAC__)
#include "wx/mac/statbox.h"
#elif defined(__WXPM__)
#include "wx/os2/statbox.h"
#elif defined(__WXSTUBS__)
#include "wx/stubs/statbox.h"
#endif
#endif // wxUSE_STATBOX
#endif
// _WX_STATBOX_H_BASE_

38
include/wx/stattext.h Normal file
View File

@@ -0,0 +1,38 @@
#ifndef _WX_STATTEXT_H_BASE_
#define _WX_STATTEXT_H_BASE_
#if wxUSE_STATTEXT
#include "wx/control.h"
WXDLLEXPORT_DATA(extern const wxChar*) wxStaticTextNameStr;
class WXDLLEXPORT wxStaticTextBase : public wxControl
{
public:
// overriden base class virtuals
virtual bool AcceptsFocus() const { return FALSE; }
};
#if defined(__WXUNIVERSAL__)
#include "wx/univ/stattext.h"
#elif defined(__WXMSW__)
#include "wx/msw/stattext.h"
#elif defined(__WXMOTIF__)
#include "wx/motif/stattext.h"
#elif defined(__WXGTK__)
#include "wx/gtk/stattext.h"
#elif defined(__WXQT__)
#include "wx/qt/stattext.h"
#elif defined(__WXMAC__)
#include "wx/mac/stattext.h"
#elif defined(__WXPM__)
#include "wx/os2/stattext.h"
#elif defined(__WXSTUBS__)
#include "wx/stubs/stattext.h"
#endif
#endif // wxUSE_STATTEXT
#endif
// _WX_STATTEXT_H_BASE_

19
include/wx/taskbar.h Normal file
View File

@@ -0,0 +1,19 @@
#ifndef _WX_TASKBAR_H_BASE_
#define _WX_TASKBAR_H_BASE_
#if defined(__WXMSW__)
#include "wx/msw/taskbar.h"
#elif defined(__WXMOTIF__)
#include "wx/motif/taskbar.h"
#elif defined(__WXGTK__)
#elif defined(__WXQT__)
#elif defined(__WXMAC__)
#include "wx/mac/taskbar.h"
#elif defined(__WXPM__)
#include "wx/os2/taskbar.h"
#elif defined(__WXSTUBS__)
#include "wx/stubs/taskbar.h"
#endif
#endif
// _WX_TASKBAR_H_BASE_

345
include/wx/textctrl.h Normal file
View File

@@ -0,0 +1,345 @@
///////////////////////////////////////////////////////////////////////////////
// Name: textctrl.h
// Purpose: wxTextCtrlBase class - the interface of wxTextCtrl
// Author: Vadim Zeitlin
// Modified by:
// Created: 13.07.99
// RCS-ID: $Id$
// Copyright: (c) wxWindows team
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_TEXTCTRL_H_BASE_
#define _WX_TEXTCTRL_H_BASE_
// ----------------------------------------------------------------------------
// headers
// ----------------------------------------------------------------------------
#ifdef __GNUG__
#pragma interface "textctrlbase.h"
#endif
#include "wx/defs.h"
#if wxUSE_TEXTCTRL
#include "wx/control.h" // the base class
// 16-bit Borland 4.0 doesn't seem to allow multiple inheritance with wxWindow
// and streambuf: it complains about deriving a huge class from the huge class
// streambuf. !! Also, can't use streambuf if making or using a DLL :-(
#if (defined(__BORLANDC__)) || defined(__MWERKS__) || defined(_WINDLL) || defined(WXUSINGDLL) || defined(WXMAKINGDLL)
#define NO_TEXT_WINDOW_STREAM
#endif
// the streambuf which is used in the declaration of wxTextCtrlBase below is not compatible
// with the standard-conforming implementation found in newer egcs versions
// (that is, the libstdc++ v3 that is shipped with it)
#if defined(__GNUC__)&&( (__GNUC__>2) ||( (__GNUC__==2)&&(__GNUC_MINOR__>97) ) )
#define NO_TEXT_WINDOW_STREAM
#endif
#ifndef NO_TEXT_WINDOW_STREAM
#if wxUSE_STD_IOSTREAM
#include "wx/ioswrap.h" // for iostream classes if we need them
#else // !wxUSE_STD_IOSTREAM
// can't compile this feature in if we don't use streams at all
#define NO_TEXT_WINDOW_STREAM
#endif // wxUSE_STD_IOSTREAM/!wxUSE_STD_IOSTREAM
#endif
class WXDLLEXPORT wxTextCtrl;
// ----------------------------------------------------------------------------
// constants
// ----------------------------------------------------------------------------
WXDLLEXPORT_DATA(extern const wxChar*) wxTextCtrlNameStr;
WXDLLEXPORT_DATA(extern const wxChar*) wxEmptyString;
// ----------------------------------------------------------------------------
// wxTextCtrl style flags
// ----------------------------------------------------------------------------
// the flag bits 0x0001, 2, 4 and 8 are free but should be used only for the
// things which don't make sense for a text control used by wxTextEntryDialog
// because they would otherwise conflict with wxOK, wxCANCEL, wxCENTRE
#define wxTE_READONLY 0x0010
#define wxTE_MULTILINE 0x0020
#define wxTE_PROCESS_TAB 0x0040
// this style means to use RICHEDIT control and does something only under wxMSW
// and Win32 and is silently ignored under all other platforms
#define wxTE_RICH 0x0080
#define wxTE_NO_VSCROLL 0x0100
#define wxTE_AUTO_SCROLL 0x0200
#define wxTE_PROCESS_ENTER 0x0400
#define wxTE_PASSWORD 0x0800
// automatically detect the URLs and generate the events when mouse is
// moved/clicked over an URL
//
// this is for Win32 richedit controls only so far
#define wxTE_AUTO_URL 0x1000
// ----------------------------------------------------------------------------
// wxTextAttr: a structure containing the visual attributes of a text
// ----------------------------------------------------------------------------
class WXDLLEXPORT wxTextAttr
{
public:
// ctors
wxTextAttr() { }
wxTextAttr(const wxColour& colText,
const wxColour& colBack = wxNullColour,
const wxFont& font = wxNullFont)
: m_colText(colText), m_colBack(colBack), m_font(font) { }
// setters
void SetTextColour(const wxColour& colText) { m_colText = colText; }
void SetBackgroundColour(const wxColour& colBack) { m_colBack = colBack; }
void SetFont(const wxFont& font) { m_font = font; }
// accessors
bool HasTextColour() const { return m_colText.Ok(); }
bool HasBackgroundColour() const { return m_colBack.Ok(); }
bool HasFont() const { return m_font.Ok(); }
// setters
const wxColour& GetTextColour() const { return m_colText; }
const wxColour& GetBackgroundColour() const { return m_colBack; }
const wxFont& GetFont() const { return m_font; }
// returns false if we have any attributes set, true otherwise
bool IsDefault() const
{
return !HasTextColour() && !HasBackgroundColour() && !HasFont();
}
private:
wxColour m_colText,
m_colBack;
wxFont m_font;
};
// ----------------------------------------------------------------------------
// wxTextCtrl: a single or multiple line text zone where user can enter and
// edit text
// ----------------------------------------------------------------------------
class WXDLLEXPORT wxTextCtrlBase : public wxControl
#ifndef NO_TEXT_WINDOW_STREAM
, public wxSTD streambuf
#endif
{
public:
// creation
// --------
wxTextCtrlBase();
~wxTextCtrlBase();
// accessors
// ---------
virtual wxString GetValue() const = 0;
virtual void SetValue(const wxString& value) = 0;
virtual int GetLineLength(long lineNo) const = 0;
virtual wxString GetLineText(long lineNo) const = 0;
virtual int GetNumberOfLines() const = 0;
virtual bool IsModified() const = 0;
virtual bool IsEditable() const = 0;
// If the return values from and to are the same, there is no selection.
virtual void GetSelection(long* from, long* to) const = 0;
// operations
// ----------
// editing
virtual void Clear() = 0;
virtual void Replace(long from, long to, const wxString& value) = 0;
virtual void Remove(long from, long to) = 0;
// load/save the controls contents from/to the file
virtual bool LoadFile(const wxString& file);
virtual bool SaveFile(const wxString& file = wxEmptyString);
// clears the dirty flag
virtual void DiscardEdits() = 0;
// set the max number of characters which may be entered in a single line
// text control
virtual void SetMaxLength(unsigned long WXUNUSED(len)) { }
// writing text inserts it at the current position, appending always
// inserts it at the end
virtual void WriteText(const wxString& text) = 0;
virtual void AppendText(const wxString& text) = 0;
// text control under some platforms supports the text styles: these
// methods allow to apply the given text style to the given selection or to
// set/get the style which will be used for all appended text
virtual bool SetStyle(long start, long end, const wxTextAttr& style);
virtual bool SetDefaultStyle(const wxTextAttr& style);
virtual const wxTextAttr& GetDefaultStyle() const;
// translate between the position (which is just an index in the text ctrl
// considering all its contents as a single strings) and (x, y) coordinates
// which represent column and line.
virtual long XYToPosition(long x, long y) const = 0;
virtual bool PositionToXY(long pos, long *x, long *y) const = 0;
virtual void ShowPosition(long pos) = 0;
// Clipboard operations
virtual void Copy() = 0;
virtual void Cut() = 0;
virtual void Paste() = 0;
virtual bool CanCopy() const;
virtual bool CanCut() const;
virtual bool CanPaste() const;
// Undo/redo
virtual void Undo() = 0;
virtual void Redo() = 0;
virtual bool CanUndo() const = 0;
virtual bool CanRedo() const = 0;
// Insertion point
virtual void SetInsertionPoint(long pos) = 0;
virtual void SetInsertionPointEnd() = 0;
virtual long GetInsertionPoint() const = 0;
virtual long GetLastPosition() const = 0;
virtual void SetSelection(long from, long to) = 0;
virtual void SelectAll();
virtual void SetEditable(bool editable) = 0;
// streambuf methods
#ifndef NO_TEXT_WINDOW_STREAM
int overflow(int i);
int sync();
int underflow();
#endif // NO_TEXT_WINDOW_STREAM
// stream-like insertion operators: these are always available, whether we
// were, or not, compiled with streambuf support
wxTextCtrl& operator<<(const wxString& s);
wxTextCtrl& operator<<(int i);
wxTextCtrl& operator<<(long i);
wxTextCtrl& operator<<(float f);
wxTextCtrl& operator<<(double d);
wxTextCtrl& operator<<(const wxChar c);
// obsolete functions
#if WXWIN_COMPATIBILITY
bool Modified() const { return IsModified(); }
#endif
protected:
// the name of the last file loaded with LoadFile() which will be used by
// SaveFile() by default
wxString m_filename;
// the text style which will be used for any new text added to the control
wxTextAttr m_defaultStyle;
private:
#ifndef NO_TEXT_WINDOW_STREAM
#if !wxUSE_IOSTREAMH
char *m_streambuf;
#endif
#endif
};
// ----------------------------------------------------------------------------
// include the platform-dependent class definition
// ----------------------------------------------------------------------------
#if defined(__WXUNIVERSAL__)
#include "wx/univ/textctrl.h"
#elif defined(__WXMSW__)
#include "wx/msw/textctrl.h"
#elif defined(__WXMOTIF__)
#include "wx/motif/textctrl.h"
#elif defined(__WXGTK__)
#include "wx/gtk/textctrl.h"
#elif defined(__WXQT__)
#include "wx/qt/textctrl.h"
#elif defined(__WXMAC__)
#include "wx/mac/textctrl.h"
#elif defined(__WXPM__)
#include "wx/os2/textctrl.h"
#elif defined(__WXSTUBS__)
#include "wx/stubs/textctrl.h"
#endif
// ----------------------------------------------------------------------------
// wxTextCtrl events
// ----------------------------------------------------------------------------
#if !WXWIN_COMPATIBILITY_EVENT_TYPES
BEGIN_DECLARE_EVENT_TYPES()
DECLARE_EVENT_TYPE(wxEVT_COMMAND_TEXT_UPDATED, 7)
DECLARE_EVENT_TYPE(wxEVT_COMMAND_TEXT_ENTER, 8)
DECLARE_EVENT_TYPE(wxEVT_COMMAND_TEXT_URL, 13)
DECLARE_EVENT_TYPE(wxEVT_COMMAND_TEXT_MAXLEN, 14)
END_DECLARE_EVENT_TYPES()
#endif // !WXWIN_COMPATIBILITY_EVENT_TYPES
class WXDLLEXPORT wxTextUrlEvent : public wxCommandEvent
{
public:
wxTextUrlEvent(int id, const wxMouseEvent& evtMouse,
long start, long end)
: wxCommandEvent(wxEVT_COMMAND_TEXT_URL, id),
m_evtMouse(evtMouse)
{ m_start = start; m_end = end; }
// get the mouse event which happend over the URL
const wxMouseEvent& GetMouseEvent() const { return m_evtMouse; }
// get the start of the URL
long GetURLStart() const { return m_start; }
// get the end of the URL
long GetURLEnd() const { return m_end; }
protected:
// the corresponding mouse event
wxMouseEvent m_evtMouse;
// the start and end indices of the URL in the text control
long m_start,
m_end;
private:
DECLARE_DYNAMIC_CLASS(wxTextUrlEvent)
public:
// for wxWin RTTI only, don't use
wxTextUrlEvent() { }
};
typedef void (wxEvtHandler::*wxTextUrlEventFunction)(wxTextUrlEvent&);
#define EVT_TEXT(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_COMMAND_TEXT_UPDATED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL ),
#define EVT_TEXT_ENTER(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_COMMAND_TEXT_ENTER, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL ),
#define EVT_TEXT_URL(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_COMMAND_TEXT_URL, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) (wxTextUrlEventFunction) & fn, (wxObject *) NULL ),
#define EVT_TEXT_MAXLEN(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_COMMAND_TEXT_MAXLEN, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL ),
#endif // wxUSE_TEXTCTRL
#endif
// _WX_TEXTCTRL_H_BASE_

50
include/wx/tglbtn.h Normal file
View File

@@ -0,0 +1,50 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/tglbtn.h
// Purpose: This dummy header includes the proper header file for the
// system we're compiling under.
// Author: John Norris, minor changes by Axel Schlueter
// Modified by:
// Created: 08.02.01
// RCS-ID: $Id$
// Copyright: (c) 2000 Johnny C. Norris II
// License: Rocketeer license
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_TOGGLEBUTTON_H_BASE_
#define _WX_TOGGLEBUTTON_H_BASE_
#include "wx/defs.h"
#if wxUSE_TOGGLEBTN
#include "wx/event.h"
#include "wx/control.h" // base class
BEGIN_DECLARE_EVENT_TYPES()
DECLARE_EVENT_TYPE(wxEVT_COMMAND_TOGGLEBUTTON_CLICKED, 19)
END_DECLARE_EVENT_TYPES()
#define EVT_TOGGLEBUTTON(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_COMMAND_TOGGLEBUTTON_CLICKED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL ),
#if defined(__WXMSW__)
#include "wx/msw/tglbtn.h"
#elif defined(__WXGTK__)
#include "wx/gtk/tglbtn.h"
/*
# elif defined(__WXMOTIF__)
# include "wx/motif/tglbtn.h"
# elif defined(__WXQT__)
# include "wx/qt/tglbtn.h"
# elif defined(__WXMAC__)
# include "wx/mac/tglbtn.h"
# elif defined(__WXPM__)
# include "wx/os2/tglbtn.h"
# elif defined(__WXSTUBS__)
# include "wx/stubs/tglbtn.h"
*/
#endif
#endif // wxUSE_TOGGLEBTN
#endif // _WX_TOGGLEBUTTON_H_BASE_

244
include/wx/timer.h Normal file
View File

@@ -0,0 +1,244 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/timer.h
// Purpose: wxTimer, wxStopWatch and global time-related functions
// Author: Julian Smart (wxTimer), Sylvain Bougnoux (wxStopWatch)
// Modified by: Vadim Zeitlin (wxTimerBase)
// Guillermo Rodriguez (global clean up)
// Created: 04/01/98
// RCS-ID: $Id$
// Copyright: (c) wxWindows team
// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_TIMER_H_BASE_
#define _WX_TIMER_H_BASE_
#ifdef __GNUG__
#pragma interface "timerbase.h"
#endif
#include "wx/setup.h"
#include "wx/object.h"
#include "wx/longlong.h"
#include "wx/event.h"
#if wxUSE_GUI && wxUSE_TIMER
// ----------------------------------------------------------------------------
// wxTimer
// ----------------------------------------------------------------------------
// the interface of wxTimer class
class WXDLLEXPORT wxTimerBase : public wxObject
{
public:
// ctors and initializers
// ----------------------
// default: if you don't call SetOwner(), your only chance to get timer
// notifications is to override Notify() in the derived class
wxTimerBase() { Init(); SetOwner(NULL); }
// ctor which allows to avoid having to override Notify() in the derived
// class: the owner will get timer notifications which can be handled with
// EVT_TIMER
wxTimerBase(wxEvtHandler *owner, int id = -1)
{ Init(); SetOwner(owner, id); }
// same as ctor above
void SetOwner(wxEvtHandler *owner, int id = -1)
{ m_owner = owner; m_idTimer = id; }
#ifdef __DARWIN__
virtual ~wxTimerBase() { }
#endif
// working with the timer
// ----------------------
// start the timer: if milliseconds == -1, use the same value as for the
// last Start()
//
// it is now valid to call Start() multiple times: this just restarts the
// timer if it is already running
virtual bool Start(int milliseconds = -1, bool oneShot = FALSE);
// stop the timer
virtual void Stop() = 0;
// override this in your wxTimer-derived class if you want to process timer
// messages in it, use non default ctor or SetOwner() otherwise
virtual void Notify();
// getting info
// ------------
// return TRUE if the timer is running
virtual bool IsRunning() const = 0;
// get the (last) timer interval in the milliseconds
int GetInterval() const { return m_milli; }
// return TRUE if the timer is one shot
bool IsOneShot() const { return m_oneShot; }
#if WXWIN_COMPATIBILITY_2
// deprecated functions
int Interval() const { return GetInterval(); };
bool OneShot() const { return IsOneShot(); }
#endif // WXWIN_COMPATIBILITY_2
protected:
// common part of all ctors
void Init() { m_oneShot = FALSE; m_milli = 0; }
wxEvtHandler *m_owner;
int m_idTimer;
int m_milli; // the timer interval
bool m_oneShot; // TRUE if one shot
};
// ----------------------------------------------------------------------------
// wxTimer itself
// ----------------------------------------------------------------------------
#if defined(__WXMSW__)
#include "wx/msw/timer.h"
#elif defined(__WXMOTIF__)
#include "wx/motif/timer.h"
#elif defined(__WXGTK__)
#include "wx/gtk/timer.h"
#elif defined(__WXMGL__)
#include "wx/mgl/timer.h"
#elif defined(__WXQT__)
#include "wx/qt/timer.h"
#elif defined(__WXMAC__)
#include "wx/mac/timer.h"
#elif defined(__WXPM__)
#include "wx/os2/timer.h"
#elif defined(__WXSTUBS__)
#include "wx/stubs/timer.h"
#endif
// ----------------------------------------------------------------------------
// wxTimerRunner: starts the timer in its ctor, stops in the dtor
// ----------------------------------------------------------------------------
class WXDLLEXPORT wxTimerRunner
{
public:
wxTimerRunner(wxTimer& timer) : m_timer(timer) { }
wxTimerRunner(wxTimer& timer, int milli, bool oneShot = FALSE)
: m_timer(timer)
{
m_timer.Start(milli, oneShot);
}
void Start(int milli, bool oneShot = FALSE)
{
m_timer.Start(milli, oneShot);
}
~wxTimerRunner()
{
if ( m_timer.IsRunning() )
{
m_timer.Stop();
}
}
private:
wxTimer& m_timer;
};
// ----------------------------------------------------------------------------
// wxTimerEvent
// ----------------------------------------------------------------------------
class WXDLLEXPORT wxTimerEvent : public wxEvent
{
public:
wxTimerEvent(int id = 0, int interval = 0) : wxEvent(id)
{
m_eventType = wxEVT_TIMER;
m_interval = interval;
}
// accessors
int GetInterval() const { return m_interval; }
private:
int m_interval;
DECLARE_DYNAMIC_CLASS(wxTimerEvent)
};
typedef void (wxEvtHandler::*wxTimerEventFunction)(wxTimerEvent&);
#define EVT_TIMER(id, func) \
DECLARE_EVENT_TABLE_ENTRY( wxEVT_TIMER, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTimerEventFunction) & func, NULL),
#endif // wxUSE_GUI && wxUSE_TIMER
// ----------------------------------------------------------------------------
// wxStopWatch: measure time intervals with up to 1ms resolution
// ----------------------------------------------------------------------------
#if wxUSE_STOPWATCH
class WXDLLEXPORT wxStopWatch
{
public:
// ctor starts the stop watch
wxStopWatch() { Start(); }
void Start(long t = 0);
void Pause() { m_pause = GetElapsedTime(); }
void Resume() { Start(m_pause); }
// get elapsed time since the last Start() or Pause() in milliseconds
long Time() const;
protected:
// returns the elapsed time since t0
long GetElapsedTime() const;
private:
wxLongLong m_t0; // the time of the last Start()
long m_pause; // the time of the last Pause() or 0
};
#endif // wxUSE_STOPWATCH
#if wxUSE_LONGLONG
// Starts a global timer
// -- DEPRECATED: use wxStopWatch instead
void WXDLLEXPORT wxStartTimer();
// Gets elapsed milliseconds since last wxStartTimer or wxGetElapsedTime
// -- DEPRECATED: use wxStopWatch instead
long WXDLLEXPORT wxGetElapsedTime(bool resetTimer = TRUE);
#endif // wxUSE_LONGLONG
// ----------------------------------------------------------------------------
// global time functions
// ----------------------------------------------------------------------------
// Get number of seconds since local time 00:00:00 Jan 1st 1970.
extern long WXDLLEXPORT wxGetLocalTime();
// Get number of seconds since GMT 00:00:00, Jan 1st 1970.
extern long WXDLLEXPORT wxGetUTCTime();
#if wxUSE_LONGLONG
// Get number of milliseconds since local time 00:00:00 Jan 1st 1970
extern wxLongLong WXDLLEXPORT wxGetLocalTimeMillis();
#endif // wxUSE_LONGLONG
#define wxGetCurrentTime() wxGetLocalTime()
#endif
// _WX_TIMER_H_BASE_

59
include/wx/toolbar.h Normal file
View File

@@ -0,0 +1,59 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/toolbar.h
// Purpose: wxToolBar interface declaration
// Author: Vadim Zeitlin
// Modified by:
// Created: 20.11.99
// RCS-ID: $Id$
// Copyright: (c) wxWindows team
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_TOOLBAR_H_BASE_
#define _WX_TOOLBAR_H_BASE_
#include "wx/tbarbase.h" // the base class for all toolbars
#if wxUSE_TOOLBAR
#if !wxUSE_TOOLBAR_NATIVE || defined(__WXUNIVERSAL__)
#include "wx/tbarsmpl.h"
class WXDLLEXPORT wxToolBar : public wxToolBarSimple
{
public:
wxToolBar() { }
wxToolBar(wxWindow *parent,
wxWindowID id,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxNO_BORDER | wxTB_HORIZONTAL,
const wxString& name = wxToolBarNameStr)
: wxToolBarSimple(parent, id, pos, size, style, name) { }
private:
DECLARE_DYNAMIC_CLASS(wxToolBar)
};
#else // wxUSE_TOOLBAR_NATIVE
#if defined(__WXMSW__) && defined(__WIN95__)
#include "wx/msw/tbar95.h"
#elif defined(__WXMSW__)
#include "wx/msw/tbarmsw.h"
#elif defined(__WXMOTIF__)
#include "wx/motif/toolbar.h"
#elif defined(__WXGTK__)
#include "wx/gtk/tbargtk.h"
#elif defined(__WXQT__)
#include "wx/qt/tbarqt.h"
#elif defined(__WXMAC__)
#include "wx/mac/toolbar.h"
#elif defined(__WXPM__)
#include "wx/os2/toolbar.h"
#elif defined(__WXSTUBS__)
#include "wx/stubs/toolbar.h"
#endif
#endif // !wxUSE_TOOLBAR_NATIVE/wxUSE_TOOLBAR_NATIVE
#endif // wxUSE_TOOLBAR
#endif
// _WX_TOOLBAR_H_BASE_

21
include/wx/tooltip.h Normal file
View File

@@ -0,0 +1,21 @@
#ifndef _WX_TOOLTIP_H_BASE_
#define _WX_TOOLTIP_H_BASE_
#if defined(__WXMSW__)
#include "wx/msw/tooltip.h"
#elif defined(__WXMOTIF__)
// #include "wx/motif/tooltip.h"
#elif defined(__WXGTK__)
#include "wx/gtk/tooltip.h"
#elif defined(__WXQT__)
#include "wx/qt/tooltip.h"
#elif defined(__WXMAC__)
#include "wx/mac/tooltip.h"
#elif defined(__WXPM__)
#include "wx/os2/tooltip.h"
#elif defined(__WXSTUBS__)
// #include "wx/stubs/tooltip.h"
#endif
#endif
// _WX_TOOLTIP_H_BASE_

40
include/wx/treectrl.h Normal file
View File

@@ -0,0 +1,40 @@
#ifndef _WX_TREECTRL_H_BASE_
#define _WX_TREECTRL_H_BASE_
#include "wx/treebase.h"
// ----------------------------------------------------------------------------
// include the platform-dependent wxTreeCtrl class
// ----------------------------------------------------------------------------
#if defined(__WXUNIVERSAL__)
#include "wx/generic/treectlg.h"
#elif defined(__WXMSW__)
#ifdef __WIN16__
#include "wx/generic/treectlg.h"
#else
#include "wx/msw/treectrl.h"
#endif
#elif defined(__WXMOTIF__)
#include "wx/generic/treectlg.h"
#elif defined(__WXGTK__)
#include "wx/generic/treectlg.h"
#elif defined(__WXQT__)
#include "wx/qt/treectrl.h"
#elif defined(__WXMAC__)
#include "wx/generic/treectlg.h"
#elif defined(__WXPM__)
#include "wx/generic/treectlg.h"
#elif defined(__WXSTUBS__)
#include "wx/generic/treectlg.h"
#endif
/*
#if !defined(__WXMSW__)
#define wxTreeCtrl wxGenericTreeCtrl
#define sm_classwxTreeCtrl sm_classwxGenericTreeCtrl
#endif
*/
#endif // _WX_TREECTRL_H_BASE_

19
include/wx/wave.h Normal file
View File

@@ -0,0 +1,19 @@
#ifndef _WX_WAVE_H_BASE_
#define _WX_WAVE_H_BASE_
#if defined(__WXMSW__)
#include "wx/msw/wave.h"
#elif defined(__WXGTK__)
#include "wx/gtk/wave.h"
#elif defined(__WXQT__)
#include "wx/qt/wave.h"
#elif defined(__WXMAC__)
#include "wx/mac/wave.h"
#elif defined(__WXPM__)
#include "wx/os2/wave.h"
#elif defined(__WXMAC__)
#include "wx/mac/wave.h"
#endif
#endif
// _WX_TREECTRL_H_BASE_

1080
include/wx/window.h Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -1,594 +0,0 @@
0.9.2 (5/3/2003 to //2003)
-----------------------------
Changed to the new prefix-less "wx" package::
import wx
instead of::
from wxPython import wx
Fixed typo in ``PyWrap.py``::
if __name__ == '__main__':
main(sys.argv)
should have been::
if __name__ == '__main__':
main()
Added pretty-print Display tab to Crust, based on suggestion from
Jason Whitlark.
Improved ``Can*`` checks in ``EditWindow``, since STC is too lenient,
particularly when it is set to read-only but returns True for
CanPaste() (seems like an STC bug to me)::
def CanCopy(self):
"""Return True if text is selected and can be copied."""
return self.GetSelectionStart() != self.GetSelectionEnd()
def CanCut(self):
"""Return True if text is selected and can be cut."""
return self.CanCopy() and self.CanEdit()
def CanEdit(self):
"""Return True if editing should succeed."""
return not self.GetReadOnly()
def CanPaste(self):
"""Return True if pasting should succeed."""
return stc.StyledTextCtrl.CanPaste(self) and self.CanEdit()
0.9.1 (3/21/2003 to 5/2/2003)
-----------------------------
PyCrust is dead! Long live Py!
* Renamed ``PyCrust`` package to ``py``.
* Moved code to wxPython's CVS repository.
Fixed bug in ``introspect.py`` on introspecting objects occurring
immediately after a secondary prompt, like this::
>>> l = [1, 2, 3]
>>> for n in range(3):
... l. <-- failed to popup autocomplete list
Added documentation files:
* PyManual.txt
* wxPythonManual.txt
* wxPythonPackage.txt
* wxPythonExamples.txt
Added PyAlaMode and PyAlaCarte code editors.
Major refactoring to support ``editor`` and ``shell`` from the same
base.
Renamed program files:
* ``PyCrustApp.py`` to ``PyCrust.py``
* ``PyFillingApp.py`` to ``PyFilling.py``
* ``PyShellApp.py`` to ``PyShell.py``
* ``wrap.py`` to ``PyWrap.py``
Removed disabling of autocomplete for lists of 2000 items or more.
The current implementation of wxSTC can now handle lists this big.
Improved handling of ``sys.path`` to mimic the standard Python shell.
0.9 (2/27/2003 to 3/20/2003)
----------------------------
Added fontIncrease, fontDecrease, fontDefault signals, receivers and
keybindings::
Ctrl+] Increase font size.
Ctrl+[ Decrease font size.
Ctrl+= Default font size.
Continued enhancement of the decorator capability to provide better
documentation and docstrings for wxPython classes and functions.
Introduced new tabbed interface:
* Namespace
* Calltip
* Session
* Dispatcher
* wxPython Docs
* wxSTC Docs
``Filling.tree`` now expands tuples as well as lists. (It should have
done this all along, I just never noticed this omission before.)
Added this True/False test to all modules::
try:
True
except NameError:
True = 1==1
False = 1==0
Added ``wxd`` directory with decoration classes.
0.8.2 (1/5/2003 to 2/26/2003)
-----------------------------
Wrapped ``sys.ps1``, ``sys.ps2``, and ``sys.ps3`` in ``str()``.
(Thanks, Kieran Holland.)
Fixed minor things found by PyChecker.
Changed locals to use ``__main__.__dict__`` and added code to clean up
the namespace, making it as close to the regular Python environment as
possible. This solves the problem of pickling and unpickling
instances of classes defined in the shell.
Made ``shell.PasteAndRun()`` a little more forgiving when it finds a
ps2 prompt line with no trailing space, such when you copy code from a
web page.
Improved autocomplete behavior by adding these to shell::
self.AutoCompSetAutoHide(False)
self.AutoCompStops(' .,;:([)]}\'"\\<>%^&+-=*/|`')
Added ``decor`` directory, ``decorator.py``, ``stcDecor.py``, and
``stcConstants.py``. These all serve the purpose of adding docstrings
to existing wxPython classes, in particular the ``wxStyledTextCtrl``.
Added ``wrap.py``, a command line utility for running a wxPython app
with additional runtime-tools loaded, such as PyCrust (the only tool
at this point).
Flushed the clipboard Cut/Copy operations so that selections will
exist in the clipboard even after PyCrust has been closed.
Improved the suppression of docstrings for simple data types appearing
in the namespace viewer.
Better handling of autocompletion with numeric types; no
autocompletion when typing a dot after an integer. If the
autocompletion is desired, type a space before the dot::
func = 3 .
More Filling!!! The namespace tree is now dynamically updated.
0.8.1 (12/20/2002 to 12/25/2002)
--------------------------------
Improved keyboard handling with Autocomplete active. You can now use
Enter as well as Tab to select an item from the list.
Disabled autocomplete for lists of 2000 items or more. The current
implementation of wxSTC can't handle lists this big.
Changed ``filling`` to always display docstrings for objects. This is
useful for objects whose docstrings have been decorated, rather than
coming directly from the source code. (Hmmm. Sounds like someone is
doing some decorating. I wonder where that would be helpful? <wink>)
Fixed handling of icon. Added ``images.py`` file.
0.8 (10/29/2002 to 12/16/2002)
------------------------------
Added "help" to startup banner info.
Made all ``wx`` and ``stc`` imports explicit. No more ``import *``.
Replaced use of the ``wx`` module's ``true`` and ``false`` with
Python's ``True`` and ``False``.
Changed ``introspect.getRoot()`` to use ``tokenize`` module. This
does a slightly better job than the previous parsing routine and the
code is clearer.
Improved handling of whitespace and empty types during introspection.
Fixed cut/copy clipboard problem under Linux. (Robin Dunn rocks!!!)
Added shell.about() which works like this::
>>> shell.about()
PyCrust Version: 0.8
Shell Revision: 1.80
Interpreter Revision: 1.15
Python Version: 2.2.2
wxPython Version: 2.3.3.1
Platform: linux2
Added copy plus and paste plus to shell menu.
Moved shell menu from ``shell.py`` to ``shellmenu.py``.
Added ``sys.stdin.readlines()`` support.
Added ``time.sleep()`` in ``readline()`` and ``OnIdle()`` event
handler to free up the CPU.
0.7.2 (2/22/2002 to 8/27/2002)
------------------------------
Tweaked ``getAttributeNames()`` to pick up a few more attributes::
'__bases__', '__class__', '__dict__', '__name__', 'func_closure',
'func_code', 'func_defaults', 'func_dict', 'func_doc',
'func_globals', 'func_name'
Added a tests directory and unit tests.
Improved support for empty types in the shell: ``[]``, ``()`` and
``{}`` as far as when call tips and autocompletion are available.
Added support for the other triple string - ``''''''``.
Refactored ``introspect.py`` to improve testability.
Improved call tips for unbound methods by leaving the "self"
parameter, since unbound methods require an instance be passed.
Fixed call tip bug where a tip was displayed when a "(" was typed
after an object that wasn't callable.
Fixed ``getAllAttributeNames`` when ``str(object)`` fails.
Added brace highlighting. (Thank you, Kevin Altis.)
Fixed problem displaying unicode objects in ``PyFilling``.
Changed how ``filling.py`` checks for expandable objects. Lists are
now expandable objects.
Made the key handling more robust when there is an active text
selection that includes text prior to the last primary prompt. Thanks
to Raul Cota for pointing this out.
Fixed wxSTC problem with brace highlighting and non-us keyboards.
(Thank you for the patch, Jean-Michel Fauth.)
Added ``busy = wxBusyCursor()`` to key points in ``shell`` and
``filling``.
Added ``OnCloseWindow`` handler to ``ShellFrame`` and ``CrustFrame``.
Default to ``SetWrapMode(1)`` for shell and namespace viewer.
Added ``shell.wrap()`` and ``shell.zoom()``.
Added autoCompleteKeys hooks for Raul Cota.
Cleaned up various little key handling bugs.
Changed input methods to get values from shell, rather than dialog
boxes. Renamed ``readIn`` to ``readline`` and ``readRaw`` to
``raw_input``.
0.7.1 (12/12/2001 to 2/21/2002)
-------------------------------
Fixed ``OnChar()`` issues effecting European keyboards, as reported by
Jean-Michel Fauth.
Fixed ``introspect.py`` issue with xmlrpc objects reported by Kevin
Altis.
Fixed some introspect/PyFilling issues with regard to Python 2.2.
Fixed font background color as reported by Keith J. Farmer. (Thanks)
Fixed problem with call tips and autocompletion inside multiline
commands as report by Kevin Altis.
Improved ``OnKeyDown`` handling of cut/copy/paste operations based on
feedback from Syver Enstad. (Thanks)
Added a ``shell.help()`` method to display some help info.
Changed sort of items in the namespace viewer to case insensitive.
Changed ``attributes.sort(lambda x, y: cmp(x.upper(), y.upper()))`` in
advance of an upcoming fix to an autocompletion matching bug in wxSTC.
Improved support for ZODB by allowing namespace drilldown into BTrees.
Added ``shell.PasteAndRun()`` to support pasting multiple commands into
the shell from the clipboard. Ctrl+Shift+V or v.
Enter now always processes a command (or copies down a previous one.)
To insert a line break, press Ctrl+Enter.
Escape key clears the current, unexecuted command.
History retrieval changed to replace current command. Added new keys
to insert from history - Shift+Up and Shift+Down.
Better call tips on objects with ``__call__`` methods.
Improved call tip positioning calculation.
0.7 (10/15/2001 to 12/11/2001)
------------------------------
Changed how command history retrieval functions work. Added Alt-P,
Alt-N as keybindings for Retrieve-Previous, Retrieve-Next.
Added full support for multi-line commands, similar to IDLE.
Changed ``introspect.getAttributeNames()`` to do a case insensitive
sort.
Changed Cut/Copy/Paste to deal with prompts intelligently. Cut and
Copy remove all prompts. Paste can handle prompted or not-prompted
text.
Added ``CopyWithPrompts()`` method attached to Ctrl-Shift-C for those
times when you really do want all the prompts left intact.
Improved handling of the shell's read-only zone.
Changed ``CrustFrame.__init__`` parameter spec to include all
parameters allowed by a ``wxFrame``.
Changed ``FillingText`` to be read-only.
Renamed ``PyCrust.py`` to ``PyCrustApp.py`` to eliminate
package/module name conflicts that kept you from doing ``from PyCrust
import shell`` inside files located in the ``PyCrust`` directory.
Renamed ``PyFilling.py`` to ``PyFillingApp.py`` and ``PyShell.py`` to
``PyShellApp.py`` to maintain consistency.
Removed the ``__date__`` property from all modules.
Fixed bug in ``introspect.getCallTip()``, reported by Kevin Altis.
0.6.1 (9/19/2001 to 10/12/2001)
-------------------------------
Changed ``Shell.run()`` to always position to the end of existing
text, as suggested by Raul Cota.
Changed ``introspect.getAllAttributeNames()`` to break circular
references in ``object.__class__``, which occurs in Zope/ZODB
extension classes.
Changed ``filling.FillingTree.getChildren()`` to introspect extension
classes.
Fixed minor bugs in ``introspect.getCallTip()`` that were interfering
with call tips for Zope/ZODB extension class methods.
In preparation for wxPython 2.3.2, added code to fix a font sizing
problem. Versions of wxPython prior to 2.3.2 had a sizing bug on Win
platform where the font was 2 points larger than what was specified.
Added a hack to ``introspect.getAllAttributeNames()`` to "wake up"
ZODB objects that are asleep - in a "ghost" state. Otherwise it
returns incomplete info.
0.6 (8/21/2001 to 9/12/2001)
----------------------------
Added ``PyFilling.py`` and ``filling.py``.
``PyShell.py`` and ``PyFilling.py`` can now be run standalone, as well
as ``PyCrust.py``.
Added ``crust.py`` and moved some code from ``PyCrust.py`` to it.
Added command history retrieval features submitted by Richie Hindle.
Changed ``shell.write()`` to replace line endings with OS-specific
endings. Changed ``shell.py`` and ``interpreter.py`` to use
``os.linesep`` in strings having hardcoded line endings.
Added ``shell.redirectStdin()``, ``shell.redirectStdout()`` and
``shell.redirectStderr()`` to allow the surrounding app to toggle
requests that the specified ``sys.std*`` be redirected to the shell.
These can also be run from within the shell itself, of course.
The shell now adds the current working directory "." to the search
path::
sys.path.insert(0, os.curdir)
Added support for distutils installations.
0.5.4 (8/17/2001 to 8/20/2001)
------------------------------
Changed default font size under Linux to::
'size' : 12,
'lnsize' : 10,
Changed ``Shell`` to expect a parameter referencing an Interpreter
class, rather than an intepreter instance, to facilitate subclassing
of Interpreter, which effectively broke when the Editor class was
eliminated.
Fixed ``PyCrustAlaCarte.py``, which had been broken by previous
changes.
Created ``InterpreterAlaCarte`` class as an example for use in the
demo.
Split ``PyCrust.py`` into ``PyCrust.py`` and ``PyShell.py`` in
anticipation of ``PyFilling.py``.
0.5.3 (8/16/2001)
-----------------
Added patch to ``PyCrust.py`` to fix wxPython bug::
wxID_SELECTALL = NewId() # This *should* be defined by wxPython.
0.5.2 (8/14/2001 to 8/15/2001)
------------------------------
Shortened module names by dropping "PyCrust" as a prefix.
Changed ``version`` to ``VERSION`` in ``version`` module.
Added Options menu to PyCrust application.
Eliminated the Editor class (and editor module) by merging with Shell.
This means that Shell "is a" wxStyledTextCtrl rather than "has a".
There just wasn't enough non-gui code to justify the separation.
Plus, Shell will be much easier for gui toolkits/designers to deal
with now.
0.5.1 (8/10/2001 to 8/14/2001)
------------------------------
Added ``introspect`` module.
Moved some functionality from ``PyCrustInterp`` to ``introspect``.
Changed ``introspect.getRoot()`` to no longer remove whitespace from
the command. This was a remnant of a previous approach that, when
left as part of the current approach, turned out to be a really bad
thing.
Changed ``introspect.getRoot()`` to allow commands of ``''``, ``""``,
``""""""``, ``[]``, ``()``, and ``{}`` to pass through. This allows
you to type them, followed by a dot, and get autocomplete options on
them.
Changed ``introspect.getRoot()`` to identify some situations where
strings shouldn't be considered roots. For example::
>>> import PyCrust # To illustrate the potential problem.
>>> len('PyCrust.py')
Typing the dot at the end of "PyCrust" in the second line above should
NOT result in an autocompletion list because "PyCrust" is part of a
string in this context, not a reference to the PyCrust module object.
Similar reasoning applies to call tips. For example::
>>> len('dir(')
Typing the left paren at the end of "dir" should NOT result in a call
tip.
Both features now behave properly in the examples given. However,
there is still the case where whitespace precedes the potential root
and that is NOT handled properly. For example::
>>> len('this is a dir(')
and::
>>> len('This is PyCrust.py')
More code needs to be written to handle more complex situations.
Added ``locals=None`` parameter to ``Shell.__init__()``.
Added support for magic attribute retrieval. Users can change this
with::
>>> shell.editor.autoCompleteIncludeMagic = 0
Added the ability to set filters on auto completion to exclude
attributes prefixed with a single or double underscore. Users can
exclude one or the other or both with::
>>> shell.editor.autoCompleteExcludeSingle = 1
>>> shell.editor.autoCompleteExcludeDouble = 1
0.5 (8/8/2001)
--------------
Mostly just a final version change before creating a release.
0.4 (8/4/2001 to 8/7/2001)
--------------------------
Changed version/revision handling.
Fixed bugs.
0.3 (8/2/2001 to 8/3/2001)
--------------------------
Removed lots of cruft.
Added lots of docstrings.
Imported to CVS repository at SourceForge.
Added call tips.
0.2 (7/30/2001 to 8/2/2001)
---------------------------
Renamed several files.
Added command autocompletion.
Added menus to PyCrust.py: File, Edit and Help.
Added sample applications: ``PyCrustAlaCarte.py``,
``PyCrustAlaMode.py``, and ``PyCrustMinimus.py``.
0.1 (7/1/2001 to 7/19/2001)
---------------------------
Added basic syntax coloring much like Boa.
Added read-only logging much like IDLE.
Can retrieve a previous command by putting the cursor back on that
line and hitting enter.
Stdin and raw_input operate properly so you can now do ``help()`` and
``license()`` without hanging.
Redefined "quit", "exit", and "close" to display a better-than-nothing
response.
Home key honors the prompt.
Created SourceForge account, but nothing was posted.
In the beginning, there was pie... (7/1/2001)
---------------------------------------------
Blame it all on IDLE, Boa and PythonWin. I was using all three, got
frustrated with their dissimilarities, and began to let everyone know
how I felt. At the same time, Scintilla looked like an interesting
tool to build a shell around. And while I didn't receive much in the
way of positive feedback, let alone encouragement, I just couldn't let
go of the idea of a Scintilla-based Python shell. Then the PythonCard
project got to the point where they were talking about including a
shell in their development environment. That was all the incentive I
needed. PyCrust had to happen...

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.6 KiB

View File

@@ -1,43 +0,0 @@
"""PyAlaCarte is a simple programmer's editor."""
__author__ = "Patrick K. O'Brien <pobrien@orbtech.com>"
__cvsid__ = "$Id$"
__revision__ = "$Revision$"[11:-2]
import wx
import os
import sys
import editor
try:
True
except NameError:
True = 1==1
False = 1==0
class App(wx.App):
"""PyAlaCarte standalone application."""
def __init__(self, filename=None):
self.filename = filename
wx.App.__init__(self, redirect=False)
def OnInit(self):
wx.InitAllImageHandlers()
self.frame = editor.EditorFrame(filename=self.filename)
self.frame.Show()
self.SetTopWindow(self.frame)
return True
def main(filename=None):
if not filename and len(sys.argv) > 1:
filename = sys.argv[1]
if filename:
filename = os.path.realpath(filename)
app = App(filename)
app.MainLoop()
if __name__ == '__main__':
main()

View File

@@ -1,43 +0,0 @@
"""PyAlaMode is a programmer's editor."""
__author__ = "Patrick K. O'Brien <pobrien@orbtech.com>"
__cvsid__ = "$Id$"
__revision__ = "$Revision$"[11:-2]
import wx
import os
import sys
import editor
try:
True
except NameError:
True = 1==1
False = 1==0
class App(wx.App):
"""PyAlaMode standalone application."""
def __init__(self, filename=None):
self.filename = filename
wx.App.__init__(self, redirect=False)
def OnInit(self):
wx.InitAllImageHandlers()
self.frame = editor.EditorNotebookFrame(filename=self.filename)
self.frame.Show()
self.SetTopWindow(self.frame)
return True
def main(filename=None):
if not filename and len(sys.argv) > 1:
filename = sys.argv[1]
if filename:
filename = os.path.realpath(filename)
app = App(filename)
app.MainLoop()
if __name__ == '__main__':
main()

View File

@@ -1,42 +0,0 @@
"""PyAlaModeTest is a programmer's editor."""
__author__ = "Patrick K. O'Brien <pobrien@orbtech.com>"
__cvsid__ = "$Id$"
__revision__ = "$Revision$"[11:-2]
import wx
import os
import sys
import editor
try:
True
except NameError:
True = 1==1
False = 1==0
class App(wx.App):
"""PyAlaModeTest standalone application."""
def __init__(self, filename=None):
self.filename = filename
wx.App.__init__(self, redirect=False)
def OnInit(self):
wx.InitAllImageHandlers()
self.frame = editor.EditorShellNotebookFrame(filename=self.filename)
self.frame.Show()
self.SetTopWindow(self.frame)
return True
def main(filename=None):
app = App(filename)
app.MainLoop()
if __name__ == '__main__':
filename = None
if len(sys.argv) > 1:
filename = os.path.realpath(sys.argv[1])
main(filename)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.6 KiB

View File

@@ -1,78 +0,0 @@
"""PyCrust is a python shell and namespace browser application."""
# The next two lines, and the other code below that makes use of
# ``__main__`` and ``original``, serve the purpose of cleaning up the
# main namespace to look as much as possible like the regular Python
# shell environment.
import __main__
original = __main__.__dict__.keys()
__author__ = "Patrick K. O'Brien <pobrien@orbtech.com>"
__cvsid__ = "$Id$"
__revision__ = "$Revision$"[11:-2]
import wx
try:
True
except NameError:
True = 1==1
False = 1==0
class App(wx.App):
"""PyCrust standalone application."""
def OnInit(self):
import wx
wx.InitAllImageHandlers()
locals = __main__.__dict__
from crust import CrustFrame
self.frame = CrustFrame(locals=locals)
self.frame.SetSize((800, 600))
self.frame.Show()
self.SetTopWindow(self.frame)
return True
'''
The main() function needs to handle being imported, such as with the
pycrust script that wxPython installs:
#!/usr/bin/env python
from wx.py.PyCrust import main
main()
'''
def main():
"""The main function for the PyCrust program."""
# Cleanup the main namespace, leaving the App class.
import __main__
md = __main__.__dict__
keepers = original
keepers.append('App')
for key in md.keys():
if key not in keepers:
del md[key]
# Create an application instance.
app = App(0)
# Mimic the contents of the standard Python shell's sys.path.
import sys
if sys.path[0]:
sys.path[0] = ''
# Add the application object to the sys module's namespace.
# This allows a shell user to do:
# >>> import sys
# >>> sys.app.whatever
sys.app = app
del sys
# Cleanup the main namespace some more.
if md.has_key('App') and md['App'] is App:
del md['App']
if md.has_key('__main__') and md['__main__'] is __main__:
del md['__main__']
# Start the wxPython event loop.
app.MainLoop()
if __name__ == '__main__':
main()

Binary file not shown.

Before

Width:  |  Height:  |  Size: 706 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

View File

@@ -1,43 +0,0 @@
"""PyFilling is a python namespace inspection application."""
__author__ = "Patrick K. O'Brien <pobrien@orbtech.com>"
__cvsid__ = "$Id$"
__revision__ = "$Revision$"[11:-2]
# We use this object to get more introspection when run standalone.
app = None
import filling
# These are imported just to have something interesting to inspect.
import crust
import interpreter
import introspect
import pseudo
import shell
import sys
import wx
try:
True
except NameError:
True = 1==1
False = 1==0
class App(filling.App):
def OnInit(self):
filling.App.OnInit(self)
self.root = self.fillingFrame.filling.tree.root
return True
def main():
"""Create and run the application."""
global app
app = App(0)
app.fillingFrame.filling.tree.Expand(app.root)
app.MainLoop()
if __name__ == '__main__':
main()

View File

@@ -1,79 +0,0 @@
"""PyShell is a python shell application."""
# The next two lines, and the other code below that makes use of
# ``__main__`` and ``original``, serve the purpose of cleaning up the
# main namespace to look as much as possible like the regular Python
# shell environment.
import __main__
original = __main__.__dict__.keys()
__author__ = "Patrick K. O'Brien <pobrien@orbtech.com>"
__cvsid__ = "$Id$"
__revision__ = "$Revision$"[11:-2]
import wx
try:
True
except NameError:
True = 1==1
False = 1==0
class App(wx.App):
"""PyShell standalone application."""
def OnInit(self):
import wx
wx.InitAllImageHandlers()
locals = __main__.__dict__
from shell import ShellFrame
self.frame = ShellFrame(locals=locals)
self.frame.SetSize((750, 525))
self.frame.Show()
self.SetTopWindow(self.frame)
self.frame.shell.SetFocus()
return True
'''
The main() function needs to handle being imported, such as with the
pyshell script that wxPython installs:
#!/usr/bin/env python
from wx.py.PyShell import main
main()
'''
def main():
"""The main function for the PyShell program."""
# Cleanup the main namespace, leaving the App class.
import __main__
md = __main__.__dict__
keepers = original
keepers.append('App')
for key in md.keys():
if key not in keepers:
del md[key]
# Create an application instance.
app = App(0)
# Cleanup the main namespace some more.
if md.has_key('App') and md['App'] is App:
del md['App']
if md.has_key('__main__') and md['__main__'] is __main__:
del md['__main__']
# Mimic the contents of the standard Python shell's sys.path.
import sys
if sys.path[0]:
sys.path[0] = ''
# Add the application object to the sys module's namespace.
# This allows a shell user to do:
# >>> import sys
# >>> sys.app.whatever
sys.app = app
del sys
# Start the wxPython event loop.
app.MainLoop()
if __name__ == '__main__':
main()

View File

@@ -1,56 +0,0 @@
"""PyWrap is a command line utility that runs a wxPython program with
additional runtime-tools, such as PyCrust."""
__author__ = "Patrick K. O'Brien <pobrien@orbtech.com>"
__cvsid__ = "$Id$"
__revision__ = "$Revision$"[11:-2]
import os
import sys
import wx
from crust import CrustFrame as Frame
try:
True
except NameError:
True = 1==1
False = 1==0
def wrap(app):
wx.InitAllImageHandlers()
frame = Frame()
frame.SetSize((750, 525))
frame.Show(True)
frame.shell.interp.locals['app'] = app
app.MainLoop()
def main(modulename=None):
sys.path.insert(0, os.curdir)
if not modulename:
if len(sys.argv) < 2:
print "Please specify a module name."
raise SystemExit
modulename = sys.argv[1]
if modulename.endswith('.py'):
modulename = modulename[:-3]
module = __import__(modulename)
# Find the App class.
App = None
d = module.__dict__
for item in d.keys():
try:
if issubclass(d[item], wx.App):
App = d[item]
except (NameError, TypeError):
pass
if App is None:
print "No App class found."
raise SystemExit
app = App()
wrap(app)
if __name__ == '__main__':
main()

View File

@@ -1,79 +0,0 @@
=====================================
PyCrust - The Flakiest Python Shell
=====================================
Half-baked by Patrick K. O'Brien (pobrien@orbtech.com)
Orbtech - "Your source for Python programming expertise."
Sample all our half-baked Python goods at www.orbtech.com.
What is PyCrust?
----------------
PyCrust is an interactive Python environment written in Python.
PyCrust components can run standalone or be integrated into other
development environments and/or other Python applications.
PyCrust comes with an interactive Python shell (PyShell), an
interactive namespace/object tree control (PyFilling) and an
integrated, split-window combination of the two (PyCrust).
What is PyCrust good for?
-------------------------
Have you ever tried to bake a pie without one? Well, you shouldn't
build a Python program without a PyCrust either.
What else do I need to use PyCrust?
-----------------------------------
PyCrust requires Python 2.1.3 or later, and wxPython 2.4 or later.
PyCrust uses wxPython and the Scintilla wrapper (wxStyledTextCtrl).
Python is available at http://www.python.org/. wxPython is available
at http://www.wxpython.org/.
Where can I get the latest version of PyCrust?
----------------------------------------------
The latest production version ships with wxPython. The latest
developer version is available in CVS at:
http://sourceforge.net/cvs/?group_id=31263
Where is the PyCrust project hosted?
------------------------------------
At SourceForge, of course. The SourceForge summary page:
http://sourceforge.net/projects/pycrust/
I found a bug in PyCrust, what do I do with it?
-----------------------------------------------
You can send it to me at pobrien@orbtech.com.
I want a new feature added to PyCrust. Will you do it?
------------------------------------------------------
Flattery and money will get you anything. Short of that, you can send
me a request and I'll see what I can do.
Does PyCrust have a mailing list full of wonderful people?
----------------------------------------------------------
As a matter of fact, we do. Join the PyCrust mailing lists at:
http://sourceforge.net/mail/?group_id=31263
What is the CVS information for this README file?
-------------------------------------------------
$Date$
$Revision$
$Id$

View File

@@ -1,20 +0,0 @@
"""The py package, formerly the PyCrust package."""
__author__ = "Patrick K. O'Brien <pobrien@orbtech.com>"
__cvsid__ = "$Id$"
__revision__ = "$Revision$"[11:-2]
import buffer
import crust
import dispatcher
import document
import editor
import editwindow
import filling
import frame
import images
import interpreter
import introspect
import pseudo
import shell
import version

View File

@@ -1,144 +0,0 @@
"""Buffer class."""
__author__ = "Patrick K. O'Brien <pobrien@orbtech.com>"
__cvsid__ = "$Id$"
__revision__ = "$Revision$"[11:-2]
from interpreter import Interpreter
import imp
import os
import sys
import document
try:
True
except NameError:
True = 1==1
False = 1==0
class Buffer:
"""Buffer class."""
id = 0
def __init__(self, filename=None):
"""Create a Buffer instance."""
Buffer.id += 1
self.id = Buffer.id
self.interp = Interpreter(locals={})
self.name = ''
self.editors = {}
self.editor = None
self.modules = sys.modules.keys()
self.syspath = sys.path[:]
while True:
try:
self.syspath.remove('')
except ValueError:
break
while True:
try:
self.syspath.remove('.')
except ValueError:
break
self.open(filename)
def addEditor(self, editor):
"""Add an editor."""
self.editor = editor
self.editors[editor.id] = editor
def hasChanged(self):
"""Return True if text in editor has changed since last save."""
if self.editor:
return self.editor.hasChanged()
else:
return False
def new(self, filepath):
"""New empty buffer."""
if not filepath:
return
if os.path.exists(filepath):
self.confirmed = self.overwriteConfirm(filepath)
else:
self.confirmed = True
def open(self, filename):
"""Open file into buffer."""
self.doc = document.Document(filename)
self.name = self.doc.filename or ('Untitled:' + str(self.id))
self.modulename = self.doc.filebase
# XXX This should really make sure filedir is first item in syspath.
# XXX Or maybe this should be moved to the update namespace method.
if self.doc.filedir and self.doc.filedir not in self.syspath:
# To create the proper context for updateNamespace.
self.syspath.insert(0, self.doc.filedir)
if self.doc.filepath and os.path.exists(self.doc.filepath):
self.confirmed = True
if self.editor:
text = self.doc.read()
self.editor._setBuffer(buffer=self, text=text)
def overwriteConfirm(filepath):
"""Confirm overwriting an existing file."""
return False
def save(self):
"""Save buffer."""
filepath = self.doc.filepath
if not filepath:
return # XXX Get filename
if not os.path.exists(filepath):
self.confirmed = True
if not self.confirmed:
self.confirmed = self.overwriteConfirm(filepath)
if self.confirmed:
self.doc.write(self.editor.getText())
if self.editor:
self.editor.setSavePoint()
def saveAs(self, filename):
"""Save buffer."""
self.doc = document.Document(filename)
self.name = self.doc.filename
self.modulename = self.doc.filebase
self.save()
def updateNamespace(self):
"""Update the namespace for autocompletion and calltips.
Return True if updated, False if there was an error."""
if not self.interp or not hasattr(self.editor, 'getText'):
return False
syspath = sys.path
sys.path = self.syspath
text = self.editor.getText()
text = text.replace('\r\n', '\n')
text = text.replace('\r', '\n')
name = self.modulename or self.name
module = imp.new_module(name)
newspace = module.__dict__.copy()
try:
try:
code = compile(text, name, 'exec')
except:
raise
# return False
try:
exec code in newspace
except:
raise
# return False
else:
# No problems, so update the namespace.
self.interp.locals.clear()
self.interp.locals.update(newspace)
return True
finally:
sys.path = syspath
for m in sys.modules.keys():
if m not in self.modules:
del sys.modules[m]

View File

@@ -1,221 +0,0 @@
"""Crust combines the shell and filling into one control."""
__author__ = "Patrick K. O'Brien <pobrien@orbtech.com>"
__cvsid__ = "$Id$"
__revision__ = "$Revision$"[11:-2]
import wx
import os
import pprint
import sys
import dispatcher
import editwindow
from filling import Filling
import frame
from shell import Shell
from version import VERSION
try:
True
except NameError:
True = 1==1
False = 1==0
class Crust(wx.SplitterWindow):
"""Crust based on SplitterWindow."""
name = 'Crust'
revision = __revision__
def __init__(self, parent, id=-1, pos=wx.DefaultPosition,
size=wx.DefaultSize, style=wx.SP_3D,
name='Crust Window', rootObject=None, rootLabel=None,
rootIsNamespace=True, intro='', locals=None,
InterpClass=None, *args, **kwds):
"""Create Crust instance."""
wx.SplitterWindow.__init__(self, parent, id, pos, size, style, name)
self.shell = Shell(parent=self, introText=intro,
locals=locals, InterpClass=InterpClass,
*args, **kwds)
self.editor = self.shell
if rootObject is None:
rootObject = self.shell.interp.locals
self.notebook = wx.Notebook(parent=self, id=-1)
self.shell.interp.locals['notebook'] = self.notebook
self.filling = Filling(parent=self.notebook,
rootObject=rootObject,
rootLabel=rootLabel,
rootIsNamespace=rootIsNamespace)
# Add 'filling' to the interpreter's locals.
self.shell.interp.locals['filling'] = self.filling
self.notebook.AddPage(page=self.filling, text='Namespace', select=True)
self.display = Display(parent=self.notebook)
self.notebook.AddPage(page=self.display, text='Display')
# Add 'pp' (pretty print) to the interpreter's locals.
self.shell.interp.locals['pp'] = self.display.setItem
self.calltip = Calltip(parent=self.notebook)
self.notebook.AddPage(page=self.calltip, text='Calltip')
self.sessionlisting = SessionListing(parent=self.notebook)
self.notebook.AddPage(page=self.sessionlisting, text='Session')
self.dispatcherlisting = DispatcherListing(parent=self.notebook)
self.notebook.AddPage(page=self.dispatcherlisting, text='Dispatcher')
from wxd import wx_
self.wxdocs = Filling(parent=self.notebook,
rootObject=wx_,
rootLabel='wx',
rootIsNamespace=False,
static=True)
self.notebook.AddPage(page=self.wxdocs, text='wxPython Docs')
from wxd import stc_
self.stcdocs = Filling(parent=self.notebook,
rootObject=stc_.StyledTextCtrl,
rootLabel='StyledTextCtrl',
rootIsNamespace=False,
static=True)
self.notebook.AddPage(page=self.stcdocs, text='StyledTextCtrl Docs')
self.SplitHorizontally(self.shell, self.notebook, 300)
self.SetMinimumPaneSize(1)
class Display(editwindow.EditWindow):
"""STC used to display an object using Pretty Print."""
def __init__(self, parent, id=-1, pos=wx.DefaultPosition,
size=wx.DefaultSize,
style=wx.CLIP_CHILDREN | wx.SUNKEN_BORDER,
static=False):
"""Create Display instance."""
editwindow.EditWindow.__init__(self, parent, id, pos, size, style)
# Configure various defaults and user preferences.
self.SetReadOnly(True)
self.SetWrapMode(False)
if not static:
dispatcher.connect(receiver=self.push, signal='Interpreter.push')
def push(self, command, more):
"""Receiver for Interpreter.push signal."""
self.Refresh()
def Refresh(self):
if not hasattr(self, "item"):
return
self.SetReadOnly(False)
text = pprint.pformat(self.item)
self.SetText(text)
self.SetReadOnly(True)
def setItem(self, item):
"""Set item to pretty print in the notebook Display tab."""
self.item = item
self.Refresh()
class Calltip(wx.TextCtrl):
"""Text control containing the most recent shell calltip."""
def __init__(self, parent=None, id=-1):
style = wx.TE_MULTILINE | wx.TE_READONLY | wx.TE_RICH2
wx.TextCtrl.__init__(self, parent=parent, id=id, style=style)
self.SetBackgroundColour(wx.Colour(255, 255, 232))
dispatcher.connect(receiver=self.display, signal='Shell.calltip')
def display(self, calltip):
"""Receiver for Shell.calltip signal."""
self.SetValue(calltip)
class SessionListing(wx.TextCtrl):
"""Text control containing all commands for session."""
def __init__(self, parent=None, id=-1):
style = wx.TE_MULTILINE | wx.TE_READONLY | \
wx.TE_RICH2 | wx.TE_DONTWRAP
wx.TextCtrl.__init__(self, parent=parent, id=id, style=style)
dispatcher.connect(receiver=self.push, signal='Interpreter.push')
def push(self, command, more):
"""Receiver for Interpreter.push signal."""
if command and not more:
self.SetInsertionPointEnd()
start, end = self.GetSelection()
if start != end:
self.SetSelection(0, 0)
self.AppendText(command + '\n')
class DispatcherListing(wx.TextCtrl):
"""Text control containing all dispatches for session."""
def __init__(self, parent=None, id=-1):
style = wx.TE_MULTILINE | wx.TE_READONLY | \
wx.TE_RICH2 | wx.TE_DONTWRAP
wx.TextCtrl.__init__(self, parent=parent, id=id, style=style)
dispatcher.connect(receiver=self.spy)
def spy(self, signal, sender):
"""Receiver for Any signal from Any sender."""
text = '%r from %s' % (signal, sender)
self.SetInsertionPointEnd()
start, end = self.GetSelection()
if start != end:
self.SetSelection(0, 0)
self.AppendText(text + '\n')
class CrustFrame(frame.Frame):
"""Frame containing all the PyCrust components."""
name = 'CrustFrame'
revision = __revision__
def __init__(self, parent=None, id=-1, title='PyCrust',
pos=wx.DefaultPosition, size=wx.DefaultSize,
style=wx.DEFAULT_FRAME_STYLE,
rootObject=None, rootLabel=None, rootIsNamespace=True,
locals=None, InterpClass=None, *args, **kwds):
"""Create CrustFrame instance."""
frame.Frame.__init__(self, parent, id, title, pos, size, style)
intro = 'PyCrust %s - The Flakiest Python Shell' % VERSION
intro += '\nSponsored by Orbtech - '
intro += 'Your source for Python programming expertise.'
self.SetStatusText(intro.replace('\n', ', '))
self.crust = Crust(parent=self, intro=intro,
rootObject=rootObject,
rootLabel=rootLabel,
rootIsNamespace=rootIsNamespace,
locals=locals,
InterpClass=InterpClass, *args, **kwds)
self.shell = self.crust.shell
# Override the filling so that status messages go to the status bar.
self.crust.filling.tree.setStatusText = self.SetStatusText
# Override the shell so that status messages go to the status bar.
self.shell.setStatusText = self.SetStatusText
# Fix a problem with the sash shrinking to nothing.
self.crust.filling.SetSashPosition(200)
# Set focus to the shell editor.
self.shell.SetFocus()
def OnClose(self, event):
"""Event handler for closing."""
self.crust.shell.destroy()
self.Destroy()
def OnAbout(self, event):
"""Display an About window."""
title = 'About PyCrust'
text = 'PyCrust %s\n\n' % VERSION + \
'Yet another Python shell, only flakier.\n\n' + \
'Half-baked by Patrick K. O\'Brien,\n' + \
'the other half is still in the oven.\n\n' + \
'Shell Revision: %s\n' % self.shell.revision + \
'Interpreter Revision: %s\n\n' % self.shell.interp.revision + \
'Python Version: %s\n' % sys.version.split()[0] + \
'wxPython Version: %s\n' % wx.VERSION_STRING + \
'Platform: %s\n' % sys.platform
dialog = wx.MessageDialog(self, text, title,
wx.OK | wx.ICON_INFORMATION)
dialog.ShowModal()
dialog.Destroy()

View File

@@ -1,266 +0,0 @@
"""Provides global signal dispatching services."""
__author__ = "Patrick K. O'Brien <pobrien@orbtech.com>"
__cvsid__ = "$Id$"
__revision__ = "$Revision$"[11:-2]
import exceptions
import types
import weakref
try:
True
except NameError:
True = 1==1
False = 1==0
class DispatcherError(exceptions.Exception):
def __init__(self, args=None):
self.args = args
class Parameter:
"""Used to represent default parameter values."""
def __repr__(self):
return self.__class__.__name__
class Any(Parameter): pass
Any = Any()
class Anonymous(Parameter): pass
Anonymous = Anonymous()
connections = {}
senders = {}
_boundMethods = weakref.WeakKeyDictionary()
def connect(receiver, signal=Any, sender=Any, weak=True):
"""Connect receiver to sender for signal.
If sender is Any, receiver will receive signal from any sender.
If signal is Any, receiver will receive any signal from sender.
If sender is None, receiver will receive signal from Anonymous.
If signal is Any and sender is None, receiver will receive any
signal from Anonymous.
If signal is Any and sender is Any, receiver will receive any
signal from any sender.
If weak is true, weak references will be used."""
if signal is None:
raise DispatcherError, 'signal cannot be None'
if weak:
receiver = safeRef(receiver)
senderkey = id(sender)
signals = {}
if connections.has_key(senderkey):
signals = connections[senderkey]
else:
connections[senderkey] = signals
# Keep track of senders for cleanup.
if sender not in (None, Any):
def remove(object, senderkey=senderkey):
_removeSender(senderkey=senderkey)
# Skip objects that can not be weakly referenced, which means
# they won't be automatically cleaned up, but that's too bad.
try:
weakSender = weakref.ref(sender, remove)
senders[senderkey] = weakSender
except:
pass
receivers = []
if signals.has_key(signal):
receivers = signals[signal]
else:
signals[signal] = receivers
try:
receivers.remove(receiver)
except ValueError:
pass
receivers.append(receiver)
def disconnect(receiver, signal=Any, sender=Any, weak=True):
"""Disconnect receiver from sender for signal.
Disconnecting is not required. The use of disconnect is the same as for
connect, only in reverse. Think of it as undoing a previous connection."""
if signal is None:
raise DispatcherError, 'signal cannot be None'
if weak:
receiver = safeRef(receiver)
senderkey = id(sender)
try:
receivers = connections[senderkey][signal]
except KeyError:
raise DispatcherError, \
'No receivers for signal %r from sender %s' % (signal, sender)
try:
receivers.remove(receiver)
except ValueError:
raise DispatcherError, \
'No connection to receiver %s for signal %r from sender %s' % \
(receiver, signal, sender)
_cleanupConnections(senderkey, signal)
def send(signal, sender=Anonymous, **kwds):
"""Send signal from sender to all connected receivers.
Return a list of tuple pairs [(receiver, response), ... ].
If sender is not specified, signal is sent anonymously."""
senderkey = id(sender)
anykey = id(Any)
# Get receivers that receive *this* signal from *this* sender.
receivers = []
try:
receivers.extend(connections[senderkey][signal])
except KeyError:
pass
# Add receivers that receive *any* signal from *this* sender.
anyreceivers = []
try:
anyreceivers = connections[senderkey][Any]
except KeyError:
pass
for receiver in anyreceivers:
if receivers.count(receiver) == 0:
receivers.append(receiver)
# Add receivers that receive *this* signal from *any* sender.
anyreceivers = []
try:
anyreceivers = connections[anykey][signal]
except KeyError:
pass
for receiver in anyreceivers:
if receivers.count(receiver) == 0:
receivers.append(receiver)
# Add receivers that receive *any* signal from *any* sender.
anyreceivers = []
try:
anyreceivers = connections[anykey][Any]
except KeyError:
pass
for receiver in anyreceivers:
if receivers.count(receiver) == 0:
receivers.append(receiver)
# Call each receiver with whatever arguments it can accept.
# Return a list of tuple pairs [(receiver, response), ... ].
responses = []
for receiver in receivers:
if type(receiver) is weakref.ReferenceType \
or isinstance(receiver, BoundMethodWeakref):
# Dereference the weak reference.
receiver = receiver()
if receiver is None:
# This receiver is dead, so skip it.
continue
response = _call(receiver, signal=signal, sender=sender, **kwds)
responses += [(receiver, response)]
return responses
def _call(receiver, **kwds):
"""Call receiver with only arguments it can accept."""
## if type(receiver) is types.InstanceType:
if hasattr(receiver, '__call__') and \
(hasattr(receiver.__call__, 'im_func') or hasattr(receiver.__call__, 'im_code')):
# receiver is a class instance; assume it is callable.
# Reassign receiver to the actual method that will be called.
receiver = receiver.__call__
if hasattr(receiver, 'im_func'):
# receiver is a method. Drop the first argument, usually 'self'.
fc = receiver.im_func.func_code
acceptable = fc.co_varnames[1:fc.co_argcount]
elif hasattr(receiver, 'func_code'):
# receiver is a function.
fc = receiver.func_code
acceptable = fc.co_varnames[0:fc.co_argcount]
else:
raise DispatcherError, 'Unknown receiver %s of type %s' % (receiver, type(receiver))
if not (fc.co_flags & 8):
# fc does not have a **kwds type parameter, therefore
# remove unacceptable arguments.
for arg in kwds.keys():
if arg not in acceptable:
del kwds[arg]
return receiver(**kwds)
def safeRef(object):
"""Return a *safe* weak reference to a callable object."""
if hasattr(object, 'im_self'):
if object.im_self is not None:
# Turn a bound method into a BoundMethodWeakref instance.
# Keep track of these instances for lookup by disconnect().
selfkey = object.im_self
funckey = object.im_func
if not _boundMethods.has_key(selfkey):
_boundMethods[selfkey] = weakref.WeakKeyDictionary()
if not _boundMethods[selfkey].has_key(funckey):
_boundMethods[selfkey][funckey] = \
BoundMethodWeakref(boundMethod=object)
return _boundMethods[selfkey][funckey]
return weakref.ref(object, _removeReceiver)
class BoundMethodWeakref:
"""BoundMethodWeakref class."""
def __init__(self, boundMethod):
"""Return a weak-reference-like instance for a bound method."""
self.isDead = 0
def remove(object, self=self):
"""Set self.isDead to true when method or instance is destroyed."""
self.isDead = 1
_removeReceiver(receiver=self)
self.weakSelf = weakref.ref(boundMethod.im_self, remove)
self.weakFunc = weakref.ref(boundMethod.im_func, remove)
def __repr__(self):
"""Return the closest representation."""
return '<bound method weakref for %s.%s>' % (self.weakSelf, self.weakFunc)
def __call__(self):
"""Return a strong reference to the bound method."""
if self.isDead:
return None
else:
object = self.weakSelf()
method = self.weakFunc().__name__
try: # wxPython hack to handle wxDead objects.
return getattr(object, method)
except AttributeError:
## _removeReceiver(receiver=self)
return None
def _removeReceiver(receiver):
"""Remove receiver from connections."""
for senderkey in connections.keys():
for signal in connections[senderkey].keys():
receivers = connections[senderkey][signal]
try:
receivers.remove(receiver)
except:
pass
_cleanupConnections(senderkey, signal)
def _cleanupConnections(senderkey, signal):
"""Delete any empty signals for senderkey. Delete senderkey if empty."""
receivers = connections[senderkey][signal]
if not receivers:
# No more connected receivers. Therefore, remove the signal.
signals = connections[senderkey]
del signals[signal]
if not signals:
# No more signal connections. Therefore, remove the sender.
_removeSender(senderkey)
def _removeSender(senderkey):
"""Remove senderkey from connections."""
del connections[senderkey]
# Senderkey will only be in senders dictionary if sender
# could be weakly referenced.
try:
del senders[senderkey]
except:
pass

View File

@@ -1,49 +0,0 @@
"""Document class."""
__author__ = "Patrick K. O'Brien <pobrien@orbtech.com>"
__cvsid__ = "$Id$"
__revision__ = "$Revision$"[11:-2]
import os
try:
True
except NameError:
True = 1==1
False = 1==0
class Document:
"""Document class."""
def __init__(self, filename=None):
"""Create a Document instance."""
self.filename = filename
self.filepath = None
self.filedir = None
self.filebase = None
self.fileext = None
if self.filename:
self.filepath = os.path.realpath(self.filename)
self.filedir, self.filename = os.path.split(self.filepath)
self.filebase, self.fileext = os.path.splitext(self.filename)
def read(self):
"""Return contents of file."""
if self.filepath and os.path.exists(self.filepath):
f = file(self.filepath, 'rb')
try:
return f.read()
finally:
f.close()
else:
return ''
def write(self, text):
"""Write text to file."""
try:
f = file(self.filepath, 'wb')
f.write(text)
finally:
if f:
f.close()

View File

@@ -1,846 +0,0 @@
"""PyAlaCarte and PyAlaMode editors."""
__author__ = "Patrick K. O'Brien <pobrien@orbtech.com>"
__cvsid__ = "$Id$"
__revision__ = "$Revision$"[11:-2]
import wx
from buffer import Buffer
import crust
import dispatcher
import editwindow
import frame
from shell import Shell
import version
try:
True
except NameError:
True = 1==1
False = 1==0
class EditorFrame(frame.Frame):
"""Frame containing one editor."""
def __init__(self, parent=None, id=-1, title='PyAlaCarte',
pos=wx.DefaultPosition, size=(800, 600),
style=wx.DEFAULT_FRAME_STYLE | wx.NO_FULL_REPAINT_ON_RESIZE,
filename=None):
"""Create EditorFrame instance."""
frame.Frame.__init__(self, parent, id, title, pos, size, style)
self.buffers = {}
self.buffer = None # Current buffer.
self.editor = None
self._defaultText = title + ' - the tastiest Python editor.'
self._statusText = self._defaultText
self.SetStatusText(self._statusText)
wx.EVT_IDLE(self, self.OnIdle)
self._setup()
if filename:
self.bufferCreate(filename)
def _setup(self):
"""Setup prior to first buffer creation.
Useful for subclasses."""
pass
def setEditor(self, editor):
self.editor = editor
self.buffer = self.editor.buffer
self.buffers[self.buffer.id] = self.buffer
def OnAbout(self, event):
"""Display an About window."""
title = 'About PyAlaCarte'
text = 'Another fine, flaky program.'
dialog = wx.MessageDialog(self, text, title,
wx.OK | wx.ICON_INFORMATION)
dialog.ShowModal()
dialog.Destroy()
def OnClose(self, event):
"""Event handler for closing."""
for buffer in self.buffers.values():
self.buffer = buffer
if buffer.hasChanged():
cancel = self.bufferSuggestSave()
if cancel and event.CanVeto():
event.Veto()
return
self.Destroy()
def OnIdle(self, event):
"""Event handler for idle time."""
self._updateStatus()
if hasattr(self, 'notebook'):
self._updateTabText()
self._updateTitle()
event.Skip()
def _updateStatus(self):
"""Show current status information."""
if self.editor and hasattr(self.editor, 'getStatus'):
status = self.editor.getStatus()
text = 'File: %s | Line: %d | Column: %d' % status
else:
text = self._defaultText
if text != self._statusText:
self.SetStatusText(text)
self._statusText = text
def _updateTabText(self):
"""Show current buffer information on notebook tab."""
## suffix = ' **'
## notebook = self.notebook
## selection = notebook.GetSelection()
## if selection == -1:
## return
## text = notebook.GetPageText(selection)
## window = notebook.GetPage(selection)
## if window.editor and window.editor.buffer.hasChanged():
## if text.endswith(suffix):
## pass
## else:
## notebook.SetPageText(selection, text + suffix)
## else:
## if text.endswith(suffix):
## notebook.SetPageText(selection, text[:len(suffix)])
def _updateTitle(self):
"""Show current title information."""
title = self.GetTitle()
if self.bufferHasChanged():
if title.startswith('* '):
pass
else:
self.SetTitle('* ' + title)
else:
if title.startswith('* '):
self.SetTitle(title[2:])
def hasBuffer(self):
"""Return True if there is a current buffer."""
if self.buffer:
return True
else:
return False
def bufferClose(self):
"""Close buffer."""
if self.bufferHasChanged():
cancel = self.bufferSuggestSave()
if cancel:
return cancel
self.bufferDestroy()
cancel = False
return cancel
def bufferCreate(self, filename=None):
"""Create new buffer."""
self.bufferDestroy()
buffer = Buffer()
self.panel = panel = wx.Panel(parent=self, id=-1)
wx.EVT_ERASE_BACKGROUND(panel, lambda x: x)
editor = Editor(parent=panel)
panel.editor = editor
sizer = wx.BoxSizer(wx.VERTICAL)
sizer.Add(editor.window, 1, wx.EXPAND)
panel.SetSizer(sizer)
panel.SetAutoLayout(True)
sizer.Layout()
buffer.addEditor(editor)
buffer.open(filename)
self.setEditor(editor)
self.editor.setFocus()
self.SendSizeEvent()
def bufferDestroy(self):
"""Destroy the current buffer."""
if self.buffer:
for editor in self.buffer.editors.values():
editor.destroy()
self.editor = None
del self.buffers[self.buffer.id]
self.buffer = None
self.panel.Destroy()
def bufferHasChanged(self):
"""Return True if buffer has changed since last save."""
if self.buffer:
return self.buffer.hasChanged()
else:
return False
def bufferNew(self):
"""Create new buffer."""
if self.bufferHasChanged():
cancel = self.bufferSuggestSave()
if cancel:
return cancel
self.bufferCreate()
cancel = False
return cancel
def bufferOpen(self):
"""Open file in buffer."""
if self.bufferHasChanged():
cancel = self.bufferSuggestSave()
if cancel:
return cancel
filedir = ''
if self.buffer and self.buffer.doc.filedir:
filedir = self.buffer.doc.filedir
result = openSingle(directory=filedir)
if result.path:
self.bufferCreate(result.path)
cancel = False
return cancel
## def bufferPrint(self):
## """Print buffer."""
## pass
## def bufferRevert(self):
## """Revert buffer to version of file on disk."""
## pass
def bufferSave(self):
"""Save buffer to its file."""
if self.buffer.doc.filepath:
self.buffer.save()
cancel = False
else:
cancel = self.bufferSaveAs()
return cancel
def bufferSaveAs(self):
"""Save buffer to a new filename."""
if self.bufferHasChanged() and self.buffer.doc.filepath:
cancel = self.bufferSuggestSave()
if cancel:
return cancel
filedir = ''
if self.buffer and self.buffer.doc.filedir:
filedir = self.buffer.doc.filedir
result = saveSingle(directory=filedir)
if result.path:
self.buffer.saveAs(result.path)
cancel = False
else:
cancel = True
return cancel
def bufferSuggestSave(self):
"""Suggest saving changes. Return True if user selected Cancel."""
result = messageDialog(parent=None,
message='%s has changed.\n'
'Would you like to save it first'
'?' % self.buffer.name,
title='Save current file?')
if result.positive:
cancel = self.bufferSave()
else:
cancel = result.text == 'Cancel'
return cancel
def updateNamespace(self):
"""Update the buffer namespace for autocompletion and calltips."""
if self.buffer.updateNamespace():
self.SetStatusText('Namespace updated')
else:
self.SetStatusText('Error executing, unable to update namespace')
class EditorNotebookFrame(EditorFrame):
"""Frame containing one or more editors in a notebook."""
def __init__(self, parent=None, id=-1, title='PyAlaMode',
pos=wx.DefaultPosition, size=(800, 600),
style=wx.DEFAULT_FRAME_STYLE | wx.NO_FULL_REPAINT_ON_RESIZE,
filename=None):
"""Create EditorNotebookFrame instance."""
self.notebook = None
EditorFrame.__init__(self, parent, id, title, pos,
size, style, filename)
if self.notebook:
dispatcher.connect(receiver=self._editorChange,
signal='EditorChange', sender=self.notebook)
def _setup(self):
"""Setup prior to first buffer creation.
Called automatically by base class during init."""
self.notebook = EditorNotebook(parent=self)
intro = 'Py %s' % version.VERSION
import imp
module = imp.new_module('__main__')
import __builtin__
module.__dict__['__builtins__'] = __builtin__
namespace = module.__dict__.copy()
self.crust = crust.Crust(parent=self.notebook, intro=intro, locals=namespace)
self.shell = self.crust.shell
# Override the filling so that status messages go to the status bar.
self.crust.filling.tree.setStatusText = self.SetStatusText
# Override the shell so that status messages go to the status bar.
self.shell.setStatusText = self.SetStatusText
# Fix a problem with the sash shrinking to nothing.
self.crust.filling.SetSashPosition(200)
self.notebook.AddPage(page=self.crust, text='*Shell*', select=True)
self.setEditor(self.crust.editor)
self.crust.editor.SetFocus()
def _editorChange(self, editor):
"""Editor change signal receiver."""
self.setEditor(editor)
def OnAbout(self, event):
"""Display an About window."""
title = 'About PyAlaMode'
text = 'Another fine, flaky program.'
dialog = wx.MessageDialog(self, text, title,
wx.OK | wx.ICON_INFORMATION)
dialog.ShowModal()
dialog.Destroy()
def _updateTitle(self):
"""Show current title information."""
pass
## title = self.GetTitle()
## if self.bufferHasChanged():
## if title.startswith('* '):
## pass
## else:
## self.SetTitle('* ' + title)
## else:
## if title.startswith('* '):
## self.SetTitle(title[2:])
def bufferCreate(self, filename=None):
"""Create new buffer."""
buffer = Buffer()
panel = wx.Panel(parent=self.notebook, id=-1)
wx.EVT_ERASE_BACKGROUND(panel, lambda x: x)
editor = Editor(parent=panel)
panel.editor = editor
sizer = wx.BoxSizer(wx.VERTICAL)
sizer.Add(editor.window, 1, wx.EXPAND)
panel.SetSizer(sizer)
panel.SetAutoLayout(True)
sizer.Layout()
buffer.addEditor(editor)
buffer.open(filename)
self.setEditor(editor)
self.notebook.AddPage(page=panel, text=self.buffer.name, select=True)
self.editor.setFocus()
def bufferDestroy(self):
"""Destroy the current buffer."""
selection = self.notebook.GetSelection()
## print "Destroy Selection:", selection
if selection > 0: # Don't destroy the PyCrust tab.
if self.buffer:
del self.buffers[self.buffer.id]
self.buffer = None # Do this before DeletePage().
self.notebook.DeletePage(selection)
def bufferNew(self):
"""Create new buffer."""
self.bufferCreate()
cancel = False
return cancel
def bufferOpen(self):
"""Open file in buffer."""
filedir = ''
if self.buffer and self.buffer.doc.filedir:
filedir = self.buffer.doc.filedir
result = openMultiple(directory=filedir)
for path in result.paths:
self.bufferCreate(path)
cancel = False
return cancel
class EditorNotebook(wx.Notebook):
"""A notebook containing a page for each editor."""
def __init__(self, parent):
"""Create EditorNotebook instance."""
wx.Notebook.__init__(self, parent, id=-1, style=wx.NO_FULL_REPAINT_ON_RESIZE)
wx.EVT_NOTEBOOK_PAGE_CHANGING(self, self.GetId(),
self.OnPageChanging)
wx.EVT_NOTEBOOK_PAGE_CHANGED(self, self.GetId(),
self.OnPageChanged)
wx.EVT_IDLE(self, self.OnIdle)
def OnIdle(self, event):
"""Event handler for idle time."""
self._updateTabText()
event.Skip()
def _updateTabText(self):
"""Show current buffer display name on all but first tab."""
size = 3
changed = ' **'
unchanged = ' --'
selection = self.GetSelection()
if selection < 1:
return
text = self.GetPageText(selection)
window = self.GetPage(selection)
if not window.editor:
return
if text.endswith(changed) or text.endswith(unchanged):
name = text[:-size]
else:
name = text
if name != window.editor.buffer.name:
text = window.editor.buffer.name
if window.editor.buffer.hasChanged():
if text.endswith(changed):
text = None
elif text.endswith(unchanged):
text = text[:-size] + changed
else:
text += changed
else:
if text.endswith(changed):
text = text[:-size] + unchanged
elif text.endswith(unchanged):
text = None
else:
text += unchanged
if text is not None:
self.SetPageText(selection, text)
self.Refresh() # Needed on Win98.
def OnPageChanging(self, event):
"""Page changing event handler."""
event.Skip()
def OnPageChanged(self, event):
"""Page changed event handler."""
new = event.GetSelection()
window = self.GetPage(new)
dispatcher.send(signal='EditorChange', sender=self,
editor=window.editor)
window.SetFocus()
event.Skip()
class EditorShellNotebookFrame(EditorNotebookFrame):
"""Frame containing a notebook containing EditorShellNotebooks."""
def __init__(self, parent=None, id=-1, title='PyAlaModeTest',
pos=wx.DefaultPosition, size=(600, 400),
style=wx.DEFAULT_FRAME_STYLE,
filename=None, singlefile=False):
"""Create EditorShellNotebookFrame instance."""
self._singlefile = singlefile
EditorNotebookFrame.__init__(self, parent, id, title, pos,
size, style, filename)
def _setup(self):
"""Setup prior to first buffer creation.
Called automatically by base class during init."""
if not self._singlefile:
self.notebook = EditorNotebook(parent=self)
def OnAbout(self, event):
"""Display an About window."""
title = 'About PyAlaModePlus'
text = 'Another fine, flaky program.'
dialog = wx.MessageDialog(self, text, title,
wx.OK | wx.ICON_INFORMATION)
dialog.ShowModal()
dialog.Destroy()
def bufferCreate(self, filename=None):
"""Create new buffer."""
if self._singlefile:
self.bufferDestroy()
notebook = EditorShellNotebook(parent=self,
filename=filename)
self.notebook = notebook
else:
notebook = EditorShellNotebook(parent=self.notebook,
filename=filename)
self.setEditor(notebook.editor)
if not self._singlefile:
self.notebook.AddPage(page=notebook, text=self.buffer.name,
select=True)
self.editor.setFocus()
def bufferDestroy(self):
"""Destroy the current buffer."""
if self.buffer:
self.editor = None
del self.buffers[self.buffer.id]
self.buffer = None # Do this before DeletePage().
if self._singlefile:
self.notebook.Destroy()
self.notebook = None
else:
selection = self.notebook.GetSelection()
## print "Destroy Selection:", selection
self.notebook.DeletePage(selection)
def bufferNew(self):
"""Create new buffer."""
if self._singlefile and self.bufferHasChanged():
cancel = self.bufferSuggestSave()
if cancel:
return cancel
self.bufferCreate()
cancel = False
return cancel
def bufferOpen(self):
"""Open file in buffer."""
if self._singlefile and self.bufferHasChanged():
cancel = self.bufferSuggestSave()
if cancel:
return cancel
filedir = ''
if self.buffer and self.buffer.doc.filedir:
filedir = self.buffer.doc.filedir
if self._singlefile:
result = openSingle(directory=filedir)
if result.path:
self.bufferCreate(result.path)
else:
result = openMultiple(directory=filedir)
for path in result.paths:
self.bufferCreate(path)
cancel = False
return cancel
class EditorShellNotebook(wx.Notebook):
"""A notebook containing an editor page and a shell page."""
def __init__(self, parent, filename=None):
"""Create EditorShellNotebook instance."""
wx.Notebook.__init__(self, parent, id=-1)
usePanels = True
if usePanels:
editorparent = editorpanel = wx.Panel(self, -1)
shellparent = shellpanel = wx.Panel(self, -1)
else:
editorparent = self
shellparent = self
self.buffer = Buffer()
self.editor = Editor(parent=editorparent)
self.buffer.addEditor(self.editor)
self.buffer.open(filename)
self.shell = Shell(parent=shellparent, locals=self.buffer.interp.locals,
style=wx.CLIP_CHILDREN | wx.SUNKEN_BORDER)
self.buffer.interp.locals.clear()
if usePanels:
self.AddPage(page=editorpanel, text='Editor', select=True)
self.AddPage(page=shellpanel, text='Shell')
# Setup sizers
editorsizer = wx.BoxSizer(wx.VERTICAL)
editorsizer.Add(self.editor.window, 1, wx.EXPAND)
editorpanel.SetSizer(editorsizer)
editorpanel.SetAutoLayout(True)
shellsizer = wx.BoxSizer(wx.VERTICAL)
shellsizer.Add(self.shell, 1, wx.EXPAND)
shellpanel.SetSizer(shellsizer)
shellpanel.SetAutoLayout(True)
else:
self.AddPage(page=self.editor.window, text='Editor', select=True)
self.AddPage(page=self.shell, text='Shell')
self.editor.setFocus()
wx.EVT_NOTEBOOK_PAGE_CHANGED(self, self.GetId(), self.OnPageChanged)
def OnPageChanged(self, event):
"""Page changed event handler."""
selection = event.GetSelection()
if selection == 0:
self.editor.setFocus()
else:
self.shell.SetFocus()
event.Skip()
def SetFocus(self):
wx.Notebook.SetFocus(self)
selection = self.GetSelection()
if selection == 0:
self.editor.setFocus()
else:
self.shell.SetFocus()
class Editor:
"""Editor having an EditWindow."""
def __init__(self, parent, id=-1, pos=wx.DefaultPosition,
size=wx.DefaultSize,
style=wx.CLIP_CHILDREN | wx.SUNKEN_BORDER):
"""Create Editor instance."""
self.window = EditWindow(self, parent, id, pos, size, style)
self.id = self.window.GetId()
self.buffer = None
# Assign handlers for keyboard events.
wx.EVT_CHAR(self.window, self.OnChar)
wx.EVT_KEY_DOWN(self.window, self.OnKeyDown)
def _setBuffer(self, buffer, text):
"""Set the editor to a buffer. Private callback called by buffer."""
self.buffer = buffer
self.autoCompleteKeys = buffer.interp.getAutoCompleteKeys()
self.clearAll()
self.setText(text)
self.emptyUndoBuffer()
self.setSavePoint()
def destroy(self):
"""Destroy all editor objects."""
self.window.Destroy()
def clearAll(self):
self.window.ClearAll()
def emptyUndoBuffer(self):
self.window.EmptyUndoBuffer()
def getStatus(self):
"""Return (filepath, line, column) status tuple."""
pos = self.window.GetCurrentPos()
line = self.window.LineFromPosition(pos) + 1
col = self.window.GetColumn(pos)
if self.buffer:
name = self.buffer.doc.filepath or self.buffer.name
else:
name = ''
status = (name, line, col)
return status
def getText(self):
"""Return contents of editor."""
return self.window.GetText()
def hasChanged(self):
"""Return True if contents have changed."""
return self.window.GetModify()
def setFocus(self):
"""Set the input focus to the editor window."""
self.window.SetFocus()
def setSavePoint(self):
self.window.SetSavePoint()
def setText(self, text):
"""Set contents of editor."""
self.window.SetText(text)
def OnChar(self, event):
"""Keypress event handler.
Only receives an event if OnKeyDown calls event.Skip() for the
corresponding event."""
key = event.KeyCode()
if key in self.autoCompleteKeys:
# Usually the dot (period) key activates auto completion.
if self.window.AutoCompActive():
self.window.AutoCompCancel()
self.window.ReplaceSelection('')
self.window.AddText(chr(key))
text, pos = self.window.GetCurLine()
text = text[:pos]
if self.window.autoComplete:
self.autoCompleteShow(text)
elif key == ord('('):
# The left paren activates a call tip and cancels an
# active auto completion.
if self.window.AutoCompActive():
self.window.AutoCompCancel()
self.window.ReplaceSelection('')
self.window.AddText('(')
text, pos = self.window.GetCurLine()
text = text[:pos]
self.autoCallTipShow(text)
else:
# Allow the normal event handling to take place.
event.Skip()
def OnKeyDown(self, event):
"""Key down event handler."""
key = event.KeyCode()
# If the auto-complete window is up let it do its thing.
if self.window.AutoCompActive():
event.Skip()
return
controlDown = event.ControlDown()
altDown = event.AltDown()
shiftDown = event.ShiftDown()
# Let Ctrl-Alt-* get handled normally.
if controlDown and altDown:
event.Skip()
# Increase font size.
elif controlDown and key in (ord(']'),):
dispatcher.send(signal='FontIncrease')
# Decrease font size.
elif controlDown and key in (ord('['),):
dispatcher.send(signal='FontDecrease')
# Default font size.
elif controlDown and key in (ord('='),):
dispatcher.send(signal='FontDefault')
else:
event.Skip()
def autoCompleteShow(self, command):
"""Display auto-completion popup list."""
list = self.buffer.interp.getAutoCompleteList(command,
includeMagic=self.window.autoCompleteIncludeMagic,
includeSingle=self.window.autoCompleteIncludeSingle,
includeDouble=self.window.autoCompleteIncludeDouble)
if list:
options = ' '.join(list)
offset = 0
self.window.AutoCompShow(offset, options)
def autoCallTipShow(self, command):
"""Display argument spec and docstring in a popup window."""
if self.window.CallTipActive():
self.window.CallTipCancel()
(name, argspec, tip) = self.buffer.interp.getCallTip(command)
if tip:
dispatcher.send(signal='Shell.calltip', sender=self, calltip=tip)
if not self.window.autoCallTip:
return
if argspec:
startpos = self.window.GetCurrentPos()
self.window.AddText(argspec + ')')
endpos = self.window.GetCurrentPos()
self.window.SetSelection(endpos, startpos)
if tip:
curpos = self.window.GetCurrentPos()
size = len(name)
tippos = curpos - (size + 1)
fallback = curpos - self.window.GetColumn(curpos)
# In case there isn't enough room, only go back to the
# fallback.
tippos = max(tippos, fallback)
self.window.CallTipShow(tippos, tip)
self.window.CallTipSetHighlight(0, size)
class EditWindow(editwindow.EditWindow):
"""EditWindow based on StyledTextCtrl."""
def __init__(self, editor, parent, id=-1, pos=wx.DefaultPosition,
size=wx.DefaultSize,
style=wx.CLIP_CHILDREN | wx.SUNKEN_BORDER):
"""Create EditWindow instance."""
editwindow.EditWindow.__init__(self, parent, id, pos, size, style)
self.editor = editor
class DialogResults:
"""DialogResults class."""
def __init__(self, returned):
"""Create wrapper for results returned by dialog."""
self.returned = returned
self.positive = returned in (wx.ID_OK, wx.ID_YES)
self.text = self._asString()
def __repr__(self):
return str(self.__dict__)
def _asString(self):
returned = self.returned
if returned == wx.ID_OK:
return "Ok"
elif returned == wx.ID_CANCEL:
return "Cancel"
elif returned == wx.ID_YES:
return "Yes"
elif returned == wx.ID_NO:
return "No"
def fileDialog(parent=None, title='Open', directory='', filename='',
wildcard='All Files (*.*)|*.*',
style=wx.OPEN | wx.MULTIPLE):
"""File dialog wrapper function."""
dialog = wx.FileDialog(parent, title, directory, filename,
wildcard, style)
result = DialogResults(dialog.ShowModal())
if result.positive:
result.paths = dialog.GetPaths()
else:
result.paths = []
dialog.Destroy()
return result
def openSingle(parent=None, title='Open', directory='', filename='',
wildcard='All Files (*.*)|*.*', style=wx.OPEN):
"""File dialog wrapper function."""
dialog = wx.FileDialog(parent, title, directory, filename,
wildcard, style)
result = DialogResults(dialog.ShowModal())
if result.positive:
result.path = dialog.GetPath()
else:
result.path = None
dialog.Destroy()
return result
def openMultiple(parent=None, title='Open', directory='', filename='',
wildcard='All Files (*.*)|*.*',
style=wx.OPEN | wx.MULTIPLE):
"""File dialog wrapper function."""
return fileDialog(parent, title, directory, filename, wildcard, style)
def saveSingle(parent=None, title='Save', directory='', filename='',
wildcard='All Files (*.*)|*.*',
style=wx.SAVE | wx.HIDE_READONLY | wx.OVERWRITE_PROMPT):
"""File dialog wrapper function."""
dialog = wx.FileDialog(parent, title, directory, filename,
wildcard, style)
result = DialogResults(dialog.ShowModal())
if result.positive:
result.path = dialog.GetPath()
else:
result.path = None
dialog.Destroy()
return result
def directory(parent=None, message='Choose a directory', path='', style=0,
pos=wx.DefaultPosition, size=wx.DefaultSize):
"""Dir dialog wrapper function."""
dialog = wx.DirDialog(parent, message, path, style, pos, size)
result = DialogResults(dialog.ShowModal())
if result.positive:
result.path = dialog.GetPath()
else:
result.path = None
dialog.Destroy()
return result
def messageDialog(parent=None, message='', title='Message box',
style=wx.YES_NO | wx.CANCEL | wx.CENTRE | wx.ICON_QUESTION,
pos=wx.DefaultPosition):
"""Message dialog wrapper function."""
dialog = wx.MessageDialog(parent, message, title, style, pos)
result = DialogResults(dialog.ShowModal())
dialog.Destroy()
return result

View File

@@ -1,199 +0,0 @@
"""EditWindow class."""
__author__ = "Patrick K. O'Brien <pobrien@orbtech.com>"
__cvsid__ = "$Id$"
__revision__ = "$Revision$"[11:-2]
import wx
from wx import stc
import keyword
import os
import sys
import time
import dispatcher
from version import VERSION
try:
True
except NameError:
True = 1==1
False = 1==0
if wx.Platform == '__WXMSW__':
FACES = { 'times' : 'Times New Roman',
'mono' : 'Courier New',
'helv' : 'Lucida Console',
'lucida' : 'Lucida Console',
'other' : 'Comic Sans MS',
'size' : 10,
'lnsize' : 9,
'backcol': '#FFFFFF',
}
else: # GTK
FACES = { 'times' : 'Times',
'mono' : 'Courier',
'helv' : 'Helvetica',
'other' : 'new century schoolbook',
'size' : 12,
'lnsize' : 10,
'backcol': '#FFFFFF',
}
class EditWindow(stc.StyledTextCtrl):
"""EditWindow based on StyledTextCtrl."""
revision = __revision__
def __init__(self, parent, id=-1, pos=wx.DefaultPosition,
size=wx.DefaultSize, style=wx.CLIP_CHILDREN | wx.SUNKEN_BORDER):
"""Create EditWindow instance."""
stc.StyledTextCtrl.__init__(self, parent, id, pos, size, style)
self.__config()
stc.EVT_STC_UPDATEUI(self, id, self.OnUpdateUI)
dispatcher.connect(receiver=self._fontsizer, signal='FontIncrease')
dispatcher.connect(receiver=self._fontsizer, signal='FontDecrease')
dispatcher.connect(receiver=self._fontsizer, signal='FontDefault')
def _fontsizer(self, signal):
"""Receiver for Font* signals."""
size = self.GetZoom()
if signal == 'FontIncrease':
size += 1
elif signal == 'FontDecrease':
size -= 1
elif signal == 'FontDefault':
size = 0
self.SetZoom(size)
def __config(self):
"""Configure shell based on user preferences."""
self.SetMarginType(1, stc.STC_MARGIN_NUMBER)
self.SetMarginWidth(1, 40)
self.SetLexer(stc.STC_LEX_PYTHON)
self.SetKeyWords(0, ' '.join(keyword.kwlist))
self.setStyles(FACES)
self.SetViewWhiteSpace(False)
self.SetTabWidth(4)
self.SetUseTabs(False)
# Do we want to automatically pop up command completion options?
self.autoComplete = True
self.autoCompleteIncludeMagic = True
self.autoCompleteIncludeSingle = True
self.autoCompleteIncludeDouble = True
self.autoCompleteCaseInsensitive = True
self.AutoCompSetIgnoreCase(self.autoCompleteCaseInsensitive)
self.AutoCompSetAutoHide(False)
self.AutoCompStops(' .,;:([)]}\'"\\<>%^&+-=*/|`')
# Do we want to automatically pop up command argument help?
self.autoCallTip = True
self.CallTipSetBackground(wx.Colour(255, 255, 232))
self.SetWrapMode(False)
try:
self.SetEndAtLastLine(False)
except AttributeError:
pass
def setStyles(self, faces):
"""Configure font size, typeface and color for lexer."""
# Default style
self.StyleSetSpec(stc.STC_STYLE_DEFAULT,
"face:%(mono)s,size:%(size)d,back:%(backcol)s" % \
faces)
self.StyleClearAll()
# Built in styles
self.StyleSetSpec(stc.STC_STYLE_LINENUMBER,
"back:#C0C0C0,face:%(mono)s,size:%(lnsize)d" % faces)
self.StyleSetSpec(stc.STC_STYLE_CONTROLCHAR,
"face:%(mono)s" % faces)
self.StyleSetSpec(stc.STC_STYLE_BRACELIGHT,
"fore:#0000FF,back:#FFFF88")
self.StyleSetSpec(stc.STC_STYLE_BRACEBAD,
"fore:#FF0000,back:#FFFF88")
# Python styles
self.StyleSetSpec(stc.STC_P_DEFAULT,
"face:%(mono)s" % faces)
self.StyleSetSpec(stc.STC_P_COMMENTLINE,
"fore:#007F00,face:%(mono)s" % faces)
self.StyleSetSpec(stc.STC_P_NUMBER,
"")
self.StyleSetSpec(stc.STC_P_STRING,
"fore:#7F007F,face:%(mono)s" % faces)
self.StyleSetSpec(stc.STC_P_CHARACTER,
"fore:#7F007F,face:%(mono)s" % faces)
self.StyleSetSpec(stc.STC_P_WORD,
"fore:#00007F,bold")
self.StyleSetSpec(stc.STC_P_TRIPLE,
"fore:#7F0000")
self.StyleSetSpec(stc.STC_P_TRIPLEDOUBLE,
"fore:#000033,back:#FFFFE8")
self.StyleSetSpec(stc.STC_P_CLASSNAME,
"fore:#0000FF,bold")
self.StyleSetSpec(stc.STC_P_DEFNAME,
"fore:#007F7F,bold")
self.StyleSetSpec(stc.STC_P_OPERATOR,
"")
self.StyleSetSpec(stc.STC_P_IDENTIFIER,
"")
self.StyleSetSpec(stc.STC_P_COMMENTBLOCK,
"fore:#7F7F7F")
self.StyleSetSpec(stc.STC_P_STRINGEOL,
"fore:#000000,face:%(mono)s,back:#E0C0E0,eolfilled" % faces)
def OnUpdateUI(self, event):
"""Check for matching braces."""
# If the auto-complete window is up let it do its thing.
if self.AutoCompActive() or self.CallTipActive():
return
braceAtCaret = -1
braceOpposite = -1
charBefore = None
caretPos = self.GetCurrentPos()
if caretPos > 0:
charBefore = self.GetCharAt(caretPos - 1)
styleBefore = self.GetStyleAt(caretPos - 1)
# Check before.
if charBefore and chr(charBefore) in '[]{}()' \
and styleBefore == stc.STC_P_OPERATOR:
braceAtCaret = caretPos - 1
# Check after.
if braceAtCaret < 0:
charAfter = self.GetCharAt(caretPos)
styleAfter = self.GetStyleAt(caretPos)
if charAfter and chr(charAfter) in '[]{}()' \
and styleAfter == stc.STC_P_OPERATOR:
braceAtCaret = caretPos
if braceAtCaret >= 0:
braceOpposite = self.BraceMatch(braceAtCaret)
if braceAtCaret != -1 and braceOpposite == -1:
self.BraceBadLight(braceAtCaret)
else:
self.BraceHighlight(braceAtCaret, braceOpposite)
def CanCopy(self):
"""Return True if text is selected and can be copied."""
return self.GetSelectionStart() != self.GetSelectionEnd()
def CanCut(self):
"""Return True if text is selected and can be cut."""
return self.CanCopy() and self.CanEdit()
def CanEdit(self):
"""Return True if editing should succeed."""
return not self.GetReadOnly()
def CanPaste(self):
"""Return True if pasting should succeed."""
return stc.StyledTextCtrl.CanPaste(self) and self.CanEdit()

View File

@@ -1,337 +0,0 @@
"""Filling is the gui tree control through which a user can navigate
the local namespace or any object."""
__author__ = "Patrick K. O'Brien <pobrien@orbtech.com>"
__cvsid__ = "$Id$"
__revision__ = "$Revision$"[11:-2]
import wx
import dispatcher
import editwindow
import inspect
import introspect
import keyword
import sys
import types
from version import VERSION
try:
True
except NameError:
True = 1==1
False = 1==0
COMMONTYPES = [getattr(types, t) for t in dir(types) \
if not t.startswith('_') \
and t not in ('ClassType', 'InstanceType', 'ModuleType')]
DOCTYPES = ('BuiltinFunctionType', 'BuiltinMethodType', 'ClassType',
'FunctionType', 'GeneratorType', 'InstanceType',
'LambdaType', 'MethodType', 'ModuleType',
'UnboundMethodType', 'method-wrapper')
SIMPLETYPES = [getattr(types, t) for t in dir(types) \
if not t.startswith('_') and t not in DOCTYPES]
del t
try:
COMMONTYPES.append(type(''.__repr__)) # Method-wrapper in version 2.2.x.
except AttributeError:
pass
class FillingTree(wx.TreeCtrl):
"""FillingTree based on TreeCtrl."""
name = 'Filling Tree'
revision = __revision__
def __init__(self, parent, id=-1, pos=wx.DefaultPosition,
size=wx.DefaultSize, style=wx.TR_DEFAULT_STYLE,
rootObject=None, rootLabel=None, rootIsNamespace=False,
static=False):
"""Create FillingTree instance."""
wx.TreeCtrl.__init__(self, parent, id, pos, size, style)
self.rootIsNamespace = rootIsNamespace
import __main__
if rootObject is None:
rootObject = __main__.__dict__
self.rootIsNamespace = True
if rootObject is __main__.__dict__ and rootLabel is None:
rootLabel = 'locals()'
if not rootLabel:
rootLabel = 'Ingredients'
rootData = wx.TreeItemData(rootObject)
self.item = self.root = self.AddRoot(rootLabel, -1, -1, rootData)
self.SetItemHasChildren(self.root, self.objHasChildren(rootObject))
wx.EVT_TREE_ITEM_EXPANDING(self, self.GetId(), self.OnItemExpanding)
wx.EVT_TREE_ITEM_COLLAPSED(self, self.GetId(), self.OnItemCollapsed)
wx.EVT_TREE_SEL_CHANGED(self, self.GetId(), self.OnSelChanged)
wx.EVT_TREE_ITEM_ACTIVATED(self, self.GetId(), self.OnItemActivated)
if not static:
dispatcher.connect(receiver=self.push, signal='Interpreter.push')
def push(self, command, more):
"""Receiver for Interpreter.push signal."""
self.display()
def OnItemExpanding(self, event):
"""Add children to the item."""
busy = wx.BusyCursor()
item = event.GetItem()
if self.IsExpanded(item):
return
self.addChildren(item)
# self.SelectItem(item)
def OnItemCollapsed(self, event):
"""Remove all children from the item."""
busy = wx.BusyCursor()
item = event.GetItem()
# self.CollapseAndReset(item)
# self.DeleteChildren(item)
# self.SelectItem(item)
def OnSelChanged(self, event):
"""Display information about the item."""
busy = wx.BusyCursor()
self.item = event.GetItem()
self.display()
def OnItemActivated(self, event):
"""Launch a DirFrame."""
item = event.GetItem()
text = self.getFullName(item)
obj = self.GetPyData(item)
frame = FillingFrame(parent=self, size=(600, 100), rootObject=obj,
rootLabel=text, rootIsNamespace=False)
frame.Show()
def objHasChildren(self, obj):
"""Return true if object has children."""
if self.objGetChildren(obj):
return True
else:
return False
def objGetChildren(self, obj):
"""Return dictionary with attributes or contents of object."""
busy = wx.BusyCursor()
otype = type(obj)
if otype is types.DictType \
or str(otype)[17:23] == 'BTrees' and hasattr(obj, 'keys'):
return obj
d = {}
if otype is types.ListType or otype is types.TupleType:
for n in range(len(obj)):
key = '[' + str(n) + ']'
d[key] = obj[n]
if otype not in COMMONTYPES:
for key in introspect.getAttributeNames(obj):
# Believe it or not, some attributes can disappear,
# such as the exc_traceback attribute of the sys
# module. So this is nested in a try block.
try:
d[key] = getattr(obj, key)
except:
pass
return d
def addChildren(self, item):
self.DeleteChildren(item)
obj = self.GetPyData(item)
children = self.objGetChildren(obj)
if not children:
return
keys = children.keys()
keys.sort(lambda x, y: cmp(str(x).lower(), str(y).lower()))
for key in keys:
itemtext = str(key)
# Show string dictionary items with single quotes, except
# for the first level of items, if they represent a
# namespace.
if type(obj) is types.DictType \
and type(key) is types.StringType \
and (item != self.root \
or (item == self.root and not self.rootIsNamespace)):
itemtext = repr(key)
child = children[key]
data = wx.TreeItemData(child)
branch = self.AppendItem(parent=item, text=itemtext, data=data)
self.SetItemHasChildren(branch, self.objHasChildren(child))
def display(self):
item = self.item
if self.IsExpanded(item):
self.addChildren(item)
self.setText('')
obj = self.GetPyData(item)
if wx.Platform == '__WXMSW__':
if obj is None: # Windows bug fix.
return
self.SetItemHasChildren(item, self.objHasChildren(obj))
otype = type(obj)
text = ''
text += self.getFullName(item)
text += '\n\nType: ' + str(otype)
try:
value = str(obj)
except:
value = ''
if otype is types.StringType or otype is types.UnicodeType:
value = repr(obj)
text += '\n\nValue: ' + value
if otype not in SIMPLETYPES:
try:
text += '\n\nDocstring:\n\n"""' + \
inspect.getdoc(obj).strip() + '"""'
except:
pass
if otype is types.InstanceType:
try:
text += '\n\nClass Definition:\n\n' + \
inspect.getsource(obj.__class__)
except:
pass
else:
try:
text += '\n\nSource Code:\n\n' + \
inspect.getsource(obj)
except:
pass
self.setText(text)
def getFullName(self, item, partial=''):
"""Return a syntactically proper name for item."""
name = self.GetItemText(item)
parent = None
obj = None
if item != self.root:
parent = self.GetItemParent(item)
obj = self.GetPyData(parent)
# Apply dictionary syntax to dictionary items, except the root
# and first level children of a namepace.
if (type(obj) is types.DictType \
or str(type(obj))[17:23] == 'BTrees' \
and hasattr(obj, 'keys')) \
and ((item != self.root and parent != self.root) \
or (parent == self.root and not self.rootIsNamespace)):
name = '[' + name + ']'
# Apply dot syntax to multipart names.
if partial:
if partial[0] == '[':
name += partial
else:
name += '.' + partial
# Repeat for everything but the root item
# and first level children of a namespace.
if (item != self.root and parent != self.root) \
or (parent == self.root and not self.rootIsNamespace):
name = self.getFullName(parent, partial=name)
return name
def setText(self, text):
"""Display information about the current selection."""
# This method will likely be replaced by the enclosing app to
# do something more interesting, like write to a text control.
print text
def setStatusText(self, text):
"""Display status information."""
# This method will likely be replaced by the enclosing app to
# do something more interesting, like write to a status bar.
print text
class FillingText(editwindow.EditWindow):
"""FillingText based on StyledTextCtrl."""
name = 'Filling Text'
revision = __revision__
def __init__(self, parent, id=-1, pos=wx.DefaultPosition,
size=wx.DefaultSize, style=wx.CLIP_CHILDREN,
static=False):
"""Create FillingText instance."""
editwindow.EditWindow.__init__(self, parent, id, pos, size, style)
# Configure various defaults and user preferences.
self.SetReadOnly(True)
self.SetWrapMode(True)
self.SetMarginWidth(1, 0)
if not static:
dispatcher.connect(receiver=self.push, signal='Interpreter.push')
def push(self, command, more):
"""Receiver for Interpreter.push signal."""
self.Refresh()
def SetText(self, *args, **kwds):
self.SetReadOnly(False)
editwindow.EditWindow.SetText(self, *args, **kwds)
self.SetReadOnly(True)
class Filling(wx.SplitterWindow):
"""Filling based on wxSplitterWindow."""
name = 'Filling'
revision = __revision__
def __init__(self, parent, id=-1, pos=wx.DefaultPosition,
size=wx.DefaultSize, style=wx.SP_3D,
name='Filling Window', rootObject=None,
rootLabel=None, rootIsNamespace=False, static=False):
"""Create a Filling instance."""
wx.SplitterWindow.__init__(self, parent, id, pos, size, style, name)
self.tree = FillingTree(parent=self, rootObject=rootObject,
rootLabel=rootLabel,
rootIsNamespace=rootIsNamespace,
static=static)
self.text = FillingText(parent=self, static=static)
self.SplitVertically(self.tree, self.text, 130)
self.SetMinimumPaneSize(1)
# Override the filling so that descriptions go to FillingText.
self.tree.setText = self.text.SetText
# Display the root item.
## self.tree.SelectItem(self.tree.root)
self.tree.display()
class FillingFrame(wx.Frame):
"""Frame containing the namespace tree component."""
name = 'Filling Frame'
revision = __revision__
def __init__(self, parent=None, id=-1, title='PyFilling',
pos=wx.DefaultPosition, size=(600, 400),
style=wx.DEFAULT_FRAME_STYLE, rootObject=None,
rootLabel=None, rootIsNamespace=False, static=False):
"""Create FillingFrame instance."""
wx.Frame.__init__(self, parent, id, title, pos, size, style)
intro = 'PyFilling - The Tastiest Namespace Inspector'
self.CreateStatusBar()
self.SetStatusText(intro)
import images
self.SetIcon(images.getPyIcon())
self.filling = Filling(parent=self, rootObject=rootObject,
rootLabel=rootLabel,
rootIsNamespace=rootIsNamespace,
static=static)
# Override so that status messages go to the status bar.
self.filling.tree.setStatusText = self.SetStatusText
class App(wx.App):
"""PyFilling standalone application."""
def OnInit(self):
wx.InitAllImageHandlers()
self.fillingFrame = FillingFrame()
self.fillingFrame.Show(True)
self.SetTopWindow(self.fillingFrame)
return True

View File

@@ -1,354 +0,0 @@
"""Base frame with menu."""
__author__ = "Patrick K. O'Brien <pobrien@orbtech.com>"
__cvsid__ = "$Id$"
__revision__ = "$Revision$"[11:-2]
import wx
from version import VERSION
try:
True
except NameError:
True = 1==1
False = 1==0
ID_NEW = wx.ID_NEW
ID_OPEN = wx.ID_OPEN
ID_REVERT = wx.ID_REVERT
ID_CLOSE = wx.ID_CLOSE
ID_SAVE = wx.ID_SAVE
ID_SAVEAS = wx.ID_SAVEAS
ID_PRINT = wx.ID_PRINT
ID_EXIT = wx.ID_EXIT
ID_UNDO = wx.ID_UNDO
ID_REDO = wx.ID_REDO
ID_CUT = wx.ID_CUT
ID_COPY = wx.ID_COPY
ID_PASTE = wx.ID_PASTE
ID_CLEAR = wx.ID_CLEAR
ID_SELECTALL = wx.ID_SELECTALL
ID_ABOUT = wx.ID_ABOUT
ID_AUTOCOMP = wx.NewId()
ID_AUTOCOMP_SHOW = wx.NewId()
ID_AUTOCOMP_MAGIC = wx.NewId()
ID_AUTOCOMP_SINGLE = wx.NewId()
ID_AUTOCOMP_DOUBLE = wx.NewId()
ID_CALLTIPS = wx.NewId()
ID_CALLTIPS_SHOW = wx.NewId()
ID_COPY_PLUS = wx.NewId()
ID_NAMESPACE = wx.NewId()
ID_PASTE_PLUS = wx.NewId()
ID_WRAP = wx.NewId()
class Frame(wx.Frame):
"""Frame with standard menu items."""
revision = __revision__
def __init__(self, parent=None, id=-1, title='Editor',
pos=wx.DefaultPosition, size=wx.DefaultSize,
style=wx.DEFAULT_FRAME_STYLE):
"""Create a Frame instance."""
wx.Frame.__init__(self, parent, id, title, pos, size, style)
self.CreateStatusBar()
self.SetStatusText('Frame')
import images
self.SetIcon(images.getPyIcon())
self.__createMenus()
wx.EVT_CLOSE(self, self.OnClose)
def OnClose(self, event):
"""Event handler for closing."""
self.Destroy()
def __createMenus(self):
m = self.fileMenu = wx.Menu()
m.Append(ID_NEW, '&New \tCtrl+N',
'New file')
m.Append(ID_OPEN, '&Open... \tCtrl+O',
'Open file')
m.AppendSeparator()
m.Append(ID_REVERT, '&Revert \tCtrl+R',
'Revert to last saved version')
m.Append(ID_CLOSE, '&Close \tCtrl+W',
'Close file')
m.AppendSeparator()
m.Append(ID_SAVE, '&Save... \tCtrl+S',
'Save file')
m.Append(ID_SAVEAS, 'Save &As \tShift+Ctrl+S',
'Save file with new name')
m.AppendSeparator()
m.Append(ID_PRINT, '&Print... \tCtrl+P',
'Print file')
m.AppendSeparator()
m.Append(ID_NAMESPACE, '&Update Namespace \tShift+Ctrl+N',
'Update namespace for autocompletion and calltips')
m.AppendSeparator()
m.Append(ID_EXIT, 'E&xit', 'Exit Program')
m = self.editMenu = wx.Menu()
m.Append(ID_UNDO, '&Undo \tCtrl+Z',
'Undo the last action')
m.Append(ID_REDO, '&Redo \tCtrl+Y',
'Redo the last undone action')
m.AppendSeparator()
m.Append(ID_CUT, 'Cu&t \tCtrl+X',
'Cut the selection')
m.Append(ID_COPY, '&Copy \tCtrl+C',
'Copy the selection')
m.Append(ID_COPY_PLUS, 'Cop&y Plus \tShift+Ctrl+C',
'Copy the selection - retaining prompts')
m.Append(ID_PASTE, '&Paste \tCtrl+V', 'Paste from clipboard')
m.Append(ID_PASTE_PLUS, 'Past&e Plus \tShift+Ctrl+V',
'Paste and run commands')
m.AppendSeparator()
m.Append(ID_CLEAR, 'Cle&ar',
'Delete the selection')
m.Append(ID_SELECTALL, 'Select A&ll \tCtrl+A',
'Select all text')
m = self.autocompMenu = wx.Menu()
m.Append(ID_AUTOCOMP_SHOW, 'Show Auto Completion',
'Show auto completion list', 1)
m.Append(ID_AUTOCOMP_MAGIC, 'Include Magic Attributes',
'Include attributes visible to __getattr__ and __setattr__',
1)
m.Append(ID_AUTOCOMP_SINGLE, 'Include Single Underscores',
'Include attibutes prefixed by a single underscore', 1)
m.Append(ID_AUTOCOMP_DOUBLE, 'Include Double Underscores',
'Include attibutes prefixed by a double underscore', 1)
m = self.calltipsMenu = wx.Menu()
m.Append(ID_CALLTIPS_SHOW, 'Show Call Tips',
'Show call tips with argument signature and docstring', 1)
m = self.optionsMenu = wx.Menu()
m.AppendMenu(ID_AUTOCOMP, '&Auto Completion', self.autocompMenu,
'Auto Completion Options')
m.AppendMenu(ID_CALLTIPS, '&Call Tips', self.calltipsMenu,
'Call Tip Options')
m.Append(ID_WRAP, '&Wrap Lines',
'Wrap lines at right edge', 1)
m = self.helpMenu = wx.Menu()
m.AppendSeparator()
m.Append(ID_ABOUT, '&About...', 'About this program')
b = self.menuBar = wx.MenuBar()
b.Append(self.fileMenu, '&File')
b.Append(self.editMenu, '&Edit')
b.Append(self.optionsMenu, '&Options')
b.Append(self.helpMenu, '&Help')
self.SetMenuBar(b)
wx.EVT_MENU(self, ID_NEW, self.OnFileNew)
wx.EVT_MENU(self, ID_OPEN, self.OnFileOpen)
wx.EVT_MENU(self, ID_REVERT, self.OnFileRevert)
wx.EVT_MENU(self, ID_CLOSE, self.OnFileClose)
wx.EVT_MENU(self, ID_SAVE, self.OnFileSave)
wx.EVT_MENU(self, ID_SAVEAS, self.OnFileSaveAs)
wx.EVT_MENU(self, ID_NAMESPACE, self.OnFileUpdateNamespace)
wx.EVT_MENU(self, ID_PRINT, self.OnFilePrint)
wx.EVT_MENU(self, ID_EXIT, self.OnExit)
wx.EVT_MENU(self, ID_UNDO, self.OnUndo)
wx.EVT_MENU(self, ID_REDO, self.OnRedo)
wx.EVT_MENU(self, ID_CUT, self.OnCut)
wx.EVT_MENU(self, ID_COPY, self.OnCopy)
wx.EVT_MENU(self, ID_COPY_PLUS, self.OnCopyPlus)
wx.EVT_MENU(self, ID_PASTE, self.OnPaste)
wx.EVT_MENU(self, ID_PASTE_PLUS, self.OnPastePlus)
wx.EVT_MENU(self, ID_CLEAR, self.OnClear)
wx.EVT_MENU(self, ID_SELECTALL, self.OnSelectAll)
wx.EVT_MENU(self, ID_ABOUT, self.OnAbout)
wx.EVT_MENU(self, ID_AUTOCOMP_SHOW, self.OnAutoCompleteShow)
wx.EVT_MENU(self, ID_AUTOCOMP_MAGIC, self.OnAutoCompleteMagic)
wx.EVT_MENU(self, ID_AUTOCOMP_SINGLE, self.OnAutoCompleteSingle)
wx.EVT_MENU(self, ID_AUTOCOMP_DOUBLE, self.OnAutoCompleteDouble)
wx.EVT_MENU(self, ID_CALLTIPS_SHOW, self.OnCallTipsShow)
wx.EVT_MENU(self, ID_WRAP, self.OnWrap)
wx.EVT_UPDATE_UI(self, ID_NEW, self.OnUpdateMenu)
wx.EVT_UPDATE_UI(self, ID_OPEN, self.OnUpdateMenu)
wx.EVT_UPDATE_UI(self, ID_REVERT, self.OnUpdateMenu)
wx.EVT_UPDATE_UI(self, ID_CLOSE, self.OnUpdateMenu)
wx.EVT_UPDATE_UI(self, ID_SAVE, self.OnUpdateMenu)
wx.EVT_UPDATE_UI(self, ID_SAVEAS, self.OnUpdateMenu)
wx.EVT_UPDATE_UI(self, ID_NAMESPACE, self.OnUpdateMenu)
wx.EVT_UPDATE_UI(self, ID_PRINT, self.OnUpdateMenu)
wx.EVT_UPDATE_UI(self, ID_UNDO, self.OnUpdateMenu)
wx.EVT_UPDATE_UI(self, ID_REDO, self.OnUpdateMenu)
wx.EVT_UPDATE_UI(self, ID_CUT, self.OnUpdateMenu)
wx.EVT_UPDATE_UI(self, ID_COPY, self.OnUpdateMenu)
wx.EVT_UPDATE_UI(self, ID_COPY_PLUS, self.OnUpdateMenu)
wx.EVT_UPDATE_UI(self, ID_PASTE, self.OnUpdateMenu)
wx.EVT_UPDATE_UI(self, ID_PASTE_PLUS, self.OnUpdateMenu)
wx.EVT_UPDATE_UI(self, ID_CLEAR, self.OnUpdateMenu)
wx.EVT_UPDATE_UI(self, ID_SELECTALL, self.OnUpdateMenu)
wx.EVT_UPDATE_UI(self, ID_AUTOCOMP_SHOW, self.OnUpdateMenu)
wx.EVT_UPDATE_UI(self, ID_AUTOCOMP_MAGIC, self.OnUpdateMenu)
wx.EVT_UPDATE_UI(self, ID_AUTOCOMP_SINGLE, self.OnUpdateMenu)
wx.EVT_UPDATE_UI(self, ID_AUTOCOMP_DOUBLE, self.OnUpdateMenu)
wx.EVT_UPDATE_UI(self, ID_CALLTIPS_SHOW, self.OnUpdateMenu)
wx.EVT_UPDATE_UI(self, ID_WRAP, self.OnUpdateMenu)
def OnFileNew(self, event):
self.bufferNew()
def OnFileOpen(self, event):
self.bufferOpen()
def OnFileRevert(self, event):
self.bufferRevert()
def OnFileClose(self, event):
self.bufferClose()
def OnFileSave(self, event):
self.bufferSave()
def OnFileSaveAs(self, event):
self.bufferSaveAs()
def OnFileUpdateNamespace(self, event):
self.updateNamespace()
def OnFilePrint(self, event):
self.bufferPrint()
def OnExit(self, event):
self.Close(False)
def OnUndo(self, event):
win = wx.Window_FindFocus()
win.Undo()
def OnRedo(self, event):
win = wx.Window_FindFocus()
win.Redo()
def OnCut(self, event):
win = wx.Window_FindFocus()
win.Cut()
def OnCopy(self, event):
win = wx.Window_FindFocus()
win.Copy()
def OnCopyPlus(self, event):
win = wx.Window_FindFocus()
win.CopyWithPrompts()
def OnPaste(self, event):
win = wx.Window_FindFocus()
win.Paste()
def OnPastePlus(self, event):
win = wx.Window_FindFocus()
win.PasteAndRun()
def OnClear(self, event):
win = wx.Window_FindFocus()
win.Clear()
def OnSelectAll(self, event):
win = wx.Window_FindFocus()
win.SelectAll()
def OnAbout(self, event):
"""Display an About window."""
title = 'About'
text = 'Your message here.'
dialog = wx.MessageDialog(self, text, title,
wx.OK | wx.ICON_INFORMATION)
dialog.ShowModal()
dialog.Destroy()
def OnAutoCompleteShow(self, event):
win = wx.Window_FindFocus()
win.autoComplete = event.IsChecked()
def OnAutoCompleteMagic(self, event):
win = wx.Window_FindFocus()
win.autoCompleteIncludeMagic = event.IsChecked()
def OnAutoCompleteSingle(self, event):
win = wx.Window_FindFocus()
win.autoCompleteIncludeSingle = event.IsChecked()
def OnAutoCompleteDouble(self, event):
win = wx.Window_FindFocus()
win.autoCompleteIncludeDouble = event.IsChecked()
def OnCallTipsShow(self, event):
win = wx.Window_FindFocus()
win.autoCallTip = event.IsChecked()
def OnWrap(self, event):
win = wx.Window_FindFocus()
win.SetWrapMode(event.IsChecked())
def OnUpdateMenu(self, event):
"""Update menu items based on current status and context."""
win = wx.Window_FindFocus()
id = event.GetId()
event.Enable(True)
try:
if id == ID_NEW:
event.Enable(hasattr(self, 'bufferNew'))
elif id == ID_OPEN:
event.Enable(hasattr(self, 'bufferOpen'))
elif id == ID_REVERT:
event.Enable(hasattr(self, 'bufferRevert')
and self.hasBuffer())
elif id == ID_CLOSE:
event.Enable(hasattr(self, 'bufferClose')
and self.hasBuffer())
elif id == ID_SAVE:
event.Enable(hasattr(self, 'bufferSave')
and self.bufferHasChanged())
elif id == ID_SAVEAS:
event.Enable(hasattr(self, 'bufferSaveAs')
and self.hasBuffer())
elif id == ID_NAMESPACE:
event.Enable(hasattr(self, 'updateNamespace')
and self.hasBuffer())
elif id == ID_PRINT:
event.Enable(hasattr(self, 'bufferPrint')
and self.hasBuffer())
elif id == ID_UNDO:
event.Enable(win.CanUndo())
elif id == ID_REDO:
event.Enable(win.CanRedo())
elif id == ID_CUT:
event.Enable(win.CanCut())
elif id == ID_COPY:
event.Enable(win.CanCopy())
elif id == ID_COPY_PLUS:
event.Enable(win.CanCopy() and hasattr(win, 'CopyWithPrompts'))
elif id == ID_PASTE:
event.Enable(win.CanPaste())
elif id == ID_PASTE_PLUS:
event.Enable(win.CanPaste() and hasattr(win, 'PasteAndRun'))
elif id == ID_CLEAR:
event.Enable(win.CanCut())
elif id == ID_SELECTALL:
event.Enable(hasattr(win, 'SelectAll'))
elif id == ID_AUTOCOMP_SHOW:
event.Check(win.autoComplete)
elif id == ID_AUTOCOMP_MAGIC:
event.Check(win.autoCompleteIncludeMagic)
elif id == ID_AUTOCOMP_SINGLE:
event.Check(win.autoCompleteIncludeSingle)
elif id == ID_AUTOCOMP_DOUBLE:
event.Check(win.autoCompleteIncludeDouble)
elif id == ID_CALLTIPS_SHOW:
event.Check(win.autoCallTip)
elif id == ID_WRAP:
event.Check(win.GetWrapMode())
else:
event.Enable(False)
except AttributeError:
# This menu option is not supported in the current context.
event.Enable(False)

View File

@@ -1,72 +0,0 @@
"""Support for icons."""
__author__ = "Patrick K. O'Brien <pobrien@orbtech.com>"
__cvsid__ = "$Id$"
__revision__ = "$Revision$"[11:-2]
import wx
import cStringIO
def getPyIcon():
icon = wx.EmptyIcon()
icon.CopyFromBitmap(getPyBitmap())
return icon
def getPyBitmap():
return wx.BitmapFromImage(getPyImage())
def getPyImage():
stream = cStringIO.StringIO(getPyData())
return wx.ImageFromStream(stream)
def getPyData():
return \
'\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00 \x00\x00\x00 \x08\x06\x00\
\x00\x00szz\xf4\x00\x00\x00\x04sBIT\x08\x08\x08\x08|\x08d\x88\x00\x00\x04\
\x95IDATx\x9c\xed\x97?lSG\x1c\xc7?\x97\x98\xd8Q\xa3\xdeY\xa2j\x06\xa4\xf7"QJ\
\xbb<3@\x01\xa9\xc2\x0c\xa8!\x1d\x1c6\xcaB\xa8D[uI2\xf4\x8f\xe8\x103\xb4\xa2\
,5\x0b\x03\x032C\xab\xc0\x92dh:t\xc0)*E\xcd@<Q\x01Rl\t\xd4D\xaa\xe4{R\xd0{&\
\xa5\xd7\xe1\xfc\xec\xe7\xfciR\x08e\xe9O\xb2\xee|\xfe\xbd\xfb}~\xdf\xdf\xbd\
\xbb\xb3PJ\xf1"\xad\xe3\x85F\xff\x1f\xe0y\x03h\xad\xcdA\xc7~\xb4\xd6f-\x9f\
\xc4\xf3\x0c>Y\x1c#\x97\xddCUk\xf4B\x8d3\x9f\x8d\x9a\x9bU%\xe2~b\xab\xdf\x82\
\x83N+\xd3\xe92\\\x1f\xcf\x93\xdd\x9f\xa1\xaa5\x95\xf9\n\xe7\xf3y\xe2\x10[V\
\x82H\xe6\xd3G\x1dN\xf7\xc3\xa7\xc7a\xc0\x83\xc3\xc7\xf3\xcc\xcc\xcd\xe3(\
\x85\xdb\xe7\xf2\xc9\xe8X\x1b\xe43+\x10\xd5\xb6\x94\x87Z\xe8\x90NU\x91I@\x00\
\x06\xbe\x18\xb7J\x98\xca$`\x98\xb9]&{,\x8fRV\x85\xa7V@k\x9bq)o\x83+\t\xe9T\
\xd5f\x95\x02\x91\xb4~_\r\xd9\xb6\xbaP\x03\x04n\x9f\xcbDa\xb8\t\xfe\xaf\x17a\
<\xe3\xc8\x94lo\x9b\xd6\xa8\xf4\x80\x07\xb7o\xcd\xe0\x0c\x0e\xa2R\x8a\xb4\
\x93n\xbal\x1a`e\xe0U\xc1\xd6\xb0\xb8\n\x99\x91"\x93\xaf\xba\xe4\x0ed\xda|6,\
\x81\xd6\xda\x9c|\xab]\xea\xcd\x04\x8f\x9b\t\xad\nz\xa1\x02\x80\xdb\xe7R\x1a\
\xcf\xa3\xb56\xeb\x02D5\x9e\xf8\xdc\xe1T\xff\xd3\x05\x8e\x82\x83U\xe1Z\xb1\
\x18\x9b\xbf\x06\xacQ\x82H\xea\x01/Z@Ut\x08R\xb4$}\x16\xd3\x81A&%\xde\xee\
\xbev\x80x\xe0]{\xb2\x1cR\xa5\xe6C*\xb5\xf1\xc4Q\xa6"e\xfbQ\x1b\x8dE\xe6\x87\
>\xaa[Q\xadi\x0b\xb0r\x8f\x9e.\xc3t\xb9\xc4]\xaf5\xf6\xfe\xdb\xddt&\x02\xfa\
\x9c\xf5\x01\xe2A\xa2\xbeX\x01>]ntR\x12\xe3[\x00\x01\x98\x89\x11[_\xed\xafn\
\xab\x81U\xa0\xe7I7\x00\x97o\x04\xcd\x89\x06<;\xe9\x80\x07]i\x97\xc17\x1f\
\xd2\xd3\x91`\xe9\xaf?\x01p^Y\x06Z\n\xfau8?a\xfb]i\x97\xec\xa1\x8c\x05(|\xd8\
N\xba\xb3\xab\x87\xfb\x8f\x97\xd8\xd9\xd5\x03\xc0\xfd\xc7K\xec\xd8\xd6\xdd\
\xfc\xfd\xc1r\xd0\xf4\x01\xda~\x03H\xf4\x04\xd4j :\xb75\xc7\xae\xfd\xbcLW\
\xda\xa5\xf0M\x1e\t\xcc\xcc\xcdq\xa9P@\x8c\xf5fL\xdaHF\x16g\x9a\x19\xad\xcc\
\xee\xcb\xa3\n\xad\xa1\xda\xf1\x08\xef\xe5\x97x\xf8\xc8f\xf8\xc7\x93:\xdb;\
\x93M\xc8\x08j\xc7\xb6n\x1e,\x07m`\x97o\x04|;>\xd1T\xc4\x17\x8a\x13\xb9\xc3\
\x88\x01\x0fs\xa4\x9cc}\xf3A\x190\x82\x1f\xddR{-\x1bV\xfc\xd8f\xba\xbd3\xd9\
\x06\x15\x07\xbb\xf8\xd3\x12\xdf]-"\x93\xb2\xb1C*\xde\xcd\x1d\xde\xccN(\xc1\
\xae\x17"\xd0#+<j\x17m{\xcd\x9bj\x00.\xaf\xf0Xb\xb8\xdfA\xa6\x14\x18\x03\x06\
\xb4o\xcf\x8d\xc4\xbervc\x86M\xdaz\x80\x00\x95T\x19?\xd0 @&%~c\xbc\xe3W\xaf\
\xb4e\x00\xffh\xc6@\xbd\x11\xbc\xde\x1a\xfe\xef.\xa5\xa2q4\n0\x81\xad\xe9\
\xae7<\x12\xaf\xf5\xc2hy\xaa\xe97\x9cS\\\x98\xb2\x0e\x03\xb1\xcdhW\xdaC\x1a\
\xa0\xa2\xa0\x0e"\x14`\xb0Y\x85\x1b\x1f\x12\xaa7\x03)\xd9\x84\xa8\xccW\xb8{\
\xa7L\xe2\xde\x02\x94\xc6Gp_\xcf\x80\x90\x98\xd0g\xf4\xac\x82Pc\x82\x1a\xd5\
\x10\x08}&\xa7J\xcc\xde.1]m\x80\xf6+\xee\xfd\xae\x9bo\xc4\xf0;\x80\xef\x90\
\x0e\x04\x06`Q!\x02\x05\xc2 \xb5\xc2\x95\x15d\xb4C&[\xf7\xd2\x04\x80\xbb\xdb\
\x9e\xd1\x8e\x02\x90\xd8\xd4$ I\x87\x80\xf1\xf1\xdc!4\xc3\x88\x94}\xd8,TH\
\xbb.5m\xf0C\x9f3\x1f\r\x01\x96.\x82\x1a9\xe9Q\xb8\xd2\xf8\xf25\x0c\xbe\xe7#\
\x92\x12\x1d[\x03\t\x00E\xf4\xa6\t\xaaZ7`$\x18\x90\xf8\xf8\x80JK\x94\xa1\x01\
\x07\xb8\x0e~X\xc3\xed\x16\xf8)\xf8~j\x12B\rI\x89_\xf7!0 \x04\xf9Q\xc0\x18\
\x0c\xd1i\xea\x13\xb7\x04\xc0\x89\x93C\xabj\xb6\xf7@\x96\xd9_J|0:\x86R\n\xb7\
\xd7@\xaa%\x9d\xa3$\xba.\x90RA]\xe3\x87\x1a\x89\xdd\xefeR\xc2\x1a\'\xa8\x1f\
\x82\x0e-@m\xd1\xde\x076\xbc\x15\x97~(\x9a\x89b\x9e\xd9[s\xab!\xf7g\xd6\x1c\
\x8f\xdb\xbel\x8e\xa1S\xc7\xda\xc6\xe6\xee\xccs\xe9\xdcYnV\x95\xd8\xf2?&q+\
\x9c\x1b1\xf3\xbf\xcd3{\xfdJ\xdb\xf8\xde\xfd\x19.\\\xad\x08\x80\xbf\x01\xd1\
\x86\xfa\x8b\xc7\xc0\xc8\xb7\x00\x00\x00\x00IEND\xaeB`\x82'

View File

@@ -1,125 +0,0 @@
"""Interpreter executes Python commands."""
__author__ = "Patrick K. O'Brien <pobrien@orbtech.com>"
__cvsid__ = "$Id$"
__revision__ = "$Revision$"[11:-2]
import os
import sys
from code import InteractiveInterpreter
import dispatcher
import introspect
try:
True
except NameError:
True = 1==1
False = 1==0
class Interpreter(InteractiveInterpreter):
"""Interpreter based on code.InteractiveInterpreter."""
revision = __revision__
def __init__(self, locals=None, rawin=None,
stdin=sys.stdin, stdout=sys.stdout, stderr=sys.stderr):
"""Create an interactive interpreter object."""
InteractiveInterpreter.__init__(self, locals=locals)
self.stdin = stdin
self.stdout = stdout
self.stderr = stderr
if rawin:
import __builtin__
__builtin__.raw_input = rawin
del __builtin__
copyright = 'Type "help", "copyright", "credits" or "license"'
copyright += ' for more information.'
self.introText = 'Python %s on %s%s%s' % \
(sys.version, sys.platform, os.linesep, copyright)
try:
sys.ps1
except AttributeError:
sys.ps1 = '>>> '
try:
sys.ps2
except AttributeError:
sys.ps2 = '... '
self.more = 0
# List of lists to support recursive push().
self.commandBuffer = []
self.startupScript = os.environ.get('PYTHONSTARTUP')
def push(self, command):
"""Send command to the interpreter to be executed.
Because this may be called recursively, we append a new list
onto the commandBuffer list and then append commands into
that. If the passed in command is part of a multi-line
command we keep appending the pieces to the last list in
commandBuffer until we have a complete command. If not, we
delete that last list."""
command = str(command) # In case the command is unicode.
if not self.more:
try: del self.commandBuffer[-1]
except IndexError: pass
if not self.more: self.commandBuffer.append([])
self.commandBuffer[-1].append(command)
source = '\n'.join(self.commandBuffer[-1])
more = self.more = self.runsource(source)
dispatcher.send(signal='Interpreter.push', sender=self,
command=command, more=more, source=source)
return more
def runsource(self, source):
"""Compile and run source code in the interpreter."""
stdin, stdout, stderr = sys.stdin, sys.stdout, sys.stderr
sys.stdin, sys.stdout, sys.stderr = \
self.stdin, self.stdout, self.stderr
more = InteractiveInterpreter.runsource(self, source)
# If sys.std* is still what we set it to, then restore it.
# But, if the executed source changed sys.std*, assume it was
# meant to be changed and leave it. Power to the people.
if sys.stdin == self.stdin:
sys.stdin = stdin
if sys.stdout == self.stdout:
sys.stdout = stdout
if sys.stderr == self.stderr:
sys.stderr = stderr
return more
def getAutoCompleteKeys(self):
"""Return list of auto-completion keycodes."""
return [ord('.')]
def getAutoCompleteList(self, command='', *args, **kwds):
"""Return list of auto-completion options for a command.
The list of options will be based on the locals namespace."""
stdin, stdout, stderr = sys.stdin, sys.stdout, sys.stderr
sys.stdin, sys.stdout, sys.stderr = \
self.stdin, self.stdout, self.stderr
l = introspect.getAutoCompleteList(command, self.locals,
*args, **kwds)
sys.stdin, sys.stdout, sys.stderr = stdin, stdout, stderr
return l
def getCallTip(self, command='', *args, **kwds):
"""Return call tip text for a command.
Call tip information will be based on the locals namespace."""
return introspect.getCallTip(command, self.locals, *args, **kwds)
class InterpreterAlaCarte(Interpreter):
"""Demo Interpreter."""
def __init__(self, locals, rawin, stdin, stdout, stderr,
ps1='main prompt', ps2='continuation prompt'):
"""Create an interactive interpreter object."""
Interpreter.__init__(self, locals=locals, rawin=rawin,
stdin=stdin, stdout=stdout, stderr=stderr)
sys.ps1 = ps1
sys.ps2 = ps2

View File

@@ -1,363 +0,0 @@
"""Provides a variety of introspective-type support functions for
things like call tips and command auto completion."""
__author__ = "Patrick K. O'Brien <pobrien@orbtech.com>"
__cvsid__ = "$Id$"
__revision__ = "$Revision$"[11:-2]
from __future__ import nested_scopes
import cStringIO
import inspect
import sys
import tokenize
import types
try:
True
except NameError:
True = 1==1
False = 1==0
def getAutoCompleteList(command='', locals=None, includeMagic=1,
includeSingle=1, includeDouble=1):
"""Return list of auto-completion options for command.
The list of options will be based on the locals namespace."""
attributes = []
# Get the proper chunk of code from the command.
root = getRoot(command, terminator='.')
try:
if locals is not None:
object = eval(root, locals)
else:
object = eval(root)
except:
pass
else:
attributes = getAttributeNames(object, includeMagic,
includeSingle, includeDouble)
return attributes
def getAttributeNames(object, includeMagic=1, includeSingle=1,
includeDouble=1):
"""Return list of unique attributes, including inherited, for object."""
attributes = []
dict = {}
if not hasattrAlwaysReturnsTrue(object):
# Add some attributes that don't always get picked up. If
# they don't apply, they'll get filtered out at the end.
attributes += ['__bases__', '__class__', '__dict__', '__name__',
'func_closure', 'func_code', 'func_defaults',
'func_dict', 'func_doc', 'func_globals', 'func_name']
if includeMagic:
try: attributes += object._getAttributeNames()
except: pass
# Get all attribute names.
attrdict = getAllAttributeNames(object)
for attrlist in attrdict.values():
attributes += attrlist
# Remove duplicates from the attribute list.
for item in attributes:
dict[item] = None
attributes = dict.keys()
attributes.sort(lambda x, y: cmp(x.upper(), y.upper()))
if not includeSingle:
attributes = filter(lambda item: item[0]!='_' \
or item[1]=='_', attributes)
if not includeDouble:
attributes = filter(lambda item: item[:2]!='__', attributes)
# Make sure we haven't picked up any bogus attributes somehow.
attributes = [attribute for attribute in attributes \
if hasattr(object, attribute)]
return attributes
def hasattrAlwaysReturnsTrue(object):
return hasattr(object, 'bogu5_123_aTTri8ute')
def getAllAttributeNames(object):
"""Return dict of all attributes, including inherited, for an object.
Recursively walk through a class and all base classes.
"""
attrdict = {} # (object, technique, count): [list of attributes]
# !!!
# Do Not use hasattr() as a test anywhere in this function,
# because it is unreliable with remote objects: xmlrpc, soap, etc.
# They always return true for hasattr().
# !!!
try:
# Yes, this can fail if object is an instance of a class with
# __str__ (or __repr__) having a bug or raising an
# exception. :-(
key = str(object)
except:
key = 'anonymous'
# Wake up sleepy objects - a hack for ZODB objects in "ghost" state.
wakeupcall = dir(object)
del wakeupcall
# Get attributes available through the normal convention.
attributes = dir(object)
attrdict[(key, 'dir', len(attributes))] = attributes
# Get attributes from the object's dictionary, if it has one.
try:
attributes = object.__dict__.keys()
attributes.sort()
except: # Must catch all because object might have __getattr__.
pass
else:
attrdict[(key, '__dict__', len(attributes))] = attributes
# For a class instance, get the attributes for the class.
try:
klass = object.__class__
except: # Must catch all because object might have __getattr__.
pass
else:
if klass is object:
# Break a circular reference. This happens with extension
# classes.
pass
else:
attrdict.update(getAllAttributeNames(klass))
# Also get attributes from any and all parent classes.
try:
bases = object.__bases__
except: # Must catch all because object might have __getattr__.
pass
else:
if isinstance(bases, types.TupleType):
for base in bases:
if type(base) is types.TypeType:
# Break a circular reference. Happens in Python 2.2.
pass
else:
attrdict.update(getAllAttributeNames(base))
return attrdict
def getCallTip(command='', locals=None):
"""For a command, return a tuple of object name, argspec, tip text.
The call tip information will be based on the locals namespace."""
calltip = ('', '', '') # object name, argspec, tip text.
# Get the proper chunk of code from the command.
root = getRoot(command, terminator='(')
try:
if locals is not None:
object = eval(root, locals)
else:
object = eval(root)
except:
return calltip
name = ''
object, dropSelf = getBaseObject(object)
try:
name = object.__name__
except AttributeError:
pass
tip1 = ''
argspec = ''
if inspect.isbuiltin(object):
# Builtin functions don't have an argspec that we can get.
pass
elif inspect.isfunction(object):
# tip1 is a string like: "getCallTip(command='', locals=None)"
argspec = apply(inspect.formatargspec, inspect.getargspec(object))
if dropSelf:
# The first parameter to a method is a reference to an
# instance, usually coded as "self", and is usually passed
# automatically by Python; therefore we want to drop it.
temp = argspec.split(',')
if len(temp) == 1: # No other arguments.
argspec = '()'
else: # Drop the first argument.
argspec = '(' + ','.join(temp[1:]).lstrip()
tip1 = name + argspec
doc = ''
if callable(object):
try:
doc = inspect.getdoc(object)
except:
pass
if doc:
# tip2 is the first separated line of the docstring, like:
# "Return call tip text for a command."
# tip3 is the rest of the docstring, like:
# "The call tip information will be based on ... <snip>
firstline = doc.split('\n')[0].lstrip()
if tip1 == firstline:
tip1 = ''
else:
tip1 += '\n\n'
docpieces = doc.split('\n\n')
tip2 = docpieces[0]
tip3 = '\n\n'.join(docpieces[1:])
tip = '%s%s\n\n%s' % (tip1, tip2, tip3)
else:
tip = tip1
calltip = (name, argspec[1:-1], tip.strip())
return calltip
def getRoot(command, terminator=None):
"""Return the rightmost root portion of an arbitrary Python command.
Return only the root portion that can be eval()'d without side
effects. The command would normally terminate with a '(' or
'.'. The terminator and anything after the terminator will be
dropped."""
command = command.split('\n')[-1]
if command.startswith(sys.ps2):
command = command[len(sys.ps2):]
command = command.lstrip()
command = rtrimTerminus(command, terminator)
tokens = getTokens(command)
if not tokens:
return ''
if tokens[-1][0] is tokenize.ENDMARKER:
# Remove the end marker.
del tokens[-1]
if not tokens:
return ''
if terminator == '.' and \
(tokens[-1][1] <> '.' or tokens[-1][0] is not tokenize.OP):
# Trap decimals in numbers, versus the dot operator.
return ''
else:
# Strip off the terminator.
if terminator and command.endswith(terminator):
size = 0 - len(terminator)
command = command[:size]
command = command.rstrip()
tokens = getTokens(command)
tokens.reverse()
line = ''
start = None
prefix = ''
laststring = '.'
emptyTypes = ('[]', '()', '{}')
for token in tokens:
tokentype = token[0]
tokenstring = token[1]
line = token[4]
if tokentype is tokenize.ENDMARKER:
continue
if tokentype in (tokenize.NAME, tokenize.STRING, tokenize.NUMBER) \
and laststring != '.':
# We've reached something that's not part of the root.
if prefix and line[token[3][1]] != ' ':
# If it doesn't have a space after it, remove the prefix.
prefix = ''
break
if tokentype in (tokenize.NAME, tokenize.STRING, tokenize.NUMBER) \
or (tokentype is tokenize.OP and tokenstring == '.'):
if prefix:
# The prefix isn't valid because it comes after a dot.
prefix = ''
break
else:
# start represents the last known good point in the line.
start = token[2][1]
elif len(tokenstring) == 1 and tokenstring in ('[({])}'):
# Remember, we're working backwords.
# So prefix += tokenstring would be wrong.
if prefix in emptyTypes and tokenstring in ('[({'):
# We've already got an empty type identified so now we
# are in a nested situation and we can break out with
# what we've got.
break
else:
prefix = tokenstring + prefix
else:
# We've reached something that's not part of the root.
break
laststring = tokenstring
if start is None:
start = len(line)
root = line[start:]
if prefix in emptyTypes:
# Empty types are safe to be eval()'d and introspected.
root = prefix + root
return root
def getTokens(command):
"""Return list of token tuples for command."""
command = str(command) # In case the command is unicode, which fails.
f = cStringIO.StringIO(command)
# tokens is a list of token tuples, each looking like:
# (type, string, (srow, scol), (erow, ecol), line)
tokens = []
# Can't use list comprehension:
# tokens = [token for token in tokenize.generate_tokens(f.readline)]
# because of need to append as much as possible before TokenError.
try:
## This code wasn't backward compatible with Python 2.1.3.
##
## for token in tokenize.generate_tokens(f.readline):
## tokens.append(token)
# This works with Python 2.1.3 (with nested_scopes).
def eater(*args):
tokens.append(args)
tokenize.tokenize_loop(f.readline, eater)
except tokenize.TokenError:
# This is due to a premature EOF, which we expect since we are
# feeding in fragments of Python code.
pass
return tokens
def rtrimTerminus(command, terminator=None):
"""Return command minus anything that follows the final terminator."""
if terminator:
pieces = command.split(terminator)
if len(pieces) > 1:
command = terminator.join(pieces[:-1]) + terminator
return command
def getBaseObject(object):
"""Return base object and dropSelf indicator for an object."""
if inspect.isbuiltin(object):
# Builtin functions don't have an argspec that we can get.
dropSelf = 0
elif inspect.ismethod(object):
# Get the function from the object otherwise
# inspect.getargspec() complains that the object isn't a
# Python function.
try:
if object.im_self is None:
# This is an unbound method so we do not drop self
# from the argspec, since an instance must be passed
# as the first arg.
dropSelf = 0
else:
dropSelf = 1
object = object.im_func
except AttributeError:
dropSelf = 0
elif inspect.isclass(object):
# Get the __init__ method function for the class.
constructor = getConstructor(object)
if constructor is not None:
object = constructor
dropSelf = 1
else:
dropSelf = 0
elif callable(object):
# Get the __call__ method instead.
try:
object = object.__call__.im_func
dropSelf = 1
except AttributeError:
dropSelf = 0
else:
dropSelf = 0
return object, dropSelf
def getConstructor(object):
"""Return constructor for class object, or None if there isn't one."""
try:
return object.__init__.im_func
except AttributeError:
for base in object.__bases__:
constructor = getConstructor(base)
if constructor is not None:
return constructor
return None

View File

@@ -1,107 +0,0 @@
"""Provides a variety of classes to create pseudo keywords and pseudo files."""
__author__ = "Patrick K. O'Brien <pobrien@orbtech.com>"
__cvsid__ = "$Id$"
__revision__ = "$Revision$"[11:-2]
try:
True
except NameError:
True = 1==1
False = 1==0
class PseudoKeyword:
"""A callable class that calls a method passed as a parameter.
Good for creating a pseudo keyword in the python runtime
environment. The keyword is really an object that has a repr()
that calls itself which calls the method that was passed in the
init of the object. All this just to avoid having to type in the
closing parens on a method. So, for example:
>>> quit = PseudoKeyword(SomeObject.someMethod)
>>> quit
SomeObject.someMethod gets executed as if it had been called
directly and the user didn't have to type the parens, like
'quit()'. This technique is most applicable for pseudo keywords
like quit, exit and help.
If SomeObject.someMethod can take parameters, they can still be
passed by using the keyword in the traditional way with parens."""
def __init__(self, method):
"""Create a callable object that executes method when called."""
if callable(method):
self.method = method
else:
raise ValueError, 'method must be callable'
def __call__(self, *args, **kwds):
self.method(*args, **kwds)
def __repr__(self):
self()
return ''
class PseudoFile:
def __init__(self):
"""Create a file-like object."""
pass
def readline(self):
pass
def write(self, s):
pass
def writelines(self, l):
map(self.write, l)
def flush(self):
pass
def isatty(self):
pass
class PseudoFileIn(PseudoFile):
def __init__(self, readline, readlines=None):
if callable(readline):
self.readline = readline
else:
raise ValueError, 'readline must be callable'
if callable(readlines):
self.readlines = readlines
def isatty(self):
return 1
class PseudoFileOut(PseudoFile):
def __init__(self, write):
if callable(write):
self.write = write
else:
raise ValueError, 'write must be callable'
def isatty(self):
return 1
class PseudoFileErr(PseudoFile):
def __init__(self, write):
if callable(write):
self.write = write
else:
raise ValueError, 'write must be callable'
def isatty(self):
return 1

File diff suppressed because it is too large Load Diff

View File

@@ -1,82 +0,0 @@
#!/usr/bin/env python
__author__ = "Patrick K. O'Brien <pobrien@orbtech.com>"
__cvsid__ = "$Id$"
__revision__ = "$Revision$"[11:-2]
import unittest
# Import from this module's parent directory.
import os
import sys
sys.path.insert(0, os.pardir)
import interpreter
del sys.path[0]
del sys
del os
"""
These unittest methods are preferred:
-------------------------------------
self.assert_(expr, msg=None)
self.assertEqual(first, second, msg=None)
self.assertRaises(excClass, callableObj, *args, **kwargs)
self.fail(msg=None)
self.failIf(expr, msg=None)
"""
class ModuleTestCase(unittest.TestCase):
def test_module(self):
module = interpreter
self.assert_(module.__author__)
self.assert_(module.__cvsid__)
self.assert_(module.__revision__)
self.assert_(module.Interpreter)
self.assert_(module.Interpreter.push)
self.assert_(module.Interpreter.runsource)
self.assert_(module.Interpreter.getAutoCompleteList)
self.assert_(module.Interpreter.getCallTip)
self.assert_(module.InterpreterAlaCarte)
class InterpreterTestCase(unittest.TestCase):
def setUp(self):
self.output = ''
self.i = interpreter.Interpreter(stdout=self)
def write(self, text):
"""Capture output from self.i.push()."""
self.output += text
def tearDown(self):
self.output = ''
self.i = None
del self.i
def test_more(self):
self.assertEqual(self.i.push('dir()'), 0)
self.assertEqual(self.i.push('for n in range(3):'), 1)
def test_push(self):
values = (
('dir', '<built-in function dir>'),
('dir()', "['__builtins__', '__doc__', '__name__']"),
('2 + 2', '4'),
('d = {}', ''),
('d', '{}'),
('del d', ''),
('len([4,5,6])', '3'),
)
for input, output in values:
if output: output += '\n'
self.i.push(input)
self.assertEqual(self.output, output)
self.output = ''
if __name__ == '__main__':
unittest.main()

View File

@@ -1,862 +0,0 @@
#!/usr/bin/env python
__author__ = "Patrick K. O'Brien <pobrien@orbtech.com>"
__cvsid__ = "$Id$"
__revision__ = "$Revision$"[11:-2]
import unittest
# Import from this module's parent directory.
import os
import sys
sys.path.insert(0, os.pardir)
import introspect
del sys.path[0]
del sys
del os
"""
These unittest methods are preferred:
-------------------------------------
self.assert_(expr, msg=None)
self.assertEqual(first, second, msg=None)
self.assertRaises(excClass, callableObj, *args, **kwargs)
self.fail(msg=None)
self.failIf(expr, msg=None)
"""
class ModuleTestCase(unittest.TestCase):
def test_module(self):
module = introspect
self.assert_(module.__author__)
self.assert_(module.__cvsid__)
self.assert_(module.__revision__)
self.assert_(module.getAllAttributeNames)
self.assert_(module.getAttributeNames)
self.assert_(module.getAutoCompleteList)
self.assert_(module.getBaseObject)
self.assert_(module.getCallTip)
self.assert_(module.getConstructor)
self.assert_(module.getRoot)
self.assert_(module.rtrimTerminus)
class RtrimTerminusTestCase(unittest.TestCase):
def test_rtrimTerminus(self):
values = (
('', '', ''),
('', None, ''),
('', '.', ''),
('', '(', ''),
('.', '', '.'),
('.', None, '.'),
('.', '.', '.'),
('.', '(', '.'),
('(', '', '('),
('(', None, '('),
('(', '.', '('),
('(', '(', '('),
('spam', '', 'spam'),
('spam', None, 'spam'),
('spam', '.', 'spam'),
('spam', '(', 'spam'),
('spam.', '', 'spam.'),
('spam.', None, 'spam.'),
('spam.', '.', 'spam.'),
('spam.', '(', 'spam.'),
('spam(', '', 'spam('),
('spam(', None, 'spam('),
('spam(', '.', 'spam('),
('spam(', '(', 'spam('),
('spam.eggs', '.', 'spam.'),
('spam.eggs.', '.', 'spam.eggs.'),
('spam.eggs(', '(', 'spam.eggs('),
('spam.eggs.', '(', 'spam.eggs.'),
('spam.eggs(', '.', 'spam.'),
('x = spam.', '.', 'x = spam.'),
('x = spam.eggs', '.', 'x = spam.'),
('x = spam.eggs.', '.', 'x = spam.eggs.'),
('x = spam.eggs(', '(', 'x = spam.eggs('),
)
for input, terminator, output in values:
result = introspect.rtrimTerminus(input, terminator)
self.assertEqual(result, output,
':in: %r :t: %r :out: %r :result: %r' %
(input, terminator, output, result))
class GetRootTestCase(unittest.TestCase):
def _checkRoot(self, input, terminator, output):
root = introspect.getRoot(command=input, terminator=terminator)
self.assertEqual(root, output,
':in: %r :t: %r :out: %r :root: %r' %
(input, terminator, output, root))
def test_getRoot(self):
values = (
('', '', ''),
('', None, ''),
('', '.', ''),
('', '(', ''),
('.', '', '.'),
('.', None, '.'),
('.', '.', ''),
('.', '(', '.'),
('(', '', ''),
('(', None, ''),
('(', '.', ''),
('(', '(', ''),
('spam', '', 'spam'),
('spam', None, 'spam'),
('spam', '.', ''),
('spam', '(', 'spam'),
('spam.', '', 'spam.'),
('spam.', None, 'spam.'),
('spam.', '.', 'spam'),
('spam.', '(', 'spam.'),
('spam(', '', ''),
('spam(', None, ''),
('spam(', '.', ''),
('spam(', '(', 'spam'),
('spam.eggs', '.', 'spam'),
('spam.eggs.', '.', 'spam.eggs'),
('spam.eggs(', '(', 'spam.eggs'),
('spam.eggs.', '(', 'spam.eggs.'),
('spam.eggs(', '.', 'spam'),
('x = spam.', '.', 'spam'),
('x = spam.eggs', '.', 'spam'),
('x = spam.eggs.', '.', 'spam.eggs'),
('x = spam.eggs(', '(', 'spam.eggs'),
('for n in range(3):\n d.', '.', 'd'),
('for n in range(3):\n... d.', '.', 'd'),
)
for input, terminator, output in values:
self._checkRoot(input, terminator, output)
def test_getRoot_Advanced(self):
values = (
('spam_', '', 'spam_'),
('spam_', None, 'spam_'),
('spam_', '.', ''),
('spam_', '(', 'spam_'),
('_spam', '', '_spam'),
('_spam', None, '_spam'),
('_spam', '.', ''),
('_spam', '(', '_spam'),
('spam_eggs', '', 'spam_eggs'),
('spam_eggs', None, 'spam_eggs'),
('spam_eggs', '.', ''),
('spam_eggs', '(', 'spam_eggs'),
('spam123', '', 'spam123'),
('spam123', None, 'spam123'),
('spam123', '.', ''),
('spam123', '(', 'spam123'),
('spam_123', '', 'spam_123'),
('spam_123', None, 'spam_123'),
('spam_123', '.', ''),
('spam_123', '(', 'spam_123'),
)
for input, terminator, output in values:
self._checkRoot(input, terminator, output)
## The original intent was to detect when we were inside a string.
## That has proven to be very difficult, for little benefit.
## The fact that autocomplete or calltips might be triggered inside
## a string is not a big deal. Sometimes it is even helpful.
## def test_getRoot_InsideStrings(self):
## values = (
## ('x = ".', '.', ''),
## ("x = '.", '.', ''),
## ('x = """.', '.', ''),
## ("x = '''.", '.', ''),
##
## ('x = "(', '(', ''),
## ("x = '(", '(', ''),
## ('x = """(', '(', ''),
## ("x = '''(", '(', ''),
##
## ('x = "spam', '.', ''),
## ('x = "spam.', '.', ''),
## ("x = 'spam.", '.', ''),
## ('x = """spam.', '.', ''),
## ("x = '''spam.", '.', ''),
##
## ('x = "spam', '(', ''),
## ('x = "spam(', '(', ''),
## ("x = 'spam(", '(', ''),
## ('x = """spam(', '(', ''),
## ("x = '''spam(", '(', ''),
##
## ('x = "spam.eggs.', '.', ''),
## ("x = 'spam.eggs.", '.', ''),
## ('x = """spam.eggs.', '.', ''),
## ("x = '''spam.eggs.", '.', ''),
##
## ('x = "spam.eggs(', '(', ''),
## ("x = 'spam.eggs(", '(', ''),
## ('x = """spam.eggs(', '(', ''),
## ("x = '''spam.eggs(", '(', ''),
## )
## for input, terminator, output in values:
## self._checkRoot(input, terminator, output)
def test_getRoot_EmptyTypes(self):
values = (
("''.", '.', "''"),
('"".', '.', '""'),
('"""""".', '.', '""""""'),
("''''''.", '.', "''''''"),
('[].', '.', '[]'),
('().', '.', '()'),
('{}.', '.', '{}'),
('[](', '(', '[]'),
('()(', '(', '()'),
('{}(', '(', '{}'),
("x = ''.", '.', "''"),
('x = "".', '.', '""'),
('x = """""".', '.', '""""""'),
("x = ''''''.", '.', "''''''"),
('x = [].', '.', '[]'),
('x = ().', '.', '()'),
('x = {}.', '.', '{}'),
('x = [](', '(', '[]'),
('x = ()(', '(', '()'),
('x = {}(', '(', '{}'),
('print [].', '.', '[]'),
('print ().', '.', '()'),
('print {}.', '.', '{}'),
('print [](', '(', '[]'),
('print ()(', '(', '()'),
('print {}(', '(', '{}'),
("''.attr.", '.', "''.attr"),
('"".attr.', '.', '"".attr'),
('"""""".attr.', '.', '"""""".attr'),
("''''''.attr.", '.', "''''''.attr"),
('[].attr.', '.', '[].attr'),
('().attr.', '.', '().attr'),
('{}.attr.', '.', '{}.attr'),
('[].attr(', '(', '[].attr'),
('().attr(', '(', '().attr'),
('{}.attr(', '(', '{}.attr'),
('spam().', '.', ''),
('spam_().', '.', ''),
('spam5().', '.', ''),
('spam[]().', '.', ''),
('spam()[].', '.', ''),
('spam[]{}.', '.', ''),
("spam(''.", '.', "''"),
('spam("".', '.', '""'),
('spam("""""".', '.', '""""""'),
("spam(''''''.", '.', "''''''"),
('spam([].', '.', '[]'),
('spam(().', '.', '()'),
('spam({}.', '.', '{}'),
('spam[[].', '.', '[]'),
('spam[().', '.', '()'),
('spam[{}.', '.', '{}'),
('x = {[].', '.', '[]'),
('x = {().', '.', '()'),
('x = {{}.', '.', '{}'),
('spam,[].', '.', '[]'),
('spam+[].', '.', '[]'),
('spam-[].', '.', '[]'),
('spam*[].', '.', '[]'),
('spam/[].', '.', '[]'),
('spam=[].', '.', '[]'),
('spam%[].', '.', '[]'),
('spam<[].', '.', '[]'),
('spam>[].', '.', '[]'),
('spam&[].', '.', '[]'),
('spam|[].', '.', '[]'),
('spam^[].', '.', '[]'),
('spam~[].', '.', '[]'),
('spam:[].', '.', '[]'),
('spam,().', '.', '()'),
('spam+().', '.', '()'),
('spam-().', '.', '()'),
('spam*().', '.', '()'),
('spam/().', '.', '()'),
('spam=().', '.', '()'),
('spam%().', '.', '()'),
('spam<().', '.', '()'),
('spam>().', '.', '()'),
('spam&().', '.', '()'),
('spam|().', '.', '()'),
('spam^().', '.', '()'),
('spam~().', '.', '()'),
('spam:().', '.', '()'),
('spam,{}.', '.', '{}'),
('spam+{}.', '.', '{}'),
('spam-{}.', '.', '{}'),
('spam*{}.', '.', '{}'),
('spam/{}.', '.', '{}'),
('spam={}.', '.', '{}'),
('spam%{}.', '.', '{}'),
('spam<{}.', '.', '{}'),
('spam>{}.', '.', '{}'),
('spam&{}.', '.', '{}'),
('spam|{}.', '.', '{}'),
('spam^{}.', '.', '{}'),
('spam~{}.', '.', '{}'),
('spam:{}.', '.', '{}'),
)
for input, terminator, output in values:
self._checkRoot(input, terminator, output)
# Support for GetBaseObjectTestCase and GetAttributeNamesTestCase.
class Foo:
def __init__(self):
pass
def __del__(self):
pass
def _private(self):
pass
class Bar:
pass
class Spam:
def __call__(self):
pass
def foo(self):
pass
def bar(spam):
# It shouldn't matter what we call "self".
pass
def eggs(self):
pass
def ham(eggs):
pass
class GetBaseObjectTestCase(unittest.TestCase):
def test_getBaseObject(self):
spam = Spam()
eggs = Spam.eggs
listappend = [].append
spamda = lambda: None
values = (
('spam', 'spam', 0),
(123, 123, 0),
(12.3, 12.3, 0),
([], [], 0),
((), (), 0),
({}, {}, 0),
# Builtin function.
(len, len, 0),
# Builtin method.
(listappend, listappend, 0),
# User function.
(ham, ham, 0),
# Byte-compiled code.
(ham.func_code, ham.func_code, 0),
# Lambda.
(spamda, spamda, 0),
# Class with init.
(Foo, Foo.__init__.im_func, 1),
# Class with no init.
(Bar, Bar, 0),
# Bound method.
(spam.foo, spam.foo.im_func, 1),
# Bound method with self named something else (spam).
(spam.bar, spam.bar.im_func, 1),
# Unbound method. (Do not drop the self argument.)
(eggs, eggs.im_func, 0),
# Callable instance.
(spam, spam.__call__.im_func, 1),
)
for object, baseObject, dropSelf in values:
result = introspect.getBaseObject(object)
self.assertEqual(result, (baseObject, dropSelf))
class GetAttributeTestCase(unittest.TestCase):
"""Base class for other test case classes."""
def setUp(self):
self.values = (
'__abs__',
'__add__',
'__and__',
'__base__',
'__bases__',
'__basicsize__',
'__builtins__',
'__call__',
'__class__',
'__cmp__',
'__coerce__',
'__contains__',
'__del__',
'__delattr__',
'__delitem__',
'__delslice__',
'__dict__',
'__dictoffset__',
'__div__',
'__divmod__',
'__doc__',
'__eq__',
'__file__',
'__flags__',
'__float__',
'__floordiv__',
'__ge__',
'__get__',
'__getattr__',
'__getattribute__',
'__getitem__',
'__getslice__',
'__gt__',
'__hash__',
'__hex__',
'__iadd__',
'__imul__',
'__init__',
'__int__',
'__invert__',
'__itemsize__',
'__iter__',
'__le__',
'__len__',
'__long__',
'__lshift__',
'__lt__',
'__mod__',
'__module__',
'__mro__',
'__mul__',
'__name__',
'__ne__',
'__neg__',
'__new__',
'__nonzero__',
'__oct__',
'__or__',
'__path__',
'__pos__',
'__pow__',
'__radd__',
'__rand__',
'__rdiv__',
'__rdivmod__',
'__reduce__',
'__repr__',
'__rfloordiv__',
'__rlshift__',
'__rmod__',
'__rmul__',
'__ror__',
'__rpow__',
'__rrshift__',
'__rshift__',
'__rsub__',
'__rtruediv__',
'__rxor__',
'__self__',
'__setattr__',
'__setitem__',
'__setslice__',
'__str__',
'__sub__',
'__subclasses__',
'__truediv__',
'__warningregistry__',
'__weakrefoffset__',
'__xor__',
'append',
'capitalize',
'center',
'clear',
'close',
'closed',
'co_argcount',
'co_cellvars',
'co_code',
'co_consts',
'co_filename',
'co_firstlineno',
'co_flags',
'co_freevars',
'co_lnotab',
'co_name',
'co_names',
'co_nlocals',
'co_stacksize',
'co_varnames',
'conjugate',
'copy',
'count',
'decode',
'encode',
'endswith',
'expandtabs',
'extend',
'fileno',
'find',
'flush',
'func_closure',
'func_code',
'func_defaults',
'func_dict',
'func_doc',
'func_globals',
'func_name',
'get',
'has_key',
'im_class',
'im_func',
'im_self',
'imag',
'index',
'insert',
'isalnum',
'isalpha',
'isatty',
'isdigit',
'islower',
'isspace',
'istitle',
'isupper',
'items',
'iteritems',
'iterkeys',
'itervalues',
'join',
'keys',
'ljust',
'lower',
'lstrip',
'mode',
'mro',
'name',
'pop',
'popitem',
'real',
'read',
'readinto',
'readline',
'readlines',
'remove',
'replace',
'reverse',
'rfind',
'rindex',
'rjust',
'rstrip',
'seek',
'setdefault',
'softspace',
'sort',
'split',
'splitlines',
'start',
'startswith',
'step',
'stop',
'strip',
'swapcase',
'tell',
'title',
'tolist',
'translate',
'truncate',
'update',
'upper',
'values',
'write',
'writelines',
'xreadlines',
)
# Since getAllAttributeNames() calls str(object),
# we need to test for a broken __str__ method.
class BrokenStr:
def __str__(self):
raise Exception
brokenStr = BrokenStr()
class GetAttributeNamesTestCase(GetAttributeTestCase):
def setUp(self):
GetAttributeTestCase.setUp(self)
import PyCrust
spam = Spam()
self.f = open('test_introspect.py')
self.items = (
None,
int(123),
long(123),
float(123),
complex(123),
"",
unicode(""),
[],
(),
xrange(0),
{},
# Builtin function.
len,
# Builtin method.
[].append,
# User function.
ham,
# Byte-compiled code.
ham.func_code,
# Lambda.
lambda: None,
# Class with no init.
Bar,
# Instance with no init.
Bar(),
# Class with init and del.
Foo,
# Instance with init and del.
Foo(),
# Bound method.
spam.foo,
# Unbound method.
Spam.eggs,
# Callable instance.
spam,
# Module.
introspect,
# Package.
PyCrust,
# Buffer.
buffer(''),
# File.
self.f,
# Slice.
slice(0),
# Ellipsis.
Ellipsis,
# BrokenStr class.
BrokenStr,
# BrokenStr instance.
brokenStr,
)
def tearDown(self):
self.items = None
self.f.close()
def test_getAttributeNames(self):
for item in self.items:
self._checkAttributeNames(item)
if __builtins__.has_key('object'):
self._checkAttributeNames(object)
def test_getAttributeNames_NoSingle(self):
for item in self.items:
result = introspect.getAttributeNames(item, includeSingle=0)
attributes = [attribute for attribute in result \
if attribute[0] != '_' or attribute[:2] == '__']
self.assertEqual(result, attributes,
':item: %r' % (item,))
def test_getAttributeNames_NoDouble(self):
for item in self.items:
result = introspect.getAttributeNames(item, includeDouble=0)
attributes = [attribute for attribute in result \
if attribute[:2] != '__']
self.assertEqual(result, attributes,
':item: %r' % (item,))
def test_getAttributeNames_NoSingleOrDouble(self):
for item in self.items:
result = introspect.getAttributeNames(item, includeSingle=0,
includeDouble=0)
attributes = [attribute for attribute in result \
if attribute[0] != '_']
self.assertEqual(result, attributes,
':item: %r' % (item,))
def _checkAttributeNames(self, item):
result = introspect.getAttributeNames(item)
attributes = [attribute for attribute in self.values \
if hasattr(item, attribute)]
for attribute in attributes:
self.assert_(attribute in result,
':item: %r :attribute: %r' % (item, attribute))
class GetAutoCompleteListTestCase(GetAttributeTestCase):
def setUp(self):
GetAttributeTestCase.setUp(self)
self.items = (
'None.',
'123 .',
'"".',
'[].',
'().',
'{}.',
# Builtin function.
'len.',
# Builtin method.
'[].append.',
)
def test_getAutoCompleteList(self):
for item in self.items:
result = introspect.getAutoCompleteList(item)
object = eval(item[:-1])
attributes = [attribute for attribute in self.values \
if hasattr(object, attribute)]
for attribute in attributes:
self.assert_(attribute in result,
':item: %r :attribute: %r' % (item, attribute))
def test_getAutoCompleteList_NoSingle(self):
for item in self.items:
result = introspect.getAutoCompleteList(item, includeSingle=0)
attributes = [attribute for attribute in result \
if attribute[0] != '_' or attribute[:2] == '__']
self.assertEqual(result, attributes,
':item: %r' % (item,))
def test_getAutoCompleteList_NoDouble(self):
for item in self.items:
result = introspect.getAutoCompleteList(item, includeDouble=0)
attributes = [attribute for attribute in result \
if attribute[:2] != '__']
self.assertEqual(result, attributes,
':item: %r' % (item,))
def test_getAutoCompleteList_NoSingleOrDouble(self):
for item in self.items:
result = introspect.getAutoCompleteList(item, includeSingle=0,
includeDouble=0)
attributes = [attribute for attribute in result \
if attribute[0] != '_']
self.assertEqual(result, attributes,
':item: %r' % (item,))
# Support for GetConstructorTestCase.
class A1:
def __init__(self, a):
self.a = a
class B1(A1):
def __init__(self, b):
self.b = b
class C1(A1):
pass
class D1(C1, B1):
pass
if __builtins__.has_key('object'):
class A2(object):
def __init__(self, a):
self.a = a
class B2(A2):
def __init__(self, b):
self.b = b
class C2(A2):
pass
class D2(C2, B2):
pass
class N:
pass
class O:
def __init__(self, a, b=2, *args, **kwargs):
pass
class P(O):
pass
class Q(P):
def __init__(self, c, d=4):
pass
class GetConstructorTestCase(unittest.TestCase):
def test_getConstructor(self):
args = ('self', 'a', 'b', 'args', 'kwargs')
varnames = introspect.getConstructor(O).func_code.co_varnames
self.assertEqual(varnames, args)
varnames = introspect.getConstructor(P).func_code.co_varnames
self.assertEqual(varnames, args)
args = ('self', 'c', 'd')
varnames = introspect.getConstructor(Q).func_code.co_varnames
self.assertEqual(varnames, args)
def test_getConstructor_None(self):
values = (N, 1, 'spam', {}, [], (), dir)
for value in values:
self.assertEqual(introspect.getConstructor(N), None)
def test_getConstructor_MultipleInheritance(self):
# Test old style inheritance rules.
args = ('self', 'a')
varnames = introspect.getConstructor(D1).func_code.co_varnames
self.assertEqual(varnames, args)
if __builtins__.has_key('object'):
# Test new style inheritance rules as well.
args = ('self', 'b')
varnames = introspect.getConstructor(D2).func_code.co_varnames
self.assertEqual(varnames, args)
if __name__ == '__main__':
unittest.main()

View File

@@ -1,81 +0,0 @@
#!/usr/bin/env python
__author__ = "Patrick K. O'Brien <pobrien@orbtech.com>"
__cvsid__ = "$Id$"
__revision__ = "$Revision$"[11:-2]
import unittest
# Import from this module's parent directory.
import os
import sys
sys.path.insert(0, os.pardir)
import pseudo
del sys.path[0]
del sys
del os
"""
These unittest methods are preferred:
-------------------------------------
self.assert_(expr, msg=None)
self.assertEqual(first, second, msg=None)
self.assertRaises(excClass, callableObj, *args, **kwargs)
self.fail(msg=None)
self.failIf(expr, msg=None)
"""
class ModuleTestCase(unittest.TestCase):
def test_module(self):
module = pseudo
self.assert_(module.__author__)
self.assert_(module.__cvsid__)
self.assert_(module.__revision__)
self.assert_(module.PseudoFile)
self.assert_(module.PseudoFileErr)
self.assert_(module.PseudoFileIn)
self.assert_(module.PseudoFileOut)
self.assert_(module.PseudoKeyword)
class PseudoTestCase(unittest.TestCase):
def setUp(self):
pass
def tearDown(self):
pass
class PseudoFileTestCase(unittest.TestCase):
def setUp(self):
pass
def tearDown(self):
pass
class PseudoFileOutTestCase(unittest.TestCase):
def setUp(self):
pass
def tearDown(self):
pass
def _write(self):
pass
def test_PseudoFileOut_goodInit(self):
self.assert_(pseudo.PseudoFileOut(write=self._write))
def test_PseudoFileOut_badInit(self):
self.assertRaises(ValueError, pseudo.PseudoFileOut, write='bad')
if __name__ == '__main__':
unittest.main()

View File

@@ -1,49 +0,0 @@
#!/usr/bin/env python
__author__ = "Patrick K. O'Brien <pobrien@orbtech.com>"
__cvsid__ = "$Id$"
__revision__ = "$Revision$"[11:-2]
import unittest
import types
# Import from this module's parent directory.
import os
import sys
sys.path.insert(0, os.pardir)
import version
del sys.path[0]
del sys
del os
"""
These unittest methods are preferred:
-------------------------------------
self.assert_(expr, msg=None)
self.assertEqual(first, second, msg=None)
self.assertRaises(excClass, callableObj, *args, **kwargs)
self.fail(msg=None)
self.failIf(expr, msg=None)
"""
class ModuleTestCase(unittest.TestCase):
def test_module(self):
module = version
self.assert_(module.__author__)
self.assert_(module.__cvsid__)
self.assert_(module.__revision__)
self.assert_(module.VERSION)
class VersionTestCase(unittest.TestCase):
def test_VERSION(self):
self.assert_(type(version.VERSION) is types.StringType)
if __name__ == '__main__':
unittest.main()

View File

@@ -1,25 +0,0 @@
#!/usr/bin/env python
__author__ = "Patrick K. O'Brien <pobrien@orbtech.com>"
__cvsid__ = "$Id$"
__revision__ = "$Revision$"[11:-2]
import unittest
import glob
import os
def suite():
"""Return a test suite containing all test cases in all test modules.
Searches the current directory for any modules matching test_*.py."""
suite = unittest.TestSuite()
for filename in glob.glob('test_*.py'):
module = __import__(os.path.splitext(filename)[0])
suite.addTest(unittest.defaultTestLoader.loadTestsFromModule(module))
return suite
if __name__ == '__main__':
unittest.main(defaultTest='suite')

View File

@@ -1,9 +0,0 @@
"""Provides an object representing the current 'version' or 'release'
of Py as a whole. Individual classes, such as the shell, filling and
interpreter, each have a revision property based on the CVS Revision."""
__author__ = "Patrick K. O'Brien <pobrien@orbtech.com>"
__cvsid__ = "$Id$"
__revision__ = "$Revision$"[11:-2]
VERSION = '0.9.3'

View File

@@ -1,58 +0,0 @@
"""Decorator classes for documentation and shell scripting.
"""
__author__ = "Patrick K. O'Brien <pobrien@orbtech.com>"
__cvsid__ = "$Id$"
__revision__ = "$Revision$"[11:-2]
# These are not the real wxPython classes. These are Python versions
# for documentation purposes. They are also used to apply docstrings
# to the real wxPython classes, which are SWIG-generated wrappers for
# C-language classes.
from Base import Object
import Parameters as wx
class AcceleratorEntry:
""""""
def __init__(self):
""""""
pass
def __del__(self):
""""""
pass
def GetCommand(self):
""""""
pass
def GetFlags(self):
""""""
pass
def GetKeyCode(self):
""""""
pass
def Set(self):
""""""
pass
class AcceleratorTable(Object):
""""""
def __init__(self):
""""""
pass
def __del__(self):
""""""
pass

View File

@@ -1,358 +0,0 @@
"""Decorator classes for documentation and shell scripting.
"""
__author__ = "Patrick K. O'Brien <pobrien@orbtech.com>"
__cvsid__ = "$Id$"
__revision__ = "$Revision$"[11:-2]
# These are not the real wxPython classes. These are Python versions
# for documentation purposes. They are also used to apply docstrings
# to the real wxPython classes, which are SWIG-generated wrappers for
# C-language classes.
from Base import EvtHandler
import Parameters as wx
try:
True
except NameError:
True = 1==1
False = 1==0
class PyApp(EvtHandler):
"""Python Application base class.
It is used to:
- set and get application-wide properties;
- implement the windowing system message or event loop;
- initiate application processing via App.OnInit;
- allow default processing of events not handled by other objects
in the application."""
def __init__(self):
"""Create a PyApp instance."""
pass
def Dispatch(self):
"""Dispatches the next event in the windowing system event
queue.
This can be used for programming event loops."""
pass
def ExitMainLoop(self):
"""Call this to explicitly exit the main message (event) loop.
You should normally exit the main loop (and the application)
by deleting the top window, which wxPython does automatically."""
pass
def GetAppName(self):
"""Return the application name."""
pass
def GetAssertMode(self):
"""Return the current assertion mode."""
pass
def GetAuto3D(self):
"""Returns True if 3D control mode is on, False otherwise.
Windows only."""
pass
def GetClassName(self):
"""Return the class name of the application."""
pass
def GetExitOnFrameDelete(self):
"""Returns True if the application will exit when the
top-level window is deleted, False otherwise."""
pass
def GetPrintMode(self):
"""Deprecated."""
pass
def GetTopWindow(self):
"""Return the top window.
If the top window hasn't been set using App.SetTopWindow,
this method will find the first top-level window (frame or
dialog) and return that."""
pass
def GetUseBestVisual(self):
"""Return True if the application will use the best visual on
systems that support different visuals, False otherwise."""
pass
def GetVendorName(self):
"""Return the application's vendor name."""
pass
def Initialized(self):
"""Return True if the application has been initialized
(i.e. if App.OnInit has returned successfully). This can be
useful for error message routines to determine which method of
output is best for the current state of the program (some
windowing systems may not like dialogs to pop up before the
main loop has been entered)."""
pass
def MainLoop(self):
"""Called by wxWindows on creation of the application.
Override this if you wish to provide your own
(environment-dependent) main loop.
Return 0 under X, and the wParam of the WM_QUIT message under
Windows."""
pass
def OnAssert(self, file, line, cond, msg):
"""Called when an assert failure occurs, i.e. the condition
specified in ASSERT macro evaluated to FALSE. It is only
called in debug mode (when __WXDEBUG__ is defined) as asserts
are not left in the release code at all.
The base class version show the default assert failure dialog
box proposing to the user to stop the program, continue or
ignore all subsequent asserts.
file is the name of the source file where the assert occured
line is the line number in this file where the assert occured
cond is the condition of the failed assert in string form
msg is the message specified as argument to ASSERT_MSG or
FAIL_MSG, will be NULL if just ASSERT or FAIL was used"""
pass
def OnExit(self):
"""Provide this member function for any processing which needs
to be done as the application is about to exit. OnExit is
called after destroying all application windows and controls,
but before wxWindows cleanup."""
pass
def OnInit(self):
"""This must be provided by the application, and will usually
create the application's main window, optionally calling
App.SetTopWindow.
Return True to continue processing, False to exit the
application."""
pass
def OnInitGui(self):
"""Called just after the platform's GUI has been initialized,
but before the App.OnInit() gets called. Rarely needed in
practice. Unlike App.OnInit(), does not need to return
True/False."""
pass
def Pending(self):
"""Return True if unprocessed events are in the window system
event queue."""
pass
def ProcessIdle(self):
"""Sends the EVT_IDLE event and is called inside the MainLoop.
You only need this if you implement your own main loop."""
pass
def SetAppName(self, name):
"""Set the name of the application."""
pass
def SetAssertMode(self, mode):
"""Lets you control how C++ assertions are processed.
Valid modes are: PYAPP_ASSERT_SUPPRESS,
PYAPP_ASSERT_EXCEPTION, and PYAPP_ASSERT_DIALOG. Using
_SUPPRESS will give you behavior like the old final builds and
the assert will be ignored, _EXCEPTION is the new default
described above, and _DIALOG is like the default in 2.3.3.1
and prior hybrid builds. You can also combine _EXCEPTION and
_DIALOG if you wish, although I don't know why you would."""
pass
def SetAuto3D(self, auto3D):
"""Switches automatic 3D controls on or off. Windows only.
If auto3D is True, all controls will be created with 3D
appearances unless overridden for a control or dialog. The
default is True."""
pass
def SetClassName(self, name):
"""Set the class name of the application."""
pass
def SetExitOnFrameDelete(self, flag):
"""If flag is True (the default), the application will exit
when the top-level frame is deleted. If False, the
application will continue to run."""
pass
def SetPrintMode(self, mode):
"""Deprecated."""
pass
def SetTopWindow(self, window):
"""Set the 'top' window.
You can call this from within App.OnInit to let wxWindows
know which is the main window. You don't have to set the top
window; it is only a convenience so that (for example) certain
dialogs without parents can use a specific window as the top
window. If no top window is specified by the application,
wxWindows just uses the first frame or dialog in its top-level
window list, when it needs to use the top window."""
pass
def SetUseBestVisual(self, flag):
"""Allows the programmer to specify whether the application
will use the best visual on systems that support several
visual on the same display. This is typically the case under
Solaris and IRIX, where the default visual is only 8-bit
whereas certain applications are supposed to run in TrueColour
mode.
Note that this function has to be called in the constructor of
the App instance and won't have any effect when called later
on.
This function currently only has effect under GTK."""
pass
def SetVendorName(self, name):
"""Sets the name of application's vendor. The name will be
used in registry access."""
pass
def Yield(self, onlyIfNeeded=False):
"""Yields control to pending messages in the windowing system.
This can be useful, for example, when a time-consuming process
writes to a text window. Without an occasional yield, the
text window will not be updated properly, and on systems with
cooperative multitasking, such as Windows 3.1 other processes
will not respond.
Caution should be exercised, however, since yielding may allow
the user to perform actions which are not compatible with the
current task. Disabling menu items or whole menus during
processing can avoid unwanted reentrance of code: see
wx.SafeYield for a better function.
Calling Yield() recursively is normally an error and an assert
failure is raised in debug build if such situation is
detected. However if the the onlyIfNeeded parameter is True,
the method will just silently return False instead."""
pass
from wxPython.wx import wxPlatform
_redirect = (wxPlatform == '__WXMSW__' or wxPlatform == '__WXMAC__')
del wxPlatform
class App(PyApp):
"""The main application class.
Inherit from this class and implement an OnInit method that
creates a frame and then calls self.SetTopWindow(frame)."""
def __init__(self, redirect=_redirect, filename=None, useBestVisual=False):
"""Create an App instance.
redirect defaults to True on Windows and Mac. If redirect is
True, stdio goes to an output window or a file if filename is
not None."""
pass
del _redirect
class PyOnDemandOutputWindow:
"""Used by App to display stdout and stderr messages if app is
created using App(redirect=True). Mostly useful on Windows or
Mac where apps aren't always launched from the command line."""
pass
class PySimpleApp(App):
"""Use instead of App for simple apps with a simple frame or
dialog, particularly for testing."""
def __init__(self, flag=0):
"""Create a PySimpleApp instance.
flag is the same as App's redirect parameter to redirect stdio."""
pass
def OnInit(self):
"""Automatically does a wx.InitAllImageHandlers()."""
pass
class PyWidgetTester(App):
"""Use instead of App for testing widgets. Provides a frame
containing an instance of a widget.
Create a PyWidgetTester instance with the desired size for the
frame, then create the widget and show the frame using SetWidget."""
def __init__(self, size=(250, 100)):
"""Create a PyWidgetTester instance, with no stdio redirection.
size is for the frame to hold the widget."""
pass
def OnInit(self):
"""Creates a frame that will hold the widget to be tested."""
pass
def SetWidget(self, widgetClass, *args):
"""Create a widgetClass instance using the supplied args and
with a frame as parent, then show the frame."""
pass
class SingleInstanceChecker:
"""Allows one to check that only a single instance of a program is
running. To do it, you should create an object of this class. As
long as this object is alive, calls to IsAnotherRunning() from
other processes will return True.
As the object should have the life span as big as possible, it
makes sense to create it either as a global or in App.OnInit()."""
def __init__(self, name, path=wx.EmptyString):
"""Create a SingleInstanceChecker instance.
name should be as unique as possible. It is used as the mutex
name under Win32 and the lock file name under Unix.
App.GetAppName() and wx.GetUserId() are commonly used.
path is optional and is ignored under Win32 and used as the
directory to create the lock file in under Unix (default is
wx.GetHomeDir())."""
pass
def Create(self, name, path=wx.EmptyString):
"""Create a SingleInstanceChecker instance."""
pass
def IsAnotherRunning(self):
"""Return True if another copy of this program is already running."""
pass

View File

@@ -1,206 +0,0 @@
"""Decorator classes for documentation and shell scripting.
"""
__author__ = "Patrick K. O'Brien <pobrien@orbtech.com>"
__cvsid__ = "$Id$"
__revision__ = "$Revision$"[11:-2]
# These are not the real wxPython classes. These are Python versions
# for documentation purposes. They are also used to apply docstrings
# to the real wxPython classes, which are SWIG-generated wrappers for
# C-language classes.
import Parameters as wx
class Object:
"""Base class for all other wxPython classes."""
def __init__(self):
"""Create a Object instance."""
pass
def Destroy(self):
"""Destroy the Object instance."""
pass
def GetClassName(self):
"""Return the name of the class."""
pass
class EvtHandler(Object):
"""Base class that can handle events from the windowing system.
If the handler is part of a chain, the destructor will unlink
itself and restore the previous and next handlers so that they
point to each other."""
def __init__(self):
"""Create a EvtHandler instance."""
pass
def AddPendingEvent(self, event):
"""Post an event to be processed later.
event is an Event instance to add to process queue.
The difference between sending an event (using the
ProcessEvent method) and posting it is that in the first case
the event is processed before the function returns, while in
the second case, the function returns immediately and the
event will be processed sometime later (usually during the
next event loop iteration).
A copy of event is made by the function, so the original can
be deleted as soon as function returns (it is common that the
original is created on the stack). This requires that the
Event::Clone method be implemented by event so that it can
be duplicated and stored until it gets processed.
This is also the method to call for inter-thread
communication. It will post events safely between different
threads which means that this method is thread-safe by using
critical sections where needed. In a multi-threaded program,
you often need to inform the main GUI thread about the status
of other working threads and such notification should be done
using this method.
This method automatically wakes up idle handling if the
underlying window system is currently idle and thus would not
send any idle events. (Waking up idle handling is done
calling WakeUpIdle.)"""
pass
def Connect(self, id, lastId, eventType, func):
"""Connects the given function dynamically with the event
handler, id and event type. This is an alternative to the use
of static event tables.
id is the identifier (or first of the identifier range) to be
associated with the event handler function.
lastId is the second part of the identifier range to be
associated with the event handler function.
eventType is the event type to be associated with this event
handler.
function is the event handler function.
userData is data to be associated with the event table entry."""
pass
def Disconnect(self, id, lastId=-1, eventType=wx.EVT_NULL):
"""Disconnects the given function dynamically from the event
handler, using the specified parameters as search criteria and
returning True if a matching function has been found and
removed. This method can only disconnect functions which have
been added using the EvtHandler.Connect method. There is no
way to disconnect functions connected using the (static) event
tables.
id is the identifier (or first of the identifier range) to be
associated with the event handler function.
lastId is the second part of the identifier range to be
associated with the event handler function.
eventType is the event type to be associated with this event
handler.
function is the event handler function.
userData is data to be associated with the event table entry."""
pass
def GetEvtHandlerEnabled(self):
"""Return True if the event handler is enabled, False
otherwise."""
pass
def GetNextHandler(self):
"""Return the next handler in the chain."""
pass
def GetPreviousHandler(self):
"""Return the previous handler in the chain."""
pass
def ProcessEvent(self, event):
"""Processes an event, searching event tables and calling zero
or more suitable event handler function(s). Return True if a
suitable event handler function was found and executed, and
the function did not call Event.Skip().
event is an Event to process.
Normally, your application would not call this function: it is
called in the wxPython implementation to dispatch incoming
user interface events to the framework (and application).
However, you might need to call it if implementing new
functionality (such as a new control) where you define new
event types, as opposed to allowing the user to override
virtual functions.
An instance where you might actually override the ProcessEvent
function is where you want to direct event processing to event
handlers not normally noticed by wxWindows. For example, in
the document/view architecture, documents and views are
potential event handlers. When an event reaches a frame,
ProcessEvent will need to be called on the associated document
and view in case event handler functions are associated with
these objects. The property classes library (Property) also
overrides ProcessEvent for similar reasons.
The normal order of event table searching is as follows:
1. If the object is disabled (via a call to
EvtHandler.SetEvtHandlerEnabled) the function skips to step
(6).
2. If the object is a Window, ProcessEvent is recursively
called on the window's Validator. If this returns TRUE, the
function exits.
3. SearchEventTable is called for this event handler. If this
fails, the base class table is tried, and so on until no more
tables exist or an appropriate function was found, in which
case the function exits.
4. The search is applied down the entire chain of event
handlers (usually the chain has a length of one). If this
succeeds, the function exits.
5. If the object is a Window and the event is a
CommandEvent, ProcessEvent is recursively applied to the
parent window's event handler. If this returns TRUE, the
function exits.
6. Finally, ProcessEvent is called on the App object.
See also:
EvtHandler::SearchEventTable"""
pass
def SetEvtHandlerEnabled(self, enabled):
"""Enable or disable the event handler.
You can use this function to avoid having to remove the event
handler from the chain, for example when implementing a dialog
editor and changing from edit to test mode."""
pass
def SetNextHandler(self, handler):
"""Set the pointer to the next handler."""
pass
def SetPreviousHandler(self, handler):
"""Set the pointer to the previous handler."""
pass

View File

@@ -1,485 +0,0 @@
"""Decorator classes for documentation and shell scripting.
"""
__author__ = "Patrick K. O'Brien <pobrien@orbtech.com>"
__cvsid__ = "$Id$"
__revision__ = "$Revision$"[11:-2]
# These are not the real wxPython classes. These are Python versions
# for documentation purposes. They are also used to apply docstrings
# to the real wxPython classes, which are SWIG-generated wrappers for
# C-language classes.
from Base import Object
import Parameters as wx
class Clipboard(Object):
""""""
def AddData(self):
""""""
pass
def Clear(self):
""""""
pass
def Close(self):
""""""
pass
def Flush(self):
""""""
pass
def GetData(self):
""""""
pass
def IsOpened(self):
""""""
pass
def IsSupported(self):
""""""
pass
def Open(self):
""""""
pass
def SetData(self):
""""""
pass
def UsePrimarySelection(self):
""""""
pass
def __init__(self):
""""""
pass
class DataFormat:
""""""
def GetId(self):
""""""
pass
def GetType(self):
""""""
pass
def SetId(self):
""""""
pass
def SetType(self):
""""""
pass
def __del__(self):
""""""
pass
def __init__(self):
""""""
pass
class DataObject:
""""""
def GetAllFormats(self):
""""""
pass
def GetDataHere(self):
""""""
pass
def GetDataSize(self):
""""""
pass
def GetFormatCount(self):
""""""
pass
def GetPreferredFormat(self):
""""""
pass
def IsSupportedFormat(self):
""""""
pass
def SetData(self):
""""""
pass
def __del__(self):
""""""
pass
def __init__(self):
""""""
pass
class DataObjectComposite(DataObject):
""""""
def Add(self):
""""""
pass
def __init__(self):
""""""
pass
class DataObjectSimple(DataObject):
""""""
def GetFormat(self):
""""""
pass
def SetFormat(self):
""""""
pass
def __init__(self):
""""""
pass
class PyDataObjectSimple(DataObjectSimple):
""""""
def __init__(self):
""""""
pass
def _setCallbackInfo(self):
""""""
pass
class BitmapDataObject(DataObjectSimple):
""""""
def GetBitmap(self):
""""""
pass
def SetBitmap(self):
""""""
pass
def __init__(self):
""""""
pass
class PyBitmapDataObject(BitmapDataObject):
""""""
def __init__(self):
""""""
pass
def _setCallbackInfo(self):
""""""
pass
class CustomDataObject(DataObjectSimple):
""""""
def GetData(self):
""""""
pass
def GetSize(self):
""""""
pass
def SetData(self):
""""""
pass
def TakeData(self):
""""""
pass
def __init__(self):
""""""
pass
class DragImage(Object):
""""""
def BeginDrag(self):
""""""
pass
def BeginDrag2(self):
""""""
pass
def EndDrag(self):
""""""
pass
def GetImageRect(self):
""""""
pass
def Hide(self):
""""""
pass
def Move(self):
""""""
pass
def RedrawImage(self):
""""""
pass
def SetBackingBitmap(self):
""""""
pass
def Show(self):
""""""
pass
def __del__(self):
""""""
pass
def __init__(self):
""""""
pass
class DropSource:
""""""
def DoDragDrop(self):
""""""
pass
def GetDataObject(self):
""""""
pass
def SetCursor(self):
""""""
pass
def SetData(self):
""""""
pass
def __del__(self):
""""""
pass
def __init__(self):
""""""
pass
def _setCallbackInfo(self):
""""""
pass
def base_GiveFeedback(self):
""""""
pass
class DropTarget:
""""""
def __init__(self):
""""""
pass
class PyDropTarget(DropTarget):
""""""
def GetData(self):
""""""
pass
def GetDataObject(self):
""""""
pass
def SetDataObject(self):
""""""
pass
def __del__(self):
""""""
pass
def __init__(self):
""""""
pass
def _setCallbackInfo(self):
""""""
pass
def base_OnDragOver(self):
""""""
pass
def base_OnDrop(self):
""""""
pass
def base_OnEnter(self):
""""""
pass
def base_OnLeave(self):
""""""
pass
class FileDataObject(DataObjectSimple):
""""""
def GetFilenames(self):
""""""
pass
def __init__(self):
""""""
pass
class FileDropTarget(PyDropTarget):
""""""
def __init__(self):
""""""
pass
def _setCallbackInfo(self):
""""""
pass
def base_OnData(self):
""""""
pass
def base_OnDragOver(self):
""""""
pass
def base_OnDrop(self):
""""""
pass
def base_OnEnter(self):
""""""
pass
def base_OnLeave(self):
""""""
pass
class TextDataObject(DataObjectSimple):
""""""
def GetText(self):
""""""
pass
def GetTextLength(self):
""""""
pass
def SetText(self):
""""""
pass
def __init__(self):
""""""
pass
class PyTextDataObject(TextDataObject):
""""""
def __init__(self):
""""""
pass
def _setCallbackInfo(self):
""""""
pass
class TextDropTarget(PyDropTarget):
""""""
def __init__(self):
""""""
pass
def _setCallbackInfo(self):
""""""
pass
def base_OnData(self):
""""""
pass
def base_OnDragOver(self):
""""""
pass
def base_OnDrop(self):
""""""
pass
def base_OnEnter(self):
""""""
pass
def base_OnLeave(self):
""""""
pass
class URLDataObject(DataObjectComposite):
""""""
def GetURL(self):
""""""
pass
def SetURL(self):
""""""
pass
def __init__(self):
""""""
pass

View File

@@ -1,199 +0,0 @@
"""Decorator classes for documentation and shell scripting.
"""
__author__ = "Patrick K. O'Brien <pobrien@orbtech.com>"
__cvsid__ = "$Id$"
__revision__ = "$Revision$"[11:-2]
# These are not the real wxPython classes. These are Python versions
# for documentation purposes. They are also used to apply docstrings
# to the real wxPython classes, which are SWIG-generated wrappers for
# C-language classes.
import Parameters as wx
class ConfigBase:
""""""
def DeleteAll(self):
""""""
pass
def DeleteEntry(self):
""""""
pass
def DeleteGroup(self):
""""""
pass
def Exists(self):
""""""
pass
def ExpandEnvVars(self):
""""""
pass
def Flush(self):
""""""
pass
def GetAppName(self):
""""""
pass
def GetEntryType(self):
""""""
pass
def GetFirstEntry(self):
""""""
pass
def GetFirstGroup(self):
""""""
pass
def GetNextEntry(self):
""""""
pass
def GetNextGroup(self):
""""""
pass
def GetNumberOfEntries(self):
""""""
pass
def GetNumberOfGroups(self):
""""""
pass
def GetPath(self):
""""""
pass
def GetStyle(self):
""""""
pass
def GetVendorName(self):
""""""
pass
def HasEntry(self):
""""""
pass
def HasGroup(self):
""""""
pass
def IsExpandingEnvVars(self):
""""""
pass
def IsRecordingDefaults(self):
""""""
pass
def Read(self):
""""""
pass
def ReadBool(self):
""""""
pass
def ReadFloat(self):
""""""
pass
def ReadInt(self):
""""""
pass
def RenameEntry(self):
""""""
pass
def RenameGroup(self):
""""""
pass
def SetAppName(self):
""""""
pass
def SetExpandEnvVars(self):
""""""
pass
def SetPath(self):
""""""
pass
def SetRecordDefaults(self):
""""""
pass
def SetStyle(self):
""""""
pass
def SetVendorName(self):
""""""
pass
def Write(self):
""""""
pass
def WriteBool(self):
""""""
pass
def WriteFloat(self):
""""""
pass
def WriteInt(self):
""""""
pass
def __del__(self):
""""""
pass
def __init__(self):
""""""
pass
class Config(ConfigBase):
""""""
def __del__(self):
""""""
pass
def __init__(self):
""""""
pass
class FileConfig(ConfigBase):
""""""
def __del__(self):
""""""
pass
def __init__(self):
""""""
pass

File diff suppressed because it is too large Load Diff

View File

@@ -1,485 +0,0 @@
"""Decorator classes for documentation and shell scripting.
"""
__author__ = "Patrick K. O'Brien <pobrien@orbtech.com>"
__cvsid__ = "$Id$"
__revision__ = "$Revision$"[11:-2]
# These are not the real wxPython classes. These are Python versions
# for documentation purposes. They are also used to apply docstrings
# to the real wxPython classes, which are SWIG-generated wrappers for
# C-language classes.
import Parameters as wx
class Point:
""""""
def Set(self):
""""""
pass
def __add__(self):
""""""
pass
def __del__(self):
""""""
pass
def __eq__(self):
""""""
pass
def __getattr__(self):
""""""
pass
def __getitem__(self):
""""""
pass
def __init__(self):
""""""
pass
def __len__(self):
""""""
pass
def __ne__(self):
""""""
pass
def __nonzero__(self):
""""""
pass
def __setattr__(self):
""""""
pass
def __setitem__(self):
""""""
pass
def __str__(self):
""""""
pass
def __sub__(self):
""""""
pass
def asTuple(self):
""""""
pass
class Point2DDouble:
""""""
def GetCrossProduct(self):
""""""
pass
def GetDistance(self):
""""""
pass
def GetDistanceSquare(self):
""""""
pass
def GetDotProduct(self):
""""""
pass
def GetFloor(self):
""""""
pass
def GetRounded(self):
""""""
pass
def GetVectorAngle(self):
""""""
pass
def GetVectorLength(self):
""""""
pass
def Normalize(self):
""""""
pass
def SetPolarCoordinates(self):
""""""
pass
def SetVectorAngle(self):
""""""
pass
def SetVectorLength(self):
""""""
pass
def __eq__(self):
""""""
pass
def __getattr__(self):
""""""
pass
def __getitem__(self):
""""""
pass
def __iadd__(self):
""""""
pass
def __idiv__(self):
""""""
pass
def __imul__(self):
""""""
pass
def __init__(self):
""""""
pass
def __isub__(self):
""""""
pass
def __len__(self):
""""""
pass
def __ne__(self):
""""""
pass
def __neg__(self):
""""""
pass
def __nonzero__(self):
""""""
pass
def __setattr__(self):
""""""
pass
def __setitem__(self):
""""""
pass
def __str__(self):
""""""
pass
def asTuple(self):
""""""
pass
class RealPoint:
""""""
def Set(self):
""""""
pass
def __add__(self):
""""""
pass
def __del__(self):
""""""
pass
def __eq__(self):
""""""
pass
def __getattr__(self):
""""""
pass
def __getitem__(self):
""""""
pass
def __init__(self):
""""""
pass
def __len__(self):
""""""
pass
def __ne__(self):
""""""
pass
def __nonzero__(self):
""""""
pass
def __setattr__(self):
""""""
pass
def __setitem__(self):
""""""
pass
def __str__(self):
""""""
pass
def __sub__(self):
""""""
pass
def asTuple(self):
""""""
pass
class Rect:
""""""
def GetBottom(self):
""""""
pass
def GetHeight(self):
""""""
pass
def GetLeft(self):
""""""
pass
def GetPosition(self):
""""""
pass
def GetRight(self):
""""""
pass
def GetSize(self):
""""""
pass
def GetTop(self):
""""""
pass
def GetWidth(self):
""""""
pass
def GetX(self):
""""""
pass
def GetY(self):
""""""
pass
def Inflate(self):
""""""
pass
def Inside(self):
""""""
pass
def SetBottom(self):
""""""
pass
def SetHeight(self):
""""""
pass
def SetLeft(self):
""""""
pass
def SetPosition(self):
""""""
pass
def SetRight(self):
""""""
pass
def SetSize(self):
""""""
pass
def SetTop(self):
""""""
pass
def SetWidth(self):
""""""
pass
def SetX(self):
""""""
pass
def SetY(self):
""""""
pass
def __add__(self):
""""""
pass
def __del__(self):
""""""
pass
def __eq__(self):
""""""
pass
def __getattr__(self):
""""""
pass
def __getitem__(self):
""""""
pass
def __init__(self):
""""""
pass
def __len__(self):
""""""
pass
def __ne__(self):
""""""
pass
def __nonzero__(self):
""""""
pass
def __setattr__(self):
""""""
pass
def __setitem__(self):
""""""
pass
def __str__(self):
""""""
pass
def asTuple(self):
""""""
pass
class Size:
""""""
def GetHeight(self):
""""""
pass
def GetWidth(self):
""""""
pass
def GetX(self):
""""""
pass
def GetY(self):
""""""
pass
def Set(self):
""""""
pass
def SetHeight(self):
""""""
pass
def SetWidth(self):
""""""
pass
def __del__(self):
""""""
pass
def __eq__(self):
""""""
pass
def __getattr__(self):
""""""
pass
def __getitem__(self):
""""""
pass
def __init__(self):
""""""
pass
def __len__(self):
""""""
pass
def __ne__(self):
""""""
pass
def __nonzero__(self):
""""""
pass
def __setattr__(self):
""""""
pass
def __setitem__(self):
""""""
pass
def __str__(self):
""""""
pass
def asTuple(self):
""""""
pass

Some files were not shown because too many files have changed in this diff Show More