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

1.1       root        1: //
                      2: // nono
                      3: // Copyright (C) 2020 nono project
                      4: // Licensed under nono-license.txt
                      5: //
                      6: 
                      7: //
                      8: // プレーン VRAM モニターウィンドウ
                      9: //
                     10: 
                     11: #pragma once
                     12: 
                     13: #include "wxsubwindow.h"
                     14: #include "wxscrollbar.h"
1.1.1.2   root       15: #include "wxtextscreen.h"
1.1       root       16: #include <array>
                     17: 
1.1.1.2   root       18: class BT45xDevice;
                     19: class PlaneVRAMDevice;
                     20: class VideoCtlrDevice;
                     21: 
1.1       root       22: // プレーン VRAM ビットマップパネル
                     23: class WXPlaneVRAMBitmapPanel : public WXBitmapPanel
                     24: {
                     25:        using inherited = WXBitmapPanel;
                     26: 
                     27:  public:
1.1.1.5   root       28:        explicit WXPlaneVRAMBitmapPanel(wxWindow *parent);
                     29:        ~WXPlaneVRAMBitmapPanel() override;
1.1       root       30: 
                     31:        void EnablePlane(int plane, bool value);
                     32:        void EnablePalette(bool value);
                     33:        void SetScale(int scale_);
                     34: 
1.1.1.2   root       35:        const wxPoint& GetCursor() const { return cursor; }
                     36: 
1.1       root       37:        void OnScroll(wxScrollEvent& event);
                     38: 
                     39:        Rect view {};                           // 表示矩形
                     40:        int virtual_width {};           // 拡大後のビットマップ幅   [pixel]
                     41:        int virtual_height {};          // 拡大後のビットマップ高さ [pixel]
                     42: 
                     43:  private:
                     44:        void OnPaletteChanged(wxCommandEvent& event);
                     45:        void GenPalette();
1.1.1.2   root       46:        void Draw() override;
                     47:        void OnMouse(wxMouseEvent& event);
1.1       root       48: 
                     49:        std::array<Color, 256> pal {};
                     50:        uint32 planemask {};
                     51:        bool apply_palette {};
                     52:        int scale {};
                     53: 
                     54:        int plane_width {};                     // 拡大前のビットマップ幅   [pixel]
                     55:        int plane_height {};            // 拡大前のビットマップ高さ [pixel]
1.1.1.2   root       56: 
                     57:        // マウスカーソルがこのパネル上にあれば、(拡大前の)仮想画面での座標。
                     58:        // マウスカーソルがパネル外なら wxDefaultPosition = (-1, -1)。
                     59:        // ステータス表示用。
                     60:        wxPoint cursor {};
                     61: 
                     62:        BT45xDevice *bt45x {};
                     63:        PlaneVRAMDevice *planevram {};
                     64:        VideoCtlrDevice *videoctlr {};
                     65: 
                     66:        // イベントテーブル
                     67:        wxDECLARE_EVENT_TABLE();
1.1       root       68: };
                     69: 
                     70: // ビットマップパネルとスクロールバーを持つ
1.1.1.3   root       71: class WXPlaneVRAMPanel : public WXTextPanel
1.1       root       72: {
1.1.1.3   root       73:        using inherited = WXTextPanel;
1.1       root       74:  public:
1.1.1.5   root       75:        explicit WXPlaneVRAMPanel(wxWindow *parent);
                     76:        ~WXPlaneVRAMPanel() override;
1.1       root       77: 
1.1.1.6 ! root       78:        void Fit() override;
1.1       root       79:        bool Layout() override;
                     80: 
1.1.1.3   root       81:        // スクロールバーの FontChanged() を呼ぶため(だけ)に
                     82:        // これ自身も wxTextPanel を継承している。
1.1.1.4   root       83:        void FontChanged() override;
1.1.1.3   root       84: 
1.1       root       85:        void EnablePlane(int plane, bool value);
                     86:        void EnablePalette(bool value);
                     87:        void SetScale(int scale_);
                     88: 
1.1.1.2   root       89:        const wxPoint& GetCursor() const { return viewctl->GetCursor(); }
                     90: 
1.1       root       91:  private:
1.1.1.6 ! root       92:        void SetScroll();
1.1       root       93: 
                     94:        WXPlaneVRAMBitmapPanel *viewctl {};
                     95:        WXScrollBar *vscroll {};
                     96:        WXScrollBar *hscroll {};
                     97:        WXBitmapPanel *corner {};       // 右下の空き地
                     98: };
                     99: 
                    100: // プレーン VRAM ウィンドウ
                    101: class WXPlaneVRAMWindow : public WXSubWindow
                    102: {
                    103:        using inherited = WXSubWindow;
                    104: 
                    105:  public:
1.1.1.2   root      106:        static const int MAX_PLANES = 8;
1.1       root      107: 
                    108:  public:
                    109:        WXPlaneVRAMWindow(wxWindow *parent, const wxString& name);
1.1.1.5   root      110:        ~WXPlaneVRAMWindow() override;
1.1       root      111: 
1.1.1.6 ! root      112:        void Fit() override;
        !           113:        bool Layout() override;
1.1       root      114: 
1.1.1.2   root      115:        // ステータスパネル
                    116:        WXTextScreen *statuspanel {};
                    117: 
1.1       root      118:  private:
1.1.1.6 ! root      119:        void DoSizeHints();
        !           120: 
1.1       root      121:        void OnPlane(wxCommandEvent& event);
                    122:        void DoPlane(int plane, bool value);
                    123:        void OnApplyPalette(wxCommandEvent& event);
                    124:        void DoApplyPalette(bool value);
                    125:        void OnScale(wxCommandEvent& event);
                    126:        void DoScale(int value);
                    127: 
1.1.1.2   root      128:        void OnTimer(wxTimerEvent& event);
                    129: 
1.1       root      130:        // コントロールパネル
1.1.1.2   root      131:        wxPanel *ctrlpanel {};
                    132:        std::vector<wxCheckBox*> planesw {};
1.1       root      133:        wxCheckBox *applysw {};
                    134:        wxChoice *scalesw {};
                    135: 
1.1.1.6 ! root      136:        // ステータスパネル右の空き地用
        !           137:        WXBitmapPanel *spacer {};
        !           138: 
1.1       root      139:        // グラフィックパネル
                    140:        WXPlaneVRAMPanel *viewpanel {};
                    141: 
1.1.1.2   root      142:        // タイマー
                    143:        wxTimer timer {};
                    144: 
                    145:        PlaneVRAMDevice *planevram {};
                    146: 
1.1.1.6 ! root      147:        // 謎のリサイズ対策
        !           148:        int min_height {};
        !           149:        wxSize correct_clientsize {};
        !           150: 
1.1       root      151:        // イベントテーブル
                    152:        wxDECLARE_EVENT_TABLE();
                    153: 
                    154:        // 状態の二次記憶域。
                    155:        // サブウィンドウは今のところ開いてる時だけオブジェクトが存在している
                    156:        // タイプだが、このウィンドウを閉じてまた開くとさっきの状態が継続して
                    157:        // いてほしいので、ここでその状況を真似する。
                    158:        // ただしこっちはあくまで補助用で、コントロールの値のほうが一次情報。
1.1.1.2   root      159:        static std::array<bool, MAX_PLANES> sticky_plane;
1.1       root      160:        static bool sticky_apply;
                    161:        static int sticky_scale;
                    162: 
                    163:        // sticky_used が false ならまだ一度も使われていない (次のコンストラクタ
                    164:        // で初期化する)、true なら前回の値が入っている。
                    165:        static bool sticky_used;
                    166: };

unix.superglobalmegacorp.com

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