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