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 <wx/resource.h>
20 #include <wx/tooltip.h>
22 #include <wx/fontenum.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__)
35 //----------------------------------------------------------------------
38 %include my_typemaps.i
40 // Import some definitions of other classes, etc.
49 static wxString wxPyEmptyStr("");
52 //---------------------------------------------------------------------------
55 wxString wxFileSelector(char* message,
56 char* default_path = NULL,
57 char* default_filename = NULL,
58 char* default_extension = NULL,
59 char* wildcard = "*.*",
61 wxWindow *parent = NULL,
62 int x = -1, int y = -1);
64 wxString wxGetTextFromUser(const wxString& message,
65 const wxString& caption = wxPyEmptyStr,
66 const wxString& default_value = wxPyEmptyStr,
67 wxWindow *parent = NULL,
68 int x = -1, int y = -1,
71 wxString wxGetPasswordFromUser(const wxString& message,
72 const wxString& caption = wxPyEmptyStr,
73 const wxString& default_value = wxPyEmptyStr,
74 wxWindow *parent = NULL);
77 // TODO: Need to custom wrap this one...
78 // int wxGetMultipleChoice(char* message, char* caption,
79 // int LCOUNT, char** choices,
80 // int nsel, int *selection,
81 // wxWindow *parent = NULL, int x = -1, int y = -1,
82 // bool centre = TRUE, int width=150, int height=200);
85 wxString wxGetSingleChoice(const wxString& message, const wxString& caption,
86 int LCOUNT, wxString* choices,
87 wxWindow *parent = NULL,
88 int x = -1, int y = -1,
90 int width=150, int height=200);
92 int wxGetSingleChoiceIndex(const wxString& message, const wxString& caption,
93 int LCOUNT, wxString* choices,
94 wxWindow *parent = NULL,
95 int x = -1, int y = -1,
97 int width=150, int height=200);
100 int wxMessageBox(const wxString& message,
101 const wxString& caption = wxPyEmptyStr,
102 int style = wxOK | wxCENTRE,
103 wxWindow *parent = NULL,
104 int x = -1, int y = -1);
106 long wxGetNumberFromUser(const wxString& message,
107 const wxString& prompt,
108 const wxString& caption,
110 long min = 0, long max = 100,
111 wxWindow *parent = NULL,
112 const wxPoint& pos = wxDefaultPosition);
114 //---------------------------------------------------------------------------
117 bool wxColourDisplay();
119 int wxDisplayDepth();
120 int wxGetDisplayDepth();
122 void wxDisplaySize(int* OUTPUT, int* OUTPUT);
123 wxSize wxGetDisplaySize();
125 void wxDisplaySizeMM(int* OUTPUT, int* OUTPUT);
126 wxSize wxGetDisplaySizeMM();
128 void wxClientDisplayRect(int *OUTPUT, int *OUTPUT, int *OUTPUT, int *OUTPUT);
129 wxRect wxGetClientDisplayRect();
131 void wxSetCursor(wxCursor& cursor);
133 //----------------------------------------------------------------------
134 // Miscellaneous functions
136 wxWindow * wxFindWindowByLabel(const wxString& label, wxWindow *parent=NULL);
137 wxWindow * wxFindWindowByName(const wxString& name, wxWindow *parent=NULL);
139 void wxBeginBusyCursor(wxCursor *cursor = wxHOURGLASS_CURSOR);
140 wxWindow * wxGetActiveWindow();
142 wxWindow* wxGenericFindWindowAtPoint(const wxPoint& pt);
143 wxWindow* wxFindWindowAtPoint(const wxPoint& pt);
146 bool wxCheckForInterrupt(wxWindow *wnd);
147 void wxFlushEvents();
150 //---------------------------------------------------------------------------
153 bool wxResourceAddIdentifier(char *name, int value);
154 void wxResourceClear(void);
155 wxBitmap wxResourceCreateBitmap(char *resource);
156 wxIcon wxResourceCreateIcon(char *resource);
157 wxMenuBar * wxResourceCreateMenuBar(char *resource);
158 int wxResourceGetIdentifier(char *name);
159 bool wxResourceParseData(char *resource, wxResourceTable *table = NULL);
160 bool wxResourceParseFile(char *filename, wxResourceTable *table = NULL);
161 bool wxResourceParseString(char *resource, wxResourceTable *table = NULL);
163 //---------------------------------------------------------------------------
177 wxSYS_OEM_FIXED_FONT,
178 wxSYS_ANSI_FIXED_FONT,
181 wxSYS_DEVICE_DEFAULT_FONT,
182 wxSYS_DEFAULT_PALETTE,
183 wxSYS_SYSTEM_FIXED_FONT,
184 wxSYS_DEFAULT_GUI_FONT,
186 wxSYS_COLOUR_SCROLLBAR,
187 wxSYS_COLOUR_BACKGROUND,
188 wxSYS_COLOUR_ACTIVECAPTION,
189 wxSYS_COLOUR_INACTIVECAPTION,
192 wxSYS_COLOUR_WINDOWFRAME,
193 wxSYS_COLOUR_MENUTEXT,
194 wxSYS_COLOUR_WINDOWTEXT,
195 wxSYS_COLOUR_CAPTIONTEXT,
196 wxSYS_COLOUR_ACTIVEBORDER,
197 wxSYS_COLOUR_INACTIVEBORDER,
198 wxSYS_COLOUR_APPWORKSPACE,
199 wxSYS_COLOUR_HIGHLIGHT,
200 wxSYS_COLOUR_HIGHLIGHTTEXT,
201 wxSYS_COLOUR_BTNFACE,
202 wxSYS_COLOUR_BTNSHADOW,
203 wxSYS_COLOUR_GRAYTEXT,
204 wxSYS_COLOUR_BTNTEXT,
205 wxSYS_COLOUR_INACTIVECAPTIONTEXT,
206 wxSYS_COLOUR_BTNHIGHLIGHT,
208 wxSYS_COLOUR_3DDKSHADOW,
209 wxSYS_COLOUR_3DLIGHT,
210 wxSYS_COLOUR_INFOTEXT,
213 wxSYS_COLOUR_DESKTOP,
215 wxSYS_COLOUR_3DSHADOW,
216 wxSYS_COLOUR_3DHIGHLIGHT,
217 wxSYS_COLOUR_3DHILIGHT,
218 wxSYS_COLOUR_BTNHILIGHT,
231 wxSYS_HSCROLL_ARROW_X,
232 wxSYS_HSCROLL_ARROW_Y,
248 wxSYS_VSCROLL_ARROW_X,
249 wxSYS_VSCROLL_ARROW_Y,
253 wxSYS_NETWORK_PRESENT,
254 wxSYS_PENWINDOWS_PRESENT,
263 wxColour wxSystemSettings_GetSystemColour(int index) {
264 return wxSystemSettings::GetSystemColour(index);
267 wxFont wxSystemSettings_GetSystemFont(int index) {
268 return wxSystemSettings::GetSystemFont(index);
271 int wxSystemSettings_GetSystemMetric(int index) {
272 return wxSystemSettings::GetSystemMetric(index);
276 //---------------------------------------------------------------------------
279 class wxToolTip : public wxObject {
281 wxToolTip(const wxString &tip);
283 void SetTip(const wxString& tip);
285 // *** Not in the "public" interface void SetWindow(wxWindow *win);
286 wxWindow *GetWindow();
288 static void Enable(bool flag);
289 static void SetDelay(long milliseconds);
292 //----------------------------------------------------------------------
296 wxCaret(wxWindow* window, const wxSize& size);
301 %name(GetPositionTuple)void GetPosition(int *OUTPUT, int *OUTPUT);
302 wxPoint GetPosition();
303 %name(GetSizeTuple)void GetSize(int *OUTPUT, int *OUTPUT);
305 wxWindow *GetWindow();
306 %name(MoveXY)void Move(int x, int y);
307 void Move(const wxPoint& pt);
308 %name(SetSizeWH) void SetSize(int width, int height);
309 void SetSize(const wxSize& size);
310 void Show(int show = TRUE);
315 int wxCaret_GetBlinkTime() {
316 return wxCaret::GetBlinkTime();
319 void wxCaret_SetBlinkTime(int milliseconds) {
320 wxCaret::SetBlinkTime(milliseconds);
324 //----------------------------------------------------------------------
327 class wxPyFontEnumerator : public wxFontEnumerator {
329 wxPyFontEnumerator() {}
330 ~wxPyFontEnumerator() {}
332 DEC_PYCALLBACK_BOOL_STRING(OnFacename);
333 DEC_PYCALLBACK_BOOL_STRINGSTRING(OnFontEncoding);
338 IMP_PYCALLBACK_BOOL_STRING(wxPyFontEnumerator, wxFontEnumerator, OnFacename);
339 IMP_PYCALLBACK_BOOL_STRINGSTRING(wxPyFontEnumerator, wxFontEnumerator, OnFontEncoding);
343 %name(wxFontEnumerator) class wxPyFontEnumerator {
345 wxPyFontEnumerator();
346 ~wxPyFontEnumerator();
347 void _setSelf(PyObject* self, PyObject* _class);
348 %pragma(python) addtomethod = "__init__:self._setSelf(self, wxFontEnumerator)"
350 bool EnumerateFacenames(
351 wxFontEncoding encoding = wxFONTENCODING_SYSTEM, // all
352 bool fixedWidthOnly = FALSE);
353 bool EnumerateEncodings(const char* facename = "");
355 //wxArrayString* GetEncodings();
356 //wxArrayString* GetFacenames();
358 PyObject* GetEncodings() {
359 wxArrayString* arr = self->GetEncodings();
360 PyObject* list = PyList_New(0);
361 for (size_t x=0; x<arr->GetCount(); x++)
362 PyList_Append(list, PyString_FromString((*arr)[x]));
366 PyObject* GetFacenames() {
367 wxArrayString* arr = self->GetFacenames();
368 PyObject* list = PyList_New(0);
369 for (size_t x=0; x<arr->GetCount(); x++)
370 PyList_Append(list, PyString_FromString((*arr)[x]));
376 //----------------------------------------------------------------------
380 wxBusyCursor(wxCursor* cursor = wxHOURGLASS_CURSOR);
384 //----------------------------------------------------------------------
386 class wxWindowDisabler {
388 wxWindowDisabler(wxWindow *winToSkip = NULL);
392 //----------------------------------------------------------------------
394 bool wxSafeYield(wxWindow* win=NULL);
395 void wxPostEvent(wxEvtHandler *dest, wxEvent& event);
400 void wxWakeUpMainThread();
403 void wxMutexGuiEnter();
404 void wxMutexGuiLeave();
407 class wxMutexGuiLocker {
415 bool wxThread_IsMain() {
416 return wxThread::IsMain();
420 //----------------------------------------------------------------------
426 // wxTipProvider(size_t currentTip); **** Abstract base class
429 virtual wxString GetTip() = 0;
430 size_t GetCurrentTip();
435 // The C++ version of wxPyTipProvider
437 class wxPyTipProvider : public wxTipProvider {
439 wxPyTipProvider(size_t currentTip)
440 : wxTipProvider(currentTip) {}
442 DEC_PYCALLBACK_STRING__pure(GetTip);
447 IMP_PYCALLBACK_STRING__pure( wxPyTipProvider, wxTipProvider, GetTip);
452 // Now let SWIG know about it
453 class wxPyTipProvider : public wxTipProvider {
455 wxPyTipProvider(size_t currentTip);
460 bool wxShowTip(wxWindow *parent, wxTipProvider *tipProvider, bool showAtStartup = TRUE);
461 %new wxTipProvider * wxCreateFileTipProvider(const wxString& filename, size_t currentTip);
464 //----------------------------------------------------------------------
467 #include <wx/generic/dragimgg.h>
470 %name (wxDragImage) class wxGenericDragImage : public wxObject
474 wxGenericDragImage(const wxBitmap& image,
475 const wxCursor& cursor = wxNullCursor);
476 %name(wxDragIcon)wxGenericDragImage(const wxIcon& image,
477 const wxCursor& cursor = wxNullCursor);
478 %name(wxDragString)wxGenericDragImage(const wxString& str,
479 const wxCursor& cursor = wxNullCursor);
480 %name(wxDragTreeItem)wxGenericDragImage(const wxTreeCtrl& treeCtrl, wxTreeItemId& id);
481 %name(wxDragListItem)wxGenericDragImage(const wxListCtrl& listCtrl, long id);
483 ~wxGenericDragImage();
485 void SetBackingBitmap(wxBitmap* bitmap);
486 bool BeginDrag(const wxPoint& hotspot, wxWindow* window,
487 bool fullScreen = FALSE, wxRect* rect = NULL);
489 %name(BeginDrag2) bool BeginDrag(const wxPoint& hotspot, wxWindow* window,
490 wxWindow* fullScreenRect);
493 bool Move(const wxPoint& pt);
497 wxRect GetImageRect(const wxPoint& pos) const;
498 bool RedrawImage(const wxPoint& oldPos, const wxPoint& newPos,
499 bool eraseOld, bool drawNew);
503 //----------------------------------------------------------------------
505 class wxPyTimer : public wxObject {
507 wxPyTimer(PyObject* notify);
512 void SetOwner(wxEvtHandler *owner, int id = -1);
513 void Start(int milliseconds=-1, int oneShot=FALSE);
517 //----------------------------------------------------------------------
518 //----------------------------------------------------------------------
523 wxLOG_FatalError, // program can't continue, abort immediately
524 wxLOG_Error, // a serious error, user must be informed about it
525 wxLOG_Warning, // user is normally informed about it but may be ignored
526 wxLOG_Message, // normal message (i.e. normal output of a non GUI app)
527 wxLOG_Info, // informational message (a.k.a. 'Verbose')
528 wxLOG_Status, // informational: might go to the status line of GUI app
529 wxLOG_Debug, // never shown to the user, disabled in release mode
530 wxLOG_Trace, // trace messages are also only enabled in debug mode
531 wxLOG_Progress, // used for progress indicator (not yet)
532 wxLOG_User = 100 // user defined levels start here
541 static bool IsEnabled();
542 static bool EnableLogging(bool doIt = TRUE);
543 static void OnLog(wxLogLevel level, const char *szString, int t=0);
545 virtual void Flush();
546 bool HasPendingMessages() const;
548 static void FlushActive();
549 static wxLog *GetActiveTarget();
550 static wxLog *SetActiveTarget(wxLog *pLogger);
552 static void Suspend();
553 static void Resume();
555 void SetVerbose(bool bVerbose = TRUE);
557 static void DontCreateOnDemand();
558 static void SetTraceMask(wxTraceMask ulMask);
559 static void AddTraceMask(const wxString& str);
560 static void RemoveTraceMask(const wxString& str);
562 bool GetVerbose() const { return m_bVerbose; }
564 static wxTraceMask GetTraceMask();
565 static bool IsAllowedTraceMask(const char *mask);
570 class wxLogStderr : public wxLog
573 wxLogStderr(/* TODO: FILE *fp = (FILE *) NULL*/);
577 class wxLogTextCtrl : public wxLog
580 wxLogTextCtrl(wxTextCtrl *pTextCtrl);
584 class wxLogGui : public wxLog
590 class wxLogWindow : public wxLog
593 wxLogWindow(wxFrame *pParent, // the parent frame (can be NULL)
594 const char *szTitle, // the title of the frame
595 bool bShow = TRUE, // show window immediately?
596 bool bPassToOld = TRUE); // pass log messages to the old target?
598 void Show(bool bShow = TRUE);
599 wxFrame *GetFrame() const;
600 wxLog *GetOldLog() const;
601 bool IsPassingMessages() const;
602 void PassMessages(bool bDoPass) { m_bPassMessages = bDoPass; }
614 unsigned long wxSysErrorCode();
615 const char* wxSysErrorMsg(unsigned long nErrCode = 0);
616 void wxLogFatalError(const char *szFormat);
617 void wxLogError(const char *szFormat);
618 void wxLogWarning(const char *szFormat);
619 void wxLogMessage(const char *szFormat);
620 void wxLogInfo(const char *szFormat);
621 void wxLogVerbose(const char *szFormat);
622 void wxLogStatus(const char *szFormat);
623 %name(wxLogStatusFrame)void wxLogStatus(wxFrame *pFrame, const char *szFormat);
624 void wxLogSysError(const char *szFormat);
628 //----------------------------------------------------------------------
637 class wxProcessEvent : public wxEvent {
639 wxProcessEvent(int id = 0, int pid = 0, int exitcode = 0);
642 int m_pid, m_exitcode;
648 %{ // C++ version of wxProcess derived class
650 class wxPyProcess : public wxProcess {
652 wxPyProcess(wxEvtHandler *parent = NULL, int id = -1)
653 : wxProcess(parent, id)
656 DEC_PYCALLBACK_VOID_INTINT(OnTerminate);
661 IMP_PYCALLBACK_VOID_INTINT( wxPyProcess, wxProcess, OnTerminate);
666 %name(wxProcess)class wxPyProcess : public wxEvtHandler {
668 wxPyProcess(wxEvtHandler *parent = NULL, int id = -1);
669 %addmethods { void Destroy() { delete self; } }
671 void _setSelf(PyObject* self, PyObject* _class);
672 %pragma(python) addtomethod = "__init__:self._setSelf(self, wxProcess)"
674 void base_OnTerminate(int pid, int status);
680 wxInputStream *GetInputStream();
681 wxInputStream *GetErrorStream();
682 wxOutputStream *GetOutputStream();
689 long wxExecute(const wxString& command,
691 wxPyProcess *process = NULL);
693 //----------------------------------------------------------------------
696 #if !wxUSE_JOYSTICK && !defined(__WXMSW__)
697 // A C++ stub class for wxJoystick for platforms that don't have it.
698 class wxJoystick : public wxObject {
700 wxJoystick(int joystick = wxJOYSTICK1) {
701 bool doSave = wxPyRestoreThread();
702 PyErr_SetString(PyExc_NotImplementedError, "wxJoystick is not available on this platform.");
703 wxPySaveThread(doSave);
705 wxPoint GetPosition() { return wxPoint(-1,-1); }
706 int GetZPosition() { return -1; }
707 int GetButtonState() { return -1; }
708 int GetPOVPosition() { return -1; }
709 int GetPOVCTSPosition() { return -1; }
710 int GetRudderPosition() { return -1; }
711 int GetUPosition() { return -1; }
712 int GetVPosition() { return -1; }
713 int GetMovementThreshold() { return -1; }
714 void SetMovementThreshold(int threshold) {}
716 bool IsOk(void) { return FALSE; }
717 int GetNumberJoysticks() { return -1; }
718 int GetManufacturerId() { return -1; }
719 int GetProductId() { return -1; }
720 wxString GetProductName() { return ""; }
721 int GetXMin() { return -1; }
722 int GetYMin() { return -1; }
723 int GetZMin() { return -1; }
724 int GetXMax() { return -1; }
725 int GetYMax() { return -1; }
726 int GetZMax() { return -1; }
727 int GetNumberButtons() { return -1; }
728 int GetNumberAxes() { return -1; }
729 int GetMaxButtons() { return -1; }
730 int GetMaxAxes() { return -1; }
731 int GetPollingMin() { return -1; }
732 int GetPollingMax() { return -1; }
733 int GetRudderMin() { return -1; }
734 int GetRudderMax() { return -1; }
735 int GetUMin() { return -1; }
736 int GetUMax() { return -1; }
737 int GetVMin() { return -1; }
738 int GetVMax() { return -1; }
740 bool HasRudder() { return FALSE; }
741 bool HasZ() { return FALSE; }
742 bool HasU() { return FALSE; }
743 bool HasV() { return FALSE; }
744 bool HasPOV() { return FALSE; }
745 bool HasPOV4Dir() { return FALSE; }
746 bool HasPOVCTS() { return FALSE; }
748 bool SetCapture(wxWindow* win, int pollingFreq = 0) { return FALSE; }
749 bool ReleaseCapture() { return FALSE; }
755 class wxJoystick : public wxObject {
757 wxJoystick(int joystick = wxJOYSTICK1);
760 wxPoint GetPosition();
762 int GetButtonState();
763 int GetPOVPosition();
764 int GetPOVCTSPosition();
765 int GetRudderPosition();
768 int GetMovementThreshold();
769 void SetMovementThreshold(int threshold) ;
772 int GetNumberJoysticks();
773 int GetManufacturerId();
775 wxString GetProductName();
782 int GetNumberButtons();
803 bool SetCapture(wxWindow* win, int pollingFreq = 0);
804 bool ReleaseCapture();
807 //----------------------------------------------------------------------
811 // A C++ stub class for wxWave for platforms that don't have it.
812 class wxWave : public wxObject
815 wxWave(const wxString& fileName, bool isResource = FALSE) {
816 wxPyTState* state = wxPyBeginBlockThreads();
817 PyErr_SetString(PyExc_NotImplementedError, "wxWave is not available on this platform.");
818 wxPyEndBlockThreads(state);
820 wxWave(int size, const wxByte* data) {
821 wxPyTState* state = wxPyBeginBlockThreads();
822 PyErr_SetString(PyExc_NotImplementedError, "wxWave is not available on this platform.");
823 wxPyEndBlockThreads(state);
828 bool IsOk() const { return FALSE; }
829 bool Play(bool async = TRUE, bool looped = FALSE) const { return FALSE; }
835 class wxWave : public wxObject
838 wxWave(const wxString& fileName, bool isResource = FALSE);
842 bool Play(bool async = TRUE, bool looped = FALSE) const;
845 %new wxWave* wxWaveData(const wxString& data);
846 %{ // Implementations of some alternate "constructors"
847 wxWave* wxWaveData(const wxString& data) {
848 return new wxWave(data.Len(), (wxByte*)data.c_str());
853 //----------------------------------------------------------------------
854 //----------------------------------------------------------------------
858 wxPyPtrTypeMap_Add("wxFontEnumerator", "wxPyFontEnumerator");
859 wxPyPtrTypeMap_Add("wxDragImage", "wxGenericDragImage");
860 wxPyPtrTypeMap_Add("wxProcess", "wxPyProcess");
863 //----------------------------------------------------------------------