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.
41 //---------------------------------------------------------------------------
44 wxString wxFileSelector(char* message,
45 char* default_path = NULL,
46 char* default_filename = NULL,
47 char* default_extension = NULL,
48 char* wildcard = "*.*",
50 wxWindow *parent = NULL,
51 int x = -1, int y = -1);
53 wxString wxGetTextFromUser(const wxString& message,
54 const wxString& caption = wxPyEmptyStr,
55 const wxString& default_value = wxPyEmptyStr,
56 wxWindow *parent = NULL,
57 int x = -1, int y = -1,
61 // TODO: Need to custom wrap this one...
62 // int wxGetMultipleChoice(char* message, char* caption,
63 // int LCOUNT, char** choices,
64 // int nsel, int *selection,
65 // wxWindow *parent = NULL, int x = -1, int y = -1,
66 // bool centre = TRUE, int width=150, int height=200);
69 wxString wxGetSingleChoice(const wxString& message, const wxString& caption,
70 int LCOUNT, wxString* choices,
71 wxWindow *parent = NULL,
72 int x = -1, int y = -1,
74 int width=150, int height=200);
76 int wxGetSingleChoiceIndex(const wxString& message, const wxString& caption,
77 int LCOUNT, wxString* choices,
78 wxWindow *parent = NULL,
79 int x = -1, int y = -1,
81 int width=150, int height=200);
84 int wxMessageBox(const wxString& message,
85 const wxString& caption = wxPyEmptyStr,
86 int style = wxOK | wxCENTRE,
87 wxWindow *parent = NULL,
88 int x = -1, int y = -1);
90 long wxGetNumberFromUser(const wxString& message,
91 const wxString& prompt,
92 const wxString& caption,
94 long min = 0, long max = 100,
95 wxWindow *parent = NULL,
96 const wxPoint& pos = wxPyDefaultPosition);
98 //---------------------------------------------------------------------------
101 bool wxColourDisplay();
102 int wxDisplayDepth();
103 void wxSetCursor(wxCursor& cursor);
105 //----------------------------------------------------------------------
106 // Miscellaneous functions
108 wxWindow * wxFindWindowByLabel(const wxString& label, wxWindow *parent=NULL);
109 wxWindow * wxFindWindowByName(const wxString& name, wxWindow *parent=NULL);
111 void wxBeginBusyCursor(wxCursor *cursor = wxHOURGLASS_CURSOR);
112 wxWindow * wxGetActiveWindow();
115 //---------------------------------------------------------------------------
118 bool wxResourceAddIdentifier(char *name, int value);
119 void wxResourceClear(void);
120 wxBitmap wxResourceCreateBitmap(char *resource);
121 wxIcon wxResourceCreateIcon(char *resource);
122 wxMenuBar * wxResourceCreateMenuBar(char *resource);
123 int wxResourceGetIdentifier(char *name);
124 bool wxResourceParseData(char *resource, wxResourceTable *table = NULL);
125 bool wxResourceParseFile(char *filename, wxResourceTable *table = NULL);
126 bool wxResourceParseString(char *resource, wxResourceTable *table = NULL);
128 //---------------------------------------------------------------------------
142 wxSYS_OEM_FIXED_FONT,
143 wxSYS_ANSI_FIXED_FONT,
146 wxSYS_DEVICE_DEFAULT_FONT,
147 wxSYS_DEFAULT_PALETTE,
148 wxSYS_SYSTEM_FIXED_FONT,
149 wxSYS_DEFAULT_GUI_FONT,
151 wxSYS_COLOUR_SCROLLBAR,
152 wxSYS_COLOUR_BACKGROUND,
153 wxSYS_COLOUR_ACTIVECAPTION,
154 wxSYS_COLOUR_INACTIVECAPTION,
157 wxSYS_COLOUR_WINDOWFRAME,
158 wxSYS_COLOUR_MENUTEXT,
159 wxSYS_COLOUR_WINDOWTEXT,
160 wxSYS_COLOUR_CAPTIONTEXT,
161 wxSYS_COLOUR_ACTIVEBORDER,
162 wxSYS_COLOUR_INACTIVEBORDER,
163 wxSYS_COLOUR_APPWORKSPACE,
164 wxSYS_COLOUR_HIGHLIGHT,
165 wxSYS_COLOUR_HIGHLIGHTTEXT,
166 wxSYS_COLOUR_BTNFACE,
167 wxSYS_COLOUR_BTNSHADOW,
168 wxSYS_COLOUR_GRAYTEXT,
169 wxSYS_COLOUR_BTNTEXT,
170 wxSYS_COLOUR_INACTIVECAPTIONTEXT,
171 wxSYS_COLOUR_BTNHIGHLIGHT,
173 wxSYS_COLOUR_3DDKSHADOW,
174 wxSYS_COLOUR_3DLIGHT,
175 wxSYS_COLOUR_INFOTEXT,
178 wxSYS_COLOUR_DESKTOP,
180 wxSYS_COLOUR_3DSHADOW,
181 wxSYS_COLOUR_3DHIGHLIGHT,
182 wxSYS_COLOUR_3DHILIGHT,
183 wxSYS_COLOUR_BTNHILIGHT,
196 wxSYS_HSCROLL_ARROW_X,
197 wxSYS_HSCROLL_ARROW_Y,
213 wxSYS_VSCROLL_ARROW_X,
214 wxSYS_VSCROLL_ARROW_Y,
218 wxSYS_NETWORK_PRESENT,
219 wxSYS_PENWINDOWS_PRESENT,
228 wxColour wxSystemSettings_GetSystemColour(int index) {
229 return wxSystemSettings::GetSystemColour(index);
232 wxFont wxSystemSettings_GetSystemFont(int index) {
233 return wxSystemSettings::GetSystemFont(index);
236 int wxSystemSettings_GetSystemMetric(int index) {
237 return wxSystemSettings::GetSystemMetric(index);
241 //---------------------------------------------------------------------------
246 wxToolTip(const wxString &tip);
248 void SetTip(const wxString& tip);
250 // *** Not in the "public" interface void SetWindow(wxWindow *win);
251 wxWindow *GetWindow();
256 void wxToolTip_Enable(bool flag) {
257 wxToolTip::Enable(flag);
260 void wxToolTip_SetDelay(long milliseconds) {
261 wxToolTip::SetDelay(milliseconds);
265 //----------------------------------------------------------------------
269 wxCaret(wxWindow* window, const wxSize& size);
274 %name(GetPositionTuple)void GetPosition(int *OUTPUT, int *OUTPUT);
275 wxPoint GetPosition();
276 %name(GetSizeTuple)void GetSize(int *OUTPUT, int *OUTPUT);
278 wxWindow *GetWindow();
279 %name(MoveXY)void Move(int x, int y);
280 void Move(const wxPoint& pt);
281 %name(SetSizeWH) void SetSize(int width, int height);
282 void SetSize(const wxSize& size);
283 void Show(int show = TRUE);
288 int wxCaret_GetBlinkTime() {
289 return wxCaret::GetBlinkTime();
292 void wxCaret_SetBlinkTime(int milliseconds) {
293 wxCaret::SetBlinkTime(milliseconds);
297 //----------------------------------------------------------------------
300 class wxPyFontEnumerator : public wxFontEnumerator {
302 wxPyFontEnumerator() {}
303 ~wxPyFontEnumerator() {}
305 DEC_PYCALLBACK_BOOL_STRING(OnFacename);
306 DEC_PYCALLBACK_BOOL_STRINGSTRING(OnFontEncoding);
311 IMP_PYCALLBACK_BOOL_STRING(wxPyFontEnumerator, wxFontEnumerator, OnFacename);
312 IMP_PYCALLBACK_BOOL_STRINGSTRING(wxPyFontEnumerator, wxFontEnumerator, OnFontEncoding);
316 %name(wxFontEnumerator) class wxPyFontEnumerator {
318 wxPyFontEnumerator();
319 ~wxPyFontEnumerator();
320 void _setSelf(PyObject* self, PyObject* _class);
321 %pragma(python) addtomethod = "__init__:self._setSelf(self, wxFontEnumerator)"
323 bool EnumerateFacenames(
324 wxFontEncoding encoding = wxFONTENCODING_SYSTEM, // all
325 bool fixedWidthOnly = FALSE);
326 bool EnumerateEncodings(const char* facename = "");
328 //wxArrayString* GetEncodings();
329 //wxArrayString* GetFacenames();
331 PyObject* GetEncodings() {
332 wxArrayString* arr = self->GetEncodings();
333 PyObject* list = PyList_New(0);
334 for (size_t x=0; x<arr->GetCount(); x++)
335 PyList_Append(list, PyString_FromString((*arr)[x]));
339 PyObject* GetFacenames() {
340 wxArrayString* arr = self->GetFacenames();
341 PyObject* list = PyList_New(0);
342 for (size_t x=0; x<arr->GetCount(); x++)
343 PyList_Append(list, PyString_FromString((*arr)[x]));
349 //----------------------------------------------------------------------
353 wxBusyCursor(wxCursor* cursor = wxHOURGLASS_CURSOR);
357 //----------------------------------------------------------------------
359 class wxWindowDisabler {
361 wxWindowDisabler(wxWindow *winToSkip = NULL);
365 //----------------------------------------------------------------------
367 void wxPostEvent(wxEvtHandler *dest, wxEvent& event);
370 bool wxSafeYield(wxWindow* win=NULL);
372 //----------------------------------------------------------------------
378 // wxTipProvider(size_t currentTip); **** Abstract base class
381 virtual wxString GetTip() = 0;
382 size_t GetCurrentTip();
387 // The C++ version of wxPyTipProvider
389 class wxPyTipProvider : public wxTipProvider {
391 wxPyTipProvider(size_t currentTip)
392 : wxTipProvider(currentTip) {}
394 DEC_PYCALLBACK_STRING__pure(GetTip);
399 IMP_PYCALLBACK_STRING__pure( wxPyTipProvider, wxTipProvider, GetTip);
404 // Now let SWIG know about it
405 class wxPyTipProvider : public wxTipProvider {
407 wxPyTipProvider(size_t currentTip);
412 bool wxShowTip(wxWindow *parent, wxTipProvider *tipProvider, bool showAtStartup = TRUE);
413 %new wxTipProvider * wxCreateFileTipProvider(const wxString& filename, size_t currentTip);
416 //----------------------------------------------------------------------
419 #include <wx/generic/dragimgg.h>
420 static wxPoint wxPyNullPoint;
423 %name (wxDragImage) class wxGenericDragImage
427 wxGenericDragImage(const wxBitmap& image,
428 const wxCursor& cursor = wxNullCursor,
429 const wxPoint& hotspot = wxPyNullPoint);
430 ~wxGenericDragImage();
432 bool BeginDrag(const wxPoint& hotspot, wxWindow* window,
433 bool fullScreen = FALSE, wxRect* rect = NULL);
435 %name(BeginDrag2) bool BeginDrag(const wxPoint& hotspot, wxWindow* window,
436 wxWindow* fullScreenRect);
439 bool Move(const wxPoint& pt);
443 wxRect GetImageRect(const wxPoint& pos) const;
444 bool RedrawImage(const wxPoint& oldPos, const wxPoint& newPos,
445 bool eraseOld, bool drawNew);
449 // Alternate Constructors
450 %new wxGenericDragImage* wxDragIcon(const wxIcon& image,
451 const wxCursor& cursor = wxNullCursor,
452 const wxPoint& hotspot = wxPyNullPoint);
454 %new wxGenericDragImage* wxDragString(const wxString& str,
455 const wxCursor& cursor = wxNullCursor,
456 const wxPoint& hotspot = wxPyNullPoint);
458 %new wxGenericDragImage* wxDragTreeItem(const wxTreeCtrl& treeCtrl, wxTreeItemId& id);
460 %new wxGenericDragImage* wxDragListItem(const wxListCtrl& listCtrl, long id);
465 wxGenericDragImage* wxDragIcon(const wxIcon& image,
466 const wxCursor& cursor,
467 const wxPoint& hotspot) {
468 return new wxGenericDragImage(image, cursor, hotspot);
471 wxGenericDragImage* wxDragString(const wxString& str,
472 const wxCursor& cursor,
473 const wxPoint& hotspot) {
474 return new wxGenericDragImage(str, cursor, hotspot);
477 wxGenericDragImage* wxDragTreeItem(const wxTreeCtrl& treeCtrl, wxTreeItemId& id) {
478 return new wxGenericDragImage(treeCtrl, id);
481 wxGenericDragImage* wxDragListItem(const wxListCtrl& listCtrl, long id) {
482 return new wxGenericDragImage(listCtrl, id);
489 //----------------------------------------------------------------------
493 wxPyTimer(PyObject* notify);
498 void SetOwner(wxEvtHandler *owner, int id = -1);
499 void Start(int milliseconds=-1, int oneShot=FALSE);
503 //----------------------------------------------------------------------
504 //----------------------------------------------------------------------
509 wxLOG_FatalError, // program can't continue, abort immediately
510 wxLOG_Error, // a serious error, user must be informed about it
511 wxLOG_Warning, // user is normally informed about it but may be ignored
512 wxLOG_Message, // normal message (i.e. normal output of a non GUI app)
513 wxLOG_Info, // informational message (a.k.a. 'Verbose')
514 wxLOG_Status, // informational: might go to the status line of GUI app
515 wxLOG_Debug, // never shown to the user, disabled in release mode
516 wxLOG_Trace, // trace messages are also only enabled in debug mode
517 wxLOG_Progress, // used for progress indicator (not yet)
518 wxLOG_User = 100 // user defined levels start here
527 static bool IsEnabled();
528 static bool EnableLogging(bool doIt = TRUE);
529 static void OnLog(wxLogLevel level, const char *szString, int t=0);
531 virtual void Flush();
532 bool HasPendingMessages() const;
534 static void FlushActive();
535 static wxLog *GetActiveTarget();
536 static wxLog *SetActiveTarget(wxLog *pLogger);
538 static void Suspend();
539 static void Resume();
541 void SetVerbose(bool bVerbose = TRUE);
543 static void DontCreateOnDemand();
544 static void SetTraceMask(wxTraceMask ulMask);
545 static void AddTraceMask(const wxString& str);
546 static void RemoveTraceMask(const wxString& str);
548 bool GetVerbose() const { return m_bVerbose; }
550 static wxTraceMask GetTraceMask();
551 static bool IsAllowedTraceMask(const char *mask);
556 class wxLogStderr : public wxLog
559 wxLogStderr(/* TODO: FILE *fp = (FILE *) NULL*/);
563 class wxLogTextCtrl : public wxLog
566 wxLogTextCtrl(wxTextCtrl *pTextCtrl);
570 class wxLogGui : public wxLog
576 class wxLogWindow : public wxLog
579 wxLogWindow(wxFrame *pParent, // the parent frame (can be NULL)
580 const char *szTitle, // the title of the frame
581 bool bShow = TRUE, // show window immediately?
582 bool bPassToOld = TRUE); // pass log messages to the old target?
584 void Show(bool bShow = TRUE);
585 wxFrame *GetFrame() const;
586 wxLog *GetOldLog() const;
587 bool IsPassingMessages() const;
588 void PassMessages(bool bDoPass) { m_bPassMessages = bDoPass; }
600 unsigned long wxSysErrorCode();
601 const char* wxSysErrorMsg(unsigned long nErrCode = 0);
602 void wxLogFatalError(const char *szFormat);
603 void wxLogError(const char *szFormat);
604 void wxLogWarning(const char *szFormat);
605 void wxLogMessage(const char *szFormat);
606 void wxLogInfo(const char *szFormat);
607 void wxLogVerbose(const char *szFormat);
608 void wxLogStatus(const char *szFormat);
609 %name(wxLogStatusFrame)void wxLogStatus(wxFrame *pFrame, const char *szFormat);
610 void wxLogSysError(const char *szFormat);
614 //----------------------------------------------------------------------
616 class wxProcessEvent : public wxEvent {
618 wxProcessEvent(int id = 0, int pid = 0, int exitcode = 0);
621 int m_pid, m_exitcode;
627 %{ // C++ version of wxProcess derived class
629 class wxPyProcess : public wxProcess {
631 wxPyProcess(wxEvtHandler *parent = NULL, int id = -1)
632 : wxProcess(parent, id)
635 DEC_PYCALLBACK_VOID_INTINT(OnTerminate);
640 IMP_PYCALLBACK_VOID_INTINT( wxPyProcess, wxProcess, OnTerminate);
644 %name(wxProcess)class wxPyProcess : public wxEvtHandler {
646 wxPyProcess(wxEvtHandler *parent = NULL, int id = -1);
647 %addmethods { void Destroy() { delete self; } }
649 void _setSelf(PyObject* self, PyObject* _class);
650 %pragma(python) addtomethod = "__init__:self._setSelf(self, wxProcess)"
652 void base_OnTerminate(int pid, int status);
658 wxInputStream *GetInputStream();
659 wxInputStream *GetErrorStream();
660 wxOutputStream *GetOutputStream();
667 long wxExecute(const wxString& command,
669 wxPyProcess *process = NULL);
671 //----------------------------------------------------------------------
676 wxJoystick(int joystick = wxJOYSTICK1);
677 wxPoint GetPosition();
679 int GetButtonState();
680 int GetPOVPosition();
681 int GetPOVCTSPosition();
682 int GetRudderPosition();
685 int GetMovementThreshold();
686 void SetMovementThreshold(int threshold) ;
689 int GetNumberJoysticks();
690 int GetManufacturerId();
692 wxString GetProductName();
699 int GetNumberButtons();
720 bool SetCapture(wxWindow* win, int pollingFreq = 0);
721 bool ReleaseCapture();
725 //----------------------------------------------------------------------
726 //----------------------------------------------------------------------