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 wxClientDisplayRect(int *OUTPUT, int *OUTPUT, int *OUTPUT, int *OUTPUT);
124 wxRect wxGetClientDisplayRect();
126 void wxSetCursor(wxCursor& cursor);
128 //----------------------------------------------------------------------
129 // Miscellaneous functions
131 wxWindow * wxFindWindowByLabel(const wxString& label, wxWindow *parent=NULL);
132 wxWindow * wxFindWindowByName(const wxString& name, wxWindow *parent=NULL);
134 void wxBeginBusyCursor(wxCursor *cursor = wxHOURGLASS_CURSOR);
135 wxWindow * wxGetActiveWindow();
138 //---------------------------------------------------------------------------
141 bool wxResourceAddIdentifier(char *name, int value);
142 void wxResourceClear(void);
143 wxBitmap wxResourceCreateBitmap(char *resource);
144 wxIcon wxResourceCreateIcon(char *resource);
145 wxMenuBar * wxResourceCreateMenuBar(char *resource);
146 int wxResourceGetIdentifier(char *name);
147 bool wxResourceParseData(char *resource, wxResourceTable *table = NULL);
148 bool wxResourceParseFile(char *filename, wxResourceTable *table = NULL);
149 bool wxResourceParseString(char *resource, wxResourceTable *table = NULL);
151 //---------------------------------------------------------------------------
165 wxSYS_OEM_FIXED_FONT,
166 wxSYS_ANSI_FIXED_FONT,
169 wxSYS_DEVICE_DEFAULT_FONT,
170 wxSYS_DEFAULT_PALETTE,
171 wxSYS_SYSTEM_FIXED_FONT,
172 wxSYS_DEFAULT_GUI_FONT,
174 wxSYS_COLOUR_SCROLLBAR,
175 wxSYS_COLOUR_BACKGROUND,
176 wxSYS_COLOUR_ACTIVECAPTION,
177 wxSYS_COLOUR_INACTIVECAPTION,
180 wxSYS_COLOUR_WINDOWFRAME,
181 wxSYS_COLOUR_MENUTEXT,
182 wxSYS_COLOUR_WINDOWTEXT,
183 wxSYS_COLOUR_CAPTIONTEXT,
184 wxSYS_COLOUR_ACTIVEBORDER,
185 wxSYS_COLOUR_INACTIVEBORDER,
186 wxSYS_COLOUR_APPWORKSPACE,
187 wxSYS_COLOUR_HIGHLIGHT,
188 wxSYS_COLOUR_HIGHLIGHTTEXT,
189 wxSYS_COLOUR_BTNFACE,
190 wxSYS_COLOUR_BTNSHADOW,
191 wxSYS_COLOUR_GRAYTEXT,
192 wxSYS_COLOUR_BTNTEXT,
193 wxSYS_COLOUR_INACTIVECAPTIONTEXT,
194 wxSYS_COLOUR_BTNHIGHLIGHT,
196 wxSYS_COLOUR_3DDKSHADOW,
197 wxSYS_COLOUR_3DLIGHT,
198 wxSYS_COLOUR_INFOTEXT,
201 wxSYS_COLOUR_DESKTOP,
203 wxSYS_COLOUR_3DSHADOW,
204 wxSYS_COLOUR_3DHIGHLIGHT,
205 wxSYS_COLOUR_3DHILIGHT,
206 wxSYS_COLOUR_BTNHILIGHT,
219 wxSYS_HSCROLL_ARROW_X,
220 wxSYS_HSCROLL_ARROW_Y,
236 wxSYS_VSCROLL_ARROW_X,
237 wxSYS_VSCROLL_ARROW_Y,
241 wxSYS_NETWORK_PRESENT,
242 wxSYS_PENWINDOWS_PRESENT,
251 wxColour wxSystemSettings_GetSystemColour(int index) {
252 return wxSystemSettings::GetSystemColour(index);
255 wxFont wxSystemSettings_GetSystemFont(int index) {
256 return wxSystemSettings::GetSystemFont(index);
259 int wxSystemSettings_GetSystemMetric(int index) {
260 return wxSystemSettings::GetSystemMetric(index);
264 //---------------------------------------------------------------------------
269 wxToolTip(const wxString &tip);
271 void SetTip(const wxString& tip);
273 // *** Not in the "public" interface void SetWindow(wxWindow *win);
274 wxWindow *GetWindow();
279 void wxToolTip_Enable(bool flag) {
280 wxToolTip::Enable(flag);
283 void wxToolTip_SetDelay(long milliseconds) {
284 wxToolTip::SetDelay(milliseconds);
288 //----------------------------------------------------------------------
292 wxCaret(wxWindow* window, const wxSize& size);
297 %name(GetPositionTuple)void GetPosition(int *OUTPUT, int *OUTPUT);
298 wxPoint GetPosition();
299 %name(GetSizeTuple)void GetSize(int *OUTPUT, int *OUTPUT);
301 wxWindow *GetWindow();
302 %name(MoveXY)void Move(int x, int y);
303 void Move(const wxPoint& pt);
304 %name(SetSizeWH) void SetSize(int width, int height);
305 void SetSize(const wxSize& size);
306 void Show(int show = TRUE);
311 int wxCaret_GetBlinkTime() {
312 return wxCaret::GetBlinkTime();
315 void wxCaret_SetBlinkTime(int milliseconds) {
316 wxCaret::SetBlinkTime(milliseconds);
320 //----------------------------------------------------------------------
323 class wxPyFontEnumerator : public wxFontEnumerator {
325 wxPyFontEnumerator() {}
326 ~wxPyFontEnumerator() {}
328 DEC_PYCALLBACK_BOOL_STRING(OnFacename);
329 DEC_PYCALLBACK_BOOL_STRINGSTRING(OnFontEncoding);
334 IMP_PYCALLBACK_BOOL_STRING(wxPyFontEnumerator, wxFontEnumerator, OnFacename);
335 IMP_PYCALLBACK_BOOL_STRINGSTRING(wxPyFontEnumerator, wxFontEnumerator, OnFontEncoding);
339 %name(wxFontEnumerator) class wxPyFontEnumerator {
341 wxPyFontEnumerator();
342 ~wxPyFontEnumerator();
343 void _setSelf(PyObject* self, PyObject* _class);
344 %pragma(python) addtomethod = "__init__:self._setSelf(self, wxFontEnumerator)"
346 bool EnumerateFacenames(
347 wxFontEncoding encoding = wxFONTENCODING_SYSTEM, // all
348 bool fixedWidthOnly = FALSE);
349 bool EnumerateEncodings(const char* facename = "");
351 //wxArrayString* GetEncodings();
352 //wxArrayString* GetFacenames();
354 PyObject* GetEncodings() {
355 wxArrayString* arr = self->GetEncodings();
356 PyObject* list = PyList_New(0);
357 for (size_t x=0; x<arr->GetCount(); x++)
358 PyList_Append(list, PyString_FromString((*arr)[x]));
362 PyObject* GetFacenames() {
363 wxArrayString* arr = self->GetFacenames();
364 PyObject* list = PyList_New(0);
365 for (size_t x=0; x<arr->GetCount(); x++)
366 PyList_Append(list, PyString_FromString((*arr)[x]));
372 //----------------------------------------------------------------------
376 wxBusyCursor(wxCursor* cursor = wxHOURGLASS_CURSOR);
380 //----------------------------------------------------------------------
382 class wxWindowDisabler {
384 wxWindowDisabler(wxWindow *winToSkip = NULL);
388 //----------------------------------------------------------------------
390 bool wxSafeYield(wxWindow* win=NULL);
391 void wxPostEvent(wxEvtHandler *dest, wxEvent& event);
396 void wxWakeUpMainThread();
399 void wxMutexGuiEnter();
400 void wxMutexGuiLeave();
403 class wxMutexGuiLocker {
411 bool wxThread_IsMain() {
412 return wxThread::IsMain();
416 //----------------------------------------------------------------------
422 // wxTipProvider(size_t currentTip); **** Abstract base class
425 virtual wxString GetTip() = 0;
426 size_t GetCurrentTip();
431 // The C++ version of wxPyTipProvider
433 class wxPyTipProvider : public wxTipProvider {
435 wxPyTipProvider(size_t currentTip)
436 : wxTipProvider(currentTip) {}
438 DEC_PYCALLBACK_STRING__pure(GetTip);
443 IMP_PYCALLBACK_STRING__pure( wxPyTipProvider, wxTipProvider, GetTip);
448 // Now let SWIG know about it
449 class wxPyTipProvider : public wxTipProvider {
451 wxPyTipProvider(size_t currentTip);
456 bool wxShowTip(wxWindow *parent, wxTipProvider *tipProvider, bool showAtStartup = TRUE);
457 %new wxTipProvider * wxCreateFileTipProvider(const wxString& filename, size_t currentTip);
460 //----------------------------------------------------------------------
463 #include <wx/generic/dragimgg.h>
464 static wxPoint wxPyNullPoint;
467 %name (wxDragImage) class wxGenericDragImage
471 wxGenericDragImage(const wxBitmap& image,
472 const wxCursor& cursor = wxNullCursor,
473 const wxPoint& hotspot = wxPyNullPoint);
474 ~wxGenericDragImage();
476 bool BeginDrag(const wxPoint& hotspot, wxWindow* window,
477 bool fullScreen = FALSE, wxRect* rect = NULL);
479 %name(BeginDrag2) bool BeginDrag(const wxPoint& hotspot, wxWindow* window,
480 wxWindow* fullScreenRect);
483 bool Move(const wxPoint& pt);
487 wxRect GetImageRect(const wxPoint& pos) const;
488 bool RedrawImage(const wxPoint& oldPos, const wxPoint& newPos,
489 bool eraseOld, bool drawNew);
493 // Alternate Constructors
494 %new wxGenericDragImage* wxDragIcon(const wxIcon& image,
495 const wxCursor& cursor = wxNullCursor,
496 const wxPoint& hotspot = wxPyNullPoint);
498 %new wxGenericDragImage* wxDragString(const wxString& str,
499 const wxCursor& cursor = wxNullCursor,
500 const wxPoint& hotspot = wxPyNullPoint);
502 %new wxGenericDragImage* wxDragTreeItem(const wxTreeCtrl& treeCtrl, wxTreeItemId& id);
504 %new wxGenericDragImage* wxDragListItem(const wxListCtrl& listCtrl, long id);
509 wxGenericDragImage* wxDragIcon(const wxIcon& image,
510 const wxCursor& cursor,
511 const wxPoint& hotspot) {
512 return new wxGenericDragImage(image, cursor, hotspot);
515 wxGenericDragImage* wxDragString(const wxString& str,
516 const wxCursor& cursor,
517 const wxPoint& hotspot) {
518 return new wxGenericDragImage(str, cursor, hotspot);
521 wxGenericDragImage* wxDragTreeItem(const wxTreeCtrl& treeCtrl, wxTreeItemId& id) {
522 return new wxGenericDragImage(treeCtrl, id);
525 wxGenericDragImage* wxDragListItem(const wxListCtrl& listCtrl, long id) {
526 return new wxGenericDragImage(listCtrl, id);
533 //----------------------------------------------------------------------
537 wxPyTimer(PyObject* notify);
542 void SetOwner(wxEvtHandler *owner, int id = -1);
543 void Start(int milliseconds=-1, int oneShot=FALSE);
547 //----------------------------------------------------------------------
548 //----------------------------------------------------------------------
553 wxLOG_FatalError, // program can't continue, abort immediately
554 wxLOG_Error, // a serious error, user must be informed about it
555 wxLOG_Warning, // user is normally informed about it but may be ignored
556 wxLOG_Message, // normal message (i.e. normal output of a non GUI app)
557 wxLOG_Info, // informational message (a.k.a. 'Verbose')
558 wxLOG_Status, // informational: might go to the status line of GUI app
559 wxLOG_Debug, // never shown to the user, disabled in release mode
560 wxLOG_Trace, // trace messages are also only enabled in debug mode
561 wxLOG_Progress, // used for progress indicator (not yet)
562 wxLOG_User = 100 // user defined levels start here
571 static bool IsEnabled();
572 static bool EnableLogging(bool doIt = TRUE);
573 static void OnLog(wxLogLevel level, const char *szString, int t=0);
575 virtual void Flush();
576 bool HasPendingMessages() const;
578 static void FlushActive();
579 static wxLog *GetActiveTarget();
580 static wxLog *SetActiveTarget(wxLog *pLogger);
582 static void Suspend();
583 static void Resume();
585 void SetVerbose(bool bVerbose = TRUE);
587 static void DontCreateOnDemand();
588 static void SetTraceMask(wxTraceMask ulMask);
589 static void AddTraceMask(const wxString& str);
590 static void RemoveTraceMask(const wxString& str);
592 bool GetVerbose() const { return m_bVerbose; }
594 static wxTraceMask GetTraceMask();
595 static bool IsAllowedTraceMask(const char *mask);
600 class wxLogStderr : public wxLog
603 wxLogStderr(/* TODO: FILE *fp = (FILE *) NULL*/);
607 class wxLogTextCtrl : public wxLog
610 wxLogTextCtrl(wxTextCtrl *pTextCtrl);
614 class wxLogGui : public wxLog
620 class wxLogWindow : public wxLog
623 wxLogWindow(wxFrame *pParent, // the parent frame (can be NULL)
624 const char *szTitle, // the title of the frame
625 bool bShow = TRUE, // show window immediately?
626 bool bPassToOld = TRUE); // pass log messages to the old target?
628 void Show(bool bShow = TRUE);
629 wxFrame *GetFrame() const;
630 wxLog *GetOldLog() const;
631 bool IsPassingMessages() const;
632 void PassMessages(bool bDoPass) { m_bPassMessages = bDoPass; }
644 unsigned long wxSysErrorCode();
645 const char* wxSysErrorMsg(unsigned long nErrCode = 0);
646 void wxLogFatalError(const char *szFormat);
647 void wxLogError(const char *szFormat);
648 void wxLogWarning(const char *szFormat);
649 void wxLogMessage(const char *szFormat);
650 void wxLogInfo(const char *szFormat);
651 void wxLogVerbose(const char *szFormat);
652 void wxLogStatus(const char *szFormat);
653 %name(wxLogStatusFrame)void wxLogStatus(wxFrame *pFrame, const char *szFormat);
654 void wxLogSysError(const char *szFormat);
658 //----------------------------------------------------------------------
667 class wxProcessEvent : public wxEvent {
669 wxProcessEvent(int id = 0, int pid = 0, int exitcode = 0);
672 int m_pid, m_exitcode;
678 %{ // C++ version of wxProcess derived class
680 class wxPyProcess : public wxProcess {
682 wxPyProcess(wxEvtHandler *parent = NULL, int id = -1)
683 : wxProcess(parent, id)
686 DEC_PYCALLBACK_VOID_INTINT(OnTerminate);
691 IMP_PYCALLBACK_VOID_INTINT( wxPyProcess, wxProcess, OnTerminate);
695 %name(wxProcess)class wxPyProcess : public wxEvtHandler {
697 wxPyProcess(wxEvtHandler *parent = NULL, int id = -1);
698 %addmethods { void Destroy() { delete self; } }
700 void _setSelf(PyObject* self, PyObject* _class);
701 %pragma(python) addtomethod = "__init__:self._setSelf(self, wxProcess)"
703 void base_OnTerminate(int pid, int status);
709 wxInputStream *GetInputStream();
710 wxInputStream *GetErrorStream();
711 wxOutputStream *GetOutputStream();
718 long wxExecute(const wxString& command,
720 wxPyProcess *process = NULL);
722 //----------------------------------------------------------------------
727 wxJoystick(int joystick = wxJOYSTICK1);
728 wxPoint GetPosition();
730 int GetButtonState();
731 int GetPOVPosition();
732 int GetPOVCTSPosition();
733 int GetRudderPosition();
736 int GetMovementThreshold();
737 void SetMovementThreshold(int threshold) ;
740 int GetNumberJoysticks();
741 int GetManufacturerId();
743 wxString GetProductName();
750 int GetNumberButtons();
771 bool SetCapture(wxWindow* win, int pollingFreq = 0);
772 bool ReleaseCapture();
776 //----------------------------------------------------------------------
777 //----------------------------------------------------------------------