OpenCPN Partial API docs
Loading...
Searching...
No Matches
tty_scroll.h
Go to the documentation of this file.
1/***************************************************************************
2 * Copyright (C) 2013 by David S. Register *
3 * *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
8 * *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
13 * *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, see <https://www.gnu.org/licenses/>. *
16 **************************************************************************/
17
24#ifndef TTYSCROLL_H_
25#define TTYSCROLL_H_
26
27#include <deque>
28#include <memory>
29
30#include <wx/scrolwin.h>
31#include <wx/textctrl.h>
32
33#include "model/gui_vars.h"
34#include "model/nmea_log.h"
35#include "model/navmsg_filter.h"
36
44public:
45 virtual wxColor operator()(NavmsgStatus) = 0;
46 virtual ~ColorByState() = default;
47};
48
51public:
52 NoColorsByState(wxColor color) : m_color(color) {}
53
54 wxColor operator()(NavmsgStatus ns) { return m_color; }
55
56private:
57 wxColor m_color;
58};
59
62public:
64
65 wxColor operator()(NavmsgStatus ns);
66};
67
69class TtyScroll : public wxScrolledWindow {
70public:
76 TtyScroll(wxWindow* parent, int n_lines);
77
78 virtual ~TtyScroll() = default;
79
85 virtual void Add(const Logline& line);
86
88 void Pause(bool pause) { m_is_paused = pause; }
89
91 void CopyToClipboard() const;
92
94 void SetFilter(const NavmsgFilter& filter) { m_filter = filter; }
95
97 const NavmsgFilter& GetFilter() { return m_filter; }
98
100 void SetQuickFilter(const std::string s) { m_quick_filter = s; }
101
103 void SetColors(std::unique_ptr<ColorByState> color_by_state);
104
105protected:
106 wxCoord m_line_height; // height of one line on screen
107 size_t m_n_lines; // number of lines we draw
108 wxCoord m_text_width; // Width of widest line displayed
109
110 std::deque<Logline> m_lines;
111 NavmsgFilter m_filter;
112 bool m_is_paused;
113 std::unique_ptr<ColorByState> m_color_by_state;
114 std::string m_quick_filter;
115
116 void DrawLine(wxDC& dc, const Logline& ll, int data_pos, int y);
117 virtual void OnDraw(wxDC& dc);
118 void OnSize(wxSizeEvent& event);
119};
120
121#endif // TTYSCROLL_H_
Functor returning log foreground color for given state.
Definition tty_scroll.h:43
Representation of message status as determined by the multiplexer.
Functor returning default color for all states.
Definition tty_scroll.h:50
The standard colors handler functor.
Definition tty_scroll.h:61
Scrolled TTY-like window for logging, etc.
Definition tty_scroll.h:69
void SetQuickFilter(const std::string s)
Apply a quick filter directly matched against lines.
Definition tty_scroll.h:100
void SetColors(std::unique_ptr< ColorByState > color_by_state)
Set color scheme.
void Pause(bool pause)
Set the window to ignore Add() or not depending on pause.
Definition tty_scroll.h:88
const NavmsgFilter & GetFilter()
Return current display filter.
Definition tty_scroll.h:97
void SetFilter(const NavmsgFilter &filter)
Apply a display filter.
Definition tty_scroll.h:94
virtual void Add(const Logline &line)
Add a line to bottom of window, typically discarding top-most line.
void DrawLine(wxDC &dc, const Logline &ll, int data_pos, int y)
Draw a single line in the log window.
void CopyToClipboard() const
Copy message contents to clipboard.
Miscellaneous globals primarely used by gui layer, not persisted in configuration file.
Data monitor filter definitions.
Basic DataMonitor logging interface: LogLine (reflects a line in the log) and NmeaLog,...
Item in the log window.
Definition nmea_log.h:32