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>
26 //----------------------------------------------------------------------
29 %include my_typemaps.i
31 // Import some definitions of other classes, etc.
38 //---------------------------------------------------------------------------
41 wxString wxFileSelector(char* message,
42 char* default_path = NULL,
43 char* default_filename = NULL,
44 char* default_extension = NULL,
45 char* wildcard = "*.*",
47 wxWindow *parent = NULL,
48 int x = -1, int y = -1);
50 wxString wxGetTextFromUser(const wxString& message,
51 const wxString& caption = wxPyEmptyStr,
52 const wxString& default_value = wxPyEmptyStr,
53 wxWindow *parent = NULL,
54 int x = -1, int y = -1,
58 // TODO: Need to custom wrap this one...
59 // int wxGetMultipleChoice(char* message, char* caption,
60 // int LCOUNT, char** choices,
61 // int nsel, int *selection,
62 // wxWindow *parent = NULL, int x = -1, int y = -1,
63 // bool centre = TRUE, int width=150, int height=200);
66 wxString wxGetSingleChoice(const wxString& message, const wxString& caption,
67 int LCOUNT, wxString* choices,
68 wxWindow *parent = NULL,
69 int x = -1, int y = -1,
71 int width=150, int height=200);
73 int wxGetSingleChoiceIndex(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);
81 int wxMessageBox(const wxString& message,
82 const wxString& caption = wxPyEmptyStr,
83 int style = wxOK | wxCENTRE,
84 wxWindow *parent = NULL,
85 int x = -1, int y = -1);
87 long wxGetNumberFromUser(const wxString& message,
88 const wxString& prompt,
89 const wxString& caption,
91 long min = 0, long max = 100,
92 wxWindow *parent = NULL,
93 const wxPoint& pos = wxPyDefaultPosition);
95 //---------------------------------------------------------------------------
98 bool wxColourDisplay();
100 void wxSetCursor(wxCursor& cursor);
102 //----------------------------------------------------------------------
103 // Miscellaneous functions
105 wxWindow * wxFindWindowByLabel(const wxString& label, wxWindow *parent=NULL);
106 wxWindow * wxFindWindowByName(const wxString& name, wxWindow *parent=NULL);
108 void wxBeginBusyCursor(wxCursor *cursor = wxHOURGLASS_CURSOR);
109 wxWindow * wxGetActiveWindow();
112 //---------------------------------------------------------------------------
115 bool wxResourceAddIdentifier(char *name, int value);
116 void wxResourceClear(void);
117 wxBitmap wxResourceCreateBitmap(char *resource);
118 wxIcon wxResourceCreateIcon(char *resource);
119 wxMenuBar * wxResourceCreateMenuBar(char *resource);
120 int wxResourceGetIdentifier(char *name);
121 bool wxResourceParseData(char *resource, wxResourceTable *table = NULL);
122 bool wxResourceParseFile(char *filename, wxResourceTable *table = NULL);
123 bool wxResourceParseString(char *resource, wxResourceTable *table = NULL);
125 //---------------------------------------------------------------------------
139 wxSYS_OEM_FIXED_FONT,
140 wxSYS_ANSI_FIXED_FONT,
143 wxSYS_DEVICE_DEFAULT_FONT,
144 wxSYS_DEFAULT_PALETTE,
145 wxSYS_SYSTEM_FIXED_FONT,
146 wxSYS_DEFAULT_GUI_FONT,
148 wxSYS_COLOUR_SCROLLBAR,
149 wxSYS_COLOUR_BACKGROUND,
150 wxSYS_COLOUR_ACTIVECAPTION,
151 wxSYS_COLOUR_INACTIVECAPTION,
154 wxSYS_COLOUR_WINDOWFRAME,
155 wxSYS_COLOUR_MENUTEXT,
156 wxSYS_COLOUR_WINDOWTEXT,
157 wxSYS_COLOUR_CAPTIONTEXT,
158 wxSYS_COLOUR_ACTIVEBORDER,
159 wxSYS_COLOUR_INACTIVEBORDER,
160 wxSYS_COLOUR_APPWORKSPACE,
161 wxSYS_COLOUR_HIGHLIGHT,
162 wxSYS_COLOUR_HIGHLIGHTTEXT,
163 wxSYS_COLOUR_BTNFACE,
164 wxSYS_COLOUR_BTNSHADOW,
165 wxSYS_COLOUR_GRAYTEXT,
166 wxSYS_COLOUR_BTNTEXT,
167 wxSYS_COLOUR_INACTIVECAPTIONTEXT,
168 wxSYS_COLOUR_BTNHIGHLIGHT,
170 wxSYS_COLOUR_3DDKSHADOW,
171 wxSYS_COLOUR_3DLIGHT,
172 wxSYS_COLOUR_INFOTEXT,
175 wxSYS_COLOUR_DESKTOP,
177 wxSYS_COLOUR_3DSHADOW,
178 wxSYS_COLOUR_3DHIGHLIGHT,
179 wxSYS_COLOUR_3DHILIGHT,
180 wxSYS_COLOUR_BTNHILIGHT,
193 wxSYS_HSCROLL_ARROW_X,
194 wxSYS_HSCROLL_ARROW_Y,
210 wxSYS_VSCROLL_ARROW_X,
211 wxSYS_VSCROLL_ARROW_Y,
215 wxSYS_NETWORK_PRESENT,
216 wxSYS_PENWINDOWS_PRESENT,
225 wxColour wxSystemSettings_GetSystemColour(int index) {
226 return wxSystemSettings::GetSystemColour(index);
229 wxFont wxSystemSettings_GetSystemFont(int index) {
230 return wxSystemSettings::GetSystemFont(index);
233 int wxSystemSettings_GetSystemMetric(int index) {
234 return wxSystemSettings::GetSystemMetric(index);
238 //---------------------------------------------------------------------------
243 wxToolTip(const wxString &tip);
245 void SetTip(const wxString& tip);
247 // *** Not in the "public" interface void SetWindow(wxWindow *win);
248 wxWindow *GetWindow();
253 void wxToolTip_Enable(bool flag) {
254 wxToolTip::Enable(flag);
257 void wxToolTip_SetDelay(long milliseconds) {
258 wxToolTip::SetDelay(milliseconds);
262 //----------------------------------------------------------------------
266 wxCaret(wxWindow* window, const wxSize& size);
271 %name(GetPositionTuple)void GetPosition(int *OUTPUT, int *OUTPUT);
272 wxPoint GetPosition();
273 %name(GetSizeTuple)void GetSize(int *OUTPUT, int *OUTPUT);
275 wxWindow *GetWindow();
276 %name(MoveXY)void Move(int x, int y);
277 void Move(const wxPoint& pt);
278 %name(SetSizeWH) void SetSize(int width, int height);
279 void SetSize(const wxSize& size);
280 void Show(int show = TRUE);
285 int wxCaret_GetBlinkTime() {
286 return wxCaret::GetBlinkTime();
289 void wxCaret_SetBlinkTime(int milliseconds) {
290 wxCaret::SetBlinkTime(milliseconds);
294 //----------------------------------------------------------------------
297 class wxPyFontEnumerator : public wxFontEnumerator {
299 wxPyFontEnumerator() {}
300 ~wxPyFontEnumerator() {}
302 DEC_PYCALLBACK_BOOL_STRING(OnFacename);
303 DEC_PYCALLBACK_BOOL_STRINGSTRING(OnFontEncoding);
308 IMP_PYCALLBACK_BOOL_STRING(wxPyFontEnumerator, wxFontEnumerator, OnFacename);
309 IMP_PYCALLBACK_BOOL_STRINGSTRING(wxPyFontEnumerator, wxFontEnumerator, OnFontEncoding);
313 %name(wxFontEnumerator) class wxPyFontEnumerator {
315 wxPyFontEnumerator();
316 ~wxPyFontEnumerator();
317 void _setSelf(PyObject* self, PyObject* _class);
318 %pragma(python) addtomethod = "__init__:self._setSelf(self, wxFontEnumerator)"
320 bool EnumerateFacenames(
321 wxFontEncoding encoding = wxFONTENCODING_SYSTEM, // all
322 bool fixedWidthOnly = FALSE);
323 bool EnumerateEncodings(const char* facename = "");
325 //wxArrayString* GetEncodings();
326 //wxArrayString* GetFacenames();
328 PyObject* GetEncodings() {
329 wxArrayString* arr = self->GetEncodings();
330 PyObject* list = PyList_New(0);
331 for (size_t x=0; x<arr->GetCount(); x++)
332 PyList_Append(list, PyString_FromString((*arr)[x]));
336 PyObject* GetFacenames() {
337 wxArrayString* arr = self->GetFacenames();
338 PyObject* list = PyList_New(0);
339 for (size_t x=0; x<arr->GetCount(); x++)
340 PyList_Append(list, PyString_FromString((*arr)[x]));
346 //----------------------------------------------------------------------
350 wxBusyCursor(wxCursor* cursor = wxHOURGLASS_CURSOR);
354 //----------------------------------------------------------------------
356 void wxPostEvent(wxEvtHandler *dest, wxEvent& event);
359 //----------------------------------------------------------------------
365 // wxTipProvider(size_t currentTip); **** Abstract base class
368 virtual wxString GetTip() = 0;
369 size_t GetCurrentTip();
374 // The C++ version of wxPyTipProvider
376 class wxPyTipProvider : public wxTipProvider {
378 wxPyTipProvider(size_t currentTip)
379 : wxTipProvider(currentTip) {}
381 DEC_PYCALLBACK_STRING__pure(GetTip);
386 IMP_PYCALLBACK_STRING__pure( wxPyTipProvider, wxTipProvider, GetTip);
391 // Now let SWIG know about it
392 class wxPyTipProvider : public wxTipProvider {
394 wxPyTipProvider(size_t currentTip);
399 bool wxShowTip(wxWindow *parent, wxTipProvider *tipProvider, bool showAtStartup = TRUE);
400 %new wxTipProvider * wxCreateFileTipProvider(const wxString& filename, size_t currentTip);
403 //----------------------------------------------------------------------
406 #include <wx/generic/dragimgg.h>
407 static wxPoint wxPyNullPoint;
410 %name (wxDragImage) class wxGenericDragImage
414 wxGenericDragImage(const wxBitmap& image,
415 const wxCursor& cursor = wxNullCursor,
416 const wxPoint& hotspot = wxPyNullPoint);
417 ~wxGenericDragImage();
419 bool BeginDrag(const wxPoint& hotspot, wxWindow* window,
420 bool fullScreen = FALSE, wxRect* rect = NULL);
422 %name(BeginDrag2) bool BeginDrag(const wxPoint& hotspot, wxWindow* window,
423 wxWindow* fullScreenRect);
426 bool Move(const wxPoint& pt);
430 wxRect GetImageRect(const wxPoint& pos) const;
431 bool RedrawImage(const wxPoint& oldPos, const wxPoint& newPos,
432 bool eraseOld, bool drawNew);
436 // Alternate Constructors
437 %new wxGenericDragImage* wxDragIcon(const wxIcon& image,
438 const wxCursor& cursor = wxNullCursor,
439 const wxPoint& hotspot = wxPyNullPoint);
441 %new wxGenericDragImage* wxDragString(const wxString& str,
442 const wxCursor& cursor = wxNullCursor,
443 const wxPoint& hotspot = wxPyNullPoint);
445 %new wxGenericDragImage* wxDragTreeItem(const wxTreeCtrl& treeCtrl, wxTreeItemId& id);
447 %new wxGenericDragImage* wxDragListItem(const wxListCtrl& listCtrl, long id);
452 wxGenericDragImage* wxDragIcon(const wxIcon& image,
453 const wxCursor& cursor,
454 const wxPoint& hotspot) {
455 return new wxGenericDragImage(image, cursor, hotspot);
458 wxGenericDragImage* wxDragString(const wxString& str,
459 const wxCursor& cursor,
460 const wxPoint& hotspot) {
461 return new wxGenericDragImage(str, cursor, hotspot);
464 wxGenericDragImage* wxDragTreeItem(const wxTreeCtrl& treeCtrl, wxTreeItemId& id) {
465 return new wxGenericDragImage(treeCtrl, id);
468 wxGenericDragImage* wxDragListItem(const wxListCtrl& listCtrl, long id) {
469 return new wxGenericDragImage(listCtrl, id);
476 //----------------------------------------------------------------------
480 wxPyTimer(PyObject* notify);
485 void SetOwner(wxEvtHandler *owner, int id = -1);
486 void Start(int milliseconds=-1, int oneShot=FALSE);
490 //----------------------------------------------------------------------
491 //----------------------------------------------------------------------
496 wxLOG_FatalError, // program can't continue, abort immediately
497 wxLOG_Error, // a serious error, user must be informed about it
498 wxLOG_Warning, // user is normally informed about it but may be ignored
499 wxLOG_Message, // normal message (i.e. normal output of a non GUI app)
500 wxLOG_Info, // informational message (a.k.a. 'Verbose')
501 wxLOG_Status, // informational: might go to the status line of GUI app
502 wxLOG_Debug, // never shown to the user, disabled in release mode
503 wxLOG_Trace, // trace messages are also only enabled in debug mode
504 wxLOG_Progress, // used for progress indicator (not yet)
505 wxLOG_User = 100 // user defined levels start here
514 static bool IsEnabled();
515 static bool EnableLogging(bool doIt = TRUE);
516 static void OnLog(wxLogLevel level, const char *szString, int t=0);
518 virtual void Flush();
519 bool HasPendingMessages() const;
521 static void FlushActive();
522 static wxLog *GetActiveTarget();
523 static wxLog *SetActiveTarget(wxLog *pLogger);
525 static void Suspend();
526 static void Resume();
528 void SetVerbose(bool bVerbose = TRUE);
530 static void DontCreateOnDemand();
531 static void SetTraceMask(wxTraceMask ulMask);
532 static void AddTraceMask(const wxString& str);
533 static void RemoveTraceMask(const wxString& str);
535 bool GetVerbose() const { return m_bVerbose; }
537 static wxTraceMask GetTraceMask();
538 static bool IsAllowedTraceMask(const char *mask);
543 class wxLogStderr : public wxLog
546 wxLogStderr(/* TODO: FILE *fp = (FILE *) NULL*/);
550 class wxLogTextCtrl : public wxLog
553 wxLogTextCtrl(wxTextCtrl *pTextCtrl);
557 class wxLogGui : public wxLog
563 class wxLogWindow : public wxLog
566 wxLogWindow(wxFrame *pParent, // the parent frame (can be NULL)
567 const char *szTitle, // the title of the frame
568 bool bShow = TRUE, // show window immediately?
569 bool bPassToOld = TRUE); // pass log messages to the old target?
571 void Show(bool bShow = TRUE);
572 wxFrame *GetFrame() const;
573 wxLog *GetOldLog() const;
574 bool IsPassingMessages() const;
575 void PassMessages(bool bDoPass) { m_bPassMessages = bDoPass; }
587 unsigned long wxSysErrorCode();
588 const char* wxSysErrorMsg(unsigned long nErrCode = 0);
589 void wxLogFatalError(const char *szFormat);
590 void wxLogError(const char *szFormat);
591 void wxLogWarning(const char *szFormat);
592 void wxLogMessage(const char *szFormat);
593 void wxLogInfo(const char *szFormat);
594 void wxLogVerbose(const char *szFormat);
595 void wxLogStatus(const char *szFormat);
596 %name(wxLogStatusFrame)void wxLogStatus(wxFrame *pFrame, const char *szFormat);
597 void wxLogSysError(const char *szFormat);
600 //----------------------------------------------------------------------
601 //----------------------------------------------------------------------