temp fix for link errors after last commit
[wxWidgets.git] / src / common / utilscmn.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: utilscmn.cpp
3 // Purpose: Miscellaneous utility functions and classes
4 // Author: Julian Smart
5 // Modified by:
6 // Created: 29/01/98
7 // RCS-ID: $Id$
8 // Copyright: (c) 1998 Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 // ============================================================================
13 // declarations
14 // ============================================================================
15
16 // ----------------------------------------------------------------------------
17 // headers
18 // ----------------------------------------------------------------------------
19
20 #ifdef __GNUG__
21 #pragma implementation "utils.h"
22 #endif
23
24 // For compilers that support precompilation, includes "wx.h".
25 #include "wx/wxprec.h"
26
27 #ifdef __BORLANDC__
28 #pragma hdrstop
29 #endif
30
31 #ifndef WX_PRECOMP
32 #include "wx/defs.h"
33 #include "wx/string.h"
34 #include "wx/utils.h"
35 #include "wx/intl.h"
36 #include "wx/log.h"
37
38 #if wxUSE_GUI
39 #include "wx/app.h"
40 #include "wx/window.h"
41 #include "wx/frame.h"
42 #include "wx/menu.h"
43 #include "wx/msgdlg.h"
44 #include "wx/textdlg.h"
45 #include "wx/textctrl.h" // for wxTE_PASSWORD
46 #if wxUSE_ACCEL
47 #include "wx/menuitem.h"
48 #include "wx/accel.h"
49 #endif // wxUSE_ACCEL
50 #endif // wxUSE_GUI
51 #endif // WX_PRECOMP
52
53 #ifndef __WIN16__
54 #include "wx/process.h"
55 #include "wx/txtstrm.h"
56 #endif
57
58 #include <ctype.h>
59 #include <stdio.h>
60 #include <stdlib.h>
61 #include <string.h>
62
63 #if !defined(__WATCOMC__)
64 #if !(defined(_MSC_VER) && (_MSC_VER > 800))
65 #include <errno.h>
66 #endif
67 #endif
68
69 #if wxUSE_GUI
70 #include "wx/colordlg.h"
71 #include "wx/fontdlg.h"
72 #include "wx/notebook.h"
73 #include "wx/frame.h"
74 #include "wx/statusbr.h"
75 #endif // wxUSE_GUI
76
77 #include <time.h>
78
79 #ifndef __MWERKS__
80 #include <sys/types.h>
81 #include <sys/stat.h>
82 #endif
83
84 #ifdef __SALFORDC__
85 #include <clib.h>
86 #endif
87
88 #ifdef __WXMSW__
89 #include "wx/msw/private.h"
90 #endif
91
92 #if 1 // def __WXBASE__
93
94 // ----------------------------------------------------------------------------
95 // common data
96 // ----------------------------------------------------------------------------
97
98 #if WXWIN_COMPATIBILITY_2_2
99 const wxChar *wxInternalErrorStr = wxT("wxWindows Internal Error");
100 const wxChar *wxFatalErrorStr = wxT("wxWindows Fatal Error");
101 #endif // WXWIN_COMPATIBILITY_2_2
102
103 // ============================================================================
104 // implementation
105 // ============================================================================
106
107 #if WXWIN_COMPATIBILITY_2_4
108
109 wxChar *
110 copystring (const wxChar *s)
111 {
112 if (s == NULL) s = wxT("");
113 size_t len = wxStrlen (s) + 1;
114
115 wxChar *news = new wxChar[len];
116 memcpy (news, s, len * sizeof(wxChar)); // Should be the fastest
117
118 return news;
119 }
120
121 #endif // WXWIN_COMPATIBILITY_2_4
122
123 // Id generation
124 static long wxCurrentId = 100;
125
126 long
127 wxNewId (void)
128 {
129 return wxCurrentId++;
130 }
131
132 long
133 wxGetCurrentId(void) { return wxCurrentId; }
134
135 void
136 wxRegisterId (long id)
137 {
138 if (id >= wxCurrentId)
139 wxCurrentId = id + 1;
140 }
141
142 // ----------------------------------------------------------------------------
143 // String <-> Number conversions (deprecated)
144 // ----------------------------------------------------------------------------
145
146 #if WXWIN_COMPATIBILITY_2_4
147
148 WXDLLEXPORT_DATA(const wxChar *) wxFloatToStringStr = wxT("%.2f");
149 WXDLLEXPORT_DATA(const wxChar *) wxDoubleToStringStr = wxT("%.2f");
150
151 void
152 StringToFloat (const wxChar *s, float *number)
153 {
154 if (s && *s && number)
155 *number = (float) wxStrtod (s, (wxChar **) NULL);
156 }
157
158 void
159 StringToDouble (const wxChar *s, double *number)
160 {
161 if (s && *s && number)
162 *number = wxStrtod (s, (wxChar **) NULL);
163 }
164
165 wxChar *
166 FloatToString (float number, const wxChar *fmt)
167 {
168 static wxChar buf[256];
169
170 wxSprintf (buf, fmt, number);
171 return buf;
172 }
173
174 wxChar *
175 DoubleToString (double number, const wxChar *fmt)
176 {
177 static wxChar buf[256];
178
179 wxSprintf (buf, fmt, number);
180 return buf;
181 }
182
183 void
184 StringToInt (const wxChar *s, int *number)
185 {
186 if (s && *s && number)
187 *number = (int) wxStrtol (s, (wxChar **) NULL, 10);
188 }
189
190 void
191 StringToLong (const wxChar *s, long *number)
192 {
193 if (s && *s && number)
194 *number = wxStrtol (s, (wxChar **) NULL, 10);
195 }
196
197 wxChar *
198 IntToString (int number)
199 {
200 static wxChar buf[20];
201
202 wxSprintf (buf, wxT("%d"), number);
203 return buf;
204 }
205
206 wxChar *
207 LongToString (long number)
208 {
209 static wxChar buf[20];
210
211 wxSprintf (buf, wxT("%ld"), number);
212 return buf;
213 }
214
215 #endif // WXWIN_COMPATIBILITY_2_4
216
217 // Array used in DecToHex conversion routine.
218 static wxChar hexArray[] = wxT("0123456789ABCDEF");
219
220 // Convert 2-digit hex number to decimal
221 int wxHexToDec(const wxString& buf)
222 {
223 int firstDigit, secondDigit;
224
225 if (buf.GetChar(0) >= wxT('A'))
226 firstDigit = buf.GetChar(0) - wxT('A') + 10;
227 else
228 firstDigit = buf.GetChar(0) - wxT('0');
229
230 if (buf.GetChar(1) >= wxT('A'))
231 secondDigit = buf.GetChar(1) - wxT('A') + 10;
232 else
233 secondDigit = buf.GetChar(1) - wxT('0');
234
235 return (firstDigit & 0xF) * 16 + (secondDigit & 0xF );
236 }
237
238 // Convert decimal integer to 2-character hex string
239 void wxDecToHex(int dec, wxChar *buf)
240 {
241 int firstDigit = (int)(dec/16.0);
242 int secondDigit = (int)(dec - (firstDigit*16.0));
243 buf[0] = hexArray[firstDigit];
244 buf[1] = hexArray[secondDigit];
245 buf[2] = 0;
246 }
247
248 // Convert decimal integer to 2-character hex string
249 wxString wxDecToHex(int dec)
250 {
251 wxChar buf[3];
252 wxDecToHex(dec, buf);
253 return wxString(buf);
254 }
255
256 // ----------------------------------------------------------------------------
257 // misc functions
258 // ----------------------------------------------------------------------------
259
260 // Return the current date/time
261 wxString wxNow()
262 {
263 time_t now = time((time_t *) NULL);
264 char *date = ctime(&now);
265 date[24] = '\0';
266 return wxString::FromAscii(date);
267 }
268
269 const wxChar *wxGetInstallPrefix()
270 {
271 wxString prefix;
272
273 if ( wxGetEnv(wxT("WXPREFIX"), &prefix) )
274 return prefix.c_str();
275
276 #ifdef wxINSTALL_PREFIX
277 return wxT(wxINSTALL_PREFIX);
278 #else
279 return wxT("");
280 #endif
281 }
282
283 wxString wxGetDataDir()
284 {
285 wxString format = wxGetInstallPrefix();
286 format << wxFILE_SEP_PATH
287 << wxT("share") << wxFILE_SEP_PATH
288 << wxT("wx") << wxFILE_SEP_PATH
289 << wxT("%i.%i");
290 wxString dir;
291 dir.Printf(format.c_str(), wxMAJOR_VERSION, wxMINOR_VERSION);
292 return dir;
293 }
294
295
296 // ----------------------------------------------------------------------------
297 // network and user id functions
298 // ----------------------------------------------------------------------------
299
300 // Get Full RFC822 style email address
301 bool wxGetEmailAddress(wxChar *address, int maxSize)
302 {
303 wxString email = wxGetEmailAddress();
304 if ( !email )
305 return FALSE;
306
307 wxStrncpy(address, email, maxSize - 1);
308 address[maxSize - 1] = wxT('\0');
309
310 return TRUE;
311 }
312
313 wxString wxGetEmailAddress()
314 {
315 wxString email;
316
317 wxString host = wxGetFullHostName();
318 if ( !!host )
319 {
320 wxString user = wxGetUserId();
321 if ( !!user )
322 {
323 email << user << wxT('@') << host;
324 }
325 }
326
327 return email;
328 }
329
330 wxString wxGetUserId()
331 {
332 static const int maxLoginLen = 256; // FIXME arbitrary number
333
334 wxString buf;
335 bool ok = wxGetUserId(buf.GetWriteBuf(maxLoginLen), maxLoginLen);
336 buf.UngetWriteBuf();
337
338 if ( !ok )
339 buf.Empty();
340
341 return buf;
342 }
343
344 wxString wxGetUserName()
345 {
346 static const int maxUserNameLen = 1024; // FIXME arbitrary number
347
348 wxString buf;
349 bool ok = wxGetUserName(buf.GetWriteBuf(maxUserNameLen), maxUserNameLen);
350 buf.UngetWriteBuf();
351
352 if ( !ok )
353 buf.Empty();
354
355 return buf;
356 }
357
358 wxString wxGetHostName()
359 {
360 static const size_t hostnameSize = 257;
361
362 wxString buf;
363 bool ok = wxGetHostName(buf.GetWriteBuf(hostnameSize), hostnameSize);
364
365 buf.UngetWriteBuf();
366
367 if ( !ok )
368 buf.Empty();
369
370 return buf;
371 }
372
373 wxString wxGetFullHostName()
374 {
375 static const size_t hostnameSize = 257;
376
377 wxString buf;
378 bool ok = wxGetFullHostName(buf.GetWriteBuf(hostnameSize), hostnameSize);
379
380 buf.UngetWriteBuf();
381
382 if ( !ok )
383 buf.Empty();
384
385 return buf;
386 }
387
388 wxString wxGetHomeDir()
389 {
390 wxString home;
391 wxGetHomeDir(&home);
392
393 return home;
394 }
395
396 #if 0
397
398 wxString wxGetCurrentDir()
399 {
400 wxString dir;
401 size_t len = 1024;
402 bool ok;
403 do
404 {
405 ok = getcwd(dir.GetWriteBuf(len + 1), len) != NULL;
406 dir.UngetWriteBuf();
407
408 if ( !ok )
409 {
410 if ( errno != ERANGE )
411 {
412 wxLogSysError(_T("Failed to get current directory"));
413
414 return wxEmptyString;
415 }
416 else
417 {
418 // buffer was too small, retry with a larger one
419 len *= 2;
420 }
421 }
422 //else: ok
423 } while ( !ok );
424
425 return dir;
426 }
427
428 #endif // 0
429
430 // ----------------------------------------------------------------------------
431 // wxExecute
432 // ----------------------------------------------------------------------------
433
434 // wxDoExecuteWithCapture() helper: reads an entire stream into one array
435 //
436 // returns TRUE if ok, FALSE if error
437 #if wxUSE_STREAMS
438 static bool ReadAll(wxInputStream *is, wxArrayString& output)
439 {
440 wxCHECK_MSG( is, FALSE, _T("NULL stream in wxExecute()?") );
441
442 // the stream could be already at EOF or in wxSTREAM_BROKEN_PIPE state
443 is->Reset();
444
445 wxTextInputStream tis(*is);
446
447 bool cont = TRUE;
448 while ( cont )
449 {
450 wxString line = tis.ReadLine();
451 if ( is->Eof() )
452 break;
453
454 if ( !*is )
455 {
456 cont = FALSE;
457 }
458 else
459 {
460 output.Add(line);
461 }
462 }
463
464 return cont;
465 }
466 #endif // wxUSE_STREAMS
467
468 // this is a private function because it hasn't a clean interface: the first
469 // array is passed by reference, the second by pointer - instead we have 2
470 // public versions of wxExecute() below
471 static long wxDoExecuteWithCapture(const wxString& command,
472 wxArrayString& output,
473 wxArrayString* error)
474 {
475 #ifdef __WIN16__
476 wxFAIL_MSG("Sorry, this version of wxExecute not implemented on WIN16.");
477
478 return 0;
479 #else // !Win16
480 // create a wxProcess which will capture the output
481 wxProcess *process = new wxProcess;
482 process->Redirect();
483
484 long rc = wxExecute(command, wxEXEC_SYNC, process);
485
486 #if wxUSE_STREAMS
487 if ( rc != -1 )
488 {
489 if ( !ReadAll(process->GetInputStream(), output) )
490 rc = -1;
491
492 if ( error )
493 {
494 if ( !ReadAll(process->GetErrorStream(), *error) )
495 rc = -1;
496 }
497
498 }
499 #endif // wxUSE_STREAMS
500
501 delete process;
502
503 return rc;
504 #endif // IO redirection supported
505 }
506
507 long wxExecute(const wxString& command, wxArrayString& output)
508 {
509 return wxDoExecuteWithCapture(command, output, NULL);
510 }
511
512 long wxExecute(const wxString& command,
513 wxArrayString& output,
514 wxArrayString& error)
515 {
516 return wxDoExecuteWithCapture(command, output, &error);
517 }
518
519 // ----------------------------------------------------------------------------
520 // wxApp::Yield() wrappers for backwards compatibility
521 // ----------------------------------------------------------------------------
522
523 bool wxYield()
524 {
525 return wxTheApp && wxTheApp->Yield();
526 }
527
528 bool wxYieldIfNeeded()
529 {
530 return wxTheApp && wxTheApp->Yield(TRUE);
531 }
532
533 #endif // __WXBASE__
534
535 // ============================================================================
536 // GUI-only functions from now on
537 // ============================================================================
538
539 #if wxUSE_GUI
540
541 #if wxUSE_MENUS
542
543 // ----------------------------------------------------------------------------
544 // Menu accelerators related functions
545 // ----------------------------------------------------------------------------
546
547 wxChar *wxStripMenuCodes(const wxChar *in, wxChar *out)
548 {
549 wxString s = wxMenuItem::GetLabelFromText(in);
550 if ( out )
551 {
552 // go smash their buffer if it's not big enough - I love char * params
553 memcpy(out, s.c_str(), s.length() * sizeof(wxChar));
554 }
555 else
556 {
557 out = copystring(s);
558 }
559
560 return out;
561 }
562
563 wxString wxStripMenuCodes(const wxString& in)
564 {
565 wxString out;
566
567 size_t len = in.length();
568 out.reserve(len);
569
570 for ( size_t n = 0; n < len; n++ )
571 {
572 wxChar ch = in[n];
573 if ( ch == _T('&') )
574 {
575 // skip it, it is used to introduce the accel char (or to quote
576 // itself in which case it should still be skipped): note that it
577 // can't be the last character of the string
578 if ( ++n == len )
579 {
580 wxLogDebug(_T("Invalid menu string '%s'"), in.c_str());
581 }
582 else
583 {
584 // use the next char instead
585 ch = in[n];
586 }
587 }
588 else if ( ch == _T('\t') )
589 {
590 // everything after TAB is accel string, exit the loop
591 break;
592 }
593
594 out += ch;
595 }
596
597 return out;
598 }
599
600 #endif // wxUSE_MENUS
601
602 // ----------------------------------------------------------------------------
603 // Window search functions
604 // ----------------------------------------------------------------------------
605
606 /*
607 * If parent is non-NULL, look through children for a label or title
608 * matching the specified string. If NULL, look through all top-level windows.
609 *
610 */
611
612 wxWindow *
613 wxFindWindowByLabel (const wxString& title, wxWindow * parent)
614 {
615 return wxWindow::FindWindowByLabel( title, parent );
616 }
617
618
619 /*
620 * If parent is non-NULL, look through children for a name
621 * matching the specified string. If NULL, look through all top-level windows.
622 *
623 */
624
625 wxWindow *
626 wxFindWindowByName (const wxString& name, wxWindow * parent)
627 {
628 return wxWindow::FindWindowByName( name, parent );
629 }
630
631 // Returns menu item id or -1 if none.
632 int
633 wxFindMenuItemId (wxFrame * frame, const wxString& menuString, const wxString& itemString)
634 {
635 #if wxUSE_MENUS
636 wxMenuBar *menuBar = frame->GetMenuBar ();
637 if ( menuBar )
638 return menuBar->FindMenuItem (menuString, itemString);
639 #endif // wxUSE_MENUS
640
641 return -1;
642 }
643
644 // Try to find the deepest child that contains 'pt'.
645 // We go backwards, to try to allow for controls that are spacially
646 // within other controls, but are still siblings (e.g. buttons within
647 // static boxes). Static boxes are likely to be created _before_ controls
648 // that sit inside them.
649 wxWindow* wxFindWindowAtPoint(wxWindow* win, const wxPoint& pt)
650 {
651 if (!win->IsShown())
652 return NULL;
653
654 // Hack for wxNotebook case: at least in wxGTK, all pages
655 // claim to be shown, so we must only deal with the selected one.
656 #if wxUSE_NOTEBOOK
657 if (win->IsKindOf(CLASSINFO(wxNotebook)))
658 {
659 wxNotebook* nb = (wxNotebook*) win;
660 int sel = nb->GetSelection();
661 if (sel >= 0)
662 {
663 wxWindow* child = nb->GetPage(sel);
664 wxWindow* foundWin = wxFindWindowAtPoint(child, pt);
665 if (foundWin)
666 return foundWin;
667 }
668 }
669 #endif
670
671 wxWindowList::Node *node = win->GetChildren().GetLast();
672 while (node)
673 {
674 wxWindow* child = node->GetData();
675 wxWindow* foundWin = wxFindWindowAtPoint(child, pt);
676 if (foundWin)
677 return foundWin;
678 node = node->GetPrevious();
679 }
680
681 wxPoint pos = win->GetPosition();
682 wxSize sz = win->GetSize();
683 if (win->GetParent())
684 {
685 pos = win->GetParent()->ClientToScreen(pos);
686 }
687
688 wxRect rect(pos, sz);
689 if (rect.Inside(pt))
690 return win;
691 else
692 return NULL;
693 }
694
695 wxWindow* wxGenericFindWindowAtPoint(const wxPoint& pt)
696 {
697 // Go backwards through the list since windows
698 // on top are likely to have been appended most
699 // recently.
700 wxWindowList::Node *node = wxTopLevelWindows.GetLast();
701 while (node)
702 {
703 wxWindow* win = node->GetData();
704 wxWindow* found = wxFindWindowAtPoint(win, pt);
705 if (found)
706 return found;
707 node = node->GetPrevious();
708 }
709 return NULL;
710 }
711
712 // ----------------------------------------------------------------------------
713 // GUI helpers
714 // ----------------------------------------------------------------------------
715
716 /*
717 * N.B. these convenience functions must be separate from msgdlgg.cpp, textdlgg.cpp
718 * since otherwise the generic code may be pulled in unnecessarily.
719 */
720
721 #if wxUSE_MSGDLG
722
723 int wxMessageBox(const wxString& message, const wxString& caption, long style,
724 wxWindow *parent, int WXUNUSED(x), int WXUNUSED(y) )
725 {
726 wxMessageDialog dialog(parent, message, caption, style);
727
728 int ans = dialog.ShowModal();
729 switch ( ans )
730 {
731 case wxID_OK:
732 return wxOK;
733 case wxID_YES:
734 return wxYES;
735 case wxID_NO:
736 return wxNO;
737 case wxID_CANCEL:
738 return wxCANCEL;
739 }
740
741 wxFAIL_MSG( _T("unexpected return code from wxMessageDialog") );
742
743 return wxCANCEL;
744 }
745
746 #endif // wxUSE_MSGDLG
747
748 #if wxUSE_TEXTDLG
749
750 wxString wxGetTextFromUser(const wxString& message, const wxString& caption,
751 const wxString& defaultValue, wxWindow *parent,
752 int x, int y, bool WXUNUSED(centre) )
753 {
754 wxString str;
755 wxTextEntryDialog dialog(parent, message, caption, defaultValue, wxOK|wxCANCEL, wxPoint(x, y));
756 if (dialog.ShowModal() == wxID_OK)
757 {
758 str = dialog.GetValue();
759 }
760
761 return str;
762 }
763
764 wxString wxGetPasswordFromUser(const wxString& message,
765 const wxString& caption,
766 const wxString& defaultValue,
767 wxWindow *parent)
768 {
769 wxString str;
770 wxTextEntryDialog dialog(parent, message, caption, defaultValue,
771 wxOK | wxCANCEL | wxTE_PASSWORD);
772 if ( dialog.ShowModal() == wxID_OK )
773 {
774 str = dialog.GetValue();
775 }
776
777 return str;
778 }
779
780 #endif // wxUSE_TEXTDLG
781
782 #if wxUSE_COLOURDLG
783
784 wxColour wxGetColourFromUser(wxWindow *parent, const wxColour& colInit)
785 {
786 wxColourData data;
787 data.SetChooseFull(TRUE);
788 if ( colInit.Ok() )
789 {
790 data.SetColour((wxColour &)colInit); // const_cast
791 }
792
793 wxColour colRet;
794 wxColourDialog dialog(parent, &data);
795 if ( dialog.ShowModal() == wxID_OK )
796 {
797 colRet = dialog.GetColourData().GetColour();
798 }
799 //else: leave it invalid
800
801 return colRet;
802 }
803
804 #endif // wxUSE_COLOURDLG
805
806 #if wxUSE_FONTDLG
807
808 wxFont wxGetFontFromUser(wxWindow *parent, const wxFont& fontInit)
809 {
810 wxFontData data;
811 if ( fontInit.Ok() )
812 {
813 data.SetInitialFont(fontInit);
814 }
815
816 wxFont fontRet;
817 wxFontDialog dialog(parent, data);
818 if ( dialog.ShowModal() == wxID_OK )
819 {
820 fontRet = dialog.GetFontData().GetChosenFont();
821 }
822 //else: leave it invalid
823
824 return fontRet;
825 }
826
827 #endif // wxUSE_FONTDLG
828 // ----------------------------------------------------------------------------
829 // missing C RTL functions (FIXME shouldn't be here at all)
830 // ----------------------------------------------------------------------------
831
832 #if defined( __MWERKS__ ) && !defined(__MACH__)
833 char *strdup(const char *s)
834 {
835 return strcpy( (char*) malloc( strlen( s ) + 1 ) , s ) ;
836 }
837 int isascii( int c )
838 {
839 return ( c >= 0 && c < 128 ) ;
840 }
841 #endif // __MWERKS__
842
843 // ----------------------------------------------------------------------------
844 // wxSafeYield and supporting functions
845 // ----------------------------------------------------------------------------
846
847 void wxEnableTopLevelWindows(bool enable)
848 {
849 wxWindowList::Node *node;
850 for ( node = wxTopLevelWindows.GetFirst(); node; node = node->GetNext() )
851 node->GetData()->Enable(enable);
852 }
853
854 wxWindowDisabler::wxWindowDisabler(wxWindow *winToSkip)
855 {
856 // remember the top level windows which were already disabled, so that we
857 // don't reenable them later
858 m_winDisabled = NULL;
859
860 wxWindowList::Node *node;
861 for ( node = wxTopLevelWindows.GetFirst(); node; node = node->GetNext() )
862 {
863 wxWindow *winTop = node->GetData();
864 if ( winTop == winToSkip )
865 continue;
866
867 // we don't need to disable the hidden or already disabled windows
868 if ( winTop->IsEnabled() && winTop->IsShown() )
869 {
870 winTop->Disable();
871 }
872 else
873 {
874 if ( !m_winDisabled )
875 {
876 m_winDisabled = new wxWindowList;
877 }
878
879 m_winDisabled->Append(winTop);
880 }
881 }
882 }
883
884 wxWindowDisabler::~wxWindowDisabler()
885 {
886 wxWindowList::Node *node;
887 for ( node = wxTopLevelWindows.GetFirst(); node; node = node->GetNext() )
888 {
889 wxWindow *winTop = node->GetData();
890 if ( !m_winDisabled || !m_winDisabled->Find(winTop) )
891 {
892 winTop->Enable();
893 }
894 //else: had been already disabled, don't reenable
895 }
896
897 delete m_winDisabled;
898 }
899
900 // Yield to other apps/messages and disable user input to all windows except
901 // the given one
902 bool wxSafeYield(wxWindow *win, bool onlyIfNeeded)
903 {
904 wxWindowDisabler wd(win);
905
906 bool rc;
907 if (onlyIfNeeded)
908 rc = wxYieldIfNeeded();
909 else
910 rc = wxYield();
911
912 return rc;
913 }
914
915 // Don't synthesize KeyUp events holding down a key and producing KeyDown
916 // events with autorepeat. On by default and always on in wxMSW. wxGTK version
917 // in utilsgtk.cpp.
918 #ifndef __WXGTK__
919 bool wxSetDetectableAutoRepeat( bool WXUNUSED(flag) )
920 {
921 return TRUE; // detectable auto-repeat is the only mode MSW supports
922 }
923 #endif // !wxGTK
924
925 #endif // wxUSE_GUI
926