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