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