Annotation of nono/wx/wxtextpanel.h, revision 1.1.1.5

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: 
1.1.1.2   root        9: #include "wxheader.h"
1.1       root       10: #include <mutex>
                     11: 
                     12: //
1.1.1.2   root       13: // テキストフォントを管理するクラス
1.1       root       14: //
                     15: // wxPanel
                     16: //  ↓
                     17: // WXTextPanel  テキストフォントを管理するクラス
                     18: //  ↓
1.1.1.3   root       19: // WXTextScreen テキストスクリーンを表示するパネル
1.1       root       20: //
                     21: 
                     22: class WXTextPanel : public wxPanel
                     23: {
1.1.1.2   root       24:        using inherited = wxPanel;
1.1       root       25:  public:
                     26:        WXTextPanel(wxWindow *parent);
1.1.1.5 ! root       27:        WXTextPanel(wxWindow *parent, long style);
1.1.1.3   root       28:        virtual ~WXTextPanel() override;
1.1       root       29: 
1.1.1.3   root       30:        // フォント種別(指定値)
1.1       root       31:        // この値を元に各コントロールに指示を出す
1.1.1.3   root       32:        static FontId global_fontid;
                     33: 
                     34:        // フォントサイズ変更 (派生クラスで用意する)
                     35:        virtual void SetFontSize(FontId) = 0;
                     36: 
                     37:        // (外部から)フォントサイズを取得。
                     38:        // このクラス内および継承クラス内からなら簡便のため、これを呼ばずに
                     39:        // 直接 font_width, font_height を使ってよい。
                     40:        const wxSize& GetFontSize() const { return fontsize; }
1.1       root       41: 
                     42:  protected:
                     43:        // このコントロールの現在のフォントサイズ
1.1.1.3   root       44:        // (一瞬の過渡期以外は基本的に global_fontid と同じ値のはず)
                     45:        FontId fontid = FontId::None;
1.1       root       46: 
                     47:        // フォントの幅と高さ(ピクセル)
1.1.1.3   root       48:        // wxSize.{x, y} はマニュアルには載ってなくて、ヘッダにも
                     49:        // 直接使うな (互換性のために public にしてある) と書いてあるけど、
                     50:        // 参照出来て便利なので使っちゃえ。
                     51:        wxSize fontsize {};
                     52:        int& font_width = fontsize.x;
                     53:        int& font_height = fontsize.y;
1.1       root       54: 
                     55:        // フォント関連の内部情報を更新する
1.1.1.3   root       56:        void UpdateFont(FontId fontid);
1.1       root       57: 
                     58:        // グリフを切り替える。
                     59:        // 0x5c は false: 円記号                    true: バックスラッシュ
                     60:        // 0x7c は false: パイプ記号              true: パイプ記号(破線)
                     61:        // 0x7e は false: オーバーライン        true: チルダ
                     62:        void SetGlyph5C(bool value) { glyph_5c = value; }
                     63:        void SetGlyph7C(bool value) { glyph_7c = value; }
                     64:        void SetGlyph7E(bool value) { glyph_7e = value; }
                     65: 
                     66:        // テキスト色を指定
1.1.1.5 ! root       67:        void ResetTextColor();
        !            68:        void SetTextColor(const wxColour& fg, const wxColour& bg);
1.1       root       69:        void SetTextForeColor(const wxColour& fg) { text_fgcolor = fg; }
                     70:        void SetTextBackColor(const wxColour& bg) { text_bgcolor = bg; }
1.1.1.5 ! root       71: 
1.1       root       72:        // テキスト色を取得
                     73:        const wxColour& GetTextForeColor() const { return text_fgcolor; }
                     74:        const wxColour& GetTextBackColor() const { return text_bgcolor; }
                     75: 
                     76:        // Shift_JIS (正確には CP932) 文字列を描画する。
                     77:        void DrawStringSJIS(wxDC&, int px, int py, const char *sjis,
                     78:                uint attr = TA::Normal);
                     79: 
1.1.1.5 ! root       80:        // 半角1文字を描画
1.1       root       81:        void DrawChar1(wxDC&, int px, int py, uint code, uint attr);
1.1.1.5 ! root       82:        // 全角1文字を描画
1.1       root       83:        void DrawChar2(wxDC&, int px, int py, uint code, uint attr);
1.1.1.5 ! root       84:        // 指定の文字ビットマップを描画
        !            85:        void DrawBitmap(wxDC&, int px, int py, const wxBitmap& bitmap);
1.1       root       86: 
                     87:  private:
                     88:        // 漢字ビットマップを生成
                     89:        wxBitmap *KanjiBitmap(uint16, uint attr);
                     90: 
1.1.1.3   root       91:        static void AllocFont(FontId fontid);
                     92:        static void FreeFont(FontId fontid);
1.1       root       93: 
                     94:        // 現在のフォントでのフォントデータ
1.1.1.4   root       95:        wxBitmap **ascii_glyph {};
                     96:        wxBitmap **bold_glyph {};
1.1       root       97: 
                     98:        // 現在のグリフ
1.1.1.4   root       99:        bool glyph_5c {};
                    100:        bool glyph_7c {};
                    101:        bool glyph_7e {};
1.1       root      102: 
                    103:        static std::mutex global_font_mutex;
                    104:        // 以下の3つを書き換える時は global_font_mutex を取ること
1.1.1.3   root      105:        static u_int font_refcnt[FontId::Max];
1.1.1.5 ! root      106:        // 半角文字キャッシュ
        !           107:        static wxBitmap *ascii_glyph_table[FontId::Max][256];
        !           108:        static wxBitmap *bold_glyph_table[FontId::Max][256];
1.1       root      109: 
                    110:        // 色
1.1.1.4   root      111:        wxColour text_fgcolor {};               // 前景色
                    112:        wxColour text_bgcolor {};               // 背景色
1.1       root      113: };

unix.superglobalmegacorp.com

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