+ strcpy(imagename, cutoff + 1); /* keep the image name */
+ *(cutoff + 1) = 0; /* chop off the filename part */
+}
+
+#endif
+
+#if wxUSE_GUI
+
+// ----------------------------------------------------------------------------
+// GUI helpers
+// ----------------------------------------------------------------------------
+
+/*
+ * N.B. these convenience functions must be separate from msgdlgg.cpp, textdlgg.cpp
+ * since otherwise the generic code may be pulled in unnecessarily.
+ */
+
+int wxMessageBox(const wxString& message, const wxString& caption, long style,
+ wxWindow *parent, int WXUNUSED(x), int WXUNUSED(y) )
+{
+ wxMessageDialog dialog(parent, message, caption, style);
+
+ int ans = dialog.ShowModal();
+ switch ( ans )
+ {
+ case wxID_OK:
+ return wxOK;
+ case wxID_YES:
+ return wxYES;
+ case wxID_NO:
+ return wxNO;
+ case wxID_CANCEL:
+ return wxCANCEL;
+ }
+
+ wxFAIL_MSG( _T("unexpected return code from wxMessageDialog") );
+
+ return wxCANCEL;
+}
+
+#if wxUSE_TEXTDLG
+wxString wxGetTextFromUser(const wxString& message, const wxString& caption,
+ const wxString& defaultValue, wxWindow *parent,
+ int x, int y, bool WXUNUSED(centre) )
+{
+ wxString str;
+ wxTextEntryDialog dialog(parent, message, caption, defaultValue, wxOK|wxCANCEL, wxPoint(x, y));
+ if (dialog.ShowModal() == wxID_OK)
+ {
+ str = dialog.GetValue();
+ }
+
+ return str;
+}
+
+wxString wxGetPasswordFromUser(const wxString& message,
+ const wxString& caption,
+ const wxString& defaultValue,
+ wxWindow *parent)
+{
+ wxString str;
+ wxTextEntryDialog dialog(parent, message, caption, defaultValue,
+ wxOK | wxCANCEL | wxTE_PASSWORD);
+ if ( dialog.ShowModal() == wxID_OK )
+ {
+ str = dialog.GetValue();
+ }
+
+ return str;
+}
+
+#endif // wxUSE_TEXTDLG
+
+wxColour wxGetColourFromUser(wxWindow *parent, const wxColour& colInit)
+{
+ wxColourData data;
+ data.SetChooseFull(TRUE);
+ if ( colInit.Ok() )
+ {
+ data.SetColour((wxColour &)colInit); // const_cast
+ }
+
+ wxColour colRet;
+ wxColourDialog dialog(parent, &data);
+ if ( dialog.ShowModal() == wxID_OK )
+ {
+ colRet = dialog.GetColourData().GetColour();
+ }
+ //else: leave it invalid
+
+ return colRet;
+}
+
+// ----------------------------------------------------------------------------
+// missing C RTL functions (FIXME shouldn't be here at all)
+// ----------------------------------------------------------------------------
+
+#ifdef __MWERKS__
+char *strdup(const char *s)
+{
+ return strcpy( (char*) malloc( strlen( s ) + 1 ) , s ) ;
+}
+
+int isascii( int c )
+{
+ return ( c >= 0 && c < 128 ) ;
+}
+#endif // __MWERKS__
+
+// ----------------------------------------------------------------------------
+// wxSafeYield and supporting functions
+// ----------------------------------------------------------------------------
+
+void wxEnableTopLevelWindows(bool enable)
+{
+ wxWindowList::Node *node;
+ for ( node = wxTopLevelWindows.GetFirst(); node; node = node->GetNext() )
+ node->GetData()->Enable(enable);
+}
+
+wxWindowDisabler::wxWindowDisabler(wxWindow *winToSkip)
+{
+#ifdef __WXMSW__
+#ifdef __WIN32__
+ // and the top level window too
+ HWND hwndFG = ::GetForegroundWindow();
+ m_winTop = hwndFG ? wxFindWinFromHandle((WXHWND)hwndFG) : (wxWindow *)NULL;
+#else
+ HWND hwndFG = ::GetTopWindow(0);
+ m_winTop = hwndFG ? wxFindWinFromHandle((WXHWND)hwndFG) : (wxWindow *)NULL;
+#endif
+#endif // MSW
+
+ // remember the top level windows which were already disabled, so that we
+ // don't reenable them later
+ m_winDisabled = NULL;
+
+ wxWindowList::Node *node;
+ for ( node = wxTopLevelWindows.GetFirst(); node; node = node->GetNext() )
+ {
+ wxWindow *winTop = node->GetData();
+ if ( winTop == winToSkip )
+ continue;
+
+ if ( winTop->IsEnabled() )
+ {
+ winTop->Disable();
+ }
+ else
+ {
+ if ( !m_winDisabled )
+ {
+ m_winDisabled = new wxWindowList;
+ }
+
+ m_winDisabled->Append(winTop);
+ }
+ }