]> git.saurik.com Git - wxWidgets.git/blame - wxPython/src/misc2.i
*** empty log message ***
[wxWidgets.git] / wxPython / src / misc2.i
CommitLineData
bb0054cd
RD
1/////////////////////////////////////////////////////////////////////////////
2// Name: misc2.i
3// Purpose: Definitions of miscelaneous functions and classes that need
4// to know about wxWindow. (So they can't be in misc.i or an
5// import loop will happen.)
6//
7// Author: Robin Dunn
8//
9// Created: 18-June-1999
10// RCS-ID: $Id$
11// Copyright: (c) 1998 by Total Control Software
12// Licence: wxWindows license
13/////////////////////////////////////////////////////////////////////////////
14
15%module misc2
16
17%{
18#include "helpers.h"
19#include <wx/resource.h>
20#include <wx/tooltip.h>
f0261a72
RD
21#include <wx/caret.h>
22#include <wx/fontenum.h>
f6bcfd97 23#include <wx/tipdlg.h>
c368d904 24#include <wx/process.h>
bb0054cd
RD
25%}
26
27//----------------------------------------------------------------------
28
29%include typemaps.i
30%include my_typemaps.i
31
32// Import some definitions of other classes, etc.
33%import _defs.i
34%import windows.i
f0261a72 35%import misc.i
06c0fba4 36%import gdi.i
b1462dfa 37%import events.i
c368d904 38%import streams.i
06c0fba4
RD
39
40//---------------------------------------------------------------------------
41// Dialog Functions
42
43wxString wxFileSelector(char* message,
44 char* default_path = NULL,
45 char* default_filename = NULL,
46 char* default_extension = NULL,
47 char* wildcard = "*.*",
48 int flags = 0,
49 wxWindow *parent = NULL,
50 int x = -1, int y = -1);
51
52wxString wxGetTextFromUser(const wxString& message,
53 const wxString& caption = wxPyEmptyStr,
54 const wxString& default_value = wxPyEmptyStr,
55 wxWindow *parent = NULL,
56 int x = -1, int y = -1,
57 bool centre = TRUE);
58
59
60// TODO: Need to custom wrap this one...
61// int wxGetMultipleChoice(char* message, char* caption,
eec92d76 62// int LCOUNT, char** choices,
06c0fba4
RD
63// int nsel, int *selection,
64// wxWindow *parent = NULL, int x = -1, int y = -1,
65// bool centre = TRUE, int width=150, int height=200);
66
67
68wxString wxGetSingleChoice(const wxString& message, const wxString& caption,
eec92d76 69 int LCOUNT, wxString* choices,
06c0fba4
RD
70 wxWindow *parent = NULL,
71 int x = -1, int y = -1,
72 bool centre = TRUE,
73 int width=150, int height=200);
74
75int wxGetSingleChoiceIndex(const wxString& message, const wxString& caption,
eec92d76 76 int LCOUNT, wxString* choices,
06c0fba4
RD
77 wxWindow *parent = NULL,
78 int x = -1, int y = -1,
79 bool centre = TRUE,
80 int width=150, int height=200);
81
82
83int wxMessageBox(const wxString& message,
84 const wxString& caption = wxPyEmptyStr,
85 int style = wxOK | wxCENTRE,
86 wxWindow *parent = NULL,
87 int x = -1, int y = -1);
88
89long wxGetNumberFromUser(const wxString& message,
90 const wxString& prompt,
91 const wxString& caption,
92 long value,
93 long min = 0, long max = 100,
94 wxWindow *parent = NULL,
95 const wxPoint& pos = wxPyDefaultPosition);
96
97//---------------------------------------------------------------------------
98// GDI Functions
99
100bool wxColourDisplay();
101int wxDisplayDepth();
102void wxSetCursor(wxCursor& cursor);
bb0054cd
RD
103
104//----------------------------------------------------------------------
06c0fba4 105// Miscellaneous functions
bb0054cd
RD
106
107wxWindow * wxFindWindowByLabel(const wxString& label, wxWindow *parent=NULL);
108wxWindow * wxFindWindowByName(const wxString& name, wxWindow *parent=NULL);
109
06c0fba4
RD
110void wxBeginBusyCursor(wxCursor *cursor = wxHOURGLASS_CURSOR);
111wxWindow * wxGetActiveWindow();
112
113
114//---------------------------------------------------------------------------
115// Resource System
116
117bool wxResourceAddIdentifier(char *name, int value);
118void wxResourceClear(void);
119wxBitmap wxResourceCreateBitmap(char *resource);
120wxIcon wxResourceCreateIcon(char *resource);
121wxMenuBar * wxResourceCreateMenuBar(char *resource);
122int wxResourceGetIdentifier(char *name);
123bool wxResourceParseData(char *resource, wxResourceTable *table = NULL);
124bool wxResourceParseFile(char *filename, wxResourceTable *table = NULL);
125bool wxResourceParseString(char *resource, wxResourceTable *table = NULL);
bb0054cd 126
06c0fba4
RD
127//---------------------------------------------------------------------------
128// System Settings
129
130enum {
131 wxSYS_WHITE_BRUSH,
132 wxSYS_LTGRAY_BRUSH,
133 wxSYS_GRAY_BRUSH,
134 wxSYS_DKGRAY_BRUSH,
135 wxSYS_BLACK_BRUSH,
136 wxSYS_NULL_BRUSH,
137 wxSYS_HOLLOW_BRUSH,
138 wxSYS_WHITE_PEN,
139 wxSYS_BLACK_PEN,
140 wxSYS_NULL_PEN,
141 wxSYS_OEM_FIXED_FONT,
142 wxSYS_ANSI_FIXED_FONT,
143 wxSYS_ANSI_VAR_FONT,
144 wxSYS_SYSTEM_FONT,
145 wxSYS_DEVICE_DEFAULT_FONT,
146 wxSYS_DEFAULT_PALETTE,
147 wxSYS_SYSTEM_FIXED_FONT,
148 wxSYS_DEFAULT_GUI_FONT,
149
150 wxSYS_COLOUR_SCROLLBAR,
151 wxSYS_COLOUR_BACKGROUND,
152 wxSYS_COLOUR_ACTIVECAPTION,
153 wxSYS_COLOUR_INACTIVECAPTION,
154 wxSYS_COLOUR_MENU,
155 wxSYS_COLOUR_WINDOW,
156 wxSYS_COLOUR_WINDOWFRAME,
157 wxSYS_COLOUR_MENUTEXT,
158 wxSYS_COLOUR_WINDOWTEXT,
159 wxSYS_COLOUR_CAPTIONTEXT,
160 wxSYS_COLOUR_ACTIVEBORDER,
161 wxSYS_COLOUR_INACTIVEBORDER,
162 wxSYS_COLOUR_APPWORKSPACE,
163 wxSYS_COLOUR_HIGHLIGHT,
164 wxSYS_COLOUR_HIGHLIGHTTEXT,
165 wxSYS_COLOUR_BTNFACE,
166 wxSYS_COLOUR_BTNSHADOW,
167 wxSYS_COLOUR_GRAYTEXT,
168 wxSYS_COLOUR_BTNTEXT,
169 wxSYS_COLOUR_INACTIVECAPTIONTEXT,
170 wxSYS_COLOUR_BTNHIGHLIGHT,
171
172 wxSYS_COLOUR_3DDKSHADOW,
173 wxSYS_COLOUR_3DLIGHT,
174 wxSYS_COLOUR_INFOTEXT,
175 wxSYS_COLOUR_INFOBK,
176
177 wxSYS_COLOUR_DESKTOP,
178 wxSYS_COLOUR_3DFACE,
179 wxSYS_COLOUR_3DSHADOW,
180 wxSYS_COLOUR_3DHIGHLIGHT,
181 wxSYS_COLOUR_3DHILIGHT,
182 wxSYS_COLOUR_BTNHILIGHT,
183
184 wxSYS_MOUSE_BUTTONS,
185 wxSYS_BORDER_X,
186 wxSYS_BORDER_Y,
187 wxSYS_CURSOR_X,
188 wxSYS_CURSOR_Y,
189 wxSYS_DCLICK_X,
190 wxSYS_DCLICK_Y,
191 wxSYS_DRAG_X,
192 wxSYS_DRAG_Y,
193 wxSYS_EDGE_X,
194 wxSYS_EDGE_Y,
195 wxSYS_HSCROLL_ARROW_X,
196 wxSYS_HSCROLL_ARROW_Y,
197 wxSYS_HTHUMB_X,
198 wxSYS_ICON_X,
199 wxSYS_ICON_Y,
200 wxSYS_ICONSPACING_X,
201 wxSYS_ICONSPACING_Y,
202 wxSYS_WINDOWMIN_X,
203 wxSYS_WINDOWMIN_Y,
204 wxSYS_SCREEN_X,
205 wxSYS_SCREEN_Y,
206 wxSYS_FRAMESIZE_X,
207 wxSYS_FRAMESIZE_Y,
208 wxSYS_SMALLICON_X,
209 wxSYS_SMALLICON_Y,
210 wxSYS_HSCROLL_Y,
211 wxSYS_VSCROLL_X,
212 wxSYS_VSCROLL_ARROW_X,
213 wxSYS_VSCROLL_ARROW_Y,
214 wxSYS_VTHUMB_Y,
215 wxSYS_CAPTION_Y,
216 wxSYS_MENU_Y,
217 wxSYS_NETWORK_PRESENT,
218 wxSYS_PENWINDOWS_PRESENT,
219 wxSYS_SHOW_SOUNDS,
220 wxSYS_SWAP_BUTTONS,
221};
222
223
224
225%inline %{
226
227 wxColour wxSystemSettings_GetSystemColour(int index) {
228 return wxSystemSettings::GetSystemColour(index);
229 }
230
231 wxFont wxSystemSettings_GetSystemFont(int index) {
232 return wxSystemSettings::GetSystemFont(index);
233 }
234
235 int wxSystemSettings_GetSystemMetric(int index) {
236 return wxSystemSettings::GetSystemMetric(index);
237 }
238%}
bb0054cd
RD
239
240//---------------------------------------------------------------------------
241// wxToolTip
242
243class wxToolTip {
244public:
245 wxToolTip(const wxString &tip);
246
247 void SetTip(const wxString& tip);
248 wxString GetTip();
249 // *** Not in the "public" interface void SetWindow(wxWindow *win);
250 wxWindow *GetWindow();
251};
252
253
254%inline %{
255 void wxToolTip_Enable(bool flag) {
256 wxToolTip::Enable(flag);
257 }
258
259 void wxToolTip_SetDelay(long milliseconds) {
260 wxToolTip::SetDelay(milliseconds);
261 }
262%}
263
264//----------------------------------------------------------------------
f0261a72
RD
265
266class wxCaret {
267public:
268 wxCaret(wxWindow* window, const wxSize& size);
269 ~wxCaret();
270
271 bool IsOk();
272 bool IsVisible();
273 %name(GetPositionTuple)void GetPosition(int *OUTPUT, int *OUTPUT);
274 wxPoint GetPosition();
275 %name(GetSizeTuple)void GetSize(int *OUTPUT, int *OUTPUT);
276 wxSize GetSize();
277 wxWindow *GetWindow();
278 %name(MoveXY)void Move(int x, int y);
279 void Move(const wxPoint& pt);
a1df7a95
RD
280 %name(SetSizeWH) void SetSize(int width, int height);
281 void SetSize(const wxSize& size);
f0261a72
RD
282 void Show(int show = TRUE);
283 void Hide();
f0261a72
RD
284};
285
286%inline %{
287 int wxCaret_GetBlinkTime() {
288 return wxCaret::GetBlinkTime();
289 }
290
291 void wxCaret_SetBlinkTime(int milliseconds) {
292 wxCaret::SetBlinkTime(milliseconds);
293 }
294%}
295
bb0054cd 296//----------------------------------------------------------------------
f0261a72
RD
297
298%{
299class wxPyFontEnumerator : public wxFontEnumerator {
300public:
301 wxPyFontEnumerator() {}
302 ~wxPyFontEnumerator() {}
303
b1462dfa 304 DEC_PYCALLBACK_BOOL_STRING(OnFacename);
f0261a72
RD
305 DEC_PYCALLBACK_BOOL_STRINGSTRING(OnFontEncoding);
306
307 PYPRIVATE;
308};
309
b1462dfa 310IMP_PYCALLBACK_BOOL_STRING(wxPyFontEnumerator, wxFontEnumerator, OnFacename);
f0261a72
RD
311IMP_PYCALLBACK_BOOL_STRINGSTRING(wxPyFontEnumerator, wxFontEnumerator, OnFontEncoding);
312
313%}
314
315%name(wxFontEnumerator) class wxPyFontEnumerator {
316public:
b1462dfa
RD
317 wxPyFontEnumerator();
318 ~wxPyFontEnumerator();
f6bcfd97
BP
319 void _setSelf(PyObject* self, PyObject* _class);
320 %pragma(python) addtomethod = "__init__:self._setSelf(self, wxFontEnumerator)"
f0261a72 321
b1462dfa
RD
322 bool EnumerateFacenames(
323 wxFontEncoding encoding = wxFONTENCODING_SYSTEM, // all
324 bool fixedWidthOnly = FALSE);
325 bool EnumerateEncodings(const char* facename = "");
65dd82cb
RD
326
327 //wxArrayString* GetEncodings();
328 //wxArrayString* GetFacenames();
329 %addmethods {
330 PyObject* GetEncodings() {
331 wxArrayString* arr = self->GetEncodings();
332 PyObject* list = PyList_New(0);
333 for (size_t x=0; x<arr->GetCount(); x++)
334 PyList_Append(list, PyString_FromString((*arr)[x]));
335 return list;
336 }
337
338 PyObject* GetFacenames() {
339 wxArrayString* arr = self->GetFacenames();
340 PyObject* list = PyList_New(0);
341 for (size_t x=0; x<arr->GetCount(); x++)
342 PyList_Append(list, PyString_FromString((*arr)[x]));
343 return list;
344 }
345 }
f0261a72 346};
2abc0a0f
RD
347
348//----------------------------------------------------------------------
349
350class wxBusyCursor {
351public:
352 wxBusyCursor(wxCursor* cursor = wxHOURGLASS_CURSOR);
353 ~wxBusyCursor();
354};
355
b1462dfa 356//----------------------------------------------------------------------
2abc0a0f 357
c368d904
RD
358class wxWindowDisabler {
359public:
360 wxWindowDisabler(wxWindow *winToSkip = NULL);
361 ~wxWindowDisabler();
362};
363
364//----------------------------------------------------------------------
365
b1462dfa 366void wxPostEvent(wxEvtHandler *dest, wxEvent& event);
694759cf 367void wxWakeUpIdle();
2abc0a0f 368
c368d904
RD
369bool wxSafeYield(wxWindow* win=NULL);
370
2abc0a0f 371//----------------------------------------------------------------------
f6bcfd97
BP
372
373
374class wxTipProvider
375{
376public:
377 // wxTipProvider(size_t currentTip); **** Abstract base class
378 ~wxTipProvider();
379
380 virtual wxString GetTip() = 0;
381 size_t GetCurrentTip();
382
383};
384
385
386// The C++ version of wxPyTipProvider
387%{
388class wxPyTipProvider : public wxTipProvider {
389public:
390 wxPyTipProvider(size_t currentTip)
391 : wxTipProvider(currentTip) {}
392
393 DEC_PYCALLBACK_STRING__pure(GetTip);
394
395 PYPRIVATE;
396};
397
398IMP_PYCALLBACK_STRING__pure( wxPyTipProvider, wxTipProvider, GetTip);
399
400%}
401
402
403// Now let SWIG know about it
404class wxPyTipProvider : public wxTipProvider {
405public:
406 wxPyTipProvider(size_t currentTip);
407};
408
409
410
411bool wxShowTip(wxWindow *parent, wxTipProvider *tipProvider, bool showAtStartup = TRUE);
412%new wxTipProvider * wxCreateFileTipProvider(const wxString& filename, size_t currentTip);
413
414
415//----------------------------------------------------------------------
416
417%{
418#include <wx/generic/dragimgg.h>
419static wxPoint wxPyNullPoint;
420%}
421
422%name (wxDragImage) class wxGenericDragImage
423{
424public:
425
426 wxGenericDragImage(const wxBitmap& image,
427 const wxCursor& cursor = wxNullCursor,
428 const wxPoint& hotspot = wxPyNullPoint);
429 ~wxGenericDragImage();
430
431 bool BeginDrag(const wxPoint& hotspot, wxWindow* window,
432 bool fullScreen = FALSE, wxRect* rect = NULL);
433
434 %name(BeginDrag2) bool BeginDrag(const wxPoint& hotspot, wxWindow* window,
435 wxWindow* fullScreenRect);
436
437 bool EndDrag();
438 bool Move(const wxPoint& pt);
439 bool Show();
440 bool Hide();
441
442 wxRect GetImageRect(const wxPoint& pos) const;
443 bool RedrawImage(const wxPoint& oldPos, const wxPoint& newPos,
444 bool eraseOld, bool drawNew);
445};
446
447
448// Alternate Constructors
449%new wxGenericDragImage* wxDragIcon(const wxIcon& image,
450 const wxCursor& cursor = wxNullCursor,
451 const wxPoint& hotspot = wxPyNullPoint);
452
453%new wxGenericDragImage* wxDragString(const wxString& str,
454 const wxCursor& cursor = wxNullCursor,
455 const wxPoint& hotspot = wxPyNullPoint);
456
457%new wxGenericDragImage* wxDragTreeItem(const wxTreeCtrl& treeCtrl, wxTreeItemId& id);
458
459%new wxGenericDragImage* wxDragListItem(const wxListCtrl& listCtrl, long id);
460
461
462%{
463
464wxGenericDragImage* wxDragIcon(const wxIcon& image,
465 const wxCursor& cursor,
466 const wxPoint& hotspot) {
467 return new wxGenericDragImage(image, cursor, hotspot);
468}
469
470wxGenericDragImage* wxDragString(const wxString& str,
471 const wxCursor& cursor,
472 const wxPoint& hotspot) {
473 return new wxGenericDragImage(str, cursor, hotspot);
474}
475
476wxGenericDragImage* wxDragTreeItem(const wxTreeCtrl& treeCtrl, wxTreeItemId& id) {
477 return new wxGenericDragImage(treeCtrl, id);
478}
479
480wxGenericDragImage* wxDragListItem(const wxListCtrl& listCtrl, long id) {
481 return new wxGenericDragImage(listCtrl, id);
482}
483
484%}
485
486
487
488//----------------------------------------------------------------------
489
490class wxPyTimer {
491public:
492 wxPyTimer(PyObject* notify);
493 ~wxPyTimer();
494 int GetInterval();
495 bool IsOneShot();
496 bool IsRunning();
497 void SetOwner(wxEvtHandler *owner, int id = -1);
498 void Start(int milliseconds=-1, int oneShot=FALSE);
499 void Stop();
500};
501
502//----------------------------------------------------------------------
503//----------------------------------------------------------------------
504
505
506enum
507{
508 wxLOG_FatalError, // program can't continue, abort immediately
509 wxLOG_Error, // a serious error, user must be informed about it
510 wxLOG_Warning, // user is normally informed about it but may be ignored
511 wxLOG_Message, // normal message (i.e. normal output of a non GUI app)
512 wxLOG_Info, // informational message (a.k.a. 'Verbose')
513 wxLOG_Status, // informational: might go to the status line of GUI app
514 wxLOG_Debug, // never shown to the user, disabled in release mode
515 wxLOG_Trace, // trace messages are also only enabled in debug mode
516 wxLOG_Progress, // used for progress indicator (not yet)
517 wxLOG_User = 100 // user defined levels start here
518};
519
520
521class wxLog
522{
523public:
524 wxLog();
525
526 static bool IsEnabled();
527 static bool EnableLogging(bool doIt = TRUE);
528 static void OnLog(wxLogLevel level, const char *szString, int t=0);
529
530 virtual void Flush();
531 bool HasPendingMessages() const;
532
533 static void FlushActive();
534 static wxLog *GetActiveTarget();
535 static wxLog *SetActiveTarget(wxLog *pLogger);
536
537 static void Suspend();
538 static void Resume();
539
540 void SetVerbose(bool bVerbose = TRUE);
541
542 static void DontCreateOnDemand();
543 static void SetTraceMask(wxTraceMask ulMask);
544 static void AddTraceMask(const wxString& str);
545 static void RemoveTraceMask(const wxString& str);
546
547 bool GetVerbose() const { return m_bVerbose; }
548
549 static wxTraceMask GetTraceMask();
550 static bool IsAllowedTraceMask(const char *mask);
551
552};
553
554
555class wxLogStderr : public wxLog
556{
557public:
558 wxLogStderr(/* TODO: FILE *fp = (FILE *) NULL*/);
559};
560
561
562class wxLogTextCtrl : public wxLog
563{
564public:
565 wxLogTextCtrl(wxTextCtrl *pTextCtrl);
566};
567
568
569class wxLogGui : public wxLog
570{
571public:
572 wxLogGui();
573};
574
575class wxLogWindow : public wxLog
576{
577public:
578 wxLogWindow(wxFrame *pParent, // the parent frame (can be NULL)
579 const char *szTitle, // the title of the frame
580 bool bShow = TRUE, // show window immediately?
581 bool bPassToOld = TRUE); // pass log messages to the old target?
582
583 void Show(bool bShow = TRUE);
584 wxFrame *GetFrame() const;
585 wxLog *GetOldLog() const;
586 bool IsPassingMessages() const;
587 void PassMessages(bool bDoPass) { m_bPassMessages = bDoPass; }
588};
589
590
591class wxLogNull
592{
593public:
594 wxLogNull();
595 ~wxLogNull();
596};
597
598
599unsigned long wxSysErrorCode();
600const char* wxSysErrorMsg(unsigned long nErrCode = 0);
601void wxLogFatalError(const char *szFormat);
602void wxLogError(const char *szFormat);
603void wxLogWarning(const char *szFormat);
604void wxLogMessage(const char *szFormat);
605void wxLogInfo(const char *szFormat);
606void wxLogVerbose(const char *szFormat);
607void wxLogStatus(const char *szFormat);
608%name(wxLogStatusFrame)void wxLogStatus(wxFrame *pFrame, const char *szFormat);
609void wxLogSysError(const char *szFormat);
610
611
c368d904
RD
612
613//----------------------------------------------------------------------
614
615class wxProcessEvent : public wxEvent {
616public:
617 wxProcessEvent(int id = 0, int pid = 0, int exitcode = 0);
618 int GetPid();
619 int GetExitCode();
620 int m_pid, m_exitcode;
621};
622
623
624
625
626%{ // C++ version of wxProcess derived class
627
628class wxPyProcess : public wxProcess {
629public:
630 wxPyProcess(wxEvtHandler *parent = NULL, int id = -1)
631 : wxProcess(parent, id)
632 {}
633
634 DEC_PYCALLBACK_VOID_INTINT(OnTerminate);
635
636 PYPRIVATE;
637};
638
639IMP_PYCALLBACK_VOID_INTINT( wxPyProcess, wxProcess, OnTerminate);
640%}
641
642
643%name(wxProcess)class wxPyProcess : public wxEvtHandler {
644public:
645 wxPyProcess(wxEvtHandler *parent = NULL, int id = -1);
646 %addmethods { void Destroy() { delete self; } }
647
648 void _setSelf(PyObject* self, PyObject* _class);
649 %pragma(python) addtomethod = "__init__:self._setSelf(self, wxProcess)"
650
651 void base_OnTerminate(int pid, int status);
652
653 void Redirect();
654 bool IsRedirected();
655 void Detach();
656
657 wxInputStream *GetInputStream();
658 wxInputStream *GetErrorStream();
659 wxOutputStream *GetOutputStream();
660
661 void CloseOutput();
662};
663
664
665
666long wxExecute(const wxString& command,
667 int sync = FALSE,
668 wxPyProcess *process = NULL);
669
f0261a72
RD
670//----------------------------------------------------------------------
671//----------------------------------------------------------------------
672