1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Definitions of miscelaneous functions and classes that need
4 // to know about wxWindow. (So they can't be in misc.i or an
5 // import loop will happen.)
9 // Created: 18-June-1999
11 // Copyright: (c) 1998 by Total Control Software
12 // Licence: wxWindows license
13 /////////////////////////////////////////////////////////////////////////////
19 #include "pyistream.h"
20 #include <wx/resource.h>
21 #include <wx/tooltip.h>
23 #include <wx/tipdlg.h>
24 #include <wx/process.h>
26 #if wxUSE_JOYSTICK || defined(__WXMSW__)
27 #include <wx/joystick.h>
30 #if wxUSE_WAVE || defined(__WXMSW__)
34 #include <wx/mimetype.h>
37 //----------------------------------------------------------------------
40 %include my_typemaps.i
42 // Import some definitions of other classes, etc.
52 //----------------------------------------------------------------------
55 // Put some wx default wxChar* values into wxStrings.
56 DECLARE_DEF_STRING(FileSelectorPromptStr);
57 DECLARE_DEF_STRING(FileSelectorDefaultWildcardStr);
58 DECLARE_DEF_STRING(DirSelectorPromptStr);
59 static const wxString wxPyEmptyString(wxT(""));
62 //---------------------------------------------------------------------------
65 wxString wxFileSelector(const wxString& message = wxPyFileSelectorPromptStr,
66 const wxString& default_path = wxPyEmptyString,
67 const wxString& default_filename = wxPyEmptyString,
68 const wxString& default_extension = wxPyEmptyString,
69 const wxString& wildcard = wxPyFileSelectorDefaultWildcardStr,
71 wxWindow *parent = NULL,
72 int x = -1, int y = -1);
74 // Ask for filename to load
75 wxString wxLoadFileSelector(const wxString& what,
76 const wxString& extension,
77 const wxString& default_name = wxPyEmptyString,
78 wxWindow *parent = NULL);
80 // Ask for filename to save
81 wxString wxSaveFileSelector(const wxString& what,
82 const wxString& extension,
83 const wxString& default_name = wxPyEmptyString,
84 wxWindow *parent = NULL);
87 wxString wxDirSelector(const wxString& message = wxPyDirSelectorPromptStr,
88 const wxString& defaultPath = wxPyEmptyString,
89 long style = wxDD_DEFAULT_STYLE,
90 const wxPoint& pos = wxDefaultPosition,
91 wxWindow *parent = NULL);
93 wxString wxGetTextFromUser(const wxString& message,
94 const wxString& caption = wxPyEmptyString,
95 const wxString& default_value = wxPyEmptyString,
96 wxWindow *parent = NULL,
97 int x = -1, int y = -1,
100 wxString wxGetPasswordFromUser(const wxString& message,
101 const wxString& caption = wxPyEmptyString,
102 const wxString& default_value = wxPyEmptyString,
103 wxWindow *parent = NULL);
106 // TODO: Need to custom wrap this one...
107 // int wxGetMultipleChoice(char* message, char* caption,
108 // int LCOUNT, char** choices,
109 // int nsel, int *selection,
110 // wxWindow *parent = NULL, int x = -1, int y = -1,
111 // bool centre = TRUE, int width=150, int height=200);
114 wxString wxGetSingleChoice(const wxString& message, const wxString& caption,
115 int LCOUNT, wxString* choices,
116 wxWindow *parent = NULL,
117 int x = -1, int y = -1,
119 int width=150, int height=200);
121 int wxGetSingleChoiceIndex(const wxString& message, const wxString& caption,
122 int LCOUNT, wxString* choices,
123 wxWindow *parent = NULL,
124 int x = -1, int y = -1,
126 int width=150, int height=200);
129 int wxMessageBox(const wxString& message,
130 const wxString& caption = wxPyEmptyString,
131 int style = wxOK | wxCENTRE,
132 wxWindow *parent = NULL,
133 int x = -1, int y = -1);
135 long wxGetNumberFromUser(const wxString& message,
136 const wxString& prompt,
137 const wxString& caption,
139 long min = 0, long max = 100,
140 wxWindow *parent = NULL,
141 const wxPoint& pos = wxDefaultPosition);
143 //---------------------------------------------------------------------------
146 bool wxColourDisplay();
148 int wxDisplayDepth();
149 int wxGetDisplayDepth();
151 void wxDisplaySize(int* OUTPUT, int* OUTPUT);
152 wxSize wxGetDisplaySize();
154 void wxDisplaySizeMM(int* OUTPUT, int* OUTPUT);
155 wxSize wxGetDisplaySizeMM();
157 void wxClientDisplayRect(int *OUTPUT, int *OUTPUT, int *OUTPUT, int *OUTPUT);
158 wxRect wxGetClientDisplayRect();
160 void wxSetCursor(wxCursor& cursor);
162 //----------------------------------------------------------------------
163 // Miscellaneous functions
165 void wxBeginBusyCursor(wxCursor *cursor = wxHOURGLASS_CURSOR);
166 wxWindow * wxGetActiveWindow();
168 wxWindow* wxGenericFindWindowAtPoint(const wxPoint& pt);
169 wxWindow* wxFindWindowAtPoint(const wxPoint& pt);
172 bool wxCheckForInterrupt(wxWindow *wnd);
173 void wxFlushEvents();
176 wxWindow* wxGetTopLevelParent(wxWindow *win);
178 //---------------------------------------------------------------------------
181 bool wxResourceAddIdentifier(char* name, int value);
182 void wxResourceClear(void);
183 wxBitmap wxResourceCreateBitmap(char* resource);
184 wxIcon wxResourceCreateIcon(char* resource);
185 wxMenuBar * wxResourceCreateMenuBar(char* resource);
186 int wxResourceGetIdentifier(char* name);
187 bool wxResourceParseData(char* resource, wxResourceTable *table = NULL);
188 bool wxResourceParseFile(char* filename, wxResourceTable *table = NULL);
189 bool wxResourceParseString(char* resource, wxResourceTable *table = NULL);
191 //---------------------------------------------------------------------------
194 // possible values for wxSystemSettings::GetFont() parameter
198 wxSYS_OEM_FIXED_FONT = 10,
199 wxSYS_ANSI_FIXED_FONT,
202 wxSYS_DEVICE_DEFAULT_FONT,
203 wxSYS_DEFAULT_PALETTE,
204 wxSYS_SYSTEM_FIXED_FONT,
205 wxSYS_DEFAULT_GUI_FONT
208 // possible values for wxSystemSettings::GetColour() parameter
212 wxSYS_COLOUR_SCROLLBAR,
213 wxSYS_COLOUR_BACKGROUND,
214 wxSYS_COLOUR_DESKTOP = wxSYS_COLOUR_BACKGROUND,
215 wxSYS_COLOUR_ACTIVECAPTION,
216 wxSYS_COLOUR_INACTIVECAPTION,
219 wxSYS_COLOUR_WINDOWFRAME,
220 wxSYS_COLOUR_MENUTEXT,
221 wxSYS_COLOUR_WINDOWTEXT,
222 wxSYS_COLOUR_CAPTIONTEXT,
223 wxSYS_COLOUR_ACTIVEBORDER,
224 wxSYS_COLOUR_INACTIVEBORDER,
225 wxSYS_COLOUR_APPWORKSPACE,
226 wxSYS_COLOUR_HIGHLIGHT,
227 wxSYS_COLOUR_HIGHLIGHTTEXT,
228 wxSYS_COLOUR_BTNFACE,
229 wxSYS_COLOUR_3DFACE = wxSYS_COLOUR_BTNFACE,
230 wxSYS_COLOUR_BTNSHADOW,
231 wxSYS_COLOUR_3DSHADOW = wxSYS_COLOUR_BTNSHADOW,
232 wxSYS_COLOUR_GRAYTEXT,
233 wxSYS_COLOUR_BTNTEXT,
234 wxSYS_COLOUR_INACTIVECAPTIONTEXT,
235 wxSYS_COLOUR_BTNHIGHLIGHT,
236 wxSYS_COLOUR_BTNHILIGHT = wxSYS_COLOUR_BTNHIGHLIGHT,
237 wxSYS_COLOUR_3DHIGHLIGHT = wxSYS_COLOUR_BTNHIGHLIGHT,
238 wxSYS_COLOUR_3DHILIGHT = wxSYS_COLOUR_BTNHIGHLIGHT,
239 wxSYS_COLOUR_3DDKSHADOW,
240 wxSYS_COLOUR_3DLIGHT,
241 wxSYS_COLOUR_INFOTEXT,
243 wxSYS_COLOUR_LISTBOX,
244 wxSYS_COLOUR_HOTLIGHT,
245 wxSYS_COLOUR_GRADIENTACTIVECAPTION,
246 wxSYS_COLOUR_GRADIENTINACTIVECAPTION,
247 wxSYS_COLOUR_MENUHILIGHT,
248 wxSYS_COLOUR_MENUBAR,
253 // possible values for wxSystemSettings::GetMetric() parameter
257 wxSYS_MOUSE_BUTTONS = 1,
268 wxSYS_HSCROLL_ARROW_X,
269 wxSYS_HSCROLL_ARROW_Y,
285 wxSYS_VSCROLL_ARROW_X,
286 wxSYS_VSCROLL_ARROW_Y,
290 wxSYS_NETWORK_PRESENT,
291 wxSYS_PENWINDOWS_PRESENT,
296 // possible values for wxSystemSettings::HasFeature() parameter
299 wxSYS_CAN_DRAW_FRAME_DECORATIONS = 1,
300 wxSYS_CAN_ICONIZE_FRAME
303 enum wxSystemScreenType
305 wxSYS_SCREEN_NONE = 0, // not yet defined
307 wxSYS_SCREEN_TINY, // <
308 wxSYS_SCREEN_PDA, // >= 320x240
309 wxSYS_SCREEN_SMALL, // >= 640x480
310 wxSYS_SCREEN_DESKTOP // >= 800x600
314 class wxSystemSettings {
316 // get a standard system colour
317 static wxColour GetColour(wxSystemColour index);
319 // get a standard system font
320 static wxFont GetFont(wxSystemFont index);
322 // get a system-dependent metric
323 static int GetMetric(wxSystemMetric index);
325 // return true if the port has certain feature
326 static bool HasFeature(wxSystemFeature index);
328 // Get system screen design (desktop, pda, ..) used for
329 // laying out various dialogs.
330 static wxSystemScreenType GetScreenType();
333 static void SetScreenType( wxSystemScreenType screen );
339 //---------------------------------------------------------------------------
342 class wxToolTip : public wxObject {
344 wxToolTip(const wxString &tip);
346 void SetTip(const wxString& tip);
348 // *** Not in the "public" interface void SetWindow(wxWindow *win);
349 wxWindow *GetWindow();
351 static void Enable(bool flag);
352 static void SetDelay(long milliseconds);
355 //----------------------------------------------------------------------
359 wxCaret(wxWindow* window, const wxSize& size);
364 %name(GetPositionTuple)void GetPosition(int *OUTPUT, int *OUTPUT);
365 wxPoint GetPosition();
366 %name(GetSizeTuple)void GetSize(int *OUTPUT, int *OUTPUT);
368 wxWindow *GetWindow();
369 %name(MoveXY)void Move(int x, int y);
370 void Move(const wxPoint& pt);
371 %name(SetSizeWH) void SetSize(int width, int height);
372 void SetSize(const wxSize& size);
373 void Show(int show = TRUE);
378 int wxCaret_GetBlinkTime() {
379 return wxCaret::GetBlinkTime();
382 void wxCaret_SetBlinkTime(int milliseconds) {
383 wxCaret::SetBlinkTime(milliseconds);
387 //----------------------------------------------------------------------
391 wxBusyCursor(wxCursor* cursor = wxHOURGLASS_CURSOR);
395 //----------------------------------------------------------------------
397 class wxWindowDisabler {
399 wxWindowDisabler(wxWindow *winToSkip = NULL);
403 //----------------------------------------------------------------------
405 bool wxSafeYield(wxWindow* win=NULL);
406 void wxPostEvent(wxEvtHandler *dest, wxEvent& event);
411 void wxWakeUpMainThread();
414 void wxMutexGuiEnter();
415 void wxMutexGuiLeave();
418 class wxMutexGuiLocker {
426 bool wxThread_IsMain() {
427 #ifdef WXP_WITH_THREAD
428 return wxThread::IsMain();
435 //----------------------------------------------------------------------
441 // wxTipProvider(size_t currentTip); **** Abstract base class
444 virtual wxString GetTip() = 0;
445 size_t GetCurrentTip();
450 // The C++ version of wxPyTipProvider
452 class wxPyTipProvider : public wxTipProvider {
454 wxPyTipProvider(size_t currentTip)
455 : wxTipProvider(currentTip) {}
457 DEC_PYCALLBACK_STRING__pure(GetTip);
462 IMP_PYCALLBACK_STRING__pure( wxPyTipProvider, wxTipProvider, GetTip);
467 // Now let SWIG know about it
468 class wxPyTipProvider : public wxTipProvider {
470 wxPyTipProvider(size_t currentTip);
472 void _setCallbackInfo(PyObject* self, PyObject* _class);
473 %pragma(python) addtomethod = "__init__:self._setCallbackInfo(self, wxPyTipProvider)"
478 bool wxShowTip(wxWindow *parent, wxTipProvider *tipProvider, bool showAtStartup = TRUE);
479 %new wxTipProvider * wxCreateFileTipProvider(const wxString& filename, size_t currentTip);
482 //----------------------------------------------------------------------
485 #include <wx/generic/dragimgg.h>
488 %name (wxDragImage) class wxGenericDragImage : public wxObject
492 wxGenericDragImage(const wxBitmap& image,
493 const wxCursor& cursor = wxNullCursor);
494 %name(wxDragIcon)wxGenericDragImage(const wxIcon& image,
495 const wxCursor& cursor = wxNullCursor);
496 %name(wxDragString)wxGenericDragImage(const wxString& str,
497 const wxCursor& cursor = wxNullCursor);
498 %name(wxDragTreeItem)wxGenericDragImage(const wxTreeCtrl& treeCtrl, wxTreeItemId& id);
499 %name(wxDragListItem)wxGenericDragImage(const wxListCtrl& listCtrl, long id);
501 ~wxGenericDragImage();
503 void SetBackingBitmap(wxBitmap* bitmap);
504 bool BeginDrag(const wxPoint& hotspot, wxWindow* window,
505 bool fullScreen = FALSE, wxRect* rect = NULL);
507 %name(BeginDrag2) bool BeginDrag(const wxPoint& hotspot, wxWindow* window,
508 wxWindow* fullScreenRect);
511 bool Move(const wxPoint& pt);
515 wxRect GetImageRect(const wxPoint& pos) const;
516 bool RedrawImage(const wxPoint& oldPos, const wxPoint& newPos,
517 bool eraseOld, bool drawNew);
521 //----------------------------------------------------------------------
523 class wxPyTimer : public wxObject {
525 wxPyTimer(PyObject* notify);
530 void SetOwner(wxEvtHandler *owner, int id = -1);
531 void Start(int milliseconds=-1, int oneShot=FALSE);
539 // ctor starts the stop watch
542 void Start(long t = 0);
546 // get elapsed time since the last Start() or Pause() in milliseconds
551 //----------------------------------------------------------------------
552 //----------------------------------------------------------------------
557 wxLOG_FatalError, // program can't continue, abort immediately
558 wxLOG_Error, // a serious error, user must be informed about it
559 wxLOG_Warning, // user is normally informed about it but may be ignored
560 wxLOG_Message, // normal message (i.e. normal output of a non GUI app)
561 wxLOG_Info, // informational message (a.k.a. 'Verbose')
562 wxLOG_Status, // informational: might go to the status line of GUI app
563 wxLOG_Debug, // never shown to the user, disabled in release mode
564 wxLOG_Trace, // trace messages are also only enabled in debug mode
565 wxLOG_Progress, // used for progress indicator (not yet)
566 wxLOG_User = 100 // user defined levels start here
569 #define wxTRACE_MemAlloc "memalloc" // trace memory allocation (new/delete)
570 #define wxTRACE_Messages "messages" // trace window messages/X callbacks
571 #define wxTRACE_ResAlloc "resalloc" // trace GDI resource allocation
572 #define wxTRACE_RefCount "refcount" // trace various ref counting operations
575 #define wxTRACE_OleCalls "ole" // OLE interface calls
596 static bool IsEnabled();
597 static bool EnableLogging(bool doIt = TRUE);
598 static void OnLog(unsigned long level, const wxString& szString, int t=0);
600 virtual void Flush();
601 bool HasPendingMessages() const;
603 static void FlushActive();
604 static wxLog *GetActiveTarget();
605 static wxLog *SetActiveTarget(wxLog *pLogger);
607 static void Suspend();
608 static void Resume();
610 static void SetVerbose(bool bVerbose = TRUE);
612 static void DontCreateOnDemand();
613 static void SetTraceMask(long ulMask);
614 static void AddTraceMask(const wxString& str);
615 static void RemoveTraceMask(const wxString& str);
616 static void ClearTraceMasks();
618 static void SetTimestamp(const wxString& ts);
619 static const wxString& GetTimestamp();
621 bool GetVerbose() const;
623 static unsigned long GetTraceMask();
624 static bool IsAllowedTraceMask(const wxString& mask);
626 // static void TimeStamp(wxString *str);
628 wxString TimeStamp() {
630 wxLog::TimeStamp(&msg);
638 class wxLogStderr : public wxLog
641 wxLogStderr(/* TODO: FILE *fp = (FILE *) NULL*/);
645 class wxLogTextCtrl : public wxLog
648 wxLogTextCtrl(wxTextCtrl *pTextCtrl);
652 class wxLogGui : public wxLog
658 class wxLogWindow : public wxLog
661 wxLogWindow(wxFrame *pParent, // the parent frame (can be NULL)
662 const wxString& szTitle, // the title of the frame
663 bool bShow = TRUE, // show window immediately?
664 bool bPassToOld = TRUE); // pass log messages to the old target?
666 void Show(bool bShow = TRUE);
667 wxFrame *GetFrame() const;
668 wxLog *GetOldLog() const;
669 bool IsPassingMessages() const;
670 void PassMessages(bool bDoPass);
674 class wxLogChain : public wxLog
677 wxLogChain(wxLog *logger);
678 void SetLog(wxLog *logger);
679 void PassMessages(bool bDoPass);
680 bool IsPassingMessages();
685 unsigned long wxSysErrorCode();
686 const wxString wxSysErrorMsg(unsigned long nErrCode = 0);
687 void wxLogFatalError(const wxString& msg);
688 void wxLogError(const wxString& msg);
689 void wxLogWarning(const wxString& msg);
690 void wxLogMessage(const wxString& msg);
691 void wxLogInfo(const wxString& msg);
692 void wxLogVerbose(const wxString& msg);
693 void wxLogStatus(const wxString& msg);
694 %name(wxLogStatusFrame)void wxLogStatus(wxFrame *pFrame, const wxString& msg);
695 void wxLogSysError(const wxString& msg);
697 void wxLogTrace(const wxString& msg);
698 %name(wxLogTraceMask)void wxLogTrace(const wxString& mask, const wxString& msg);
700 void wxLogGeneric(unsigned long level, const wxString& msg);
702 // wxLogFatalError helper: show the (fatal) error to the user in a safe way,
703 // i.e. without using wxMessageBox() for example because it could crash
704 void wxSafeShowMessage(const wxString& title, const wxString& text);
708 // Suspress logging while an instance of this class exists
720 // A wxLog class that can be derived from in wxPython
721 class wxPyLog : public wxLog {
723 wxPyLog() : wxLog() {}
725 virtual void DoLog(wxLogLevel level, const wxChar *szString, time_t t) {
727 wxPyBeginBlockThreads();
728 if ((found = wxPyCBH_findCallback(m_myInst, "DoLog"))) {
729 PyObject* s = wx2PyString(szString);
730 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iOi)", level, s, t));
733 wxPyEndBlockThreads();
735 wxLog::DoLog(level, szString, t);
738 virtual void DoLogString(const wxChar *szString, time_t t) {
740 wxPyBeginBlockThreads();
741 if ((found = wxPyCBH_findCallback(m_myInst, "DoLogString"))) {
742 PyObject* s = wx2PyString(szString);
743 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oi)", s, t));
746 wxPyEndBlockThreads();
748 wxLog::DoLogString(szString, t);
755 // Now tell SWIG about it
756 class wxPyLog : public wxLog {
759 void _setCallbackInfo(PyObject* self, PyObject* _class);
760 %pragma(python) addtomethod = "__init__:self._setCallbackInfo(self, wxPyLog)"
761 %addmethods { void Destroy() { delete self; } }
766 //----------------------------------------------------------------------
771 wxKILL_OK, // no error
772 wxKILL_BAD_SIGNAL, // no such signal
773 wxKILL_ACCESS_DENIED, // permission denied
774 wxKILL_NO_PROCESS, // no such process
775 wxKILL_ERROR // another, unspecified error
780 wxSIGNONE = 0, // verify if the process exists under Unix
787 wxSIGIOT = wxSIGABRT, // another name
798 // further signals are different in meaning between different Unix systems
810 class wxProcessEvent : public wxEvent {
812 wxProcessEvent(int id = 0, int pid = 0, int exitcode = 0);
815 int m_pid, m_exitcode;
821 %{ // C++ version of wxProcess derived class
823 class wxPyProcess : public wxProcess {
825 wxPyProcess(wxEvtHandler *parent = NULL, int id = -1)
826 : wxProcess(parent, id)
829 DEC_PYCALLBACK_VOID_INTINT(OnTerminate);
834 IMP_PYCALLBACK_VOID_INTINT( wxPyProcess, wxProcess, OnTerminate);
839 %name(wxProcess)class wxPyProcess : public wxEvtHandler {
841 // kill the process with the given PID
842 static wxKillError Kill(int pid, wxSignal sig = wxSIGTERM);
844 // test if the given process exists
845 static bool Exists(int pid);
847 // this function replaces the standard popen() one: it launches a process
848 // asynchronously and allows the caller to get the streams connected to its
851 // on error NULL is returned, in any case the process object will be
852 // deleted automatically when the process terminates and should *not* be
853 // deleted by the caller
854 static wxPyProcess *Open(const wxString& cmd, int flags = wxEXEC_ASYNC);
858 wxPyProcess(wxEvtHandler *parent = NULL, int id = -1);
859 %addmethods { void Destroy() { delete self; } }
861 void _setCallbackInfo(PyObject* self, PyObject* _class);
862 %pragma(python) addtomethod = "__init__:self._setCallbackInfo(self, wxProcess)"
864 void base_OnTerminate(int pid, int status);
870 wxInputStream *GetInputStream();
871 wxInputStream *GetErrorStream();
872 wxOutputStream *GetOutputStream();
880 // execute the process asynchronously
883 // execute it synchronously, i.e. wait until it finishes
886 // under Windows, don't hide the child even if it's IO is redirected (this
887 // is done by default)
890 // under Unix, if the process is the group leader then killing -pid kills
891 // all children as well as pid
892 wxEXEC_MAKE_GROUP_LEADER = 4
896 long wxExecute(const wxString& command,
897 int flags = wxEXEC_ASYNC,
898 wxPyProcess *process = NULL);
900 //----------------------------------------------------------------------
903 // Which joystick? Same as Windows ids so no conversion necessary.
910 // Which button is down?
922 #if !wxUSE_JOYSTICK && !defined(__WXMSW__)
923 // A C++ stub class for wxJoystick for platforms that don't have it.
924 class wxJoystick : public wxObject {
926 wxJoystick(int joystick = wxJOYSTICK1) {
927 wxPyBeginBlockThreads();
928 PyErr_SetString(PyExc_NotImplementedError, "wxJoystick is not available on this platform.");
929 wxPyEndBlockThreads();
931 wxPoint GetPosition() { return wxPoint(-1,-1); }
932 int GetZPosition() { return -1; }
933 int GetButtonState() { return -1; }
934 int GetPOVPosition() { return -1; }
935 int GetPOVCTSPosition() { return -1; }
936 int GetRudderPosition() { return -1; }
937 int GetUPosition() { return -1; }
938 int GetVPosition() { return -1; }
939 int GetMovementThreshold() { return -1; }
940 void SetMovementThreshold(int threshold) {}
942 bool IsOk(void) { return FALSE; }
943 int GetNumberJoysticks() { return -1; }
944 int GetManufacturerId() { return -1; }
945 int GetProductId() { return -1; }
946 wxString GetProductName() { return ""; }
947 int GetXMin() { return -1; }
948 int GetYMin() { return -1; }
949 int GetZMin() { return -1; }
950 int GetXMax() { return -1; }
951 int GetYMax() { return -1; }
952 int GetZMax() { return -1; }
953 int GetNumberButtons() { return -1; }
954 int GetNumberAxes() { return -1; }
955 int GetMaxButtons() { return -1; }
956 int GetMaxAxes() { return -1; }
957 int GetPollingMin() { return -1; }
958 int GetPollingMax() { return -1; }
959 int GetRudderMin() { return -1; }
960 int GetRudderMax() { return -1; }
961 int GetUMin() { return -1; }
962 int GetUMax() { return -1; }
963 int GetVMin() { return -1; }
964 int GetVMax() { return -1; }
966 bool HasRudder() { return FALSE; }
967 bool HasZ() { return FALSE; }
968 bool HasU() { return FALSE; }
969 bool HasV() { return FALSE; }
970 bool HasPOV() { return FALSE; }
971 bool HasPOV4Dir() { return FALSE; }
972 bool HasPOVCTS() { return FALSE; }
974 bool SetCapture(wxWindow* win, int pollingFreq = 0) { return FALSE; }
975 bool ReleaseCapture() { return FALSE; }
981 class wxJoystick : public wxObject {
983 wxJoystick(int joystick = wxJOYSTICK1);
986 wxPoint GetPosition();
988 int GetButtonState();
989 int GetPOVPosition();
990 int GetPOVCTSPosition();
991 int GetRudderPosition();
994 int GetMovementThreshold();
995 void SetMovementThreshold(int threshold) ;
998 int GetNumberJoysticks();
999 int GetManufacturerId();
1001 wxString GetProductName();
1008 int GetNumberButtons();
1009 int GetNumberAxes();
1010 int GetMaxButtons();
1012 int GetPollingMin();
1013 int GetPollingMax();
1029 bool SetCapture(wxWindow* win, int pollingFreq = 0);
1030 bool ReleaseCapture();
1033 //----------------------------------------------------------------------
1037 // A C++ stub class for wxWave for platforms that don't have it.
1038 class wxWave : public wxObject
1041 wxWave(const wxString& fileName, bool isResource = FALSE) {
1042 wxPyBeginBlockThreads();
1043 PyErr_SetString(PyExc_NotImplementedError, "wxWave is not available on this platform.");
1044 wxPyEndBlockThreads();
1046 wxWave(int size, const wxByte* data) {
1047 wxPyBeginBlockThreads();
1048 PyErr_SetString(PyExc_NotImplementedError, "wxWave is not available on this platform.");
1049 wxPyEndBlockThreads();
1054 bool IsOk() const { return FALSE; }
1055 bool Play(bool async = TRUE, bool looped = FALSE) const { return FALSE; }
1061 class wxWave : public wxObject
1064 wxWave(const wxString& fileName, bool isResource = FALSE);
1068 bool Play(bool async = TRUE, bool looped = FALSE) const;
1071 %new wxWave* wxWaveData(const wxString& data);
1072 %{ // Implementations of some alternate "constructors"
1073 wxWave* wxWaveData(const wxString& data) {
1074 return new wxWave(data.Len(), (wxByte*)data.c_str());
1079 //----------------------------------------------------------------------
1083 wxMAILCAP_STANDARD = 1,
1084 wxMAILCAP_NETSCAPE = 2,
1086 wxMAILCAP_GNOME = 8,
1093 class wxFileTypeInfo
1098 wxFileTypeInfo(const char* mimeType,
1099 const char* openCmd,
1100 const char* printCmd,
1104 // the array elements correspond to the parameters of the ctor above in
1106 %name(wxFileTypeInfoSequence)wxFileTypeInfo(const wxArrayString& sArray);
1108 // invalid item - use this to terminate the array passed to
1109 // wxMimeTypesManager::AddFallbacks
1110 %name(wxNullFileTypeInfo)wxFileTypeInfo();
1113 // test if this object can be used
1114 bool IsValid() const;
1117 // set the icon info
1118 void SetIcon(const wxString& iconFile, int iconIndex = 0);
1120 // set the short desc
1121 void SetShortDesc(const wxString& shortDesc);
1124 // get the MIME type
1125 const wxString& GetMimeType() const;
1126 // get the open command
1127 const wxString& GetOpenCommand() const;
1128 // get the print command
1129 const wxString& GetPrintCommand() const;
1130 // get the short description (only used under Win32 so far)
1131 const wxString& GetShortDesc() const;
1132 // get the long, user visible description
1133 const wxString& GetDescription() const;
1136 // get the array of all extensions
1137 //const wxArrayString& GetExtensions() const;
1139 PyObject* GetExtensions() {
1140 wxArrayString& arr = (wxArrayString&)self->GetExtensions();
1141 return wxArrayString2PyList_helper(arr);
1145 int GetExtensionsCount() const;
1147 // get the icon info
1148 const wxString& GetIconFile() const;
1149 int GetIconIndex() const;
1159 // TODO: Make a wxPyMessageParameters with virtual GetParamValue...
1161 // An object of this class must be passed to Get{Open|Print}Command. The
1162 // default implementation is trivial and doesn't know anything at all about
1163 // parameters, only filename and MIME type are used (so it's probably ok for
1164 // Windows where %{param} is not used anyhow)
1165 class MessageParameters
1169 MessageParameters(const wxString& filename=wxPyEmptyString,
1170 const wxString& mimetype=wxPyEmptyString);
1172 // accessors (called by GetOpenCommand)
1174 const wxString& GetFileName() const;
1176 const wxString& GetMimeType() const;;
1178 // override this function in derived class
1179 virtual wxString GetParamValue(const wxString& name) const;
1181 // virtual dtor as in any base class
1182 virtual ~MessageParameters();
1186 // ctor from static data
1187 wxFileType(const wxFileTypeInfo& ftInfo);
1189 // return the MIME type for this file type
1191 PyObject* GetMimeType() {
1193 if (self->GetMimeType(&str)) {
1195 return PyUnicode_FromUnicode(str.c_str(), str.Len());
1197 return PyString_FromStringAndSize(str.c_str(), str.Len());
1203 PyObject* GetMimeTypes() {
1205 if (self->GetMimeTypes(arr))
1206 return wxArrayString2PyList_helper(arr);
1213 // Get all extensions associated with this file type
1215 PyObject* GetExtensions() {
1217 if (self->GetExtensions(arr))
1218 return wxArrayString2PyList_helper(arr);
1226 // Get the icon corresponding to this file type
1227 %new wxIcon* GetIcon() {
1229 if (self->GetIcon(&icon))
1230 return new wxIcon(icon);
1235 // Get the icon corresponding to this file type, the name of the file
1236 // where this icon resides, and its index in this file if applicable.
1237 PyObject* GetIconInfo() {
1241 if (self->GetIcon(&icon, &iconFile, &iconIndex)) {
1242 wxPyBeginBlockThreads();
1243 PyObject* tuple = PyTuple_New(3);
1244 PyTuple_SetItem(tuple, 0, wxPyConstructObject(new wxIcon(icon),
1247 PyTuple_SetItem(tuple, 1, PyUnicode_FromUnicode(iconFile.c_str(), iconFile.Len()));
1249 PyTuple_SetItem(tuple, 1, PyString_FromStringAndSize(iconFile.c_str(), iconFile.Len()));
1251 PyTuple_SetItem(tuple, 2, PyInt_FromLong(iconIndex));
1252 wxPyEndBlockThreads();
1261 // get a brief file type description ("*.txt" => "text document")
1262 PyObject* GetDescription() {
1264 if (self->GetDescription(&str)) {
1266 return PyUnicode_FromUnicode(str.c_str(), str.Len());
1268 return PyString_FromStringAndSize(str.c_str(), str.Len());
1276 // get the command to open/execute the file of given type
1278 PyObject* GetOpenCommand(const wxString& filename,
1279 const wxString& mimetype=wxPyEmptyString) {
1281 if (self->GetOpenCommand(&str, wxFileType::MessageParameters(filename, mimetype))) {
1283 return PyUnicode_FromUnicode(str.c_str(), str.Len());
1285 return PyString_FromStringAndSize(str.c_str(), str.Len());
1293 // get the command to print the file of given type
1295 PyObject* GetPrintCommand(const wxString& filename,
1296 const wxString& mimetype=wxPyEmptyString) {
1298 if (self->GetPrintCommand(&str, wxFileType::MessageParameters(filename, mimetype))) {
1300 return PyUnicode_FromUnicode(str.c_str(), str.Len());
1302 return PyString_FromStringAndSize(str.c_str(), str.Len());
1310 // Get all commands defined for this file type
1312 PyObject* GetAllCommands(const wxString& filename,
1313 const wxString& mimetype=wxPyEmptyString) {
1314 wxArrayString verbs;
1315 wxArrayString commands;
1316 if (self->GetAllCommands(&verbs, &commands,
1317 wxFileType::MessageParameters(filename, mimetype))) {
1318 wxPyBeginBlockThreads();
1319 PyObject* tuple = PyTuple_New(2);
1320 PyTuple_SetItem(tuple, 0, wxArrayString2PyList_helper(verbs));
1321 PyTuple_SetItem(tuple, 1, wxArrayString2PyList_helper(commands));
1322 wxPyEndBlockThreads();
1331 // set an arbitrary command, ask confirmation if it already exists and
1332 // overwriteprompt is TRUE
1333 bool SetCommand(const wxString& cmd, const wxString& verb,
1334 bool overwriteprompt = TRUE);
1336 bool SetDefaultIcon(const wxString& cmd = wxPyEmptyString, int index = 0);
1339 // remove the association for this filetype from the system MIME database:
1340 // notice that it will only work if the association is defined in the user
1341 // file/registry part, we will never modify the system-wide settings
1345 // expand a string in the format of GetOpenCommand (which may contain
1346 // '%s' and '%t' format specificators for the file name and mime type
1347 // and %{param} constructions).
1348 static wxString ExpandCommand(const wxString& command,
1349 const MessageParameters& params);
1351 // dtor (not virtual, shouldn't be derived from)
1359 class wxMimeTypesManager
1362 // static helper functions
1363 // -----------------------
1365 // check if the given MIME type is the same as the other one: the
1366 // second argument may contain wildcards ('*'), but not the first. If
1367 // the types are equal or if the mimeType matches wildcard the function
1368 // returns TRUE, otherwise it returns FALSE
1369 static bool IsOfType(const wxString& mimeType, const wxString& wildcard);
1372 wxMimeTypesManager();
1374 // loads data from standard files according to the mailcap styles
1375 // specified: this is a bitwise OR of wxMailcapStyle values
1377 // use the extraDir parameter if you want to look for files in another
1379 void Initialize(int mailcapStyle = wxMAILCAP_STANDARD,
1380 const wxString& extraDir = wxPyEmptyString);
1382 // and this function clears all the data from the manager
1385 // Database lookup: all functions return a pointer to wxFileType object
1386 // whose methods may be used to query it for the information you're
1387 // interested in. If the return value is !NULL, caller is responsible for
1389 // get file type from file extension
1390 %new wxFileType *GetFileTypeFromExtension(const wxString& ext);
1392 // get file type from MIME type (in format <category>/<format>)
1393 %new wxFileType *GetFileTypeFromMimeType(const wxString& mimeType);
1395 // other operations: return TRUE if there were no errors or FALSE if there
1396 // were some unreckognized entries (the good entries are always read anyhow)
1399 // read in additional file (the standard ones are read automatically)
1400 // in mailcap format (see mimetype.cpp for description)
1402 // 'fallback' parameter may be set to TRUE to avoid overriding the
1403 // settings from other, previously parsed, files by this one: normally,
1404 // the files read most recently would override the older files, but with
1405 // fallback == TRUE this won't happen
1406 bool ReadMailcap(const wxString& filename, bool fallback = FALSE);
1408 // read in additional file in mime.types format
1409 bool ReadMimeTypes(const wxString& filename);
1411 // enumerate all known MIME types
1413 PyObject* EnumAllFileTypes() {
1415 self->EnumAllFileTypes(arr);
1416 return wxArrayString2PyList_helper(arr);
1420 // these functions can be used to provide default values for some of the
1421 // MIME types inside the program itself (you may also use
1422 // ReadMailcap(filenameWithDefaultTypes, TRUE /* use as fallback */) to
1423 // achieve the same goal, but this requires having this info in a file).
1425 void AddFallback(const wxFileTypeInfo& ft);
1428 // create or remove associations
1430 // create a new association using the fields of wxFileTypeInfo (at least
1431 // the MIME type and the extension should be set)
1432 // if the other fields are empty, the existing values should be left alone
1433 %new wxFileType *Associate(const wxFileTypeInfo& ftInfo);
1436 bool Unassociate(wxFileType *ft) ;
1438 // dtor (not virtual, shouldn't be derived from)
1439 ~wxMimeTypesManager();
1447 extern wxMimeTypesManager* wxTheMimeTypesManager;
1453 //----------------------------------------------------------------------
1456 #include <wx/artprov.h>
1458 DECLARE_DEF_STRING(ART_OTHER);
1462 %pragma(python) code = "
1464 wxART_TOOLBAR = 'wxART_TOOLBAR_C'
1465 wxART_MENU = 'wxART_MENU_C'
1466 wxART_FRAME_ICON = 'wxART_FRAME_ICON_C'
1467 wxART_CMN_DIALOG = 'wxART_CMN_DIALOG_C'
1468 wxART_HELP_BROWSER = 'wxART_HELP_BROWSER_C'
1469 wxART_MESSAGE_BOX = 'wxART_MESSAGE_BOX_C'
1470 wxART_OTHER = 'wxART_OTHER_C'
1473 wxART_ADD_BOOKMARK = 'wxART_ADD_BOOKMARK'
1474 wxART_DEL_BOOKMARK = 'wxART_DEL_BOOKMARK'
1475 wxART_HELP_SIDE_PANEL = 'wxART_HELP_SIDE_PANEL'
1476 wxART_HELP_SETTINGS = 'wxART_HELP_SETTINGS'
1477 wxART_HELP_BOOK = 'wxART_HELP_BOOK'
1478 wxART_HELP_FOLDER = 'wxART_HELP_FOLDER'
1479 wxART_HELP_PAGE = 'wxART_HELP_PAGE'
1480 wxART_GO_BACK = 'wxART_GO_BACK'
1481 wxART_GO_FORWARD = 'wxART_GO_FORWARD'
1482 wxART_GO_UP = 'wxART_GO_UP'
1483 wxART_GO_DOWN = 'wxART_GO_DOWN'
1484 wxART_GO_TO_PARENT = 'wxART_GO_TO_PARENT'
1485 wxART_GO_HOME = 'wxART_GO_HOME'
1486 wxART_FILE_OPEN = 'wxART_FILE_OPEN'
1487 wxART_PRINT = 'wxART_PRINT'
1488 wxART_HELP = 'wxART_HELP'
1489 wxART_TIP = 'wxART_TIP'
1490 wxART_REPORT_VIEW = 'wxART_REPORT_VIEW'
1491 wxART_LIST_VIEW = 'wxART_LIST_VIEW'
1492 wxART_NEW_DIR = 'wxART_NEW_DIR'
1493 wxART_FOLDER = 'wxART_FOLDER'
1494 wxART_GO_DIR_UP = 'wxART_GO_DIR_UP'
1495 wxART_EXECUTABLE_FILE = 'wxART_EXECUTABLE_FILE'
1496 wxART_NORMAL_FILE = 'wxART_NORMAL_FILE'
1497 wxART_TICK_MARK = 'wxART_TICK_MARK'
1498 wxART_CROSS_MARK = 'wxART_CROSS_MARK'
1499 wxART_ERROR = 'wxART_ERROR'
1500 wxART_QUESTION = 'wxART_QUESTION'
1501 wxART_WARNING = 'wxART_WARNING'
1502 wxART_INFORMATION = 'wxART_INFORMATION'
1505 %{ // Python aware wxArtProvider
1506 class wxPyArtProvider : public wxArtProvider {
1509 virtual wxBitmap CreateBitmap(const wxArtID& id,
1510 const wxArtClient& client,
1511 const wxSize& size) {
1512 wxBitmap rval = wxNullBitmap;
1513 wxPyBeginBlockThreads();
1514 if ((wxPyCBH_findCallback(m_myInst, "CreateBitmap"))) {
1515 PyObject* so = wxPyConstructObject((void*)&size, "wxSize", 0);
1519 s1 = wx2PyString(id);
1520 s2 = wx2PyString(client);
1521 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(OOO)", s1, s2, so));
1526 if (!SWIG_GetPtrObj(ro, (void**)&ptr, "_wxBitmap_p"))
1531 wxPyEndBlockThreads();
1539 // The one for SWIG to see
1540 %name(wxArtProvider) class wxPyArtProvider : public wxObject
1545 void _setCallbackInfo(PyObject* self, PyObject* _class);
1546 %pragma(python) addtomethod = "__init__:self._setCallbackInfo(self, wxArtProvider)"
1548 // Add new provider to the top of providers stack.
1549 static void PushProvider(wxPyArtProvider *provider);
1551 // Remove latest added provider and delete it.
1552 static bool PopProvider();
1554 // Remove provider. The provider must have been added previously!
1555 // The provider is _not_ deleted.
1556 static bool RemoveProvider(wxPyArtProvider *provider);
1558 // Query the providers for bitmap with given ID and return it. Return
1559 // wxNullBitmap if no provider provides it.
1560 static wxBitmap GetBitmap(const wxString& id,
1561 const wxString& client = wxPyART_OTHER,
1562 const wxSize& size = wxDefaultSize);
1564 // Query the providers for icon with given ID and return it. Return
1565 // wxNullIcon if no provider provides it.
1566 static wxIcon GetIcon(const wxString& id,
1567 const wxString& client = wxPyART_OTHER,
1568 const wxSize& size = wxDefaultSize);
1570 // Destroy caches & all providers
1571 static void CleanUpProviders();
1575 //----------------------------------------------------------------------
1578 #include <wx/docview.h>
1581 class wxFileHistory : public wxObject
1584 wxFileHistory(int maxFiles = 9);
1588 void AddFileToHistory(const wxString& file);
1589 void RemoveFileFromHistory(int i);
1590 int GetMaxFiles() const;
1591 void UseMenu(wxMenu *menu);
1593 // Remove menu from the list (MDI child may be closing)
1594 void RemoveMenu(wxMenu *menu);
1596 void Load(wxConfigBase& config);
1597 void Save(wxConfigBase& config);
1599 void AddFilesToMenu();
1600 %name(AddFilesToThisMenu)void AddFilesToMenu(wxMenu* menu);
1603 wxString GetHistoryFile(int i) const;
1605 // A synonym for GetNoHistoryFiles
1606 int GetCount() const;
1607 int GetNoHistoryFiles() const;
1611 //----------------------------------------------------------------------
1612 //----------------------------------------------------------------------
1615 // #if wxUSE_UNICODE
1616 // #define ADD_STRING(dict, str) \
1617 // wxString tmp##str(str); \
1618 // PyDict_SetItemString(dict, #str, \
1619 // PyUnicode_FromUnicode(tmp##str.c_str(), tmp##str.Len()))
1621 // #define ADD_STRING(dict, str) \
1622 // PyDict_SetItemString(d, #str, PyString_FromString(str))
1628 wxPyPtrTypeMap_Add("wxDragImage", "wxGenericDragImage");
1629 wxPyPtrTypeMap_Add("wxProcess", "wxPyProcess");
1630 wxPyPtrTypeMap_Add("wxArtProvider", "wxPyArtProvider");
1634 //----------------------------------------------------------------------