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>
25 #include <wx/joystick.h>
28 //----------------------------------------------------------------------
31 %include my_typemaps.i
33 // Import some definitions of other classes, etc.
42 static wxString wxPyEmptyStr("");
45 //---------------------------------------------------------------------------
48 wxString wxFileSelector(char* message,
49 char* default_path = NULL,
50 char* default_filename = NULL,
51 char* default_extension = NULL,
52 char* wildcard = "*.*",
54 wxWindow *parent = NULL,
55 int x = -1, int y = -1);
57 wxString wxGetTextFromUser(const wxString& message,
58 const wxString& caption = wxPyEmptyStr,
59 const wxString& default_value = wxPyEmptyStr,
60 wxWindow *parent = NULL,
61 int x = -1, int y = -1,
64 wxString wxGetPasswordFromUser(const wxString& message,
65 const wxString& caption = wxPyEmptyStr,
66 const wxString& default_value = wxPyEmptyStr,
67 wxWindow *parent = NULL);
70 // TODO: Need to custom wrap this one...
71 // int wxGetMultipleChoice(char* message, char* caption,
72 // int LCOUNT, char** choices,
73 // int nsel, int *selection,
74 // wxWindow *parent = NULL, int x = -1, int y = -1,
75 // bool centre = TRUE, int width=150, int height=200);
78 wxString wxGetSingleChoice(const wxString& message, const wxString& caption,
79 int LCOUNT, wxString* choices,
80 wxWindow *parent = NULL,
81 int x = -1, int y = -1,
83 int width=150, int height=200);
85 int wxGetSingleChoiceIndex(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);
93 int wxMessageBox(const wxString& message,
94 const wxString& caption = wxPyEmptyStr,
95 int style = wxOK | wxCENTRE,
96 wxWindow *parent = NULL,
97 int x = -1, int y = -1);
99 long wxGetNumberFromUser(const wxString& message,
100 const wxString& prompt,
101 const wxString& caption,
103 long min = 0, long max = 100,
104 wxWindow *parent = NULL,
105 const wxPoint& pos = wxDefaultPosition);
107 //---------------------------------------------------------------------------
110 bool wxColourDisplay();
112 int wxDisplayDepth();
113 int wxGetDisplayDepth();
115 void wxDisplaySize(int* OUTPUT, int* OUTPUT);
116 wxSize wxGetDisplaySize();
118 void wxDisplaySizeMM(int* OUTPUT, int* OUTPUT);
119 wxSize wxGetDisplaySizeMM();
121 void wxSetCursor(wxCursor& cursor);
123 //----------------------------------------------------------------------
124 // Miscellaneous functions
126 wxWindow * wxFindWindowByLabel(const wxString& label, wxWindow *parent=NULL);
127 wxWindow * wxFindWindowByName(const wxString& name, wxWindow *parent=NULL);
129 void wxBeginBusyCursor(wxCursor *cursor = wxHOURGLASS_CURSOR);
130 wxWindow * wxGetActiveWindow();
133 //---------------------------------------------------------------------------
136 bool wxResourceAddIdentifier(char *name, int value);
137 void wxResourceClear(void);
138 wxBitmap wxResourceCreateBitmap(char *resource);
139 wxIcon wxResourceCreateIcon(char *resource);
140 wxMenuBar * wxResourceCreateMenuBar(char *resource);
141 int wxResourceGetIdentifier(char *name);
142 bool wxResourceParseData(char *resource, wxResourceTable *table = NULL);
143 bool wxResourceParseFile(char *filename, wxResourceTable *table = NULL);
144 bool wxResourceParseString(char *resource, wxResourceTable *table = NULL);
146 //---------------------------------------------------------------------------
160 wxSYS_OEM_FIXED_FONT,
161 wxSYS_ANSI_FIXED_FONT,
164 wxSYS_DEVICE_DEFAULT_FONT,
165 wxSYS_DEFAULT_PALETTE,
166 wxSYS_SYSTEM_FIXED_FONT,
167 wxSYS_DEFAULT_GUI_FONT,
169 wxSYS_COLOUR_SCROLLBAR,
170 wxSYS_COLOUR_BACKGROUND,
171 wxSYS_COLOUR_ACTIVECAPTION,
172 wxSYS_COLOUR_INACTIVECAPTION,
175 wxSYS_COLOUR_WINDOWFRAME,
176 wxSYS_COLOUR_MENUTEXT,
177 wxSYS_COLOUR_WINDOWTEXT,
178 wxSYS_COLOUR_CAPTIONTEXT,
179 wxSYS_COLOUR_ACTIVEBORDER,
180 wxSYS_COLOUR_INACTIVEBORDER,
181 wxSYS_COLOUR_APPWORKSPACE,
182 wxSYS_COLOUR_HIGHLIGHT,
183 wxSYS_COLOUR_HIGHLIGHTTEXT,
184 wxSYS_COLOUR_BTNFACE,
185 wxSYS_COLOUR_BTNSHADOW,
186 wxSYS_COLOUR_GRAYTEXT,
187 wxSYS_COLOUR_BTNTEXT,
188 wxSYS_COLOUR_INACTIVECAPTIONTEXT,
189 wxSYS_COLOUR_BTNHIGHLIGHT,
191 wxSYS_COLOUR_3DDKSHADOW,
192 wxSYS_COLOUR_3DLIGHT,
193 wxSYS_COLOUR_INFOTEXT,
196 wxSYS_COLOUR_DESKTOP,
198 wxSYS_COLOUR_3DSHADOW,
199 wxSYS_COLOUR_3DHIGHLIGHT,
200 wxSYS_COLOUR_3DHILIGHT,
201 wxSYS_COLOUR_BTNHILIGHT,
214 wxSYS_HSCROLL_ARROW_X,
215 wxSYS_HSCROLL_ARROW_Y,
231 wxSYS_VSCROLL_ARROW_X,
232 wxSYS_VSCROLL_ARROW_Y,
236 wxSYS_NETWORK_PRESENT,
237 wxSYS_PENWINDOWS_PRESENT,
246 wxColour wxSystemSettings_GetSystemColour(int index) {
247 return wxSystemSettings::GetSystemColour(index);
250 wxFont wxSystemSettings_GetSystemFont(int index) {
251 return wxSystemSettings::GetSystemFont(index);
254 int wxSystemSettings_GetSystemMetric(int index) {
255 return wxSystemSettings::GetSystemMetric(index);
259 //---------------------------------------------------------------------------
264 wxToolTip(const wxString &tip);
266 void SetTip(const wxString& tip);
268 // *** Not in the "public" interface void SetWindow(wxWindow *win);
269 wxWindow *GetWindow();
274 void wxToolTip_Enable(bool flag) {
275 wxToolTip::Enable(flag);
278 void wxToolTip_SetDelay(long milliseconds) {
279 wxToolTip::SetDelay(milliseconds);
283 //----------------------------------------------------------------------
287 wxCaret(wxWindow* window, const wxSize& size);
292 %name(GetPositionTuple)void GetPosition(int *OUTPUT, int *OUTPUT);
293 wxPoint GetPosition();
294 %name(GetSizeTuple)void GetSize(int *OUTPUT, int *OUTPUT);
296 wxWindow *GetWindow();
297 %name(MoveXY)void Move(int x, int y);
298 void Move(const wxPoint& pt);
299 %name(SetSizeWH) void SetSize(int width, int height);
300 void SetSize(const wxSize& size);
301 void Show(int show = TRUE);
306 int wxCaret_GetBlinkTime() {
307 return wxCaret::GetBlinkTime();
310 void wxCaret_SetBlinkTime(int milliseconds) {
311 wxCaret::SetBlinkTime(milliseconds);
315 //----------------------------------------------------------------------
318 class wxPyFontEnumerator : public wxFontEnumerator {
320 wxPyFontEnumerator() {}
321 ~wxPyFontEnumerator() {}
323 DEC_PYCALLBACK_BOOL_STRING(OnFacename);
324 DEC_PYCALLBACK_BOOL_STRINGSTRING(OnFontEncoding);
329 IMP_PYCALLBACK_BOOL_STRING(wxPyFontEnumerator, wxFontEnumerator, OnFacename);
330 IMP_PYCALLBACK_BOOL_STRINGSTRING(wxPyFontEnumerator, wxFontEnumerator, OnFontEncoding);
334 %name(wxFontEnumerator) class wxPyFontEnumerator {
336 wxPyFontEnumerator();
337 ~wxPyFontEnumerator();
338 void _setSelf(PyObject* self, PyObject* _class);
339 %pragma(python) addtomethod = "__init__:self._setSelf(self, wxFontEnumerator)"
341 bool EnumerateFacenames(
342 wxFontEncoding encoding = wxFONTENCODING_SYSTEM, // all
343 bool fixedWidthOnly = FALSE);
344 bool EnumerateEncodings(const char* facename = "");
346 //wxArrayString* GetEncodings();
347 //wxArrayString* GetFacenames();
349 PyObject* GetEncodings() {
350 wxArrayString* arr = self->GetEncodings();
351 PyObject* list = PyList_New(0);
352 for (size_t x=0; x<arr->GetCount(); x++)
353 PyList_Append(list, PyString_FromString((*arr)[x]));
357 PyObject* GetFacenames() {
358 wxArrayString* arr = self->GetFacenames();
359 PyObject* list = PyList_New(0);
360 for (size_t x=0; x<arr->GetCount(); x++)
361 PyList_Append(list, PyString_FromString((*arr)[x]));
367 //----------------------------------------------------------------------
371 wxBusyCursor(wxCursor* cursor = wxHOURGLASS_CURSOR);
375 //----------------------------------------------------------------------
377 class wxWindowDisabler {
379 wxWindowDisabler(wxWindow *winToSkip = NULL);
383 //----------------------------------------------------------------------
385 bool wxSafeYield(wxWindow* win=NULL);
386 void wxPostEvent(wxEvtHandler *dest, wxEvent& event);
390 void wxWakeUpMainThread();
391 void wxMutexGuiEnter();
392 void wxMutexGuiLeave();
395 class wxMutexGuiLocker {
403 bool wxThread_IsMain() {
404 return wxThread::IsMain();
408 //----------------------------------------------------------------------
414 // wxTipProvider(size_t currentTip); **** Abstract base class
417 virtual wxString GetTip() = 0;
418 size_t GetCurrentTip();
423 // The C++ version of wxPyTipProvider
425 class wxPyTipProvider : public wxTipProvider {
427 wxPyTipProvider(size_t currentTip)
428 : wxTipProvider(currentTip) {}
430 DEC_PYCALLBACK_STRING__pure(GetTip);
435 IMP_PYCALLBACK_STRING__pure( wxPyTipProvider, wxTipProvider, GetTip);
440 // Now let SWIG know about it
441 class wxPyTipProvider : public wxTipProvider {
443 wxPyTipProvider(size_t currentTip);
448 bool wxShowTip(wxWindow *parent, wxTipProvider *tipProvider, bool showAtStartup = TRUE);
449 %new wxTipProvider * wxCreateFileTipProvider(const wxString& filename, size_t currentTip);
452 //----------------------------------------------------------------------
455 #include <wx/generic/dragimgg.h>
456 static wxPoint wxPyNullPoint;
459 %name (wxDragImage) class wxGenericDragImage
463 wxGenericDragImage(const wxBitmap& image,
464 const wxCursor& cursor = wxNullCursor,
465 const wxPoint& hotspot = wxPyNullPoint);
466 ~wxGenericDragImage();
468 bool BeginDrag(const wxPoint& hotspot, wxWindow* window,
469 bool fullScreen = FALSE, wxRect* rect = NULL);
471 %name(BeginDrag2) bool BeginDrag(const wxPoint& hotspot, wxWindow* window,
472 wxWindow* fullScreenRect);
475 bool Move(const wxPoint& pt);
479 wxRect GetImageRect(const wxPoint& pos) const;
480 bool RedrawImage(const wxPoint& oldPos, const wxPoint& newPos,
481 bool eraseOld, bool drawNew);
485 // Alternate Constructors
486 %new wxGenericDragImage* wxDragIcon(const wxIcon& image,
487 const wxCursor& cursor = wxNullCursor,
488 const wxPoint& hotspot = wxPyNullPoint);
490 %new wxGenericDragImage* wxDragString(const wxString& str,
491 const wxCursor& cursor = wxNullCursor,
492 const wxPoint& hotspot = wxPyNullPoint);
494 %new wxGenericDragImage* wxDragTreeItem(const wxTreeCtrl& treeCtrl, wxTreeItemId& id);
496 %new wxGenericDragImage* wxDragListItem(const wxListCtrl& listCtrl, long id);
501 wxGenericDragImage* wxDragIcon(const wxIcon& image,
502 const wxCursor& cursor,
503 const wxPoint& hotspot) {
504 return new wxGenericDragImage(image, cursor, hotspot);
507 wxGenericDragImage* wxDragString(const wxString& str,
508 const wxCursor& cursor,
509 const wxPoint& hotspot) {
510 return new wxGenericDragImage(str, cursor, hotspot);
513 wxGenericDragImage* wxDragTreeItem(const wxTreeCtrl& treeCtrl, wxTreeItemId& id) {
514 return new wxGenericDragImage(treeCtrl, id);
517 wxGenericDragImage* wxDragListItem(const wxListCtrl& listCtrl, long id) {
518 return new wxGenericDragImage(listCtrl, id);
525 //----------------------------------------------------------------------
529 wxPyTimer(PyObject* notify);
534 void SetOwner(wxEvtHandler *owner, int id = -1);
535 void Start(int milliseconds=-1, int oneShot=FALSE);
539 //----------------------------------------------------------------------
540 //----------------------------------------------------------------------
545 wxLOG_FatalError, // program can't continue, abort immediately
546 wxLOG_Error, // a serious error, user must be informed about it
547 wxLOG_Warning, // user is normally informed about it but may be ignored
548 wxLOG_Message, // normal message (i.e. normal output of a non GUI app)
549 wxLOG_Info, // informational message (a.k.a. 'Verbose')
550 wxLOG_Status, // informational: might go to the status line of GUI app
551 wxLOG_Debug, // never shown to the user, disabled in release mode
552 wxLOG_Trace, // trace messages are also only enabled in debug mode
553 wxLOG_Progress, // used for progress indicator (not yet)
554 wxLOG_User = 100 // user defined levels start here
563 static bool IsEnabled();
564 static bool EnableLogging(bool doIt = TRUE);
565 static void OnLog(wxLogLevel level, const char *szString, int t=0);
567 virtual void Flush();
568 bool HasPendingMessages() const;
570 static void FlushActive();
571 static wxLog *GetActiveTarget();
572 static wxLog *SetActiveTarget(wxLog *pLogger);
574 static void Suspend();
575 static void Resume();
577 void SetVerbose(bool bVerbose = TRUE);
579 static void DontCreateOnDemand();
580 static void SetTraceMask(wxTraceMask ulMask);
581 static void AddTraceMask(const wxString& str);
582 static void RemoveTraceMask(const wxString& str);
584 bool GetVerbose() const { return m_bVerbose; }
586 static wxTraceMask GetTraceMask();
587 static bool IsAllowedTraceMask(const char *mask);
592 class wxLogStderr : public wxLog
595 wxLogStderr(/* TODO: FILE *fp = (FILE *) NULL*/);
599 class wxLogTextCtrl : public wxLog
602 wxLogTextCtrl(wxTextCtrl *pTextCtrl);
606 class wxLogGui : public wxLog
612 class wxLogWindow : public wxLog
615 wxLogWindow(wxFrame *pParent, // the parent frame (can be NULL)
616 const char *szTitle, // the title of the frame
617 bool bShow = TRUE, // show window immediately?
618 bool bPassToOld = TRUE); // pass log messages to the old target?
620 void Show(bool bShow = TRUE);
621 wxFrame *GetFrame() const;
622 wxLog *GetOldLog() const;
623 bool IsPassingMessages() const;
624 void PassMessages(bool bDoPass) { m_bPassMessages = bDoPass; }
636 unsigned long wxSysErrorCode();
637 const char* wxSysErrorMsg(unsigned long nErrCode = 0);
638 void wxLogFatalError(const char *szFormat);
639 void wxLogError(const char *szFormat);
640 void wxLogWarning(const char *szFormat);
641 void wxLogMessage(const char *szFormat);
642 void wxLogInfo(const char *szFormat);
643 void wxLogVerbose(const char *szFormat);
644 void wxLogStatus(const char *szFormat);
645 %name(wxLogStatusFrame)void wxLogStatus(wxFrame *pFrame, const char *szFormat);
646 void wxLogSysError(const char *szFormat);
650 //----------------------------------------------------------------------
659 class wxProcessEvent : public wxEvent {
661 wxProcessEvent(int id = 0, int pid = 0, int exitcode = 0);
664 int m_pid, m_exitcode;
670 %{ // C++ version of wxProcess derived class
672 class wxPyProcess : public wxProcess {
674 wxPyProcess(wxEvtHandler *parent = NULL, int id = -1)
675 : wxProcess(parent, id)
678 DEC_PYCALLBACK_VOID_INTINT(OnTerminate);
683 IMP_PYCALLBACK_VOID_INTINT( wxPyProcess, wxProcess, OnTerminate);
687 %name(wxProcess)class wxPyProcess : public wxEvtHandler {
689 wxPyProcess(wxEvtHandler *parent = NULL, int id = -1);
690 %addmethods { void Destroy() { delete self; } }
692 void _setSelf(PyObject* self, PyObject* _class);
693 %pragma(python) addtomethod = "__init__:self._setSelf(self, wxProcess)"
695 void base_OnTerminate(int pid, int status);
701 wxInputStream *GetInputStream();
702 wxInputStream *GetErrorStream();
703 wxOutputStream *GetOutputStream();
710 long wxExecute(const wxString& command,
712 wxPyProcess *process = NULL);
714 //----------------------------------------------------------------------
719 wxJoystick(int joystick = wxJOYSTICK1);
720 wxPoint GetPosition();
722 int GetButtonState();
723 int GetPOVPosition();
724 int GetPOVCTSPosition();
725 int GetRudderPosition();
728 int GetMovementThreshold();
729 void SetMovementThreshold(int threshold) ;
732 int GetNumberJoysticks();
733 int GetManufacturerId();
735 wxString GetProductName();
742 int GetNumberButtons();
763 bool SetCapture(wxWindow* win, int pollingFreq = 0);
764 bool ReleaseCapture();
768 //----------------------------------------------------------------------
769 //----------------------------------------------------------------------