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 void wxPostEvent(wxEvtHandler *dest, wxEvent& event);
388 bool wxSafeYield(wxWindow* win=NULL);
390 //----------------------------------------------------------------------
396 // wxTipProvider(size_t currentTip); **** Abstract base class
399 virtual wxString GetTip() = 0;
400 size_t GetCurrentTip();
405 // The C++ version of wxPyTipProvider
407 class wxPyTipProvider : public wxTipProvider {
409 wxPyTipProvider(size_t currentTip)
410 : wxTipProvider(currentTip) {}
412 DEC_PYCALLBACK_STRING__pure(GetTip);
417 IMP_PYCALLBACK_STRING__pure( wxPyTipProvider, wxTipProvider, GetTip);
422 // Now let SWIG know about it
423 class wxPyTipProvider : public wxTipProvider {
425 wxPyTipProvider(size_t currentTip);
430 bool wxShowTip(wxWindow *parent, wxTipProvider *tipProvider, bool showAtStartup = TRUE);
431 %new wxTipProvider * wxCreateFileTipProvider(const wxString& filename, size_t currentTip);
434 //----------------------------------------------------------------------
437 #include <wx/generic/dragimgg.h>
438 static wxPoint wxPyNullPoint;
441 %name (wxDragImage) class wxGenericDragImage
445 wxGenericDragImage(const wxBitmap& image,
446 const wxCursor& cursor = wxNullCursor,
447 const wxPoint& hotspot = wxPyNullPoint);
448 ~wxGenericDragImage();
450 bool BeginDrag(const wxPoint& hotspot, wxWindow* window,
451 bool fullScreen = FALSE, wxRect* rect = NULL);
453 %name(BeginDrag2) bool BeginDrag(const wxPoint& hotspot, wxWindow* window,
454 wxWindow* fullScreenRect);
457 bool Move(const wxPoint& pt);
461 wxRect GetImageRect(const wxPoint& pos) const;
462 bool RedrawImage(const wxPoint& oldPos, const wxPoint& newPos,
463 bool eraseOld, bool drawNew);
467 // Alternate Constructors
468 %new wxGenericDragImage* wxDragIcon(const wxIcon& image,
469 const wxCursor& cursor = wxNullCursor,
470 const wxPoint& hotspot = wxPyNullPoint);
472 %new wxGenericDragImage* wxDragString(const wxString& str,
473 const wxCursor& cursor = wxNullCursor,
474 const wxPoint& hotspot = wxPyNullPoint);
476 %new wxGenericDragImage* wxDragTreeItem(const wxTreeCtrl& treeCtrl, wxTreeItemId& id);
478 %new wxGenericDragImage* wxDragListItem(const wxListCtrl& listCtrl, long id);
483 wxGenericDragImage* wxDragIcon(const wxIcon& image,
484 const wxCursor& cursor,
485 const wxPoint& hotspot) {
486 return new wxGenericDragImage(image, cursor, hotspot);
489 wxGenericDragImage* wxDragString(const wxString& str,
490 const wxCursor& cursor,
491 const wxPoint& hotspot) {
492 return new wxGenericDragImage(str, cursor, hotspot);
495 wxGenericDragImage* wxDragTreeItem(const wxTreeCtrl& treeCtrl, wxTreeItemId& id) {
496 return new wxGenericDragImage(treeCtrl, id);
499 wxGenericDragImage* wxDragListItem(const wxListCtrl& listCtrl, long id) {
500 return new wxGenericDragImage(listCtrl, id);
507 //----------------------------------------------------------------------
511 wxPyTimer(PyObject* notify);
516 void SetOwner(wxEvtHandler *owner, int id = -1);
517 void Start(int milliseconds=-1, int oneShot=FALSE);
521 //----------------------------------------------------------------------
522 //----------------------------------------------------------------------
527 wxLOG_FatalError, // program can't continue, abort immediately
528 wxLOG_Error, // a serious error, user must be informed about it
529 wxLOG_Warning, // user is normally informed about it but may be ignored
530 wxLOG_Message, // normal message (i.e. normal output of a non GUI app)
531 wxLOG_Info, // informational message (a.k.a. 'Verbose')
532 wxLOG_Status, // informational: might go to the status line of GUI app
533 wxLOG_Debug, // never shown to the user, disabled in release mode
534 wxLOG_Trace, // trace messages are also only enabled in debug mode
535 wxLOG_Progress, // used for progress indicator (not yet)
536 wxLOG_User = 100 // user defined levels start here
545 static bool IsEnabled();
546 static bool EnableLogging(bool doIt = TRUE);
547 static void OnLog(wxLogLevel level, const char *szString, int t=0);
549 virtual void Flush();
550 bool HasPendingMessages() const;
552 static void FlushActive();
553 static wxLog *GetActiveTarget();
554 static wxLog *SetActiveTarget(wxLog *pLogger);
556 static void Suspend();
557 static void Resume();
559 void SetVerbose(bool bVerbose = TRUE);
561 static void DontCreateOnDemand();
562 static void SetTraceMask(wxTraceMask ulMask);
563 static void AddTraceMask(const wxString& str);
564 static void RemoveTraceMask(const wxString& str);
566 bool GetVerbose() const { return m_bVerbose; }
568 static wxTraceMask GetTraceMask();
569 static bool IsAllowedTraceMask(const char *mask);
574 class wxLogStderr : public wxLog
577 wxLogStderr(/* TODO: FILE *fp = (FILE *) NULL*/);
581 class wxLogTextCtrl : public wxLog
584 wxLogTextCtrl(wxTextCtrl *pTextCtrl);
588 class wxLogGui : public wxLog
594 class wxLogWindow : public wxLog
597 wxLogWindow(wxFrame *pParent, // the parent frame (can be NULL)
598 const char *szTitle, // the title of the frame
599 bool bShow = TRUE, // show window immediately?
600 bool bPassToOld = TRUE); // pass log messages to the old target?
602 void Show(bool bShow = TRUE);
603 wxFrame *GetFrame() const;
604 wxLog *GetOldLog() const;
605 bool IsPassingMessages() const;
606 void PassMessages(bool bDoPass) { m_bPassMessages = bDoPass; }
618 unsigned long wxSysErrorCode();
619 const char* wxSysErrorMsg(unsigned long nErrCode = 0);
620 void wxLogFatalError(const char *szFormat);
621 void wxLogError(const char *szFormat);
622 void wxLogWarning(const char *szFormat);
623 void wxLogMessage(const char *szFormat);
624 void wxLogInfo(const char *szFormat);
625 void wxLogVerbose(const char *szFormat);
626 void wxLogStatus(const char *szFormat);
627 %name(wxLogStatusFrame)void wxLogStatus(wxFrame *pFrame, const char *szFormat);
628 void wxLogSysError(const char *szFormat);
632 //----------------------------------------------------------------------
641 class wxProcessEvent : public wxEvent {
643 wxProcessEvent(int id = 0, int pid = 0, int exitcode = 0);
646 int m_pid, m_exitcode;
652 %{ // C++ version of wxProcess derived class
654 class wxPyProcess : public wxProcess {
656 wxPyProcess(wxEvtHandler *parent = NULL, int id = -1)
657 : wxProcess(parent, id)
660 DEC_PYCALLBACK_VOID_INTINT(OnTerminate);
665 IMP_PYCALLBACK_VOID_INTINT( wxPyProcess, wxProcess, OnTerminate);
669 %name(wxProcess)class wxPyProcess : public wxEvtHandler {
671 wxPyProcess(wxEvtHandler *parent = NULL, int id = -1);
672 %addmethods { void Destroy() { delete self; } }
674 void _setSelf(PyObject* self, PyObject* _class);
675 %pragma(python) addtomethod = "__init__:self._setSelf(self, wxProcess)"
677 void base_OnTerminate(int pid, int status);
683 wxInputStream *GetInputStream();
684 wxInputStream *GetErrorStream();
685 wxOutputStream *GetOutputStream();
692 long wxExecute(const wxString& command,
694 wxPyProcess *process = NULL);
696 //----------------------------------------------------------------------
701 wxJoystick(int joystick = wxJOYSTICK1);
702 wxPoint GetPosition();
704 int GetButtonState();
705 int GetPOVPosition();
706 int GetPOVCTSPosition();
707 int GetRudderPosition();
710 int GetMovementThreshold();
711 void SetMovementThreshold(int threshold) ;
714 int GetNumberJoysticks();
715 int GetManufacturerId();
717 wxString GetProductName();
724 int GetNumberButtons();
745 bool SetCapture(wxWindow* win, int pollingFreq = 0);
746 bool ReleaseCapture();
750 //----------------------------------------------------------------------
751 //----------------------------------------------------------------------