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