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