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