|
|
1.1 root 1: //
2: // nono
1.1.1.2 root 3: // Copyright (C) 2020 nono project
4: // Licensed under nono-license.txt
1.1 root 5: //
6:
1.1.1.7 root 7: //
8: // ログモニター
9: //
10:
1.1 root 11: #pragma once
12:
13: #include "wxsubwindow.h"
1.1.1.7 root 14: #include "wxscrollbar.h"
1.1.1.8 root 15: #include "wxmonitor.h"
1.1 root 16:
1.1.1.7 root 17: class Logger;
1.1.1.6 root 18: class WXLogMonitor;
19:
20: // モニター部分
21: class LogMonitor : public Object
22: {
23: using inherited = Object;
24: public:
25: LogMonitor();
26: ~LogMonitor() override;
27:
28: void Init(WXLogMonitor *parent_);
29:
30: DECLARE_MONITOR_CALLBACK(MonitorUpdate);
31:
32: // バックログに追加
33: void Append(const char *);
34:
35: // 1行追加された時の下請け処理
36: void IncLines();
37:
38: private:
39: WXLogMonitor *parent {};
40:
1.1.1.7 root 41: Logger *logger {};
42:
1.1.1.6 root 43: // ログ全体の行数(上限)
44: const int backlog = 10000;
45:
46: // ログバッファ
47: TextScreen logbuf {};
48:
49: // 今から書き込む行の logbuf でのY座標
50: int cursor {};
51:
52: // UTF-8 -> CP932 変換
53: wxCSConv conv { "CP932" };
54: };
55:
56: // ログウィンドウ
1.1.1.8 root 57: class WXLogMonitor : public WXSubWindow
1.1 root 58: {
1.1.1.8 root 59: using inherited = WXSubWindow;
1.1.1.6 root 60: friend class LogMonitor;
1.1 root 61:
62: public:
1.1.1.9 root 63: explicit WXLogMonitor(wxWindow *);
64: ~WXLogMonitor() override;
1.1 root 65:
1.1.1.8 root 66: bool Layout() override;
67:
1.1 root 68: private:
1.1.1.3 root 69: // サイズ変更イベント
70: void OnSize(wxSizeEvent&);
1.1 root 71:
1.1.1.3 root 72: // マウスホイールイベント
73: void OnMouseWheel(wxMouseEvent&);
74:
75: // スクロールイベント
76: void OnScroll(wxScrollEvent&);
77:
78: // スクロールバー再設定
79: void SetScroll();
80:
81: // スクロール処理
82: void DoScroll(int pos);
83:
1.1.1.8 root 84: WXMonitorPanel *screen {};
85:
1.1.1.3 root 86: // スクロールバー
1.1.1.7 root 87: WXScrollBar *vscroll {};
1.1 root 88:
1.1.1.4 root 89: int col {};
90: int row {};
1.1 root 91:
1.1.1.3 root 92: // 表示開始位置
93: // パネル最下行に表示する行を、最新行からのオフセットで表す。
94: // 0 ならパネル最下行は最新行、1 なら一つ手前の行…となる。
1.1.1.4 root 95: int vpos {};
1.1.1.3 root 96:
97: // 現在のログ行数
1.1.1.4 root 98: int lines {};
1.1.1.3 root 99:
1.1.1.6 root 100: // モニター
1.1.1.10! root 101: std::unique_ptr<Monitor> monitor /*{}*/;
1.1.1.6 root 102: LogMonitor log {};
1.1 root 103:
104: // イベントテーブル
105: wxDECLARE_EVENT_TABLE();
106: };
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.