source: git/src/cavernlog.h

Last change on this file was 1b3bd5d, checked in by Olly Betts <olly@…>, 4 months ago

CavernLogWindow? now honours system dark mode

CavernLogWindow? was using the desktop default window background
colour with black text, which was hard to read with a dark desktop
theme.

Now with a dark desktop theme CavernLogWindow? uses white text on black;
with a light desktop theme the background colour is now set to white
(which matches how this worked when the log window was based on
wxHtmlWindow.

  • Property mode set to 100644
File size: 2.8 KB
RevLine 
[b0c416c]1/* cavernlog.h
[6bec10c]2 * Run cavern inside an Aven window
3 *
[ac20829b]4 * Copyright (C) 2005-2024 Olly Betts
[6bec10c]5 *
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.
10 *
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.
15 *
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
19 */
20
21#ifndef SURVEX_CAVERNLOG_H
22#define SURVEX_CAVERNLOG_H
23
24#include "wx.h"
[15ba0b5]25#include <wx/process.h>
[6bec10c]26
[0e81a88]27#include <string>
[ac20829b]28#include <vector>
[0e81a88]29
[fb5887c]30class MainFrm;
31
[ac20829b]32class CavernLogWindow : public wxScrolledWindow {
[fb5887c]33    wxString filename;
34
35    MainFrm * mainfrm;
36
[76bc864f]37    wxProcess * cavern_out = nullptr;
[ac20829b]38    size_t ptr = 0;
39    bool expecting_caret_line = false;
[76bc864f]40    int info_count = 0;
41    int link_count = 0;
[8991d7f]42
[76bc864f]43    bool init_done = false;
[d7b53e3]44
[1b3bd5d]45    bool dark_mode = false;
46
[d7b53e3]47    wxString survey;
48
[ac20829b]49    wxTimer timer;
50
[0e81a88]51    std::string log_txt;
52
[ac20829b]53    enum { LOG_NONE, LOG_ERROR, LOG_WARNING, LOG_INFO };
[fc626ae]54
[ac20829b]55    class LineInfo {
56      public:
57        unsigned start_offset = 0;
58        unsigned len = 0;
59        unsigned link_len = 0;
60        unsigned link_pixel_width = 0;
61        unsigned colour = LOG_NONE;
62        unsigned colour_start = 0;
63        unsigned colour_len = 0;
[fc626ae]64
[ac20829b]65        LineInfo() { }
66
67        explicit LineInfo(unsigned start_offset_)
68            : start_offset(start_offset_) { }
69    };
70
71    std::vector<LineInfo> line_info;
72
73    wxButton* save_button = nullptr;
74    wxButton* reprocess_button = nullptr;
75    wxButton* ok_button = nullptr;
[fc626ae]76
[6bec10c]77  public:
[d7b53e3]78    CavernLogWindow(MainFrm * mainfrm_, const wxString & survey_, wxWindow * parent);
[6bec10c]79
[8991d7f]80    ~CavernLogWindow();
81
82    /** Start to process survey data in file. */
83    void process(const wxString &file);
[6bec10c]84
[ac20829b]85    void OnMouseMove(wxMouseEvent& e);
86
87    void OnLinkClicked(wxMouseEvent& e);
[fb5887c]88
[81e1aa4]89    void OnReprocess(wxCommandEvent &);
[fb5887c]90
[0e81a88]91    void OnSave(wxCommandEvent &);
92
[fb5887c]93    void OnOK(wxCommandEvent &);
94
[ac20829b]95    void ProcessCavernOutput();
[fc626ae]96
[ac20829b]97    void OnCavernOutput(wxCommandEvent&) {
98        ProcessCavernOutput();
99        Update();
100        timer.StartOnce();
101    }
102
103    void CheckForOutput(bool immediate = false);
104
105    void OnIdle(wxIdleEvent&) { CheckForOutput(); }
106
107    void OnTimer(wxTimerEvent&) { CheckForOutput(); }
108
109    int OnPaintButton(wxButton* b, int x);
110
111    void OnPaint(wxPaintEvent&);
[8991d7f]112
[15ba0b5]113    void OnEndProcess(wxProcessEvent & e);
114
[fb5887c]115    DECLARE_EVENT_TABLE()
[6bec10c]116};
117
[549eb37]118wxString escape_for_shell(wxString s, bool protect_dash = false);
119wxString get_command_path(const wxChar * command_name);
120
[6bec10c]121#endif
Note: See TracBrowser for help on using the repository browser.