]> git.saurik.com Git - wxWidgets.git/blob - wxPython/src/misc2.i
Some trace log updates
[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 #define wxTRACE_MemAlloc "memalloc" // trace memory allocation (new/delete)
567 #define wxTRACE_Messages "messages" // trace window messages/X callbacks
568 #define wxTRACE_ResAlloc "resalloc" // trace GDI resource allocation
569 #define wxTRACE_RefCount "refcount" // trace various ref counting operations
570
571 #ifdef __WXMSW__
572 #define wxTRACE_OleCalls "ole" // OLE interface calls
573 #endif
574
575 enum {
576 wxTraceMemAlloc,
577 wxTraceMessages,
578 wxTraceResAlloc,
579 wxTraceRefCount,
580
581 #ifdef __WXMSW__
582 wxTraceOleCalls,
583 #endif
584 };
585
586
587
588 class wxLog
589 {
590 public:
591 wxLog();
592
593 static bool IsEnabled();
594 static bool EnableLogging(bool doIt = TRUE);
595 static void OnLog(unsigned long level, const wxString& szString, int t=0);
596
597 virtual void Flush();
598 bool HasPendingMessages() const;
599
600 static void FlushActive();
601 static wxLog *GetActiveTarget();
602 static wxLog *SetActiveTarget(wxLog *pLogger);
603
604 static void Suspend();
605 static void Resume();
606
607 static void SetVerbose(bool bVerbose = TRUE);
608
609 static void DontCreateOnDemand();
610 static void SetTraceMask(long ulMask);
611 static void AddTraceMask(const wxString& str);
612 static void RemoveTraceMask(const wxString& str);
613 static void ClearTraceMasks();
614
615 static void SetTimestamp(const wxString& ts);
616 static const wxString& GetTimestamp();
617
618 bool GetVerbose() const;
619
620 static wxTraceMask GetTraceMask();
621 static bool IsAllowedTraceMask(const wxString& mask);
622
623 // static void TimeStamp(wxString *str);
624 %addmethods {
625 wxString TimeStamp() {
626 wxString msg;
627 wxLog::TimeStamp(&msg);
628 return msg;
629 }
630 }
631
632 };
633
634
635 class wxLogStderr : public wxLog
636 {
637 public:
638 wxLogStderr(/* TODO: FILE *fp = (FILE *) NULL*/);
639 };
640
641
642 class wxLogTextCtrl : public wxLog
643 {
644 public:
645 wxLogTextCtrl(wxTextCtrl *pTextCtrl);
646 };
647
648
649 class wxLogGui : public wxLog
650 {
651 public:
652 wxLogGui();
653 };
654
655 class wxLogWindow : public wxLog
656 {
657 public:
658 wxLogWindow(wxFrame *pParent, // the parent frame (can be NULL)
659 const wxString& szTitle, // the title of the frame
660 bool bShow = TRUE, // show window immediately?
661 bool bPassToOld = TRUE); // pass log messages to the old target?
662
663 void Show(bool bShow = TRUE);
664 wxFrame *GetFrame() const;
665 wxLog *GetOldLog() const;
666 bool IsPassingMessages() const;
667 void PassMessages(bool bDoPass);
668 };
669
670
671 class wxLogChain : public wxLog
672 {
673 public:
674 wxLogChain(wxLog *logger);
675 void SetLog(wxLog *logger);
676 void PassMessages(bool bDoPass);
677 bool IsPassingMessages();
678 wxLog *GetOldLog();
679 };
680
681
682 unsigned long wxSysErrorCode();
683 const wxString wxSysErrorMsg(unsigned long nErrCode = 0);
684 void wxLogFatalError(const wxString& szFormat);
685 void wxLogError(const wxString& szFormat);
686 void wxLogWarning(const wxString& szFormat);
687 void wxLogMessage(const wxString& szFormat);
688 void wxLogInfo(const wxString& szFormat);
689 void wxLogVerbose(const wxString& szFormat);
690 void wxLogStatus(const wxString& szFormat);
691 %name(wxLogStatusFrame)void wxLogStatus(wxFrame *pFrame, const wxString& szFormat);
692 void wxLogSysError(const wxString& szFormat);
693
694 // wxLogFatalError helper: show the (fatal) error to the user in a safe way,
695 // i.e. without using wxMessageBox() for example because it could crash
696 void wxSafeShowMessage(const wxString& title, const wxString& text);
697
698
699
700 // Suspress logging while an instance of this class exists
701 class wxLogNull
702 {
703 public:
704 wxLogNull();
705 ~wxLogNull();
706 };
707
708
709
710
711 %{
712 // A wxLog class that can be derived from in wxPython
713 class wxPyLog : public wxLog {
714 public:
715 wxPyLog() : wxLog() {}
716
717 virtual void DoLog(wxLogLevel level, const wxChar *szString, time_t t) {
718 bool found;
719 wxPyBeginBlockThreads();
720 if ((found = wxPyCBH_findCallback(m_myInst, "DoLog"))) {
721 PyObject* s = wx2PyString(szString);
722 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iOi)", level, s, t));
723 Py_DECREF(s);
724 }
725 wxPyEndBlockThreads();
726 if (! found)
727 wxLog::DoLog(level, szString, t);
728 }
729
730 virtual void DoLogString(const wxChar *szString, time_t t) {
731 bool found;
732 wxPyBeginBlockThreads();
733 if ((found = wxPyCBH_findCallback(m_myInst, "DoLogString"))) {
734 PyObject* s = wx2PyString(szString);
735 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oi)", s, t));
736 Py_DECREF(s);
737 }
738 wxPyEndBlockThreads();
739 if (! found)
740 wxLog::DoLogString(szString, t);
741 }
742
743 PYPRIVATE;
744 };
745 %}
746
747 // Now tell SWIG about it
748 class wxPyLog : public wxLog {
749 public:
750 wxPyLog();
751 void _setCallbackInfo(PyObject* self, PyObject* _class);
752 %pragma(python) addtomethod = "__init__:self._setCallbackInfo(self, wxPyLog)"
753 %addmethods { void Destroy() { delete self; } }
754
755 };
756
757
758 //----------------------------------------------------------------------
759
760
761 enum {
762 /* event type */
763 wxEVT_END_PROCESS
764 };
765
766
767 class wxProcessEvent : public wxEvent {
768 public:
769 wxProcessEvent(int id = 0, int pid = 0, int exitcode = 0);
770 int GetPid();
771 int GetExitCode();
772 int m_pid, m_exitcode;
773 };
774
775
776
777
778 %{ // C++ version of wxProcess derived class
779
780 class wxPyProcess : public wxProcess {
781 public:
782 wxPyProcess(wxEvtHandler *parent = NULL, int id = -1)
783 : wxProcess(parent, id)
784 {}
785
786 DEC_PYCALLBACK_VOID_INTINT(OnTerminate);
787
788 PYPRIVATE;
789 };
790
791 IMP_PYCALLBACK_VOID_INTINT( wxPyProcess, wxProcess, OnTerminate);
792
793 %}
794
795
796 %name(wxProcess)class wxPyProcess : public wxEvtHandler {
797 public:
798 wxPyProcess(wxEvtHandler *parent = NULL, int id = -1);
799 %addmethods { void Destroy() { delete self; } }
800
801 void _setCallbackInfo(PyObject* self, PyObject* _class);
802 %pragma(python) addtomethod = "__init__:self._setCallbackInfo(self, wxProcess)"
803
804 void base_OnTerminate(int pid, int status);
805
806 void Redirect();
807 bool IsRedirected();
808 void Detach();
809
810 wxInputStream *GetInputStream();
811 wxInputStream *GetErrorStream();
812 wxOutputStream *GetOutputStream();
813
814 void CloseOutput();
815 };
816
817
818 enum
819 {
820 // execute the process asynchronously
821 wxEXEC_ASYNC = 0,
822
823 // execute it synchronously, i.e. wait until it finishes
824 wxEXEC_SYNC = 1,
825
826 // under Windows, don't hide the child even if it's IO is redirected (this
827 // is done by default)
828 wxEXEC_NOHIDE = 2,
829
830 // under Unix, if the process is the group leader then killing -pid kills
831 // all children as well as pid
832 wxEXEC_MAKE_GROUP_LEADER = 4
833 };
834
835
836 long wxExecute(const wxString& command,
837 int flags = wxEXEC_ASYNC,
838 wxPyProcess *process = NULL);
839
840 //----------------------------------------------------------------------
841
842 %{
843 #if !wxUSE_JOYSTICK && !defined(__WXMSW__)
844 // A C++ stub class for wxJoystick for platforms that don't have it.
845 class wxJoystick : public wxObject {
846 public:
847 wxJoystick(int joystick = wxJOYSTICK1) {
848 wxPyBeginBlockThreads();
849 PyErr_SetString(PyExc_NotImplementedError, "wxJoystick is not available on this platform.");
850 wxPyEndBlockThreads();
851 }
852 wxPoint GetPosition() { return wxPoint(-1,-1); }
853 int GetZPosition() { return -1; }
854 int GetButtonState() { return -1; }
855 int GetPOVPosition() { return -1; }
856 int GetPOVCTSPosition() { return -1; }
857 int GetRudderPosition() { return -1; }
858 int GetUPosition() { return -1; }
859 int GetVPosition() { return -1; }
860 int GetMovementThreshold() { return -1; }
861 void SetMovementThreshold(int threshold) {}
862
863 bool IsOk(void) { return FALSE; }
864 int GetNumberJoysticks() { return -1; }
865 int GetManufacturerId() { return -1; }
866 int GetProductId() { return -1; }
867 wxString GetProductName() { return ""; }
868 int GetXMin() { return -1; }
869 int GetYMin() { return -1; }
870 int GetZMin() { return -1; }
871 int GetXMax() { return -1; }
872 int GetYMax() { return -1; }
873 int GetZMax() { return -1; }
874 int GetNumberButtons() { return -1; }
875 int GetNumberAxes() { return -1; }
876 int GetMaxButtons() { return -1; }
877 int GetMaxAxes() { return -1; }
878 int GetPollingMin() { return -1; }
879 int GetPollingMax() { return -1; }
880 int GetRudderMin() { return -1; }
881 int GetRudderMax() { return -1; }
882 int GetUMin() { return -1; }
883 int GetUMax() { return -1; }
884 int GetVMin() { return -1; }
885 int GetVMax() { return -1; }
886
887 bool HasRudder() { return FALSE; }
888 bool HasZ() { return FALSE; }
889 bool HasU() { return FALSE; }
890 bool HasV() { return FALSE; }
891 bool HasPOV() { return FALSE; }
892 bool HasPOV4Dir() { return FALSE; }
893 bool HasPOVCTS() { return FALSE; }
894
895 bool SetCapture(wxWindow* win, int pollingFreq = 0) { return FALSE; }
896 bool ReleaseCapture() { return FALSE; }
897 };
898 #endif
899 %}
900
901
902 class wxJoystick : public wxObject {
903 public:
904 wxJoystick(int joystick = wxJOYSTICK1);
905 ~wxJoystick();
906
907 wxPoint GetPosition();
908 int GetZPosition();
909 int GetButtonState();
910 int GetPOVPosition();
911 int GetPOVCTSPosition();
912 int GetRudderPosition();
913 int GetUPosition();
914 int GetVPosition();
915 int GetMovementThreshold();
916 void SetMovementThreshold(int threshold) ;
917
918 bool IsOk(void);
919 int GetNumberJoysticks();
920 int GetManufacturerId();
921 int GetProductId();
922 wxString GetProductName();
923 int GetXMin();
924 int GetYMin();
925 int GetZMin();
926 int GetXMax();
927 int GetYMax();
928 int GetZMax();
929 int GetNumberButtons();
930 int GetNumberAxes();
931 int GetMaxButtons();
932 int GetMaxAxes();
933 int GetPollingMin();
934 int GetPollingMax();
935 int GetRudderMin();
936 int GetRudderMax();
937 int GetUMin();
938 int GetUMax();
939 int GetVMin();
940 int GetVMax();
941
942 bool HasRudder();
943 bool HasZ();
944 bool HasU();
945 bool HasV();
946 bool HasPOV();
947 bool HasPOV4Dir();
948 bool HasPOVCTS();
949
950 bool SetCapture(wxWindow* win, int pollingFreq = 0);
951 bool ReleaseCapture();
952 };
953
954 //----------------------------------------------------------------------
955
956 %{
957 #if !wxUSE_WAVE
958 // A C++ stub class for wxWave for platforms that don't have it.
959 class wxWave : public wxObject
960 {
961 public:
962 wxWave(const wxString& fileName, bool isResource = FALSE) {
963 wxPyBeginBlockThreads();
964 PyErr_SetString(PyExc_NotImplementedError, "wxWave is not available on this platform.");
965 wxPyEndBlockThreads();
966 }
967 wxWave(int size, const wxByte* data) {
968 wxPyBeginBlockThreads();
969 PyErr_SetString(PyExc_NotImplementedError, "wxWave is not available on this platform.");
970 wxPyEndBlockThreads();
971 }
972
973 ~wxWave() {}
974
975 bool IsOk() const { return FALSE; }
976 bool Play(bool async = TRUE, bool looped = FALSE) const { return FALSE; }
977 };
978
979 #endif
980 %}
981
982 class wxWave : public wxObject
983 {
984 public:
985 wxWave(const wxString& fileName, bool isResource = FALSE);
986 ~wxWave();
987
988 bool IsOk() const;
989 bool Play(bool async = TRUE, bool looped = FALSE) const;
990 };
991
992 %new wxWave* wxWaveData(const wxString& data);
993 %{ // Implementations of some alternate "constructors"
994 wxWave* wxWaveData(const wxString& data) {
995 return new wxWave(data.Len(), (wxByte*)data.c_str());
996 }
997 %}
998
999
1000 //----------------------------------------------------------------------
1001
1002 enum wxMailcapStyle
1003 {
1004 wxMAILCAP_STANDARD = 1,
1005 wxMAILCAP_NETSCAPE = 2,
1006 wxMAILCAP_KDE = 4,
1007 wxMAILCAP_GNOME = 8,
1008
1009 wxMAILCAP_ALL = 15
1010 };
1011
1012
1013
1014 class wxFileTypeInfo
1015 {
1016 public:
1017 // ctors
1018 // a normal item
1019 wxFileTypeInfo(const char* mimeType,
1020 const char* openCmd,
1021 const char* printCmd,
1022 const char* desc);
1023
1024
1025 // the array elements correspond to the parameters of the ctor above in
1026 // the same order
1027 %name(wxFileTypeInfoSequence)wxFileTypeInfo(const wxArrayString& sArray);
1028
1029 // invalid item - use this to terminate the array passed to
1030 // wxMimeTypesManager::AddFallbacks
1031 %name(wxNullFileTypeInfo)wxFileTypeInfo();
1032
1033
1034 // test if this object can be used
1035 bool IsValid() const;
1036
1037 // setters
1038 // set the icon info
1039 void SetIcon(const wxString& iconFile, int iconIndex = 0);
1040
1041 // set the short desc
1042 void SetShortDesc(const wxString& shortDesc);
1043
1044 // accessors
1045 // get the MIME type
1046 const wxString& GetMimeType() const;
1047 // get the open command
1048 const wxString& GetOpenCommand() const;
1049 // get the print command
1050 const wxString& GetPrintCommand() const;
1051 // get the short description (only used under Win32 so far)
1052 const wxString& GetShortDesc() const;
1053 // get the long, user visible description
1054 const wxString& GetDescription() const;
1055
1056
1057 // get the array of all extensions
1058 //const wxArrayString& GetExtensions() const;
1059 %addmethods {
1060 PyObject* GetExtensions() {
1061 wxArrayString& arr = (wxArrayString&)self->GetExtensions();
1062 return wxArrayString2PyList_helper(arr);
1063 }
1064 }
1065
1066 int GetExtensionsCount() const;
1067
1068 // get the icon info
1069 const wxString& GetIconFile() const;
1070 int GetIconIndex() const;
1071 };
1072
1073
1074
1075
1076 class wxFileType
1077 {
1078 public:
1079
1080 // TODO: Make a wxPyMessageParameters with virtual GetParamValue...
1081
1082 // An object of this class must be passed to Get{Open|Print}Command. The
1083 // default implementation is trivial and doesn't know anything at all about
1084 // parameters, only filename and MIME type are used (so it's probably ok for
1085 // Windows where %{param} is not used anyhow)
1086 class MessageParameters
1087 {
1088 public:
1089 // ctors
1090 MessageParameters(const wxString& filename=wxPyEmptyString,
1091 const wxString& mimetype=wxPyEmptyString);
1092
1093 // accessors (called by GetOpenCommand)
1094 // filename
1095 const wxString& GetFileName() const;
1096 // mime type
1097 const wxString& GetMimeType() const;;
1098
1099 // override this function in derived class
1100 virtual wxString GetParamValue(const wxString& name) const;
1101
1102 // virtual dtor as in any base class
1103 virtual ~MessageParameters();
1104 };
1105
1106
1107 // ctor from static data
1108 wxFileType(const wxFileTypeInfo& ftInfo);
1109
1110 // return the MIME type for this file type
1111 %addmethods {
1112 PyObject* GetMimeType() {
1113 wxString str;
1114 if (self->GetMimeType(&str)) {
1115 #if wxUSE_UNICODE
1116 return PyUnicode_FromUnicode(str.c_str(), str.Len());
1117 #else
1118 return PyString_FromStringAndSize(str.c_str(), str.Len());
1119 #endif
1120 }
1121 else
1122 RETURN_NONE();
1123 }
1124 PyObject* GetMimeTypes() {
1125 wxArrayString arr;
1126 if (self->GetMimeTypes(arr))
1127 return wxArrayString2PyList_helper(arr);
1128 else
1129 RETURN_NONE();
1130 }
1131 }
1132
1133
1134 // Get all extensions associated with this file type
1135 %addmethods {
1136 PyObject* GetExtensions() {
1137 wxArrayString arr;
1138 if (self->GetExtensions(arr))
1139 return wxArrayString2PyList_helper(arr);
1140 else
1141 RETURN_NONE();
1142 }
1143 }
1144
1145
1146 %addmethods {
1147 // Get the icon corresponding to this file type
1148 %new wxIcon* GetIcon() {
1149 wxIcon icon;
1150 if (self->GetIcon(&icon))
1151 return new wxIcon(icon);
1152 else
1153 return NULL;
1154 }
1155
1156 // Get the icon corresponding to this file type, the name of the file
1157 // where this icon resides, and its index in this file if applicable.
1158 PyObject* GetIconInfo() {
1159 wxIcon icon;
1160 wxString iconFile;
1161 int iconIndex;
1162 if (self->GetIcon(&icon, &iconFile, &iconIndex)) {
1163 wxPyBeginBlockThreads();
1164 PyObject* tuple = PyTuple_New(3);
1165 PyTuple_SetItem(tuple, 0, wxPyConstructObject(new wxIcon(icon),
1166 "wxIcon", TRUE));
1167 #if wxUSE_UNICODE
1168 PyTuple_SetItem(tuple, 1, PyUnicode_FromUnicode(iconFile.c_str(), iconFile.Len()));
1169 #else
1170 PyTuple_SetItem(tuple, 1, PyString_FromStringAndSize(iconFile.c_str(), iconFile.Len()));
1171 #endif
1172 PyTuple_SetItem(tuple, 2, PyInt_FromLong(iconIndex));
1173 wxPyEndBlockThreads();
1174 return tuple;
1175 }
1176 else
1177 RETURN_NONE();
1178 }
1179 }
1180
1181 %addmethods {
1182 // get a brief file type description ("*.txt" => "text document")
1183 PyObject* GetDescription() {
1184 wxString str;
1185 if (self->GetDescription(&str)) {
1186 #if wxUSE_UNICODE
1187 return PyUnicode_FromUnicode(str.c_str(), str.Len());
1188 #else
1189 return PyString_FromStringAndSize(str.c_str(), str.Len());
1190 #endif
1191 } else
1192 RETURN_NONE();
1193 }
1194 }
1195
1196
1197 // get the command to open/execute the file of given type
1198 %addmethods {
1199 PyObject* GetOpenCommand(const wxString& filename,
1200 const wxString& mimetype=wxPyEmptyString) {
1201 wxString str;
1202 if (self->GetOpenCommand(&str, wxFileType::MessageParameters(filename, mimetype))) {
1203 #if wxUSE_UNICODE
1204 return PyUnicode_FromUnicode(str.c_str(), str.Len());
1205 #else
1206 return PyString_FromStringAndSize(str.c_str(), str.Len());
1207 #endif
1208 } else
1209 RETURN_NONE();
1210 }
1211 }
1212
1213
1214 // get the command to print the file of given type
1215 %addmethods {
1216 PyObject* GetPrintCommand(const wxString& filename,
1217 const wxString& mimetype=wxPyEmptyString) {
1218 wxString str;
1219 if (self->GetPrintCommand(&str, wxFileType::MessageParameters(filename, mimetype))) {
1220 #if wxUSE_UNICODE
1221 return PyUnicode_FromUnicode(str.c_str(), str.Len());
1222 #else
1223 return PyString_FromStringAndSize(str.c_str(), str.Len());
1224 #endif
1225 } else
1226 RETURN_NONE();
1227 }
1228 }
1229
1230
1231 // Get all commands defined for this file type
1232 %addmethods {
1233 PyObject* GetAllCommands(const wxString& filename,
1234 const wxString& mimetype=wxPyEmptyString) {
1235 wxArrayString verbs;
1236 wxArrayString commands;
1237 if (self->GetAllCommands(&verbs, &commands,
1238 wxFileType::MessageParameters(filename, mimetype))) {
1239 wxPyBeginBlockThreads();
1240 PyObject* tuple = PyTuple_New(2);
1241 PyTuple_SetItem(tuple, 0, wxArrayString2PyList_helper(verbs));
1242 PyTuple_SetItem(tuple, 1, wxArrayString2PyList_helper(commands));
1243 wxPyEndBlockThreads();
1244 return tuple;
1245 }
1246 else
1247 RETURN_NONE();
1248 }
1249 }
1250
1251
1252 // set an arbitrary command, ask confirmation if it already exists and
1253 // overwriteprompt is TRUE
1254 bool SetCommand(const wxString& cmd, const wxString& verb,
1255 bool overwriteprompt = TRUE);
1256
1257 bool SetDefaultIcon(const wxString& cmd = wxPyEmptyString, int index = 0);
1258
1259
1260 // remove the association for this filetype from the system MIME database:
1261 // notice that it will only work if the association is defined in the user
1262 // file/registry part, we will never modify the system-wide settings
1263 bool Unassociate();
1264
1265 // operations
1266 // expand a string in the format of GetOpenCommand (which may contain
1267 // '%s' and '%t' format specificators for the file name and mime type
1268 // and %{param} constructions).
1269 static wxString ExpandCommand(const wxString& command,
1270 const MessageParameters& params);
1271
1272 // dtor (not virtual, shouldn't be derived from)
1273 ~wxFileType();
1274
1275 };
1276
1277
1278
1279
1280 class wxMimeTypesManager
1281 {
1282 public:
1283 // static helper functions
1284 // -----------------------
1285
1286 // check if the given MIME type is the same as the other one: the
1287 // second argument may contain wildcards ('*'), but not the first. If
1288 // the types are equal or if the mimeType matches wildcard the function
1289 // returns TRUE, otherwise it returns FALSE
1290 static bool IsOfType(const wxString& mimeType, const wxString& wildcard);
1291
1292 // ctor
1293 wxMimeTypesManager();
1294
1295 // loads data from standard files according to the mailcap styles
1296 // specified: this is a bitwise OR of wxMailcapStyle values
1297 //
1298 // use the extraDir parameter if you want to look for files in another
1299 // directory
1300 void Initialize(int mailcapStyle = wxMAILCAP_STANDARD,
1301 const wxString& extraDir = wxPyEmptyString);
1302
1303 // and this function clears all the data from the manager
1304 void ClearData();
1305
1306 // Database lookup: all functions return a pointer to wxFileType object
1307 // whose methods may be used to query it for the information you're
1308 // interested in. If the return value is !NULL, caller is responsible for
1309 // deleting it.
1310 // get file type from file extension
1311 %new wxFileType *GetFileTypeFromExtension(const wxString& ext);
1312
1313 // get file type from MIME type (in format <category>/<format>)
1314 %new wxFileType *GetFileTypeFromMimeType(const wxString& mimeType);
1315
1316 // other operations: return TRUE if there were no errors or FALSE if there
1317 // were some unreckognized entries (the good entries are always read anyhow)
1318 //
1319
1320 // read in additional file (the standard ones are read automatically)
1321 // in mailcap format (see mimetype.cpp for description)
1322 //
1323 // 'fallback' parameter may be set to TRUE to avoid overriding the
1324 // settings from other, previously parsed, files by this one: normally,
1325 // the files read most recently would override the older files, but with
1326 // fallback == TRUE this won't happen
1327 bool ReadMailcap(const wxString& filename, bool fallback = FALSE);
1328
1329 // read in additional file in mime.types format
1330 bool ReadMimeTypes(const wxString& filename);
1331
1332 // enumerate all known MIME types
1333 %addmethods {
1334 PyObject* EnumAllFileTypes() {
1335 wxArrayString arr;
1336 self->EnumAllFileTypes(arr);
1337 return wxArrayString2PyList_helper(arr);
1338 }
1339 }
1340
1341 // these functions can be used to provide default values for some of the
1342 // MIME types inside the program itself (you may also use
1343 // ReadMailcap(filenameWithDefaultTypes, TRUE /* use as fallback */) to
1344 // achieve the same goal, but this requires having this info in a file).
1345 //
1346 void AddFallback(const wxFileTypeInfo& ft);
1347
1348
1349 // create or remove associations
1350
1351 // create a new association using the fields of wxFileTypeInfo (at least
1352 // the MIME type and the extension should be set)
1353 // if the other fields are empty, the existing values should be left alone
1354 %new wxFileType *Associate(const wxFileTypeInfo& ftInfo);
1355
1356 // undo Associate()
1357 bool Unassociate(wxFileType *ft) ;
1358
1359 // dtor (not virtual, shouldn't be derived from)
1360 ~wxMimeTypesManager();
1361 };
1362
1363
1364 %readonly
1365 %{
1366 #if 0
1367 %}
1368 extern wxMimeTypesManager* wxTheMimeTypesManager;
1369 %{
1370 #endif
1371 %}
1372 %readwrite
1373
1374 //----------------------------------------------------------------------
1375
1376 %{
1377 #include <wx/artprov.h>
1378
1379 DECLARE_DEF_STRING(ART_OTHER);
1380
1381 %}
1382
1383 // Art clients
1384 #define wxART_TOOLBAR "toolbar_C"
1385 #define wxART_MENU "menu_C"
1386 #define wxART_FRAME_ICON "frame_icon_C"
1387
1388 #define wxART_CMN_DIALOG "cmn_dialog_C"
1389 #define wxART_HELP_BROWSER "help_browser_C"
1390 #define wxART_MESSAGE_BOX "message_box_C"
1391
1392 #define wxART_OTHER "other_C"
1393
1394 // Art IDs
1395 #define wxART_ADD_BOOKMARK "add_bookmark"
1396 #define wxART_DEL_BOOKMARK "del_bookmark"
1397 #define wxART_HELP_SIDE_PANEL "help_side_panel"
1398 #define wxART_HELP_SETTINGS "help_settings"
1399 #define wxART_HELP_BOOK "help_book"
1400 #define wxART_HELP_FOLDER "help_folder"
1401 #define wxART_HELP_PAGE "help_page"
1402 #define wxART_GO_BACK "go_back"
1403 #define wxART_GO_FORWARD "go_forward"
1404 #define wxART_GO_UP "go_up"
1405 #define wxART_GO_DOWN "go_down"
1406 #define wxART_GO_TO_PARENT "go_to_parent"
1407 #define wxART_GO_HOME "go_home"
1408 #define wxART_FILE_OPEN "file_open"
1409 #define wxART_PRINT "print"
1410 #define wxART_HELP "help"
1411 #define wxART_TIP "tip"
1412 #define wxART_REPORT_VIEW "report_view"
1413 #define wxART_LIST_VIEW "list_view"
1414 #define wxART_NEW_DIR "new_dir"
1415 #define wxART_FOLDER "folder"
1416 #define wxART_GO_DIR_UP "go_dir_up"
1417 #define wxART_EXECUTABLE_FILE "executable_file"
1418 #define wxART_NORMAL_FILE "normal_file"
1419 #define wxART_TICK_MARK "tick"
1420 #define wxART_CROSS_MARK "cross"
1421 #define wxART_ERROR "error"
1422 #define wxART_QUESTION "question"
1423 #define wxART_WARNING "warning"
1424 #define wxART_INFORMATION "information"
1425
1426
1427 %{ // Python aware wxArtProvider
1428 class wxPyArtProvider : public wxArtProvider {
1429 public:
1430
1431 virtual wxBitmap CreateBitmap(const wxArtID& id,
1432 const wxArtClient& client,
1433 const wxSize& size) {
1434 wxBitmap rval = wxNullBitmap;
1435 wxPyBeginBlockThreads();
1436 if ((wxPyCBH_findCallback(m_myInst, "CreateBitmap"))) {
1437 PyObject* so = wxPyConstructObject((void*)&size, "wxSize", 0);
1438 PyObject* ro;
1439 wxBitmap* ptr;
1440 PyObject* s1, *s2;
1441 s1 = wx2PyString(id);
1442 s2 = wx2PyString(client);
1443 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(OOO)", s1, s2, so));
1444 Py_DECREF(so);
1445 Py_DECREF(s1);
1446 Py_DECREF(s2);
1447 if (ro) {
1448 if (!SWIG_GetPtrObj(ro, (void**)&ptr, "_wxBitmap_p"))
1449 rval = *ptr;
1450 Py_DECREF(ro);
1451 }
1452 }
1453 wxPyEndBlockThreads();
1454 return rval;
1455 }
1456
1457 PYPRIVATE;
1458 };
1459 %}
1460
1461 // The one for SWIG to see
1462 %name(wxArtProvider) class wxPyArtProvider : public wxObject
1463 {
1464 public:
1465 wxPyArtProvider();
1466
1467 void _setCallbackInfo(PyObject* self, PyObject* _class);
1468 %pragma(python) addtomethod = "__init__:self._setCallbackInfo(self, wxArtProvider)"
1469
1470 // Add new provider to the top of providers stack.
1471 static void PushProvider(wxPyArtProvider *provider);
1472
1473 // Remove latest added provider and delete it.
1474 static bool PopProvider();
1475
1476 // Remove provider. The provider must have been added previously!
1477 // The provider is _not_ deleted.
1478 static bool RemoveProvider(wxPyArtProvider *provider);
1479
1480 // Query the providers for bitmap with given ID and return it. Return
1481 // wxNullBitmap if no provider provides it.
1482 static wxBitmap GetBitmap(const wxString& id,
1483 const wxString& client = wxPyART_OTHER,
1484 const wxSize& size = wxDefaultSize);
1485
1486 // Query the providers for icon with given ID and return it. Return
1487 // wxNullIcon if no provider provides it.
1488 static wxIcon GetIcon(const wxString& id,
1489 const wxString& client = wxPyART_OTHER,
1490 const wxSize& size = wxDefaultSize);
1491
1492 // Destroy caches & all providers
1493 static void CleanUpProviders();
1494 };
1495
1496
1497 //----------------------------------------------------------------------
1498
1499 %{
1500 #include <wx/docview.h>
1501 %}
1502
1503 class wxFileHistory : public wxObject
1504 {
1505 public:
1506 wxFileHistory(int maxFiles = 9);
1507 ~wxFileHistory();
1508
1509 // Operations
1510 void AddFileToHistory(const wxString& file);
1511 void RemoveFileFromHistory(int i);
1512 int GetMaxFiles() const;
1513 void UseMenu(wxMenu *menu);
1514
1515 // Remove menu from the list (MDI child may be closing)
1516 void RemoveMenu(wxMenu *menu);
1517
1518 void Load(wxConfigBase& config);
1519 void Save(wxConfigBase& config);
1520
1521 void AddFilesToMenu();
1522 %name(AddFilesToThisMenu)void AddFilesToMenu(wxMenu* menu);
1523
1524 // Accessors
1525 wxString GetHistoryFile(int i) const;
1526
1527 // A synonym for GetNoHistoryFiles
1528 int GetCount() const;
1529 int GetNoHistoryFiles() const;
1530
1531 };
1532
1533 //----------------------------------------------------------------------
1534 //----------------------------------------------------------------------
1535
1536 // %{
1537 // #if wxUSE_UNICODE
1538 // #define ADD_STRING(dict, str) \
1539 // wxString tmp##str(str); \
1540 // PyDict_SetItemString(dict, #str, \
1541 // PyUnicode_FromUnicode(tmp##str.c_str(), tmp##str.Len()))
1542 // #else
1543 // #define ADD_STRING(dict, str) \
1544 // PyDict_SetItemString(d, #str, PyString_FromString(str))
1545 // #endif
1546 // %}
1547
1548
1549 %init %{
1550 wxPyPtrTypeMap_Add("wxDragImage", "wxGenericDragImage");
1551 wxPyPtrTypeMap_Add("wxProcess", "wxPyProcess");
1552 wxPyPtrTypeMap_Add("wxArtProvider", "wxPyArtProvider");
1553
1554 %}
1555
1556 //----------------------------------------------------------------------
1557