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
23
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
41
44public:
45 virtual wxColor operator()(NavmsgStatus) = 0;
46 virtual ~ColorByState() = default;
47};
48
50class NoColorsByState : public ColorByState {
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
61class StdColorsByState : public ColorByState {
62public:
63 StdColorsByState() {};
64
65 wxColor operator()(NavmsgStatus ns);
66};
67
68class UserColorsByState : public ColorByState {
69public:
70 UserColorsByState() {};
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 virtual void Clear();
99
101 void Pause(bool pause) { m_is_paused = pause; }
102
104 void CopyToClipboard() const;
105
107 void SetFilter(const NavmsgFilter& filter) { m_filter = filter; }
108
110 const NavmsgFilter& GetFilter() { return m_filter; }
111
113 void SetQuickFilter(const std::string s) { m_quick_filter = s; }
114
116 void SetColors(std::unique_ptr<ColorByState> color_by_state);
117
118protected:
119 wxCoord m_line_height; // height of one line on screen
120 size_t m_n_lines; // number of lines we draw
121 wxCoord m_text_width; // Width of widest line displayed
122
123 std::deque<Logline> m_lines;
124 NavmsgFilter m_filter;
125 bool m_is_paused;
126 std::unique_ptr<ColorByState> m_color_by_state;
127 std::string m_quick_filter;
128
129 void DrawLine(wxDC& dc, const Logline& ll, int data_pos, int y);
130 virtual void OnDraw(wxDC& dc);
131 void OnSize(wxSizeEvent& event);
132};
133
134#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.
The standard colors handler functor.
Definition tty_scroll.h:61
void SetQuickFilter(const std::string s)
Apply a quick filter directly matched against lines.
Definition tty_scroll.h:113
void SetColors(std::unique_ptr< ColorByState > color_by_state)
Set color scheme.
virtual void Clear()
Clear the log window.
void Pause(bool pause)
Set the window to ignore Add() or not depending on pause.
Definition tty_scroll.h:101
const NavmsgFilter & GetFilter()
Return current display filter.
Definition tty_scroll.h:110
void SetFilter(const NavmsgFilter &filter)
Apply a display filter.
Definition tty_scroll.h:107
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.
TtyScroll(wxWindow *parent, int n_lines)
Create a TtyScroll instance.
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