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>
27 //----------------------------------------------------------------------
30 %include my_typemaps.i
32 // Import some definitions of other classes, etc.
40 //---------------------------------------------------------------------------
43 wxString wxFileSelector(char* message,
44 char* default_path = NULL,
45 char* default_filename = NULL,
46 char* default_extension = NULL,
47 char* wildcard = "*.*",
49 wxWindow *parent = NULL,
50 int x = -1, int y = -1);
52 wxString wxGetTextFromUser(const wxString& message,
53 const wxString& caption = wxPyEmptyStr,
54 const wxString& default_value = wxPyEmptyStr,
55 wxWindow *parent = NULL,
56 int x = -1, int y = -1,
60 // TODO: Need to custom wrap this one...
61 // int wxGetMultipleChoice(char* message, char* caption,
62 // int LCOUNT, char** choices,
63 // int nsel, int *selection,
64 // wxWindow *parent = NULL, int x = -1, int y = -1,
65 // bool centre = TRUE, int width=150, int height=200);
68 wxString wxGetSingleChoice(const wxString& message, const wxString& caption,
69 int LCOUNT, wxString* choices,
70 wxWindow *parent = NULL,
71 int x = -1, int y = -1,
73 int width=150, int height=200);
75 int wxGetSingleChoiceIndex(const wxString& message, const wxString& caption,
76 int LCOUNT, wxString* choices,
77 wxWindow *parent = NULL,
78 int x = -1, int y = -1,
80 int width=150, int height=200);
83 int wxMessageBox(const wxString& message,
84 const wxString& caption = wxPyEmptyStr,
85 int style = wxOK | wxCENTRE,
86 wxWindow *parent = NULL,
87 int x = -1, int y = -1);
89 long wxGetNumberFromUser(const wxString& message,
90 const wxString& prompt,
91 const wxString& caption,
93 long min = 0, long max = 100,
94 wxWindow *parent = NULL,
95 const wxPoint& pos = wxPyDefaultPosition);
97 //---------------------------------------------------------------------------
100 bool wxColourDisplay();
101 int wxDisplayDepth();
102 void wxSetCursor(wxCursor& cursor);
104 //----------------------------------------------------------------------
105 // Miscellaneous functions
107 wxWindow * wxFindWindowByLabel(const wxString& label, wxWindow *parent=NULL);
108 wxWindow * wxFindWindowByName(const wxString& name, wxWindow *parent=NULL);
110 void wxBeginBusyCursor(wxCursor *cursor = wxHOURGLASS_CURSOR);
111 wxWindow * wxGetActiveWindow();
114 //---------------------------------------------------------------------------
117 bool wxResourceAddIdentifier(char *name, int value);
118 void wxResourceClear(void);
119 wxBitmap wxResourceCreateBitmap(char *resource);
120 wxIcon wxResourceCreateIcon(char *resource);
121 wxMenuBar * wxResourceCreateMenuBar(char *resource);
122 int wxResourceGetIdentifier(char *name);
123 bool wxResourceParseData(char *resource, wxResourceTable *table = NULL);
124 bool wxResourceParseFile(char *filename, wxResourceTable *table = NULL);
125 bool wxResourceParseString(char *resource, wxResourceTable *table = NULL);
127 //---------------------------------------------------------------------------
141 wxSYS_OEM_FIXED_FONT,
142 wxSYS_ANSI_FIXED_FONT,
145 wxSYS_DEVICE_DEFAULT_FONT,
146 wxSYS_DEFAULT_PALETTE,
147 wxSYS_SYSTEM_FIXED_FONT,
148 wxSYS_DEFAULT_GUI_FONT,
150 wxSYS_COLOUR_SCROLLBAR,
151 wxSYS_COLOUR_BACKGROUND,
152 wxSYS_COLOUR_ACTIVECAPTION,
153 wxSYS_COLOUR_INACTIVECAPTION,
156 wxSYS_COLOUR_WINDOWFRAME,
157 wxSYS_COLOUR_MENUTEXT,
158 wxSYS_COLOUR_WINDOWTEXT,
159 wxSYS_COLOUR_CAPTIONTEXT,
160 wxSYS_COLOUR_ACTIVEBORDER,
161 wxSYS_COLOUR_INACTIVEBORDER,
162 wxSYS_COLOUR_APPWORKSPACE,
163 wxSYS_COLOUR_HIGHLIGHT,
164 wxSYS_COLOUR_HIGHLIGHTTEXT,
165 wxSYS_COLOUR_BTNFACE,
166 wxSYS_COLOUR_BTNSHADOW,
167 wxSYS_COLOUR_GRAYTEXT,
168 wxSYS_COLOUR_BTNTEXT,
169 wxSYS_COLOUR_INACTIVECAPTIONTEXT,
170 wxSYS_COLOUR_BTNHIGHLIGHT,
172 wxSYS_COLOUR_3DDKSHADOW,
173 wxSYS_COLOUR_3DLIGHT,
174 wxSYS_COLOUR_INFOTEXT,
177 wxSYS_COLOUR_DESKTOP,
179 wxSYS_COLOUR_3DSHADOW,
180 wxSYS_COLOUR_3DHIGHLIGHT,
181 wxSYS_COLOUR_3DHILIGHT,
182 wxSYS_COLOUR_BTNHILIGHT,
195 wxSYS_HSCROLL_ARROW_X,
196 wxSYS_HSCROLL_ARROW_Y,
212 wxSYS_VSCROLL_ARROW_X,
213 wxSYS_VSCROLL_ARROW_Y,
217 wxSYS_NETWORK_PRESENT,
218 wxSYS_PENWINDOWS_PRESENT,
227 wxColour wxSystemSettings_GetSystemColour(int index) {
228 return wxSystemSettings::GetSystemColour(index);
231 wxFont wxSystemSettings_GetSystemFont(int index) {
232 return wxSystemSettings::GetSystemFont(index);
235 int wxSystemSettings_GetSystemMetric(int index) {
236 return wxSystemSettings::GetSystemMetric(index);
240 //---------------------------------------------------------------------------
245 wxToolTip(const wxString &tip);
247 void SetTip(const wxString& tip);
249 // *** Not in the "public" interface void SetWindow(wxWindow *win);
250 wxWindow *GetWindow();
255 void wxToolTip_Enable(bool flag) {
256 wxToolTip::Enable(flag);
259 void wxToolTip_SetDelay(long milliseconds) {
260 wxToolTip::SetDelay(milliseconds);
264 //----------------------------------------------------------------------
268 wxCaret(wxWindow* window, const wxSize& size);
273 %name(GetPositionTuple)void GetPosition(int *OUTPUT, int *OUTPUT);
274 wxPoint GetPosition();
275 %name(GetSizeTuple)void GetSize(int *OUTPUT, int *OUTPUT);
277 wxWindow *GetWindow();
278 %name(MoveXY)void Move(int x, int y);
279 void Move(const wxPoint& pt);
280 %name(SetSizeWH) void SetSize(int width, int height);
281 void SetSize(const wxSize& size);
282 void Show(int show = TRUE);
287 int wxCaret_GetBlinkTime() {
288 return wxCaret::GetBlinkTime();
291 void wxCaret_SetBlinkTime(int milliseconds) {
292 wxCaret::SetBlinkTime(milliseconds);
296 //----------------------------------------------------------------------
299 class wxPyFontEnumerator : public wxFontEnumerator {
301 wxPyFontEnumerator() {}
302 ~wxPyFontEnumerator() {}
304 DEC_PYCALLBACK_BOOL_STRING(OnFacename);
305 DEC_PYCALLBACK_BOOL_STRINGSTRING(OnFontEncoding);
310 IMP_PYCALLBACK_BOOL_STRING(wxPyFontEnumerator, wxFontEnumerator, OnFacename);
311 IMP_PYCALLBACK_BOOL_STRINGSTRING(wxPyFontEnumerator, wxFontEnumerator, OnFontEncoding);
315 %name(wxFontEnumerator) class wxPyFontEnumerator {
317 wxPyFontEnumerator();
318 ~wxPyFontEnumerator();
319 void _setSelf(PyObject* self, PyObject* _class);
320 %pragma(python) addtomethod = "__init__:self._setSelf(self, wxFontEnumerator)"
322 bool EnumerateFacenames(
323 wxFontEncoding encoding = wxFONTENCODING_SYSTEM, // all
324 bool fixedWidthOnly = FALSE);
325 bool EnumerateEncodings(const char* facename = "");
327 //wxArrayString* GetEncodings();
328 //wxArrayString* GetFacenames();
330 PyObject* GetEncodings() {
331 wxArrayString* arr = self->GetEncodings();
332 PyObject* list = PyList_New(0);
333 for (size_t x=0; x<arr->GetCount(); x++)
334 PyList_Append(list, PyString_FromString((*arr)[x]));
338 PyObject* GetFacenames() {
339 wxArrayString* arr = self->GetFacenames();
340 PyObject* list = PyList_New(0);
341 for (size_t x=0; x<arr->GetCount(); x++)
342 PyList_Append(list, PyString_FromString((*arr)[x]));
348 //----------------------------------------------------------------------
352 wxBusyCursor(wxCursor* cursor = wxHOURGLASS_CURSOR);
356 //----------------------------------------------------------------------
358 class wxWindowDisabler {
360 wxWindowDisabler(wxWindow *winToSkip = NULL);
364 //----------------------------------------------------------------------
366 void wxPostEvent(wxEvtHandler *dest, wxEvent& event);
369 bool wxSafeYield(wxWindow* win=NULL);
371 //----------------------------------------------------------------------
377 // wxTipProvider(size_t currentTip); **** Abstract base class
380 virtual wxString GetTip() = 0;
381 size_t GetCurrentTip();
386 // The C++ version of wxPyTipProvider
388 class wxPyTipProvider : public wxTipProvider {
390 wxPyTipProvider(size_t currentTip)
391 : wxTipProvider(currentTip) {}
393 DEC_PYCALLBACK_STRING__pure(GetTip);
398 IMP_PYCALLBACK_STRING__pure( wxPyTipProvider, wxTipProvider, GetTip);
403 // Now let SWIG know about it
404 class wxPyTipProvider : public wxTipProvider {
406 wxPyTipProvider(size_t currentTip);
411 bool wxShowTip(wxWindow *parent, wxTipProvider *tipProvider, bool showAtStartup = TRUE);
412 %new wxTipProvider * wxCreateFileTipProvider(const wxString& filename, size_t currentTip);
415 //----------------------------------------------------------------------
418 #include <wx/generic/dragimgg.h>
419 static wxPoint wxPyNullPoint;
422 %name (wxDragImage) class wxGenericDragImage
426 wxGenericDragImage(const wxBitmap& image,
427 const wxCursor& cursor = wxNullCursor,
428 const wxPoint& hotspot = wxPyNullPoint);
429 ~wxGenericDragImage();
431 bool BeginDrag(const wxPoint& hotspot, wxWindow* window,
432 bool fullScreen = FALSE, wxRect* rect = NULL);
434 %name(BeginDrag2) bool BeginDrag(const wxPoint& hotspot, wxWindow* window,
435 wxWindow* fullScreenRect);
438 bool Move(const wxPoint& pt);
442 wxRect GetImageRect(const wxPoint& pos) const;
443 bool RedrawImage(const wxPoint& oldPos, const wxPoint& newPos,
444 bool eraseOld, bool drawNew);
448 // Alternate Constructors
449 %new wxGenericDragImage* wxDragIcon(const wxIcon& image,
450 const wxCursor& cursor = wxNullCursor,
451 const wxPoint& hotspot = wxPyNullPoint);
453 %new wxGenericDragImage* wxDragString(const wxString& str,
454 const wxCursor& cursor = wxNullCursor,
455 const wxPoint& hotspot = wxPyNullPoint);
457 %new wxGenericDragImage* wxDragTreeItem(const wxTreeCtrl& treeCtrl, wxTreeItemId& id);
459 %new wxGenericDragImage* wxDragListItem(const wxListCtrl& listCtrl, long id);
464 wxGenericDragImage* wxDragIcon(const wxIcon& image,
465 const wxCursor& cursor,
466 const wxPoint& hotspot) {
467 return new wxGenericDragImage(image, cursor, hotspot);
470 wxGenericDragImage* wxDragString(const wxString& str,
471 const wxCursor& cursor,
472 const wxPoint& hotspot) {
473 return new wxGenericDragImage(str, cursor, hotspot);
476 wxGenericDragImage* wxDragTreeItem(const wxTreeCtrl& treeCtrl, wxTreeItemId& id) {
477 return new wxGenericDragImage(treeCtrl, id);
480 wxGenericDragImage* wxDragListItem(const wxListCtrl& listCtrl, long id) {
481 return new wxGenericDragImage(listCtrl, id);
488 //----------------------------------------------------------------------
492 wxPyTimer(PyObject* notify);
497 void SetOwner(wxEvtHandler *owner, int id = -1);
498 void Start(int milliseconds=-1, int oneShot=FALSE);
502 //----------------------------------------------------------------------
503 //----------------------------------------------------------------------
508 wxLOG_FatalError, // program can't continue, abort immediately
509 wxLOG_Error, // a serious error, user must be informed about it
510 wxLOG_Warning, // user is normally informed about it but may be ignored
511 wxLOG_Message, // normal message (i.e. normal output of a non GUI app)
512 wxLOG_Info, // informational message (a.k.a. 'Verbose')
513 wxLOG_Status, // informational: might go to the status line of GUI app
514 wxLOG_Debug, // never shown to the user, disabled in release mode
515 wxLOG_Trace, // trace messages are also only enabled in debug mode
516 wxLOG_Progress, // used for progress indicator (not yet)
517 wxLOG_User = 100 // user defined levels start here
526 static bool IsEnabled();
527 static bool EnableLogging(bool doIt = TRUE);
528 static void OnLog(wxLogLevel level, const char *szString, int t=0);
530 virtual void Flush();
531 bool HasPendingMessages() const;
533 static void FlushActive();
534 static wxLog *GetActiveTarget();
535 static wxLog *SetActiveTarget(wxLog *pLogger);
537 static void Suspend();
538 static void Resume();
540 void SetVerbose(bool bVerbose = TRUE);
542 static void DontCreateOnDemand();
543 static void SetTraceMask(wxTraceMask ulMask);
544 static void AddTraceMask(const wxString& str);
545 static void RemoveTraceMask(const wxString& str);
547 bool GetVerbose() const { return m_bVerbose; }
549 static wxTraceMask GetTraceMask();
550 static bool IsAllowedTraceMask(const char *mask);
555 class wxLogStderr : public wxLog
558 wxLogStderr(/* TODO: FILE *fp = (FILE *) NULL*/);
562 class wxLogTextCtrl : public wxLog
565 wxLogTextCtrl(wxTextCtrl *pTextCtrl);
569 class wxLogGui : public wxLog
575 class wxLogWindow : public wxLog
578 wxLogWindow(wxFrame *pParent, // the parent frame (can be NULL)
579 const char *szTitle, // the title of the frame
580 bool bShow = TRUE, // show window immediately?
581 bool bPassToOld = TRUE); // pass log messages to the old target?
583 void Show(bool bShow = TRUE);
584 wxFrame *GetFrame() const;
585 wxLog *GetOldLog() const;
586 bool IsPassingMessages() const;
587 void PassMessages(bool bDoPass) { m_bPassMessages = bDoPass; }
599 unsigned long wxSysErrorCode();
600 const char* wxSysErrorMsg(unsigned long nErrCode = 0);
601 void wxLogFatalError(const char *szFormat);
602 void wxLogError(const char *szFormat);
603 void wxLogWarning(const char *szFormat);
604 void wxLogMessage(const char *szFormat);
605 void wxLogInfo(const char *szFormat);
606 void wxLogVerbose(const char *szFormat);
607 void wxLogStatus(const char *szFormat);
608 %name(wxLogStatusFrame)void wxLogStatus(wxFrame *pFrame, const char *szFormat);
609 void wxLogSysError(const char *szFormat);
613 //----------------------------------------------------------------------
615 class wxProcessEvent : public wxEvent {
617 wxProcessEvent(int id = 0, int pid = 0, int exitcode = 0);
620 int m_pid, m_exitcode;
626 %{ // C++ version of wxProcess derived class
628 class wxPyProcess : public wxProcess {
630 wxPyProcess(wxEvtHandler *parent = NULL, int id = -1)
631 : wxProcess(parent, id)
634 DEC_PYCALLBACK_VOID_INTINT(OnTerminate);
639 IMP_PYCALLBACK_VOID_INTINT( wxPyProcess, wxProcess, OnTerminate);
643 %name(wxProcess)class wxPyProcess : public wxEvtHandler {
645 wxPyProcess(wxEvtHandler *parent = NULL, int id = -1);
646 %addmethods { void Destroy() { delete self; } }
648 void _setSelf(PyObject* self, PyObject* _class);
649 %pragma(python) addtomethod = "__init__:self._setSelf(self, wxProcess)"
651 void base_OnTerminate(int pid, int status);
657 wxInputStream *GetInputStream();
658 wxInputStream *GetErrorStream();
659 wxOutputStream *GetOutputStream();
666 long wxExecute(const wxString& command,
668 wxPyProcess *process = NULL);
670 //----------------------------------------------------------------------
671 //----------------------------------------------------------------------