1 // This file is part of Golly. 2 // See docs/License.html for the copyright notice. 3 4 #ifndef _WXUTILS_H_ 5 #define _WXUTILS_H_ 6 7 // Various utility routines: 8 9 void Note(const wxString& msg, bool showCancel = true); 10 // Display given message in a modal dialog. 11 // If called from a script then an optional Cancel button 12 // can be used to abort the script. 13 14 void Warning(const wxString& msg, bool showCancel = true); 15 // Beep and display message in a modal dialog. 16 // If called from a script then an optional Cancel button 17 // can be used to abort the script. 18 19 void Fatal(const wxString& msg); 20 // Beep, display message in a modal dialog, then exit app. 21 22 void Beep(); 23 // Play beep sound, depending on preference setting. 24 25 bool GetString(const wxString& title, const wxString& prompt, 26 const wxString& instring, wxString& outstring); 27 // Display a dialog box to get a string from the user. 28 // Returns false if user hits Cancel button. 29 30 bool GetInteger(const wxString& title, const wxString& prompt, 31 int inval, int minval, int maxval, int* outval); 32 // Display a dialog box to get an integer value from the user. 33 // Returns false if user hits Cancel button. 34 35 int SaveChanges(const wxString& query, const wxString& msg); 36 // Ask user if changes should be saved and return following result: 37 // 2 if user selects Yes/Save button, 38 // 1 if user selects No/Don't Save button, 39 // 0 if user selects Cancel button. 40 41 void BeginProgress(const wxString& dlgtitle); 42 // Call at the start of a lengthy task. The cursor changes to indicate 43 // the app is busy but the progress dialog won't appear immediately. 44 45 bool AbortProgress(double fraction_done, const wxString& newmsg); 46 // Call frequently while the task is being carried out. The progress 47 // dialog only appears if the task is likely to take more than a few secs. 48 // Pass in a fraction from 0.0 to 1.0 indicating how much has been done, 49 // or any negative value to show an indeterminate progress gauge. 50 // The given string can be used to display extra information. 51 // The call returns true if the user cancels the progress dialog. 52 53 void EndProgress(); 54 // Call when the task has finished (even if it was aborted). 55 56 void FillRect(wxDC& dc, wxRect& rect, wxBrush& brush); 57 // Fill given rectangle using given brush. 58 59 void CreatePaleBitmap(const wxBitmap& inmap, wxBitmap& outmap); 60 // Create a pale gray version of given bitmap. 61 62 bool IsScriptFile(const wxString& filename); 63 // Return true if the given file is a Lua, Perl or Python script. 64 // It simply checks if the file's extension is .lua or .pl or .py 65 // (ignoring case). 66 67 bool IsHTMLFile(const wxString& filename); 68 // Return true if the given file's extension is .htm or .html 69 // (ignoring case). 70 71 bool IsTextFile(const wxString& filename); 72 // Return true if the given file's extension is .txt or .doc, 73 // or if it's not a HTML file and its name contains "readme" 74 // (ignoring case). 75 76 bool IsZipFile(const wxString& filename); 77 // Return true if the given file's extension is .zip or .gar 78 // (ignoring case). 79 80 bool IsRuleFile(const wxString& filename); 81 // Return true if the given file is a rule-related file with 82 // an extension of .rule or .table or .tree or .colors or .icons 83 // (ignoring case). 84 85 // Following macro is used to create a wxBitmap from included XPM data: 86 87 #if defined(__WXGTK__) || defined(__WXMAC__) 88 #define XPM_BITMAP(name) wxBitmap(name##_xpm) 89 #else // other platforms (eg. wxMSW) 90 #define XPM_BITMAP(name) wxBitmap(name##_xpm, wxBITMAP_TYPE_XPM) 91 #endif 92 93 #endif // _WXUTILS_H_ 94