Switch use of threads on defined(CAVERNLOG_USE_THREADS)
[survex.git] / src / cavernlog.h
blob3d43a95e5a2b7e1c3fd6066cfc0212d0221a0381
1 /* cavernlog.h
2 * Run cavern inside an Aven window
4 * Copyright (C) 2005,2006,2010,2015,2016 Olly Betts
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 #ifndef SURVEX_CAVERNLOG_H
22 #define SURVEX_CAVERNLOG_H
24 #include "wx.h"
25 #include <wx/html/htmlwin.h>
27 #include <string>
29 #ifdef wxUSE_THREADS
30 # define CAVERNLOG_USE_THREADS
31 #endif
33 #ifdef CAVERNLOG_USE_THREADS
34 class CavernOutputEvent;
35 class CavernThread;
36 #endif
37 class MainFrm;
39 class CavernLogWindow : public wxHtmlWindow {
40 #ifdef CAVERNLOG_USE_THREADS
41 friend class CavernThread;
42 #endif
44 wxString filename;
46 MainFrm * mainfrm;
48 FILE * cavern_out;
49 wxString cur;
50 int link_count;
51 unsigned char buf[1024];
52 unsigned char * end;
54 bool init_done;
56 wxString survey;
58 std::string log_txt;
60 #ifdef CAVERNLOG_USE_THREADS
61 void stop_thread();
63 CavernThread * thread;
65 wxCriticalSection thread_lock;
66 #endif
68 public:
69 CavernLogWindow(MainFrm * mainfrm_, const wxString & survey_, wxWindow * parent);
71 ~CavernLogWindow();
73 /** Start to process survey data in file. */
74 void process(const wxString &file);
76 virtual void OnLinkClicked(const wxHtmlLinkInfo &link);
78 void OnReprocess(wxCommandEvent &);
80 void OnSave(wxCommandEvent &);
82 void OnOK(wxCommandEvent &);
84 #ifdef CAVERNLOG_USE_THREADS
85 void OnCavernOutput(wxCommandEvent & e);
87 void OnClose(wxCloseEvent &);
88 #else
89 void OnIdle(wxIdleEvent &);
90 #endif
92 DECLARE_EVENT_TABLE()
95 #endif