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,
65 // TODO: Need to custom wrap this one...
66 // int wxGetMultipleChoice(char* message, char* caption,
67 // int LCOUNT, char** choices,
68 // int nsel, int *selection,
69 // wxWindow *parent = NULL, int x = -1, int y = -1,
70 // bool centre = TRUE, int width=150, int height=200);
73 wxString wxGetSingleChoice(const wxString& message, const wxString& caption,
74 int LCOUNT, wxString* choices,
75 wxWindow *parent = NULL,
76 int x = -1, int y = -1,
78 int width=150, int height=200);
80 int wxGetSingleChoiceIndex(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);
88 int wxMessageBox(const wxString& message,
89 const wxString& caption = wxPyEmptyStr,
90 int style = wxOK | wxCENTRE,
91 wxWindow *parent = NULL,
92 int x = -1, int y = -1);
94 long wxGetNumberFromUser(const wxString& message,
95 const wxString& prompt,
96 const wxString& caption,
98 long min = 0, long max = 100,
99 wxWindow *parent = NULL,
100 const wxPoint& pos = wxDefaultPosition);
102 //---------------------------------------------------------------------------
105 bool wxColourDisplay();
107 int wxDisplayDepth();
108 int wxGetDisplayDepth();
110 void wxDisplaySize(int* OUTPUT, int* OUTPUT);
111 wxSize wxGetDisplaySize();
112 void wxDisplaySizeMM(int* OUTPUT, int* OUTPUT);
113 wxSize wxGetDisplaySizeMM();
115 void wxSetCursor(wxCursor& cursor);
117 //----------------------------------------------------------------------
118 // Miscellaneous functions
120 wxWindow * wxFindWindowByLabel(const wxString& label, wxWindow *parent=NULL);
121 wxWindow * wxFindWindowByName(const wxString& name, wxWindow *parent=NULL);
123 void wxBeginBusyCursor(wxCursor *cursor = wxHOURGLASS_CURSOR);
124 wxWindow * wxGetActiveWindow();
127 //---------------------------------------------------------------------------
130 bool wxResourceAddIdentifier(char *name, int value);
131 void wxResourceClear(void);
132 wxBitmap wxResourceCreateBitmap(char *resource);
133 wxIcon wxResourceCreateIcon(char *resource);
134 wxMenuBar * wxResourceCreateMenuBar(char *resource);
135 int wxResourceGetIdentifier(char *name);
136 bool wxResourceParseData(char *resource, wxResourceTable *table = NULL);
137 bool wxResourceParseFile(char *filename, wxResourceTable *table = NULL);
138 bool wxResourceParseString(char *resource, wxResourceTable *table = NULL);
140 //---------------------------------------------------------------------------
154 wxSYS_OEM_FIXED_FONT,
155 wxSYS_ANSI_FIXED_FONT,
158 wxSYS_DEVICE_DEFAULT_FONT,
159 wxSYS_DEFAULT_PALETTE,
160 wxSYS_SYSTEM_FIXED_FONT,
161 wxSYS_DEFAULT_GUI_FONT,
163 wxSYS_COLOUR_SCROLLBAR,
164 wxSYS_COLOUR_BACKGROUND,
165 wxSYS_COLOUR_ACTIVECAPTION,
166 wxSYS_COLOUR_INACTIVECAPTION,
169 wxSYS_COLOUR_WINDOWFRAME,
170 wxSYS_COLOUR_MENUTEXT,
171 wxSYS_COLOUR_WINDOWTEXT,
172 wxSYS_COLOUR_CAPTIONTEXT,
173 wxSYS_COLOUR_ACTIVEBORDER,
174 wxSYS_COLOUR_INACTIVEBORDER,
175 wxSYS_COLOUR_APPWORKSPACE,
176 wxSYS_COLOUR_HIGHLIGHT,
177 wxSYS_COLOUR_HIGHLIGHTTEXT,
178 wxSYS_COLOUR_BTNFACE,
179 wxSYS_COLOUR_BTNSHADOW,
180 wxSYS_COLOUR_GRAYTEXT,
181 wxSYS_COLOUR_BTNTEXT,
182 wxSYS_COLOUR_INACTIVECAPTIONTEXT,
183 wxSYS_COLOUR_BTNHIGHLIGHT,
185 wxSYS_COLOUR_3DDKSHADOW,
186 wxSYS_COLOUR_3DLIGHT,
187 wxSYS_COLOUR_INFOTEXT,
190 wxSYS_COLOUR_DESKTOP,
192 wxSYS_COLOUR_3DSHADOW,
193 wxSYS_COLOUR_3DHIGHLIGHT,
194 wxSYS_COLOUR_3DHILIGHT,
195 wxSYS_COLOUR_BTNHILIGHT,
208 wxSYS_HSCROLL_ARROW_X,
209 wxSYS_HSCROLL_ARROW_Y,
225 wxSYS_VSCROLL_ARROW_X,
226 wxSYS_VSCROLL_ARROW_Y,
230 wxSYS_NETWORK_PRESENT,
231 wxSYS_PENWINDOWS_PRESENT,
240 wxColour wxSystemSettings_GetSystemColour(int index) {
241 return wxSystemSettings::GetSystemColour(index);
244 wxFont wxSystemSettings_GetSystemFont(int index) {
245 return wxSystemSettings::GetSystemFont(index);
248 int wxSystemSettings_GetSystemMetric(int index) {
249 return wxSystemSettings::GetSystemMetric(index);
253 //---------------------------------------------------------------------------
258 wxToolTip(const wxString &tip);
260 void SetTip(const wxString& tip);
262 // *** Not in the "public" interface void SetWindow(wxWindow *win);
263 wxWindow *GetWindow();
268 void wxToolTip_Enable(bool flag) {
269 wxToolTip::Enable(flag);
272 void wxToolTip_SetDelay(long milliseconds) {
273 wxToolTip::SetDelay(milliseconds);
277 //----------------------------------------------------------------------
281 wxCaret(wxWindow* window, const wxSize& size);
286 %name(GetPositionTuple)void GetPosition(int *OUTPUT, int *OUTPUT);
287 wxPoint GetPosition();
288 %name(GetSizeTuple)void GetSize(int *OUTPUT, int *OUTPUT);
290 wxWindow *GetWindow();
291 %name(MoveXY)void Move(int x, int y);
292 void Move(const wxPoint& pt);
293 %name(SetSizeWH) void SetSize(int width, int height);
294 void SetSize(const wxSize& size);
295 void Show(int show = TRUE);
300 int wxCaret_GetBlinkTime() {
301 return wxCaret::GetBlinkTime();
304 void wxCaret_SetBlinkTime(int milliseconds) {
305 wxCaret::SetBlinkTime(milliseconds);
309 //----------------------------------------------------------------------
312 class wxPyFontEnumerator : public wxFontEnumerator {
314 wxPyFontEnumerator() {}
315 ~wxPyFontEnumerator() {}
317 DEC_PYCALLBACK_BOOL_STRING(OnFacename);
318 DEC_PYCALLBACK_BOOL_STRINGSTRING(OnFontEncoding);
323 IMP_PYCALLBACK_BOOL_STRING(wxPyFontEnumerator, wxFontEnumerator, OnFacename);
324 IMP_PYCALLBACK_BOOL_STRINGSTRING(wxPyFontEnumerator, wxFontEnumerator, OnFontEncoding);
328 %name(wxFontEnumerator) class wxPyFontEnumerator {
330 wxPyFontEnumerator();
331 ~wxPyFontEnumerator();
332 void _setSelf(PyObject* self, PyObject* _class);
333 %pragma(python) addtomethod = "__init__:self._setSelf(self, wxFontEnumerator)"
335 bool EnumerateFacenames(
336 wxFontEncoding encoding = wxFONTENCODING_SYSTEM, // all
337 bool fixedWidthOnly = FALSE);
338 bool EnumerateEncodings(const char* facename = "");
340 //wxArrayString* GetEncodings();
341 //wxArrayString* GetFacenames();
343 PyObject* GetEncodings() {
344 wxArrayString* arr = self->GetEncodings();
345 PyObject* list = PyList_New(0);
346 for (size_t x=0; x<arr->GetCount(); x++)
347 PyList_Append(list, PyString_FromString((*arr)[x]));
351 PyObject* GetFacenames() {
352 wxArrayString* arr = self->GetFacenames();
353 PyObject* list = PyList_New(0);
354 for (size_t x=0; x<arr->GetCount(); x++)
355 PyList_Append(list, PyString_FromString((*arr)[x]));
361 //----------------------------------------------------------------------
365 wxBusyCursor(wxCursor* cursor = wxHOURGLASS_CURSOR);
369 //----------------------------------------------------------------------
371 class wxWindowDisabler {
373 wxWindowDisabler(wxWindow *winToSkip = NULL);
377 //----------------------------------------------------------------------
379 void wxPostEvent(wxEvtHandler *dest, wxEvent& event);
382 bool wxSafeYield(wxWindow* win=NULL);
384 //----------------------------------------------------------------------
390 // wxTipProvider(size_t currentTip); **** Abstract base class
393 virtual wxString GetTip() = 0;
394 size_t GetCurrentTip();
399 // The C++ version of wxPyTipProvider
401 class wxPyTipProvider : public wxTipProvider {
403 wxPyTipProvider(size_t currentTip)
404 : wxTipProvider(currentTip) {}
406 DEC_PYCALLBACK_STRING__pure(GetTip);
411 IMP_PYCALLBACK_STRING__pure( wxPyTipProvider, wxTipProvider, GetTip);
416 // Now let SWIG know about it
417 class wxPyTipProvider : public wxTipProvider {
419 wxPyTipProvider(size_t currentTip);
424 bool wxShowTip(wxWindow *parent, wxTipProvider *tipProvider, bool showAtStartup = TRUE);
425 %new wxTipProvider * wxCreateFileTipProvider(const wxString& filename, size_t currentTip);
428 //----------------------------------------------------------------------
431 #include <wx/generic/dragimgg.h>
432 static wxPoint wxPyNullPoint;
435 %name (wxDragImage) class wxGenericDragImage
439 wxGenericDragImage(const wxBitmap& image,
440 const wxCursor& cursor = wxNullCursor,
441 const wxPoint& hotspot = wxPyNullPoint);
442 ~wxGenericDragImage();
444 bool BeginDrag(const wxPoint& hotspot, wxWindow* window,
445 bool fullScreen = FALSE, wxRect* rect = NULL);
447 %name(BeginDrag2) bool BeginDrag(const wxPoint& hotspot, wxWindow* window,
448 wxWindow* fullScreenRect);
451 bool Move(const wxPoint& pt);
455 wxRect GetImageRect(const wxPoint& pos) const;
456 bool RedrawImage(const wxPoint& oldPos, const wxPoint& newPos,
457 bool eraseOld, bool drawNew);
461 // Alternate Constructors
462 %new wxGenericDragImage* wxDragIcon(const wxIcon& image,
463 const wxCursor& cursor = wxNullCursor,
464 const wxPoint& hotspot = wxPyNullPoint);
466 %new wxGenericDragImage* wxDragString(const wxString& str,
467 const wxCursor& cursor = wxNullCursor,
468 const wxPoint& hotspot = wxPyNullPoint);
470 %new wxGenericDragImage* wxDragTreeItem(const wxTreeCtrl& treeCtrl, wxTreeItemId& id);
472 %new wxGenericDragImage* wxDragListItem(const wxListCtrl& listCtrl, long id);
477 wxGenericDragImage* wxDragIcon(const wxIcon& image,
478 const wxCursor& cursor,
479 const wxPoint& hotspot) {
480 return new wxGenericDragImage(image, cursor, hotspot);
483 wxGenericDragImage* wxDragString(const wxString& str,
484 const wxCursor& cursor,
485 const wxPoint& hotspot) {
486 return new wxGenericDragImage(str, cursor, hotspot);
489 wxGenericDragImage* wxDragTreeItem(const wxTreeCtrl& treeCtrl, wxTreeItemId& id) {
490 return new wxGenericDragImage(treeCtrl, id);
493 wxGenericDragImage* wxDragListItem(const wxListCtrl& listCtrl, long id) {
494 return new wxGenericDragImage(listCtrl, id);
501 //----------------------------------------------------------------------
505 wxPyTimer(PyObject* notify);
510 void SetOwner(wxEvtHandler *owner, int id = -1);
511 void Start(int milliseconds=-1, int oneShot=FALSE);
515 //----------------------------------------------------------------------
516 //----------------------------------------------------------------------
521 wxLOG_FatalError, // program can't continue, abort immediately
522 wxLOG_Error, // a serious error, user must be informed about it
523 wxLOG_Warning, // user is normally informed about it but may be ignored
524 wxLOG_Message, // normal message (i.e. normal output of a non GUI app)
525 wxLOG_Info, // informational message (a.k.a. 'Verbose')
526 wxLOG_Status, // informational: might go to the status line of GUI app
527 wxLOG_Debug, // never shown to the user, disabled in release mode
528 wxLOG_Trace, // trace messages are also only enabled in debug mode
529 wxLOG_Progress, // used for progress indicator (not yet)
530 wxLOG_User = 100 // user defined levels start here
539 static bool IsEnabled();
540 static bool EnableLogging(bool doIt = TRUE);
541 static void OnLog(wxLogLevel level, const char *szString, int t=0);
543 virtual void Flush();
544 bool HasPendingMessages() const;
546 static void FlushActive();
547 static wxLog *GetActiveTarget();
548 static wxLog *SetActiveTarget(wxLog *pLogger);
550 static void Suspend();
551 static void Resume();
553 void SetVerbose(bool bVerbose = TRUE);
555 static void DontCreateOnDemand();
556 static void SetTraceMask(wxTraceMask ulMask);
557 static void AddTraceMask(const wxString& str);
558 static void RemoveTraceMask(const wxString& str);
560 bool GetVerbose() const { return m_bVerbose; }
562 static wxTraceMask GetTraceMask();
563 static bool IsAllowedTraceMask(const char *mask);
568 class wxLogStderr : public wxLog
571 wxLogStderr(/* TODO: FILE *fp = (FILE *) NULL*/);
575 class wxLogTextCtrl : public wxLog
578 wxLogTextCtrl(wxTextCtrl *pTextCtrl);
582 class wxLogGui : public wxLog
588 class wxLogWindow : public wxLog
591 wxLogWindow(wxFrame *pParent, // the parent frame (can be NULL)
592 const char *szTitle, // the title of the frame
593 bool bShow = TRUE, // show window immediately?
594 bool bPassToOld = TRUE); // pass log messages to the old target?
596 void Show(bool bShow = TRUE);
597 wxFrame *GetFrame() const;
598 wxLog *GetOldLog() const;
599 bool IsPassingMessages() const;
600 void PassMessages(bool bDoPass) { m_bPassMessages = bDoPass; }
612 unsigned long wxSysErrorCode();
613 const char* wxSysErrorMsg(unsigned long nErrCode = 0);
614 void wxLogFatalError(const char *szFormat);
615 void wxLogError(const char *szFormat);
616 void wxLogWarning(const char *szFormat);
617 void wxLogMessage(const char *szFormat);
618 void wxLogInfo(const char *szFormat);
619 void wxLogVerbose(const char *szFormat);
620 void wxLogStatus(const char *szFormat);
621 %name(wxLogStatusFrame)void wxLogStatus(wxFrame *pFrame, const char *szFormat);
622 void wxLogSysError(const char *szFormat);
626 //----------------------------------------------------------------------
628 class wxProcessEvent : public wxEvent {
630 wxProcessEvent(int id = 0, int pid = 0, int exitcode = 0);
633 int m_pid, m_exitcode;
639 %{ // C++ version of wxProcess derived class
641 class wxPyProcess : public wxProcess {
643 wxPyProcess(wxEvtHandler *parent = NULL, int id = -1)
644 : wxProcess(parent, id)
647 DEC_PYCALLBACK_VOID_INTINT(OnTerminate);
652 IMP_PYCALLBACK_VOID_INTINT( wxPyProcess, wxProcess, OnTerminate);
656 %name(wxProcess)class wxPyProcess : public wxEvtHandler {
658 wxPyProcess(wxEvtHandler *parent = NULL, int id = -1);
659 %addmethods { void Destroy() { delete self; } }
661 void _setSelf(PyObject* self, PyObject* _class);
662 %pragma(python) addtomethod = "__init__:self._setSelf(self, wxProcess)"
664 void base_OnTerminate(int pid, int status);
670 wxInputStream *GetInputStream();
671 wxInputStream *GetErrorStream();
672 wxOutputStream *GetOutputStream();
679 long wxExecute(const wxString& command,
681 wxPyProcess *process = NULL);
683 //----------------------------------------------------------------------
688 wxJoystick(int joystick = wxJOYSTICK1);
689 wxPoint GetPosition();
691 int GetButtonState();
692 int GetPOVPosition();
693 int GetPOVCTSPosition();
694 int GetRudderPosition();
697 int GetMovementThreshold();
698 void SetMovementThreshold(int threshold) ;
701 int GetNumberJoysticks();
702 int GetManufacturerId();
704 wxString GetProductName();
711 int GetNumberButtons();
732 bool SetCapture(wxWindow* win, int pollingFreq = 0);
733 bool ReleaseCapture();
737 //----------------------------------------------------------------------
738 //----------------------------------------------------------------------