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/tooltip.h>
22 #include <wx/tipdlg.h>
23 #include <wx/process.h>
25 #if wxUSE_JOYSTICK || defined(__WXMSW__)
26 #include <wx/joystick.h>
29 #if wxUSE_WAVE || defined(__WXMSW__)
33 #include <wx/mimetype.h>
34 #include <wx/snglinst.h>
35 #include <wx/effects.h>
38 //----------------------------------------------------------------------
41 %include my_typemaps.i
43 // Import some definitions of other classes, etc.
53 //----------------------------------------------------------------------
56 // Put some wx default wxChar* values into wxStrings.
57 DECLARE_DEF_STRING(FileSelectorPromptStr);
58 DECLARE_DEF_STRING(FileSelectorDefaultWildcardStr);
59 DECLARE_DEF_STRING(DirSelectorPromptStr);
60 static const wxString wxPyEmptyString(wxT(""));
63 //---------------------------------------------------------------------------
66 wxString wxFileSelector(const wxString& message = wxPyFileSelectorPromptStr,
67 const wxString& default_path = wxPyEmptyString,
68 const wxString& default_filename = wxPyEmptyString,
69 const wxString& default_extension = wxPyEmptyString,
70 const wxString& wildcard = wxPyFileSelectorDefaultWildcardStr,
72 wxWindow *parent = NULL,
73 int x = -1, int y = -1);
75 // Ask for filename to load
76 wxString wxLoadFileSelector(const wxString& what,
77 const wxString& extension,
78 const wxString& default_name = wxPyEmptyString,
79 wxWindow *parent = NULL);
81 // Ask for filename to save
82 wxString wxSaveFileSelector(const wxString& what,
83 const wxString& extension,
84 const wxString& default_name = wxPyEmptyString,
85 wxWindow *parent = NULL);
88 wxString wxDirSelector(const wxString& message = wxPyDirSelectorPromptStr,
89 const wxString& defaultPath = wxPyEmptyString,
90 long style = wxDD_DEFAULT_STYLE,
91 const wxPoint& pos = wxDefaultPosition,
92 wxWindow *parent = NULL);
94 wxString wxGetTextFromUser(const wxString& message,
95 const wxString& caption = wxPyEmptyString,
96 const wxString& default_value = wxPyEmptyString,
97 wxWindow *parent = NULL,
98 int x = -1, int y = -1,
101 wxString wxGetPasswordFromUser(const wxString& message,
102 const wxString& caption = wxPyEmptyString,
103 const wxString& default_value = wxPyEmptyString,
104 wxWindow *parent = NULL);
107 // TODO: Need to custom wrap this one...
108 // int wxGetMultipleChoice(char* message, char* caption,
109 // int LCOUNT, char** choices,
110 // int nsel, int *selection,
111 // wxWindow *parent = NULL, int x = -1, int y = -1,
112 // bool centre = TRUE, int width=150, int height=200);
115 wxString wxGetSingleChoice(const wxString& message, const wxString& caption,
116 int LCOUNT, wxString* choices,
117 wxWindow *parent = NULL,
118 int x = -1, int y = -1,
120 int width=150, int height=200);
122 int wxGetSingleChoiceIndex(const wxString& message, const wxString& caption,
123 int LCOUNT, wxString* choices,
124 wxWindow *parent = NULL,
125 int x = -1, int y = -1,
127 int width=150, int height=200);
130 int wxMessageBox(const wxString& message,
131 const wxString& caption = wxPyEmptyString,
132 int style = wxOK | wxCENTRE,
133 wxWindow *parent = NULL,
134 int x = -1, int y = -1);
136 long wxGetNumberFromUser(const wxString& message,
137 const wxString& prompt,
138 const wxString& caption,
140 long min = 0, long max = 100,
141 wxWindow *parent = NULL,
142 const wxPoint& pos = wxDefaultPosition);
144 //---------------------------------------------------------------------------
147 bool wxColourDisplay();
149 int wxDisplayDepth();
150 int wxGetDisplayDepth();
152 void wxDisplaySize(int* OUTPUT, int* OUTPUT);
153 wxSize wxGetDisplaySize();
155 void wxDisplaySizeMM(int* OUTPUT, int* OUTPUT);
156 wxSize wxGetDisplaySizeMM();
158 void wxClientDisplayRect(int *OUTPUT, int *OUTPUT, int *OUTPUT, int *OUTPUT);
159 wxRect wxGetClientDisplayRect();
161 void wxSetCursor(wxCursor& cursor);
163 //----------------------------------------------------------------------
164 // Miscellaneous functions
166 void wxBeginBusyCursor(wxCursor *cursor = wxHOURGLASS_CURSOR);
167 wxWindow * wxGetActiveWindow();
169 wxWindow* wxGenericFindWindowAtPoint(const wxPoint& pt);
170 wxWindow* wxFindWindowAtPoint(const wxPoint& pt);
173 bool wxCheckForInterrupt(wxWindow *wnd);
174 void wxFlushEvents();
177 wxWindow* wxGetTopLevelParent(wxWindow *win);
179 //bool wxSpawnBrowser(wxWindow *parent, wxString href);
181 //---------------------------------------------------------------------------
184 #ifdef wxUSE_WX_RESOURCES
185 bool wxResourceAddIdentifier(char* name, int value);
186 void wxResourceClear(void);
187 wxBitmap wxResourceCreateBitmap(char* resource);
188 wxIcon wxResourceCreateIcon(char* resource);
189 wxMenuBar * wxResourceCreateMenuBar(char* resource);
190 int wxResourceGetIdentifier(char* name);
191 bool wxResourceParseData(char* resource, wxResourceTable *table = NULL);
192 bool wxResourceParseFile(char* filename, wxResourceTable *table = NULL);
193 bool wxResourceParseString(char* resource, wxResourceTable *table = NULL);
196 //---------------------------------------------------------------------------
199 // possible values for wxSystemSettings::GetFont() parameter
203 wxSYS_OEM_FIXED_FONT = 10,
204 wxSYS_ANSI_FIXED_FONT,
207 wxSYS_DEVICE_DEFAULT_FONT,
208 wxSYS_DEFAULT_PALETTE,
209 wxSYS_SYSTEM_FIXED_FONT,
210 wxSYS_DEFAULT_GUI_FONT
213 // possible values for wxSystemSettings::GetColour() parameter
217 wxSYS_COLOUR_SCROLLBAR,
218 wxSYS_COLOUR_BACKGROUND,
219 wxSYS_COLOUR_DESKTOP = wxSYS_COLOUR_BACKGROUND,
220 wxSYS_COLOUR_ACTIVECAPTION,
221 wxSYS_COLOUR_INACTIVECAPTION,
224 wxSYS_COLOUR_WINDOWFRAME,
225 wxSYS_COLOUR_MENUTEXT,
226 wxSYS_COLOUR_WINDOWTEXT,
227 wxSYS_COLOUR_CAPTIONTEXT,
228 wxSYS_COLOUR_ACTIVEBORDER,
229 wxSYS_COLOUR_INACTIVEBORDER,
230 wxSYS_COLOUR_APPWORKSPACE,
231 wxSYS_COLOUR_HIGHLIGHT,
232 wxSYS_COLOUR_HIGHLIGHTTEXT,
233 wxSYS_COLOUR_BTNFACE,
234 wxSYS_COLOUR_3DFACE = wxSYS_COLOUR_BTNFACE,
235 wxSYS_COLOUR_BTNSHADOW,
236 wxSYS_COLOUR_3DSHADOW = wxSYS_COLOUR_BTNSHADOW,
237 wxSYS_COLOUR_GRAYTEXT,
238 wxSYS_COLOUR_BTNTEXT,
239 wxSYS_COLOUR_INACTIVECAPTIONTEXT,
240 wxSYS_COLOUR_BTNHIGHLIGHT,
241 wxSYS_COLOUR_BTNHILIGHT = wxSYS_COLOUR_BTNHIGHLIGHT,
242 wxSYS_COLOUR_3DHIGHLIGHT = wxSYS_COLOUR_BTNHIGHLIGHT,
243 wxSYS_COLOUR_3DHILIGHT = wxSYS_COLOUR_BTNHIGHLIGHT,
244 wxSYS_COLOUR_3DDKSHADOW,
245 wxSYS_COLOUR_3DLIGHT,
246 wxSYS_COLOUR_INFOTEXT,
248 wxSYS_COLOUR_LISTBOX,
249 wxSYS_COLOUR_HOTLIGHT,
250 wxSYS_COLOUR_GRADIENTACTIVECAPTION,
251 wxSYS_COLOUR_GRADIENTINACTIVECAPTION,
252 wxSYS_COLOUR_MENUHILIGHT,
253 wxSYS_COLOUR_MENUBAR,
258 // possible values for wxSystemSettings::GetMetric() parameter
262 wxSYS_MOUSE_BUTTONS = 1,
273 wxSYS_HSCROLL_ARROW_X,
274 wxSYS_HSCROLL_ARROW_Y,
290 wxSYS_VSCROLL_ARROW_X,
291 wxSYS_VSCROLL_ARROW_Y,
295 wxSYS_NETWORK_PRESENT,
296 wxSYS_PENWINDOWS_PRESENT,
301 // possible values for wxSystemSettings::HasFeature() parameter
304 wxSYS_CAN_DRAW_FRAME_DECORATIONS = 1,
305 wxSYS_CAN_ICONIZE_FRAME
308 enum wxSystemScreenType
310 wxSYS_SCREEN_NONE = 0, // not yet defined
312 wxSYS_SCREEN_TINY, // <
313 wxSYS_SCREEN_PDA, // >= 320x240
314 wxSYS_SCREEN_SMALL, // >= 640x480
315 wxSYS_SCREEN_DESKTOP // >= 800x600
319 class wxSystemSettings {
321 // get a standard system colour
322 static wxColour GetColour(wxSystemColour index);
324 // get a standard system font
325 static wxFont GetFont(wxSystemFont index);
327 // get a system-dependent metric
328 static int GetMetric(wxSystemMetric index);
330 // return true if the port has certain feature
331 static bool HasFeature(wxSystemFeature index);
333 // Get system screen design (desktop, pda, ..) used for
334 // laying out various dialogs.
335 static wxSystemScreenType GetScreenType();
338 static void SetScreenType( wxSystemScreenType screen );
344 //---------------------------------------------------------------------------
347 class wxToolTip : public wxObject {
349 wxToolTip(const wxString &tip);
351 void SetTip(const wxString& tip);
353 // *** Not in the "public" interface void SetWindow(wxWindow *win);
354 wxWindow *GetWindow();
356 static void Enable(bool flag);
357 static void SetDelay(long milliseconds);
360 //----------------------------------------------------------------------
364 wxCaret(wxWindow* window, const wxSize& size);
369 %name(GetPositionTuple)void GetPosition(int *OUTPUT, int *OUTPUT);
370 wxPoint GetPosition();
371 %name(GetSizeTuple)void GetSize(int *OUTPUT, int *OUTPUT);
373 wxWindow *GetWindow();
374 %name(MoveXY)void Move(int x, int y);
375 void Move(const wxPoint& pt);
376 %name(SetSizeWH) void SetSize(int width, int height);
377 void SetSize(const wxSize& size);
378 void Show(int show = TRUE);
381 %pragma(python) addtoclass = "def __nonzero__(self): return self.IsOk()"
385 int wxCaret_GetBlinkTime() {
386 return wxCaret::GetBlinkTime();
389 void wxCaret_SetBlinkTime(int milliseconds) {
390 wxCaret::SetBlinkTime(milliseconds);
394 //----------------------------------------------------------------------
398 wxBusyCursor(wxCursor* cursor = wxHOURGLASS_CURSOR);
402 //----------------------------------------------------------------------
404 class wxWindowDisabler {
406 wxWindowDisabler(wxWindow *winToSkip = NULL);
410 //----------------------------------------------------------------------
412 bool wxSafeYield(wxWindow* win=NULL, bool onlyIfNeeded=FALSE);
413 void wxPostEvent(wxEvtHandler *dest, wxEvent& event);
418 void wxWakeUpMainThread();
421 void wxMutexGuiEnter();
422 void wxMutexGuiLeave();
425 class wxMutexGuiLocker {
433 bool wxThread_IsMain() {
434 #ifdef WXP_WITH_THREAD
435 return wxThread::IsMain();
442 //----------------------------------------------------------------------
448 // wxTipProvider(size_t currentTip); **** Abstract base class
451 virtual wxString GetTip() = 0;
452 size_t GetCurrentTip();
453 virtual wxString PreprocessTip(const wxString& tip);
457 // The C++ version of wxPyTipProvider
459 class wxPyTipProvider : public wxTipProvider {
461 wxPyTipProvider(size_t currentTip)
462 : wxTipProvider(currentTip) {}
464 DEC_PYCALLBACK_STRING__pure(GetTip);
465 DEC_PYCALLBACK_STRING_STRING(PreprocessTip);
469 IMP_PYCALLBACK_STRING__pure( wxPyTipProvider, wxTipProvider, GetTip);
470 IMP_PYCALLBACK_STRING_STRING(wxPyTipProvider, wxTipProvider, PreprocessTip);
474 // Now let SWIG know about it
475 class wxPyTipProvider : public wxTipProvider {
477 wxPyTipProvider(size_t currentTip);
479 void _setCallbackInfo(PyObject* self, PyObject* _class);
480 %pragma(python) addtomethod = "__init__:self._setCallbackInfo(self, wxPyTipProvider)"
485 bool wxShowTip(wxWindow *parent, wxTipProvider *tipProvider, bool showAtStartup = TRUE);
486 %new wxTipProvider * wxCreateFileTipProvider(const wxString& filename, size_t currentTip);
489 //----------------------------------------------------------------------
492 #include <wx/generic/dragimgg.h>
495 %name (wxDragImage) class wxGenericDragImage : public wxObject
499 wxGenericDragImage(const wxBitmap& image,
500 const wxCursor& cursor = wxNullCursor);
501 %name(wxDragIcon)wxGenericDragImage(const wxIcon& image,
502 const wxCursor& cursor = wxNullCursor);
503 %name(wxDragString)wxGenericDragImage(const wxString& str,
504 const wxCursor& cursor = wxNullCursor);
505 %name(wxDragTreeItem)wxGenericDragImage(const wxTreeCtrl& treeCtrl, wxTreeItemId& id);
506 %name(wxDragListItem)wxGenericDragImage(const wxListCtrl& listCtrl, long id);
508 ~wxGenericDragImage();
510 void SetBackingBitmap(wxBitmap* bitmap);
511 bool BeginDrag(const wxPoint& hotspot, wxWindow* window,
512 bool fullScreen = FALSE, wxRect* rect = NULL);
514 %name(BeginDragBounded) bool BeginDrag(const wxPoint& hotspot, wxWindow* window,
515 wxWindow* boundingWindow);
517 %pragma(python) addtoclass = "BeginDrag2 = BeginDragBounded"
520 bool Move(const wxPoint& pt);
524 wxRect GetImageRect(const wxPoint& pos) const;
525 bool RedrawImage(const wxPoint& oldPos, const wxPoint& newPos,
526 bool eraseOld, bool drawNew);
530 //----------------------------------------------------------------------
532 class wxPyTimer : public wxObject {
534 wxPyTimer(PyObject* notify);
539 void SetOwner(wxEvtHandler *owner, int id = -1);
540 bool Start(int milliseconds=-1, int oneShot=FALSE);
548 // ctor starts the stop watch
551 void Start(long t = 0);
555 // get elapsed time since the last Start() or Pause() in milliseconds
560 //----------------------------------------------------------------------
561 //----------------------------------------------------------------------
566 wxLOG_FatalError, // program can't continue, abort immediately
567 wxLOG_Error, // a serious error, user must be informed about it
568 wxLOG_Warning, // user is normally informed about it but may be ignored
569 wxLOG_Message, // normal message (i.e. normal output of a non GUI app)
570 wxLOG_Info, // informational message (a.k.a. 'Verbose')
571 wxLOG_Status, // informational: might go to the status line of GUI app
572 wxLOG_Debug, // never shown to the user, disabled in release mode
573 wxLOG_Trace, // trace messages are also only enabled in debug mode
574 wxLOG_Progress, // used for progress indicator (not yet)
575 wxLOG_User = 100 // user defined levels start here
578 #define wxTRACE_MemAlloc "memalloc" // trace memory allocation (new/delete)
579 #define wxTRACE_Messages "messages" // trace window messages/X callbacks
580 #define wxTRACE_ResAlloc "resalloc" // trace GDI resource allocation
581 #define wxTRACE_RefCount "refcount" // trace various ref counting operations
584 #define wxTRACE_OleCalls "ole" // OLE interface calls
605 static bool IsEnabled();
606 static bool EnableLogging(bool doIt = TRUE);
607 static void OnLog(unsigned long level, const wxString& szString, int t=0);
609 virtual void Flush();
610 static void FlushActive();
611 static wxLog *GetActiveTarget();
612 static wxLog *SetActiveTarget(wxLog *pLogger);
614 static void Suspend();
615 static void Resume();
617 static void SetVerbose(bool bVerbose = TRUE);
619 static void DontCreateOnDemand();
620 static void SetTraceMask(long ulMask);
621 static void AddTraceMask(const wxString& str);
622 static void RemoveTraceMask(const wxString& str);
623 static void ClearTraceMasks();
624 static const wxArrayString &GetTraceMasks();
626 static void SetTimestamp(const wxString& ts);
627 static const wxString& GetTimestamp();
629 bool GetVerbose() const;
631 static unsigned long GetTraceMask();
632 static bool IsAllowedTraceMask(const wxString& mask);
634 static void SetLogLevel(unsigned long logLevel);
635 static unsigned long GetLogLevel();
638 // static void TimeStamp(wxString *str);
640 wxString TimeStamp() {
642 wxLog::TimeStamp(&msg);
650 class wxLogStderr : public wxLog
653 wxLogStderr(/* TODO: FILE *fp = (FILE *) NULL*/);
657 class wxLogTextCtrl : public wxLog
660 wxLogTextCtrl(wxTextCtrl *pTextCtrl);
664 class wxLogGui : public wxLog
670 class wxLogWindow : public wxLog
673 wxLogWindow(wxFrame *pParent, // the parent frame (can be NULL)
674 const wxString& szTitle, // the title of the frame
675 bool bShow = TRUE, // show window immediately?
676 bool bPassToOld = TRUE); // pass log messages to the old target?
678 void Show(bool bShow = TRUE);
679 wxFrame *GetFrame() const;
680 wxLog *GetOldLog() const;
681 bool IsPassingMessages() const;
682 void PassMessages(bool bDoPass);
686 class wxLogChain : public wxLog
689 wxLogChain(wxLog *logger);
690 void SetLog(wxLog *logger);
691 void PassMessages(bool bDoPass);
692 bool IsPassingMessages();
697 unsigned long wxSysErrorCode();
698 const wxString wxSysErrorMsg(unsigned long nErrCode = 0);
699 void wxLogFatalError(const wxString& msg);
700 void wxLogError(const wxString& msg);
701 void wxLogWarning(const wxString& msg);
702 void wxLogMessage(const wxString& msg);
703 void wxLogInfo(const wxString& msg);
704 void wxLogDebug(const wxString& msg);
705 void wxLogVerbose(const wxString& msg);
706 void wxLogStatus(const wxString& msg);
707 %name(wxLogStatusFrame)void wxLogStatus(wxFrame *pFrame, const wxString& msg);
708 void wxLogSysError(const wxString& msg);
710 void wxLogTrace(const wxString& msg);
711 %name(wxLogTraceMask)void wxLogTrace(const wxString& mask, const wxString& msg);
713 void wxLogGeneric(unsigned long level, const wxString& msg);
715 // wxLogFatalError helper: show the (fatal) error to the user in a safe way,
716 // i.e. without using wxMessageBox() for example because it could crash
717 void wxSafeShowMessage(const wxString& title, const wxString& text);
721 // Suspress logging while an instance of this class exists
733 // A wxLog class that can be derived from in wxPython
734 class wxPyLog : public wxLog {
736 wxPyLog() : wxLog() {}
738 virtual void DoLog(wxLogLevel level, const wxChar *szString, time_t t) {
740 wxPyBeginBlockThreads();
741 if ((found = wxPyCBH_findCallback(m_myInst, "DoLog"))) {
742 PyObject* s = wx2PyString(szString);
743 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iOi)", level, s, t));
746 wxPyEndBlockThreads();
748 wxLog::DoLog(level, szString, t);
751 virtual void DoLogString(const wxChar *szString, time_t t) {
753 wxPyBeginBlockThreads();
754 if ((found = wxPyCBH_findCallback(m_myInst, "DoLogString"))) {
755 PyObject* s = wx2PyString(szString);
756 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oi)", s, t));
759 wxPyEndBlockThreads();
761 wxLog::DoLogString(szString, t);
768 // Now tell SWIG about it
769 class wxPyLog : public wxLog {
772 void _setCallbackInfo(PyObject* self, PyObject* _class);
773 %pragma(python) addtomethod = "__init__:self._setCallbackInfo(self, wxPyLog)"
774 %addmethods { void Destroy() { delete self; } }
779 //----------------------------------------------------------------------
784 wxKILL_OK, // no error
785 wxKILL_BAD_SIGNAL, // no such signal
786 wxKILL_ACCESS_DENIED, // permission denied
787 wxKILL_NO_PROCESS, // no such process
788 wxKILL_ERROR // another, unspecified error
793 wxSIGNONE = 0, // verify if the process exists under Unix
800 wxSIGIOT = wxSIGABRT, // another name
811 // further signals are different in meaning between different Unix systems
823 class wxProcessEvent : public wxEvent {
825 wxProcessEvent(int id = 0, int pid = 0, int exitcode = 0);
828 int m_pid, m_exitcode;
834 %{ // C++ version of wxProcess derived class
836 class wxPyProcess : public wxProcess {
838 wxPyProcess(wxEvtHandler *parent = NULL, int id = -1)
839 : wxProcess(parent, id)
842 DEC_PYCALLBACK_VOID_INTINT(OnTerminate);
847 IMP_PYCALLBACK_VOID_INTINT( wxPyProcess, wxProcess, OnTerminate);
852 %name(wxProcess)class wxPyProcess : public wxEvtHandler {
854 // kill the process with the given PID
855 static wxKillError Kill(int pid, wxSignal sig = wxSIGTERM);
857 // test if the given process exists
858 static bool Exists(int pid);
860 // this function replaces the standard popen() one: it launches a process
861 // asynchronously and allows the caller to get the streams connected to its
864 // on error NULL is returned, in any case the process object will be
865 // deleted automatically when the process terminates and should *not* be
866 // deleted by the caller
867 static wxPyProcess *Open(const wxString& cmd, int flags = wxEXEC_ASYNC);
871 wxPyProcess(wxEvtHandler *parent = NULL, int id = -1);
872 %addmethods { void Destroy() { delete self; } }
874 void _setCallbackInfo(PyObject* self, PyObject* _class);
875 %pragma(python) addtomethod = "__init__:self._setCallbackInfo(self, wxProcess)"
877 void base_OnTerminate(int pid, int status);
883 wxInputStream *GetInputStream();
884 wxInputStream *GetErrorStream();
885 wxOutputStream *GetOutputStream();
889 // return TRUE if the child process stdout is not closed
890 bool IsInputOpened() const;
892 // return TRUE if any input is available on the child process stdout/err
893 bool IsInputAvailable() const;
894 bool IsErrorAvailable() const;
900 // execute the process asynchronously
903 // execute it synchronously, i.e. wait until it finishes
906 // under Windows, don't hide the child even if it's IO is redirected (this
907 // is done by default)
910 // under Unix, if the process is the group leader then killing -pid kills
911 // all children as well as pid
912 wxEXEC_MAKE_GROUP_LEADER = 4
916 long wxExecute(const wxString& command,
917 int flags = wxEXEC_ASYNC,
918 wxPyProcess *process = NULL);
920 //----------------------------------------------------------------------
923 // Which joystick? Same as Windows ids so no conversion necessary.
930 // Which button is down?
942 #if !wxUSE_JOYSTICK && !defined(__WXMSW__)
943 // A C++ stub class for wxJoystick for platforms that don't have it.
944 class wxJoystick : public wxObject {
946 wxJoystick(int joystick = wxJOYSTICK1) {
947 wxPyBeginBlockThreads();
948 PyErr_SetString(PyExc_NotImplementedError, "wxJoystick is not available on this platform.");
949 wxPyEndBlockThreads();
951 wxPoint GetPosition() { return wxPoint(-1,-1); }
952 int GetZPosition() { return -1; }
953 int GetButtonState() { return -1; }
954 int GetPOVPosition() { return -1; }
955 int GetPOVCTSPosition() { return -1; }
956 int GetRudderPosition() { return -1; }
957 int GetUPosition() { return -1; }
958 int GetVPosition() { return -1; }
959 int GetMovementThreshold() { return -1; }
960 void SetMovementThreshold(int threshold) {}
962 bool IsOk(void) { return FALSE; }
963 int GetNumberJoysticks() { return -1; }
964 int GetManufacturerId() { return -1; }
965 int GetProductId() { return -1; }
966 wxString GetProductName() { return ""; }
967 int GetXMin() { return -1; }
968 int GetYMin() { return -1; }
969 int GetZMin() { return -1; }
970 int GetXMax() { return -1; }
971 int GetYMax() { return -1; }
972 int GetZMax() { return -1; }
973 int GetNumberButtons() { return -1; }
974 int GetNumberAxes() { return -1; }
975 int GetMaxButtons() { return -1; }
976 int GetMaxAxes() { return -1; }
977 int GetPollingMin() { return -1; }
978 int GetPollingMax() { return -1; }
979 int GetRudderMin() { return -1; }
980 int GetRudderMax() { return -1; }
981 int GetUMin() { return -1; }
982 int GetUMax() { return -1; }
983 int GetVMin() { return -1; }
984 int GetVMax() { return -1; }
986 bool HasRudder() { return FALSE; }
987 bool HasZ() { return FALSE; }
988 bool HasU() { return FALSE; }
989 bool HasV() { return FALSE; }
990 bool HasPOV() { return FALSE; }
991 bool HasPOV4Dir() { return FALSE; }
992 bool HasPOVCTS() { return FALSE; }
994 bool SetCapture(wxWindow* win, int pollingFreq = 0) { return FALSE; }
995 bool ReleaseCapture() { return FALSE; }
1001 class wxJoystick : public wxObject {
1003 wxJoystick(int joystick = wxJOYSTICK1);
1006 wxPoint GetPosition();
1008 int GetButtonState();
1009 int GetPOVPosition();
1010 int GetPOVCTSPosition();
1011 int GetRudderPosition();
1014 int GetMovementThreshold();
1015 void SetMovementThreshold(int threshold) ;
1018 int GetNumberJoysticks();
1019 int GetManufacturerId();
1021 wxString GetProductName();
1028 int GetNumberButtons();
1029 int GetNumberAxes();
1030 int GetMaxButtons();
1032 int GetPollingMin();
1033 int GetPollingMax();
1049 bool SetCapture(wxWindow* win, int pollingFreq = 0);
1050 bool ReleaseCapture();
1052 %pragma(python) addtoclass = "def __nonzero__(self): return self.IsOk()"
1055 //----------------------------------------------------------------------
1059 // A C++ stub class for wxWave for platforms that don't have it.
1060 class wxWave : public wxObject
1063 wxWave(const wxString& fileName, bool isResource = FALSE) {
1064 wxPyBeginBlockThreads();
1065 PyErr_SetString(PyExc_NotImplementedError, "wxWave is not available on this platform.");
1066 wxPyEndBlockThreads();
1068 wxWave(int size, const wxByte* data) {
1069 wxPyBeginBlockThreads();
1070 PyErr_SetString(PyExc_NotImplementedError, "wxWave is not available on this platform.");
1071 wxPyEndBlockThreads();
1076 bool IsOk() const { return FALSE; }
1077 bool Play(bool async = TRUE, bool looped = FALSE) const { return FALSE; }
1083 class wxWave : public wxObject
1086 wxWave(const wxString& fileName, bool isResource = FALSE);
1090 bool Play(bool async = TRUE, bool looped = FALSE) const;
1092 %pragma(python) addtoclass = "def __nonzero__(self): return self.IsOk()"
1095 %new wxWave* wxWaveData(const wxString& data);
1096 %{ // Implementations of some alternate "constructors"
1097 wxWave* wxWaveData(const wxString& data) {
1098 return new wxWave(data.Len(), (wxByte*)data.c_str());
1103 //----------------------------------------------------------------------
1107 wxMAILCAP_STANDARD = 1,
1108 wxMAILCAP_NETSCAPE = 2,
1110 wxMAILCAP_GNOME = 8,
1117 class wxFileTypeInfo
1122 wxFileTypeInfo(const wxString& mimeType,
1123 const wxString& openCmd,
1124 const wxString& printCmd,
1125 const wxString& desc);
1128 // the array elements correspond to the parameters of the ctor above in
1130 %name(wxFileTypeInfoSequence)wxFileTypeInfo(const wxArrayString& sArray);
1132 // invalid item - use this to terminate the array passed to
1133 // wxMimeTypesManager::AddFallbacks
1134 %name(wxNullFileTypeInfo)wxFileTypeInfo();
1137 // test if this object can be used
1138 bool IsValid() const;
1141 // set the icon info
1142 void SetIcon(const wxString& iconFile, int iconIndex = 0);
1144 // set the short desc
1145 void SetShortDesc(const wxString& shortDesc);
1148 // get the MIME type
1149 const wxString& GetMimeType() const;
1150 // get the open command
1151 const wxString& GetOpenCommand() const;
1152 // get the print command
1153 const wxString& GetPrintCommand() const;
1154 // get the short description (only used under Win32 so far)
1155 const wxString& GetShortDesc() const;
1156 // get the long, user visible description
1157 const wxString& GetDescription() const;
1160 // get the array of all extensions
1161 //const wxArrayString& GetExtensions() const;
1163 PyObject* GetExtensions() {
1164 wxArrayString& arr = (wxArrayString&)self->GetExtensions();
1165 return wxArrayString2PyList_helper(arr);
1169 int GetExtensionsCount() const;
1171 // get the icon info
1172 const wxString& GetIconFile() const;
1173 int GetIconIndex() const;
1183 // TODO: Make a wxPyMessageParameters with virtual GetParamValue...
1185 // An object of this class must be passed to Get{Open|Print}Command. The
1186 // default implementation is trivial and doesn't know anything at all about
1187 // parameters, only filename and MIME type are used (so it's probably ok for
1188 // Windows where %{param} is not used anyhow)
1189 class MessageParameters
1193 MessageParameters(const wxString& filename=wxPyEmptyString,
1194 const wxString& mimetype=wxPyEmptyString);
1196 // accessors (called by GetOpenCommand)
1198 const wxString& GetFileName() const;
1200 const wxString& GetMimeType() const;;
1202 // override this function in derived class
1203 virtual wxString GetParamValue(const wxString& name) const;
1205 // virtual dtor as in any base class
1206 virtual ~MessageParameters();
1210 // ctor from static data
1211 wxFileType(const wxFileTypeInfo& ftInfo);
1213 // return the MIME type for this file type
1215 PyObject* GetMimeType() {
1217 if (self->GetMimeType(&str)) {
1219 return PyUnicode_FromWideChar(str.c_str(), str.Len());
1221 return PyString_FromStringAndSize(str.c_str(), str.Len());
1227 PyObject* GetMimeTypes() {
1229 if (self->GetMimeTypes(arr))
1230 return wxArrayString2PyList_helper(arr);
1237 // Get all extensions associated with this file type
1239 PyObject* GetExtensions() {
1241 if (self->GetExtensions(arr))
1242 return wxArrayString2PyList_helper(arr);
1250 // Get the icon corresponding to this file type
1251 %new wxIcon* GetIcon() {
1253 if (self->GetIcon(&loc))
1254 return new wxIcon(loc);
1259 // Get the icon corresponding to this file type, the name of the file
1260 // where this icon resides, and its index in this file if applicable.
1261 PyObject* GetIconInfo() {
1263 if (self->GetIcon(&loc)) {
1264 wxString iconFile = loc.GetFileName();
1267 iconIndex = loc.GetIndex();
1269 // Make a tuple and put the values in it
1270 wxPyBeginBlockThreads();
1271 PyObject* tuple = PyTuple_New(3);
1272 PyTuple_SetItem(tuple, 0,
1273 wxPyConstructObject(new wxIcon(loc), wxT("wxIcon"), TRUE));
1275 PyTuple_SetItem(tuple, 1, PyUnicode_FromWideChar(iconFile.c_str(), iconFile.Len()));
1277 PyTuple_SetItem(tuple, 1, PyString_FromStringAndSize(iconFile.c_str(), iconFile.Len()));
1279 PyTuple_SetItem(tuple, 2, PyInt_FromLong(iconIndex));
1280 wxPyEndBlockThreads();
1289 // get a brief file type description ("*.txt" => "text document")
1290 PyObject* GetDescription() {
1292 if (self->GetDescription(&str)) {
1294 return PyUnicode_FromWideChar(str.c_str(), str.Len());
1296 return PyString_FromStringAndSize(str.c_str(), str.Len());
1304 // get the command to open/execute the file of given type
1306 PyObject* GetOpenCommand(const wxString& filename,
1307 const wxString& mimetype=wxPyEmptyString) {
1309 if (self->GetOpenCommand(&str, wxFileType::MessageParameters(filename, mimetype))) {
1311 return PyUnicode_FromWideChar(str.c_str(), str.Len());
1313 return PyString_FromStringAndSize(str.c_str(), str.Len());
1321 // get the command to print the file of given type
1323 PyObject* GetPrintCommand(const wxString& filename,
1324 const wxString& mimetype=wxPyEmptyString) {
1326 if (self->GetPrintCommand(&str, wxFileType::MessageParameters(filename, mimetype))) {
1328 return PyUnicode_FromWideChar(str.c_str(), str.Len());
1330 return PyString_FromStringAndSize(str.c_str(), str.Len());
1338 // Get all commands defined for this file type
1340 PyObject* GetAllCommands(const wxString& filename,
1341 const wxString& mimetype=wxPyEmptyString) {
1342 wxArrayString verbs;
1343 wxArrayString commands;
1344 if (self->GetAllCommands(&verbs, &commands,
1345 wxFileType::MessageParameters(filename, mimetype))) {
1346 wxPyBeginBlockThreads();
1347 PyObject* tuple = PyTuple_New(2);
1348 PyTuple_SetItem(tuple, 0, wxArrayString2PyList_helper(verbs));
1349 PyTuple_SetItem(tuple, 1, wxArrayString2PyList_helper(commands));
1350 wxPyEndBlockThreads();
1359 // set an arbitrary command, ask confirmation if it already exists and
1360 // overwriteprompt is TRUE
1361 bool SetCommand(const wxString& cmd, const wxString& verb,
1362 bool overwriteprompt = TRUE);
1364 bool SetDefaultIcon(const wxString& cmd = wxPyEmptyString, int index = 0);
1367 // remove the association for this filetype from the system MIME database:
1368 // notice that it will only work if the association is defined in the user
1369 // file/registry part, we will never modify the system-wide settings
1373 // expand a string in the format of GetOpenCommand (which may contain
1374 // '%s' and '%t' format specificators for the file name and mime type
1375 // and %{param} constructions).
1376 static wxString ExpandCommand(const wxString& command,
1377 const MessageParameters& params);
1379 // dtor (not virtual, shouldn't be derived from)
1387 class wxMimeTypesManager
1390 // static helper functions
1391 // -----------------------
1393 // check if the given MIME type is the same as the other one: the
1394 // second argument may contain wildcards ('*'), but not the first. If
1395 // the types are equal or if the mimeType matches wildcard the function
1396 // returns TRUE, otherwise it returns FALSE
1397 static bool IsOfType(const wxString& mimeType, const wxString& wildcard);
1400 wxMimeTypesManager();
1402 // loads data from standard files according to the mailcap styles
1403 // specified: this is a bitwise OR of wxMailcapStyle values
1405 // use the extraDir parameter if you want to look for files in another
1407 void Initialize(int mailcapStyle = wxMAILCAP_ALL,
1408 const wxString& extraDir = wxPyEmptyString);
1410 // and this function clears all the data from the manager
1413 // Database lookup: all functions return a pointer to wxFileType object
1414 // whose methods may be used to query it for the information you're
1415 // interested in. If the return value is !NULL, caller is responsible for
1417 // get file type from file extension
1418 %new wxFileType *GetFileTypeFromExtension(const wxString& ext);
1420 // get file type from MIME type (in format <category>/<format>)
1421 %new wxFileType *GetFileTypeFromMimeType(const wxString& mimeType);
1423 // other operations: return TRUE if there were no errors or FALSE if there
1424 // were some unreckognized entries (the good entries are always read anyhow)
1427 // read in additional file (the standard ones are read automatically)
1428 // in mailcap format (see mimetype.cpp for description)
1430 // 'fallback' parameter may be set to TRUE to avoid overriding the
1431 // settings from other, previously parsed, files by this one: normally,
1432 // the files read most recently would override the older files, but with
1433 // fallback == TRUE this won't happen
1434 bool ReadMailcap(const wxString& filename, bool fallback = FALSE);
1436 // read in additional file in mime.types format
1437 bool ReadMimeTypes(const wxString& filename);
1439 // enumerate all known MIME types
1441 PyObject* EnumAllFileTypes() {
1443 self->EnumAllFileTypes(arr);
1444 return wxArrayString2PyList_helper(arr);
1448 // these functions can be used to provide default values for some of the
1449 // MIME types inside the program itself (you may also use
1450 // ReadMailcap(filenameWithDefaultTypes, TRUE /* use as fallback */) to
1451 // achieve the same goal, but this requires having this info in a file).
1453 void AddFallback(const wxFileTypeInfo& ft);
1456 // create or remove associations
1458 // create a new association using the fields of wxFileTypeInfo (at least
1459 // the MIME type and the extension should be set)
1460 // if the other fields are empty, the existing values should be left alone
1461 %new wxFileType *Associate(const wxFileTypeInfo& ftInfo);
1464 bool Unassociate(wxFileType *ft) ;
1466 // dtor (not virtual, shouldn't be derived from)
1467 ~wxMimeTypesManager();
1475 // See also wxPy_ReinitStockObjects in helpers.cpp
1476 extern wxMimeTypesManager* wxTheMimeTypesManager;
1482 //----------------------------------------------------------------------
1485 #include <wx/artprov.h>
1487 DECLARE_DEF_STRING(ART_OTHER);
1491 %pragma(python) code = "
1493 wxART_TOOLBAR = 'wxART_TOOLBAR_C'
1494 wxART_MENU = 'wxART_MENU_C'
1495 wxART_FRAME_ICON = 'wxART_FRAME_ICON_C'
1496 wxART_CMN_DIALOG = 'wxART_CMN_DIALOG_C'
1497 wxART_HELP_BROWSER = 'wxART_HELP_BROWSER_C'
1498 wxART_MESSAGE_BOX = 'wxART_MESSAGE_BOX_C'
1499 wxART_OTHER = 'wxART_OTHER_C'
1502 wxART_ADD_BOOKMARK = 'wxART_ADD_BOOKMARK'
1503 wxART_DEL_BOOKMARK = 'wxART_DEL_BOOKMARK'
1504 wxART_HELP_SIDE_PANEL = 'wxART_HELP_SIDE_PANEL'
1505 wxART_HELP_SETTINGS = 'wxART_HELP_SETTINGS'
1506 wxART_HELP_BOOK = 'wxART_HELP_BOOK'
1507 wxART_HELP_FOLDER = 'wxART_HELP_FOLDER'
1508 wxART_HELP_PAGE = 'wxART_HELP_PAGE'
1509 wxART_GO_BACK = 'wxART_GO_BACK'
1510 wxART_GO_FORWARD = 'wxART_GO_FORWARD'
1511 wxART_GO_UP = 'wxART_GO_UP'
1512 wxART_GO_DOWN = 'wxART_GO_DOWN'
1513 wxART_GO_TO_PARENT = 'wxART_GO_TO_PARENT'
1514 wxART_GO_HOME = 'wxART_GO_HOME'
1515 wxART_FILE_OPEN = 'wxART_FILE_OPEN'
1516 wxART_PRINT = 'wxART_PRINT'
1517 wxART_HELP = 'wxART_HELP'
1518 wxART_TIP = 'wxART_TIP'
1519 wxART_REPORT_VIEW = 'wxART_REPORT_VIEW'
1520 wxART_LIST_VIEW = 'wxART_LIST_VIEW'
1521 wxART_NEW_DIR = 'wxART_NEW_DIR'
1522 wxART_FOLDER = 'wxART_FOLDER'
1523 wxART_GO_DIR_UP = 'wxART_GO_DIR_UP'
1524 wxART_EXECUTABLE_FILE = 'wxART_EXECUTABLE_FILE'
1525 wxART_NORMAL_FILE = 'wxART_NORMAL_FILE'
1526 wxART_TICK_MARK = 'wxART_TICK_MARK'
1527 wxART_CROSS_MARK = 'wxART_CROSS_MARK'
1528 wxART_ERROR = 'wxART_ERROR'
1529 wxART_QUESTION = 'wxART_QUESTION'
1530 wxART_WARNING = 'wxART_WARNING'
1531 wxART_INFORMATION = 'wxART_INFORMATION'
1532 wxART_MISSING_IMAGE = 'wxART_MISSING_IMAGE'
1535 %{ // Python aware wxArtProvider
1536 class wxPyArtProvider : public wxArtProvider {
1539 virtual wxBitmap CreateBitmap(const wxArtID& id,
1540 const wxArtClient& client,
1541 const wxSize& size) {
1542 wxBitmap rval = wxNullBitmap;
1543 wxPyBeginBlockThreads();
1544 if ((wxPyCBH_findCallback(m_myInst, "CreateBitmap"))) {
1545 PyObject* so = wxPyConstructObject((void*)&size, wxT("wxSize"), 0);
1549 s1 = wx2PyString(id);
1550 s2 = wx2PyString(client);
1551 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(OOO)", s1, s2, so));
1556 if (!SWIG_GetPtrObj(ro, (void**)&ptr, "_wxBitmap_p"))
1561 wxPyEndBlockThreads();
1569 // The one for SWIG to see
1570 %name(wxArtProvider) class wxPyArtProvider : public wxObject
1575 void _setCallbackInfo(PyObject* self, PyObject* _class);
1576 %pragma(python) addtomethod = "__init__:self._setCallbackInfo(self, wxArtProvider)"
1578 // Add new provider to the top of providers stack.
1579 static void PushProvider(wxPyArtProvider *provider);
1581 // Remove latest added provider and delete it.
1582 static bool PopProvider();
1584 // Remove provider. The provider must have been added previously!
1585 // The provider is _not_ deleted.
1586 static bool RemoveProvider(wxPyArtProvider *provider);
1588 // Query the providers for bitmap with given ID and return it. Return
1589 // wxNullBitmap if no provider provides it.
1590 static wxBitmap GetBitmap(const wxString& id,
1591 const wxString& client = wxPyART_OTHER,
1592 const wxSize& size = wxDefaultSize);
1594 // Query the providers for icon with given ID and return it. Return
1595 // wxNullIcon if no provider provides it.
1596 static wxIcon GetIcon(const wxString& id,
1597 const wxString& client = wxPyART_OTHER,
1598 const wxSize& size = wxDefaultSize);
1603 //----------------------------------------------------------------------
1606 #include <wx/docview.h>
1609 class wxFileHistory : public wxObject
1612 wxFileHistory(int maxFiles = 9);
1616 void AddFileToHistory(const wxString& file);
1617 void RemoveFileFromHistory(int i);
1618 int GetMaxFiles() const;
1619 void UseMenu(wxMenu *menu);
1621 // Remove menu from the list (MDI child may be closing)
1622 void RemoveMenu(wxMenu *menu);
1624 void Load(wxConfigBase& config);
1625 void Save(wxConfigBase& config);
1627 void AddFilesToMenu();
1628 %name(AddFilesToThisMenu)void AddFilesToMenu(wxMenu* menu);
1631 wxString GetHistoryFile(int i) const;
1633 int GetCount() const;
1634 %pragma(python) addtoclass = "GetNoHistoryFiles = GetCount"
1638 //----------------------------------------------------------------------
1640 class wxEffects: public wxObject
1643 // Assume system colours
1646 wxColour GetHighlightColour() const;
1647 wxColour GetLightShadow() const;
1648 wxColour GetFaceColour() const;
1649 wxColour GetMediumShadow() const;
1650 wxColour GetDarkShadow() const;
1652 void SetHighlightColour(const wxColour& c);
1653 void SetLightShadow(const wxColour& c);
1654 void SetFaceColour(const wxColour& c);
1655 void SetMediumShadow(const wxColour& c);
1656 void SetDarkShadow(const wxColour& c);
1658 void Set(const wxColour& highlightColour, const wxColour& lightShadow,
1659 const wxColour& faceColour, const wxColour& mediumShadow,
1660 const wxColour& darkShadow);
1662 // Draw a sunken edge
1663 void DrawSunkenEdge(wxDC& dc, const wxRect& rect, int borderSize = 1);
1666 bool TileBitmap(const wxRect& rect, wxDC& dc, wxBitmap& bitmap);
1670 //----------------------------------------------------------------------
1672 class wxSingleInstanceChecker
1675 // like Create() but no error checking (dangerous!)
1676 wxSingleInstanceChecker(const wxString& name,
1677 const wxString& path = wxPyEmptyString);
1679 // default ctor, use Create() after it
1680 %name(wxPreSingleInstanceChecker) wxSingleInstanceChecker();
1682 ~wxSingleInstanceChecker();
1685 // name must be given and be as unique as possible, it is used as the mutex
1686 // name under Win32 and the lock file name under Unix -
1687 // wxTheApp->GetAppName() may be a good value for this parameter
1689 // path is optional and is ignored under Win32 and used as the directory to
1690 // create the lock file in under Unix (default is wxGetHomeDir())
1692 // returns FALSE if initialization failed, it doesn't mean that another
1693 // instance is running - use IsAnotherRunning() to check it
1694 bool Create(const wxString& name, const wxString& path = wxPyEmptyString);
1696 // is another copy of this program already running?
1697 bool IsAnotherRunning() const;
1700 //----------------------------------------------------------------------
1704 wxPyPtrTypeMap_Add("wxDragImage", "wxGenericDragImage");
1705 wxPyPtrTypeMap_Add("wxProcess", "wxPyProcess");
1706 wxPyPtrTypeMap_Add("wxArtProvider", "wxPyArtProvider");
1710 //----------------------------------------------------------------------