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