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
69public:
71
72 wxColor operator()(NavmsgStatus ns);
73
74private:
75 StdColorsByState defaults;
76};
77
79class TtyScroll : public wxScrolledWindow {
80public:
86 TtyScroll(wxWindow* parent, int n_lines);
87
88 virtual ~TtyScroll() = default;
89
95 virtual void Add(const Logline& line);
96
98 void Pause(bool pause) { m_is_paused = pause; }
99
101 void CopyToClipboard() const;
102
104 void SetFilter(const NavmsgFilter& filter) { m_filter = filter; }
105
107 const NavmsgFilter& GetFilter() { return m_filter; }
108
110 void SetQuickFilter(const std::string s) { m_quick_filter = s; }
111
113 void SetColors(std::unique_ptr<ColorByState> color_by_state);
114
115protected:
116 wxCoord m_line_height; // height of one line on screen
117 size_t m_n_lines; // number of lines we draw
118 wxCoord m_text_width; // Width of widest line displayed
119
120 std::deque<Logline> m_lines;
121 NavmsgFilter m_filter;
122 bool m_is_paused;
123 std::unique_ptr<ColorByState> m_color_by_state;
124 std::string m_quick_filter;
125
126 void DrawLine(wxDC& dc, const Logline& ll, int data_pos, int y);
127 virtual void OnDraw(wxDC& dc);
128 void OnSize(wxSizeEvent& event);
129};
130
131#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:79
void SetQuickFilter(const std::string s)
Apply a quick filter directly matched against lines.
Definition tty_scroll.h:110
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:98
const NavmsgFilter & GetFilter()
Return current display filter.
Definition tty_scroll.h:107
void SetFilter(const NavmsgFilter &filter)
Apply a display filter.
Definition tty_scroll.h:104
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