]> git.saurik.com Git - wxWidgets.git/blame - wxPython/src/misc2.i
Unicode fix from Will
[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"
4152e8b9 19#include "pyistream.h"
bb0054cd 20#include <wx/tooltip.h>
f0261a72 21#include <wx/caret.h>
f6bcfd97 22#include <wx/tipdlg.h>
c368d904 23#include <wx/process.h>
493f1553
RD
24
25#if wxUSE_JOYSTICK || defined(__WXMSW__)
185d7c3e 26#include <wx/joystick.h>
4662be59 27#endif
493f1553
RD
28
29#if wxUSE_WAVE || defined(__WXMSW__)
30#include <wx/wave.h>
31#endif
b37c7e1d
RD
32
33#include <wx/mimetype.h>
fd512ba2
RD
34#include <wx/snglinst.h>
35#include <wx/effects.h>
3ef86e32 36#include <wx/sysopt.h>
bb0054cd
RD
37%}
38
39//----------------------------------------------------------------------
40
41%include typemaps.i
42%include my_typemaps.i
43
44// Import some definitions of other classes, etc.
45%import _defs.i
46%import windows.i
f0261a72 47%import misc.i
06c0fba4 48%import gdi.i
b1462dfa 49%import events.i
c368d904 50%import streams.i
7dbce44a 51%import utils.i
06c0fba4 52
b68dc582 53
137b5242
RD
54//----------------------------------------------------------------------
55
56%{
57 // Put some wx default wxChar* values into wxStrings.
58 DECLARE_DEF_STRING(FileSelectorPromptStr);
59 DECLARE_DEF_STRING(FileSelectorDefaultWildcardStr);
7cdaed0b 60 DECLARE_DEF_STRING(DirSelectorPromptStr);
137b5242
RD
61 static const wxString wxPyEmptyString(wxT(""));
62%}
63
06c0fba4
RD
64//---------------------------------------------------------------------------
65// Dialog Functions
66
137b5242
RD
67wxString wxFileSelector(const wxString& message = wxPyFileSelectorPromptStr,
68 const wxString& default_path = wxPyEmptyString,
69 const wxString& default_filename = wxPyEmptyString,
70 const wxString& default_extension = wxPyEmptyString,
71 const wxString& wildcard = wxPyFileSelectorDefaultWildcardStr,
06c0fba4
RD
72 int flags = 0,
73 wxWindow *parent = NULL,
74 int x = -1, int y = -1);
a541c325 75
3ef86e32
RD
76// TODO: wxFileSelectorEx
77
78
a541c325 79// Ask for filename to load
137b5242
RD
80wxString wxLoadFileSelector(const wxString& what,
81 const wxString& extension,
82 const wxString& default_name = wxPyEmptyString,
a541c325
RD
83 wxWindow *parent = NULL);
84
85// Ask for filename to save
137b5242
RD
86wxString wxSaveFileSelector(const wxString& what,
87 const wxString& extension,
88 const wxString& default_name = wxPyEmptyString,
a541c325 89 wxWindow *parent = NULL);
06c0fba4 90
7cdaed0b
RD
91
92wxString wxDirSelector(const wxString& message = wxPyDirSelectorPromptStr,
93 const wxString& defaultPath = wxPyEmptyString,
daa3eac9 94 long style = wxDD_DEFAULT_STYLE,
7cdaed0b
RD
95 const wxPoint& pos = wxDefaultPosition,
96 wxWindow *parent = NULL);
97
06c0fba4 98wxString wxGetTextFromUser(const wxString& message,
137b5242
RD
99 const wxString& caption = wxPyEmptyString,
100 const wxString& default_value = wxPyEmptyString,
06c0fba4
RD
101 wxWindow *parent = NULL,
102 int x = -1, int y = -1,
103 bool centre = TRUE);
104
1b62f00d 105wxString wxGetPasswordFromUser(const wxString& message,
137b5242
RD
106 const wxString& caption = wxPyEmptyString,
107 const wxString& default_value = wxPyEmptyString,
1b62f00d
RD
108 wxWindow *parent = NULL);
109
06c0fba4
RD
110
111// TODO: Need to custom wrap this one...
112// int wxGetMultipleChoice(char* message, char* caption,
eec92d76 113// int LCOUNT, char** choices,
06c0fba4
RD
114// int nsel, int *selection,
115// wxWindow *parent = NULL, int x = -1, int y = -1,
116// bool centre = TRUE, int width=150, int height=200);
117
118
119wxString wxGetSingleChoice(const wxString& message, const wxString& caption,
eec92d76 120 int LCOUNT, wxString* choices,
06c0fba4
RD
121 wxWindow *parent = NULL,
122 int x = -1, int y = -1,
123 bool centre = TRUE,
124 int width=150, int height=200);
125
126int wxGetSingleChoiceIndex(const wxString& message, const wxString& caption,
eec92d76 127 int LCOUNT, wxString* choices,
06c0fba4
RD
128 wxWindow *parent = NULL,
129 int x = -1, int y = -1,
130 bool centre = TRUE,
131 int width=150, int height=200);
132
133
134int wxMessageBox(const wxString& message,
137b5242 135 const wxString& caption = wxPyEmptyString,
06c0fba4
RD
136 int style = wxOK | wxCENTRE,
137 wxWindow *parent = NULL,
138 int x = -1, int y = -1);
139
140long wxGetNumberFromUser(const wxString& message,
141 const wxString& prompt,
142 const wxString& caption,
143 long value,
144 long min = 0, long max = 100,
145 wxWindow *parent = NULL,
b68dc582 146 const wxPoint& pos = wxDefaultPosition);
06c0fba4
RD
147
148//---------------------------------------------------------------------------
149// GDI Functions
150
151bool wxColourDisplay();
1e7ecb7b 152
06c0fba4 153int wxDisplayDepth();
1e7ecb7b
RD
154int wxGetDisplayDepth();
155
ec5d7799 156void wxDisplaySize(int* OUTPUT, int* OUTPUT);
1e7ecb7b 157wxSize wxGetDisplaySize();
1b62f00d 158
ec5d7799 159void wxDisplaySizeMM(int* OUTPUT, int* OUTPUT);
1e7ecb7b
RD
160wxSize wxGetDisplaySizeMM();
161
ec5d7799
RD
162void wxClientDisplayRect(int *OUTPUT, int *OUTPUT, int *OUTPUT, int *OUTPUT);
163wxRect wxGetClientDisplayRect();
164
06c0fba4 165void wxSetCursor(wxCursor& cursor);
bb0054cd
RD
166
167//----------------------------------------------------------------------
06c0fba4 168// Miscellaneous functions
bb0054cd 169
06c0fba4
RD
170void wxBeginBusyCursor(wxCursor *cursor = wxHOURGLASS_CURSOR);
171wxWindow * wxGetActiveWindow();
172
493f1553
RD
173wxWindow* wxGenericFindWindowAtPoint(const wxPoint& pt);
174wxWindow* wxFindWindowAtPoint(const wxPoint& pt);
4dfaa61e
RD
175
176#ifdef __WXMSW__
493f1553 177bool wxCheckForInterrupt(wxWindow *wnd);
18d95cf0 178// link error? void wxFlushEvents();
4dfaa61e 179#endif
06c0fba4 180
2a74d141
RD
181wxWindow* wxGetTopLevelParent(wxWindow *win);
182
fd512ba2
RD
183//bool wxSpawnBrowser(wxWindow *parent, wxString href);
184
06c0fba4
RD
185//---------------------------------------------------------------------------
186// Resource System
187
1e4a197e 188#ifdef wxUSE_WX_RESOURCES
137b5242 189bool wxResourceAddIdentifier(char* name, int value);
06c0fba4 190void wxResourceClear(void);
137b5242
RD
191wxBitmap wxResourceCreateBitmap(char* resource);
192wxIcon wxResourceCreateIcon(char* resource);
193wxMenuBar * wxResourceCreateMenuBar(char* resource);
194int wxResourceGetIdentifier(char* name);
195bool wxResourceParseData(char* resource, wxResourceTable *table = NULL);
196bool wxResourceParseFile(char* filename, wxResourceTable *table = NULL);
197bool wxResourceParseString(char* resource, wxResourceTable *table = NULL);
1e4a197e 198#endif
bb0054cd 199
06c0fba4
RD
200//---------------------------------------------------------------------------
201// System Settings
202
b5a5d647
RD
203// possible values for wxSystemSettings::GetFont() parameter
204//
205enum wxSystemFont
206{
207 wxSYS_OEM_FIXED_FONT = 10,
06c0fba4
RD
208 wxSYS_ANSI_FIXED_FONT,
209 wxSYS_ANSI_VAR_FONT,
210 wxSYS_SYSTEM_FONT,
211 wxSYS_DEVICE_DEFAULT_FONT,
212 wxSYS_DEFAULT_PALETTE,
213 wxSYS_SYSTEM_FIXED_FONT,
b5a5d647
RD
214 wxSYS_DEFAULT_GUI_FONT
215};
06c0fba4 216
b5a5d647
RD
217// possible values for wxSystemSettings::GetColour() parameter
218//
219enum wxSystemColour
220{
06c0fba4
RD
221 wxSYS_COLOUR_SCROLLBAR,
222 wxSYS_COLOUR_BACKGROUND,
c6c593e8 223 wxSYS_COLOUR_DESKTOP = wxSYS_COLOUR_BACKGROUND,
06c0fba4
RD
224 wxSYS_COLOUR_ACTIVECAPTION,
225 wxSYS_COLOUR_INACTIVECAPTION,
226 wxSYS_COLOUR_MENU,
227 wxSYS_COLOUR_WINDOW,
228 wxSYS_COLOUR_WINDOWFRAME,
229 wxSYS_COLOUR_MENUTEXT,
230 wxSYS_COLOUR_WINDOWTEXT,
231 wxSYS_COLOUR_CAPTIONTEXT,
232 wxSYS_COLOUR_ACTIVEBORDER,
233 wxSYS_COLOUR_INACTIVEBORDER,
234 wxSYS_COLOUR_APPWORKSPACE,
235 wxSYS_COLOUR_HIGHLIGHT,
236 wxSYS_COLOUR_HIGHLIGHTTEXT,
237 wxSYS_COLOUR_BTNFACE,
c6c593e8 238 wxSYS_COLOUR_3DFACE = wxSYS_COLOUR_BTNFACE,
06c0fba4 239 wxSYS_COLOUR_BTNSHADOW,
c6c593e8 240 wxSYS_COLOUR_3DSHADOW = wxSYS_COLOUR_BTNSHADOW,
06c0fba4
RD
241 wxSYS_COLOUR_GRAYTEXT,
242 wxSYS_COLOUR_BTNTEXT,
243 wxSYS_COLOUR_INACTIVECAPTIONTEXT,
244 wxSYS_COLOUR_BTNHIGHLIGHT,
c6c593e8
RD
245 wxSYS_COLOUR_BTNHILIGHT = wxSYS_COLOUR_BTNHIGHLIGHT,
246 wxSYS_COLOUR_3DHIGHLIGHT = wxSYS_COLOUR_BTNHIGHLIGHT,
247 wxSYS_COLOUR_3DHILIGHT = wxSYS_COLOUR_BTNHIGHLIGHT,
06c0fba4
RD
248 wxSYS_COLOUR_3DDKSHADOW,
249 wxSYS_COLOUR_3DLIGHT,
250 wxSYS_COLOUR_INFOTEXT,
251 wxSYS_COLOUR_INFOBK,
b5a5d647 252 wxSYS_COLOUR_LISTBOX,
c6c593e8
RD
253 wxSYS_COLOUR_HOTLIGHT,
254 wxSYS_COLOUR_GRADIENTACTIVECAPTION,
255 wxSYS_COLOUR_GRADIENTINACTIVECAPTION,
256 wxSYS_COLOUR_MENUHILIGHT,
257 wxSYS_COLOUR_MENUBAR,
b5a5d647 258
c6c593e8 259 wxSYS_COLOUR_MAX
b5a5d647 260};
06c0fba4 261
b5a5d647
RD
262// possible values for wxSystemSettings::GetMetric() parameter
263//
264enum wxSystemMetric
265{
266 wxSYS_MOUSE_BUTTONS = 1,
06c0fba4
RD
267 wxSYS_BORDER_X,
268 wxSYS_BORDER_Y,
269 wxSYS_CURSOR_X,
270 wxSYS_CURSOR_Y,
271 wxSYS_DCLICK_X,
272 wxSYS_DCLICK_Y,
273 wxSYS_DRAG_X,
274 wxSYS_DRAG_Y,
275 wxSYS_EDGE_X,
276 wxSYS_EDGE_Y,
277 wxSYS_HSCROLL_ARROW_X,
278 wxSYS_HSCROLL_ARROW_Y,
279 wxSYS_HTHUMB_X,
280 wxSYS_ICON_X,
281 wxSYS_ICON_Y,
282 wxSYS_ICONSPACING_X,
283 wxSYS_ICONSPACING_Y,
284 wxSYS_WINDOWMIN_X,
285 wxSYS_WINDOWMIN_Y,
286 wxSYS_SCREEN_X,
287 wxSYS_SCREEN_Y,
288 wxSYS_FRAMESIZE_X,
289 wxSYS_FRAMESIZE_Y,
290 wxSYS_SMALLICON_X,
291 wxSYS_SMALLICON_Y,
292 wxSYS_HSCROLL_Y,
293 wxSYS_VSCROLL_X,
294 wxSYS_VSCROLL_ARROW_X,
295 wxSYS_VSCROLL_ARROW_Y,
296 wxSYS_VTHUMB_Y,
297 wxSYS_CAPTION_Y,
298 wxSYS_MENU_Y,
299 wxSYS_NETWORK_PRESENT,
300 wxSYS_PENWINDOWS_PRESENT,
301 wxSYS_SHOW_SOUNDS,
b5a5d647 302 wxSYS_SWAP_BUTTONS
06c0fba4
RD
303};
304
b5a5d647
RD
305// possible values for wxSystemSettings::HasFeature() parameter
306enum wxSystemFeature
307{
308 wxSYS_CAN_DRAW_FRAME_DECORATIONS = 1,
309 wxSYS_CAN_ICONIZE_FRAME
310};
06c0fba4 311
12bfbb29 312enum wxSystemScreenType
daa3eac9
RD
313{
314 wxSYS_SCREEN_NONE = 0, // not yet defined
12bfbb29
RD
315
316 wxSYS_SCREEN_TINY, // <
daa3eac9 317 wxSYS_SCREEN_PDA, // >= 320x240
12bfbb29
RD
318 wxSYS_SCREEN_SMALL, // >= 640x480
319 wxSYS_SCREEN_DESKTOP // >= 800x600
daa3eac9 320};
06c0fba4 321
06c0fba4 322
b5a5d647
RD
323class wxSystemSettings {
324public:
325 // get a standard system colour
326 static wxColour GetColour(wxSystemColour index);
327
328 // get a standard system font
329 static wxFont GetFont(wxSystemFont index);
330
331 // get a system-dependent metric
332 static int GetMetric(wxSystemMetric index);
333
334 // return true if the port has certain feature
335 static bool HasFeature(wxSystemFeature index);
336
0b85cc38
RD
337 // Get system screen design (desktop, pda, ..) used for
338 // laying out various dialogs.
12bfbb29 339 static wxSystemScreenType GetScreenType();
daa3eac9 340
0b85cc38 341 // Override default.
12bfbb29 342 static void SetScreenType( wxSystemScreenType screen );
daa3eac9 343
b5a5d647 344};
06c0fba4 345
06c0fba4 346
bb0054cd 347
3ef86e32
RD
348class wxSystemOptions : public wxObject
349{
350public:
351 wxSystemOptions() { }
352
353 // User-customizable hints to wxWindows or associated libraries
354 // These could also be used to influence GetSystem... calls, indeed
355 // to implement SetSystemColour/Font/Metric
356
357 static void SetOption(const wxString& name, const wxString& value);
358 %name(SetOptionInt)static void SetOption(const wxString& name, int value);
359 static wxString GetOption(const wxString& name) ;
360 static int GetOptionInt(const wxString& name) ;
361 static bool HasOption(const wxString& name) ;
362};
363
364
bb0054cd
RD
365//---------------------------------------------------------------------------
366// wxToolTip
367
9416aa89 368class wxToolTip : public wxObject {
bb0054cd
RD
369public:
370 wxToolTip(const wxString &tip);
371
372 void SetTip(const wxString& tip);
373 wxString GetTip();
374 // *** Not in the "public" interface void SetWindow(wxWindow *win);
375 wxWindow *GetWindow();
bb0054cd 376
edf2f43e
RD
377 static void Enable(bool flag);
378 static void SetDelay(long milliseconds);
379};
bb0054cd
RD
380
381//----------------------------------------------------------------------
f0261a72
RD
382
383class wxCaret {
384public:
385 wxCaret(wxWindow* window, const wxSize& size);
386 ~wxCaret();
387
388 bool IsOk();
389 bool IsVisible();
390 %name(GetPositionTuple)void GetPosition(int *OUTPUT, int *OUTPUT);
391 wxPoint GetPosition();
392 %name(GetSizeTuple)void GetSize(int *OUTPUT, int *OUTPUT);
393 wxSize GetSize();
394 wxWindow *GetWindow();
395 %name(MoveXY)void Move(int x, int y);
396 void Move(const wxPoint& pt);
a1df7a95
RD
397 %name(SetSizeWH) void SetSize(int width, int height);
398 void SetSize(const wxSize& size);
f0261a72
RD
399 void Show(int show = TRUE);
400 void Hide();
1fded56b
RD
401
402 %pragma(python) addtoclass = "def __nonzero__(self): return self.IsOk()"
f0261a72
RD
403};
404
405%inline %{
406 int wxCaret_GetBlinkTime() {
407 return wxCaret::GetBlinkTime();
408 }
409
410 void wxCaret_SetBlinkTime(int milliseconds) {
411 wxCaret::SetBlinkTime(milliseconds);
412 }
413%}
414
bb0054cd 415//----------------------------------------------------------------------
f0261a72 416
2abc0a0f
RD
417class wxBusyCursor {
418public:
419 wxBusyCursor(wxCursor* cursor = wxHOURGLASS_CURSOR);
420 ~wxBusyCursor();
421};
422
b1462dfa 423//----------------------------------------------------------------------
2abc0a0f 424
c368d904
RD
425class wxWindowDisabler {
426public:
427 wxWindowDisabler(wxWindow *winToSkip = NULL);
428 ~wxWindowDisabler();
429};
430
431//----------------------------------------------------------------------
432
1e4a197e 433bool wxSafeYield(wxWindow* win=NULL, bool onlyIfNeeded=FALSE);
b1462dfa 434void wxPostEvent(wxEvtHandler *dest, wxEvent& event);
694759cf 435void wxWakeUpIdle();
2abc0a0f 436
6e18ca6c 437
4662be59 438#ifdef __WXMSW__
6e18ca6c 439void wxWakeUpMainThread();
4662be59
RD
440#endif
441
6e18ca6c
RD
442void wxMutexGuiEnter();
443void wxMutexGuiLeave();
444
445
446class wxMutexGuiLocker {
447public:
448 wxMutexGuiLocker();
449 ~wxMutexGuiLocker();
450};
451
452
453%inline %{
454 bool wxThread_IsMain() {
00ca6262 455#ifdef WXP_WITH_THREAD
6e18ca6c 456 return wxThread::IsMain();
00ca6262
RD
457#else
458 return TRUE;
459#endif
6e18ca6c
RD
460 }
461%}
c368d904 462
2abc0a0f 463//----------------------------------------------------------------------
f6bcfd97
BP
464
465
466class wxTipProvider
467{
468public:
469 // wxTipProvider(size_t currentTip); **** Abstract base class
470 ~wxTipProvider();
471
472 virtual wxString GetTip() = 0;
473 size_t GetCurrentTip();
fd512ba2 474 virtual wxString PreprocessTip(const wxString& tip);
f6bcfd97
BP
475};
476
477
478// The C++ version of wxPyTipProvider
479%{
480class wxPyTipProvider : public wxTipProvider {
481public:
482 wxPyTipProvider(size_t currentTip)
483 : wxTipProvider(currentTip) {}
484
485 DEC_PYCALLBACK_STRING__pure(GetTip);
fd512ba2 486 DEC_PYCALLBACK_STRING_STRING(PreprocessTip);
f6bcfd97
BP
487 PYPRIVATE;
488};
489
490IMP_PYCALLBACK_STRING__pure( wxPyTipProvider, wxTipProvider, GetTip);
fd512ba2 491IMP_PYCALLBACK_STRING_STRING(wxPyTipProvider, wxTipProvider, PreprocessTip);
f6bcfd97
BP
492%}
493
494
495// Now let SWIG know about it
496class wxPyTipProvider : public wxTipProvider {
497public:
498 wxPyTipProvider(size_t currentTip);
cf276873
RD
499
500 void _setCallbackInfo(PyObject* self, PyObject* _class);
501 %pragma(python) addtomethod = "__init__:self._setCallbackInfo(self, wxPyTipProvider)"
f6bcfd97
BP
502};
503
504
505
506bool wxShowTip(wxWindow *parent, wxTipProvider *tipProvider, bool showAtStartup = TRUE);
507%new wxTipProvider * wxCreateFileTipProvider(const wxString& filename, size_t currentTip);
508
509
510//----------------------------------------------------------------------
511
512%{
513#include <wx/generic/dragimgg.h>
f6bcfd97
BP
514%}
515
9416aa89 516%name (wxDragImage) class wxGenericDragImage : public wxObject
f6bcfd97
BP
517{
518public:
519
520 wxGenericDragImage(const wxBitmap& image,
10e07c70 521 const wxCursor& cursor = wxNullCursor);
cdf14688
RD
522 %name(wxDragIcon)wxGenericDragImage(const wxIcon& image,
523 const wxCursor& cursor = wxNullCursor);
524 %name(wxDragString)wxGenericDragImage(const wxString& str,
525 const wxCursor& cursor = wxNullCursor);
526 %name(wxDragTreeItem)wxGenericDragImage(const wxTreeCtrl& treeCtrl, wxTreeItemId& id);
527 %name(wxDragListItem)wxGenericDragImage(const wxListCtrl& listCtrl, long id);
528
f6bcfd97
BP
529 ~wxGenericDragImage();
530
10e07c70 531 void SetBackingBitmap(wxBitmap* bitmap);
f6bcfd97
BP
532 bool BeginDrag(const wxPoint& hotspot, wxWindow* window,
533 bool fullScreen = FALSE, wxRect* rect = NULL);
534
1e4a197e
RD
535 %name(BeginDragBounded) bool BeginDrag(const wxPoint& hotspot, wxWindow* window,
536 wxWindow* boundingWindow);
537
538 %pragma(python) addtoclass = "BeginDrag2 = BeginDragBounded"
f6bcfd97
BP
539
540 bool EndDrag();
541 bool Move(const wxPoint& pt);
542 bool Show();
543 bool Hide();
544
545 wxRect GetImageRect(const wxPoint& pos) const;
546 bool RedrawImage(const wxPoint& oldPos, const wxPoint& newPos,
547 bool eraseOld, bool drawNew);
548};
549
550
f6bcfd97
BP
551//----------------------------------------------------------------------
552
9416aa89 553class wxPyTimer : public wxObject {
f6bcfd97
BP
554public:
555 wxPyTimer(PyObject* notify);
556 ~wxPyTimer();
557 int GetInterval();
558 bool IsOneShot();
559 bool IsRunning();
560 void SetOwner(wxEvtHandler *owner, int id = -1);
1fded56b 561 bool Start(int milliseconds=-1, int oneShot=FALSE);
f6bcfd97
BP
562 void Stop();
563};
564
b37c7e1d
RD
565
566class wxStopWatch
567{
568public:
569 // ctor starts the stop watch
570 wxStopWatch();
68320e40 571 ~wxStopWatch();
b37c7e1d
RD
572 void Start(long t = 0);
573 void Pause();
574 void Resume();
575
576 // get elapsed time since the last Start() or Pause() in milliseconds
577 long Time() const;
578};
579
580
f6bcfd97
BP
581//----------------------------------------------------------------------
582//----------------------------------------------------------------------
583
584
585enum
586{
587 wxLOG_FatalError, // program can't continue, abort immediately
588 wxLOG_Error, // a serious error, user must be informed about it
589 wxLOG_Warning, // user is normally informed about it but may be ignored
590 wxLOG_Message, // normal message (i.e. normal output of a non GUI app)
591 wxLOG_Info, // informational message (a.k.a. 'Verbose')
592 wxLOG_Status, // informational: might go to the status line of GUI app
593 wxLOG_Debug, // never shown to the user, disabled in release mode
594 wxLOG_Trace, // trace messages are also only enabled in debug mode
595 wxLOG_Progress, // used for progress indicator (not yet)
596 wxLOG_User = 100 // user defined levels start here
597};
598
8baa46e9
RD
599#define wxTRACE_MemAlloc "memalloc" // trace memory allocation (new/delete)
600#define wxTRACE_Messages "messages" // trace window messages/X callbacks
601#define wxTRACE_ResAlloc "resalloc" // trace GDI resource allocation
602#define wxTRACE_RefCount "refcount" // trace various ref counting operations
603
604#ifdef __WXMSW__
605#define wxTRACE_OleCalls "ole" // OLE interface calls
606#endif
607
608enum {
609 wxTraceMemAlloc,
610 wxTraceMessages,
611 wxTraceResAlloc,
612 wxTraceRefCount,
613
614#ifdef __WXMSW__
615 wxTraceOleCalls,
616#endif
617};
618
619
f6bcfd97
BP
620
621class wxLog
622{
623public:
624 wxLog();
625
626 static bool IsEnabled();
627 static bool EnableLogging(bool doIt = TRUE);
8baa46e9 628 static void OnLog(unsigned long level, const wxString& szString, int t=0);
f6bcfd97
BP
629
630 virtual void Flush();
f6bcfd97
BP
631 static void FlushActive();
632 static wxLog *GetActiveTarget();
633 static wxLog *SetActiveTarget(wxLog *pLogger);
634
635 static void Suspend();
636 static void Resume();
637
d6eacb25 638 static void SetVerbose(bool bVerbose = TRUE);
f6bcfd97
BP
639
640 static void DontCreateOnDemand();
8baa46e9 641 static void SetTraceMask(long ulMask);
f6bcfd97
BP
642 static void AddTraceMask(const wxString& str);
643 static void RemoveTraceMask(const wxString& str);
76bfdc78 644 static void ClearTraceMasks();
fd512ba2 645 static const wxArrayString &GetTraceMasks();
76bfdc78 646
137b5242
RD
647 static void SetTimestamp(const wxString& ts);
648 static const wxString& GetTimestamp();
f6bcfd97 649
19e30148 650 bool GetVerbose() const;
f6bcfd97 651
be13a6af 652 static unsigned long GetTraceMask();
c8bc7bb8 653 static bool IsAllowedTraceMask(const wxString& mask);
f6bcfd97 654
1e4a197e
RD
655 static void SetLogLevel(unsigned long logLevel);
656 static unsigned long GetLogLevel();
657
658
76bfdc78
RD
659 // static void TimeStamp(wxString *str);
660 %addmethods {
661 wxString TimeStamp() {
662 wxString msg;
663 wxLog::TimeStamp(&msg);
664 return msg;
665 }
666 }
d6eacb25 667
f6bcfd97
BP
668};
669
670
671class wxLogStderr : public wxLog
672{
673public:
674 wxLogStderr(/* TODO: FILE *fp = (FILE *) NULL*/);
675};
676
677
678class wxLogTextCtrl : public wxLog
679{
680public:
681 wxLogTextCtrl(wxTextCtrl *pTextCtrl);
682};
683
684
685class wxLogGui : public wxLog
686{
687public:
688 wxLogGui();
689};
690
691class wxLogWindow : public wxLog
692{
693public:
694 wxLogWindow(wxFrame *pParent, // the parent frame (can be NULL)
c8bc7bb8 695 const wxString& szTitle, // the title of the frame
f6bcfd97
BP
696 bool bShow = TRUE, // show window immediately?
697 bool bPassToOld = TRUE); // pass log messages to the old target?
698
699 void Show(bool bShow = TRUE);
700 wxFrame *GetFrame() const;
701 wxLog *GetOldLog() const;
702 bool IsPassingMessages() const;
c8bc7bb8 703 void PassMessages(bool bDoPass);
f6bcfd97
BP
704};
705
706
76bfdc78
RD
707class wxLogChain : public wxLog
708{
709public:
710 wxLogChain(wxLog *logger);
711 void SetLog(wxLog *logger);
712 void PassMessages(bool bDoPass);
713 bool IsPassingMessages();
714 wxLog *GetOldLog();
715};
716
717
f6bcfd97 718unsigned long wxSysErrorCode();
c8bc7bb8 719const wxString wxSysErrorMsg(unsigned long nErrCode = 0);
be13a6af
RD
720void wxLogFatalError(const wxString& msg);
721void wxLogError(const wxString& msg);
722void wxLogWarning(const wxString& msg);
723void wxLogMessage(const wxString& msg);
724void wxLogInfo(const wxString& msg);
1e4a197e 725void wxLogDebug(const wxString& msg);
be13a6af
RD
726void wxLogVerbose(const wxString& msg);
727void wxLogStatus(const wxString& msg);
728%name(wxLogStatusFrame)void wxLogStatus(wxFrame *pFrame, const wxString& msg);
729void wxLogSysError(const wxString& msg);
730
731void wxLogTrace(const wxString& msg);
732%name(wxLogTraceMask)void wxLogTrace(const wxString& mask, const wxString& msg);
733
734void wxLogGeneric(unsigned long level, const wxString& msg);
f6bcfd97 735
b7fc54be
RD
736// wxLogFatalError helper: show the (fatal) error to the user in a safe way,
737// i.e. without using wxMessageBox() for example because it could crash
0b85cc38 738void wxSafeShowMessage(const wxString& title, const wxString& text);
b7fc54be
RD
739
740
741
19e30148
RD
742// Suspress logging while an instance of this class exists
743class wxLogNull
744{
745public:
746 wxLogNull();
747 ~wxLogNull();
748};
749
750
751
f6bcfd97 752
76bfdc78 753%{
19e30148 754// A wxLog class that can be derived from in wxPython
76bfdc78
RD
755class wxPyLog : public wxLog {
756public:
757 wxPyLog() : wxLog() {}
758
759 virtual void DoLog(wxLogLevel level, const wxChar *szString, time_t t) {
760 bool found;
4268f798 761 wxPyBeginBlockThreads();
a66212dc
RD
762 if ((found = wxPyCBH_findCallback(m_myInst, "DoLog"))) {
763 PyObject* s = wx2PyString(szString);
764 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iOi)", level, s, t));
765 Py_DECREF(s);
766 }
4268f798 767 wxPyEndBlockThreads();
76bfdc78
RD
768 if (! found)
769 wxLog::DoLog(level, szString, t);
770 }
771
772 virtual void DoLogString(const wxChar *szString, time_t t) {
773 bool found;
4268f798 774 wxPyBeginBlockThreads();
a66212dc
RD
775 if ((found = wxPyCBH_findCallback(m_myInst, "DoLogString"))) {
776 PyObject* s = wx2PyString(szString);
777 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oi)", s, t));
778 Py_DECREF(s);
779 }
4268f798 780 wxPyEndBlockThreads();
76bfdc78
RD
781 if (! found)
782 wxLog::DoLogString(szString, t);
783 }
784
785 PYPRIVATE;
786};
787%}
788
789// Now tell SWIG about it
790class wxPyLog : public wxLog {
791public:
792 wxPyLog();
0122b7e3
RD
793 void _setCallbackInfo(PyObject* self, PyObject* _class);
794 %pragma(python) addtomethod = "__init__:self._setCallbackInfo(self, wxPyLog)"
76bfdc78
RD
795 %addmethods { void Destroy() { delete self; } }
796
797};
798
c368d904
RD
799
800//----------------------------------------------------------------------
801
1b62f00d 802
814f509c
RD
803enum wxKillError
804{
805 wxKILL_OK, // no error
806 wxKILL_BAD_SIGNAL, // no such signal
807 wxKILL_ACCESS_DENIED, // permission denied
808 wxKILL_NO_PROCESS, // no such process
809 wxKILL_ERROR // another, unspecified error
810};
811
1883480f
RD
812enum wxSignal
813{
814 wxSIGNONE = 0, // verify if the process exists under Unix
815 wxSIGHUP,
816 wxSIGINT,
817 wxSIGQUIT,
818 wxSIGILL,
819 wxSIGTRAP,
820 wxSIGABRT,
821 wxSIGIOT = wxSIGABRT, // another name
822 wxSIGEMT,
823 wxSIGFPE,
824 wxSIGKILL,
825 wxSIGBUS,
826 wxSIGSEGV,
827 wxSIGSYS,
828 wxSIGPIPE,
829 wxSIGALRM,
830 wxSIGTERM
831
832 // further signals are different in meaning between different Unix systems
833};
834
835
836
837enum {
838 /* event type */
839 wxEVT_END_PROCESS
840};
841
842
814f509c 843
c368d904
RD
844class wxProcessEvent : public wxEvent {
845public:
846 wxProcessEvent(int id = 0, int pid = 0, int exitcode = 0);
847 int GetPid();
848 int GetExitCode();
849 int m_pid, m_exitcode;
850};
851
852
853
854
855%{ // C++ version of wxProcess derived class
856
857class wxPyProcess : public wxProcess {
858public:
859 wxPyProcess(wxEvtHandler *parent = NULL, int id = -1)
860 : wxProcess(parent, id)
861 {}
862
863 DEC_PYCALLBACK_VOID_INTINT(OnTerminate);
864
865 PYPRIVATE;
866};
867
868IMP_PYCALLBACK_VOID_INTINT( wxPyProcess, wxProcess, OnTerminate);
19a97bd6 869
c368d904
RD
870%}
871
872
873%name(wxProcess)class wxPyProcess : public wxEvtHandler {
874public:
814f509c
RD
875 // kill the process with the given PID
876 static wxKillError Kill(int pid, wxSignal sig = wxSIGTERM);
877
878 // test if the given process exists
879 static bool Exists(int pid);
880
881 // this function replaces the standard popen() one: it launches a process
882 // asynchronously and allows the caller to get the streams connected to its
883 // std{in|out|err}
884 //
885 // on error NULL is returned, in any case the process object will be
886 // deleted automatically when the process terminates and should *not* be
887 // deleted by the caller
e626d7c7 888 static wxPyProcess *Open(const wxString& cmd, int flags = wxEXEC_ASYNC);
814f509c
RD
889
890
891
c368d904
RD
892 wxPyProcess(wxEvtHandler *parent = NULL, int id = -1);
893 %addmethods { void Destroy() { delete self; } }
894
0122b7e3
RD
895 void _setCallbackInfo(PyObject* self, PyObject* _class);
896 %pragma(python) addtomethod = "__init__:self._setCallbackInfo(self, wxProcess)"
c368d904
RD
897
898 void base_OnTerminate(int pid, int status);
899
900 void Redirect();
901 bool IsRedirected();
902 void Detach();
903
904 wxInputStream *GetInputStream();
905 wxInputStream *GetErrorStream();
906 wxOutputStream *GetOutputStream();
907
908 void CloseOutput();
3b3ab7f6
RD
909
910 // return TRUE if the child process stdout is not closed
911 bool IsInputOpened() const;
912
913 // return TRUE if any input is available on the child process stdout/err
914 bool IsInputAvailable() const;
915 bool IsErrorAvailable() const;
c368d904
RD
916};
917
918
d6eacb25
RD
919enum
920{
921 // execute the process asynchronously
922 wxEXEC_ASYNC = 0,
923
924 // execute it synchronously, i.e. wait until it finishes
925 wxEXEC_SYNC = 1,
926
927 // under Windows, don't hide the child even if it's IO is redirected (this
928 // is done by default)
929 wxEXEC_NOHIDE = 2,
930
931 // under Unix, if the process is the group leader then killing -pid kills
932 // all children as well as pid
933 wxEXEC_MAKE_GROUP_LEADER = 4
b96c7a38
RD
934};
935
c368d904
RD
936
937long wxExecute(const wxString& command,
b96c7a38 938 int flags = wxEXEC_ASYNC,
c368d904
RD
939 wxPyProcess *process = NULL);
940
185d7c3e
RD
941//----------------------------------------------------------------------
942
3eb221f6
RD
943
944// Which joystick? Same as Windows ids so no conversion necessary.
945enum
946{
947 wxJOYSTICK1,
948 wxJOYSTICK2
949};
950
951// Which button is down?
952enum
953{
954 wxJOY_BUTTON_ANY,
955 wxJOY_BUTTON1,
956 wxJOY_BUTTON2,
957 wxJOY_BUTTON3,
958 wxJOY_BUTTON4,
959};
960
961
493f1553
RD
962%{
963#if !wxUSE_JOYSTICK && !defined(__WXMSW__)
964// A C++ stub class for wxJoystick for platforms that don't have it.
965class wxJoystick : public wxObject {
966public:
967 wxJoystick(int joystick = wxJOYSTICK1) {
4268f798 968 wxPyBeginBlockThreads();
493f1553 969 PyErr_SetString(PyExc_NotImplementedError, "wxJoystick is not available on this platform.");
4268f798 970 wxPyEndBlockThreads();
493f1553
RD
971 }
972 wxPoint GetPosition() { return wxPoint(-1,-1); }
973 int GetZPosition() { return -1; }
974 int GetButtonState() { return -1; }
975 int GetPOVPosition() { return -1; }
976 int GetPOVCTSPosition() { return -1; }
977 int GetRudderPosition() { return -1; }
978 int GetUPosition() { return -1; }
979 int GetVPosition() { return -1; }
980 int GetMovementThreshold() { return -1; }
d56cebe7 981 void SetMovementThreshold(int threshold) {}
493f1553
RD
982
983 bool IsOk(void) { return FALSE; }
984 int GetNumberJoysticks() { return -1; }
985 int GetManufacturerId() { return -1; }
986 int GetProductId() { return -1; }
987 wxString GetProductName() { return ""; }
988 int GetXMin() { return -1; }
989 int GetYMin() { return -1; }
990 int GetZMin() { return -1; }
991 int GetXMax() { return -1; }
992 int GetYMax() { return -1; }
993 int GetZMax() { return -1; }
994 int GetNumberButtons() { return -1; }
995 int GetNumberAxes() { return -1; }
996 int GetMaxButtons() { return -1; }
997 int GetMaxAxes() { return -1; }
998 int GetPollingMin() { return -1; }
999 int GetPollingMax() { return -1; }
1000 int GetRudderMin() { return -1; }
1001 int GetRudderMax() { return -1; }
1002 int GetUMin() { return -1; }
1003 int GetUMax() { return -1; }
1004 int GetVMin() { return -1; }
1005 int GetVMax() { return -1; }
1006
1007 bool HasRudder() { return FALSE; }
1008 bool HasZ() { return FALSE; }
1009 bool HasU() { return FALSE; }
1010 bool HasV() { return FALSE; }
1011 bool HasPOV() { return FALSE; }
1012 bool HasPOV4Dir() { return FALSE; }
1013 bool HasPOVCTS() { return FALSE; }
1014
1015 bool SetCapture(wxWindow* win, int pollingFreq = 0) { return FALSE; }
1016 bool ReleaseCapture() { return FALSE; }
1017};
1018#endif
1019%}
1020
1021
9416aa89 1022class wxJoystick : public wxObject {
185d7c3e
RD
1023public:
1024 wxJoystick(int joystick = wxJOYSTICK1);
ac346f50
RD
1025 ~wxJoystick();
1026
185d7c3e
RD
1027 wxPoint GetPosition();
1028 int GetZPosition();
1029 int GetButtonState();
1030 int GetPOVPosition();
1031 int GetPOVCTSPosition();
1032 int GetRudderPosition();
1033 int GetUPosition();
1034 int GetVPosition();
1035 int GetMovementThreshold();
1036 void SetMovementThreshold(int threshold) ;
1037
1038 bool IsOk(void);
1039 int GetNumberJoysticks();
1040 int GetManufacturerId();
1041 int GetProductId();
1042 wxString GetProductName();
1043 int GetXMin();
1044 int GetYMin();
1045 int GetZMin();
1046 int GetXMax();
1047 int GetYMax();
1048 int GetZMax();
1049 int GetNumberButtons();
1050 int GetNumberAxes();
1051 int GetMaxButtons();
1052 int GetMaxAxes();
1053 int GetPollingMin();
1054 int GetPollingMax();
1055 int GetRudderMin();
1056 int GetRudderMax();
1057 int GetUMin();
1058 int GetUMax();
1059 int GetVMin();
1060 int GetVMax();
1061
1062 bool HasRudder();
1063 bool HasZ();
1064 bool HasU();
1065 bool HasV();
1066 bool HasPOV();
1067 bool HasPOV4Dir();
1068 bool HasPOVCTS();
1069
1070 bool SetCapture(wxWindow* win, int pollingFreq = 0);
1071 bool ReleaseCapture();
1fded56b
RD
1072
1073 %pragma(python) addtoclass = "def __nonzero__(self): return self.IsOk()"
185d7c3e 1074};
493f1553
RD
1075
1076//----------------------------------------------------------------------
1077
1078%{
0adbc166 1079#if !wxUSE_WAVE
493f1553
RD
1080// A C++ stub class for wxWave for platforms that don't have it.
1081class wxWave : public wxObject
1082{
1083public:
1084 wxWave(const wxString& fileName, bool isResource = FALSE) {
4268f798 1085 wxPyBeginBlockThreads();
493f1553 1086 PyErr_SetString(PyExc_NotImplementedError, "wxWave is not available on this platform.");
4268f798 1087 wxPyEndBlockThreads();
493f1553
RD
1088 }
1089 wxWave(int size, const wxByte* data) {
4268f798 1090 wxPyBeginBlockThreads();
493f1553 1091 PyErr_SetString(PyExc_NotImplementedError, "wxWave is not available on this platform.");
4268f798 1092 wxPyEndBlockThreads();
493f1553
RD
1093 }
1094
1095 ~wxWave() {}
1096
1097 bool IsOk() const { return FALSE; }
1098 bool Play(bool async = TRUE, bool looped = FALSE) const { return FALSE; }
1099};
1100
2cd2fac8 1101#endif
493f1553
RD
1102%}
1103
1104class wxWave : public wxObject
1105{
1106public:
1fded56b
RD
1107 wxWave(const wxString& fileName, bool isResource = FALSE);
1108 ~wxWave();
1109
1110 bool IsOk() const;
1111 bool Play(bool async = TRUE, bool looped = FALSE) const;
493f1553 1112
1fded56b 1113 %pragma(python) addtoclass = "def __nonzero__(self): return self.IsOk()"
493f1553
RD
1114};
1115
1116%new wxWave* wxWaveData(const wxString& data);
1117%{ // Implementations of some alternate "constructors"
1118 wxWave* wxWaveData(const wxString& data) {
1119 return new wxWave(data.Len(), (wxByte*)data.c_str());
1120 }
1121%}
185d7c3e 1122
4f3449b4 1123
b37c7e1d
RD
1124//----------------------------------------------------------------------
1125
1126enum wxMailcapStyle
1127{
1128 wxMAILCAP_STANDARD = 1,
1129 wxMAILCAP_NETSCAPE = 2,
1130 wxMAILCAP_KDE = 4,
1131 wxMAILCAP_GNOME = 8,
1132
1133 wxMAILCAP_ALL = 15
1134};
1135
1136
1137
1138class wxFileTypeInfo
1139{
1140public:
1141 // ctors
1142 // a normal item
1e4a197e
RD
1143 wxFileTypeInfo(const wxString& mimeType,
1144 const wxString& openCmd,
1145 const wxString& printCmd,
1146 const wxString& desc);
b37c7e1d
RD
1147
1148
1149 // the array elements correspond to the parameters of the ctor above in
1150 // the same order
1151 %name(wxFileTypeInfoSequence)wxFileTypeInfo(const wxArrayString& sArray);
1152
1153 // invalid item - use this to terminate the array passed to
1154 // wxMimeTypesManager::AddFallbacks
1155 %name(wxNullFileTypeInfo)wxFileTypeInfo();
1156
1157
1158 // test if this object can be used
1159 bool IsValid() const;
1160
1161 // setters
1162 // set the icon info
1163 void SetIcon(const wxString& iconFile, int iconIndex = 0);
1164
1165 // set the short desc
1166 void SetShortDesc(const wxString& shortDesc);
1167
1168 // accessors
1169 // get the MIME type
1170 const wxString& GetMimeType() const;
1171 // get the open command
1172 const wxString& GetOpenCommand() const;
1173 // get the print command
1174 const wxString& GetPrintCommand() const;
1175 // get the short description (only used under Win32 so far)
1176 const wxString& GetShortDesc() const;
1177 // get the long, user visible description
1178 const wxString& GetDescription() const;
1179
1180
1181 // get the array of all extensions
1182 //const wxArrayString& GetExtensions() const;
1183 %addmethods {
1184 PyObject* GetExtensions() {
1185 wxArrayString& arr = (wxArrayString&)self->GetExtensions();
1186 return wxArrayString2PyList_helper(arr);
1187 }
1188 }
1189
1190 int GetExtensionsCount() const;
1191
1192 // get the icon info
1193 const wxString& GetIconFile() const;
1194 int GetIconIndex() const;
1195};
1196
1197
1198
1199
1200class wxFileType
1201{
1202public:
1203
1204 // TODO: Make a wxPyMessageParameters with virtual GetParamValue...
1205
1206 // An object of this class must be passed to Get{Open|Print}Command. The
1207 // default implementation is trivial and doesn't know anything at all about
1208 // parameters, only filename and MIME type are used (so it's probably ok for
1209 // Windows where %{param} is not used anyhow)
1210 class MessageParameters
1211 {
1212 public:
1213 // ctors
137b5242
RD
1214 MessageParameters(const wxString& filename=wxPyEmptyString,
1215 const wxString& mimetype=wxPyEmptyString);
b37c7e1d
RD
1216
1217 // accessors (called by GetOpenCommand)
1218 // filename
1219 const wxString& GetFileName() const;
1220 // mime type
1221 const wxString& GetMimeType() const;;
1222
1223 // override this function in derived class
1224 virtual wxString GetParamValue(const wxString& name) const;
1225
1226 // virtual dtor as in any base class
1227 virtual ~MessageParameters();
1228 };
1229
1230
1231 // ctor from static data
1232 wxFileType(const wxFileTypeInfo& ftInfo);
1233
1234 // return the MIME type for this file type
1235 %addmethods {
1236 PyObject* GetMimeType() {
1237 wxString str;
c8bc7bb8
RD
1238 if (self->GetMimeType(&str)) {
1239#if wxUSE_UNICODE
1e4a197e 1240 return PyUnicode_FromWideChar(str.c_str(), str.Len());
c8bc7bb8
RD
1241#else
1242 return PyString_FromStringAndSize(str.c_str(), str.Len());
1243#endif
1244 }
b37c7e1d
RD
1245 else
1246 RETURN_NONE();
1247 }
1248 PyObject* GetMimeTypes() {
1249 wxArrayString arr;
1250 if (self->GetMimeTypes(arr))
1251 return wxArrayString2PyList_helper(arr);
1252 else
1253 RETURN_NONE();
1254 }
1255 }
1256
1257
1258 // Get all extensions associated with this file type
1259 %addmethods {
1260 PyObject* GetExtensions() {
1261 wxArrayString arr;
1262 if (self->GetExtensions(arr))
1263 return wxArrayString2PyList_helper(arr);
1264 else
1265 RETURN_NONE();
1266 }
1267 }
1268
1269
1270 %addmethods {
1271 // Get the icon corresponding to this file type
1272 %new wxIcon* GetIcon() {
dd116e73
RD
1273 wxIconLocation loc;
1274 if (self->GetIcon(&loc))
1275 return new wxIcon(loc);
b37c7e1d
RD
1276 else
1277 return NULL;
1278 }
1279
1280 // Get the icon corresponding to this file type, the name of the file
1281 // where this icon resides, and its index in this file if applicable.
1282 PyObject* GetIconInfo() {
dd116e73
RD
1283 wxIconLocation loc;
1284 if (self->GetIcon(&loc)) {
1285 wxString iconFile = loc.GetFileName();
1286 int iconIndex = -1;
1287#ifdef __WXMSW__
1288 iconIndex = loc.GetIndex();
1289#endif
1290 // Make a tuple and put the values in it
4268f798 1291 wxPyBeginBlockThreads();
b37c7e1d 1292 PyObject* tuple = PyTuple_New(3);
dd116e73
RD
1293 PyTuple_SetItem(tuple, 0,
1294 wxPyConstructObject(new wxIcon(loc), wxT("wxIcon"), TRUE));
c8bc7bb8 1295#if wxUSE_UNICODE
1e4a197e 1296 PyTuple_SetItem(tuple, 1, PyUnicode_FromWideChar(iconFile.c_str(), iconFile.Len()));
c8bc7bb8
RD
1297#else
1298 PyTuple_SetItem(tuple, 1, PyString_FromStringAndSize(iconFile.c_str(), iconFile.Len()));
1299#endif
b37c7e1d 1300 PyTuple_SetItem(tuple, 2, PyInt_FromLong(iconIndex));
4268f798 1301 wxPyEndBlockThreads();
b37c7e1d
RD
1302 return tuple;
1303 }
1304 else
1305 RETURN_NONE();
1306 }
1307 }
1308
1309 %addmethods {
1310 // get a brief file type description ("*.txt" => "text document")
1311 PyObject* GetDescription() {
1312 wxString str;
c8bc7bb8
RD
1313 if (self->GetDescription(&str)) {
1314#if wxUSE_UNICODE
1e4a197e 1315 return PyUnicode_FromWideChar(str.c_str(), str.Len());
c8bc7bb8
RD
1316#else
1317 return PyString_FromStringAndSize(str.c_str(), str.Len());
1318#endif
1319 } else
b37c7e1d
RD
1320 RETURN_NONE();
1321 }
1322 }
1323
1324
1325 // get the command to open/execute the file of given type
1326 %addmethods {
1327 PyObject* GetOpenCommand(const wxString& filename,
137b5242 1328 const wxString& mimetype=wxPyEmptyString) {
b37c7e1d 1329 wxString str;
c8bc7bb8
RD
1330 if (self->GetOpenCommand(&str, wxFileType::MessageParameters(filename, mimetype))) {
1331#if wxUSE_UNICODE
1e4a197e 1332 return PyUnicode_FromWideChar(str.c_str(), str.Len());
c8bc7bb8
RD
1333#else
1334 return PyString_FromStringAndSize(str.c_str(), str.Len());
1335#endif
1336 } else
b37c7e1d
RD
1337 RETURN_NONE();
1338 }
1339 }
1340
1341
1342 // get the command to print the file of given type
1343 %addmethods {
1344 PyObject* GetPrintCommand(const wxString& filename,
137b5242 1345 const wxString& mimetype=wxPyEmptyString) {
b37c7e1d 1346 wxString str;
c8bc7bb8
RD
1347 if (self->GetPrintCommand(&str, wxFileType::MessageParameters(filename, mimetype))) {
1348#if wxUSE_UNICODE
1e4a197e 1349 return PyUnicode_FromWideChar(str.c_str(), str.Len());
c8bc7bb8
RD
1350#else
1351 return PyString_FromStringAndSize(str.c_str(), str.Len());
1352#endif
1353 } else
b37c7e1d
RD
1354 RETURN_NONE();
1355 }
1356 }
1357
1358
1359 // Get all commands defined for this file type
1360 %addmethods {
1361 PyObject* GetAllCommands(const wxString& filename,
137b5242 1362 const wxString& mimetype=wxPyEmptyString) {
b37c7e1d
RD
1363 wxArrayString verbs;
1364 wxArrayString commands;
1365 if (self->GetAllCommands(&verbs, &commands,
1366 wxFileType::MessageParameters(filename, mimetype))) {
4268f798 1367 wxPyBeginBlockThreads();
b37c7e1d
RD
1368 PyObject* tuple = PyTuple_New(2);
1369 PyTuple_SetItem(tuple, 0, wxArrayString2PyList_helper(verbs));
1370 PyTuple_SetItem(tuple, 1, wxArrayString2PyList_helper(commands));
4268f798 1371 wxPyEndBlockThreads();
b37c7e1d
RD
1372 return tuple;
1373 }
1374 else
1375 RETURN_NONE();
1376 }
1377 }
1378
1379
1380 // set an arbitrary command, ask confirmation if it already exists and
1381 // overwriteprompt is TRUE
1382 bool SetCommand(const wxString& cmd, const wxString& verb,
1383 bool overwriteprompt = TRUE);
1384
137b5242 1385 bool SetDefaultIcon(const wxString& cmd = wxPyEmptyString, int index = 0);
b37c7e1d
RD
1386
1387
1388 // remove the association for this filetype from the system MIME database:
1389 // notice that it will only work if the association is defined in the user
1390 // file/registry part, we will never modify the system-wide settings
1391 bool Unassociate();
1392
1393 // operations
1394 // expand a string in the format of GetOpenCommand (which may contain
1395 // '%s' and '%t' format specificators for the file name and mime type
1396 // and %{param} constructions).
1397 static wxString ExpandCommand(const wxString& command,
1398 const MessageParameters& params);
1399
1400 // dtor (not virtual, shouldn't be derived from)
1401 ~wxFileType();
1402
1403};
1404
1405
1406
1407
1408class wxMimeTypesManager
1409{
1410public:
1411 // static helper functions
1412 // -----------------------
1413
1414 // check if the given MIME type is the same as the other one: the
1415 // second argument may contain wildcards ('*'), but not the first. If
1416 // the types are equal or if the mimeType matches wildcard the function
1417 // returns TRUE, otherwise it returns FALSE
1418 static bool IsOfType(const wxString& mimeType, const wxString& wildcard);
1419
1420 // ctor
1421 wxMimeTypesManager();
1422
1423 // loads data from standard files according to the mailcap styles
1424 // specified: this is a bitwise OR of wxMailcapStyle values
1425 //
1426 // use the extraDir parameter if you want to look for files in another
1427 // directory
9cbf6f6e 1428 void Initialize(int mailcapStyle = wxMAILCAP_ALL,
137b5242 1429 const wxString& extraDir = wxPyEmptyString);
b37c7e1d
RD
1430
1431 // and this function clears all the data from the manager
1432 void ClearData();
1433
1434 // Database lookup: all functions return a pointer to wxFileType object
1435 // whose methods may be used to query it for the information you're
1436 // interested in. If the return value is !NULL, caller is responsible for
1437 // deleting it.
1438 // get file type from file extension
1439 %new wxFileType *GetFileTypeFromExtension(const wxString& ext);
1440
1441 // get file type from MIME type (in format <category>/<format>)
1442 %new wxFileType *GetFileTypeFromMimeType(const wxString& mimeType);
1443
1444 // other operations: return TRUE if there were no errors or FALSE if there
1445 // were some unreckognized entries (the good entries are always read anyhow)
1446 //
1447
1448 // read in additional file (the standard ones are read automatically)
1449 // in mailcap format (see mimetype.cpp for description)
1450 //
1451 // 'fallback' parameter may be set to TRUE to avoid overriding the
1452 // settings from other, previously parsed, files by this one: normally,
1453 // the files read most recently would override the older files, but with
1454 // fallback == TRUE this won't happen
1455 bool ReadMailcap(const wxString& filename, bool fallback = FALSE);
1456
1457 // read in additional file in mime.types format
1458 bool ReadMimeTypes(const wxString& filename);
1459
1460 // enumerate all known MIME types
1461 %addmethods {
1462 PyObject* EnumAllFileTypes() {
1463 wxArrayString arr;
1464 self->EnumAllFileTypes(arr);
1465 return wxArrayString2PyList_helper(arr);
1466 }
1467 }
1468
1469 // these functions can be used to provide default values for some of the
1470 // MIME types inside the program itself (you may also use
1471 // ReadMailcap(filenameWithDefaultTypes, TRUE /* use as fallback */) to
1472 // achieve the same goal, but this requires having this info in a file).
1473 //
1474 void AddFallback(const wxFileTypeInfo& ft);
1475
1476
1477 // create or remove associations
1478
1479 // create a new association using the fields of wxFileTypeInfo (at least
1480 // the MIME type and the extension should be set)
1481 // if the other fields are empty, the existing values should be left alone
1482 %new wxFileType *Associate(const wxFileTypeInfo& ftInfo);
1483
1484 // undo Associate()
1485 bool Unassociate(wxFileType *ft) ;
1486
1487 // dtor (not virtual, shouldn't be derived from)
1488 ~wxMimeTypesManager();
1489};
1490
1491
1492%readonly
1493%{
1494#if 0
1495%}
dd116e73 1496// See also wxPy_ReinitStockObjects in helpers.cpp
b37c7e1d
RD
1497extern wxMimeTypesManager* wxTheMimeTypesManager;
1498%{
1499#endif
1500%}
1501%readwrite
1502
72797a7d
RD
1503//----------------------------------------------------------------------
1504
1505%{
1506#include <wx/artprov.h>
1507
1508 DECLARE_DEF_STRING(ART_OTHER);
1509
1510%}
1511
eb67b703
RD
1512%pragma(python) code = "
1513# Art clients
1514wxART_TOOLBAR = 'wxART_TOOLBAR_C'
1515wxART_MENU = 'wxART_MENU_C'
1516wxART_FRAME_ICON = 'wxART_FRAME_ICON_C'
1517wxART_CMN_DIALOG = 'wxART_CMN_DIALOG_C'
1518wxART_HELP_BROWSER = 'wxART_HELP_BROWSER_C'
1519wxART_MESSAGE_BOX = 'wxART_MESSAGE_BOX_C'
1520wxART_OTHER = 'wxART_OTHER_C'
1521
1522# Art IDs
1523wxART_ADD_BOOKMARK = 'wxART_ADD_BOOKMARK'
1524wxART_DEL_BOOKMARK = 'wxART_DEL_BOOKMARK'
1525wxART_HELP_SIDE_PANEL = 'wxART_HELP_SIDE_PANEL'
1526wxART_HELP_SETTINGS = 'wxART_HELP_SETTINGS'
1527wxART_HELP_BOOK = 'wxART_HELP_BOOK'
1528wxART_HELP_FOLDER = 'wxART_HELP_FOLDER'
1529wxART_HELP_PAGE = 'wxART_HELP_PAGE'
1530wxART_GO_BACK = 'wxART_GO_BACK'
1531wxART_GO_FORWARD = 'wxART_GO_FORWARD'
1532wxART_GO_UP = 'wxART_GO_UP'
1533wxART_GO_DOWN = 'wxART_GO_DOWN'
1534wxART_GO_TO_PARENT = 'wxART_GO_TO_PARENT'
1535wxART_GO_HOME = 'wxART_GO_HOME'
1536wxART_FILE_OPEN = 'wxART_FILE_OPEN'
1537wxART_PRINT = 'wxART_PRINT'
1538wxART_HELP = 'wxART_HELP'
1539wxART_TIP = 'wxART_TIP'
1540wxART_REPORT_VIEW = 'wxART_REPORT_VIEW'
1541wxART_LIST_VIEW = 'wxART_LIST_VIEW'
1542wxART_NEW_DIR = 'wxART_NEW_DIR'
1543wxART_FOLDER = 'wxART_FOLDER'
1544wxART_GO_DIR_UP = 'wxART_GO_DIR_UP'
1545wxART_EXECUTABLE_FILE = 'wxART_EXECUTABLE_FILE'
1546wxART_NORMAL_FILE = 'wxART_NORMAL_FILE'
1547wxART_TICK_MARK = 'wxART_TICK_MARK'
1548wxART_CROSS_MARK = 'wxART_CROSS_MARK'
1549wxART_ERROR = 'wxART_ERROR'
1550wxART_QUESTION = 'wxART_QUESTION'
1551wxART_WARNING = 'wxART_WARNING'
1552wxART_INFORMATION = 'wxART_INFORMATION'
9cbf6f6e 1553wxART_MISSING_IMAGE = 'wxART_MISSING_IMAGE'
eb67b703 1554"
72797a7d
RD
1555
1556%{ // Python aware wxArtProvider
1557class wxPyArtProvider : public wxArtProvider {
1558public:
1559
1560 virtual wxBitmap CreateBitmap(const wxArtID& id,
1561 const wxArtClient& client,
1562 const wxSize& size) {
1563 wxBitmap rval = wxNullBitmap;
1564 wxPyBeginBlockThreads();
1565 if ((wxPyCBH_findCallback(m_myInst, "CreateBitmap"))) {
1e4a197e 1566 PyObject* so = wxPyConstructObject((void*)&size, wxT("wxSize"), 0);
72797a7d
RD
1567 PyObject* ro;
1568 wxBitmap* ptr;
a66212dc 1569 PyObject* s1, *s2;
72797a7d
RD
1570 s1 = wx2PyString(id);
1571 s2 = wx2PyString(client);
a66212dc 1572 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(OOO)", s1, s2, so));
72797a7d 1573 Py_DECREF(so);
a66212dc
RD
1574 Py_DECREF(s1);
1575 Py_DECREF(s2);
72797a7d
RD
1576 if (ro) {
1577 if (!SWIG_GetPtrObj(ro, (void**)&ptr, "_wxBitmap_p"))
1578 rval = *ptr;
1579 Py_DECREF(ro);
1580 }
1581 }
1582 wxPyEndBlockThreads();
1583 return rval;
1584 }
1585
1586 PYPRIVATE;
1587};
1588%}
1589
1590// The one for SWIG to see
1591%name(wxArtProvider) class wxPyArtProvider : public wxObject
1592{
1593public:
1594 wxPyArtProvider();
1595
1596 void _setCallbackInfo(PyObject* self, PyObject* _class);
1597 %pragma(python) addtomethod = "__init__:self._setCallbackInfo(self, wxArtProvider)"
1598
1599 // Add new provider to the top of providers stack.
1600 static void PushProvider(wxPyArtProvider *provider);
1601
1602 // Remove latest added provider and delete it.
1603 static bool PopProvider();
1604
1605 // Remove provider. The provider must have been added previously!
1606 // The provider is _not_ deleted.
1607 static bool RemoveProvider(wxPyArtProvider *provider);
1608
1609 // Query the providers for bitmap with given ID and return it. Return
1610 // wxNullBitmap if no provider provides it.
1611 static wxBitmap GetBitmap(const wxString& id,
1612 const wxString& client = wxPyART_OTHER,
1613 const wxSize& size = wxDefaultSize);
1614
1615 // Query the providers for icon with given ID and return it. Return
1616 // wxNullIcon if no provider provides it.
1617 static wxIcon GetIcon(const wxString& id,
1618 const wxString& client = wxPyART_OTHER,
1619 const wxSize& size = wxDefaultSize);
1620
72797a7d
RD
1621};
1622
1623
7dbce44a
RD
1624//----------------------------------------------------------------------
1625
1626%{
1627#include <wx/docview.h>
1628%}
1629
1630class wxFileHistory : public wxObject
1631{
1632public:
1633 wxFileHistory(int maxFiles = 9);
1634 ~wxFileHistory();
1635
1636 // Operations
1637 void AddFileToHistory(const wxString& file);
1638 void RemoveFileFromHistory(int i);
1639 int GetMaxFiles() const;
1640 void UseMenu(wxMenu *menu);
1641
1642 // Remove menu from the list (MDI child may be closing)
1643 void RemoveMenu(wxMenu *menu);
1644
1645 void Load(wxConfigBase& config);
1646 void Save(wxConfigBase& config);
1647
1648 void AddFilesToMenu();
68bc8549 1649 %name(AddFilesToThisMenu)void AddFilesToMenu(wxMenu* menu);
7dbce44a
RD
1650
1651 // Accessors
1652 wxString GetHistoryFile(int i) const;
1653
7dbce44a 1654 int GetCount() const;
dd116e73 1655 %pragma(python) addtoclass = "GetNoHistoryFiles = GetCount"
7dbce44a
RD
1656
1657};
1658
4f3449b4 1659//----------------------------------------------------------------------
fd512ba2
RD
1660
1661class wxEffects: public wxObject
1662{
1663public:
1664 // Assume system colours
1665 wxEffects();
1666
1667 wxColour GetHighlightColour() const;
1668 wxColour GetLightShadow() const;
1669 wxColour GetFaceColour() const;
1670 wxColour GetMediumShadow() const;
1671 wxColour GetDarkShadow() const;
1672
1673 void SetHighlightColour(const wxColour& c);
1674 void SetLightShadow(const wxColour& c);
1675 void SetFaceColour(const wxColour& c);
1676 void SetMediumShadow(const wxColour& c);
1677 void SetDarkShadow(const wxColour& c);
1678
1679 void Set(const wxColour& highlightColour, const wxColour& lightShadow,
1680 const wxColour& faceColour, const wxColour& mediumShadow,
1681 const wxColour& darkShadow);
1682
1683 // Draw a sunken edge
1684 void DrawSunkenEdge(wxDC& dc, const wxRect& rect, int borderSize = 1);
1685
1686 // Tile a bitmap
1687 bool TileBitmap(const wxRect& rect, wxDC& dc, wxBitmap& bitmap);
1688
1689};
1690
f0261a72 1691//----------------------------------------------------------------------
9416aa89 1692
fd512ba2
RD
1693class wxSingleInstanceChecker
1694{
1695public:
1696 // like Create() but no error checking (dangerous!)
1697 wxSingleInstanceChecker(const wxString& name,
1698 const wxString& path = wxPyEmptyString);
1699
1700 // default ctor, use Create() after it
1701 %name(wxPreSingleInstanceChecker) wxSingleInstanceChecker();
1702
1703 ~wxSingleInstanceChecker();
1704
1705
1706 // name must be given and be as unique as possible, it is used as the mutex
1707 // name under Win32 and the lock file name under Unix -
1708 // wxTheApp->GetAppName() may be a good value for this parameter
1709 //
1710 // path is optional and is ignored under Win32 and used as the directory to
1711 // create the lock file in under Unix (default is wxGetHomeDir())
1712 //
1713 // returns FALSE if initialization failed, it doesn't mean that another
1714 // instance is running - use IsAnotherRunning() to check it
1715 bool Create(const wxString& name, const wxString& path = wxPyEmptyString);
1716
1717 // is another copy of this program already running?
1718 bool IsAnotherRunning() const;
1719};
1720
1721//----------------------------------------------------------------------
1722
8a12f92d
RD
1723%{
1724#ifdef __WXMSW__
1725#include <wx/msw/private.h>
20821889 1726#include <wx/dynload.h>
8a12f92d
RD
1727#endif
1728%}
1729
20821889 1730
8a12f92d
RD
1731%inline %{
1732
20821889 1733void wxDrawWindowOnDC(wxWindow* window, const wxDC& dc, int method)
8a12f92d
RD
1734{
1735#ifdef __WXMSW__
20821889
RD
1736
1737 switch (method)
1738 {
1739 case 1:
1740 // This one only partially works. Appears to be an undocumented
1741 // "standard" convention that not all widgets adhear to. For
1742 // example, for some widgets backgrounds or non-client areas may
1743 // not be painted.
1744 ::SendMessage(GetHwndOf(window), WM_PAINT, (long)GetHdcOf(dc), 0);
1745 break;
1746
1747 case 2:
1748 // This one works much better, except for on XP. On Win2k nearly
1749 // all widgets and their children are captured correctly[**]. On
1750 // XP with Themes activated most native widgets draw only
1751 // partially, if at all. Without themes it works just like on
1752 // Win2k.
1753 //
1754 // ** For example the radio buttons in a wxRadioBox are not its
1755 // children by default, but you can capture it via the panel
1756 // instead, or change RADIOBTN_PARENT_IS_RADIOBOX in radiobox.cpp.
1757 ::SendMessage(GetHwndOf(window), WM_PRINT, (long)GetHdcOf(dc),
1758 PRF_CLIENT | PRF_NONCLIENT | PRF_CHILDREN |
1759 PRF_ERASEBKGND | PRF_OWNED );
1760 break;
1761
1762 case 3:
1763 // This one is only defined in the latest SDK and is only
1764 // available on XP. MSDN says it is similar to sending WM_PRINT
1765 // so I expect that it will work similar to the above. Since it
1766 // is avaialble only on XP, it can't be compiled like this and
1767 // will have to be loaded dynamically.
1768 // //::PrintWindow(GetHwndOf(window), GetHdcOf(dc), 0); //break;
1769
1770 // fall through
1771
1772 case 4:
1773 // Use PrintWindow if available, or fallback to WM_PRINT
1774 // otherwise. Unfortunately using PrintWindow is even worse than
1775 // WM_PRINT. For most native widgets nothing is drawn to the dc
1776 // at all, with or without Themes.
1777 typedef BOOL (WINAPI *PrintWindow_t)(HWND, HDC, UINT);
1778 static bool s_triedToLoad = false;
1779 static PrintWindow_t pfnPrintWindow = NULL;
1780 if ( !s_triedToLoad )
1781 {
1782
1783 s_triedToLoad = true;
1784 wxDynamicLibrary dllUser32(_T("user32.dll"));
1785 if ( dllUser32.IsLoaded() )
1786 {
1787 wxLogNull nolog; // Don't report errors here
1788 pfnPrintWindow = (PrintWindow_t)dllUser32.GetSymbol(_T("PrintWindow"));
1789 }
1790 }
1791 if (pfnPrintWindow)
1792 {
1793 printf("Using PrintWindow\n");
1794 pfnPrintWindow(GetHwndOf(window), GetHdcOf(dc), 0);
1795 }
1796 else
1797 {
1798 printf("Using WM_PRINT\n");
1799 ::SendMessage(GetHwndOf(window), WM_PRINT, (long)GetHdcOf(dc),
1800 PRF_CLIENT | PRF_NONCLIENT | PRF_CHILDREN | PRF_ERASEBKGND | PRF_OWNED );
1801 }
1802 }
8a12f92d
RD
1803#endif
1804}
1805
1806%}
1807//----------------------------------------------------------------------
1808
fd512ba2 1809
9416aa89 1810%init %{
9416aa89
RD
1811 wxPyPtrTypeMap_Add("wxDragImage", "wxGenericDragImage");
1812 wxPyPtrTypeMap_Add("wxProcess", "wxPyProcess");
72797a7d 1813 wxPyPtrTypeMap_Add("wxArtProvider", "wxPyArtProvider");
8baa46e9 1814
9416aa89
RD
1815%}
1816
f0261a72
RD
1817//----------------------------------------------------------------------
1818