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>
35 #include <wx/snglinst.h>
36 #include <wx/effects.h>
37 //#include <wx/spawnbrowser.h>
40 //----------------------------------------------------------------------
43 %include my_typemaps.i
45 // Import some definitions of other classes, etc.
55 //----------------------------------------------------------------------
58 // Put some wx default wxChar* values into wxStrings.
59 DECLARE_DEF_STRING(FileSelectorPromptStr);
60 DECLARE_DEF_STRING(FileSelectorDefaultWildcardStr);
61 DECLARE_DEF_STRING(DirSelectorPromptStr);
62 static const wxString wxPyEmptyString(wxT(""));
65 //---------------------------------------------------------------------------
68 wxString wxFileSelector(const wxString& message = wxPyFileSelectorPromptStr,
69 const wxString& default_path = wxPyEmptyString,
70 const wxString& default_filename = wxPyEmptyString,
71 const wxString& default_extension = wxPyEmptyString,
72 const wxString& wildcard = wxPyFileSelectorDefaultWildcardStr,
74 wxWindow *parent = NULL,
75 int x = -1, int y = -1);
77 // Ask for filename to load
78 wxString wxLoadFileSelector(const wxString& what,
79 const wxString& extension,
80 const wxString& default_name = wxPyEmptyString,
81 wxWindow *parent = NULL);
83 // Ask for filename to save
84 wxString wxSaveFileSelector(const wxString& what,
85 const wxString& extension,
86 const wxString& default_name = wxPyEmptyString,
87 wxWindow *parent = NULL);
90 wxString wxDirSelector(const wxString& message = wxPyDirSelectorPromptStr,
91 const wxString& defaultPath = wxPyEmptyString,
92 long style = wxDD_DEFAULT_STYLE,
93 const wxPoint& pos = wxDefaultPosition,
94 wxWindow *parent = NULL);
96 wxString wxGetTextFromUser(const wxString& message,
97 const wxString& caption = wxPyEmptyString,
98 const wxString& default_value = wxPyEmptyString,
99 wxWindow *parent = NULL,
100 int x = -1, int y = -1,
103 wxString wxGetPasswordFromUser(const wxString& message,
104 const wxString& caption = wxPyEmptyString,
105 const wxString& default_value = wxPyEmptyString,
106 wxWindow *parent = NULL);
109 // TODO: Need to custom wrap this one...
110 // int wxGetMultipleChoice(char* message, char* caption,
111 // int LCOUNT, char** choices,
112 // int nsel, int *selection,
113 // wxWindow *parent = NULL, int x = -1, int y = -1,
114 // bool centre = TRUE, int width=150, int height=200);
117 wxString wxGetSingleChoice(const wxString& message, const wxString& caption,
118 int LCOUNT, wxString* choices,
119 wxWindow *parent = NULL,
120 int x = -1, int y = -1,
122 int width=150, int height=200);
124 int wxGetSingleChoiceIndex(const wxString& message, const wxString& caption,
125 int LCOUNT, wxString* choices,
126 wxWindow *parent = NULL,
127 int x = -1, int y = -1,
129 int width=150, int height=200);
132 int wxMessageBox(const wxString& message,
133 const wxString& caption = wxPyEmptyString,
134 int style = wxOK | wxCENTRE,
135 wxWindow *parent = NULL,
136 int x = -1, int y = -1);
138 long wxGetNumberFromUser(const wxString& message,
139 const wxString& prompt,
140 const wxString& caption,
142 long min = 0, long max = 100,
143 wxWindow *parent = NULL,
144 const wxPoint& pos = wxDefaultPosition);
146 //---------------------------------------------------------------------------
149 bool wxColourDisplay();
151 int wxDisplayDepth();
152 int wxGetDisplayDepth();
154 void wxDisplaySize(int* OUTPUT, int* OUTPUT);
155 wxSize wxGetDisplaySize();
157 void wxDisplaySizeMM(int* OUTPUT, int* OUTPUT);
158 wxSize wxGetDisplaySizeMM();
160 void wxClientDisplayRect(int *OUTPUT, int *OUTPUT, int *OUTPUT, int *OUTPUT);
161 wxRect wxGetClientDisplayRect();
163 void wxSetCursor(wxCursor& cursor);
165 //----------------------------------------------------------------------
166 // Miscellaneous functions
168 void wxBeginBusyCursor(wxCursor *cursor = wxHOURGLASS_CURSOR);
169 wxWindow * wxGetActiveWindow();
171 wxWindow* wxGenericFindWindowAtPoint(const wxPoint& pt);
172 wxWindow* wxFindWindowAtPoint(const wxPoint& pt);
175 bool wxCheckForInterrupt(wxWindow *wnd);
176 void wxFlushEvents();
179 wxWindow* wxGetTopLevelParent(wxWindow *win);
181 //bool wxSpawnBrowser(wxWindow *parent, wxString href);
183 //---------------------------------------------------------------------------
186 bool wxResourceAddIdentifier(char* name, int value);
187 void wxResourceClear(void);
188 wxBitmap wxResourceCreateBitmap(char* resource);
189 wxIcon wxResourceCreateIcon(char* resource);
190 wxMenuBar * wxResourceCreateMenuBar(char* resource);
191 int wxResourceGetIdentifier(char* name);
192 bool wxResourceParseData(char* resource, wxResourceTable *table = NULL);
193 bool wxResourceParseFile(char* filename, wxResourceTable *table = NULL);
194 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);
383 int wxCaret_GetBlinkTime() {
384 return wxCaret::GetBlinkTime();
387 void wxCaret_SetBlinkTime(int milliseconds) {
388 wxCaret::SetBlinkTime(milliseconds);
392 //----------------------------------------------------------------------
396 wxBusyCursor(wxCursor* cursor = wxHOURGLASS_CURSOR);
400 //----------------------------------------------------------------------
402 class wxWindowDisabler {
404 wxWindowDisabler(wxWindow *winToSkip = NULL);
408 //----------------------------------------------------------------------
410 bool wxSafeYield(wxWindow* win=NULL);
411 void wxPostEvent(wxEvtHandler *dest, wxEvent& event);
416 void wxWakeUpMainThread();
419 void wxMutexGuiEnter();
420 void wxMutexGuiLeave();
423 class wxMutexGuiLocker {
431 bool wxThread_IsMain() {
432 #ifdef WXP_WITH_THREAD
433 return wxThread::IsMain();
440 //----------------------------------------------------------------------
446 // wxTipProvider(size_t currentTip); **** Abstract base class
449 virtual wxString GetTip() = 0;
450 size_t GetCurrentTip();
451 virtual wxString PreprocessTip(const wxString& tip);
455 // The C++ version of wxPyTipProvider
457 class wxPyTipProvider : public wxTipProvider {
459 wxPyTipProvider(size_t currentTip)
460 : wxTipProvider(currentTip) {}
462 DEC_PYCALLBACK_STRING__pure(GetTip);
463 DEC_PYCALLBACK_STRING_STRING(PreprocessTip);
467 IMP_PYCALLBACK_STRING__pure( wxPyTipProvider, wxTipProvider, GetTip);
468 IMP_PYCALLBACK_STRING_STRING(wxPyTipProvider, wxTipProvider, PreprocessTip);
472 // Now let SWIG know about it
473 class wxPyTipProvider : public wxTipProvider {
475 wxPyTipProvider(size_t currentTip);
477 void _setCallbackInfo(PyObject* self, PyObject* _class);
478 %pragma(python) addtomethod = "__init__:self._setCallbackInfo(self, wxPyTipProvider)"
483 bool wxShowTip(wxWindow *parent, wxTipProvider *tipProvider, bool showAtStartup = TRUE);
484 %new wxTipProvider * wxCreateFileTipProvider(const wxString& filename, size_t currentTip);
487 //----------------------------------------------------------------------
490 #include <wx/generic/dragimgg.h>
493 %name (wxDragImage) class wxGenericDragImage : public wxObject
497 wxGenericDragImage(const wxBitmap& image,
498 const wxCursor& cursor = wxNullCursor);
499 %name(wxDragIcon)wxGenericDragImage(const wxIcon& image,
500 const wxCursor& cursor = wxNullCursor);
501 %name(wxDragString)wxGenericDragImage(const wxString& str,
502 const wxCursor& cursor = wxNullCursor);
503 %name(wxDragTreeItem)wxGenericDragImage(const wxTreeCtrl& treeCtrl, wxTreeItemId& id);
504 %name(wxDragListItem)wxGenericDragImage(const wxListCtrl& listCtrl, long id);
506 ~wxGenericDragImage();
508 void SetBackingBitmap(wxBitmap* bitmap);
509 bool BeginDrag(const wxPoint& hotspot, wxWindow* window,
510 bool fullScreen = FALSE, wxRect* rect = NULL);
512 %name(BeginDrag2) bool BeginDrag(const wxPoint& hotspot, wxWindow* window,
513 wxWindow* fullScreenRect);
516 bool Move(const wxPoint& pt);
520 wxRect GetImageRect(const wxPoint& pos) const;
521 bool RedrawImage(const wxPoint& oldPos, const wxPoint& newPos,
522 bool eraseOld, bool drawNew);
526 //----------------------------------------------------------------------
528 class wxPyTimer : public wxObject {
530 wxPyTimer(PyObject* notify);
535 void SetOwner(wxEvtHandler *owner, int id = -1);
536 void Start(int milliseconds=-1, int oneShot=FALSE);
544 // ctor starts the stop watch
547 void Start(long t = 0);
551 // get elapsed time since the last Start() or Pause() in milliseconds
556 //----------------------------------------------------------------------
557 //----------------------------------------------------------------------
562 wxLOG_FatalError, // program can't continue, abort immediately
563 wxLOG_Error, // a serious error, user must be informed about it
564 wxLOG_Warning, // user is normally informed about it but may be ignored
565 wxLOG_Message, // normal message (i.e. normal output of a non GUI app)
566 wxLOG_Info, // informational message (a.k.a. 'Verbose')
567 wxLOG_Status, // informational: might go to the status line of GUI app
568 wxLOG_Debug, // never shown to the user, disabled in release mode
569 wxLOG_Trace, // trace messages are also only enabled in debug mode
570 wxLOG_Progress, // used for progress indicator (not yet)
571 wxLOG_User = 100 // user defined levels start here
574 #define wxTRACE_MemAlloc "memalloc" // trace memory allocation (new/delete)
575 #define wxTRACE_Messages "messages" // trace window messages/X callbacks
576 #define wxTRACE_ResAlloc "resalloc" // trace GDI resource allocation
577 #define wxTRACE_RefCount "refcount" // trace various ref counting operations
580 #define wxTRACE_OleCalls "ole" // OLE interface calls
601 static bool IsEnabled();
602 static bool EnableLogging(bool doIt = TRUE);
603 static void OnLog(unsigned long level, const wxString& szString, int t=0);
605 virtual void Flush();
606 bool HasPendingMessages() const;
608 static void FlushActive();
609 static wxLog *GetActiveTarget();
610 static wxLog *SetActiveTarget(wxLog *pLogger);
612 static void Suspend();
613 static void Resume();
615 static void SetVerbose(bool bVerbose = TRUE);
617 static void DontCreateOnDemand();
618 static void SetTraceMask(long ulMask);
619 static void AddTraceMask(const wxString& str);
620 static void RemoveTraceMask(const wxString& str);
621 static void ClearTraceMasks();
622 static const wxArrayString &GetTraceMasks();
624 static void SetTimestamp(const wxString& ts);
625 static const wxString& GetTimestamp();
627 bool GetVerbose() const;
629 static unsigned long GetTraceMask();
630 static bool IsAllowedTraceMask(const wxString& mask);
632 // static void TimeStamp(wxString *str);
634 wxString TimeStamp() {
636 wxLog::TimeStamp(&msg);
644 class wxLogStderr : public wxLog
647 wxLogStderr(/* TODO: FILE *fp = (FILE *) NULL*/);
651 class wxLogTextCtrl : public wxLog
654 wxLogTextCtrl(wxTextCtrl *pTextCtrl);
658 class wxLogGui : public wxLog
664 class wxLogWindow : public wxLog
667 wxLogWindow(wxFrame *pParent, // the parent frame (can be NULL)
668 const wxString& szTitle, // the title of the frame
669 bool bShow = TRUE, // show window immediately?
670 bool bPassToOld = TRUE); // pass log messages to the old target?
672 void Show(bool bShow = TRUE);
673 wxFrame *GetFrame() const;
674 wxLog *GetOldLog() const;
675 bool IsPassingMessages() const;
676 void PassMessages(bool bDoPass);
680 class wxLogChain : public wxLog
683 wxLogChain(wxLog *logger);
684 void SetLog(wxLog *logger);
685 void PassMessages(bool bDoPass);
686 bool IsPassingMessages();
691 unsigned long wxSysErrorCode();
692 const wxString wxSysErrorMsg(unsigned long nErrCode = 0);
693 void wxLogFatalError(const wxString& msg);
694 void wxLogError(const wxString& msg);
695 void wxLogWarning(const wxString& msg);
696 void wxLogMessage(const wxString& msg);
697 void wxLogInfo(const wxString& msg);
698 void wxLogVerbose(const wxString& msg);
699 void wxLogStatus(const wxString& msg);
700 %name(wxLogStatusFrame)void wxLogStatus(wxFrame *pFrame, const wxString& msg);
701 void wxLogSysError(const wxString& msg);
703 void wxLogTrace(const wxString& msg);
704 %name(wxLogTraceMask)void wxLogTrace(const wxString& mask, const wxString& msg);
706 void wxLogGeneric(unsigned long level, const wxString& msg);
708 // wxLogFatalError helper: show the (fatal) error to the user in a safe way,
709 // i.e. without using wxMessageBox() for example because it could crash
710 void wxSafeShowMessage(const wxString& title, const wxString& text);
714 // Suspress logging while an instance of this class exists
726 // A wxLog class that can be derived from in wxPython
727 class wxPyLog : public wxLog {
729 wxPyLog() : wxLog() {}
731 virtual void DoLog(wxLogLevel level, const wxChar *szString, time_t t) {
733 wxPyBeginBlockThreads();
734 if ((found = wxPyCBH_findCallback(m_myInst, "DoLog"))) {
735 PyObject* s = wx2PyString(szString);
736 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iOi)", level, s, t));
739 wxPyEndBlockThreads();
741 wxLog::DoLog(level, szString, t);
744 virtual void DoLogString(const wxChar *szString, time_t t) {
746 wxPyBeginBlockThreads();
747 if ((found = wxPyCBH_findCallback(m_myInst, "DoLogString"))) {
748 PyObject* s = wx2PyString(szString);
749 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oi)", s, t));
752 wxPyEndBlockThreads();
754 wxLog::DoLogString(szString, t);
761 // Now tell SWIG about it
762 class wxPyLog : public wxLog {
765 void _setCallbackInfo(PyObject* self, PyObject* _class);
766 %pragma(python) addtomethod = "__init__:self._setCallbackInfo(self, wxPyLog)"
767 %addmethods { void Destroy() { delete self; } }
772 //----------------------------------------------------------------------
777 wxKILL_OK, // no error
778 wxKILL_BAD_SIGNAL, // no such signal
779 wxKILL_ACCESS_DENIED, // permission denied
780 wxKILL_NO_PROCESS, // no such process
781 wxKILL_ERROR // another, unspecified error
786 wxSIGNONE = 0, // verify if the process exists under Unix
793 wxSIGIOT = wxSIGABRT, // another name
804 // further signals are different in meaning between different Unix systems
816 class wxProcessEvent : public wxEvent {
818 wxProcessEvent(int id = 0, int pid = 0, int exitcode = 0);
821 int m_pid, m_exitcode;
827 %{ // C++ version of wxProcess derived class
829 class wxPyProcess : public wxProcess {
831 wxPyProcess(wxEvtHandler *parent = NULL, int id = -1)
832 : wxProcess(parent, id)
835 DEC_PYCALLBACK_VOID_INTINT(OnTerminate);
840 IMP_PYCALLBACK_VOID_INTINT( wxPyProcess, wxProcess, OnTerminate);
845 %name(wxProcess)class wxPyProcess : public wxEvtHandler {
847 // kill the process with the given PID
848 static wxKillError Kill(int pid, wxSignal sig = wxSIGTERM);
850 // test if the given process exists
851 static bool Exists(int pid);
853 // this function replaces the standard popen() one: it launches a process
854 // asynchronously and allows the caller to get the streams connected to its
857 // on error NULL is returned, in any case the process object will be
858 // deleted automatically when the process terminates and should *not* be
859 // deleted by the caller
860 static wxPyProcess *Open(const wxString& cmd, int flags = wxEXEC_ASYNC);
864 wxPyProcess(wxEvtHandler *parent = NULL, int id = -1);
865 %addmethods { void Destroy() { delete self; } }
867 void _setCallbackInfo(PyObject* self, PyObject* _class);
868 %pragma(python) addtomethod = "__init__:self._setCallbackInfo(self, wxProcess)"
870 void base_OnTerminate(int pid, int status);
876 wxInputStream *GetInputStream();
877 wxInputStream *GetErrorStream();
878 wxOutputStream *GetOutputStream();
882 // return TRUE if the child process stdout is not closed
883 bool IsInputOpened() const;
885 // return TRUE if any input is available on the child process stdout/err
886 bool IsInputAvailable() const;
887 bool IsErrorAvailable() const;
893 // execute the process asynchronously
896 // execute it synchronously, i.e. wait until it finishes
899 // under Windows, don't hide the child even if it's IO is redirected (this
900 // is done by default)
903 // under Unix, if the process is the group leader then killing -pid kills
904 // all children as well as pid
905 wxEXEC_MAKE_GROUP_LEADER = 4
909 long wxExecute(const wxString& command,
910 int flags = wxEXEC_ASYNC,
911 wxPyProcess *process = NULL);
913 //----------------------------------------------------------------------
916 // Which joystick? Same as Windows ids so no conversion necessary.
923 // Which button is down?
935 #if !wxUSE_JOYSTICK && !defined(__WXMSW__)
936 // A C++ stub class for wxJoystick for platforms that don't have it.
937 class wxJoystick : public wxObject {
939 wxJoystick(int joystick = wxJOYSTICK1) {
940 wxPyBeginBlockThreads();
941 PyErr_SetString(PyExc_NotImplementedError, "wxJoystick is not available on this platform.");
942 wxPyEndBlockThreads();
944 wxPoint GetPosition() { return wxPoint(-1,-1); }
945 int GetZPosition() { return -1; }
946 int GetButtonState() { return -1; }
947 int GetPOVPosition() { return -1; }
948 int GetPOVCTSPosition() { return -1; }
949 int GetRudderPosition() { return -1; }
950 int GetUPosition() { return -1; }
951 int GetVPosition() { return -1; }
952 int GetMovementThreshold() { return -1; }
953 void SetMovementThreshold(int threshold) {}
955 bool IsOk(void) { return FALSE; }
956 int GetNumberJoysticks() { return -1; }
957 int GetManufacturerId() { return -1; }
958 int GetProductId() { return -1; }
959 wxString GetProductName() { return ""; }
960 int GetXMin() { return -1; }
961 int GetYMin() { return -1; }
962 int GetZMin() { return -1; }
963 int GetXMax() { return -1; }
964 int GetYMax() { return -1; }
965 int GetZMax() { return -1; }
966 int GetNumberButtons() { return -1; }
967 int GetNumberAxes() { return -1; }
968 int GetMaxButtons() { return -1; }
969 int GetMaxAxes() { return -1; }
970 int GetPollingMin() { return -1; }
971 int GetPollingMax() { return -1; }
972 int GetRudderMin() { return -1; }
973 int GetRudderMax() { return -1; }
974 int GetUMin() { return -1; }
975 int GetUMax() { return -1; }
976 int GetVMin() { return -1; }
977 int GetVMax() { return -1; }
979 bool HasRudder() { return FALSE; }
980 bool HasZ() { return FALSE; }
981 bool HasU() { return FALSE; }
982 bool HasV() { return FALSE; }
983 bool HasPOV() { return FALSE; }
984 bool HasPOV4Dir() { return FALSE; }
985 bool HasPOVCTS() { return FALSE; }
987 bool SetCapture(wxWindow* win, int pollingFreq = 0) { return FALSE; }
988 bool ReleaseCapture() { return FALSE; }
994 class wxJoystick : public wxObject {
996 wxJoystick(int joystick = wxJOYSTICK1);
999 wxPoint GetPosition();
1001 int GetButtonState();
1002 int GetPOVPosition();
1003 int GetPOVCTSPosition();
1004 int GetRudderPosition();
1007 int GetMovementThreshold();
1008 void SetMovementThreshold(int threshold) ;
1011 int GetNumberJoysticks();
1012 int GetManufacturerId();
1014 wxString GetProductName();
1021 int GetNumberButtons();
1022 int GetNumberAxes();
1023 int GetMaxButtons();
1025 int GetPollingMin();
1026 int GetPollingMax();
1042 bool SetCapture(wxWindow* win, int pollingFreq = 0);
1043 bool ReleaseCapture();
1046 //----------------------------------------------------------------------
1050 // A C++ stub class for wxWave for platforms that don't have it.
1051 class wxWave : public wxObject
1054 wxWave(const wxString& fileName, bool isResource = FALSE) {
1055 wxPyBeginBlockThreads();
1056 PyErr_SetString(PyExc_NotImplementedError, "wxWave is not available on this platform.");
1057 wxPyEndBlockThreads();
1059 wxWave(int size, const wxByte* data) {
1060 wxPyBeginBlockThreads();
1061 PyErr_SetString(PyExc_NotImplementedError, "wxWave is not available on this platform.");
1062 wxPyEndBlockThreads();
1067 bool IsOk() const { return FALSE; }
1068 bool Play(bool async = TRUE, bool looped = FALSE) const { return FALSE; }
1074 class wxWave : public wxObject
1077 wxWave(const wxString& fileName, bool isResource = FALSE);
1081 bool Play(bool async = TRUE, bool looped = FALSE) const;
1084 %new wxWave* wxWaveData(const wxString& data);
1085 %{ // Implementations of some alternate "constructors"
1086 wxWave* wxWaveData(const wxString& data) {
1087 return new wxWave(data.Len(), (wxByte*)data.c_str());
1092 //----------------------------------------------------------------------
1096 wxMAILCAP_STANDARD = 1,
1097 wxMAILCAP_NETSCAPE = 2,
1099 wxMAILCAP_GNOME = 8,
1106 class wxFileTypeInfo
1111 wxFileTypeInfo(const char* mimeType,
1112 const char* openCmd,
1113 const char* printCmd,
1117 // the array elements correspond to the parameters of the ctor above in
1119 %name(wxFileTypeInfoSequence)wxFileTypeInfo(const wxArrayString& sArray);
1121 // invalid item - use this to terminate the array passed to
1122 // wxMimeTypesManager::AddFallbacks
1123 %name(wxNullFileTypeInfo)wxFileTypeInfo();
1126 // test if this object can be used
1127 bool IsValid() const;
1130 // set the icon info
1131 void SetIcon(const wxString& iconFile, int iconIndex = 0);
1133 // set the short desc
1134 void SetShortDesc(const wxString& shortDesc);
1137 // get the MIME type
1138 const wxString& GetMimeType() const;
1139 // get the open command
1140 const wxString& GetOpenCommand() const;
1141 // get the print command
1142 const wxString& GetPrintCommand() const;
1143 // get the short description (only used under Win32 so far)
1144 const wxString& GetShortDesc() const;
1145 // get the long, user visible description
1146 const wxString& GetDescription() const;
1149 // get the array of all extensions
1150 //const wxArrayString& GetExtensions() const;
1152 PyObject* GetExtensions() {
1153 wxArrayString& arr = (wxArrayString&)self->GetExtensions();
1154 return wxArrayString2PyList_helper(arr);
1158 int GetExtensionsCount() const;
1160 // get the icon info
1161 const wxString& GetIconFile() const;
1162 int GetIconIndex() const;
1172 // TODO: Make a wxPyMessageParameters with virtual GetParamValue...
1174 // An object of this class must be passed to Get{Open|Print}Command. The
1175 // default implementation is trivial and doesn't know anything at all about
1176 // parameters, only filename and MIME type are used (so it's probably ok for
1177 // Windows where %{param} is not used anyhow)
1178 class MessageParameters
1182 MessageParameters(const wxString& filename=wxPyEmptyString,
1183 const wxString& mimetype=wxPyEmptyString);
1185 // accessors (called by GetOpenCommand)
1187 const wxString& GetFileName() const;
1189 const wxString& GetMimeType() const;;
1191 // override this function in derived class
1192 virtual wxString GetParamValue(const wxString& name) const;
1194 // virtual dtor as in any base class
1195 virtual ~MessageParameters();
1199 // ctor from static data
1200 wxFileType(const wxFileTypeInfo& ftInfo);
1202 // return the MIME type for this file type
1204 PyObject* GetMimeType() {
1206 if (self->GetMimeType(&str)) {
1208 return PyUnicode_FromUnicode(str.c_str(), str.Len());
1210 return PyString_FromStringAndSize(str.c_str(), str.Len());
1216 PyObject* GetMimeTypes() {
1218 if (self->GetMimeTypes(arr))
1219 return wxArrayString2PyList_helper(arr);
1226 // Get all extensions associated with this file type
1228 PyObject* GetExtensions() {
1230 if (self->GetExtensions(arr))
1231 return wxArrayString2PyList_helper(arr);
1239 // Get the icon corresponding to this file type
1240 %new wxIcon* GetIcon() {
1242 if (self->GetIcon(&icon))
1243 return new wxIcon(icon);
1248 // Get the icon corresponding to this file type, the name of the file
1249 // where this icon resides, and its index in this file if applicable.
1250 PyObject* GetIconInfo() {
1254 if (self->GetIcon(&icon, &iconFile, &iconIndex)) {
1255 wxPyBeginBlockThreads();
1256 PyObject* tuple = PyTuple_New(3);
1257 PyTuple_SetItem(tuple, 0, wxPyConstructObject(new wxIcon(icon),
1260 PyTuple_SetItem(tuple, 1, PyUnicode_FromUnicode(iconFile.c_str(), iconFile.Len()));
1262 PyTuple_SetItem(tuple, 1, PyString_FromStringAndSize(iconFile.c_str(), iconFile.Len()));
1264 PyTuple_SetItem(tuple, 2, PyInt_FromLong(iconIndex));
1265 wxPyEndBlockThreads();
1274 // get a brief file type description ("*.txt" => "text document")
1275 PyObject* GetDescription() {
1277 if (self->GetDescription(&str)) {
1279 return PyUnicode_FromUnicode(str.c_str(), str.Len());
1281 return PyString_FromStringAndSize(str.c_str(), str.Len());
1289 // get the command to open/execute the file of given type
1291 PyObject* GetOpenCommand(const wxString& filename,
1292 const wxString& mimetype=wxPyEmptyString) {
1294 if (self->GetOpenCommand(&str, wxFileType::MessageParameters(filename, mimetype))) {
1296 return PyUnicode_FromUnicode(str.c_str(), str.Len());
1298 return PyString_FromStringAndSize(str.c_str(), str.Len());
1306 // get the command to print the file of given type
1308 PyObject* GetPrintCommand(const wxString& filename,
1309 const wxString& mimetype=wxPyEmptyString) {
1311 if (self->GetPrintCommand(&str, wxFileType::MessageParameters(filename, mimetype))) {
1313 return PyUnicode_FromUnicode(str.c_str(), str.Len());
1315 return PyString_FromStringAndSize(str.c_str(), str.Len());
1323 // Get all commands defined for this file type
1325 PyObject* GetAllCommands(const wxString& filename,
1326 const wxString& mimetype=wxPyEmptyString) {
1327 wxArrayString verbs;
1328 wxArrayString commands;
1329 if (self->GetAllCommands(&verbs, &commands,
1330 wxFileType::MessageParameters(filename, mimetype))) {
1331 wxPyBeginBlockThreads();
1332 PyObject* tuple = PyTuple_New(2);
1333 PyTuple_SetItem(tuple, 0, wxArrayString2PyList_helper(verbs));
1334 PyTuple_SetItem(tuple, 1, wxArrayString2PyList_helper(commands));
1335 wxPyEndBlockThreads();
1344 // set an arbitrary command, ask confirmation if it already exists and
1345 // overwriteprompt is TRUE
1346 bool SetCommand(const wxString& cmd, const wxString& verb,
1347 bool overwriteprompt = TRUE);
1349 bool SetDefaultIcon(const wxString& cmd = wxPyEmptyString, int index = 0);
1352 // remove the association for this filetype from the system MIME database:
1353 // notice that it will only work if the association is defined in the user
1354 // file/registry part, we will never modify the system-wide settings
1358 // expand a string in the format of GetOpenCommand (which may contain
1359 // '%s' and '%t' format specificators for the file name and mime type
1360 // and %{param} constructions).
1361 static wxString ExpandCommand(const wxString& command,
1362 const MessageParameters& params);
1364 // dtor (not virtual, shouldn't be derived from)
1372 class wxMimeTypesManager
1375 // static helper functions
1376 // -----------------------
1378 // check if the given MIME type is the same as the other one: the
1379 // second argument may contain wildcards ('*'), but not the first. If
1380 // the types are equal or if the mimeType matches wildcard the function
1381 // returns TRUE, otherwise it returns FALSE
1382 static bool IsOfType(const wxString& mimeType, const wxString& wildcard);
1385 wxMimeTypesManager();
1387 // loads data from standard files according to the mailcap styles
1388 // specified: this is a bitwise OR of wxMailcapStyle values
1390 // use the extraDir parameter if you want to look for files in another
1392 void Initialize(int mailcapStyle = wxMAILCAP_STANDARD,
1393 const wxString& extraDir = wxPyEmptyString);
1395 // and this function clears all the data from the manager
1398 // Database lookup: all functions return a pointer to wxFileType object
1399 // whose methods may be used to query it for the information you're
1400 // interested in. If the return value is !NULL, caller is responsible for
1402 // get file type from file extension
1403 %new wxFileType *GetFileTypeFromExtension(const wxString& ext);
1405 // get file type from MIME type (in format <category>/<format>)
1406 %new wxFileType *GetFileTypeFromMimeType(const wxString& mimeType);
1408 // other operations: return TRUE if there were no errors or FALSE if there
1409 // were some unreckognized entries (the good entries are always read anyhow)
1412 // read in additional file (the standard ones are read automatically)
1413 // in mailcap format (see mimetype.cpp for description)
1415 // 'fallback' parameter may be set to TRUE to avoid overriding the
1416 // settings from other, previously parsed, files by this one: normally,
1417 // the files read most recently would override the older files, but with
1418 // fallback == TRUE this won't happen
1419 bool ReadMailcap(const wxString& filename, bool fallback = FALSE);
1421 // read in additional file in mime.types format
1422 bool ReadMimeTypes(const wxString& filename);
1424 // enumerate all known MIME types
1426 PyObject* EnumAllFileTypes() {
1428 self->EnumAllFileTypes(arr);
1429 return wxArrayString2PyList_helper(arr);
1433 // these functions can be used to provide default values for some of the
1434 // MIME types inside the program itself (you may also use
1435 // ReadMailcap(filenameWithDefaultTypes, TRUE /* use as fallback */) to
1436 // achieve the same goal, but this requires having this info in a file).
1438 void AddFallback(const wxFileTypeInfo& ft);
1441 // create or remove associations
1443 // create a new association using the fields of wxFileTypeInfo (at least
1444 // the MIME type and the extension should be set)
1445 // if the other fields are empty, the existing values should be left alone
1446 %new wxFileType *Associate(const wxFileTypeInfo& ftInfo);
1449 bool Unassociate(wxFileType *ft) ;
1451 // dtor (not virtual, shouldn't be derived from)
1452 ~wxMimeTypesManager();
1460 extern wxMimeTypesManager* wxTheMimeTypesManager;
1466 //----------------------------------------------------------------------
1469 #include <wx/artprov.h>
1471 DECLARE_DEF_STRING(ART_OTHER);
1475 %pragma(python) code = "
1477 wxART_TOOLBAR = 'wxART_TOOLBAR_C'
1478 wxART_MENU = 'wxART_MENU_C'
1479 wxART_FRAME_ICON = 'wxART_FRAME_ICON_C'
1480 wxART_CMN_DIALOG = 'wxART_CMN_DIALOG_C'
1481 wxART_HELP_BROWSER = 'wxART_HELP_BROWSER_C'
1482 wxART_MESSAGE_BOX = 'wxART_MESSAGE_BOX_C'
1483 wxART_OTHER = 'wxART_OTHER_C'
1486 wxART_ADD_BOOKMARK = 'wxART_ADD_BOOKMARK'
1487 wxART_DEL_BOOKMARK = 'wxART_DEL_BOOKMARK'
1488 wxART_HELP_SIDE_PANEL = 'wxART_HELP_SIDE_PANEL'
1489 wxART_HELP_SETTINGS = 'wxART_HELP_SETTINGS'
1490 wxART_HELP_BOOK = 'wxART_HELP_BOOK'
1491 wxART_HELP_FOLDER = 'wxART_HELP_FOLDER'
1492 wxART_HELP_PAGE = 'wxART_HELP_PAGE'
1493 wxART_GO_BACK = 'wxART_GO_BACK'
1494 wxART_GO_FORWARD = 'wxART_GO_FORWARD'
1495 wxART_GO_UP = 'wxART_GO_UP'
1496 wxART_GO_DOWN = 'wxART_GO_DOWN'
1497 wxART_GO_TO_PARENT = 'wxART_GO_TO_PARENT'
1498 wxART_GO_HOME = 'wxART_GO_HOME'
1499 wxART_FILE_OPEN = 'wxART_FILE_OPEN'
1500 wxART_PRINT = 'wxART_PRINT'
1501 wxART_HELP = 'wxART_HELP'
1502 wxART_TIP = 'wxART_TIP'
1503 wxART_REPORT_VIEW = 'wxART_REPORT_VIEW'
1504 wxART_LIST_VIEW = 'wxART_LIST_VIEW'
1505 wxART_NEW_DIR = 'wxART_NEW_DIR'
1506 wxART_FOLDER = 'wxART_FOLDER'
1507 wxART_GO_DIR_UP = 'wxART_GO_DIR_UP'
1508 wxART_EXECUTABLE_FILE = 'wxART_EXECUTABLE_FILE'
1509 wxART_NORMAL_FILE = 'wxART_NORMAL_FILE'
1510 wxART_TICK_MARK = 'wxART_TICK_MARK'
1511 wxART_CROSS_MARK = 'wxART_CROSS_MARK'
1512 wxART_ERROR = 'wxART_ERROR'
1513 wxART_QUESTION = 'wxART_QUESTION'
1514 wxART_WARNING = 'wxART_WARNING'
1515 wxART_INFORMATION = 'wxART_INFORMATION'
1518 %{ // Python aware wxArtProvider
1519 class wxPyArtProvider : public wxArtProvider {
1522 virtual wxBitmap CreateBitmap(const wxArtID& id,
1523 const wxArtClient& client,
1524 const wxSize& size) {
1525 wxBitmap rval = wxNullBitmap;
1526 wxPyBeginBlockThreads();
1527 if ((wxPyCBH_findCallback(m_myInst, "CreateBitmap"))) {
1528 PyObject* so = wxPyConstructObject((void*)&size, "wxSize", 0);
1532 s1 = wx2PyString(id);
1533 s2 = wx2PyString(client);
1534 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(OOO)", s1, s2, so));
1539 if (!SWIG_GetPtrObj(ro, (void**)&ptr, "_wxBitmap_p"))
1544 wxPyEndBlockThreads();
1552 // The one for SWIG to see
1553 %name(wxArtProvider) class wxPyArtProvider : public wxObject
1558 void _setCallbackInfo(PyObject* self, PyObject* _class);
1559 %pragma(python) addtomethod = "__init__:self._setCallbackInfo(self, wxArtProvider)"
1561 // Add new provider to the top of providers stack.
1562 static void PushProvider(wxPyArtProvider *provider);
1564 // Remove latest added provider and delete it.
1565 static bool PopProvider();
1567 // Remove provider. The provider must have been added previously!
1568 // The provider is _not_ deleted.
1569 static bool RemoveProvider(wxPyArtProvider *provider);
1571 // Query the providers for bitmap with given ID and return it. Return
1572 // wxNullBitmap if no provider provides it.
1573 static wxBitmap GetBitmap(const wxString& id,
1574 const wxString& client = wxPyART_OTHER,
1575 const wxSize& size = wxDefaultSize);
1577 // Query the providers for icon with given ID and return it. Return
1578 // wxNullIcon if no provider provides it.
1579 static wxIcon GetIcon(const wxString& id,
1580 const wxString& client = wxPyART_OTHER,
1581 const wxSize& size = wxDefaultSize);
1583 // Destroy caches & all providers
1584 static void CleanUpProviders();
1588 //----------------------------------------------------------------------
1591 #include <wx/docview.h>
1594 class wxFileHistory : public wxObject
1597 wxFileHistory(int maxFiles = 9);
1601 void AddFileToHistory(const wxString& file);
1602 void RemoveFileFromHistory(int i);
1603 int GetMaxFiles() const;
1604 void UseMenu(wxMenu *menu);
1606 // Remove menu from the list (MDI child may be closing)
1607 void RemoveMenu(wxMenu *menu);
1609 void Load(wxConfigBase& config);
1610 void Save(wxConfigBase& config);
1612 void AddFilesToMenu();
1613 %name(AddFilesToThisMenu)void AddFilesToMenu(wxMenu* menu);
1616 wxString GetHistoryFile(int i) const;
1618 // A synonym for GetNoHistoryFiles
1619 int GetCount() const;
1620 int GetNoHistoryFiles() const;
1624 //----------------------------------------------------------------------
1626 class wxEffects: public wxObject
1629 // Assume system colours
1632 wxColour GetHighlightColour() const;
1633 wxColour GetLightShadow() const;
1634 wxColour GetFaceColour() const;
1635 wxColour GetMediumShadow() const;
1636 wxColour GetDarkShadow() const;
1638 void SetHighlightColour(const wxColour& c);
1639 void SetLightShadow(const wxColour& c);
1640 void SetFaceColour(const wxColour& c);
1641 void SetMediumShadow(const wxColour& c);
1642 void SetDarkShadow(const wxColour& c);
1644 void Set(const wxColour& highlightColour, const wxColour& lightShadow,
1645 const wxColour& faceColour, const wxColour& mediumShadow,
1646 const wxColour& darkShadow);
1648 // Draw a sunken edge
1649 void DrawSunkenEdge(wxDC& dc, const wxRect& rect, int borderSize = 1);
1652 bool TileBitmap(const wxRect& rect, wxDC& dc, wxBitmap& bitmap);
1656 //----------------------------------------------------------------------
1658 class wxSingleInstanceChecker
1661 // like Create() but no error checking (dangerous!)
1662 wxSingleInstanceChecker(const wxString& name,
1663 const wxString& path = wxPyEmptyString);
1665 // default ctor, use Create() after it
1666 %name(wxPreSingleInstanceChecker) wxSingleInstanceChecker();
1668 ~wxSingleInstanceChecker();
1671 // name must be given and be as unique as possible, it is used as the mutex
1672 // name under Win32 and the lock file name under Unix -
1673 // wxTheApp->GetAppName() may be a good value for this parameter
1675 // path is optional and is ignored under Win32 and used as the directory to
1676 // create the lock file in under Unix (default is wxGetHomeDir())
1678 // returns FALSE if initialization failed, it doesn't mean that another
1679 // instance is running - use IsAnotherRunning() to check it
1680 bool Create(const wxString& name, const wxString& path = wxPyEmptyString);
1682 // is another copy of this program already running?
1683 bool IsAnotherRunning() const;
1686 //----------------------------------------------------------------------
1690 // #if wxUSE_UNICODE
1691 // #define ADD_STRING(dict, str) \
1692 // wxString tmp##str(str); \
1693 // PyDict_SetItemString(dict, #str, \
1694 // PyUnicode_FromUnicode(tmp##str.c_str(), tmp##str.Len()))
1696 // #define ADD_STRING(dict, str) \
1697 // PyDict_SetItemString(d, #str, PyString_FromString(str))
1703 wxPyPtrTypeMap_Add("wxDragImage", "wxGenericDragImage");
1704 wxPyPtrTypeMap_Add("wxProcess", "wxPyProcess");
1705 wxPyPtrTypeMap_Add("wxArtProvider", "wxPyArtProvider");
1709 //----------------------------------------------------------------------