]> git.saurik.com Git - wxWidgets.git/blob - wxPython/src/misc2.i
Fixed a bunch of embarassing reference leaks
[wxWidgets.git] / wxPython / src / misc2.i
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: misc2.i
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.)
6 //
7 // Author: Robin Dunn
8 //
9 // Created: 18-June-1999
10 // RCS-ID: $Id$
11 // Copyright: (c) 1998 by Total Control Software
12 // Licence: wxWindows license
13 /////////////////////////////////////////////////////////////////////////////
14
15 %module misc2
16
17 %{
18 #include "helpers.h"
19 #include "pyistream.h"
20 #include <wx/resource.h>
21 #include <wx/tooltip.h>
22 #include <wx/caret.h>
23 #include <wx/tipdlg.h>
24 #include <wx/process.h>
25
26 #if wxUSE_JOYSTICK || defined(__WXMSW__)
27 #include <wx/joystick.h>
28 #endif
29
30 #if wxUSE_WAVE || defined(__WXMSW__)
31 #include <wx/wave.h>
32 #endif
33
34 #include <wx/mimetype.h>
35 %}
36
37 //----------------------------------------------------------------------
38
39 %include typemaps.i
40 %include my_typemaps.i
41
42 // Import some definitions of other classes, etc.
43 %import _defs.i
44 %import windows.i
45 %import misc.i
46 %import gdi.i
47 %import events.i
48 %import streams.i
49 %import utils.i
50
51
52 //----------------------------------------------------------------------
53
54 %{
55 // Put some wx default wxChar* values into wxStrings.
56 DECLARE_DEF_STRING(FileSelectorPromptStr);
57 DECLARE_DEF_STRING(FileSelectorDefaultWildcardStr);
58 DECLARE_DEF_STRING(DirSelectorPromptStr);
59 static const wxString wxPyEmptyString(wxT(""));
60 %}
61
62 //---------------------------------------------------------------------------
63 // Dialog Functions
64
65 wxString wxFileSelector(const wxString& message = wxPyFileSelectorPromptStr,
66 const wxString& default_path = wxPyEmptyString,
67 const wxString& default_filename = wxPyEmptyString,
68 const wxString& default_extension = wxPyEmptyString,
69 const wxString& wildcard = wxPyFileSelectorDefaultWildcardStr,
70 int flags = 0,
71 wxWindow *parent = NULL,
72 int x = -1, int y = -1);
73
74 // Ask for filename to load
75 wxString wxLoadFileSelector(const wxString& what,
76 const wxString& extension,
77 const wxString& default_name = wxPyEmptyString,
78 wxWindow *parent = NULL);
79
80 // Ask for filename to save
81 wxString wxSaveFileSelector(const wxString& what,
82 const wxString& extension,
83 const wxString& default_name = wxPyEmptyString,
84 wxWindow *parent = NULL);
85
86
87 wxString wxDirSelector(const wxString& message = wxPyDirSelectorPromptStr,
88 const wxString& defaultPath = wxPyEmptyString,
89 long style = wxDD_DEFAULT_STYLE,
90 const wxPoint& pos = wxDefaultPosition,
91 wxWindow *parent = NULL);
92
93 wxString wxGetTextFromUser(const wxString& message,
94 const wxString& caption = wxPyEmptyString,
95 const wxString& default_value = wxPyEmptyString,
96 wxWindow *parent = NULL,
97 int x = -1, int y = -1,
98 bool centre = TRUE);
99
100 wxString wxGetPasswordFromUser(const wxString& message,
101 const wxString& caption = wxPyEmptyString,
102 const wxString& default_value = wxPyEmptyString,
103 wxWindow *parent = NULL);
104
105
106 // TODO: Need to custom wrap this one...
107 // int wxGetMultipleChoice(char* message, char* caption,
108 // int LCOUNT, char** choices,
109 // int nsel, int *selection,
110 // wxWindow *parent = NULL, int x = -1, int y = -1,
111 // bool centre = TRUE, int width=150, int height=200);
112
113
114 wxString wxGetSingleChoice(const wxString& message, const wxString& caption,
115 int LCOUNT, wxString* choices,
116 wxWindow *parent = NULL,
117 int x = -1, int y = -1,
118 bool centre = TRUE,
119 int width=150, int height=200);
120
121 int wxGetSingleChoiceIndex(const wxString& message, const wxString& caption,
122 int LCOUNT, wxString* choices,
123 wxWindow *parent = NULL,
124 int x = -1, int y = -1,
125 bool centre = TRUE,
126 int width=150, int height=200);
127
128
129 int wxMessageBox(const wxString& message,
130 const wxString& caption = wxPyEmptyString,
131 int style = wxOK | wxCENTRE,
132 wxWindow *parent = NULL,
133 int x = -1, int y = -1);
134
135 long wxGetNumberFromUser(const wxString& message,
136 const wxString& prompt,
137 const wxString& caption,
138 long value,
139 long min = 0, long max = 100,
140 wxWindow *parent = NULL,
141 const wxPoint& pos = wxDefaultPosition);
142
143 //---------------------------------------------------------------------------
144 // GDI Functions
145
146 bool wxColourDisplay();
147
148 int wxDisplayDepth();
149 int wxGetDisplayDepth();
150
151 void wxDisplaySize(int* OUTPUT, int* OUTPUT);
152 wxSize wxGetDisplaySize();
153
154 void wxDisplaySizeMM(int* OUTPUT, int* OUTPUT);
155 wxSize wxGetDisplaySizeMM();
156
157 void wxClientDisplayRect(int *OUTPUT, int *OUTPUT, int *OUTPUT, int *OUTPUT);
158 wxRect wxGetClientDisplayRect();
159
160 void wxSetCursor(wxCursor& cursor);
161
162 //----------------------------------------------------------------------
163 // Miscellaneous functions
164
165 void wxBeginBusyCursor(wxCursor *cursor = wxHOURGLASS_CURSOR);
166 wxWindow * wxGetActiveWindow();
167
168 wxWindow* wxGenericFindWindowAtPoint(const wxPoint& pt);
169 wxWindow* wxFindWindowAtPoint(const wxPoint& pt);
170
171 #ifdef __WXMSW__
172 bool wxCheckForInterrupt(wxWindow *wnd);
173 void wxFlushEvents();
174 #endif
175
176 wxWindow* wxGetTopLevelParent(wxWindow *win);
177
178 //---------------------------------------------------------------------------
179 // Resource System
180
181 bool wxResourceAddIdentifier(char* name, int value);
182 void wxResourceClear(void);
183 wxBitmap wxResourceCreateBitmap(char* resource);
184 wxIcon wxResourceCreateIcon(char* resource);
185 wxMenuBar * wxResourceCreateMenuBar(char* resource);
186 int wxResourceGetIdentifier(char* name);
187 bool wxResourceParseData(char* resource, wxResourceTable *table = NULL);
188 bool wxResourceParseFile(char* filename, wxResourceTable *table = NULL);
189 bool wxResourceParseString(char* resource, wxResourceTable *table = NULL);
190
191 //---------------------------------------------------------------------------
192 // System Settings
193
194 // possible values for wxSystemSettings::GetFont() parameter
195 //
196 enum wxSystemFont
197 {
198 wxSYS_OEM_FIXED_FONT = 10,
199 wxSYS_ANSI_FIXED_FONT,
200 wxSYS_ANSI_VAR_FONT,
201 wxSYS_SYSTEM_FONT,
202 wxSYS_DEVICE_DEFAULT_FONT,
203 wxSYS_DEFAULT_PALETTE,
204 wxSYS_SYSTEM_FIXED_FONT,
205 wxSYS_DEFAULT_GUI_FONT
206 };
207
208 // possible values for wxSystemSettings::GetColour() parameter
209 //
210 enum wxSystemColour
211 {
212 wxSYS_COLOUR_SCROLLBAR,
213 wxSYS_COLOUR_BACKGROUND,
214 wxSYS_COLOUR_DESKTOP = wxSYS_COLOUR_BACKGROUND,
215 wxSYS_COLOUR_ACTIVECAPTION,
216 wxSYS_COLOUR_INACTIVECAPTION,
217 wxSYS_COLOUR_MENU,
218 wxSYS_COLOUR_WINDOW,
219 wxSYS_COLOUR_WINDOWFRAME,
220 wxSYS_COLOUR_MENUTEXT,
221 wxSYS_COLOUR_WINDOWTEXT,
222 wxSYS_COLOUR_CAPTIONTEXT,
223 wxSYS_COLOUR_ACTIVEBORDER,
224 wxSYS_COLOUR_INACTIVEBORDER,
225 wxSYS_COLOUR_APPWORKSPACE,
226 wxSYS_COLOUR_HIGHLIGHT,
227 wxSYS_COLOUR_HIGHLIGHTTEXT,
228 wxSYS_COLOUR_BTNFACE,
229 wxSYS_COLOUR_3DFACE = wxSYS_COLOUR_BTNFACE,
230 wxSYS_COLOUR_BTNSHADOW,
231 wxSYS_COLOUR_3DSHADOW = wxSYS_COLOUR_BTNSHADOW,
232 wxSYS_COLOUR_GRAYTEXT,
233 wxSYS_COLOUR_BTNTEXT,
234 wxSYS_COLOUR_INACTIVECAPTIONTEXT,
235 wxSYS_COLOUR_BTNHIGHLIGHT,
236 wxSYS_COLOUR_BTNHILIGHT = wxSYS_COLOUR_BTNHIGHLIGHT,
237 wxSYS_COLOUR_3DHIGHLIGHT = wxSYS_COLOUR_BTNHIGHLIGHT,
238 wxSYS_COLOUR_3DHILIGHT = wxSYS_COLOUR_BTNHIGHLIGHT,
239 wxSYS_COLOUR_3DDKSHADOW,
240 wxSYS_COLOUR_3DLIGHT,
241 wxSYS_COLOUR_INFOTEXT,
242 wxSYS_COLOUR_INFOBK,
243 wxSYS_COLOUR_LISTBOX,
244 wxSYS_COLOUR_HOTLIGHT,
245 wxSYS_COLOUR_GRADIENTACTIVECAPTION,
246 wxSYS_COLOUR_GRADIENTINACTIVECAPTION,
247 wxSYS_COLOUR_MENUHILIGHT,
248 wxSYS_COLOUR_MENUBAR,
249
250 wxSYS_COLOUR_MAX
251 };
252
253 // possible values for wxSystemSettings::GetMetric() parameter
254 //
255 enum wxSystemMetric
256 {
257 wxSYS_MOUSE_BUTTONS = 1,
258 wxSYS_BORDER_X,
259 wxSYS_BORDER_Y,
260 wxSYS_CURSOR_X,
261 wxSYS_CURSOR_Y,
262 wxSYS_DCLICK_X,
263 wxSYS_DCLICK_Y,
264 wxSYS_DRAG_X,
265 wxSYS_DRAG_Y,
266 wxSYS_EDGE_X,
267 wxSYS_EDGE_Y,
268 wxSYS_HSCROLL_ARROW_X,
269 wxSYS_HSCROLL_ARROW_Y,
270 wxSYS_HTHUMB_X,
271 wxSYS_ICON_X,
272 wxSYS_ICON_Y,
273 wxSYS_ICONSPACING_X,
274 wxSYS_ICONSPACING_Y,
275 wxSYS_WINDOWMIN_X,
276 wxSYS_WINDOWMIN_Y,
277 wxSYS_SCREEN_X,
278 wxSYS_SCREEN_Y,
279 wxSYS_FRAMESIZE_X,
280 wxSYS_FRAMESIZE_Y,
281 wxSYS_SMALLICON_X,
282 wxSYS_SMALLICON_Y,
283 wxSYS_HSCROLL_Y,
284 wxSYS_VSCROLL_X,
285 wxSYS_VSCROLL_ARROW_X,
286 wxSYS_VSCROLL_ARROW_Y,
287 wxSYS_VTHUMB_Y,
288 wxSYS_CAPTION_Y,
289 wxSYS_MENU_Y,
290 wxSYS_NETWORK_PRESENT,
291 wxSYS_PENWINDOWS_PRESENT,
292 wxSYS_SHOW_SOUNDS,
293 wxSYS_SWAP_BUTTONS
294 };
295
296 // possible values for wxSystemSettings::HasFeature() parameter
297 enum wxSystemFeature
298 {
299 wxSYS_CAN_DRAW_FRAME_DECORATIONS = 1,
300 wxSYS_CAN_ICONIZE_FRAME
301 };
302
303 enum wxSystemScreenType
304 {
305 wxSYS_SCREEN_NONE = 0, // not yet defined
306
307 wxSYS_SCREEN_TINY, // <
308 wxSYS_SCREEN_PDA, // >= 320x240
309 wxSYS_SCREEN_SMALL, // >= 640x480
310 wxSYS_SCREEN_DESKTOP // >= 800x600
311 };
312
313
314 class wxSystemSettings {
315 public:
316 // get a standard system colour
317 static wxColour GetColour(wxSystemColour index);
318
319 // get a standard system font
320 static wxFont GetFont(wxSystemFont index);
321
322 // get a system-dependent metric
323 static int GetMetric(wxSystemMetric index);
324
325 // return true if the port has certain feature
326 static bool HasFeature(wxSystemFeature index);
327
328 // Get system screen design (desktop, pda, ..) used for
329 // laying out various dialogs.
330 static wxSystemScreenType GetScreenType();
331
332 // Override default.
333 static void SetScreenType( wxSystemScreenType screen );
334
335 };
336
337
338
339 //---------------------------------------------------------------------------
340 // wxToolTip
341
342 class wxToolTip : public wxObject {
343 public:
344 wxToolTip(const wxString &tip);
345
346 void SetTip(const wxString& tip);
347 wxString GetTip();
348 // *** Not in the "public" interface void SetWindow(wxWindow *win);
349 wxWindow *GetWindow();
350
351 static void Enable(bool flag);
352 static void SetDelay(long milliseconds);
353 };
354
355 //----------------------------------------------------------------------
356
357 class wxCaret {
358 public:
359 wxCaret(wxWindow* window, const wxSize& size);
360 ~wxCaret();
361
362 bool IsOk();
363 bool IsVisible();
364 %name(GetPositionTuple)void GetPosition(int *OUTPUT, int *OUTPUT);
365 wxPoint GetPosition();
366 %name(GetSizeTuple)void GetSize(int *OUTPUT, int *OUTPUT);
367 wxSize GetSize();
368 wxWindow *GetWindow();
369 %name(MoveXY)void Move(int x, int y);
370 void Move(const wxPoint& pt);
371 %name(SetSizeWH) void SetSize(int width, int height);
372 void SetSize(const wxSize& size);
373 void Show(int show = TRUE);
374 void Hide();
375 };
376
377 %inline %{
378 int wxCaret_GetBlinkTime() {
379 return wxCaret::GetBlinkTime();
380 }
381
382 void wxCaret_SetBlinkTime(int milliseconds) {
383 wxCaret::SetBlinkTime(milliseconds);
384 }
385 %}
386
387 //----------------------------------------------------------------------
388
389 class wxBusyCursor {
390 public:
391 wxBusyCursor(wxCursor* cursor = wxHOURGLASS_CURSOR);
392 ~wxBusyCursor();
393 };
394
395 //----------------------------------------------------------------------
396
397 class wxWindowDisabler {
398 public:
399 wxWindowDisabler(wxWindow *winToSkip = NULL);
400 ~wxWindowDisabler();
401 };
402
403 //----------------------------------------------------------------------
404
405 bool wxSafeYield(wxWindow* win=NULL);
406 void wxPostEvent(wxEvtHandler *dest, wxEvent& event);
407 void wxWakeUpIdle();
408
409
410 #ifdef __WXMSW__
411 void wxWakeUpMainThread();
412 #endif
413
414 void wxMutexGuiEnter();
415 void wxMutexGuiLeave();
416
417
418 class wxMutexGuiLocker {
419 public:
420 wxMutexGuiLocker();
421 ~wxMutexGuiLocker();
422 };
423
424
425 %inline %{
426 bool wxThread_IsMain() {
427 #ifdef WXP_WITH_THREAD
428 return wxThread::IsMain();
429 #else
430 return TRUE;
431 #endif
432 }
433 %}
434
435 //----------------------------------------------------------------------
436
437
438 class wxTipProvider
439 {
440 public:
441 // wxTipProvider(size_t currentTip); **** Abstract base class
442 ~wxTipProvider();
443
444 virtual wxString GetTip() = 0;
445 size_t GetCurrentTip();
446
447 };
448
449
450 // The C++ version of wxPyTipProvider
451 %{
452 class wxPyTipProvider : public wxTipProvider {
453 public:
454 wxPyTipProvider(size_t currentTip)
455 : wxTipProvider(currentTip) {}
456
457 DEC_PYCALLBACK_STRING__pure(GetTip);
458
459 PYPRIVATE;
460 };
461
462 IMP_PYCALLBACK_STRING__pure( wxPyTipProvider, wxTipProvider, GetTip);
463
464 %}
465
466
467 // Now let SWIG know about it
468 class wxPyTipProvider : public wxTipProvider {
469 public:
470 wxPyTipProvider(size_t currentTip);
471 };
472
473
474
475 bool wxShowTip(wxWindow *parent, wxTipProvider *tipProvider, bool showAtStartup = TRUE);
476 %new wxTipProvider * wxCreateFileTipProvider(const wxString& filename, size_t currentTip);
477
478
479 //----------------------------------------------------------------------
480
481 %{
482 #include <wx/generic/dragimgg.h>
483 %}
484
485 %name (wxDragImage) class wxGenericDragImage : public wxObject
486 {
487 public:
488
489 wxGenericDragImage(const wxBitmap& image,
490 const wxCursor& cursor = wxNullCursor);
491 %name(wxDragIcon)wxGenericDragImage(const wxIcon& image,
492 const wxCursor& cursor = wxNullCursor);
493 %name(wxDragString)wxGenericDragImage(const wxString& str,
494 const wxCursor& cursor = wxNullCursor);
495 %name(wxDragTreeItem)wxGenericDragImage(const wxTreeCtrl& treeCtrl, wxTreeItemId& id);
496 %name(wxDragListItem)wxGenericDragImage(const wxListCtrl& listCtrl, long id);
497
498 ~wxGenericDragImage();
499
500 void SetBackingBitmap(wxBitmap* bitmap);
501 bool BeginDrag(const wxPoint& hotspot, wxWindow* window,
502 bool fullScreen = FALSE, wxRect* rect = NULL);
503
504 %name(BeginDrag2) bool BeginDrag(const wxPoint& hotspot, wxWindow* window,
505 wxWindow* fullScreenRect);
506
507 bool EndDrag();
508 bool Move(const wxPoint& pt);
509 bool Show();
510 bool Hide();
511
512 wxRect GetImageRect(const wxPoint& pos) const;
513 bool RedrawImage(const wxPoint& oldPos, const wxPoint& newPos,
514 bool eraseOld, bool drawNew);
515 };
516
517
518 //----------------------------------------------------------------------
519
520 class wxPyTimer : public wxObject {
521 public:
522 wxPyTimer(PyObject* notify);
523 ~wxPyTimer();
524 int GetInterval();
525 bool IsOneShot();
526 bool IsRunning();
527 void SetOwner(wxEvtHandler *owner, int id = -1);
528 void Start(int milliseconds=-1, int oneShot=FALSE);
529 void Stop();
530 };
531
532
533 class wxStopWatch
534 {
535 public:
536 // ctor starts the stop watch
537 wxStopWatch();
538 ~wxStopWatch();
539 void Start(long t = 0);
540 void Pause();
541 void Resume();
542
543 // get elapsed time since the last Start() or Pause() in milliseconds
544 long Time() const;
545 };
546
547
548 //----------------------------------------------------------------------
549 //----------------------------------------------------------------------
550
551
552 enum
553 {
554 wxLOG_FatalError, // program can't continue, abort immediately
555 wxLOG_Error, // a serious error, user must be informed about it
556 wxLOG_Warning, // user is normally informed about it but may be ignored
557 wxLOG_Message, // normal message (i.e. normal output of a non GUI app)
558 wxLOG_Info, // informational message (a.k.a. 'Verbose')
559 wxLOG_Status, // informational: might go to the status line of GUI app
560 wxLOG_Debug, // never shown to the user, disabled in release mode
561 wxLOG_Trace, // trace messages are also only enabled in debug mode
562 wxLOG_Progress, // used for progress indicator (not yet)
563 wxLOG_User = 100 // user defined levels start here
564 };
565
566
567 class wxLog
568 {
569 public:
570 wxLog();
571
572 static bool IsEnabled();
573 static bool EnableLogging(bool doIt = TRUE);
574 static void OnLog(wxLogLevel level, const wxString& szString, int t=0);
575
576 virtual void Flush();
577 bool HasPendingMessages() const;
578
579 static void FlushActive();
580 static wxLog *GetActiveTarget();
581 static wxLog *SetActiveTarget(wxLog *pLogger);
582
583 static void Suspend();
584 static void Resume();
585
586 static void SetVerbose(bool bVerbose = TRUE);
587
588 static void DontCreateOnDemand();
589 static void SetTraceMask(wxTraceMask ulMask);
590 static void AddTraceMask(const wxString& str);
591 static void RemoveTraceMask(const wxString& str);
592 static void ClearTraceMasks();
593
594 static void SetTimestamp(const wxString& ts);
595 static const wxString& GetTimestamp();
596
597 bool GetVerbose() const;
598
599 static wxTraceMask GetTraceMask();
600 static bool IsAllowedTraceMask(const wxString& mask);
601
602 // static void TimeStamp(wxString *str);
603 %addmethods {
604 wxString TimeStamp() {
605 wxString msg;
606 wxLog::TimeStamp(&msg);
607 return msg;
608 }
609 }
610
611 };
612
613
614 class wxLogStderr : public wxLog
615 {
616 public:
617 wxLogStderr(/* TODO: FILE *fp = (FILE *) NULL*/);
618 };
619
620
621 class wxLogTextCtrl : public wxLog
622 {
623 public:
624 wxLogTextCtrl(wxTextCtrl *pTextCtrl);
625 };
626
627
628 class wxLogGui : public wxLog
629 {
630 public:
631 wxLogGui();
632 };
633
634 class wxLogWindow : public wxLog
635 {
636 public:
637 wxLogWindow(wxFrame *pParent, // the parent frame (can be NULL)
638 const wxString& szTitle, // the title of the frame
639 bool bShow = TRUE, // show window immediately?
640 bool bPassToOld = TRUE); // pass log messages to the old target?
641
642 void Show(bool bShow = TRUE);
643 wxFrame *GetFrame() const;
644 wxLog *GetOldLog() const;
645 bool IsPassingMessages() const;
646 void PassMessages(bool bDoPass);
647 };
648
649
650 class wxLogChain : public wxLog
651 {
652 public:
653 wxLogChain(wxLog *logger);
654 void SetLog(wxLog *logger);
655 void PassMessages(bool bDoPass);
656 bool IsPassingMessages();
657 wxLog *GetOldLog();
658 };
659
660
661 unsigned long wxSysErrorCode();
662 const wxString wxSysErrorMsg(unsigned long nErrCode = 0);
663 void wxLogFatalError(const wxString& szFormat);
664 void wxLogError(const wxString& szFormat);
665 void wxLogWarning(const wxString& szFormat);
666 void wxLogMessage(const wxString& szFormat);
667 void wxLogInfo(const wxString& szFormat);
668 void wxLogVerbose(const wxString& szFormat);
669 void wxLogStatus(const wxString& szFormat);
670 %name(wxLogStatusFrame)void wxLogStatus(wxFrame *pFrame, const wxString& szFormat);
671 void wxLogSysError(const wxString& szFormat);
672
673 // wxLogFatalError helper: show the (fatal) error to the user in a safe way,
674 // i.e. without using wxMessageBox() for example because it could crash
675 void wxSafeShowMessage(const wxString& title, const wxString& text);
676
677
678
679 // Suspress logging while an instance of this class exists
680 class wxLogNull
681 {
682 public:
683 wxLogNull();
684 ~wxLogNull();
685 };
686
687
688
689
690 %{
691 // A wxLog class that can be derived from in wxPython
692 class wxPyLog : public wxLog {
693 public:
694 wxPyLog() : wxLog() {}
695
696 virtual void DoLog(wxLogLevel level, const wxChar *szString, time_t t) {
697 bool found;
698 wxPyBeginBlockThreads();
699 if ((found = wxPyCBH_findCallback(m_myInst, "DoLog"))) {
700 PyObject* s = wx2PyString(szString);
701 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iOi)", level, s, t));
702 Py_DECREF(s);
703 }
704 wxPyEndBlockThreads();
705 if (! found)
706 wxLog::DoLog(level, szString, t);
707 }
708
709 virtual void DoLogString(const wxChar *szString, time_t t) {
710 bool found;
711 wxPyBeginBlockThreads();
712 if ((found = wxPyCBH_findCallback(m_myInst, "DoLogString"))) {
713 PyObject* s = wx2PyString(szString);
714 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oi)", s, t));
715 Py_DECREF(s);
716 }
717 wxPyEndBlockThreads();
718 if (! found)
719 wxLog::DoLogString(szString, t);
720 }
721
722 PYPRIVATE;
723 };
724 %}
725
726 // Now tell SWIG about it
727 class wxPyLog : public wxLog {
728 public:
729 wxPyLog();
730 void _setCallbackInfo(PyObject* self, PyObject* _class);
731 %pragma(python) addtomethod = "__init__:self._setCallbackInfo(self, wxPyLog)"
732 %addmethods { void Destroy() { delete self; } }
733
734 };
735
736
737 //----------------------------------------------------------------------
738
739
740 enum {
741 /* event type */
742 wxEVT_END_PROCESS
743 };
744
745
746 class wxProcessEvent : public wxEvent {
747 public:
748 wxProcessEvent(int id = 0, int pid = 0, int exitcode = 0);
749 int GetPid();
750 int GetExitCode();
751 int m_pid, m_exitcode;
752 };
753
754
755
756
757 %{ // C++ version of wxProcess derived class
758
759 class wxPyProcess : public wxProcess {
760 public:
761 wxPyProcess(wxEvtHandler *parent = NULL, int id = -1)
762 : wxProcess(parent, id)
763 {}
764
765 DEC_PYCALLBACK_VOID_INTINT(OnTerminate);
766
767 PYPRIVATE;
768 };
769
770 IMP_PYCALLBACK_VOID_INTINT( wxPyProcess, wxProcess, OnTerminate);
771
772 %}
773
774
775 %name(wxProcess)class wxPyProcess : public wxEvtHandler {
776 public:
777 wxPyProcess(wxEvtHandler *parent = NULL, int id = -1);
778 %addmethods { void Destroy() { delete self; } }
779
780 void _setCallbackInfo(PyObject* self, PyObject* _class);
781 %pragma(python) addtomethod = "__init__:self._setCallbackInfo(self, wxProcess)"
782
783 void base_OnTerminate(int pid, int status);
784
785 void Redirect();
786 bool IsRedirected();
787 void Detach();
788
789 wxInputStream *GetInputStream();
790 wxInputStream *GetErrorStream();
791 wxOutputStream *GetOutputStream();
792
793 void CloseOutput();
794 };
795
796
797 enum
798 {
799 // execute the process asynchronously
800 wxEXEC_ASYNC = 0,
801
802 // execute it synchronously, i.e. wait until it finishes
803 wxEXEC_SYNC = 1,
804
805 // under Windows, don't hide the child even if it's IO is redirected (this
806 // is done by default)
807 wxEXEC_NOHIDE = 2,
808
809 // under Unix, if the process is the group leader then killing -pid kills
810 // all children as well as pid
811 wxEXEC_MAKE_GROUP_LEADER = 4
812 };
813
814
815 long wxExecute(const wxString& command,
816 int flags = wxEXEC_ASYNC,
817 wxPyProcess *process = NULL);
818
819 //----------------------------------------------------------------------
820
821 %{
822 #if !wxUSE_JOYSTICK && !defined(__WXMSW__)
823 // A C++ stub class for wxJoystick for platforms that don't have it.
824 class wxJoystick : public wxObject {
825 public:
826 wxJoystick(int joystick = wxJOYSTICK1) {
827 wxPyBeginBlockThreads();
828 PyErr_SetString(PyExc_NotImplementedError, "wxJoystick is not available on this platform.");
829 wxPyEndBlockThreads();
830 }
831 wxPoint GetPosition() { return wxPoint(-1,-1); }
832 int GetZPosition() { return -1; }
833 int GetButtonState() { return -1; }
834 int GetPOVPosition() { return -1; }
835 int GetPOVCTSPosition() { return -1; }
836 int GetRudderPosition() { return -1; }
837 int GetUPosition() { return -1; }
838 int GetVPosition() { return -1; }
839 int GetMovementThreshold() { return -1; }
840 void SetMovementThreshold(int threshold) {}
841
842 bool IsOk(void) { return FALSE; }
843 int GetNumberJoysticks() { return -1; }
844 int GetManufacturerId() { return -1; }
845 int GetProductId() { return -1; }
846 wxString GetProductName() { return ""; }
847 int GetXMin() { return -1; }
848 int GetYMin() { return -1; }
849 int GetZMin() { return -1; }
850 int GetXMax() { return -1; }
851 int GetYMax() { return -1; }
852 int GetZMax() { return -1; }
853 int GetNumberButtons() { return -1; }
854 int GetNumberAxes() { return -1; }
855 int GetMaxButtons() { return -1; }
856 int GetMaxAxes() { return -1; }
857 int GetPollingMin() { return -1; }
858 int GetPollingMax() { return -1; }
859 int GetRudderMin() { return -1; }
860 int GetRudderMax() { return -1; }
861 int GetUMin() { return -1; }
862 int GetUMax() { return -1; }
863 int GetVMin() { return -1; }
864 int GetVMax() { return -1; }
865
866 bool HasRudder() { return FALSE; }
867 bool HasZ() { return FALSE; }
868 bool HasU() { return FALSE; }
869 bool HasV() { return FALSE; }
870 bool HasPOV() { return FALSE; }
871 bool HasPOV4Dir() { return FALSE; }
872 bool HasPOVCTS() { return FALSE; }
873
874 bool SetCapture(wxWindow* win, int pollingFreq = 0) { return FALSE; }
875 bool ReleaseCapture() { return FALSE; }
876 };
877 #endif
878 %}
879
880
881 class wxJoystick : public wxObject {
882 public:
883 wxJoystick(int joystick = wxJOYSTICK1);
884 ~wxJoystick();
885
886 wxPoint GetPosition();
887 int GetZPosition();
888 int GetButtonState();
889 int GetPOVPosition();
890 int GetPOVCTSPosition();
891 int GetRudderPosition();
892 int GetUPosition();
893 int GetVPosition();
894 int GetMovementThreshold();
895 void SetMovementThreshold(int threshold) ;
896
897 bool IsOk(void);
898 int GetNumberJoysticks();
899 int GetManufacturerId();
900 int GetProductId();
901 wxString GetProductName();
902 int GetXMin();
903 int GetYMin();
904 int GetZMin();
905 int GetXMax();
906 int GetYMax();
907 int GetZMax();
908 int GetNumberButtons();
909 int GetNumberAxes();
910 int GetMaxButtons();
911 int GetMaxAxes();
912 int GetPollingMin();
913 int GetPollingMax();
914 int GetRudderMin();
915 int GetRudderMax();
916 int GetUMin();
917 int GetUMax();
918 int GetVMin();
919 int GetVMax();
920
921 bool HasRudder();
922 bool HasZ();
923 bool HasU();
924 bool HasV();
925 bool HasPOV();
926 bool HasPOV4Dir();
927 bool HasPOVCTS();
928
929 bool SetCapture(wxWindow* win, int pollingFreq = 0);
930 bool ReleaseCapture();
931 };
932
933 //----------------------------------------------------------------------
934
935 %{
936 #if !wxUSE_WAVE
937 // A C++ stub class for wxWave for platforms that don't have it.
938 class wxWave : public wxObject
939 {
940 public:
941 wxWave(const wxString& fileName, bool isResource = FALSE) {
942 wxPyBeginBlockThreads();
943 PyErr_SetString(PyExc_NotImplementedError, "wxWave is not available on this platform.");
944 wxPyEndBlockThreads();
945 }
946 wxWave(int size, const wxByte* data) {
947 wxPyBeginBlockThreads();
948 PyErr_SetString(PyExc_NotImplementedError, "wxWave is not available on this platform.");
949 wxPyEndBlockThreads();
950 }
951
952 ~wxWave() {}
953
954 bool IsOk() const { return FALSE; }
955 bool Play(bool async = TRUE, bool looped = FALSE) const { return FALSE; }
956 };
957
958 #endif
959 %}
960
961 class wxWave : public wxObject
962 {
963 public:
964 wxWave(const wxString& fileName, bool isResource = FALSE);
965 ~wxWave();
966
967 bool IsOk() const;
968 bool Play(bool async = TRUE, bool looped = FALSE) const;
969 };
970
971 %new wxWave* wxWaveData(const wxString& data);
972 %{ // Implementations of some alternate "constructors"
973 wxWave* wxWaveData(const wxString& data) {
974 return new wxWave(data.Len(), (wxByte*)data.c_str());
975 }
976 %}
977
978
979 //----------------------------------------------------------------------
980
981 enum wxMailcapStyle
982 {
983 wxMAILCAP_STANDARD = 1,
984 wxMAILCAP_NETSCAPE = 2,
985 wxMAILCAP_KDE = 4,
986 wxMAILCAP_GNOME = 8,
987
988 wxMAILCAP_ALL = 15
989 };
990
991
992
993 class wxFileTypeInfo
994 {
995 public:
996 // ctors
997 // a normal item
998 wxFileTypeInfo(const char* mimeType,
999 const char* openCmd,
1000 const char* printCmd,
1001 const char* desc);
1002
1003
1004 // the array elements correspond to the parameters of the ctor above in
1005 // the same order
1006 %name(wxFileTypeInfoSequence)wxFileTypeInfo(const wxArrayString& sArray);
1007
1008 // invalid item - use this to terminate the array passed to
1009 // wxMimeTypesManager::AddFallbacks
1010 %name(wxNullFileTypeInfo)wxFileTypeInfo();
1011
1012
1013 // test if this object can be used
1014 bool IsValid() const;
1015
1016 // setters
1017 // set the icon info
1018 void SetIcon(const wxString& iconFile, int iconIndex = 0);
1019
1020 // set the short desc
1021 void SetShortDesc(const wxString& shortDesc);
1022
1023 // accessors
1024 // get the MIME type
1025 const wxString& GetMimeType() const;
1026 // get the open command
1027 const wxString& GetOpenCommand() const;
1028 // get the print command
1029 const wxString& GetPrintCommand() const;
1030 // get the short description (only used under Win32 so far)
1031 const wxString& GetShortDesc() const;
1032 // get the long, user visible description
1033 const wxString& GetDescription() const;
1034
1035
1036 // get the array of all extensions
1037 //const wxArrayString& GetExtensions() const;
1038 %addmethods {
1039 PyObject* GetExtensions() {
1040 wxArrayString& arr = (wxArrayString&)self->GetExtensions();
1041 return wxArrayString2PyList_helper(arr);
1042 }
1043 }
1044
1045 int GetExtensionsCount() const;
1046
1047 // get the icon info
1048 const wxString& GetIconFile() const;
1049 int GetIconIndex() const;
1050 };
1051
1052
1053
1054
1055 class wxFileType
1056 {
1057 public:
1058
1059 // TODO: Make a wxPyMessageParameters with virtual GetParamValue...
1060
1061 // An object of this class must be passed to Get{Open|Print}Command. The
1062 // default implementation is trivial and doesn't know anything at all about
1063 // parameters, only filename and MIME type are used (so it's probably ok for
1064 // Windows where %{param} is not used anyhow)
1065 class MessageParameters
1066 {
1067 public:
1068 // ctors
1069 MessageParameters(const wxString& filename=wxPyEmptyString,
1070 const wxString& mimetype=wxPyEmptyString);
1071
1072 // accessors (called by GetOpenCommand)
1073 // filename
1074 const wxString& GetFileName() const;
1075 // mime type
1076 const wxString& GetMimeType() const;;
1077
1078 // override this function in derived class
1079 virtual wxString GetParamValue(const wxString& name) const;
1080
1081 // virtual dtor as in any base class
1082 virtual ~MessageParameters();
1083 };
1084
1085
1086 // ctor from static data
1087 wxFileType(const wxFileTypeInfo& ftInfo);
1088
1089 // return the MIME type for this file type
1090 %addmethods {
1091 PyObject* GetMimeType() {
1092 wxString str;
1093 if (self->GetMimeType(&str)) {
1094 #if wxUSE_UNICODE
1095 return PyUnicode_FromUnicode(str.c_str(), str.Len());
1096 #else
1097 return PyString_FromStringAndSize(str.c_str(), str.Len());
1098 #endif
1099 }
1100 else
1101 RETURN_NONE();
1102 }
1103 PyObject* GetMimeTypes() {
1104 wxArrayString arr;
1105 if (self->GetMimeTypes(arr))
1106 return wxArrayString2PyList_helper(arr);
1107 else
1108 RETURN_NONE();
1109 }
1110 }
1111
1112
1113 // Get all extensions associated with this file type
1114 %addmethods {
1115 PyObject* GetExtensions() {
1116 wxArrayString arr;
1117 if (self->GetExtensions(arr))
1118 return wxArrayString2PyList_helper(arr);
1119 else
1120 RETURN_NONE();
1121 }
1122 }
1123
1124
1125 %addmethods {
1126 // Get the icon corresponding to this file type
1127 %new wxIcon* GetIcon() {
1128 wxIcon icon;
1129 if (self->GetIcon(&icon))
1130 return new wxIcon(icon);
1131 else
1132 return NULL;
1133 }
1134
1135 // Get the icon corresponding to this file type, the name of the file
1136 // where this icon resides, and its index in this file if applicable.
1137 PyObject* GetIconInfo() {
1138 wxIcon icon;
1139 wxString iconFile;
1140 int iconIndex;
1141 if (self->GetIcon(&icon, &iconFile, &iconIndex)) {
1142 wxPyBeginBlockThreads();
1143 PyObject* tuple = PyTuple_New(3);
1144 PyTuple_SetItem(tuple, 0, wxPyConstructObject(new wxIcon(icon),
1145 "wxIcon", TRUE));
1146 #if wxUSE_UNICODE
1147 PyTuple_SetItem(tuple, 1, PyUnicode_FromUnicode(iconFile.c_str(), iconFile.Len()));
1148 #else
1149 PyTuple_SetItem(tuple, 1, PyString_FromStringAndSize(iconFile.c_str(), iconFile.Len()));
1150 #endif
1151 PyTuple_SetItem(tuple, 2, PyInt_FromLong(iconIndex));
1152 wxPyEndBlockThreads();
1153 return tuple;
1154 }
1155 else
1156 RETURN_NONE();
1157 }
1158 }
1159
1160 %addmethods {
1161 // get a brief file type description ("*.txt" => "text document")
1162 PyObject* GetDescription() {
1163 wxString str;
1164 if (self->GetDescription(&str)) {
1165 #if wxUSE_UNICODE
1166 return PyUnicode_FromUnicode(str.c_str(), str.Len());
1167 #else
1168 return PyString_FromStringAndSize(str.c_str(), str.Len());
1169 #endif
1170 } else
1171 RETURN_NONE();
1172 }
1173 }
1174
1175
1176 // get the command to open/execute the file of given type
1177 %addmethods {
1178 PyObject* GetOpenCommand(const wxString& filename,
1179 const wxString& mimetype=wxPyEmptyString) {
1180 wxString str;
1181 if (self->GetOpenCommand(&str, wxFileType::MessageParameters(filename, mimetype))) {
1182 #if wxUSE_UNICODE
1183 return PyUnicode_FromUnicode(str.c_str(), str.Len());
1184 #else
1185 return PyString_FromStringAndSize(str.c_str(), str.Len());
1186 #endif
1187 } else
1188 RETURN_NONE();
1189 }
1190 }
1191
1192
1193 // get the command to print the file of given type
1194 %addmethods {
1195 PyObject* GetPrintCommand(const wxString& filename,
1196 const wxString& mimetype=wxPyEmptyString) {
1197 wxString str;
1198 if (self->GetPrintCommand(&str, wxFileType::MessageParameters(filename, mimetype))) {
1199 #if wxUSE_UNICODE
1200 return PyUnicode_FromUnicode(str.c_str(), str.Len());
1201 #else
1202 return PyString_FromStringAndSize(str.c_str(), str.Len());
1203 #endif
1204 } else
1205 RETURN_NONE();
1206 }
1207 }
1208
1209
1210 // Get all commands defined for this file type
1211 %addmethods {
1212 PyObject* GetAllCommands(const wxString& filename,
1213 const wxString& mimetype=wxPyEmptyString) {
1214 wxArrayString verbs;
1215 wxArrayString commands;
1216 if (self->GetAllCommands(&verbs, &commands,
1217 wxFileType::MessageParameters(filename, mimetype))) {
1218 wxPyBeginBlockThreads();
1219 PyObject* tuple = PyTuple_New(2);
1220 PyTuple_SetItem(tuple, 0, wxArrayString2PyList_helper(verbs));
1221 PyTuple_SetItem(tuple, 1, wxArrayString2PyList_helper(commands));
1222 wxPyEndBlockThreads();
1223 return tuple;
1224 }
1225 else
1226 RETURN_NONE();
1227 }
1228 }
1229
1230
1231 // set an arbitrary command, ask confirmation if it already exists and
1232 // overwriteprompt is TRUE
1233 bool SetCommand(const wxString& cmd, const wxString& verb,
1234 bool overwriteprompt = TRUE);
1235
1236 bool SetDefaultIcon(const wxString& cmd = wxPyEmptyString, int index = 0);
1237
1238
1239 // remove the association for this filetype from the system MIME database:
1240 // notice that it will only work if the association is defined in the user
1241 // file/registry part, we will never modify the system-wide settings
1242 bool Unassociate();
1243
1244 // operations
1245 // expand a string in the format of GetOpenCommand (which may contain
1246 // '%s' and '%t' format specificators for the file name and mime type
1247 // and %{param} constructions).
1248 static wxString ExpandCommand(const wxString& command,
1249 const MessageParameters& params);
1250
1251 // dtor (not virtual, shouldn't be derived from)
1252 ~wxFileType();
1253
1254 };
1255
1256
1257
1258
1259 class wxMimeTypesManager
1260 {
1261 public:
1262 // static helper functions
1263 // -----------------------
1264
1265 // check if the given MIME type is the same as the other one: the
1266 // second argument may contain wildcards ('*'), but not the first. If
1267 // the types are equal or if the mimeType matches wildcard the function
1268 // returns TRUE, otherwise it returns FALSE
1269 static bool IsOfType(const wxString& mimeType, const wxString& wildcard);
1270
1271 // ctor
1272 wxMimeTypesManager();
1273
1274 // loads data from standard files according to the mailcap styles
1275 // specified: this is a bitwise OR of wxMailcapStyle values
1276 //
1277 // use the extraDir parameter if you want to look for files in another
1278 // directory
1279 void Initialize(int mailcapStyle = wxMAILCAP_STANDARD,
1280 const wxString& extraDir = wxPyEmptyString);
1281
1282 // and this function clears all the data from the manager
1283 void ClearData();
1284
1285 // Database lookup: all functions return a pointer to wxFileType object
1286 // whose methods may be used to query it for the information you're
1287 // interested in. If the return value is !NULL, caller is responsible for
1288 // deleting it.
1289 // get file type from file extension
1290 %new wxFileType *GetFileTypeFromExtension(const wxString& ext);
1291
1292 // get file type from MIME type (in format <category>/<format>)
1293 %new wxFileType *GetFileTypeFromMimeType(const wxString& mimeType);
1294
1295 // other operations: return TRUE if there were no errors or FALSE if there
1296 // were some unreckognized entries (the good entries are always read anyhow)
1297 //
1298
1299 // read in additional file (the standard ones are read automatically)
1300 // in mailcap format (see mimetype.cpp for description)
1301 //
1302 // 'fallback' parameter may be set to TRUE to avoid overriding the
1303 // settings from other, previously parsed, files by this one: normally,
1304 // the files read most recently would override the older files, but with
1305 // fallback == TRUE this won't happen
1306 bool ReadMailcap(const wxString& filename, bool fallback = FALSE);
1307
1308 // read in additional file in mime.types format
1309 bool ReadMimeTypes(const wxString& filename);
1310
1311 // enumerate all known MIME types
1312 %addmethods {
1313 PyObject* EnumAllFileTypes() {
1314 wxArrayString arr;
1315 self->EnumAllFileTypes(arr);
1316 return wxArrayString2PyList_helper(arr);
1317 }
1318 }
1319
1320 // these functions can be used to provide default values for some of the
1321 // MIME types inside the program itself (you may also use
1322 // ReadMailcap(filenameWithDefaultTypes, TRUE /* use as fallback */) to
1323 // achieve the same goal, but this requires having this info in a file).
1324 //
1325 void AddFallback(const wxFileTypeInfo& ft);
1326
1327
1328 // create or remove associations
1329
1330 // create a new association using the fields of wxFileTypeInfo (at least
1331 // the MIME type and the extension should be set)
1332 // if the other fields are empty, the existing values should be left alone
1333 %new wxFileType *Associate(const wxFileTypeInfo& ftInfo);
1334
1335 // undo Associate()
1336 bool Unassociate(wxFileType *ft) ;
1337
1338 // dtor (not virtual, shouldn't be derived from)
1339 ~wxMimeTypesManager();
1340 };
1341
1342
1343 %readonly
1344 %{
1345 #if 0
1346 %}
1347 extern wxMimeTypesManager* wxTheMimeTypesManager;
1348 %{
1349 #endif
1350 %}
1351 %readwrite
1352
1353 //----------------------------------------------------------------------
1354
1355 %{
1356 #include <wx/artprov.h>
1357
1358 DECLARE_DEF_STRING(ART_OTHER);
1359
1360 %}
1361
1362 // Art clients
1363 #define wxART_TOOLBAR "toolbar_C"
1364 #define wxART_MENU "menu_C"
1365 #define wxART_FRAME_ICON "frame_icon_C"
1366
1367 #define wxART_CMN_DIALOG "cmn_dialog_C"
1368 #define wxART_HELP_BROWSER "help_browser_C"
1369 #define wxART_MESSAGE_BOX "message_box_C"
1370
1371 #define wxART_OTHER "other_C"
1372
1373 // Art IDs
1374 #define wxART_ADD_BOOKMARK "add_bookmark"
1375 #define wxART_DEL_BOOKMARK "del_bookmark"
1376 #define wxART_HELP_SIDE_PANEL "help_side_panel"
1377 #define wxART_HELP_SETTINGS "help_settings"
1378 #define wxART_HELP_BOOK "help_book"
1379 #define wxART_HELP_FOLDER "help_folder"
1380 #define wxART_HELP_PAGE "help_page"
1381 #define wxART_GO_BACK "go_back"
1382 #define wxART_GO_FORWARD "go_forward"
1383 #define wxART_GO_UP "go_up"
1384 #define wxART_GO_DOWN "go_down"
1385 #define wxART_GO_TO_PARENT "go_to_parent"
1386 #define wxART_GO_HOME "go_home"
1387 #define wxART_FILE_OPEN "file_open"
1388 #define wxART_PRINT "print"
1389 #define wxART_HELP "help"
1390 #define wxART_TIP "tip"
1391 #define wxART_REPORT_VIEW "report_view"
1392 #define wxART_LIST_VIEW "list_view"
1393 #define wxART_NEW_DIR "new_dir"
1394 #define wxART_FOLDER "folder"
1395 #define wxART_GO_DIR_UP "go_dir_up"
1396 #define wxART_EXECUTABLE_FILE "executable_file"
1397 #define wxART_NORMAL_FILE "normal_file"
1398 #define wxART_TICK_MARK "tick"
1399 #define wxART_CROSS_MARK "cross"
1400 #define wxART_ERROR "error"
1401 #define wxART_QUESTION "question"
1402 #define wxART_WARNING "warning"
1403 #define wxART_INFORMATION "information"
1404
1405
1406 %{ // Python aware wxArtProvider
1407 class wxPyArtProvider : public wxArtProvider {
1408 public:
1409
1410 virtual wxBitmap CreateBitmap(const wxArtID& id,
1411 const wxArtClient& client,
1412 const wxSize& size) {
1413 wxBitmap rval = wxNullBitmap;
1414 wxPyBeginBlockThreads();
1415 if ((wxPyCBH_findCallback(m_myInst, "CreateBitmap"))) {
1416 PyObject* so = wxPyConstructObject((void*)&size, "wxSize", 0);
1417 PyObject* ro;
1418 wxBitmap* ptr;
1419 PyObject* s1, *s2;
1420 s1 = wx2PyString(id);
1421 s2 = wx2PyString(client);
1422 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(OOO)", s1, s2, so));
1423 Py_DECREF(so);
1424 Py_DECREF(s1);
1425 Py_DECREF(s2);
1426 if (ro) {
1427 if (!SWIG_GetPtrObj(ro, (void**)&ptr, "_wxBitmap_p"))
1428 rval = *ptr;
1429 Py_DECREF(ro);
1430 }
1431 }
1432 wxPyEndBlockThreads();
1433 return rval;
1434 }
1435
1436 PYPRIVATE;
1437 };
1438 %}
1439
1440 // The one for SWIG to see
1441 %name(wxArtProvider) class wxPyArtProvider : public wxObject
1442 {
1443 public:
1444 wxPyArtProvider();
1445
1446 void _setCallbackInfo(PyObject* self, PyObject* _class);
1447 %pragma(python) addtomethod = "__init__:self._setCallbackInfo(self, wxArtProvider)"
1448
1449 // Add new provider to the top of providers stack.
1450 static void PushProvider(wxPyArtProvider *provider);
1451
1452 // Remove latest added provider and delete it.
1453 static bool PopProvider();
1454
1455 // Remove provider. The provider must have been added previously!
1456 // The provider is _not_ deleted.
1457 static bool RemoveProvider(wxPyArtProvider *provider);
1458
1459 // Query the providers for bitmap with given ID and return it. Return
1460 // wxNullBitmap if no provider provides it.
1461 static wxBitmap GetBitmap(const wxString& id,
1462 const wxString& client = wxPyART_OTHER,
1463 const wxSize& size = wxDefaultSize);
1464
1465 // Query the providers for icon with given ID and return it. Return
1466 // wxNullIcon if no provider provides it.
1467 static wxIcon GetIcon(const wxString& id,
1468 const wxString& client = wxPyART_OTHER,
1469 const wxSize& size = wxDefaultSize);
1470
1471 // Destroy caches & all providers
1472 static void CleanUpProviders();
1473 };
1474
1475
1476 //----------------------------------------------------------------------
1477
1478 %{
1479 #include <wx/docview.h>
1480 %}
1481
1482 class wxFileHistory : public wxObject
1483 {
1484 public:
1485 wxFileHistory(int maxFiles = 9);
1486 ~wxFileHistory();
1487
1488 // Operations
1489 void AddFileToHistory(const wxString& file);
1490 void RemoveFileFromHistory(int i);
1491 int GetMaxFiles() const;
1492 void UseMenu(wxMenu *menu);
1493
1494 // Remove menu from the list (MDI child may be closing)
1495 void RemoveMenu(wxMenu *menu);
1496
1497 void Load(wxConfigBase& config);
1498 void Save(wxConfigBase& config);
1499
1500 void AddFilesToMenu();
1501 %name(AddFilesToThisMenu)void AddFilesToMenu(wxMenu* menu);
1502
1503 // Accessors
1504 wxString GetHistoryFile(int i) const;
1505
1506 // A synonym for GetNoHistoryFiles
1507 int GetCount() const;
1508 int GetNoHistoryFiles() const;
1509
1510 };
1511
1512 //----------------------------------------------------------------------
1513 //----------------------------------------------------------------------
1514
1515
1516 %init %{
1517 wxPyPtrTypeMap_Add("wxDragImage", "wxGenericDragImage");
1518 wxPyPtrTypeMap_Add("wxProcess", "wxPyProcess");
1519 wxPyPtrTypeMap_Add("wxArtProvider", "wxPyArtProvider");
1520 %}
1521
1522 //----------------------------------------------------------------------
1523