]> git.saurik.com Git - wxWidgets.git/blob - wxPython/src/misc2.i
Added base_IsAcceptedKey which was fogotten somehow...
[wxWidgets.git] / wxPython / src / misc2.i
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>
21 #include <wx/caret.h>
22 #include <wx/fontenum.h>
23 #include <wx/tipdlg.h>
24 #include <wx/process.h>
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
35 %import misc.i
36 %import gdi.i
37 %import events.i
38 %import streams.i
39
40 //---------------------------------------------------------------------------
41 // Dialog Functions
42
43 wxString 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
52 wxString 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,
62 // int LCOUNT, char** choices,
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
68 wxString wxGetSingleChoice(const wxString& message, const wxString& caption,
69 int LCOUNT, wxString* choices,
70 wxWindow *parent = NULL,
71 int x = -1, int y = -1,
72 bool centre = TRUE,
73 int width=150, int height=200);
74
75 int wxGetSingleChoiceIndex(const wxString& message, const wxString& caption,
76 int LCOUNT, wxString* choices,
77 wxWindow *parent = NULL,
78 int x = -1, int y = -1,
79 bool centre = TRUE,
80 int width=150, int height=200);
81
82
83 int 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
89 long 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
100 bool wxColourDisplay();
101 int wxDisplayDepth();
102 void wxSetCursor(wxCursor& cursor);
103
104 //----------------------------------------------------------------------
105 // Miscellaneous functions
106
107 wxWindow * wxFindWindowByLabel(const wxString& label, wxWindow *parent=NULL);
108 wxWindow * wxFindWindowByName(const wxString& name, wxWindow *parent=NULL);
109
110 void wxBeginBusyCursor(wxCursor *cursor = wxHOURGLASS_CURSOR);
111 wxWindow * wxGetActiveWindow();
112
113
114 //---------------------------------------------------------------------------
115 // Resource System
116
117 bool wxResourceAddIdentifier(char *name, int value);
118 void wxResourceClear(void);
119 wxBitmap wxResourceCreateBitmap(char *resource);
120 wxIcon wxResourceCreateIcon(char *resource);
121 wxMenuBar * wxResourceCreateMenuBar(char *resource);
122 int wxResourceGetIdentifier(char *name);
123 bool wxResourceParseData(char *resource, wxResourceTable *table = NULL);
124 bool wxResourceParseFile(char *filename, wxResourceTable *table = NULL);
125 bool wxResourceParseString(char *resource, wxResourceTable *table = NULL);
126
127 //---------------------------------------------------------------------------
128 // System Settings
129
130 enum {
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 %}
239
240 //---------------------------------------------------------------------------
241 // wxToolTip
242
243 class wxToolTip {
244 public:
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 //----------------------------------------------------------------------
265
266 class wxCaret {
267 public:
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);
280 %name(SetSizeWH) void SetSize(int width, int height);
281 void SetSize(const wxSize& size);
282 void Show(int show = TRUE);
283 void Hide();
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
296 //----------------------------------------------------------------------
297
298 %{
299 class wxPyFontEnumerator : public wxFontEnumerator {
300 public:
301 wxPyFontEnumerator() {}
302 ~wxPyFontEnumerator() {}
303
304 DEC_PYCALLBACK_BOOL_STRING(OnFacename);
305 DEC_PYCALLBACK_BOOL_STRINGSTRING(OnFontEncoding);
306
307 PYPRIVATE;
308 };
309
310 IMP_PYCALLBACK_BOOL_STRING(wxPyFontEnumerator, wxFontEnumerator, OnFacename);
311 IMP_PYCALLBACK_BOOL_STRINGSTRING(wxPyFontEnumerator, wxFontEnumerator, OnFontEncoding);
312
313 %}
314
315 %name(wxFontEnumerator) class wxPyFontEnumerator {
316 public:
317 wxPyFontEnumerator();
318 ~wxPyFontEnumerator();
319 void _setSelf(PyObject* self, PyObject* _class);
320 %pragma(python) addtomethod = "__init__:self._setSelf(self, wxFontEnumerator)"
321
322 bool EnumerateFacenames(
323 wxFontEncoding encoding = wxFONTENCODING_SYSTEM, // all
324 bool fixedWidthOnly = FALSE);
325 bool EnumerateEncodings(const char* facename = "");
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 }
346 };
347
348 //----------------------------------------------------------------------
349
350 class wxBusyCursor {
351 public:
352 wxBusyCursor(wxCursor* cursor = wxHOURGLASS_CURSOR);
353 ~wxBusyCursor();
354 };
355
356 //----------------------------------------------------------------------
357
358 class wxWindowDisabler {
359 public:
360 wxWindowDisabler(wxWindow *winToSkip = NULL);
361 ~wxWindowDisabler();
362 };
363
364 //----------------------------------------------------------------------
365
366 void wxPostEvent(wxEvtHandler *dest, wxEvent& event);
367 void wxWakeUpIdle();
368
369 bool wxSafeYield(wxWindow* win=NULL);
370
371 //----------------------------------------------------------------------
372
373
374 class wxTipProvider
375 {
376 public:
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 %{
388 class wxPyTipProvider : public wxTipProvider {
389 public:
390 wxPyTipProvider(size_t currentTip)
391 : wxTipProvider(currentTip) {}
392
393 DEC_PYCALLBACK_STRING__pure(GetTip);
394
395 PYPRIVATE;
396 };
397
398 IMP_PYCALLBACK_STRING__pure( wxPyTipProvider, wxTipProvider, GetTip);
399
400 %}
401
402
403 // Now let SWIG know about it
404 class wxPyTipProvider : public wxTipProvider {
405 public:
406 wxPyTipProvider(size_t currentTip);
407 };
408
409
410
411 bool 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>
419 static wxPoint wxPyNullPoint;
420 %}
421
422 %name (wxDragImage) class wxGenericDragImage
423 {
424 public:
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
464 wxGenericDragImage* wxDragIcon(const wxIcon& image,
465 const wxCursor& cursor,
466 const wxPoint& hotspot) {
467 return new wxGenericDragImage(image, cursor, hotspot);
468 }
469
470 wxGenericDragImage* wxDragString(const wxString& str,
471 const wxCursor& cursor,
472 const wxPoint& hotspot) {
473 return new wxGenericDragImage(str, cursor, hotspot);
474 }
475
476 wxGenericDragImage* wxDragTreeItem(const wxTreeCtrl& treeCtrl, wxTreeItemId& id) {
477 return new wxGenericDragImage(treeCtrl, id);
478 }
479
480 wxGenericDragImage* wxDragListItem(const wxListCtrl& listCtrl, long id) {
481 return new wxGenericDragImage(listCtrl, id);
482 }
483
484 %}
485
486
487
488 //----------------------------------------------------------------------
489
490 class wxPyTimer {
491 public:
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
506 enum
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
521 class wxLog
522 {
523 public:
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
555 class wxLogStderr : public wxLog
556 {
557 public:
558 wxLogStderr(/* TODO: FILE *fp = (FILE *) NULL*/);
559 };
560
561
562 class wxLogTextCtrl : public wxLog
563 {
564 public:
565 wxLogTextCtrl(wxTextCtrl *pTextCtrl);
566 };
567
568
569 class wxLogGui : public wxLog
570 {
571 public:
572 wxLogGui();
573 };
574
575 class wxLogWindow : public wxLog
576 {
577 public:
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
591 class wxLogNull
592 {
593 public:
594 wxLogNull();
595 ~wxLogNull();
596 };
597
598
599 unsigned long wxSysErrorCode();
600 const char* wxSysErrorMsg(unsigned long nErrCode = 0);
601 void wxLogFatalError(const char *szFormat);
602 void wxLogError(const char *szFormat);
603 void wxLogWarning(const char *szFormat);
604 void wxLogMessage(const char *szFormat);
605 void wxLogInfo(const char *szFormat);
606 void wxLogVerbose(const char *szFormat);
607 void wxLogStatus(const char *szFormat);
608 %name(wxLogStatusFrame)void wxLogStatus(wxFrame *pFrame, const char *szFormat);
609 void wxLogSysError(const char *szFormat);
610
611
612
613 //----------------------------------------------------------------------
614
615 class wxProcessEvent : public wxEvent {
616 public:
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
628 class wxPyProcess : public wxProcess {
629 public:
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
639 IMP_PYCALLBACK_VOID_INTINT( wxPyProcess, wxProcess, OnTerminate);
640 %}
641
642
643 %name(wxProcess)class wxPyProcess : public wxEvtHandler {
644 public:
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
666 long wxExecute(const wxString& command,
667 int sync = FALSE,
668 wxPyProcess *process = NULL);
669
670 //----------------------------------------------------------------------
671 //----------------------------------------------------------------------
672