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