|
|
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 root 15: #include "wxtextscreen.h"
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: // ログウィンドウ
57: class WXLogMonitor : public WXVResizeSubWindow
1.1 root 58: {
1.1.1.3 root 59: using inherited = WXVResizeSubWindow;
1.1.1.6 root 60: friend class LogMonitor;
1.1 root 61:
62: public:
1.1.1.6 root 63: WXLogMonitor(wxWindow *);
1.1.1.3 root 64: virtual ~WXLogMonitor() override;
1.1 root 65:
66: private:
1.1.1.3 root 67: // サイズ変更イベント
68: void OnSize(wxSizeEvent&);
1.1 root 69:
1.1.1.3 root 70: // マウスホイールイベント
71: void OnMouseWheel(wxMouseEvent&);
72:
73: // スクロールイベント
74: void OnScroll(wxScrollEvent&);
75:
76: // スクロールバー再設定
77: void SetScroll();
78:
79: // スクロール処理
80: void DoScroll(int pos);
81:
82: // スクロールバー
1.1.1.7 ! root 83: WXScrollBar *vscroll {};
1.1 root 84:
1.1.1.4 root 85: int col {};
86: int row {};
1.1 root 87:
1.1.1.3 root 88: // 表示開始位置
89: // パネル最下行に表示する行を、最新行からのオフセットで表す。
90: // 0 ならパネル最下行は最新行、1 なら一つ手前の行…となる。
1.1.1.4 root 91: int vpos {};
1.1.1.3 root 92:
93: // 現在のログ行数
1.1.1.4 root 94: int lines {};
1.1.1.3 root 95:
1.1.1.6 root 96: // モニター
97: Monitor monitor {};
98: LogMonitor log {};
1.1 root 99:
100: // イベントテーブル
101: wxDECLARE_EVENT_TABLE();
102: };
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.