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