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, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
18 ***************************************************************************
19 */
20
21#ifndef __TTYSCROLL_H__
22#define __TTYSCROLL_H__
23
24#include <deque>
25#include <memory>
26
27#include <wx/scrolwin.h>
28#include <wx/textctrl.h>
29
30#include "model/nmea_log.h"
31#include "model/navmsg_filter.h"
32
38extern const wxString kUtfCheckMark;
39extern const wxString kUtfCircledDivisionSlash;
40extern const wxString kUtfFallingDiagonal;
41extern const wxString kUtfIdenticalTo;
42extern const wxString kUtfLeftArrow;
43extern const wxString kUtfLeftRightArrow;
44extern const wxString kUtfLeftwardsArrowToBar;
45extern const wxString kUtfMultiplicationX;
46extern const wxString kUtfRightArrow;
47
50public:
51 virtual wxColor operator()(NavmsgStatus) = 0;
52 virtual ~ColorByState() = default;
53};
54
57public:
58 NoColorsByState(wxColor color) : m_color(color) {}
59
60 wxColor operator()(NavmsgStatus ns) { return m_color; }
61
62private:
63 wxColor m_color;
64};
65
68public:
70
71 wxColor operator()(NavmsgStatus ns);
72};
73
75class TtyScroll : public wxScrolledWindow {
76public:
82 TtyScroll(wxWindow* parent, int n_lines);
83
84 virtual ~TtyScroll() = default;
85
91 virtual void Add(const Logline& line);
92
94 void Pause(bool pause) { m_is_paused = pause; }
95
97 void CopyToClipboard() const;
98
100 void SetFilter(const NavmsgFilter& filter) { m_filter = filter; }
101
103 const NavmsgFilter& GetFilter() { return m_filter; }
104
106 void SetQuickFilter(const std::string s) { m_quick_filter = s; }
107
109 void SetColors(std::unique_ptr<ColorByState> color_by_state);
110
111protected:
112 wxCoord m_line_height; // height of one line on screen
113 size_t m_n_lines; // number of lines we draw
114 wxCoord m_text_width; // Width of widest line displayed
115
116 std::deque<Logline> m_lines;
117 NavmsgFilter m_filter;
118 bool m_is_paused;
119 std::unique_ptr<ColorByState> m_color_by_state;
120 std::string m_quick_filter;
121
122 void DrawLine(wxDC& dc, const Logline& ll, int data_pos, int y);
123 virtual void OnDraw(wxDC& dc);
124 void OnSize(wxSizeEvent& event);
125};
126
127#endif
Functor returning log foreground color for given state.
Definition tty_scroll.h:49
Representation of message status as determined by the multiplexer.
Functor returning default color for all states.
Definition tty_scroll.h:56
The standard colors handler functor.
Definition tty_scroll.h:67
Scrolled TTY-like window for logging, etc.
Definition tty_scroll.h:75
void SetQuickFilter(const std::string s)
Apply a quick filter directly matched against lines.
Definition tty_scroll.h:106
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:94
const NavmsgFilter & GetFilter()
Return current display filter.
Definition tty_scroll.h:103
void SetFilter(const NavmsgFilter &filter)
Apply a display filter.
Definition tty_scroll.h:100
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.
Data monitor filter definitions.
Item in the log window.
Definition nmea_log.h:10