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