1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Miscellaneous utility functions and classes
4 // Author: Julian Smart
8 // Copyright: (c) 1998 Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // ============================================================================
14 // ============================================================================
16 // ----------------------------------------------------------------------------
18 // ----------------------------------------------------------------------------
20 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) && !defined(__EMX__)
21 // Some older compilers (such as EMX) cannot handle
22 // #pragma interface/implementation correctly, iff
23 // #pragma implementation is used in _two_ translation
24 // units (as created by e.g. event.cpp compiled for
25 // libwx_base and event.cpp compiled for libwx_gui_core).
26 // So we must not use those pragmas for those compilers in
28 #pragma implementation "utils.h"
31 // For compilers that support precompilation, includes "wx.h".
32 #include "wx/wxprec.h"
40 #include "wx/string.h"
46 #include "wx/window.h"
49 #include "wx/msgdlg.h"
50 #include "wx/textdlg.h"
51 #include "wx/textctrl.h" // for wxTE_PASSWORD
53 #include "wx/menuitem.h"
59 #include "wx/apptrait.h"
61 #include "wx/process.h"
62 #include "wx/txtstrm.h"
64 #include "wx/mimetype.h"
65 #include "wx/config.h"
67 #if defined(__WXWINCE__) && wxUSE_DATETIME
68 #include "wx/datetime.h"
76 #if !defined(__WATCOMC__)
77 #if !(defined(_MSC_VER) && (_MSC_VER > 800))
83 #include "wx/colordlg.h"
84 #include "wx/fontdlg.h"
85 #include "wx/notebook.h"
87 #include "wx/statusbr.h"
93 #include "wx/msw/wince/time.h"
96 #if !defined(__MWERKS__) && !defined(__WXWINCE__)
97 #include <sys/types.h>
101 #if defined(__WXMSW__)
102 #include "wx/msw/private.h"
107 // ----------------------------------------------------------------------------
109 // ----------------------------------------------------------------------------
111 #if WXWIN_COMPATIBILITY_2_2
112 const wxChar
*wxInternalErrorStr
= wxT("wxWidgets Internal Error");
113 const wxChar
*wxFatalErrorStr
= wxT("wxWidgets Fatal Error");
114 #endif // WXWIN_COMPATIBILITY_2_2
116 // ============================================================================
118 // ============================================================================
120 #if WXWIN_COMPATIBILITY_2_4
123 copystring (const wxChar
*s
)
125 if (s
== NULL
) s
= wxEmptyString
;
126 size_t len
= wxStrlen (s
) + 1;
128 wxChar
*news
= new wxChar
[len
];
129 memcpy (news
, s
, len
* sizeof(wxChar
)); // Should be the fastest
134 #endif // WXWIN_COMPATIBILITY_2_4
136 // ----------------------------------------------------------------------------
137 // String <-> Number conversions (deprecated)
138 // ----------------------------------------------------------------------------
140 #if WXWIN_COMPATIBILITY_2_4
142 WXDLLIMPEXP_DATA_BASE(const wxChar
*) wxFloatToStringStr
= wxT("%.2f");
143 WXDLLIMPEXP_DATA_BASE(const wxChar
*) wxDoubleToStringStr
= wxT("%.2f");
146 StringToFloat (const wxChar
*s
, float *number
)
148 if (s
&& *s
&& number
)
149 *number
= (float) wxStrtod (s
, (wxChar
**) NULL
);
153 StringToDouble (const wxChar
*s
, double *number
)
155 if (s
&& *s
&& number
)
156 *number
= wxStrtod (s
, (wxChar
**) NULL
);
160 FloatToString (float number
, const wxChar
*fmt
)
162 static wxChar buf
[256];
164 wxSprintf (buf
, fmt
, number
);
169 DoubleToString (double number
, const wxChar
*fmt
)
171 static wxChar buf
[256];
173 wxSprintf (buf
, fmt
, number
);
178 StringToInt (const wxChar
*s
, int *number
)
180 if (s
&& *s
&& number
)
181 *number
= (int) wxStrtol (s
, (wxChar
**) NULL
, 10);
185 StringToLong (const wxChar
*s
, long *number
)
187 if (s
&& *s
&& number
)
188 *number
= wxStrtol (s
, (wxChar
**) NULL
, 10);
192 IntToString (int number
)
194 static wxChar buf
[20];
196 wxSprintf (buf
, wxT("%d"), number
);
201 LongToString (long number
)
203 static wxChar buf
[20];
205 wxSprintf (buf
, wxT("%ld"), number
);
209 #endif // WXWIN_COMPATIBILITY_2_4
211 // Array used in DecToHex conversion routine.
212 static wxChar hexArray
[] = wxT("0123456789ABCDEF");
214 // Convert 2-digit hex number to decimal
215 int wxHexToDec(const wxString
& buf
)
217 int firstDigit
, secondDigit
;
219 if (buf
.GetChar(0) >= wxT('A'))
220 firstDigit
= buf
.GetChar(0) - wxT('A') + 10;
222 firstDigit
= buf
.GetChar(0) - wxT('0');
224 if (buf
.GetChar(1) >= wxT('A'))
225 secondDigit
= buf
.GetChar(1) - wxT('A') + 10;
227 secondDigit
= buf
.GetChar(1) - wxT('0');
229 return (firstDigit
& 0xF) * 16 + (secondDigit
& 0xF );
232 // Convert decimal integer to 2-character hex string
233 void wxDecToHex(int dec
, wxChar
*buf
)
235 int firstDigit
= (int)(dec
/16.0);
236 int secondDigit
= (int)(dec
- (firstDigit
*16.0));
237 buf
[0] = hexArray
[firstDigit
];
238 buf
[1] = hexArray
[secondDigit
];
242 // Convert decimal integer to 2-character hex string
243 wxString
wxDecToHex(int dec
)
246 wxDecToHex(dec
, buf
);
247 return wxString(buf
);
250 // ----------------------------------------------------------------------------
252 // ----------------------------------------------------------------------------
254 // Return the current date/time
259 wxDateTime now
= wxDateTime::Now();
262 return wxEmptyString
;
265 time_t now
= time((time_t *) NULL
);
266 char *date
= ctime(&now
);
268 return wxString::FromAscii(date
);
272 void wxUsleep(unsigned long milliseconds
)
274 wxMilliSleep(milliseconds
);
277 const wxChar
*wxGetInstallPrefix()
281 if ( wxGetEnv(wxT("WXPREFIX"), &prefix
) )
282 return prefix
.c_str();
284 #ifdef wxINSTALL_PREFIX
285 return wxT(wxINSTALL_PREFIX
);
287 return wxEmptyString
;
291 wxString
wxGetDataDir()
293 wxString dir
= wxGetInstallPrefix();
294 dir
<< wxFILE_SEP_PATH
<< wxT("share") << wxFILE_SEP_PATH
<< wxT("wx");
298 int wxGetOsVersion(int *verMaj
, int *verMin
)
300 // we want this function to work even if there is no wxApp
301 wxConsoleAppTraits traitsConsole
;
302 wxAppTraits
*traits
= wxTheApp
? wxTheApp
->GetTraits() : NULL
;
304 traits
= &traitsConsole
;
306 wxToolkitInfo
& info
= traits
->GetToolkitInfo();
308 *verMaj
= info
.versionMajor
;
310 *verMin
= info
.versionMinor
;
314 // ----------------------------------------------------------------------------
315 // network and user id functions
316 // ----------------------------------------------------------------------------
318 // Get Full RFC822 style email address
319 bool wxGetEmailAddress(wxChar
*address
, int maxSize
)
321 wxString email
= wxGetEmailAddress();
325 wxStrncpy(address
, email
, maxSize
- 1);
326 address
[maxSize
- 1] = wxT('\0');
331 wxString
wxGetEmailAddress()
335 wxString host
= wxGetFullHostName();
338 wxString user
= wxGetUserId();
341 email
<< user
<< wxT('@') << host
;
348 wxString
wxGetUserId()
350 static const int maxLoginLen
= 256; // FIXME arbitrary number
353 bool ok
= wxGetUserId(wxStringBuffer(buf
, maxLoginLen
), maxLoginLen
);
361 wxString
wxGetUserName()
363 static const int maxUserNameLen
= 1024; // FIXME arbitrary number
366 bool ok
= wxGetUserName(wxStringBuffer(buf
, maxUserNameLen
), maxUserNameLen
);
374 wxString
wxGetHostName()
376 static const size_t hostnameSize
= 257;
379 bool ok
= wxGetHostName(wxStringBuffer(buf
, hostnameSize
), hostnameSize
);
387 wxString
wxGetFullHostName()
389 static const size_t hostnameSize
= 257;
392 bool ok
= wxGetFullHostName(wxStringBuffer(buf
, hostnameSize
), hostnameSize
);
400 wxString
wxGetHomeDir()
410 wxString
wxGetCurrentDir()
417 ok
= getcwd(dir
.GetWriteBuf(len
+ 1), len
) != NULL
;
422 if ( errno
!= ERANGE
)
424 wxLogSysError(_T("Failed to get current directory"));
426 return wxEmptyString
;
430 // buffer was too small, retry with a larger one
442 // ----------------------------------------------------------------------------
444 // ----------------------------------------------------------------------------
446 // wxDoExecuteWithCapture() helper: reads an entire stream into one array
448 // returns true if ok, false if error
450 static bool ReadAll(wxInputStream
*is
, wxArrayString
& output
)
452 wxCHECK_MSG( is
, false, _T("NULL stream in wxExecute()?") );
454 // the stream could be already at EOF or in wxSTREAM_BROKEN_PIPE state
457 wxTextInputStream
tis(*is
);
462 wxString line
= tis
.ReadLine();
478 #endif // wxUSE_STREAMS
480 // this is a private function because it hasn't a clean interface: the first
481 // array is passed by reference, the second by pointer - instead we have 2
482 // public versions of wxExecute() below
483 static long wxDoExecuteWithCapture(const wxString
& command
,
484 wxArrayString
& output
,
485 wxArrayString
* error
,
488 // create a wxProcess which will capture the output
489 wxProcess
*process
= new wxProcess
;
492 long rc
= wxExecute(command
, wxEXEC_SYNC
| flags
, process
);
497 if ( !ReadAll(process
->GetInputStream(), output
) )
502 if ( !ReadAll(process
->GetErrorStream(), *error
) )
510 #endif // wxUSE_STREAMS/!wxUSE_STREAMS
517 long wxExecute(const wxString
& command
, wxArrayString
& output
, int flags
)
519 return wxDoExecuteWithCapture(command
, output
, NULL
, flags
);
522 long wxExecute(const wxString
& command
,
523 wxArrayString
& output
,
524 wxArrayString
& error
,
527 return wxDoExecuteWithCapture(command
, output
, &error
, flags
);
530 // ----------------------------------------------------------------------------
531 // Launch default browser
532 // ----------------------------------------------------------------------------
534 bool wxLaunchDefaultBrowser(const wxString
& url
)
536 wxString finalurl
= url
;
538 //if it isn't a full url, try appending http:// to it
539 if(wxURI(url
).IsReference())
540 finalurl
= wxString(wxT("http://")) + url
;
542 #if defined(__WXMSW__) && wxUSE_CONFIG_NATIVE
546 // ShellExecute() always opens in the same window,
547 // so do it manually for new window (from Mahogany)
548 wxRegKey
key(wxRegKey::HKCR
, url
.BeforeFirst(':') + wxT("\\shell\\open"));
551 wxRegKey
keyDDE(key
, wxT("DDEExec"));
552 if ( keyDDE
.Exists() )
554 wxString ddeTopic
= wxRegKey(keyDDE
, wxT("topic"));
556 // we only know the syntax of WWW_OpenURL DDE request
557 if ( ddeTopic
== wxT("WWW_OpenURL") )
559 wxString ddeCmd
= keyDDE
;
561 // this is a bit naive but should work as -1 can't appear
562 // elsewhere in the DDE topic, normally
563 if ( ddeCmd
.Replace(wxT("-1"), wxT("0"),
564 false /* only first occurence */) == 1 )
566 // and also replace the parameters
567 if ( ddeCmd
.Replace(wxT("%1"), url
, false) == 1 )
569 // magic incantation understood by wxMSW
570 command
<< wxT("WX_DDE#")
571 << wxRegKey(key
, wxT("command")).QueryDefaultValue() << wxT('#')
572 << wxRegKey(keyDDE
, wxT("application")).QueryDefaultValue()
573 << wxT('#') << ddeTopic
<< wxT('#')
581 //Try wxExecute - if it doesn't work or the regkey stuff
582 //above failed, fallback to opening the file in the same
584 if ( command
.empty() || wxExecute(command
) == -1)
586 int nResult
; //HINSTANCE error code
588 #if !defined(__WXWINCE__)
589 // CYGWIN and MINGW may have problems - so load ShellExecute
591 typedef HINSTANCE (WINAPI
*LPShellExecute
)(HWND hwnd
, const wxChar
* lpOperation
,
592 const wxChar
* lpFile
,
593 const wxChar
* lpParameters
,
594 const wxChar
* lpDirectory
,
597 HINSTANCE hShellDll
= ::LoadLibrary(wxT("shell32.dll"));
598 if(hShellDll
== NULL
)
601 LPShellExecute lpShellExecute
=
602 (LPShellExecute
) ::GetProcAddress(hShellDll
,
603 wxString::Format(wxT("ShellExecute%s"),
613 ).mb_str(wxConvLocal
)
616 if(lpShellExecute
== NULL
)
619 // Windows sometimes doesn't open the browser correctly when using mime
620 // types, so do ShellExecute - i.e. start <url> (from James Carroll)
621 nResult
= (int) (*lpShellExecute
)(NULL
, NULL
, finalurl
.c_str(),
622 NULL
, wxT(""), SW_SHOWNORMAL
);
623 // Unload Shell32.dll
624 ::FreeLibrary(hShellDll
);
626 //Windows CE does not have normal ShellExecute - but it has
627 //ShellExecuteEx all the way back to version 1.0
630 //Set up the SHELLEXECUTEINFO structure to pass to ShellExecuteEx
631 SHELLEXECUTEINFO sei
;
632 sei
.cbSize
= sizeof(SHELLEXECUTEINFO
);
637 sei
.hkeyClass
= NULL
;
645 sei
.lpDirectory
= NULL
;
646 sei
.lpFile
= finalurl
.c_str();
648 sei
.lpParameters
= NULL
;
649 sei
.lpVerb
= TEXT("open");
650 sei
.nShow
= SW_SHOWNORMAL
;
652 //Call ShellExecuteEx
653 ShellExecuteEx(&sei
);
656 nResult
= (int) sei
.hInstApp
;
659 // Hack for Firefox (returns file not found for some reason)
660 // from Angelo Mandato's wxHyperlinksCtrl
661 // HINSTANCE_ERROR == 32 (HINSTANCE_ERROR does not exist on Windows CE)
662 if (nResult
<= 32 && nResult
!= SE_ERR_FNF
)
666 // Log something if SE_ERR_FNF happens
667 if(nResult
== SE_ERR_FNF
)
668 wxLogDebug(wxT("Got SE_ERR_FNF from ShellExecute - maybe FireFox"));
675 wxFileType
*ft
= wxTheMimeTypesManager
->GetFileTypeFromExtension (_T("html"));
678 wxLogError(_T("No default application can open .html extension"));
683 ft
->GetMimeType(&mt
);
686 bool ok
= ft
->GetOpenCommand (&cmd
, wxFileType::MessageParameters(finalurl
));
691 if( wxExecute (cmd
, wxEXEC_ASYNC
) == -1 )
693 wxLogError(_T("Failed to launch application for wxLaunchDefaultBrowser"));
699 // fallback to checking for the BROWSER environment variable
700 cmd
= wxGetenv(wxT("BROWSER"));
701 if ( cmd
.empty() || wxExecute(cmd
+ wxT(" ") + finalurl
) == -1)
706 #else // !wxUSE_MIMETYPE && !(WXMSW && wxUSE_NATIVE_CONFIG)
712 //success - hopefully
716 // ----------------------------------------------------------------------------
717 // wxApp::Yield() wrappers for backwards compatibility
718 // ----------------------------------------------------------------------------
722 return wxTheApp
&& wxTheApp
->Yield();
725 bool wxYieldIfNeeded()
727 return wxTheApp
&& wxTheApp
->Yield(true);
732 // ============================================================================
733 // GUI-only functions from now on
734 // ============================================================================
739 static long wxCurrentId
= 100;
743 // skip the part of IDs space that contains hard-coded values:
744 if (wxCurrentId
== wxID_LOWEST
)
745 wxCurrentId
= wxID_HIGHEST
+ 1;
747 return wxCurrentId
++;
751 wxGetCurrentId(void) { return wxCurrentId
; }
754 wxRegisterId (long id
)
756 if (id
>= wxCurrentId
)
757 wxCurrentId
= id
+ 1;
762 // ----------------------------------------------------------------------------
763 // Menu accelerators related functions
764 // ----------------------------------------------------------------------------
766 wxChar
*wxStripMenuCodes(const wxChar
*in
, wxChar
*out
)
768 wxString s
= wxMenuItem::GetLabelFromText(in
);
771 // go smash their buffer if it's not big enough - I love char * params
772 memcpy(out
, s
.c_str(), s
.length() * sizeof(wxChar
));
776 // MYcopystring - for easier search...
777 out
= new wxChar
[s
.length() + 1];
778 wxStrcpy(out
, s
.c_str());
784 wxString
wxStripMenuCodes(const wxString
& in
)
788 size_t len
= in
.length();
791 for ( size_t n
= 0; n
< len
; n
++ )
796 // skip it, it is used to introduce the accel char (or to quote
797 // itself in which case it should still be skipped): note that it
798 // can't be the last character of the string
801 wxLogDebug(_T("Invalid menu string '%s'"), in
.c_str());
805 // use the next char instead
809 else if ( ch
== _T('\t') )
811 // everything after TAB is accel string, exit the loop
821 #endif // wxUSE_MENUS
823 // ----------------------------------------------------------------------------
824 // Window search functions
825 // ----------------------------------------------------------------------------
828 * If parent is non-NULL, look through children for a label or title
829 * matching the specified string. If NULL, look through all top-level windows.
834 wxFindWindowByLabel (const wxString
& title
, wxWindow
* parent
)
836 return wxWindow::FindWindowByLabel( title
, parent
);
841 * If parent is non-NULL, look through children for a name
842 * matching the specified string. If NULL, look through all top-level windows.
847 wxFindWindowByName (const wxString
& name
, wxWindow
* parent
)
849 return wxWindow::FindWindowByName( name
, parent
);
852 // Returns menu item id or wxNOT_FOUND if none.
854 wxFindMenuItemId (wxFrame
* frame
, const wxString
& menuString
, const wxString
& itemString
)
857 wxMenuBar
*menuBar
= frame
->GetMenuBar ();
859 return menuBar
->FindMenuItem (menuString
, itemString
);
860 #endif // wxUSE_MENUS
865 // Try to find the deepest child that contains 'pt'.
866 // We go backwards, to try to allow for controls that are spacially
867 // within other controls, but are still siblings (e.g. buttons within
868 // static boxes). Static boxes are likely to be created _before_ controls
869 // that sit inside them.
870 wxWindow
* wxFindWindowAtPoint(wxWindow
* win
, const wxPoint
& pt
)
875 // Hack for wxNotebook case: at least in wxGTK, all pages
876 // claim to be shown, so we must only deal with the selected one.
878 if (win
->IsKindOf(CLASSINFO(wxNotebook
)))
880 wxNotebook
* nb
= (wxNotebook
*) win
;
881 int sel
= nb
->GetSelection();
884 wxWindow
* child
= nb
->GetPage(sel
);
885 wxWindow
* foundWin
= wxFindWindowAtPoint(child
, pt
);
892 wxWindowList::compatibility_iterator node
= win
->GetChildren().GetLast();
895 wxWindow
* child
= node
->GetData();
896 wxWindow
* foundWin
= wxFindWindowAtPoint(child
, pt
);
899 node
= node
->GetPrevious();
902 wxPoint pos
= win
->GetPosition();
903 wxSize sz
= win
->GetSize();
904 if (win
->GetParent())
906 pos
= win
->GetParent()->ClientToScreen(pos
);
909 wxRect
rect(pos
, sz
);
916 wxWindow
* wxGenericFindWindowAtPoint(const wxPoint
& pt
)
918 // Go backwards through the list since windows
919 // on top are likely to have been appended most
921 wxWindowList::compatibility_iterator node
= wxTopLevelWindows
.GetLast();
924 wxWindow
* win
= node
->GetData();
925 wxWindow
* found
= wxFindWindowAtPoint(win
, pt
);
928 node
= node
->GetPrevious();
933 // ----------------------------------------------------------------------------
935 // ----------------------------------------------------------------------------
938 * N.B. these convenience functions must be separate from msgdlgg.cpp, textdlgg.cpp
939 * since otherwise the generic code may be pulled in unnecessarily.
944 int wxMessageBox(const wxString
& message
, const wxString
& caption
, long style
,
945 wxWindow
*parent
, int WXUNUSED(x
), int WXUNUSED(y
) )
947 long decorated_style
= style
;
949 if ( ( style
& ( wxICON_EXCLAMATION
| wxICON_HAND
| wxICON_INFORMATION
| wxICON_QUESTION
) ) == 0 )
951 decorated_style
|= ( style
& wxYES
) ? wxICON_QUESTION
: wxICON_INFORMATION
;
954 wxMessageDialog
dialog(parent
, message
, caption
, decorated_style
);
956 int ans
= dialog
.ShowModal();
969 wxFAIL_MSG( _T("unexpected return code from wxMessageDialog") );
974 #endif // wxUSE_MSGDLG
978 wxString
wxGetTextFromUser(const wxString
& message
, const wxString
& caption
,
979 const wxString
& defaultValue
, wxWindow
*parent
,
980 wxCoord x
, wxCoord y
, bool centre
)
983 long style
= wxTextEntryDialogStyle
;
990 wxTextEntryDialog
dialog(parent
, message
, caption
, defaultValue
, style
, wxPoint(x
, y
));
992 if (dialog
.ShowModal() == wxID_OK
)
994 str
= dialog
.GetValue();
1000 wxString
wxGetPasswordFromUser(const wxString
& message
,
1001 const wxString
& caption
,
1002 const wxString
& defaultValue
,
1004 wxCoord x
, wxCoord y
, bool centre
)
1007 long style
= wxTextEntryDialogStyle
;
1014 wxPasswordEntryDialog
dialog(parent
, message
, caption
, defaultValue
,
1015 style
, wxPoint(x
, y
));
1016 if ( dialog
.ShowModal() == wxID_OK
)
1018 str
= dialog
.GetValue();
1024 #endif // wxUSE_TEXTDLG
1028 wxColour
wxGetColourFromUser(wxWindow
*parent
, const wxColour
& colInit
)
1031 data
.SetChooseFull(true);
1034 data
.SetColour((wxColour
&)colInit
); // const_cast
1038 wxColourDialog
dialog(parent
, &data
);
1039 if ( dialog
.ShowModal() == wxID_OK
)
1041 colRet
= dialog
.GetColourData().GetColour();
1043 //else: leave it invalid
1048 #endif // wxUSE_COLOURDLG
1052 wxFont
wxGetFontFromUser(wxWindow
*parent
, const wxFont
& fontInit
)
1055 if ( fontInit
.Ok() )
1057 data
.SetInitialFont(fontInit
);
1061 wxFontDialog
dialog(parent
, data
);
1062 if ( dialog
.ShowModal() == wxID_OK
)
1064 fontRet
= dialog
.GetFontData().GetChosenFont();
1066 //else: leave it invalid
1071 #endif // wxUSE_FONTDLG
1073 // ----------------------------------------------------------------------------
1074 // wxSafeYield and supporting functions
1075 // ----------------------------------------------------------------------------
1077 void wxEnableTopLevelWindows(bool enable
)
1079 wxWindowList::compatibility_iterator node
;
1080 for ( node
= wxTopLevelWindows
.GetFirst(); node
; node
= node
->GetNext() )
1081 node
->GetData()->Enable(enable
);
1084 wxWindowDisabler::wxWindowDisabler(wxWindow
*winToSkip
)
1086 // remember the top level windows which were already disabled, so that we
1087 // don't reenable them later
1088 m_winDisabled
= NULL
;
1090 wxWindowList::compatibility_iterator node
;
1091 for ( node
= wxTopLevelWindows
.GetFirst(); node
; node
= node
->GetNext() )
1093 wxWindow
*winTop
= node
->GetData();
1094 if ( winTop
== winToSkip
)
1097 // we don't need to disable the hidden or already disabled windows
1098 if ( winTop
->IsEnabled() && winTop
->IsShown() )
1104 if ( !m_winDisabled
)
1106 m_winDisabled
= new wxWindowList
;
1109 m_winDisabled
->Append(winTop
);
1114 wxWindowDisabler::~wxWindowDisabler()
1116 wxWindowList::compatibility_iterator node
;
1117 for ( node
= wxTopLevelWindows
.GetFirst(); node
; node
= node
->GetNext() )
1119 wxWindow
*winTop
= node
->GetData();
1120 if ( !m_winDisabled
|| !m_winDisabled
->Find(winTop
) )
1124 //else: had been already disabled, don't reenable
1127 delete m_winDisabled
;
1130 // Yield to other apps/messages and disable user input to all windows except
1132 bool wxSafeYield(wxWindow
*win
, bool onlyIfNeeded
)
1134 wxWindowDisabler
wd(win
);
1138 rc
= wxYieldIfNeeded();
1145 // Don't synthesize KeyUp events holding down a key and producing KeyDown
1146 // events with autorepeat. On by default and always on in wxMSW. wxGTK version
1149 bool wxSetDetectableAutoRepeat( bool WXUNUSED(flag
) )
1151 return true; // detectable auto-repeat is the only mode MSW supports