[27b8b59] | 1 | /* |
---|
[5809313] | 2 | // aven.h |
---|
[9a7375f] | 3 | // |
---|
[5809313] | 4 | // Main class for Aven. |
---|
[9a7375f] | 5 | // |
---|
[5809313] | 6 | // Copyright (C) 2001, Mark R. Shinwell. |
---|
[5892e08] | 7 | // Copyright (C) 2002,2003,2004,2005,2006 Olly Betts |
---|
[9a7375f] | 8 | // |
---|
| 9 | // This program is free software; you can redistribute it and/or modify |
---|
| 10 | // it under the terms of the GNU General Public License as published by |
---|
| 11 | // the Free Software Foundation; either version 2 of the License, or |
---|
| 12 | // (at your option) any later version. |
---|
| 13 | // |
---|
| 14 | // This program is distributed in the hope that it will be useful, |
---|
| 15 | // but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 16 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 17 | // GNU General Public License for more details. |
---|
| 18 | // |
---|
| 19 | // You should have received a copy of the GNU General Public License |
---|
| 20 | // along with this program; if not, write to the Free Software |
---|
[ecbc6c18] | 21 | // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
---|
[27b8b59] | 22 | */ |
---|
[9a7375f] | 23 | |
---|
[78f0fb7a] | 24 | /* Note: this header needs to be safe to include from C code */ |
---|
| 25 | |
---|
[9a7375f] | 26 | #ifndef aven_h |
---|
| 27 | #define aven_h |
---|
| 28 | |
---|
[a4140e9] | 29 | #include <stdarg.h> |
---|
| 30 | |
---|
[5627cbb] | 31 | #define APP_NAME wxT("Aven") |
---|
| 32 | #define APP_IMAGE wxT("aven.png") |
---|
| 33 | #define APP_ABOUT_IMAGE wxT("aven-about.png") |
---|
[7213bd1] | 34 | |
---|
[a4140e9] | 35 | extern |
---|
| 36 | #ifdef __cplusplus |
---|
| 37 | "C" |
---|
| 38 | #endif |
---|
| 39 | void aven_v_report(int severity, const char *fnm, int line, int en, |
---|
| 40 | va_list ap); |
---|
| 41 | |
---|
| 42 | #ifdef __cplusplus |
---|
| 43 | |
---|
[5809313] | 44 | #include "wx.h" |
---|
[9a7375f] | 45 | |
---|
[5627cbb] | 46 | #include <string> |
---|
| 47 | |
---|
| 48 | inline std::string |
---|
| 49 | string_formatv(const char * fmt, va_list args) |
---|
| 50 | { |
---|
| 51 | static size_t len = 4096; |
---|
| 52 | static char * buf = NULL; |
---|
| 53 | while (true) { |
---|
| 54 | if (!buf) buf = new char[len]; |
---|
| 55 | int r = vsnprintf(buf, len, fmt, args); |
---|
| 56 | if (r < int(len) && r != -1) { |
---|
| 57 | return std::string(buf, r); |
---|
| 58 | } |
---|
| 59 | delete [] buf; |
---|
| 60 | buf = NULL; |
---|
| 61 | len += len; |
---|
| 62 | } |
---|
| 63 | } |
---|
| 64 | |
---|
| 65 | inline std::string |
---|
| 66 | string_format(const char * fmt, ...) |
---|
| 67 | { |
---|
| 68 | va_list args; |
---|
| 69 | va_start(args, fmt); |
---|
| 70 | std::string s = string_formatv(fmt, args); |
---|
| 71 | va_end(args); |
---|
| 72 | return s; |
---|
| 73 | } |
---|
| 74 | |
---|
| 75 | // wmsg is the unicode version of msg. |
---|
| 76 | wxString wmsg(int msg_no); |
---|
| 77 | |
---|
[8a05a7a] | 78 | const wxString & wmsg_cfgpth(); |
---|
| 79 | |
---|
[5809313] | 80 | class MainFrm; |
---|
[9a7375f] | 81 | |
---|
[5892e08] | 82 | class Aven : public wxGLApp { |
---|
[2c1d2f4] | 83 | MainFrm * m_Frame; |
---|
| 84 | // This must be a pointer, otherwise it gets initialised too early and |
---|
| 85 | // we get a segfault on MS Windows when it tries to look up paper |
---|
| 86 | // sizes in wxThePrintPaperDatabase which is still NULL at the point |
---|
| 87 | // when the Aven class is constructed. |
---|
| 88 | wxPageSetupDialogData * m_pageSetupData; |
---|
[9a7375f] | 89 | |
---|
| 90 | public: |
---|
[5809313] | 91 | Aven(); |
---|
[2c1d2f4] | 92 | ~Aven(); |
---|
[cb3d1e2] | 93 | |
---|
[5627cbb] | 94 | #ifdef __WXMSW__ |
---|
[879e9c3] | 95 | virtual bool Initialize(int& argc, wxChar **argv); |
---|
[5627cbb] | 96 | #endif |
---|
[5809313] | 97 | virtual bool OnInit(); |
---|
[9a7375f] | 98 | |
---|
[e0ffc2c] | 99 | wxPageSetupDialogData * GetPageSetupDialogData(); |
---|
| 100 | void SetPageSetupDialogData(const wxPageSetupDialogData & psdd); |
---|
| 101 | |
---|
[5809313] | 102 | void ReportError(const wxString&); |
---|
[9a7375f] | 103 | }; |
---|
| 104 | |
---|
[5809313] | 105 | DECLARE_APP(Aven) |
---|
| 106 | |
---|
[9a7375f] | 107 | #endif |
---|
[a4140e9] | 108 | |
---|
| 109 | #endif |
---|