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);
475 bool wxShowTip(wxWindow *parent, wxTipProvider *tipProvider, bool showAtStartup = TRUE);
476 %new wxTipProvider * wxCreateFileTipProvider(const wxString& filename, size_t currentTip);
479 //----------------------------------------------------------------------
482 #include <wx/generic/dragimgg.h>
485 %name (wxDragImage) class wxGenericDragImage : public wxObject
489 wxGenericDragImage(const wxBitmap& image,
490 const wxCursor& cursor = wxNullCursor);
491 %name(wxDragIcon)wxGenericDragImage(const wxIcon& image,
492 const wxCursor& cursor = wxNullCursor);
493 %name(wxDragString)wxGenericDragImage(const wxString& str,
494 const wxCursor& cursor = wxNullCursor);
495 %name(wxDragTreeItem)wxGenericDragImage(const wxTreeCtrl& treeCtrl, wxTreeItemId& id);
496 %name(wxDragListItem)wxGenericDragImage(const wxListCtrl& listCtrl, long id);
498 ~wxGenericDragImage();
500 void SetBackingBitmap(wxBitmap* bitmap);
501 bool BeginDrag(const wxPoint& hotspot, wxWindow* window,
502 bool fullScreen = FALSE, wxRect* rect = NULL);
504 %name(BeginDrag2) bool BeginDrag(const wxPoint& hotspot, wxWindow* window,
505 wxWindow* fullScreenRect);
508 bool Move(const wxPoint& pt);
512 wxRect GetImageRect(const wxPoint& pos) const;
513 bool RedrawImage(const wxPoint& oldPos, const wxPoint& newPos,
514 bool eraseOld, bool drawNew);
518 //----------------------------------------------------------------------
520 class wxPyTimer : public wxObject {
522 wxPyTimer(PyObject* notify);
527 void SetOwner(wxEvtHandler *owner, int id = -1);
528 void Start(int milliseconds=-1, int oneShot=FALSE);
536 // ctor starts the stop watch
539 void Start(long t = 0);
543 // get elapsed time since the last Start() or Pause() in milliseconds
548 //----------------------------------------------------------------------
549 //----------------------------------------------------------------------
554 wxLOG_FatalError, // program can't continue, abort immediately
555 wxLOG_Error, // a serious error, user must be informed about it
556 wxLOG_Warning, // user is normally informed about it but may be ignored
557 wxLOG_Message, // normal message (i.e. normal output of a non GUI app)
558 wxLOG_Info, // informational message (a.k.a. 'Verbose')
559 wxLOG_Status, // informational: might go to the status line of GUI app
560 wxLOG_Debug, // never shown to the user, disabled in release mode
561 wxLOG_Trace, // trace messages are also only enabled in debug mode
562 wxLOG_Progress, // used for progress indicator (not yet)
563 wxLOG_User = 100 // user defined levels start here
566 #define wxTRACE_MemAlloc "memalloc" // trace memory allocation (new/delete)
567 #define wxTRACE_Messages "messages" // trace window messages/X callbacks
568 #define wxTRACE_ResAlloc "resalloc" // trace GDI resource allocation
569 #define wxTRACE_RefCount "refcount" // trace various ref counting operations
572 #define wxTRACE_OleCalls "ole" // OLE interface calls
593 static bool IsEnabled();
594 static bool EnableLogging(bool doIt = TRUE);
595 static void OnLog(unsigned long level, const wxString& szString, int t=0);
597 virtual void Flush();
598 bool HasPendingMessages() const;
600 static void FlushActive();
601 static wxLog *GetActiveTarget();
602 static wxLog *SetActiveTarget(wxLog *pLogger);
604 static void Suspend();
605 static void Resume();
607 static void SetVerbose(bool bVerbose = TRUE);
609 static void DontCreateOnDemand();
610 static void SetTraceMask(long ulMask);
611 static void AddTraceMask(const wxString& str);
612 static void RemoveTraceMask(const wxString& str);
613 static void ClearTraceMasks();
615 static void SetTimestamp(const wxString& ts);
616 static const wxString& GetTimestamp();
618 bool GetVerbose() const;
620 static unsigned long GetTraceMask();
621 static bool IsAllowedTraceMask(const wxString& mask);
623 // static void TimeStamp(wxString *str);
625 wxString TimeStamp() {
627 wxLog::TimeStamp(&msg);
635 class wxLogStderr : public wxLog
638 wxLogStderr(/* TODO: FILE *fp = (FILE *) NULL*/);
642 class wxLogTextCtrl : public wxLog
645 wxLogTextCtrl(wxTextCtrl *pTextCtrl);
649 class wxLogGui : public wxLog
655 class wxLogWindow : public wxLog
658 wxLogWindow(wxFrame *pParent, // the parent frame (can be NULL)
659 const wxString& szTitle, // the title of the frame
660 bool bShow = TRUE, // show window immediately?
661 bool bPassToOld = TRUE); // pass log messages to the old target?
663 void Show(bool bShow = TRUE);
664 wxFrame *GetFrame() const;
665 wxLog *GetOldLog() const;
666 bool IsPassingMessages() const;
667 void PassMessages(bool bDoPass);
671 class wxLogChain : public wxLog
674 wxLogChain(wxLog *logger);
675 void SetLog(wxLog *logger);
676 void PassMessages(bool bDoPass);
677 bool IsPassingMessages();
682 unsigned long wxSysErrorCode();
683 const wxString wxSysErrorMsg(unsigned long nErrCode = 0);
684 void wxLogFatalError(const wxString& msg);
685 void wxLogError(const wxString& msg);
686 void wxLogWarning(const wxString& msg);
687 void wxLogMessage(const wxString& msg);
688 void wxLogInfo(const wxString& msg);
689 void wxLogVerbose(const wxString& msg);
690 void wxLogStatus(const wxString& msg);
691 %name(wxLogStatusFrame)void wxLogStatus(wxFrame *pFrame, const wxString& msg);
692 void wxLogSysError(const wxString& msg);
694 void wxLogTrace(const wxString& msg);
695 %name(wxLogTraceMask)void wxLogTrace(const wxString& mask, const wxString& msg);
697 void wxLogGeneric(unsigned long level, const wxString& msg);
699 // wxLogFatalError helper: show the (fatal) error to the user in a safe way,
700 // i.e. without using wxMessageBox() for example because it could crash
701 void wxSafeShowMessage(const wxString& title, const wxString& text);
705 // Suspress logging while an instance of this class exists
717 // A wxLog class that can be derived from in wxPython
718 class wxPyLog : public wxLog {
720 wxPyLog() : wxLog() {}
722 virtual void DoLog(wxLogLevel level, const wxChar *szString, time_t t) {
724 wxPyBeginBlockThreads();
725 if ((found = wxPyCBH_findCallback(m_myInst, "DoLog"))) {
726 PyObject* s = wx2PyString(szString);
727 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iOi)", level, s, t));
730 wxPyEndBlockThreads();
732 wxLog::DoLog(level, szString, t);
735 virtual void DoLogString(const wxChar *szString, time_t t) {
737 wxPyBeginBlockThreads();
738 if ((found = wxPyCBH_findCallback(m_myInst, "DoLogString"))) {
739 PyObject* s = wx2PyString(szString);
740 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oi)", s, t));
743 wxPyEndBlockThreads();
745 wxLog::DoLogString(szString, t);
752 // Now tell SWIG about it
753 class wxPyLog : public wxLog {
756 void _setCallbackInfo(PyObject* self, PyObject* _class);
757 %pragma(python) addtomethod = "__init__:self._setCallbackInfo(self, wxPyLog)"
758 %addmethods { void Destroy() { delete self; } }
763 //----------------------------------------------------------------------
774 wxKILL_OK, // no error
775 wxKILL_BAD_SIGNAL, // no such signal
776 wxKILL_ACCESS_DENIED, // permission denied
777 wxKILL_NO_PROCESS, // no such process
778 wxKILL_ERROR // another, unspecified error
782 class wxProcessEvent : public wxEvent {
784 wxProcessEvent(int id = 0, int pid = 0, int exitcode = 0);
787 int m_pid, m_exitcode;
793 %{ // C++ version of wxProcess derived class
795 class wxPyProcess : public wxProcess {
797 wxPyProcess(wxEvtHandler *parent = NULL, int id = -1)
798 : wxProcess(parent, id)
801 DEC_PYCALLBACK_VOID_INTINT(OnTerminate);
806 IMP_PYCALLBACK_VOID_INTINT( wxPyProcess, wxProcess, OnTerminate);
811 %name(wxProcess)class wxPyProcess : public wxEvtHandler {
813 // kill the process with the given PID
814 static wxKillError Kill(int pid, wxSignal sig = wxSIGTERM);
816 // test if the given process exists
817 static bool Exists(int pid);
819 // this function replaces the standard popen() one: it launches a process
820 // asynchronously and allows the caller to get the streams connected to its
823 // on error NULL is returned, in any case the process object will be
824 // deleted automatically when the process terminates and should *not* be
825 // deleted by the caller
826 static wxPyProcess *Open(const wxString& cmd);
830 wxPyProcess(wxEvtHandler *parent = NULL, int id = -1);
831 %addmethods { void Destroy() { delete self; } }
833 void _setCallbackInfo(PyObject* self, PyObject* _class);
834 %pragma(python) addtomethod = "__init__:self._setCallbackInfo(self, wxProcess)"
836 void base_OnTerminate(int pid, int status);
842 wxInputStream *GetInputStream();
843 wxInputStream *GetErrorStream();
844 wxOutputStream *GetOutputStream();
852 // execute the process asynchronously
855 // execute it synchronously, i.e. wait until it finishes
858 // under Windows, don't hide the child even if it's IO is redirected (this
859 // is done by default)
862 // under Unix, if the process is the group leader then killing -pid kills
863 // all children as well as pid
864 wxEXEC_MAKE_GROUP_LEADER = 4
868 long wxExecute(const wxString& command,
869 int flags = wxEXEC_ASYNC,
870 wxPyProcess *process = NULL);
872 //----------------------------------------------------------------------
875 // Which joystick? Same as Windows ids so no conversion necessary.
882 // Which button is down?
894 #if !wxUSE_JOYSTICK && !defined(__WXMSW__)
895 // A C++ stub class for wxJoystick for platforms that don't have it.
896 class wxJoystick : public wxObject {
898 wxJoystick(int joystick = wxJOYSTICK1) {
899 wxPyBeginBlockThreads();
900 PyErr_SetString(PyExc_NotImplementedError, "wxJoystick is not available on this platform.");
901 wxPyEndBlockThreads();
903 wxPoint GetPosition() { return wxPoint(-1,-1); }
904 int GetZPosition() { return -1; }
905 int GetButtonState() { return -1; }
906 int GetPOVPosition() { return -1; }
907 int GetPOVCTSPosition() { return -1; }
908 int GetRudderPosition() { return -1; }
909 int GetUPosition() { return -1; }
910 int GetVPosition() { return -1; }
911 int GetMovementThreshold() { return -1; }
912 void SetMovementThreshold(int threshold) {}
914 bool IsOk(void) { return FALSE; }
915 int GetNumberJoysticks() { return -1; }
916 int GetManufacturerId() { return -1; }
917 int GetProductId() { return -1; }
918 wxString GetProductName() { return ""; }
919 int GetXMin() { return -1; }
920 int GetYMin() { return -1; }
921 int GetZMin() { return -1; }
922 int GetXMax() { return -1; }
923 int GetYMax() { return -1; }
924 int GetZMax() { return -1; }
925 int GetNumberButtons() { return -1; }
926 int GetNumberAxes() { return -1; }
927 int GetMaxButtons() { return -1; }
928 int GetMaxAxes() { return -1; }
929 int GetPollingMin() { return -1; }
930 int GetPollingMax() { return -1; }
931 int GetRudderMin() { return -1; }
932 int GetRudderMax() { return -1; }
933 int GetUMin() { return -1; }
934 int GetUMax() { return -1; }
935 int GetVMin() { return -1; }
936 int GetVMax() { return -1; }
938 bool HasRudder() { return FALSE; }
939 bool HasZ() { return FALSE; }
940 bool HasU() { return FALSE; }
941 bool HasV() { return FALSE; }
942 bool HasPOV() { return FALSE; }
943 bool HasPOV4Dir() { return FALSE; }
944 bool HasPOVCTS() { return FALSE; }
946 bool SetCapture(wxWindow* win, int pollingFreq = 0) { return FALSE; }
947 bool ReleaseCapture() { return FALSE; }
953 class wxJoystick : public wxObject {
955 wxJoystick(int joystick = wxJOYSTICK1);
958 wxPoint GetPosition();
960 int GetButtonState();
961 int GetPOVPosition();
962 int GetPOVCTSPosition();
963 int GetRudderPosition();
966 int GetMovementThreshold();
967 void SetMovementThreshold(int threshold) ;
970 int GetNumberJoysticks();
971 int GetManufacturerId();
973 wxString GetProductName();
980 int GetNumberButtons();
1001 bool SetCapture(wxWindow* win, int pollingFreq = 0);
1002 bool ReleaseCapture();
1005 //----------------------------------------------------------------------
1009 // A C++ stub class for wxWave for platforms that don't have it.
1010 class wxWave : public wxObject
1013 wxWave(const wxString& fileName, bool isResource = FALSE) {
1014 wxPyBeginBlockThreads();
1015 PyErr_SetString(PyExc_NotImplementedError, "wxWave is not available on this platform.");
1016 wxPyEndBlockThreads();
1018 wxWave(int size, const wxByte* data) {
1019 wxPyBeginBlockThreads();
1020 PyErr_SetString(PyExc_NotImplementedError, "wxWave is not available on this platform.");
1021 wxPyEndBlockThreads();
1026 bool IsOk() const { return FALSE; }
1027 bool Play(bool async = TRUE, bool looped = FALSE) const { return FALSE; }
1033 class wxWave : public wxObject
1036 wxWave(const wxString& fileName, bool isResource = FALSE);
1040 bool Play(bool async = TRUE, bool looped = FALSE) const;
1043 %new wxWave* wxWaveData(const wxString& data);
1044 %{ // Implementations of some alternate "constructors"
1045 wxWave* wxWaveData(const wxString& data) {
1046 return new wxWave(data.Len(), (wxByte*)data.c_str());
1051 //----------------------------------------------------------------------
1055 wxMAILCAP_STANDARD = 1,
1056 wxMAILCAP_NETSCAPE = 2,
1058 wxMAILCAP_GNOME = 8,
1065 class wxFileTypeInfo
1070 wxFileTypeInfo(const char* mimeType,
1071 const char* openCmd,
1072 const char* printCmd,
1076 // the array elements correspond to the parameters of the ctor above in
1078 %name(wxFileTypeInfoSequence)wxFileTypeInfo(const wxArrayString& sArray);
1080 // invalid item - use this to terminate the array passed to
1081 // wxMimeTypesManager::AddFallbacks
1082 %name(wxNullFileTypeInfo)wxFileTypeInfo();
1085 // test if this object can be used
1086 bool IsValid() const;
1089 // set the icon info
1090 void SetIcon(const wxString& iconFile, int iconIndex = 0);
1092 // set the short desc
1093 void SetShortDesc(const wxString& shortDesc);
1096 // get the MIME type
1097 const wxString& GetMimeType() const;
1098 // get the open command
1099 const wxString& GetOpenCommand() const;
1100 // get the print command
1101 const wxString& GetPrintCommand() const;
1102 // get the short description (only used under Win32 so far)
1103 const wxString& GetShortDesc() const;
1104 // get the long, user visible description
1105 const wxString& GetDescription() const;
1108 // get the array of all extensions
1109 //const wxArrayString& GetExtensions() const;
1111 PyObject* GetExtensions() {
1112 wxArrayString& arr = (wxArrayString&)self->GetExtensions();
1113 return wxArrayString2PyList_helper(arr);
1117 int GetExtensionsCount() const;
1119 // get the icon info
1120 const wxString& GetIconFile() const;
1121 int GetIconIndex() const;
1131 // TODO: Make a wxPyMessageParameters with virtual GetParamValue...
1133 // An object of this class must be passed to Get{Open|Print}Command. The
1134 // default implementation is trivial and doesn't know anything at all about
1135 // parameters, only filename and MIME type are used (so it's probably ok for
1136 // Windows where %{param} is not used anyhow)
1137 class MessageParameters
1141 MessageParameters(const wxString& filename=wxPyEmptyString,
1142 const wxString& mimetype=wxPyEmptyString);
1144 // accessors (called by GetOpenCommand)
1146 const wxString& GetFileName() const;
1148 const wxString& GetMimeType() const;;
1150 // override this function in derived class
1151 virtual wxString GetParamValue(const wxString& name) const;
1153 // virtual dtor as in any base class
1154 virtual ~MessageParameters();
1158 // ctor from static data
1159 wxFileType(const wxFileTypeInfo& ftInfo);
1161 // return the MIME type for this file type
1163 PyObject* GetMimeType() {
1165 if (self->GetMimeType(&str)) {
1167 return PyUnicode_FromUnicode(str.c_str(), str.Len());
1169 return PyString_FromStringAndSize(str.c_str(), str.Len());
1175 PyObject* GetMimeTypes() {
1177 if (self->GetMimeTypes(arr))
1178 return wxArrayString2PyList_helper(arr);
1185 // Get all extensions associated with this file type
1187 PyObject* GetExtensions() {
1189 if (self->GetExtensions(arr))
1190 return wxArrayString2PyList_helper(arr);
1198 // Get the icon corresponding to this file type
1199 %new wxIcon* GetIcon() {
1201 if (self->GetIcon(&icon))
1202 return new wxIcon(icon);
1207 // Get the icon corresponding to this file type, the name of the file
1208 // where this icon resides, and its index in this file if applicable.
1209 PyObject* GetIconInfo() {
1213 if (self->GetIcon(&icon, &iconFile, &iconIndex)) {
1214 wxPyBeginBlockThreads();
1215 PyObject* tuple = PyTuple_New(3);
1216 PyTuple_SetItem(tuple, 0, wxPyConstructObject(new wxIcon(icon),
1219 PyTuple_SetItem(tuple, 1, PyUnicode_FromUnicode(iconFile.c_str(), iconFile.Len()));
1221 PyTuple_SetItem(tuple, 1, PyString_FromStringAndSize(iconFile.c_str(), iconFile.Len()));
1223 PyTuple_SetItem(tuple, 2, PyInt_FromLong(iconIndex));
1224 wxPyEndBlockThreads();
1233 // get a brief file type description ("*.txt" => "text document")
1234 PyObject* GetDescription() {
1236 if (self->GetDescription(&str)) {
1238 return PyUnicode_FromUnicode(str.c_str(), str.Len());
1240 return PyString_FromStringAndSize(str.c_str(), str.Len());
1248 // get the command to open/execute the file of given type
1250 PyObject* GetOpenCommand(const wxString& filename,
1251 const wxString& mimetype=wxPyEmptyString) {
1253 if (self->GetOpenCommand(&str, wxFileType::MessageParameters(filename, mimetype))) {
1255 return PyUnicode_FromUnicode(str.c_str(), str.Len());
1257 return PyString_FromStringAndSize(str.c_str(), str.Len());
1265 // get the command to print the file of given type
1267 PyObject* GetPrintCommand(const wxString& filename,
1268 const wxString& mimetype=wxPyEmptyString) {
1270 if (self->GetPrintCommand(&str, wxFileType::MessageParameters(filename, mimetype))) {
1272 return PyUnicode_FromUnicode(str.c_str(), str.Len());
1274 return PyString_FromStringAndSize(str.c_str(), str.Len());
1282 // Get all commands defined for this file type
1284 PyObject* GetAllCommands(const wxString& filename,
1285 const wxString& mimetype=wxPyEmptyString) {
1286 wxArrayString verbs;
1287 wxArrayString commands;
1288 if (self->GetAllCommands(&verbs, &commands,
1289 wxFileType::MessageParameters(filename, mimetype))) {
1290 wxPyBeginBlockThreads();
1291 PyObject* tuple = PyTuple_New(2);
1292 PyTuple_SetItem(tuple, 0, wxArrayString2PyList_helper(verbs));
1293 PyTuple_SetItem(tuple, 1, wxArrayString2PyList_helper(commands));
1294 wxPyEndBlockThreads();
1303 // set an arbitrary command, ask confirmation if it already exists and
1304 // overwriteprompt is TRUE
1305 bool SetCommand(const wxString& cmd, const wxString& verb,
1306 bool overwriteprompt = TRUE);
1308 bool SetDefaultIcon(const wxString& cmd = wxPyEmptyString, int index = 0);
1311 // remove the association for this filetype from the system MIME database:
1312 // notice that it will only work if the association is defined in the user
1313 // file/registry part, we will never modify the system-wide settings
1317 // expand a string in the format of GetOpenCommand (which may contain
1318 // '%s' and '%t' format specificators for the file name and mime type
1319 // and %{param} constructions).
1320 static wxString ExpandCommand(const wxString& command,
1321 const MessageParameters& params);
1323 // dtor (not virtual, shouldn't be derived from)
1331 class wxMimeTypesManager
1334 // static helper functions
1335 // -----------------------
1337 // check if the given MIME type is the same as the other one: the
1338 // second argument may contain wildcards ('*'), but not the first. If
1339 // the types are equal or if the mimeType matches wildcard the function
1340 // returns TRUE, otherwise it returns FALSE
1341 static bool IsOfType(const wxString& mimeType, const wxString& wildcard);
1344 wxMimeTypesManager();
1346 // loads data from standard files according to the mailcap styles
1347 // specified: this is a bitwise OR of wxMailcapStyle values
1349 // use the extraDir parameter if you want to look for files in another
1351 void Initialize(int mailcapStyle = wxMAILCAP_STANDARD,
1352 const wxString& extraDir = wxPyEmptyString);
1354 // and this function clears all the data from the manager
1357 // Database lookup: all functions return a pointer to wxFileType object
1358 // whose methods may be used to query it for the information you're
1359 // interested in. If the return value is !NULL, caller is responsible for
1361 // get file type from file extension
1362 %new wxFileType *GetFileTypeFromExtension(const wxString& ext);
1364 // get file type from MIME type (in format <category>/<format>)
1365 %new wxFileType *GetFileTypeFromMimeType(const wxString& mimeType);
1367 // other operations: return TRUE if there were no errors or FALSE if there
1368 // were some unreckognized entries (the good entries are always read anyhow)
1371 // read in additional file (the standard ones are read automatically)
1372 // in mailcap format (see mimetype.cpp for description)
1374 // 'fallback' parameter may be set to TRUE to avoid overriding the
1375 // settings from other, previously parsed, files by this one: normally,
1376 // the files read most recently would override the older files, but with
1377 // fallback == TRUE this won't happen
1378 bool ReadMailcap(const wxString& filename, bool fallback = FALSE);
1380 // read in additional file in mime.types format
1381 bool ReadMimeTypes(const wxString& filename);
1383 // enumerate all known MIME types
1385 PyObject* EnumAllFileTypes() {
1387 self->EnumAllFileTypes(arr);
1388 return wxArrayString2PyList_helper(arr);
1392 // these functions can be used to provide default values for some of the
1393 // MIME types inside the program itself (you may also use
1394 // ReadMailcap(filenameWithDefaultTypes, TRUE /* use as fallback */) to
1395 // achieve the same goal, but this requires having this info in a file).
1397 void AddFallback(const wxFileTypeInfo& ft);
1400 // create or remove associations
1402 // create a new association using the fields of wxFileTypeInfo (at least
1403 // the MIME type and the extension should be set)
1404 // if the other fields are empty, the existing values should be left alone
1405 %new wxFileType *Associate(const wxFileTypeInfo& ftInfo);
1408 bool Unassociate(wxFileType *ft) ;
1410 // dtor (not virtual, shouldn't be derived from)
1411 ~wxMimeTypesManager();
1419 extern wxMimeTypesManager* wxTheMimeTypesManager;
1425 //----------------------------------------------------------------------
1428 #include <wx/artprov.h>
1430 DECLARE_DEF_STRING(ART_OTHER);
1435 #define wxART_TOOLBAR "toolbar_C"
1436 #define wxART_MENU "menu_C"
1437 #define wxART_FRAME_ICON "frame_icon_C"
1439 #define wxART_CMN_DIALOG "cmn_dialog_C"
1440 #define wxART_HELP_BROWSER "help_browser_C"
1441 #define wxART_MESSAGE_BOX "message_box_C"
1443 #define wxART_OTHER "other_C"
1446 #define wxART_ADD_BOOKMARK "add_bookmark"
1447 #define wxART_DEL_BOOKMARK "del_bookmark"
1448 #define wxART_HELP_SIDE_PANEL "help_side_panel"
1449 #define wxART_HELP_SETTINGS "help_settings"
1450 #define wxART_HELP_BOOK "help_book"
1451 #define wxART_HELP_FOLDER "help_folder"
1452 #define wxART_HELP_PAGE "help_page"
1453 #define wxART_GO_BACK "go_back"
1454 #define wxART_GO_FORWARD "go_forward"
1455 #define wxART_GO_UP "go_up"
1456 #define wxART_GO_DOWN "go_down"
1457 #define wxART_GO_TO_PARENT "go_to_parent"
1458 #define wxART_GO_HOME "go_home"
1459 #define wxART_FILE_OPEN "file_open"
1460 #define wxART_PRINT "print"
1461 #define wxART_HELP "help"
1462 #define wxART_TIP "tip"
1463 #define wxART_REPORT_VIEW "report_view"
1464 #define wxART_LIST_VIEW "list_view"
1465 #define wxART_NEW_DIR "new_dir"
1466 #define wxART_FOLDER "folder"
1467 #define wxART_GO_DIR_UP "go_dir_up"
1468 #define wxART_EXECUTABLE_FILE "executable_file"
1469 #define wxART_NORMAL_FILE "normal_file"
1470 #define wxART_TICK_MARK "tick"
1471 #define wxART_CROSS_MARK "cross"
1472 #define wxART_ERROR "error"
1473 #define wxART_QUESTION "question"
1474 #define wxART_WARNING "warning"
1475 #define wxART_INFORMATION "information"
1478 %{ // Python aware wxArtProvider
1479 class wxPyArtProvider : public wxArtProvider {
1482 virtual wxBitmap CreateBitmap(const wxArtID& id,
1483 const wxArtClient& client,
1484 const wxSize& size) {
1485 wxBitmap rval = wxNullBitmap;
1486 wxPyBeginBlockThreads();
1487 if ((wxPyCBH_findCallback(m_myInst, "CreateBitmap"))) {
1488 PyObject* so = wxPyConstructObject((void*)&size, "wxSize", 0);
1492 s1 = wx2PyString(id);
1493 s2 = wx2PyString(client);
1494 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(OOO)", s1, s2, so));
1499 if (!SWIG_GetPtrObj(ro, (void**)&ptr, "_wxBitmap_p"))
1504 wxPyEndBlockThreads();
1512 // The one for SWIG to see
1513 %name(wxArtProvider) class wxPyArtProvider : public wxObject
1518 void _setCallbackInfo(PyObject* self, PyObject* _class);
1519 %pragma(python) addtomethod = "__init__:self._setCallbackInfo(self, wxArtProvider)"
1521 // Add new provider to the top of providers stack.
1522 static void PushProvider(wxPyArtProvider *provider);
1524 // Remove latest added provider and delete it.
1525 static bool PopProvider();
1527 // Remove provider. The provider must have been added previously!
1528 // The provider is _not_ deleted.
1529 static bool RemoveProvider(wxPyArtProvider *provider);
1531 // Query the providers for bitmap with given ID and return it. Return
1532 // wxNullBitmap if no provider provides it.
1533 static wxBitmap GetBitmap(const wxString& id,
1534 const wxString& client = wxPyART_OTHER,
1535 const wxSize& size = wxDefaultSize);
1537 // Query the providers for icon with given ID and return it. Return
1538 // wxNullIcon if no provider provides it.
1539 static wxIcon GetIcon(const wxString& id,
1540 const wxString& client = wxPyART_OTHER,
1541 const wxSize& size = wxDefaultSize);
1543 // Destroy caches & all providers
1544 static void CleanUpProviders();
1548 //----------------------------------------------------------------------
1551 #include <wx/docview.h>
1554 class wxFileHistory : public wxObject
1557 wxFileHistory(int maxFiles = 9);
1561 void AddFileToHistory(const wxString& file);
1562 void RemoveFileFromHistory(int i);
1563 int GetMaxFiles() const;
1564 void UseMenu(wxMenu *menu);
1566 // Remove menu from the list (MDI child may be closing)
1567 void RemoveMenu(wxMenu *menu);
1569 void Load(wxConfigBase& config);
1570 void Save(wxConfigBase& config);
1572 void AddFilesToMenu();
1573 %name(AddFilesToThisMenu)void AddFilesToMenu(wxMenu* menu);
1576 wxString GetHistoryFile(int i) const;
1578 // A synonym for GetNoHistoryFiles
1579 int GetCount() const;
1580 int GetNoHistoryFiles() const;
1584 //----------------------------------------------------------------------
1585 //----------------------------------------------------------------------
1588 // #if wxUSE_UNICODE
1589 // #define ADD_STRING(dict, str) \
1590 // wxString tmp##str(str); \
1591 // PyDict_SetItemString(dict, #str, \
1592 // PyUnicode_FromUnicode(tmp##str.c_str(), tmp##str.Len()))
1594 // #define ADD_STRING(dict, str) \
1595 // PyDict_SetItemString(d, #str, PyString_FromString(str))
1601 wxPyPtrTypeMap_Add("wxDragImage", "wxGenericDragImage");
1602 wxPyPtrTypeMap_Add("wxProcess", "wxPyProcess");
1603 wxPyPtrTypeMap_Add("wxArtProvider", "wxPyArtProvider");
1607 //----------------------------------------------------------------------