Annotation of nono/wx/wxlogmonitor.h, revision 1.1.1.6

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: 
                      7: #pragma once
                      8: 
                      9: #include "wxsubwindow.h"
                     10: #include "wxtextscreen.h"
                     11: 
1.1.1.6 ! root       12: class WXLogMonitor;
        !            13: 
        !            14: // モニター部分
        !            15: class LogMonitor : public Object
        !            16: {
        !            17:        using inherited = Object;
        !            18:  public:
        !            19:        LogMonitor();
        !            20:        ~LogMonitor() override;
        !            21: 
        !            22:        void Init(WXLogMonitor *parent_);
        !            23: 
        !            24:        DECLARE_MONITOR_CALLBACK(MonitorUpdate);
        !            25: 
        !            26:        // バックログに追加
        !            27:        void Append(const char *);
        !            28: 
        !            29:        // 1行追加された時の下請け処理
        !            30:        void IncLines();
        !            31: 
        !            32:  private:
        !            33:        WXLogMonitor *parent {};
        !            34: 
        !            35:        // ログ全体の行数(上限)
        !            36:        const int backlog = 10000;
        !            37: 
        !            38:        // ログバッファ
        !            39:        TextScreen logbuf {};
        !            40: 
        !            41:        // 今から書き込む行の logbuf でのY座標
        !            42:        int cursor {};
        !            43: 
        !            44:        // UTF-8 -> CP932 変換
        !            45:        wxCSConv conv { "CP932" };
        !            46: };
        !            47: 
        !            48: //
        !            49: // ログウィンドウ
        !            50: //
        !            51: class WXLogMonitor : public WXVResizeSubWindow
1.1       root       52: {
1.1.1.3   root       53:        using inherited = WXVResizeSubWindow;
1.1.1.6 ! root       54:        friend class LogMonitor;
1.1       root       55: 
                     56:  public:
1.1.1.6 ! root       57:        WXLogMonitor(wxWindow *);
1.1.1.3   root       58:        virtual ~WXLogMonitor() override;
1.1       root       59: 
                     60:  private:
1.1.1.3   root       61:        // サイズ変更イベント
                     62:        void OnSize(wxSizeEvent&);
1.1       root       63: 
1.1.1.3   root       64:        // マウスホイールイベント
                     65:        void OnMouseWheel(wxMouseEvent&);
                     66: 
                     67:        // スクロールイベント
                     68:        void OnScroll(wxScrollEvent&);
                     69: 
                     70:        // スクロールバー再設定
                     71:        void SetScroll();
                     72: 
                     73:        // スクロール処理
                     74:        void DoScroll(int pos);
                     75: 
                     76:        // ウィンドウサイズ再計算
                     77:        void DoSize() override;
                     78: 
                     79:        // スクロールバー
1.1.1.4   root       80:        wxScrollBar *vscroll {};
1.1       root       81: 
1.1.1.4   root       82:        int col {};
                     83:        int row {};
1.1       root       84: 
1.1.1.3   root       85:        // 表示開始位置
                     86:        // パネル最下行に表示する行を、最新行からのオフセットで表す。
                     87:        // 0 ならパネル最下行は最新行、1 なら一つ手前の行…となる。
1.1.1.4   root       88:        int vpos {};
1.1.1.3   root       89: 
                     90:        // 現在のログ行数
1.1.1.4   root       91:        int lines {};
1.1.1.3   root       92: 
1.1.1.6 ! root       93:        // モニター
        !            94:        Monitor monitor {};
        !            95:        LogMonitor log {};
1.1       root       96: 
                     97:        // イベントテーブル
                     98:        wxDECLARE_EVENT_TABLE();
                     99: };

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.