]> git.saurik.com Git - wxWidgets.git/blob - wxPython/src/misc2.i
fixed another return FALSE in a function returning a pointer (patch 545046)
[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;
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 wxLogChain : public wxLog
636 {
637 public:
638 wxLogChain(wxLog *logger);
639 void SetLog(wxLog *logger);
640 void PassMessages(bool bDoPass);
641 bool IsPassingMessages();
642 wxLog *GetOldLog();
643 };
644
645
646 unsigned long wxSysErrorCode();
647 const wxString wxSysErrorMsg(unsigned long nErrCode = 0);
648 void wxLogFatalError(const wxString& szFormat);
649 void wxLogError(const wxString& szFormat);
650 void wxLogWarning(const wxString& szFormat);
651 void wxLogMessage(const wxString& szFormat);
652 void wxLogInfo(const wxString& szFormat);
653 void wxLogVerbose(const wxString& szFormat);
654 void wxLogStatus(const wxString& szFormat);
655 %name(wxLogStatusFrame)void wxLogStatus(wxFrame *pFrame, const wxString& szFormat);
656 void wxLogSysError(const wxString& szFormat);
657
658 // Suspress logging while an instance of this class exists
659 class wxLogNull
660 {
661 public:
662 wxLogNull();
663 ~wxLogNull();
664 };
665
666
667
668
669 %{
670 // A wxLog class that can be derived from in wxPython
671 class wxPyLog : public wxLog {
672 public:
673 wxPyLog() : wxLog() {}
674
675 virtual void DoLog(wxLogLevel level, const wxChar *szString, time_t t) {
676 bool found;
677 wxPyBeginBlockThreads();
678 if ((found = wxPyCBH_findCallback(m_myInst, "DoLog")))
679 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iOi)", level,
680 wx2PyString(szString), t));
681 wxPyEndBlockThreads();
682 if (! found)
683 wxLog::DoLog(level, szString, t);
684 }
685
686 virtual void DoLogString(const wxChar *szString, time_t t) {
687 bool found;
688 wxPyBeginBlockThreads();
689 if ((found = wxPyCBH_findCallback(m_myInst, "DoLogString")))
690 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oi)",
691 wx2PyString(szString), t));
692 wxPyEndBlockThreads();
693 if (! found)
694 wxLog::DoLogString(szString, t);
695 }
696
697 PYPRIVATE;
698 };
699 %}
700
701 // Now tell SWIG about it
702 class wxPyLog : public wxLog {
703 public:
704 wxPyLog();
705 void _setCallbackInfo(PyObject* self, PyObject* _class);
706 %pragma(python) addtomethod = "__init__:self._setCallbackInfo(self, wxPyLog)"
707 %addmethods { void Destroy() { delete self; } }
708
709 };
710
711
712 //----------------------------------------------------------------------
713
714
715 enum {
716 /* event type */
717 wxEVT_END_PROCESS
718 };
719
720
721 class wxProcessEvent : public wxEvent {
722 public:
723 wxProcessEvent(int id = 0, int pid = 0, int exitcode = 0);
724 int GetPid();
725 int GetExitCode();
726 int m_pid, m_exitcode;
727 };
728
729
730
731
732 %{ // C++ version of wxProcess derived class
733
734 class wxPyProcess : public wxProcess {
735 public:
736 wxPyProcess(wxEvtHandler *parent = NULL, int id = -1)
737 : wxProcess(parent, id)
738 {}
739
740 DEC_PYCALLBACK_VOID_INTINT(OnTerminate);
741
742 PYPRIVATE;
743 };
744
745 IMP_PYCALLBACK_VOID_INTINT( wxPyProcess, wxProcess, OnTerminate);
746
747 %}
748
749
750 %name(wxProcess)class wxPyProcess : public wxEvtHandler {
751 public:
752 wxPyProcess(wxEvtHandler *parent = NULL, int id = -1);
753 %addmethods { void Destroy() { delete self; } }
754
755 void _setCallbackInfo(PyObject* self, PyObject* _class);
756 %pragma(python) addtomethod = "__init__:self._setCallbackInfo(self, wxProcess)"
757
758 void base_OnTerminate(int pid, int status);
759
760 void Redirect();
761 bool IsRedirected();
762 void Detach();
763
764 wxInputStream *GetInputStream();
765 wxInputStream *GetErrorStream();
766 wxOutputStream *GetOutputStream();
767
768 void CloseOutput();
769 };
770
771
772 enum
773 {
774 // execute the process asynchronously
775 wxEXEC_ASYNC = 0,
776
777 // execute it synchronously, i.e. wait until it finishes
778 wxEXEC_SYNC = 1,
779
780 // under Windows, don't hide the child even if it's IO is redirected (this
781 // is done by default)
782 wxEXEC_NOHIDE = 2,
783
784 // under Unix, if the process is the group leader then killing -pid kills
785 // all children as well as pid
786 wxEXEC_MAKE_GROUP_LEADER = 4
787 };
788
789
790 long wxExecute(const wxString& command,
791 int flags = wxEXEC_ASYNC,
792 wxPyProcess *process = NULL);
793
794 //----------------------------------------------------------------------
795
796 %{
797 #if !wxUSE_JOYSTICK && !defined(__WXMSW__)
798 // A C++ stub class for wxJoystick for platforms that don't have it.
799 class wxJoystick : public wxObject {
800 public:
801 wxJoystick(int joystick = wxJOYSTICK1) {
802 wxPyBeginBlockThreads();
803 PyErr_SetString(PyExc_NotImplementedError, "wxJoystick is not available on this platform.");
804 wxPyEndBlockThreads();
805 }
806 wxPoint GetPosition() { return wxPoint(-1,-1); }
807 int GetZPosition() { return -1; }
808 int GetButtonState() { return -1; }
809 int GetPOVPosition() { return -1; }
810 int GetPOVCTSPosition() { return -1; }
811 int GetRudderPosition() { return -1; }
812 int GetUPosition() { return -1; }
813 int GetVPosition() { return -1; }
814 int GetMovementThreshold() { return -1; }
815 void SetMovementThreshold(int threshold) {}
816
817 bool IsOk(void) { return FALSE; }
818 int GetNumberJoysticks() { return -1; }
819 int GetManufacturerId() { return -1; }
820 int GetProductId() { return -1; }
821 wxString GetProductName() { return ""; }
822 int GetXMin() { return -1; }
823 int GetYMin() { return -1; }
824 int GetZMin() { return -1; }
825 int GetXMax() { return -1; }
826 int GetYMax() { return -1; }
827 int GetZMax() { return -1; }
828 int GetNumberButtons() { return -1; }
829 int GetNumberAxes() { return -1; }
830 int GetMaxButtons() { return -1; }
831 int GetMaxAxes() { return -1; }
832 int GetPollingMin() { return -1; }
833 int GetPollingMax() { return -1; }
834 int GetRudderMin() { return -1; }
835 int GetRudderMax() { return -1; }
836 int GetUMin() { return -1; }
837 int GetUMax() { return -1; }
838 int GetVMin() { return -1; }
839 int GetVMax() { return -1; }
840
841 bool HasRudder() { return FALSE; }
842 bool HasZ() { return FALSE; }
843 bool HasU() { return FALSE; }
844 bool HasV() { return FALSE; }
845 bool HasPOV() { return FALSE; }
846 bool HasPOV4Dir() { return FALSE; }
847 bool HasPOVCTS() { return FALSE; }
848
849 bool SetCapture(wxWindow* win, int pollingFreq = 0) { return FALSE; }
850 bool ReleaseCapture() { return FALSE; }
851 };
852 #endif
853 %}
854
855
856 class wxJoystick : public wxObject {
857 public:
858 wxJoystick(int joystick = wxJOYSTICK1);
859 ~wxJoystick();
860
861 wxPoint GetPosition();
862 int GetZPosition();
863 int GetButtonState();
864 int GetPOVPosition();
865 int GetPOVCTSPosition();
866 int GetRudderPosition();
867 int GetUPosition();
868 int GetVPosition();
869 int GetMovementThreshold();
870 void SetMovementThreshold(int threshold) ;
871
872 bool IsOk(void);
873 int GetNumberJoysticks();
874 int GetManufacturerId();
875 int GetProductId();
876 wxString GetProductName();
877 int GetXMin();
878 int GetYMin();
879 int GetZMin();
880 int GetXMax();
881 int GetYMax();
882 int GetZMax();
883 int GetNumberButtons();
884 int GetNumberAxes();
885 int GetMaxButtons();
886 int GetMaxAxes();
887 int GetPollingMin();
888 int GetPollingMax();
889 int GetRudderMin();
890 int GetRudderMax();
891 int GetUMin();
892 int GetUMax();
893 int GetVMin();
894 int GetVMax();
895
896 bool HasRudder();
897 bool HasZ();
898 bool HasU();
899 bool HasV();
900 bool HasPOV();
901 bool HasPOV4Dir();
902 bool HasPOVCTS();
903
904 bool SetCapture(wxWindow* win, int pollingFreq = 0);
905 bool ReleaseCapture();
906 };
907
908 //----------------------------------------------------------------------
909
910 %{
911 #if !wxUSE_WAVE
912 // A C++ stub class for wxWave for platforms that don't have it.
913 class wxWave : public wxObject
914 {
915 public:
916 wxWave(const wxString& fileName, bool isResource = FALSE) {
917 wxPyBeginBlockThreads();
918 PyErr_SetString(PyExc_NotImplementedError, "wxWave is not available on this platform.");
919 wxPyEndBlockThreads();
920 }
921 wxWave(int size, const wxByte* data) {
922 wxPyBeginBlockThreads();
923 PyErr_SetString(PyExc_NotImplementedError, "wxWave is not available on this platform.");
924 wxPyEndBlockThreads();
925 }
926
927 ~wxWave() {}
928
929 bool IsOk() const { return FALSE; }
930 bool Play(bool async = TRUE, bool looped = FALSE) const { return FALSE; }
931 };
932
933 #endif
934 %}
935
936 class wxWave : public wxObject
937 {
938 public:
939 wxWave(const wxString& fileName, bool isResource = FALSE);
940 ~wxWave();
941
942 bool IsOk() const;
943 bool Play(bool async = TRUE, bool looped = FALSE) const;
944 };
945
946 %new wxWave* wxWaveData(const wxString& data);
947 %{ // Implementations of some alternate "constructors"
948 wxWave* wxWaveData(const wxString& data) {
949 return new wxWave(data.Len(), (wxByte*)data.c_str());
950 }
951 %}
952
953
954 //----------------------------------------------------------------------
955
956 enum wxMailcapStyle
957 {
958 wxMAILCAP_STANDARD = 1,
959 wxMAILCAP_NETSCAPE = 2,
960 wxMAILCAP_KDE = 4,
961 wxMAILCAP_GNOME = 8,
962
963 wxMAILCAP_ALL = 15
964 };
965
966
967
968 class wxFileTypeInfo
969 {
970 public:
971 // ctors
972 // a normal item
973 wxFileTypeInfo(const char* mimeType,
974 const char* openCmd,
975 const char* printCmd,
976 const char* desc);
977
978
979 // the array elements correspond to the parameters of the ctor above in
980 // the same order
981 %name(wxFileTypeInfoSequence)wxFileTypeInfo(const wxArrayString& sArray);
982
983 // invalid item - use this to terminate the array passed to
984 // wxMimeTypesManager::AddFallbacks
985 %name(wxNullFileTypeInfo)wxFileTypeInfo();
986
987
988 // test if this object can be used
989 bool IsValid() const;
990
991 // setters
992 // set the icon info
993 void SetIcon(const wxString& iconFile, int iconIndex = 0);
994
995 // set the short desc
996 void SetShortDesc(const wxString& shortDesc);
997
998 // accessors
999 // get the MIME type
1000 const wxString& GetMimeType() const;
1001 // get the open command
1002 const wxString& GetOpenCommand() const;
1003 // get the print command
1004 const wxString& GetPrintCommand() const;
1005 // get the short description (only used under Win32 so far)
1006 const wxString& GetShortDesc() const;
1007 // get the long, user visible description
1008 const wxString& GetDescription() const;
1009
1010
1011 // get the array of all extensions
1012 //const wxArrayString& GetExtensions() const;
1013 %addmethods {
1014 PyObject* GetExtensions() {
1015 wxArrayString& arr = (wxArrayString&)self->GetExtensions();
1016 return wxArrayString2PyList_helper(arr);
1017 }
1018 }
1019
1020 int GetExtensionsCount() const;
1021
1022 // get the icon info
1023 const wxString& GetIconFile() const;
1024 int GetIconIndex() const;
1025 };
1026
1027
1028
1029
1030 class wxFileType
1031 {
1032 public:
1033
1034 // TODO: Make a wxPyMessageParameters with virtual GetParamValue...
1035
1036 // An object of this class must be passed to Get{Open|Print}Command. The
1037 // default implementation is trivial and doesn't know anything at all about
1038 // parameters, only filename and MIME type are used (so it's probably ok for
1039 // Windows where %{param} is not used anyhow)
1040 class MessageParameters
1041 {
1042 public:
1043 // ctors
1044 MessageParameters(const wxString& filename=wxPyEmptyString,
1045 const wxString& mimetype=wxPyEmptyString);
1046
1047 // accessors (called by GetOpenCommand)
1048 // filename
1049 const wxString& GetFileName() const;
1050 // mime type
1051 const wxString& GetMimeType() const;;
1052
1053 // override this function in derived class
1054 virtual wxString GetParamValue(const wxString& name) const;
1055
1056 // virtual dtor as in any base class
1057 virtual ~MessageParameters();
1058 };
1059
1060
1061 // ctor from static data
1062 wxFileType(const wxFileTypeInfo& ftInfo);
1063
1064 // return the MIME type for this file type
1065 %addmethods {
1066 PyObject* GetMimeType() {
1067 wxString str;
1068 if (self->GetMimeType(&str)) {
1069 #if wxUSE_UNICODE
1070 return PyUnicode_FromUnicode(str.c_str(), str.Len());
1071 #else
1072 return PyString_FromStringAndSize(str.c_str(), str.Len());
1073 #endif
1074 }
1075 else
1076 RETURN_NONE();
1077 }
1078 PyObject* GetMimeTypes() {
1079 wxArrayString arr;
1080 if (self->GetMimeTypes(arr))
1081 return wxArrayString2PyList_helper(arr);
1082 else
1083 RETURN_NONE();
1084 }
1085 }
1086
1087
1088 // Get all extensions associated with this file type
1089 %addmethods {
1090 PyObject* GetExtensions() {
1091 wxArrayString arr;
1092 if (self->GetExtensions(arr))
1093 return wxArrayString2PyList_helper(arr);
1094 else
1095 RETURN_NONE();
1096 }
1097 }
1098
1099
1100 %addmethods {
1101 // Get the icon corresponding to this file type
1102 %new wxIcon* GetIcon() {
1103 wxIcon icon;
1104 if (self->GetIcon(&icon))
1105 return new wxIcon(icon);
1106 else
1107 return NULL;
1108 }
1109
1110 // Get the icon corresponding to this file type, the name of the file
1111 // where this icon resides, and its index in this file if applicable.
1112 PyObject* GetIconInfo() {
1113 wxIcon icon;
1114 wxString iconFile;
1115 int iconIndex;
1116 if (self->GetIcon(&icon, &iconFile, &iconIndex)) {
1117 wxPyBeginBlockThreads();
1118 PyObject* tuple = PyTuple_New(3);
1119 PyTuple_SetItem(tuple, 0, wxPyConstructObject(new wxIcon(icon),
1120 "wxIcon", TRUE));
1121 #if wxUSE_UNICODE
1122 PyTuple_SetItem(tuple, 1, PyUnicode_FromUnicode(iconFile.c_str(), iconFile.Len()));
1123 #else
1124 PyTuple_SetItem(tuple, 1, PyString_FromStringAndSize(iconFile.c_str(), iconFile.Len()));
1125 #endif
1126 PyTuple_SetItem(tuple, 2, PyInt_FromLong(iconIndex));
1127 wxPyEndBlockThreads();
1128 return tuple;
1129 }
1130 else
1131 RETURN_NONE();
1132 }
1133 }
1134
1135 %addmethods {
1136 // get a brief file type description ("*.txt" => "text document")
1137 PyObject* GetDescription() {
1138 wxString str;
1139 if (self->GetDescription(&str)) {
1140 #if wxUSE_UNICODE
1141 return PyUnicode_FromUnicode(str.c_str(), str.Len());
1142 #else
1143 return PyString_FromStringAndSize(str.c_str(), str.Len());
1144 #endif
1145 } else
1146 RETURN_NONE();
1147 }
1148 }
1149
1150
1151 // get the command to open/execute the file of given type
1152 %addmethods {
1153 PyObject* GetOpenCommand(const wxString& filename,
1154 const wxString& mimetype=wxPyEmptyString) {
1155 wxString str;
1156 if (self->GetOpenCommand(&str, wxFileType::MessageParameters(filename, mimetype))) {
1157 #if wxUSE_UNICODE
1158 return PyUnicode_FromUnicode(str.c_str(), str.Len());
1159 #else
1160 return PyString_FromStringAndSize(str.c_str(), str.Len());
1161 #endif
1162 } else
1163 RETURN_NONE();
1164 }
1165 }
1166
1167
1168 // get the command to print the file of given type
1169 %addmethods {
1170 PyObject* GetPrintCommand(const wxString& filename,
1171 const wxString& mimetype=wxPyEmptyString) {
1172 wxString str;
1173 if (self->GetPrintCommand(&str, wxFileType::MessageParameters(filename, mimetype))) {
1174 #if wxUSE_UNICODE
1175 return PyUnicode_FromUnicode(str.c_str(), str.Len());
1176 #else
1177 return PyString_FromStringAndSize(str.c_str(), str.Len());
1178 #endif
1179 } else
1180 RETURN_NONE();
1181 }
1182 }
1183
1184
1185 // Get all commands defined for this file type
1186 %addmethods {
1187 PyObject* GetAllCommands(const wxString& filename,
1188 const wxString& mimetype=wxPyEmptyString) {
1189 wxArrayString verbs;
1190 wxArrayString commands;
1191 if (self->GetAllCommands(&verbs, &commands,
1192 wxFileType::MessageParameters(filename, mimetype))) {
1193 wxPyBeginBlockThreads();
1194 PyObject* tuple = PyTuple_New(2);
1195 PyTuple_SetItem(tuple, 0, wxArrayString2PyList_helper(verbs));
1196 PyTuple_SetItem(tuple, 1, wxArrayString2PyList_helper(commands));
1197 wxPyEndBlockThreads();
1198 return tuple;
1199 }
1200 else
1201 RETURN_NONE();
1202 }
1203 }
1204
1205
1206 // set an arbitrary command, ask confirmation if it already exists and
1207 // overwriteprompt is TRUE
1208 bool SetCommand(const wxString& cmd, const wxString& verb,
1209 bool overwriteprompt = TRUE);
1210
1211 bool SetDefaultIcon(const wxString& cmd = wxPyEmptyString, int index = 0);
1212
1213
1214 // remove the association for this filetype from the system MIME database:
1215 // notice that it will only work if the association is defined in the user
1216 // file/registry part, we will never modify the system-wide settings
1217 bool Unassociate();
1218
1219 // operations
1220 // expand a string in the format of GetOpenCommand (which may contain
1221 // '%s' and '%t' format specificators for the file name and mime type
1222 // and %{param} constructions).
1223 static wxString ExpandCommand(const wxString& command,
1224 const MessageParameters& params);
1225
1226 // dtor (not virtual, shouldn't be derived from)
1227 ~wxFileType();
1228
1229 };
1230
1231
1232
1233
1234 class wxMimeTypesManager
1235 {
1236 public:
1237 // static helper functions
1238 // -----------------------
1239
1240 // check if the given MIME type is the same as the other one: the
1241 // second argument may contain wildcards ('*'), but not the first. If
1242 // the types are equal or if the mimeType matches wildcard the function
1243 // returns TRUE, otherwise it returns FALSE
1244 static bool IsOfType(const wxString& mimeType, const wxString& wildcard);
1245
1246 // ctor
1247 wxMimeTypesManager();
1248
1249 // loads data from standard files according to the mailcap styles
1250 // specified: this is a bitwise OR of wxMailcapStyle values
1251 //
1252 // use the extraDir parameter if you want to look for files in another
1253 // directory
1254 void Initialize(int mailcapStyle = wxMAILCAP_STANDARD,
1255 const wxString& extraDir = wxPyEmptyString);
1256
1257 // and this function clears all the data from the manager
1258 void ClearData();
1259
1260 // Database lookup: all functions return a pointer to wxFileType object
1261 // whose methods may be used to query it for the information you're
1262 // interested in. If the return value is !NULL, caller is responsible for
1263 // deleting it.
1264 // get file type from file extension
1265 %new wxFileType *GetFileTypeFromExtension(const wxString& ext);
1266
1267 // get file type from MIME type (in format <category>/<format>)
1268 %new wxFileType *GetFileTypeFromMimeType(const wxString& mimeType);
1269
1270 // other operations: return TRUE if there were no errors or FALSE if there
1271 // were some unreckognized entries (the good entries are always read anyhow)
1272 //
1273
1274 // read in additional file (the standard ones are read automatically)
1275 // in mailcap format (see mimetype.cpp for description)
1276 //
1277 // 'fallback' parameter may be set to TRUE to avoid overriding the
1278 // settings from other, previously parsed, files by this one: normally,
1279 // the files read most recently would override the older files, but with
1280 // fallback == TRUE this won't happen
1281 bool ReadMailcap(const wxString& filename, bool fallback = FALSE);
1282
1283 // read in additional file in mime.types format
1284 bool ReadMimeTypes(const wxString& filename);
1285
1286 // enumerate all known MIME types
1287 %addmethods {
1288 PyObject* EnumAllFileTypes() {
1289 wxArrayString arr;
1290 self->EnumAllFileTypes(arr);
1291 return wxArrayString2PyList_helper(arr);
1292 }
1293 }
1294
1295 // these functions can be used to provide default values for some of the
1296 // MIME types inside the program itself (you may also use
1297 // ReadMailcap(filenameWithDefaultTypes, TRUE /* use as fallback */) to
1298 // achieve the same goal, but this requires having this info in a file).
1299 //
1300 void AddFallback(const wxFileTypeInfo& ft);
1301
1302
1303 // create or remove associations
1304
1305 // create a new association using the fields of wxFileTypeInfo (at least
1306 // the MIME type and the extension should be set)
1307 // if the other fields are empty, the existing values should be left alone
1308 %new wxFileType *Associate(const wxFileTypeInfo& ftInfo);
1309
1310 // undo Associate()
1311 bool Unassociate(wxFileType *ft) ;
1312
1313 // dtor (not virtual, shouldn't be derived from)
1314 ~wxMimeTypesManager();
1315 };
1316
1317
1318 %readonly
1319 %{
1320 #if 0
1321 %}
1322 extern wxMimeTypesManager* wxTheMimeTypesManager;
1323 %{
1324 #endif
1325 %}
1326 %readwrite
1327
1328 //----------------------------------------------------------------------
1329
1330 %{
1331 #include <wx/docview.h>
1332 %}
1333
1334 class wxFileHistory : public wxObject
1335 {
1336 public:
1337 wxFileHistory(int maxFiles = 9);
1338 ~wxFileHistory();
1339
1340 // Operations
1341 void AddFileToHistory(const wxString& file);
1342 void RemoveFileFromHistory(int i);
1343 int GetMaxFiles() const;
1344 void UseMenu(wxMenu *menu);
1345
1346 // Remove menu from the list (MDI child may be closing)
1347 void RemoveMenu(wxMenu *menu);
1348
1349 void Load(wxConfigBase& config);
1350 void Save(wxConfigBase& config);
1351
1352 void AddFilesToMenu();
1353 %name(AddFilesToThisMenu)void AddFilesToMenu(wxMenu* menu);
1354
1355 // Accessors
1356 wxString GetHistoryFile(int i) const;
1357
1358 // A synonym for GetNoHistoryFiles
1359 int GetCount() const;
1360 int GetNoHistoryFiles() const;
1361
1362 };
1363
1364 //----------------------------------------------------------------------
1365 //----------------------------------------------------------------------
1366
1367
1368 %init %{
1369 wxPyPtrTypeMap_Add("wxDragImage", "wxGenericDragImage");
1370 wxPyPtrTypeMap_Add("wxProcess", "wxPyProcess");
1371 %}
1372
1373 //----------------------------------------------------------------------
1374