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