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