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