|
|
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.11! root 66: void FontChanged() override;
1.1.1.8 root 67: bool Layout() override;
68:
1.1 root 69: private:
1.1.1.11! root 70: void Fit() override;
! 71:
! 72: // 最大/最小サイズ設定
! 73: wxSize DoSizeHints();
1.1 root 74:
1.1.1.3 root 75: // マウスホイールイベント
76: void OnMouseWheel(wxMouseEvent&);
77:
78: // スクロールイベント
79: void OnScroll(wxScrollEvent&);
80:
81: // スクロールバー再設定
82: void SetScroll();
83:
84: // スクロール処理
85: void DoScroll(int pos);
86:
1.1.1.8 root 87: WXMonitorPanel *screen {};
88:
1.1.1.3 root 89: // スクロールバー
1.1.1.7 root 90: WXScrollBar *vscroll {};
1.1 root 91:
1.1.1.4 root 92: int col {};
93: int row {};
1.1 root 94:
1.1.1.3 root 95: // 表示開始位置
96: // パネル最下行に表示する行を、最新行からのオフセットで表す。
97: // 0 ならパネル最下行は最新行、1 なら一つ手前の行…となる。
1.1.1.4 root 98: int vpos {};
1.1.1.3 root 99:
100: // 現在のログ行数
1.1.1.4 root 101: int lines {};
1.1.1.3 root 102:
1.1.1.6 root 103: // モニター
1.1.1.10 root 104: std::unique_ptr<Monitor> monitor /*{}*/;
1.1.1.6 root 105: LogMonitor log {};
1.1 root 106:
1.1.1.11! root 107: // 前回のウィンドウマージン (クライアント領域の外側)
! 108: wxSize oldmargin {};
! 109:
! 110: // 謎のリサイズ対策
! 111: bool layout_pass2 {};
1.1 root 112: };
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.