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