|
|
1.1 root 1: //
2: // nono
3: // Copyright (C) 2021 nono project
4: // Licensed under nono-license.txt
5: //
6:
7: // クライアントサイズを正しく扱える wxFrame ラッパークラス。
8: // wxFrame の代わりに必ずこれを使うこと。
9: //
10: // Ubuntu など、ウィンドウマネージャによっては(?)、
11: // まだ実画面を持っていないコンストラクタ時点でのクライアントサイズの指定は
12: // ウィンドウサイズを設定してしまうようだ。そのため、実際にウィンドウが表示
13: // されると、ウィンドウマネージャのフレーム分だけ小さいクライアント領域を
14: // もったウィンドウが出来てしまう。
15: // とりあえず、実際にウィンドウを描画した後に Fit() を行えば解決するのと、
16: // これに副作用もなさそうなので、OnPaint イベントを一回呼び出して Fit() だけ
17: // 行い、イベントも取り外す。
18:
19: #include "wxfitframe.h"
20:
21: // コンストラクタ
22: WXFitFrame::WXFitFrame(wxWindow *parent, wxWindowID id, const wxString& title,
23: long style)
24: : inherited(parent, id, title, wxDefaultPosition, wxDefaultSize, style)
25: {
26: Connect(wxEVT_PAINT, wxPaintEventHandler(WXFitFrame::OnPaint));
27: }
28:
29: // 描画イベント
30: // (確実にウィンドウが表示された後で呼ばれるイベントという意味で)
31: void
32: WXFitFrame::OnPaint(wxPaintEvent& event)
33: {
34: assert(IsShownOnScreen() == true);
35:
36: // ここで Fit する
37: Fit();
38: // もう不要なので取り外す
39: Disconnect(wxEVT_PAINT, wxPaintEventHandler(WXFitFrame::OnPaint));
40: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.