]> git.saurik.com Git - wxWidgets.git/blob - wxPython/src/misc2.i
wxPyEmptyStr --> wxEmptyString
[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 <wx/resource.h>
20 #include <wx/tooltip.h>
21 #include <wx/caret.h>
22 #include <wx/fontenum.h>
23 #include <wx/tipdlg.h>
24 #include <wx/process.h>
25
26 #if wxUSE_JOYSTICK || defined(__WXMSW__)
27 #include <wx/joystick.h>
28 #endif
29
30 #if wxUSE_WAVE || defined(__WXMSW__)
31 #include <wx/wave.h>
32 #endif
33
34 #include <wx/mimetype.h>
35 %}
36
37 //----------------------------------------------------------------------
38
39 %include typemaps.i
40 %include my_typemaps.i
41
42 // Import some definitions of other classes, etc.
43 %import _defs.i
44 %import windows.i
45 %import misc.i
46 %import gdi.i
47 %import events.i
48 %import streams.i
49 %import utils.i
50
51
52 //---------------------------------------------------------------------------
53 // Dialog Functions
54
55 wxString wxFileSelector(char* message,
56 char* default_path = NULL,
57 char* default_filename = NULL,
58 char* default_extension = NULL,
59 char* wildcard = "*.*",
60 int flags = 0,
61 wxWindow *parent = NULL,
62 int x = -1, int y = -1);
63
64 wxString wxGetTextFromUser(const wxString& message,
65 const wxString& caption = wxEmptyString,
66 const wxString& default_value = wxEmptyString,
67 wxWindow *parent = NULL,
68 int x = -1, int y = -1,
69 bool centre = TRUE);
70
71 wxString wxGetPasswordFromUser(const wxString& message,
72 const wxString& caption = wxEmptyString,
73 const wxString& default_value = wxEmptyString,
74 wxWindow *parent = NULL);
75
76
77 // TODO: Need to custom wrap this one...
78 // int wxGetMultipleChoice(char* message, char* caption,
79 // int LCOUNT, char** choices,
80 // int nsel, int *selection,
81 // wxWindow *parent = NULL, int x = -1, int y = -1,
82 // bool centre = TRUE, int width=150, int height=200);
83
84
85 wxString wxGetSingleChoice(const wxString& message, const wxString& caption,
86 int LCOUNT, wxString* choices,
87 wxWindow *parent = NULL,
88 int x = -1, int y = -1,
89 bool centre = TRUE,
90 int width=150, int height=200);
91
92 int wxGetSingleChoiceIndex(const wxString& message, const wxString& caption,
93 int LCOUNT, wxString* choices,
94 wxWindow *parent = NULL,
95 int x = -1, int y = -1,
96 bool centre = TRUE,
97 int width=150, int height=200);
98
99
100 int wxMessageBox(const wxString& message,
101 const wxString& caption = wxEmptyString,
102 int style = wxOK | wxCENTRE,
103 wxWindow *parent = NULL,
104 int x = -1, int y = -1);
105
106 long wxGetNumberFromUser(const wxString& message,
107 const wxString& prompt,
108 const wxString& caption,
109 long value,
110 long min = 0, long max = 100,
111 wxWindow *parent = NULL,
112 const wxPoint& pos = wxDefaultPosition);
113
114 //---------------------------------------------------------------------------
115 // GDI Functions
116
117 bool wxColourDisplay();
118
119 int wxDisplayDepth();
120 int wxGetDisplayDepth();
121
122 void wxDisplaySize(int* OUTPUT, int* OUTPUT);
123 wxSize wxGetDisplaySize();
124
125 void wxDisplaySizeMM(int* OUTPUT, int* OUTPUT);
126 wxSize wxGetDisplaySizeMM();
127
128 void wxClientDisplayRect(int *OUTPUT, int *OUTPUT, int *OUTPUT, int *OUTPUT);
129 wxRect wxGetClientDisplayRect();
130
131 void wxSetCursor(wxCursor& cursor);
132
133 //----------------------------------------------------------------------
134 // Miscellaneous functions
135
136 wxWindow * wxFindWindowByLabel(const wxString& label, wxWindow *parent=NULL);
137 wxWindow * wxFindWindowByName(const wxString& name, wxWindow *parent=NULL);
138
139 void wxBeginBusyCursor(wxCursor *cursor = wxHOURGLASS_CURSOR);
140 wxWindow * wxGetActiveWindow();
141
142 wxWindow* wxGenericFindWindowAtPoint(const wxPoint& pt);
143 wxWindow* wxFindWindowAtPoint(const wxPoint& pt);
144
145 #ifdef __WXMSW__
146 bool wxCheckForInterrupt(wxWindow *wnd);
147 void wxFlushEvents();
148 #endif
149
150 //---------------------------------------------------------------------------
151 // Resource System
152
153 bool wxResourceAddIdentifier(char *name, int value);
154 void wxResourceClear(void);
155 wxBitmap wxResourceCreateBitmap(char *resource);
156 wxIcon wxResourceCreateIcon(char *resource);
157 wxMenuBar * wxResourceCreateMenuBar(char *resource);
158 int wxResourceGetIdentifier(char *name);
159 bool wxResourceParseData(char *resource, wxResourceTable *table = NULL);
160 bool wxResourceParseFile(char *filename, wxResourceTable *table = NULL);
161 bool wxResourceParseString(char *resource, wxResourceTable *table = NULL);
162
163 //---------------------------------------------------------------------------
164 // System Settings
165
166 // possible values for wxSystemSettings::GetFont() parameter
167 //
168 enum wxSystemFont
169 {
170 wxSYS_OEM_FIXED_FONT = 10,
171 wxSYS_ANSI_FIXED_FONT,
172 wxSYS_ANSI_VAR_FONT,
173 wxSYS_SYSTEM_FONT,
174 wxSYS_DEVICE_DEFAULT_FONT,
175 wxSYS_DEFAULT_PALETTE,
176 wxSYS_SYSTEM_FIXED_FONT,
177 wxSYS_DEFAULT_GUI_FONT
178 };
179
180 // possible values for wxSystemSettings::GetColour() parameter
181 //
182 enum wxSystemColour
183 {
184 wxSYS_COLOUR_SCROLLBAR,
185 wxSYS_COLOUR_BACKGROUND,
186 wxSYS_COLOUR_DESKTOP = wxSYS_COLOUR_BACKGROUND,
187 wxSYS_COLOUR_ACTIVECAPTION,
188 wxSYS_COLOUR_INACTIVECAPTION,
189 wxSYS_COLOUR_MENU,
190 wxSYS_COLOUR_WINDOW,
191 wxSYS_COLOUR_WINDOWFRAME,
192 wxSYS_COLOUR_MENUTEXT,
193 wxSYS_COLOUR_WINDOWTEXT,
194 wxSYS_COLOUR_CAPTIONTEXT,
195 wxSYS_COLOUR_ACTIVEBORDER,
196 wxSYS_COLOUR_INACTIVEBORDER,
197 wxSYS_COLOUR_APPWORKSPACE,
198 wxSYS_COLOUR_HIGHLIGHT,
199 wxSYS_COLOUR_HIGHLIGHTTEXT,
200 wxSYS_COLOUR_BTNFACE,
201 wxSYS_COLOUR_3DFACE = wxSYS_COLOUR_BTNFACE,
202 wxSYS_COLOUR_BTNSHADOW,
203 wxSYS_COLOUR_3DSHADOW = wxSYS_COLOUR_BTNSHADOW,
204 wxSYS_COLOUR_GRAYTEXT,
205 wxSYS_COLOUR_BTNTEXT,
206 wxSYS_COLOUR_INACTIVECAPTIONTEXT,
207 wxSYS_COLOUR_BTNHIGHLIGHT,
208 wxSYS_COLOUR_BTNHILIGHT = wxSYS_COLOUR_BTNHIGHLIGHT,
209 wxSYS_COLOUR_3DHIGHLIGHT = wxSYS_COLOUR_BTNHIGHLIGHT,
210 wxSYS_COLOUR_3DHILIGHT = wxSYS_COLOUR_BTNHIGHLIGHT,
211 wxSYS_COLOUR_3DDKSHADOW,
212 wxSYS_COLOUR_3DLIGHT,
213 wxSYS_COLOUR_INFOTEXT,
214 wxSYS_COLOUR_INFOBK,
215 wxSYS_COLOUR_LISTBOX,
216 wxSYS_COLOUR_HOTLIGHT,
217 wxSYS_COLOUR_GRADIENTACTIVECAPTION,
218 wxSYS_COLOUR_GRADIENTINACTIVECAPTION,
219 wxSYS_COLOUR_MENUHILIGHT,
220 wxSYS_COLOUR_MENUBAR,
221
222 wxSYS_COLOUR_MAX
223 };
224
225 // possible values for wxSystemSettings::GetMetric() parameter
226 //
227 enum wxSystemMetric
228 {
229 wxSYS_MOUSE_BUTTONS = 1,
230 wxSYS_BORDER_X,
231 wxSYS_BORDER_Y,
232 wxSYS_CURSOR_X,
233 wxSYS_CURSOR_Y,
234 wxSYS_DCLICK_X,
235 wxSYS_DCLICK_Y,
236 wxSYS_DRAG_X,
237 wxSYS_DRAG_Y,
238 wxSYS_EDGE_X,
239 wxSYS_EDGE_Y,
240 wxSYS_HSCROLL_ARROW_X,
241 wxSYS_HSCROLL_ARROW_Y,
242 wxSYS_HTHUMB_X,
243 wxSYS_ICON_X,
244 wxSYS_ICON_Y,
245 wxSYS_ICONSPACING_X,
246 wxSYS_ICONSPACING_Y,
247 wxSYS_WINDOWMIN_X,
248 wxSYS_WINDOWMIN_Y,
249 wxSYS_SCREEN_X,
250 wxSYS_SCREEN_Y,
251 wxSYS_FRAMESIZE_X,
252 wxSYS_FRAMESIZE_Y,
253 wxSYS_SMALLICON_X,
254 wxSYS_SMALLICON_Y,
255 wxSYS_HSCROLL_Y,
256 wxSYS_VSCROLL_X,
257 wxSYS_VSCROLL_ARROW_X,
258 wxSYS_VSCROLL_ARROW_Y,
259 wxSYS_VTHUMB_Y,
260 wxSYS_CAPTION_Y,
261 wxSYS_MENU_Y,
262 wxSYS_NETWORK_PRESENT,
263 wxSYS_PENWINDOWS_PRESENT,
264 wxSYS_SHOW_SOUNDS,
265 wxSYS_SWAP_BUTTONS
266 };
267
268 // possible values for wxSystemSettings::HasFeature() parameter
269 enum wxSystemFeature
270 {
271 wxSYS_CAN_DRAW_FRAME_DECORATIONS = 1,
272 wxSYS_CAN_ICONIZE_FRAME
273 };
274
275
276
277 class wxSystemSettings {
278 public:
279 // get a standard system colour
280 static wxColour GetColour(wxSystemColour index);
281
282 // get a standard system font
283 static wxFont GetFont(wxSystemFont index);
284
285 // get a system-dependent metric
286 static int GetMetric(wxSystemMetric index);
287
288 // return true if the port has certain feature
289 static bool HasFeature(wxSystemFeature index);
290
291 };
292
293
294
295 //---------------------------------------------------------------------------
296 // wxToolTip
297
298 class wxToolTip : public wxObject {
299 public:
300 wxToolTip(const wxString &tip);
301
302 void SetTip(const wxString& tip);
303 wxString GetTip();
304 // *** Not in the "public" interface void SetWindow(wxWindow *win);
305 wxWindow *GetWindow();
306
307 static void Enable(bool flag);
308 static void SetDelay(long milliseconds);
309 };
310
311 //----------------------------------------------------------------------
312
313 class wxCaret {
314 public:
315 wxCaret(wxWindow* window, const wxSize& size);
316 ~wxCaret();
317
318 bool IsOk();
319 bool IsVisible();
320 %name(GetPositionTuple)void GetPosition(int *OUTPUT, int *OUTPUT);
321 wxPoint GetPosition();
322 %name(GetSizeTuple)void GetSize(int *OUTPUT, int *OUTPUT);
323 wxSize GetSize();
324 wxWindow *GetWindow();
325 %name(MoveXY)void Move(int x, int y);
326 void Move(const wxPoint& pt);
327 %name(SetSizeWH) void SetSize(int width, int height);
328 void SetSize(const wxSize& size);
329 void Show(int show = TRUE);
330 void Hide();
331 };
332
333 %inline %{
334 int wxCaret_GetBlinkTime() {
335 return wxCaret::GetBlinkTime();
336 }
337
338 void wxCaret_SetBlinkTime(int milliseconds) {
339 wxCaret::SetBlinkTime(milliseconds);
340 }
341 %}
342
343 //----------------------------------------------------------------------
344
345 %{
346 class wxPyFontEnumerator : public wxFontEnumerator {
347 public:
348 wxPyFontEnumerator() {}
349 ~wxPyFontEnumerator() {}
350
351 DEC_PYCALLBACK_BOOL_STRING(OnFacename);
352 DEC_PYCALLBACK_BOOL_STRINGSTRING(OnFontEncoding);
353
354 PYPRIVATE;
355 };
356
357 IMP_PYCALLBACK_BOOL_STRING(wxPyFontEnumerator, wxFontEnumerator, OnFacename);
358 IMP_PYCALLBACK_BOOL_STRINGSTRING(wxPyFontEnumerator, wxFontEnumerator, OnFontEncoding);
359
360 %}
361
362 %name(wxFontEnumerator) class wxPyFontEnumerator {
363 public:
364 wxPyFontEnumerator();
365 ~wxPyFontEnumerator();
366 void _setCallbackInfo(PyObject* self, PyObject* _class, bool incref);
367 %pragma(python) addtomethod = "__init__:self._setCallbackInfo(self, wxFontEnumerator, 0)"
368
369 bool EnumerateFacenames(
370 wxFontEncoding encoding = wxFONTENCODING_SYSTEM, // all
371 bool fixedWidthOnly = FALSE);
372 bool EnumerateEncodings(const char* facename = "");
373
374 //wxArrayString* GetEncodings();
375 //wxArrayString* GetFacenames();
376 %addmethods {
377 PyObject* GetEncodings() {
378 wxArrayString* arr = self->GetEncodings();
379 return wxArrayString2PyList_helper(*arr);
380 }
381
382 PyObject* GetFacenames() {
383 wxArrayString* arr = self->GetFacenames();
384 return wxArrayString2PyList_helper(*arr);
385 }
386 }
387 };
388
389 //----------------------------------------------------------------------
390
391 class wxBusyCursor {
392 public:
393 wxBusyCursor(wxCursor* cursor = wxHOURGLASS_CURSOR);
394 ~wxBusyCursor();
395 };
396
397 //----------------------------------------------------------------------
398
399 class wxWindowDisabler {
400 public:
401 wxWindowDisabler(wxWindow *winToSkip = NULL);
402 ~wxWindowDisabler();
403 };
404
405 //----------------------------------------------------------------------
406
407 bool wxSafeYield(wxWindow* win=NULL);
408 void wxPostEvent(wxEvtHandler *dest, wxEvent& event);
409 void wxWakeUpIdle();
410
411
412 #ifdef __WXMSW__
413 void wxWakeUpMainThread();
414 #endif
415
416 void wxMutexGuiEnter();
417 void wxMutexGuiLeave();
418
419
420 class wxMutexGuiLocker {
421 public:
422 wxMutexGuiLocker();
423 ~wxMutexGuiLocker();
424 };
425
426
427 %inline %{
428 bool wxThread_IsMain() {
429 #ifdef WXP_WITH_THREAD
430 return wxThread::IsMain();
431 #else
432 return TRUE;
433 #endif
434 }
435 %}
436
437 //----------------------------------------------------------------------
438
439
440 class wxTipProvider
441 {
442 public:
443 // wxTipProvider(size_t currentTip); **** Abstract base class
444 ~wxTipProvider();
445
446 virtual wxString GetTip() = 0;
447 size_t GetCurrentTip();
448
449 };
450
451
452 // The C++ version of wxPyTipProvider
453 %{
454 class wxPyTipProvider : public wxTipProvider {
455 public:
456 wxPyTipProvider(size_t currentTip)
457 : wxTipProvider(currentTip) {}
458
459 DEC_PYCALLBACK_STRING__pure(GetTip);
460
461 PYPRIVATE;
462 };
463
464 IMP_PYCALLBACK_STRING__pure( wxPyTipProvider, wxTipProvider, GetTip);
465
466 %}
467
468
469 // Now let SWIG know about it
470 class wxPyTipProvider : public wxTipProvider {
471 public:
472 wxPyTipProvider(size_t currentTip);
473 };
474
475
476
477 bool wxShowTip(wxWindow *parent, wxTipProvider *tipProvider, bool showAtStartup = TRUE);
478 %new wxTipProvider * wxCreateFileTipProvider(const wxString& filename, size_t currentTip);
479
480
481 //----------------------------------------------------------------------
482
483 %{
484 #include <wx/generic/dragimgg.h>
485 %}
486
487 %name (wxDragImage) class wxGenericDragImage : public wxObject
488 {
489 public:
490
491 wxGenericDragImage(const wxBitmap& image,
492 const wxCursor& cursor = wxNullCursor);
493 %name(wxDragIcon)wxGenericDragImage(const wxIcon& image,
494 const wxCursor& cursor = wxNullCursor);
495 %name(wxDragString)wxGenericDragImage(const wxString& str,
496 const wxCursor& cursor = wxNullCursor);
497 %name(wxDragTreeItem)wxGenericDragImage(const wxTreeCtrl& treeCtrl, wxTreeItemId& id);
498 %name(wxDragListItem)wxGenericDragImage(const wxListCtrl& listCtrl, long id);
499
500 ~wxGenericDragImage();
501
502 void SetBackingBitmap(wxBitmap* bitmap);
503 bool BeginDrag(const wxPoint& hotspot, wxWindow* window,
504 bool fullScreen = FALSE, wxRect* rect = NULL);
505
506 %name(BeginDrag2) bool BeginDrag(const wxPoint& hotspot, wxWindow* window,
507 wxWindow* fullScreenRect);
508
509 bool EndDrag();
510 bool Move(const wxPoint& pt);
511 bool Show();
512 bool Hide();
513
514 wxRect GetImageRect(const wxPoint& pos) const;
515 bool RedrawImage(const wxPoint& oldPos, const wxPoint& newPos,
516 bool eraseOld, bool drawNew);
517 };
518
519
520 //----------------------------------------------------------------------
521
522 class wxPyTimer : public wxObject {
523 public:
524 wxPyTimer(PyObject* notify);
525 ~wxPyTimer();
526 int GetInterval();
527 bool IsOneShot();
528 bool IsRunning();
529 void SetOwner(wxEvtHandler *owner, int id = -1);
530 void Start(int milliseconds=-1, int oneShot=FALSE);
531 void Stop();
532 };
533
534
535 class wxStopWatch
536 {
537 public:
538 // ctor starts the stop watch
539 wxStopWatch();
540 ~wxStopWatch();
541 void Start(long t = 0);
542 void Pause();
543 void Resume();
544
545 // get elapsed time since the last Start() or Pause() in milliseconds
546 long Time() const;
547 };
548
549
550 //----------------------------------------------------------------------
551 //----------------------------------------------------------------------
552
553
554 enum
555 {
556 wxLOG_FatalError, // program can't continue, abort immediately
557 wxLOG_Error, // a serious error, user must be informed about it
558 wxLOG_Warning, // user is normally informed about it but may be ignored
559 wxLOG_Message, // normal message (i.e. normal output of a non GUI app)
560 wxLOG_Info, // informational message (a.k.a. 'Verbose')
561 wxLOG_Status, // informational: might go to the status line of GUI app
562 wxLOG_Debug, // never shown to the user, disabled in release mode
563 wxLOG_Trace, // trace messages are also only enabled in debug mode
564 wxLOG_Progress, // used for progress indicator (not yet)
565 wxLOG_User = 100 // user defined levels start here
566 };
567
568
569 class wxLog
570 {
571 public:
572 wxLog();
573
574 static bool IsEnabled();
575 static bool EnableLogging(bool doIt = TRUE);
576 static void OnLog(wxLogLevel level, const char *szString, int t=0);
577
578 virtual void Flush();
579 bool HasPendingMessages() const;
580
581 static void FlushActive();
582 static wxLog *GetActiveTarget();
583 static wxLog *SetActiveTarget(wxLog *pLogger);
584
585 static void Suspend();
586 static void Resume();
587
588 void SetVerbose(bool bVerbose = TRUE);
589
590 static void DontCreateOnDemand();
591 static void SetTraceMask(wxTraceMask ulMask);
592 static void AddTraceMask(const wxString& str);
593 static void RemoveTraceMask(const wxString& str);
594 static void ClearTraceMasks();
595
596 static void SetTimestamp(const wxChar *ts);
597 static const wxChar *GetTimestamp();
598
599 bool GetVerbose() const { return m_bVerbose; }
600
601 static wxTraceMask GetTraceMask();
602 static bool IsAllowedTraceMask(const char *mask);
603
604 // static void TimeStamp(wxString *str);
605 %addmethods {
606 wxString TimeStamp() {
607 wxString msg;
608 wxLog::TimeStamp(&msg);
609 return msg;
610 }
611 }
612 };
613
614
615 class wxLogStderr : public wxLog
616 {
617 public:
618 wxLogStderr(/* TODO: FILE *fp = (FILE *) NULL*/);
619 };
620
621
622 class wxLogTextCtrl : public wxLog
623 {
624 public:
625 wxLogTextCtrl(wxTextCtrl *pTextCtrl);
626 };
627
628
629 class wxLogGui : public wxLog
630 {
631 public:
632 wxLogGui();
633 };
634
635 class wxLogWindow : public wxLog
636 {
637 public:
638 wxLogWindow(wxFrame *pParent, // the parent frame (can be NULL)
639 const char *szTitle, // the title of the frame
640 bool bShow = TRUE, // show window immediately?
641 bool bPassToOld = TRUE); // pass log messages to the old target?
642
643 void Show(bool bShow = TRUE);
644 wxFrame *GetFrame() const;
645 wxLog *GetOldLog() const;
646 bool IsPassingMessages() const;
647 void PassMessages(bool bDoPass) { m_bPassMessages = bDoPass; }
648 };
649
650
651 class wxLogNull
652 {
653 public:
654 wxLogNull();
655 ~wxLogNull();
656 };
657
658
659 class wxLogChain : public wxLog
660 {
661 public:
662 wxLogChain(wxLog *logger);
663 void SetLog(wxLog *logger);
664 void PassMessages(bool bDoPass);
665 bool IsPassingMessages();
666 wxLog *GetOldLog();
667 };
668
669
670 unsigned long wxSysErrorCode();
671 const char* wxSysErrorMsg(unsigned long nErrCode = 0);
672 void wxLogFatalError(const char *szFormat);
673 void wxLogError(const char *szFormat);
674 void wxLogWarning(const char *szFormat);
675 void wxLogMessage(const char *szFormat);
676 void wxLogInfo(const char *szFormat);
677 void wxLogVerbose(const char *szFormat);
678 void wxLogStatus(const char *szFormat);
679 %name(wxLogStatusFrame)void wxLogStatus(wxFrame *pFrame, const char *szFormat);
680 void wxLogSysError(const char *szFormat);
681
682
683 %{
684 // A Log class that can be derived from in wxPython
685 class wxPyLog : public wxLog {
686 public:
687 wxPyLog() : wxLog() {}
688
689 virtual void DoLog(wxLogLevel level, const wxChar *szString, time_t t) {
690 bool found;
691 wxPyBeginBlockThreads();
692 if ((found = wxPyCBH_findCallback(m_myInst, "DoLog")))
693 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(isi)", level, szString, t));
694 wxPyEndBlockThreads();
695 if (! found)
696 wxLog::DoLog(level, szString, t);
697 }
698
699 virtual void DoLogString(const wxChar *szString, time_t t) {
700 bool found;
701 wxPyBeginBlockThreads();
702 if ((found = wxPyCBH_findCallback(m_myInst, "DoLogString")))
703 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(si)", szString, t));
704 wxPyEndBlockThreads();
705 if (! found)
706 wxLog::DoLogString(szString, t);
707 }
708
709 PYPRIVATE;
710 };
711 %}
712
713 // Now tell SWIG about it
714 class wxPyLog : public wxLog {
715 public:
716 wxPyLog();
717 void _setCallbackInfo(PyObject* self, PyObject* _class);
718 %pragma(python) addtomethod = "__init__:self._setCallbackInfo(self, wxPyLog)"
719 %addmethods { void Destroy() { delete self; } }
720
721 };
722
723
724 //----------------------------------------------------------------------
725
726
727 enum {
728 /* event type */
729 wxEVT_END_PROCESS
730 };
731
732
733 class wxProcessEvent : public wxEvent {
734 public:
735 wxProcessEvent(int id = 0, int pid = 0, int exitcode = 0);
736 int GetPid();
737 int GetExitCode();
738 int m_pid, m_exitcode;
739 };
740
741
742
743
744 %{ // C++ version of wxProcess derived class
745
746 class wxPyProcess : public wxProcess {
747 public:
748 wxPyProcess(wxEvtHandler *parent = NULL, int id = -1)
749 : wxProcess(parent, id)
750 {}
751
752 DEC_PYCALLBACK_VOID_INTINT(OnTerminate);
753
754 PYPRIVATE;
755 };
756
757 IMP_PYCALLBACK_VOID_INTINT( wxPyProcess, wxProcess, OnTerminate);
758
759 %}
760
761
762 %name(wxProcess)class wxPyProcess : public wxEvtHandler {
763 public:
764 wxPyProcess(wxEvtHandler *parent = NULL, int id = -1);
765 %addmethods { void Destroy() { delete self; } }
766
767 void _setCallbackInfo(PyObject* self, PyObject* _class);
768 %pragma(python) addtomethod = "__init__:self._setCallbackInfo(self, wxProcess)"
769
770 void base_OnTerminate(int pid, int status);
771
772 void Redirect();
773 bool IsRedirected();
774 void Detach();
775
776 wxInputStream *GetInputStream();
777 wxInputStream *GetErrorStream();
778 wxOutputStream *GetOutputStream();
779
780 void CloseOutput();
781 };
782
783
784
785 long wxExecute(const wxString& command,
786 int sync = FALSE,
787 wxPyProcess *process = NULL);
788
789 //----------------------------------------------------------------------
790
791 %{
792 #if !wxUSE_JOYSTICK && !defined(__WXMSW__)
793 // A C++ stub class for wxJoystick for platforms that don't have it.
794 class wxJoystick : public wxObject {
795 public:
796 wxJoystick(int joystick = wxJOYSTICK1) {
797 wxPyBeginBlockThreads();
798 PyErr_SetString(PyExc_NotImplementedError, "wxJoystick is not available on this platform.");
799 wxPyEndBlockThreads();
800 }
801 wxPoint GetPosition() { return wxPoint(-1,-1); }
802 int GetZPosition() { return -1; }
803 int GetButtonState() { return -1; }
804 int GetPOVPosition() { return -1; }
805 int GetPOVCTSPosition() { return -1; }
806 int GetRudderPosition() { return -1; }
807 int GetUPosition() { return -1; }
808 int GetVPosition() { return -1; }
809 int GetMovementThreshold() { return -1; }
810 void SetMovementThreshold(int threshold) {}
811
812 bool IsOk(void) { return FALSE; }
813 int GetNumberJoysticks() { return -1; }
814 int GetManufacturerId() { return -1; }
815 int GetProductId() { return -1; }
816 wxString GetProductName() { return ""; }
817 int GetXMin() { return -1; }
818 int GetYMin() { return -1; }
819 int GetZMin() { return -1; }
820 int GetXMax() { return -1; }
821 int GetYMax() { return -1; }
822 int GetZMax() { return -1; }
823 int GetNumberButtons() { return -1; }
824 int GetNumberAxes() { return -1; }
825 int GetMaxButtons() { return -1; }
826 int GetMaxAxes() { return -1; }
827 int GetPollingMin() { return -1; }
828 int GetPollingMax() { return -1; }
829 int GetRudderMin() { return -1; }
830 int GetRudderMax() { return -1; }
831 int GetUMin() { return -1; }
832 int GetUMax() { return -1; }
833 int GetVMin() { return -1; }
834 int GetVMax() { return -1; }
835
836 bool HasRudder() { return FALSE; }
837 bool HasZ() { return FALSE; }
838 bool HasU() { return FALSE; }
839 bool HasV() { return FALSE; }
840 bool HasPOV() { return FALSE; }
841 bool HasPOV4Dir() { return FALSE; }
842 bool HasPOVCTS() { return FALSE; }
843
844 bool SetCapture(wxWindow* win, int pollingFreq = 0) { return FALSE; }
845 bool ReleaseCapture() { return FALSE; }
846 };
847 #endif
848 %}
849
850
851 class wxJoystick : public wxObject {
852 public:
853 wxJoystick(int joystick = wxJOYSTICK1);
854 ~wxJoystick();
855
856 wxPoint GetPosition();
857 int GetZPosition();
858 int GetButtonState();
859 int GetPOVPosition();
860 int GetPOVCTSPosition();
861 int GetRudderPosition();
862 int GetUPosition();
863 int GetVPosition();
864 int GetMovementThreshold();
865 void SetMovementThreshold(int threshold) ;
866
867 bool IsOk(void);
868 int GetNumberJoysticks();
869 int GetManufacturerId();
870 int GetProductId();
871 wxString GetProductName();
872 int GetXMin();
873 int GetYMin();
874 int GetZMin();
875 int GetXMax();
876 int GetYMax();
877 int GetZMax();
878 int GetNumberButtons();
879 int GetNumberAxes();
880 int GetMaxButtons();
881 int GetMaxAxes();
882 int GetPollingMin();
883 int GetPollingMax();
884 int GetRudderMin();
885 int GetRudderMax();
886 int GetUMin();
887 int GetUMax();
888 int GetVMin();
889 int GetVMax();
890
891 bool HasRudder();
892 bool HasZ();
893 bool HasU();
894 bool HasV();
895 bool HasPOV();
896 bool HasPOV4Dir();
897 bool HasPOVCTS();
898
899 bool SetCapture(wxWindow* win, int pollingFreq = 0);
900 bool ReleaseCapture();
901 };
902
903 //----------------------------------------------------------------------
904
905 %{
906 #if !wxUSE_WAVE
907 // A C++ stub class for wxWave for platforms that don't have it.
908 class wxWave : public wxObject
909 {
910 public:
911 wxWave(const wxString& fileName, bool isResource = FALSE) {
912 wxPyBeginBlockThreads();
913 PyErr_SetString(PyExc_NotImplementedError, "wxWave is not available on this platform.");
914 wxPyEndBlockThreads();
915 }
916 wxWave(int size, const wxByte* data) {
917 wxPyBeginBlockThreads();
918 PyErr_SetString(PyExc_NotImplementedError, "wxWave is not available on this platform.");
919 wxPyEndBlockThreads();
920 }
921
922 ~wxWave() {}
923
924 bool IsOk() const { return FALSE; }
925 bool Play(bool async = TRUE, bool looped = FALSE) const { return FALSE; }
926 };
927
928 #endif
929 %}
930
931 class wxWave : public wxObject
932 {
933 public:
934 wxWave(const wxString& fileName, bool isResource = FALSE);
935 ~wxWave();
936
937 bool IsOk() const;
938 bool Play(bool async = TRUE, bool looped = FALSE) const;
939 };
940
941 %new wxWave* wxWaveData(const wxString& data);
942 %{ // Implementations of some alternate "constructors"
943 wxWave* wxWaveData(const wxString& data) {
944 return new wxWave(data.Len(), (wxByte*)data.c_str());
945 }
946 %}
947
948
949 //----------------------------------------------------------------------
950
951 enum wxMailcapStyle
952 {
953 wxMAILCAP_STANDARD = 1,
954 wxMAILCAP_NETSCAPE = 2,
955 wxMAILCAP_KDE = 4,
956 wxMAILCAP_GNOME = 8,
957
958 wxMAILCAP_ALL = 15
959 };
960
961
962
963 class wxFileTypeInfo
964 {
965 public:
966 // ctors
967 // a normal item
968 wxFileTypeInfo(const char *mimeType,
969 const char *openCmd,
970 const char *printCmd,
971 const char *desc);
972
973
974 // the array elements correspond to the parameters of the ctor above in
975 // the same order
976 %name(wxFileTypeInfoSequence)wxFileTypeInfo(const wxArrayString& sArray);
977
978 // invalid item - use this to terminate the array passed to
979 // wxMimeTypesManager::AddFallbacks
980 %name(wxNullFileTypeInfo)wxFileTypeInfo();
981
982
983 // test if this object can be used
984 bool IsValid() const;
985
986 // setters
987 // set the icon info
988 void SetIcon(const wxString& iconFile, int iconIndex = 0);
989
990 // set the short desc
991 void SetShortDesc(const wxString& shortDesc);
992
993 // accessors
994 // get the MIME type
995 const wxString& GetMimeType() const;
996 // get the open command
997 const wxString& GetOpenCommand() const;
998 // get the print command
999 const wxString& GetPrintCommand() const;
1000 // get the short description (only used under Win32 so far)
1001 const wxString& GetShortDesc() const;
1002 // get the long, user visible description
1003 const wxString& GetDescription() const;
1004
1005
1006 // get the array of all extensions
1007 //const wxArrayString& GetExtensions() const;
1008 %addmethods {
1009 PyObject* GetExtensions() {
1010 wxArrayString& arr = (wxArrayString&)self->GetExtensions();
1011 return wxArrayString2PyList_helper(arr);
1012 }
1013 }
1014
1015 int GetExtensionsCount() const;
1016
1017 // get the icon info
1018 const wxString& GetIconFile() const;
1019 int GetIconIndex() const;
1020 };
1021
1022
1023
1024
1025 class wxFileType
1026 {
1027 public:
1028
1029 // TODO: Make a wxPyMessageParameters with virtual GetParamValue...
1030
1031 // An object of this class must be passed to Get{Open|Print}Command. The
1032 // default implementation is trivial and doesn't know anything at all about
1033 // parameters, only filename and MIME type are used (so it's probably ok for
1034 // Windows where %{param} is not used anyhow)
1035 class MessageParameters
1036 {
1037 public:
1038 // ctors
1039 MessageParameters(const wxString& filename=wxEmptyString,
1040 const wxString& mimetype=wxEmptyString);
1041
1042 // accessors (called by GetOpenCommand)
1043 // filename
1044 const wxString& GetFileName() const;
1045 // mime type
1046 const wxString& GetMimeType() const;;
1047
1048 // override this function in derived class
1049 virtual wxString GetParamValue(const wxString& name) const;
1050
1051 // virtual dtor as in any base class
1052 virtual ~MessageParameters();
1053 };
1054
1055
1056 // ctor from static data
1057 wxFileType(const wxFileTypeInfo& ftInfo);
1058
1059 // return the MIME type for this file type
1060 %addmethods {
1061 PyObject* GetMimeType() {
1062 wxString str;
1063 if (self->GetMimeType(&str))
1064 return PyString_FromString(str.c_str());
1065 else
1066 RETURN_NONE();
1067 }
1068 PyObject* GetMimeTypes() {
1069 wxArrayString arr;
1070 if (self->GetMimeTypes(arr))
1071 return wxArrayString2PyList_helper(arr);
1072 else
1073 RETURN_NONE();
1074 }
1075 }
1076
1077
1078 // Get all extensions associated with this file type
1079 %addmethods {
1080 PyObject* GetExtensions() {
1081 wxArrayString arr;
1082 if (self->GetExtensions(arr))
1083 return wxArrayString2PyList_helper(arr);
1084 else
1085 RETURN_NONE();
1086 }
1087 }
1088
1089
1090 %addmethods {
1091 // Get the icon corresponding to this file type
1092 %new wxIcon* GetIcon() {
1093 wxIcon icon;
1094 if (self->GetIcon(&icon))
1095 return new wxIcon(icon);
1096 else
1097 return NULL;
1098 }
1099
1100 // Get the icon corresponding to this file type, the name of the file
1101 // where this icon resides, and its index in this file if applicable.
1102 PyObject* GetIconInfo() {
1103 wxIcon icon;
1104 wxString iconFile;
1105 int iconIndex;
1106 if (self->GetIcon(&icon, &iconFile, &iconIndex)) {
1107 wxPyBeginBlockThreads();
1108 PyObject* tuple = PyTuple_New(3);
1109 PyTuple_SetItem(tuple, 0, wxPyConstructObject(new wxIcon(icon),
1110 "wxIcon", TRUE));
1111 PyTuple_SetItem(tuple, 1, PyString_FromString(iconFile.c_str()));
1112 PyTuple_SetItem(tuple, 2, PyInt_FromLong(iconIndex));
1113 wxPyEndBlockThreads();
1114 return tuple;
1115 }
1116 else
1117 RETURN_NONE();
1118 }
1119 }
1120
1121 %addmethods {
1122 // get a brief file type description ("*.txt" => "text document")
1123 PyObject* GetDescription() {
1124 wxString str;
1125 if (self->GetDescription(&str))
1126 return PyString_FromString(str.c_str());
1127 else
1128 RETURN_NONE();
1129 }
1130 }
1131
1132
1133 // get the command to open/execute the file of given type
1134 %addmethods {
1135 PyObject* GetOpenCommand(const wxString& filename,
1136 const wxString& mimetype=wxEmptyString) {
1137 wxString str;
1138 if (self->GetOpenCommand(&str, wxFileType::MessageParameters(filename, mimetype)))
1139 return PyString_FromString(str.c_str());
1140 else
1141 RETURN_NONE();
1142 }
1143 }
1144
1145
1146 // get the command to print the file of given type
1147 %addmethods {
1148 PyObject* GetPrintCommand(const wxString& filename,
1149 const wxString& mimetype=wxEmptyString) {
1150 wxString str;
1151 if (self->GetPrintCommand(&str, wxFileType::MessageParameters(filename, mimetype)))
1152 return PyString_FromString(str.c_str());
1153 else
1154 RETURN_NONE();
1155 }
1156 }
1157
1158
1159 // Get all commands defined for this file type
1160 %addmethods {
1161 PyObject* GetAllCommands(const wxString& filename,
1162 const wxString& mimetype=wxEmptyString) {
1163 wxArrayString verbs;
1164 wxArrayString commands;
1165 if (self->GetAllCommands(&verbs, &commands,
1166 wxFileType::MessageParameters(filename, mimetype))) {
1167 wxPyBeginBlockThreads();
1168 PyObject* tuple = PyTuple_New(2);
1169 PyTuple_SetItem(tuple, 0, wxArrayString2PyList_helper(verbs));
1170 PyTuple_SetItem(tuple, 1, wxArrayString2PyList_helper(commands));
1171 wxPyEndBlockThreads();
1172 return tuple;
1173 }
1174 else
1175 RETURN_NONE();
1176 }
1177 }
1178
1179
1180 // set an arbitrary command, ask confirmation if it already exists and
1181 // overwriteprompt is TRUE
1182 bool SetCommand(const wxString& cmd, const wxString& verb,
1183 bool overwriteprompt = TRUE);
1184
1185 bool SetDefaultIcon(const wxString& cmd = wxEmptyString, int index = 0);
1186
1187
1188 // remove the association for this filetype from the system MIME database:
1189 // notice that it will only work if the association is defined in the user
1190 // file/registry part, we will never modify the system-wide settings
1191 bool Unassociate();
1192
1193 // operations
1194 // expand a string in the format of GetOpenCommand (which may contain
1195 // '%s' and '%t' format specificators for the file name and mime type
1196 // and %{param} constructions).
1197 static wxString ExpandCommand(const wxString& command,
1198 const MessageParameters& params);
1199
1200 // dtor (not virtual, shouldn't be derived from)
1201 ~wxFileType();
1202
1203 };
1204
1205
1206
1207
1208 class wxMimeTypesManager
1209 {
1210 public:
1211 // static helper functions
1212 // -----------------------
1213
1214 // check if the given MIME type is the same as the other one: the
1215 // second argument may contain wildcards ('*'), but not the first. If
1216 // the types are equal or if the mimeType matches wildcard the function
1217 // returns TRUE, otherwise it returns FALSE
1218 static bool IsOfType(const wxString& mimeType, const wxString& wildcard);
1219
1220 // ctor
1221 wxMimeTypesManager();
1222
1223 // loads data from standard files according to the mailcap styles
1224 // specified: this is a bitwise OR of wxMailcapStyle values
1225 //
1226 // use the extraDir parameter if you want to look for files in another
1227 // directory
1228 void Initialize(int mailcapStyle = wxMAILCAP_STANDARD,
1229 const wxString& extraDir = wxEmptyString);
1230
1231 // and this function clears all the data from the manager
1232 void ClearData();
1233
1234 // Database lookup: all functions return a pointer to wxFileType object
1235 // whose methods may be used to query it for the information you're
1236 // interested in. If the return value is !NULL, caller is responsible for
1237 // deleting it.
1238 // get file type from file extension
1239 %new wxFileType *GetFileTypeFromExtension(const wxString& ext);
1240
1241 // get file type from MIME type (in format <category>/<format>)
1242 %new wxFileType *GetFileTypeFromMimeType(const wxString& mimeType);
1243
1244 // other operations: return TRUE if there were no errors or FALSE if there
1245 // were some unreckognized entries (the good entries are always read anyhow)
1246 //
1247
1248 // read in additional file (the standard ones are read automatically)
1249 // in mailcap format (see mimetype.cpp for description)
1250 //
1251 // 'fallback' parameter may be set to TRUE to avoid overriding the
1252 // settings from other, previously parsed, files by this one: normally,
1253 // the files read most recently would override the older files, but with
1254 // fallback == TRUE this won't happen
1255 bool ReadMailcap(const wxString& filename, bool fallback = FALSE);
1256
1257 // read in additional file in mime.types format
1258 bool ReadMimeTypes(const wxString& filename);
1259
1260 // enumerate all known MIME types
1261 %addmethods {
1262 PyObject* EnumAllFileTypes() {
1263 wxArrayString arr;
1264 self->EnumAllFileTypes(arr);
1265 return wxArrayString2PyList_helper(arr);
1266 }
1267 }
1268
1269 // these functions can be used to provide default values for some of the
1270 // MIME types inside the program itself (you may also use
1271 // ReadMailcap(filenameWithDefaultTypes, TRUE /* use as fallback */) to
1272 // achieve the same goal, but this requires having this info in a file).
1273 //
1274 void AddFallback(const wxFileTypeInfo& ft);
1275
1276
1277 // create or remove associations
1278
1279 // create a new association using the fields of wxFileTypeInfo (at least
1280 // the MIME type and the extension should be set)
1281 // if the other fields are empty, the existing values should be left alone
1282 %new wxFileType *Associate(const wxFileTypeInfo& ftInfo);
1283
1284 // undo Associate()
1285 bool Unassociate(wxFileType *ft) ;
1286
1287 // dtor (not virtual, shouldn't be derived from)
1288 ~wxMimeTypesManager();
1289 };
1290
1291
1292 %readonly
1293 %{
1294 #if 0
1295 %}
1296 extern wxMimeTypesManager* wxTheMimeTypesManager;
1297 %{
1298 #endif
1299 %}
1300 %readwrite
1301
1302 //----------------------------------------------------------------------
1303
1304 %{
1305 #include <wx/docview.h>
1306 %}
1307
1308 class wxFileHistory : public wxObject
1309 {
1310 public:
1311 wxFileHistory(int maxFiles = 9);
1312 ~wxFileHistory();
1313
1314 // Operations
1315 void AddFileToHistory(const wxString& file);
1316 void RemoveFileFromHistory(int i);
1317 int GetMaxFiles() const;
1318 void UseMenu(wxMenu *menu);
1319
1320 // Remove menu from the list (MDI child may be closing)
1321 void RemoveMenu(wxMenu *menu);
1322
1323 void Load(wxConfigBase& config);
1324 void Save(wxConfigBase& config);
1325
1326 void AddFilesToMenu();
1327 %name(AddFilesToSingleMenu)void AddFilesToMenu(wxMenu* menu);
1328
1329 // Accessors
1330 wxString GetHistoryFile(int i) const;
1331
1332 // A synonym for GetNoHistoryFiles
1333 int GetCount() const;
1334 int GetNoHistoryFiles() const;
1335
1336 };
1337
1338 //----------------------------------------------------------------------
1339 //----------------------------------------------------------------------
1340
1341
1342 %init %{
1343 wxPyPtrTypeMap_Add("wxFontEnumerator", "wxPyFontEnumerator");
1344 wxPyPtrTypeMap_Add("wxDragImage", "wxGenericDragImage");
1345 wxPyPtrTypeMap_Add("wxProcess", "wxPyProcess");
1346 %}
1347
1348 //----------------------------------------------------------------------
1349