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 #include <wx/joystick.h>
30 //----------------------------------------------------------------------
33 %include my_typemaps.i
35 // Import some definitions of other classes, etc.
44 static wxString wxPyEmptyStr("");
47 //---------------------------------------------------------------------------
50 wxString wxFileSelector(char* message,
51 char* default_path = NULL,
52 char* default_filename = NULL,
53 char* default_extension = NULL,
54 char* wildcard = "*.*",
56 wxWindow *parent = NULL,
57 int x = -1, int y = -1);
59 wxString wxGetTextFromUser(const wxString& message,
60 const wxString& caption = wxPyEmptyStr,
61 const wxString& default_value = wxPyEmptyStr,
62 wxWindow *parent = NULL,
63 int x = -1, int y = -1,
66 wxString wxGetPasswordFromUser(const wxString& message,
67 const wxString& caption = wxPyEmptyStr,
68 const wxString& default_value = wxPyEmptyStr,
69 wxWindow *parent = NULL);
72 // TODO: Need to custom wrap this one...
73 // int wxGetMultipleChoice(char* message, char* caption,
74 // int LCOUNT, char** choices,
75 // int nsel, int *selection,
76 // wxWindow *parent = NULL, int x = -1, int y = -1,
77 // bool centre = TRUE, int width=150, int height=200);
80 wxString wxGetSingleChoice(const wxString& message, const wxString& caption,
81 int LCOUNT, wxString* choices,
82 wxWindow *parent = NULL,
83 int x = -1, int y = -1,
85 int width=150, int height=200);
87 int wxGetSingleChoiceIndex(const wxString& message, const wxString& caption,
88 int LCOUNT, wxString* choices,
89 wxWindow *parent = NULL,
90 int x = -1, int y = -1,
92 int width=150, int height=200);
95 int wxMessageBox(const wxString& message,
96 const wxString& caption = wxPyEmptyStr,
97 int style = wxOK | wxCENTRE,
98 wxWindow *parent = NULL,
99 int x = -1, int y = -1);
101 long wxGetNumberFromUser(const wxString& message,
102 const wxString& prompt,
103 const wxString& caption,
105 long min = 0, long max = 100,
106 wxWindow *parent = NULL,
107 const wxPoint& pos = wxDefaultPosition);
109 //---------------------------------------------------------------------------
112 bool wxColourDisplay();
114 int wxDisplayDepth();
115 int wxGetDisplayDepth();
117 void wxDisplaySize(int* OUTPUT, int* OUTPUT);
118 wxSize wxGetDisplaySize();
120 void wxDisplaySizeMM(int* OUTPUT, int* OUTPUT);
121 wxSize wxGetDisplaySizeMM();
123 void wxSetCursor(wxCursor& cursor);
125 //----------------------------------------------------------------------
126 // Miscellaneous functions
128 wxWindow * wxFindWindowByLabel(const wxString& label, wxWindow *parent=NULL);
129 wxWindow * wxFindWindowByName(const wxString& name, wxWindow *parent=NULL);
131 void wxBeginBusyCursor(wxCursor *cursor = wxHOURGLASS_CURSOR);
132 wxWindow * wxGetActiveWindow();
135 //---------------------------------------------------------------------------
138 bool wxResourceAddIdentifier(char *name, int value);
139 void wxResourceClear(void);
140 wxBitmap wxResourceCreateBitmap(char *resource);
141 wxIcon wxResourceCreateIcon(char *resource);
142 wxMenuBar * wxResourceCreateMenuBar(char *resource);
143 int wxResourceGetIdentifier(char *name);
144 bool wxResourceParseData(char *resource, wxResourceTable *table = NULL);
145 bool wxResourceParseFile(char *filename, wxResourceTable *table = NULL);
146 bool wxResourceParseString(char *resource, wxResourceTable *table = NULL);
148 //---------------------------------------------------------------------------
162 wxSYS_OEM_FIXED_FONT,
163 wxSYS_ANSI_FIXED_FONT,
166 wxSYS_DEVICE_DEFAULT_FONT,
167 wxSYS_DEFAULT_PALETTE,
168 wxSYS_SYSTEM_FIXED_FONT,
169 wxSYS_DEFAULT_GUI_FONT,
171 wxSYS_COLOUR_SCROLLBAR,
172 wxSYS_COLOUR_BACKGROUND,
173 wxSYS_COLOUR_ACTIVECAPTION,
174 wxSYS_COLOUR_INACTIVECAPTION,
177 wxSYS_COLOUR_WINDOWFRAME,
178 wxSYS_COLOUR_MENUTEXT,
179 wxSYS_COLOUR_WINDOWTEXT,
180 wxSYS_COLOUR_CAPTIONTEXT,
181 wxSYS_COLOUR_ACTIVEBORDER,
182 wxSYS_COLOUR_INACTIVEBORDER,
183 wxSYS_COLOUR_APPWORKSPACE,
184 wxSYS_COLOUR_HIGHLIGHT,
185 wxSYS_COLOUR_HIGHLIGHTTEXT,
186 wxSYS_COLOUR_BTNFACE,
187 wxSYS_COLOUR_BTNSHADOW,
188 wxSYS_COLOUR_GRAYTEXT,
189 wxSYS_COLOUR_BTNTEXT,
190 wxSYS_COLOUR_INACTIVECAPTIONTEXT,
191 wxSYS_COLOUR_BTNHIGHLIGHT,
193 wxSYS_COLOUR_3DDKSHADOW,
194 wxSYS_COLOUR_3DLIGHT,
195 wxSYS_COLOUR_INFOTEXT,
198 wxSYS_COLOUR_DESKTOP,
200 wxSYS_COLOUR_3DSHADOW,
201 wxSYS_COLOUR_3DHIGHLIGHT,
202 wxSYS_COLOUR_3DHILIGHT,
203 wxSYS_COLOUR_BTNHILIGHT,
216 wxSYS_HSCROLL_ARROW_X,
217 wxSYS_HSCROLL_ARROW_Y,
233 wxSYS_VSCROLL_ARROW_X,
234 wxSYS_VSCROLL_ARROW_Y,
238 wxSYS_NETWORK_PRESENT,
239 wxSYS_PENWINDOWS_PRESENT,
248 wxColour wxSystemSettings_GetSystemColour(int index) {
249 return wxSystemSettings::GetSystemColour(index);
252 wxFont wxSystemSettings_GetSystemFont(int index) {
253 return wxSystemSettings::GetSystemFont(index);
256 int wxSystemSettings_GetSystemMetric(int index) {
257 return wxSystemSettings::GetSystemMetric(index);
261 //---------------------------------------------------------------------------
266 wxToolTip(const wxString &tip);
268 void SetTip(const wxString& tip);
270 // *** Not in the "public" interface void SetWindow(wxWindow *win);
271 wxWindow *GetWindow();
276 void wxToolTip_Enable(bool flag) {
277 wxToolTip::Enable(flag);
280 void wxToolTip_SetDelay(long milliseconds) {
281 wxToolTip::SetDelay(milliseconds);
285 //----------------------------------------------------------------------
289 wxCaret(wxWindow* window, const wxSize& size);
294 %name(GetPositionTuple)void GetPosition(int *OUTPUT, int *OUTPUT);
295 wxPoint GetPosition();
296 %name(GetSizeTuple)void GetSize(int *OUTPUT, int *OUTPUT);
298 wxWindow *GetWindow();
299 %name(MoveXY)void Move(int x, int y);
300 void Move(const wxPoint& pt);
301 %name(SetSizeWH) void SetSize(int width, int height);
302 void SetSize(const wxSize& size);
303 void Show(int show = TRUE);
308 int wxCaret_GetBlinkTime() {
309 return wxCaret::GetBlinkTime();
312 void wxCaret_SetBlinkTime(int milliseconds) {
313 wxCaret::SetBlinkTime(milliseconds);
317 //----------------------------------------------------------------------
320 class wxPyFontEnumerator : public wxFontEnumerator {
322 wxPyFontEnumerator() {}
323 ~wxPyFontEnumerator() {}
325 DEC_PYCALLBACK_BOOL_STRING(OnFacename);
326 DEC_PYCALLBACK_BOOL_STRINGSTRING(OnFontEncoding);
331 IMP_PYCALLBACK_BOOL_STRING(wxPyFontEnumerator, wxFontEnumerator, OnFacename);
332 IMP_PYCALLBACK_BOOL_STRINGSTRING(wxPyFontEnumerator, wxFontEnumerator, OnFontEncoding);
336 %name(wxFontEnumerator) class wxPyFontEnumerator {
338 wxPyFontEnumerator();
339 ~wxPyFontEnumerator();
340 void _setSelf(PyObject* self, PyObject* _class);
341 %pragma(python) addtomethod = "__init__:self._setSelf(self, wxFontEnumerator)"
343 bool EnumerateFacenames(
344 wxFontEncoding encoding = wxFONTENCODING_SYSTEM, // all
345 bool fixedWidthOnly = FALSE);
346 bool EnumerateEncodings(const char* facename = "");
348 //wxArrayString* GetEncodings();
349 //wxArrayString* GetFacenames();
351 PyObject* GetEncodings() {
352 wxArrayString* arr = self->GetEncodings();
353 PyObject* list = PyList_New(0);
354 for (size_t x=0; x<arr->GetCount(); x++)
355 PyList_Append(list, PyString_FromString((*arr)[x]));
359 PyObject* GetFacenames() {
360 wxArrayString* arr = self->GetFacenames();
361 PyObject* list = PyList_New(0);
362 for (size_t x=0; x<arr->GetCount(); x++)
363 PyList_Append(list, PyString_FromString((*arr)[x]));
369 //----------------------------------------------------------------------
373 wxBusyCursor(wxCursor* cursor = wxHOURGLASS_CURSOR);
377 //----------------------------------------------------------------------
379 class wxWindowDisabler {
381 wxWindowDisabler(wxWindow *winToSkip = NULL);
385 //----------------------------------------------------------------------
387 bool wxSafeYield(wxWindow* win=NULL);
388 void wxPostEvent(wxEvtHandler *dest, wxEvent& event);
393 void wxWakeUpMainThread();
396 void wxMutexGuiEnter();
397 void wxMutexGuiLeave();
400 class wxMutexGuiLocker {
408 bool wxThread_IsMain() {
409 return wxThread::IsMain();
413 //----------------------------------------------------------------------
419 // wxTipProvider(size_t currentTip); **** Abstract base class
422 virtual wxString GetTip() = 0;
423 size_t GetCurrentTip();
428 // The C++ version of wxPyTipProvider
430 class wxPyTipProvider : public wxTipProvider {
432 wxPyTipProvider(size_t currentTip)
433 : wxTipProvider(currentTip) {}
435 DEC_PYCALLBACK_STRING__pure(GetTip);
440 IMP_PYCALLBACK_STRING__pure( wxPyTipProvider, wxTipProvider, GetTip);
445 // Now let SWIG know about it
446 class wxPyTipProvider : public wxTipProvider {
448 wxPyTipProvider(size_t currentTip);
453 bool wxShowTip(wxWindow *parent, wxTipProvider *tipProvider, bool showAtStartup = TRUE);
454 %new wxTipProvider * wxCreateFileTipProvider(const wxString& filename, size_t currentTip);
457 //----------------------------------------------------------------------
460 #include <wx/generic/dragimgg.h>
461 static wxPoint wxPyNullPoint;
464 %name (wxDragImage) class wxGenericDragImage
468 wxGenericDragImage(const wxBitmap& image,
469 const wxCursor& cursor = wxNullCursor,
470 const wxPoint& hotspot = wxPyNullPoint);
471 ~wxGenericDragImage();
473 bool BeginDrag(const wxPoint& hotspot, wxWindow* window,
474 bool fullScreen = FALSE, wxRect* rect = NULL);
476 %name(BeginDrag2) bool BeginDrag(const wxPoint& hotspot, wxWindow* window,
477 wxWindow* fullScreenRect);
480 bool Move(const wxPoint& pt);
484 wxRect GetImageRect(const wxPoint& pos) const;
485 bool RedrawImage(const wxPoint& oldPos, const wxPoint& newPos,
486 bool eraseOld, bool drawNew);
490 // Alternate Constructors
491 %new wxGenericDragImage* wxDragIcon(const wxIcon& image,
492 const wxCursor& cursor = wxNullCursor,
493 const wxPoint& hotspot = wxPyNullPoint);
495 %new wxGenericDragImage* wxDragString(const wxString& str,
496 const wxCursor& cursor = wxNullCursor,
497 const wxPoint& hotspot = wxPyNullPoint);
499 %new wxGenericDragImage* wxDragTreeItem(const wxTreeCtrl& treeCtrl, wxTreeItemId& id);
501 %new wxGenericDragImage* wxDragListItem(const wxListCtrl& listCtrl, long id);
506 wxGenericDragImage* wxDragIcon(const wxIcon& image,
507 const wxCursor& cursor,
508 const wxPoint& hotspot) {
509 return new wxGenericDragImage(image, cursor, hotspot);
512 wxGenericDragImage* wxDragString(const wxString& str,
513 const wxCursor& cursor,
514 const wxPoint& hotspot) {
515 return new wxGenericDragImage(str, cursor, hotspot);
518 wxGenericDragImage* wxDragTreeItem(const wxTreeCtrl& treeCtrl, wxTreeItemId& id) {
519 return new wxGenericDragImage(treeCtrl, id);
522 wxGenericDragImage* wxDragListItem(const wxListCtrl& listCtrl, long id) {
523 return new wxGenericDragImage(listCtrl, id);
530 //----------------------------------------------------------------------
534 wxPyTimer(PyObject* notify);
539 void SetOwner(wxEvtHandler *owner, int id = -1);
540 void Start(int milliseconds=-1, int oneShot=FALSE);
544 //----------------------------------------------------------------------
545 //----------------------------------------------------------------------
550 wxLOG_FatalError, // program can't continue, abort immediately
551 wxLOG_Error, // a serious error, user must be informed about it
552 wxLOG_Warning, // user is normally informed about it but may be ignored
553 wxLOG_Message, // normal message (i.e. normal output of a non GUI app)
554 wxLOG_Info, // informational message (a.k.a. 'Verbose')
555 wxLOG_Status, // informational: might go to the status line of GUI app
556 wxLOG_Debug, // never shown to the user, disabled in release mode
557 wxLOG_Trace, // trace messages are also only enabled in debug mode
558 wxLOG_Progress, // used for progress indicator (not yet)
559 wxLOG_User = 100 // user defined levels start here
568 static bool IsEnabled();
569 static bool EnableLogging(bool doIt = TRUE);
570 static void OnLog(wxLogLevel level, const char *szString, int t=0);
572 virtual void Flush();
573 bool HasPendingMessages() const;
575 static void FlushActive();
576 static wxLog *GetActiveTarget();
577 static wxLog *SetActiveTarget(wxLog *pLogger);
579 static void Suspend();
580 static void Resume();
582 void SetVerbose(bool bVerbose = TRUE);
584 static void DontCreateOnDemand();
585 static void SetTraceMask(wxTraceMask ulMask);
586 static void AddTraceMask(const wxString& str);
587 static void RemoveTraceMask(const wxString& str);
589 bool GetVerbose() const { return m_bVerbose; }
591 static wxTraceMask GetTraceMask();
592 static bool IsAllowedTraceMask(const char *mask);
597 class wxLogStderr : public wxLog
600 wxLogStderr(/* TODO: FILE *fp = (FILE *) NULL*/);
604 class wxLogTextCtrl : public wxLog
607 wxLogTextCtrl(wxTextCtrl *pTextCtrl);
611 class wxLogGui : public wxLog
617 class wxLogWindow : public wxLog
620 wxLogWindow(wxFrame *pParent, // the parent frame (can be NULL)
621 const char *szTitle, // the title of the frame
622 bool bShow = TRUE, // show window immediately?
623 bool bPassToOld = TRUE); // pass log messages to the old target?
625 void Show(bool bShow = TRUE);
626 wxFrame *GetFrame() const;
627 wxLog *GetOldLog() const;
628 bool IsPassingMessages() const;
629 void PassMessages(bool bDoPass) { m_bPassMessages = bDoPass; }
641 unsigned long wxSysErrorCode();
642 const char* wxSysErrorMsg(unsigned long nErrCode = 0);
643 void wxLogFatalError(const char *szFormat);
644 void wxLogError(const char *szFormat);
645 void wxLogWarning(const char *szFormat);
646 void wxLogMessage(const char *szFormat);
647 void wxLogInfo(const char *szFormat);
648 void wxLogVerbose(const char *szFormat);
649 void wxLogStatus(const char *szFormat);
650 %name(wxLogStatusFrame)void wxLogStatus(wxFrame *pFrame, const char *szFormat);
651 void wxLogSysError(const char *szFormat);
655 //----------------------------------------------------------------------
664 class wxProcessEvent : public wxEvent {
666 wxProcessEvent(int id = 0, int pid = 0, int exitcode = 0);
669 int m_pid, m_exitcode;
675 %{ // C++ version of wxProcess derived class
677 class wxPyProcess : public wxProcess {
679 wxPyProcess(wxEvtHandler *parent = NULL, int id = -1)
680 : wxProcess(parent, id)
683 DEC_PYCALLBACK_VOID_INTINT(OnTerminate);
688 IMP_PYCALLBACK_VOID_INTINT( wxPyProcess, wxProcess, OnTerminate);
692 %name(wxProcess)class wxPyProcess : public wxEvtHandler {
694 wxPyProcess(wxEvtHandler *parent = NULL, int id = -1);
695 %addmethods { void Destroy() { delete self; } }
697 void _setSelf(PyObject* self, PyObject* _class);
698 %pragma(python) addtomethod = "__init__:self._setSelf(self, wxProcess)"
700 void base_OnTerminate(int pid, int status);
706 wxInputStream *GetInputStream();
707 wxInputStream *GetErrorStream();
708 wxOutputStream *GetOutputStream();
715 long wxExecute(const wxString& command,
717 wxPyProcess *process = NULL);
719 //----------------------------------------------------------------------
724 wxJoystick(int joystick = wxJOYSTICK1);
725 wxPoint GetPosition();
727 int GetButtonState();
728 int GetPOVPosition();
729 int GetPOVCTSPosition();
730 int GetRudderPosition();
733 int GetMovementThreshold();
734 void SetMovementThreshold(int threshold) ;
737 int GetNumberJoysticks();
738 int GetManufacturerId();
740 wxString GetProductName();
747 int GetNumberButtons();
768 bool SetCapture(wxWindow* win, int pollingFreq = 0);
769 bool ReleaseCapture();
773 //----------------------------------------------------------------------
774 //----------------------------------------------------------------------