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);
144 bool wxCheckForInterrupt(wxWindow *wnd);
146 //---------------------------------------------------------------------------
149 bool wxResourceAddIdentifier(char *name, int value);
150 void wxResourceClear(void);
151 wxBitmap wxResourceCreateBitmap(char *resource);
152 wxIcon wxResourceCreateIcon(char *resource);
153 wxMenuBar * wxResourceCreateMenuBar(char *resource);
154 int wxResourceGetIdentifier(char *name);
155 bool wxResourceParseData(char *resource, wxResourceTable *table = NULL);
156 bool wxResourceParseFile(char *filename, wxResourceTable *table = NULL);
157 bool wxResourceParseString(char *resource, wxResourceTable *table = NULL);
159 //---------------------------------------------------------------------------
173 wxSYS_OEM_FIXED_FONT,
174 wxSYS_ANSI_FIXED_FONT,
177 wxSYS_DEVICE_DEFAULT_FONT,
178 wxSYS_DEFAULT_PALETTE,
179 wxSYS_SYSTEM_FIXED_FONT,
180 wxSYS_DEFAULT_GUI_FONT,
182 wxSYS_COLOUR_SCROLLBAR,
183 wxSYS_COLOUR_BACKGROUND,
184 wxSYS_COLOUR_ACTIVECAPTION,
185 wxSYS_COLOUR_INACTIVECAPTION,
188 wxSYS_COLOUR_WINDOWFRAME,
189 wxSYS_COLOUR_MENUTEXT,
190 wxSYS_COLOUR_WINDOWTEXT,
191 wxSYS_COLOUR_CAPTIONTEXT,
192 wxSYS_COLOUR_ACTIVEBORDER,
193 wxSYS_COLOUR_INACTIVEBORDER,
194 wxSYS_COLOUR_APPWORKSPACE,
195 wxSYS_COLOUR_HIGHLIGHT,
196 wxSYS_COLOUR_HIGHLIGHTTEXT,
197 wxSYS_COLOUR_BTNFACE,
198 wxSYS_COLOUR_BTNSHADOW,
199 wxSYS_COLOUR_GRAYTEXT,
200 wxSYS_COLOUR_BTNTEXT,
201 wxSYS_COLOUR_INACTIVECAPTIONTEXT,
202 wxSYS_COLOUR_BTNHIGHLIGHT,
204 wxSYS_COLOUR_3DDKSHADOW,
205 wxSYS_COLOUR_3DLIGHT,
206 wxSYS_COLOUR_INFOTEXT,
209 wxSYS_COLOUR_DESKTOP,
211 wxSYS_COLOUR_3DSHADOW,
212 wxSYS_COLOUR_3DHIGHLIGHT,
213 wxSYS_COLOUR_3DHILIGHT,
214 wxSYS_COLOUR_BTNHILIGHT,
227 wxSYS_HSCROLL_ARROW_X,
228 wxSYS_HSCROLL_ARROW_Y,
244 wxSYS_VSCROLL_ARROW_X,
245 wxSYS_VSCROLL_ARROW_Y,
249 wxSYS_NETWORK_PRESENT,
250 wxSYS_PENWINDOWS_PRESENT,
259 wxColour wxSystemSettings_GetSystemColour(int index) {
260 return wxSystemSettings::GetSystemColour(index);
263 wxFont wxSystemSettings_GetSystemFont(int index) {
264 return wxSystemSettings::GetSystemFont(index);
267 int wxSystemSettings_GetSystemMetric(int index) {
268 return wxSystemSettings::GetSystemMetric(index);
272 //---------------------------------------------------------------------------
275 class wxToolTip : public wxObject {
277 wxToolTip(const wxString &tip);
279 void SetTip(const wxString& tip);
281 // *** Not in the "public" interface void SetWindow(wxWindow *win);
282 wxWindow *GetWindow();
287 void wxToolTip_Enable(bool flag) {
288 wxToolTip::Enable(flag);
291 void wxToolTip_SetDelay(long milliseconds) {
292 wxToolTip::SetDelay(milliseconds);
296 //----------------------------------------------------------------------
300 wxCaret(wxWindow* window, const wxSize& size);
305 %name(GetPositionTuple)void GetPosition(int *OUTPUT, int *OUTPUT);
306 wxPoint GetPosition();
307 %name(GetSizeTuple)void GetSize(int *OUTPUT, int *OUTPUT);
309 wxWindow *GetWindow();
310 %name(MoveXY)void Move(int x, int y);
311 void Move(const wxPoint& pt);
312 %name(SetSizeWH) void SetSize(int width, int height);
313 void SetSize(const wxSize& size);
314 void Show(int show = TRUE);
319 int wxCaret_GetBlinkTime() {
320 return wxCaret::GetBlinkTime();
323 void wxCaret_SetBlinkTime(int milliseconds) {
324 wxCaret::SetBlinkTime(milliseconds);
328 //----------------------------------------------------------------------
331 class wxPyFontEnumerator : public wxFontEnumerator {
333 wxPyFontEnumerator() {}
334 ~wxPyFontEnumerator() {}
336 DEC_PYCALLBACK_BOOL_STRING(OnFacename);
337 DEC_PYCALLBACK_BOOL_STRINGSTRING(OnFontEncoding);
342 IMP_PYCALLBACK_BOOL_STRING(wxPyFontEnumerator, wxFontEnumerator, OnFacename);
343 IMP_PYCALLBACK_BOOL_STRINGSTRING(wxPyFontEnumerator, wxFontEnumerator, OnFontEncoding);
347 %name(wxFontEnumerator) class wxPyFontEnumerator {
349 wxPyFontEnumerator();
350 ~wxPyFontEnumerator();
351 void _setSelf(PyObject* self, PyObject* _class);
352 %pragma(python) addtomethod = "__init__:self._setSelf(self, wxFontEnumerator)"
354 bool EnumerateFacenames(
355 wxFontEncoding encoding = wxFONTENCODING_SYSTEM, // all
356 bool fixedWidthOnly = FALSE);
357 bool EnumerateEncodings(const char* facename = "");
359 //wxArrayString* GetEncodings();
360 //wxArrayString* GetFacenames();
362 PyObject* GetEncodings() {
363 wxArrayString* arr = self->GetEncodings();
364 PyObject* list = PyList_New(0);
365 for (size_t x=0; x<arr->GetCount(); x++)
366 PyList_Append(list, PyString_FromString((*arr)[x]));
370 PyObject* GetFacenames() {
371 wxArrayString* arr = self->GetFacenames();
372 PyObject* list = PyList_New(0);
373 for (size_t x=0; x<arr->GetCount(); x++)
374 PyList_Append(list, PyString_FromString((*arr)[x]));
380 //----------------------------------------------------------------------
384 wxBusyCursor(wxCursor* cursor = wxHOURGLASS_CURSOR);
388 //----------------------------------------------------------------------
390 class wxWindowDisabler {
392 wxWindowDisabler(wxWindow *winToSkip = NULL);
396 //----------------------------------------------------------------------
398 bool wxSafeYield(wxWindow* win=NULL);
399 void wxPostEvent(wxEvtHandler *dest, wxEvent& event);
404 void wxWakeUpMainThread();
407 void wxMutexGuiEnter();
408 void wxMutexGuiLeave();
411 class wxMutexGuiLocker {
419 bool wxThread_IsMain() {
420 return wxThread::IsMain();
424 //----------------------------------------------------------------------
430 // wxTipProvider(size_t currentTip); **** Abstract base class
433 virtual wxString GetTip() = 0;
434 size_t GetCurrentTip();
439 // The C++ version of wxPyTipProvider
441 class wxPyTipProvider : public wxTipProvider {
443 wxPyTipProvider(size_t currentTip)
444 : wxTipProvider(currentTip) {}
446 DEC_PYCALLBACK_STRING__pure(GetTip);
451 IMP_PYCALLBACK_STRING__pure( wxPyTipProvider, wxTipProvider, GetTip);
456 // Now let SWIG know about it
457 class wxPyTipProvider : public wxTipProvider {
459 wxPyTipProvider(size_t currentTip);
464 bool wxShowTip(wxWindow *parent, wxTipProvider *tipProvider, bool showAtStartup = TRUE);
465 %new wxTipProvider * wxCreateFileTipProvider(const wxString& filename, size_t currentTip);
468 //----------------------------------------------------------------------
471 #include <wx/generic/dragimgg.h>
474 %name (wxDragImage) class wxGenericDragImage : public wxObject
478 wxGenericDragImage(const wxBitmap& image,
479 const wxCursor& cursor = wxNullCursor);
480 ~wxGenericDragImage();
482 void SetBackingBitmap(wxBitmap* bitmap);
483 bool BeginDrag(const wxPoint& hotspot, wxWindow* window,
484 bool fullScreen = FALSE, wxRect* rect = NULL);
486 %name(BeginDrag2) bool BeginDrag(const wxPoint& hotspot, wxWindow* window,
487 wxWindow* fullScreenRect);
490 bool Move(const wxPoint& pt);
494 wxRect GetImageRect(const wxPoint& pos) const;
495 bool RedrawImage(const wxPoint& oldPos, const wxPoint& newPos,
496 bool eraseOld, bool drawNew);
500 // Alternate Constructors
501 %new wxGenericDragImage* wxDragIcon(const wxIcon& image,
502 const wxCursor& cursor = wxNullCursor);
504 %new wxGenericDragImage* wxDragString(const wxString& str,
505 const wxCursor& cursor = wxNullCursor);
507 %new wxGenericDragImage* wxDragTreeItem(const wxTreeCtrl& treeCtrl, wxTreeItemId& id);
509 %new wxGenericDragImage* wxDragListItem(const wxListCtrl& listCtrl, long id);
514 wxGenericDragImage* wxDragIcon(const wxIcon& image,
515 const wxCursor& cursor) {
516 return new wxGenericDragImage(image, cursor);
519 wxGenericDragImage* wxDragString(const wxString& str,
520 const wxCursor& cursor) {
521 return new wxGenericDragImage(str, cursor);
524 wxGenericDragImage* wxDragTreeItem(const wxTreeCtrl& treeCtrl, wxTreeItemId& id) {
525 return new wxGenericDragImage(treeCtrl, id);
528 wxGenericDragImage* wxDragListItem(const wxListCtrl& listCtrl, long id) {
529 return new wxGenericDragImage(listCtrl, id);
536 //----------------------------------------------------------------------
538 class wxPyTimer : public wxObject {
540 wxPyTimer(PyObject* notify);
545 void SetOwner(wxEvtHandler *owner, int id = -1);
546 void Start(int milliseconds=-1, int oneShot=FALSE);
550 //----------------------------------------------------------------------
551 //----------------------------------------------------------------------
556 wxLOG_FatalError, // program can't continue, abort immediately
557 wxLOG_Error, // a serious error, user must be informed about it
558 wxLOG_Warning, // user is normally informed about it but may be ignored
559 wxLOG_Message, // normal message (i.e. normal output of a non GUI app)
560 wxLOG_Info, // informational message (a.k.a. 'Verbose')
561 wxLOG_Status, // informational: might go to the status line of GUI app
562 wxLOG_Debug, // never shown to the user, disabled in release mode
563 wxLOG_Trace, // trace messages are also only enabled in debug mode
564 wxLOG_Progress, // used for progress indicator (not yet)
565 wxLOG_User = 100 // user defined levels start here
574 static bool IsEnabled();
575 static bool EnableLogging(bool doIt = TRUE);
576 static void OnLog(wxLogLevel level, const char *szString, int t=0);
578 virtual void Flush();
579 bool HasPendingMessages() const;
581 static void FlushActive();
582 static wxLog *GetActiveTarget();
583 static wxLog *SetActiveTarget(wxLog *pLogger);
585 static void Suspend();
586 static void Resume();
588 void SetVerbose(bool bVerbose = TRUE);
590 static void DontCreateOnDemand();
591 static void SetTraceMask(wxTraceMask ulMask);
592 static void AddTraceMask(const wxString& str);
593 static void RemoveTraceMask(const wxString& str);
595 bool GetVerbose() const { return m_bVerbose; }
597 static wxTraceMask GetTraceMask();
598 static bool IsAllowedTraceMask(const char *mask);
603 class wxLogStderr : public wxLog
606 wxLogStderr(/* TODO: FILE *fp = (FILE *) NULL*/);
610 class wxLogTextCtrl : public wxLog
613 wxLogTextCtrl(wxTextCtrl *pTextCtrl);
617 class wxLogGui : public wxLog
623 class wxLogWindow : public wxLog
626 wxLogWindow(wxFrame *pParent, // the parent frame (can be NULL)
627 const char *szTitle, // the title of the frame
628 bool bShow = TRUE, // show window immediately?
629 bool bPassToOld = TRUE); // pass log messages to the old target?
631 void Show(bool bShow = TRUE);
632 wxFrame *GetFrame() const;
633 wxLog *GetOldLog() const;
634 bool IsPassingMessages() const;
635 void PassMessages(bool bDoPass) { m_bPassMessages = bDoPass; }
647 unsigned long wxSysErrorCode();
648 const char* wxSysErrorMsg(unsigned long nErrCode = 0);
649 void wxLogFatalError(const char *szFormat);
650 void wxLogError(const char *szFormat);
651 void wxLogWarning(const char *szFormat);
652 void wxLogMessage(const char *szFormat);
653 void wxLogInfo(const char *szFormat);
654 void wxLogVerbose(const char *szFormat);
655 void wxLogStatus(const char *szFormat);
656 %name(wxLogStatusFrame)void wxLogStatus(wxFrame *pFrame, const char *szFormat);
657 void wxLogSysError(const char *szFormat);
661 //----------------------------------------------------------------------
670 class wxProcessEvent : public wxEvent {
672 wxProcessEvent(int id = 0, int pid = 0, int exitcode = 0);
675 int m_pid, m_exitcode;
681 %{ // C++ version of wxProcess derived class
683 class wxPyProcess : public wxProcess {
685 wxPyProcess(wxEvtHandler *parent = NULL, int id = -1)
686 : wxProcess(parent, id)
689 DEC_PYCALLBACK_VOID_INTINT(OnTerminate);
694 IMP_PYCALLBACK_VOID_INTINT( wxPyProcess, wxProcess, OnTerminate);
698 %name(wxProcess)class wxPyProcess : public wxEvtHandler {
700 wxPyProcess(wxEvtHandler *parent = NULL, int id = -1);
701 %addmethods { void Destroy() { delete self; } }
703 void _setSelf(PyObject* self, PyObject* _class);
704 %pragma(python) addtomethod = "__init__:self._setSelf(self, wxProcess)"
706 void base_OnTerminate(int pid, int status);
712 wxInputStream *GetInputStream();
713 wxInputStream *GetErrorStream();
714 wxOutputStream *GetOutputStream();
721 long wxExecute(const wxString& command,
723 wxPyProcess *process = NULL);
725 //----------------------------------------------------------------------
728 #if !wxUSE_JOYSTICK && !defined(__WXMSW__)
729 // A C++ stub class for wxJoystick for platforms that don't have it.
730 class wxJoystick : public wxObject {
732 wxJoystick(int joystick = wxJOYSTICK1) {
733 bool doSave = wxPyRestoreThread();
734 PyErr_SetString(PyExc_NotImplementedError, "wxJoystick is not available on this platform.");
735 wxPySaveThread(doSave);
737 wxPoint GetPosition() { return wxPoint(-1,-1); }
738 int GetZPosition() { return -1; }
739 int GetButtonState() { return -1; }
740 int GetPOVPosition() { return -1; }
741 int GetPOVCTSPosition() { return -1; }
742 int GetRudderPosition() { return -1; }
743 int GetUPosition() { return -1; }
744 int GetVPosition() { return -1; }
745 int GetMovementThreshold() { return -1; }
746 void SetMovementThreshold(int threshold) ;
748 bool IsOk(void) { return FALSE; }
749 int GetNumberJoysticks() { return -1; }
750 int GetManufacturerId() { return -1; }
751 int GetProductId() { return -1; }
752 wxString GetProductName() { return ""; }
753 int GetXMin() { return -1; }
754 int GetYMin() { return -1; }
755 int GetZMin() { return -1; }
756 int GetXMax() { return -1; }
757 int GetYMax() { return -1; }
758 int GetZMax() { return -1; }
759 int GetNumberButtons() { return -1; }
760 int GetNumberAxes() { return -1; }
761 int GetMaxButtons() { return -1; }
762 int GetMaxAxes() { return -1; }
763 int GetPollingMin() { return -1; }
764 int GetPollingMax() { return -1; }
765 int GetRudderMin() { return -1; }
766 int GetRudderMax() { return -1; }
767 int GetUMin() { return -1; }
768 int GetUMax() { return -1; }
769 int GetVMin() { return -1; }
770 int GetVMax() { return -1; }
772 bool HasRudder() { return FALSE; }
773 bool HasZ() { return FALSE; }
774 bool HasU() { return FALSE; }
775 bool HasV() { return FALSE; }
776 bool HasPOV() { return FALSE; }
777 bool HasPOV4Dir() { return FALSE; }
778 bool HasPOVCTS() { return FALSE; }
780 bool SetCapture(wxWindow* win, int pollingFreq = 0) { return FALSE; }
781 bool ReleaseCapture() { return FALSE; }
787 class wxJoystick : public wxObject {
789 wxJoystick(int joystick = wxJOYSTICK1);
790 wxPoint GetPosition();
792 int GetButtonState();
793 int GetPOVPosition();
794 int GetPOVCTSPosition();
795 int GetRudderPosition();
798 int GetMovementThreshold();
799 void SetMovementThreshold(int threshold) ;
802 int GetNumberJoysticks();
803 int GetManufacturerId();
805 wxString GetProductName();
812 int GetNumberButtons();
833 bool SetCapture(wxWindow* win, int pollingFreq = 0);
834 bool ReleaseCapture();
837 //----------------------------------------------------------------------
840 #if !wxUSE_WAVE && !defined(__WXMSW__)
841 // A C++ stub class for wxWave for platforms that don't have it.
842 class wxWave : public wxObject
845 wxWave(const wxString& fileName, bool isResource = FALSE) {
846 bool doSave = wxPyRestoreThread();
847 PyErr_SetString(PyExc_NotImplementedError, "wxWave is not available on this platform.");
848 wxPySaveThread(doSave);
850 wxWave(int size, const wxByte* data) {
851 bool doSave = wxPyRestoreThread();
852 PyErr_SetString(PyExc_NotImplementedError, "wxWave is not available on this platform.");
853 wxPySaveThread(doSave);
858 bool IsOk() const { return FALSE; }
859 bool Play(bool async = TRUE, bool looped = FALSE) const { return FALSE; }
865 class wxWave : public wxObject
868 wxWave(const wxString& fileName, bool isResource = FALSE);
872 bool Play(bool async = TRUE, bool looped = FALSE) const;
875 %new wxWave* wxWaveData(const wxString& data);
876 %{ // Implementations of some alternate "constructors"
877 wxWave* wxWaveData(const wxString& data) {
878 return new wxWave(data.Len(), (wxByte*)data.c_str());
882 //----------------------------------------------------------------------
886 wxPyPtrTypeMap_Add("wxFontEnumerator", "wxPyFontEnumerator");
887 wxPyPtrTypeMap_Add("wxDragImage", "wxGenericDragImage");
888 wxPyPtrTypeMap_Add("wxProcess", "wxPyProcess");
891 //----------------------------------------------------------------------