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