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