ぬの部屋(仮)
nu-no-he-ya
  •       1
    2345678
    9101112131415
    16171819202122
    23242526272829
    30      
       1234
    567891011
    12131415161718
    19202122232425
    262728293031 
           
     123456
    78910111213
    14151617181920
    21222324252627
    282930    
           
         12
    3456789
    10111213141516
    17181920212223
    24252627282930
    31      
         12
    3456789
    10111213141516
    17181920212223
    2425262728  
           
      12345
    6789101112
    13141516171819
    20212223242526
    2728293031  
           
          1
    2345678
    9101112131415
    16171819202122
    23242526272829
    3031     
        123
    45678910
    11121314151617
    18192021222324
    252627282930 
           
     123456
    78910111213
    14151617181920
    21222324252627
    28293031   
           
          1
    2345678
    9101112131415
    16171819202122
    23242526272829
    30      
       1234
    567891011
    12131415161718
    19202122232425
    262728293031 
           
    1234567
    891011121314
    15161718192021
    22232425262728
    293031    
           
         12
    3456789
    10111213141516
    17181920212223
    24252627282930
           
      12345
    6789101112
    13141516171819
    20212223242526
    2728293031  
           
    1234567
    891011121314
    15161718192021
    22232425262728
    2930     
           
        123
    45678910
    11121314151617
    18192021222324
    25262728293031
           
       1234
    567891011
    12131415161718
    19202122232425
    26272829   
           
    1234567
    891011121314
    15161718192021
    22232425262728
    293031    
           
        123
    45678910
    11121314151617
    18192021222324
    25262728293031
           
      12345
    6789101112
    13141516171819
    20212223242526
    27282930   
           
          1
    2345678
    9101112131415
    16171819202122
    23242526272829
    3031     
        123
    45678910
    11121314151617
    18192021222324
    252627282930 
           
     123456
    78910111213
    14151617181920
    21222324252627
    28293031   
           
         12
    3456789
    10111213141516
    17181920212223
    24252627282930
    31      
       1234
    567891011
    12131415161718
    19202122232425
    2627282930  
           
    1234567
    891011121314
    15161718192021
    22232425262728
    293031    
           
         12
    3456789
    10111213141516
    17181920212223
    24252627282930
           
      12345
    6789101112
    13141516171819
    20212223242526
    2728293031  
           
      12345
    6789101112
    13141516171819
    20212223242526
    2728     
           
          1
    2345678
    9101112131415
    16171819202122
    23242526272829
    3031     
       1234
    567891011
    12131415161718
    19202122232425
    262728293031 
           
     123456
    78910111213
    14151617181920
    21222324252627
    282930    
           
         12
    3456789
    10111213141516
    17181920212223
    24252627282930
    31      
       1234
    567891011
    12131415161718
    19202122232425
    2627282930  
           
    1234567
    891011121314
    15161718192021
    22232425262728
    293031    
           
        123
    45678910
    11121314151617
    18192021222324
    25262728293031
           
      12345
    6789101112
    13141516171819
    20212223242526
    27282930   
           
          1
    2345678
    9101112131415
    16171819202122
    23242526272829
    3031     
        123
    45678910
    11121314151617
    18192021222324
    252627282930 
           
     123456
    78910111213
    14151617181920
    21222324252627
    28293031   
           
     123456
    78910111213
    14151617181920
    21222324252627
    28      
           
         12
    3456789
    10111213141516
    17181920212223
    24252627282930
    31      
      12345
    6789101112
    13141516171819
    20212223242526
    2728293031  
           
    1234567
    891011121314
    15161718192021
    22232425262728
    2930     
           
        123
    45678910
    11121314151617
    18192021222324
    25262728293031
           
      12345
    6789101112
    13141516171819
    20212223242526
    27282930   
           
          1
    2345678
    9101112131415
    16171819202122
    23242526272829
    3031     
       1234
    567891011
    12131415161718
    19202122232425
    262728293031 
           
     123456
    78910111213
    14151617181920
    21222324252627
    282930    
           
         12
    3456789
    10111213141516
    17181920212223
    24252627282930
    31      
       1234
    567891011
    12131415161718
    19202122232425
    2627282930  
           
    1234567
    891011121314
    15161718192021
    22232425262728
    293031    
           
    1234567
    891011121314
    15161718192021
    22232425262728
           
           
        123
    45678910
    11121314151617
    18192021222324
    25262728293031
           
     123456
    78910111213
    14151617181920
    21222324252627
    28293031   
           
          1
    2345678
    9101112131415
    16171819202122
    23242526272829
    30      
       1234
    567891011
    12131415161718
    19202122232425
    262728293031 
           
     123456
    78910111213
    14151617181920
    21222324252627
    282930    
           
         12
    3456789
    10111213141516
    17181920212223
    24252627282930
    31      
      12345
    6789101112
    13141516171819
    20212223242526
    2728293031  
           
    1234567
    891011121314
    15161718192021
    22232425262728
    2930     
           
        123
    45678910
    11121314151617
    18192021222324
    25262728293031
           
      12345
    6789101112
    13141516171819
    20212223242526
    27282930   
           
          1
    2345678
    9101112131415
    16171819202122
    23242526272829
    3031     
         12
    3456789
    10111213141516
    17181920212223
    242526272829 
           
      12345
    6789101112
    13141516171819
    20212223242526
    2728293031  
           
          1
    2345678
    9101112131415
    16171819202122
    23242526272829
    3031     
        123
    45678910
    11121314151617
    18192021222324
    252627282930 
           
     123456
    78910111213
    14151617181920
    21222324252627
    28293031   
           
          1
    2345678
    9101112131415
    16171819202122
    23242526272829
    30      
       1234
    567891011
    12131415161718
    19202122232425
    262728293031 
           
    1234567
    891011121314
    15161718192021
    22232425262728
    293031    
           
         12
    3456789
    10111213141516
    17181920212223
    24252627282930
           
      12345
    6789101112
    13141516171819
    20212223242526
    2728293031  
           
    1234567
    891011121314
    15161718192021
    22232425262728
    2930     
           
        123
    45678910
    11121314151617
    18192021222324
    25262728293031
           
        123
    45678910
    11121314151617
    18192021222324
    25262728   
           
     123456
    78910111213
    14151617181920
    21222324252627
    28293031   
           
         12
    3456789
    10111213141516
    17181920212223
    24252627282930
    31      
       1234
    567891011
    12131415161718
    19202122232425
    2627282930  
           
    1234567
    15161718192021
    293031    
           
         12
    3456789
    10111213141516
           
      12345
    6789101112
    13141516171819
    20212223242526
    2728293031  
           
          1
    2345678
    9101112131415
    16171819202122
    23242526272829
    3031     
        123
    45678910
    11121314151617
    18192021222324
    252627282930 
           
     123456
    78910111213
    14151617181920
    21222324252627
    28293031   
           
          1
    2345678
    9101112131415
    16171819202122
    23242526272829
    30      
       1234
    567891011
    12131415161718
    19202122232425
    262728293031 
           
    1234567
    891011121314
    15161718192021
    22232425262728
    293031    
           
        123
    45678910
    11121314151617
    18192021222324
    25262728293031
           
      12345
    6789101112
    13141516171819
    20212223242526
    27282930   
           
        123
    45678910
    11121314151617
    18192021222324
    252627282930 
           
     123456
    78910111213
    14151617181920
    21222324252627
    28293031   
           
       1234
    567891011
    12131415161718
    19202122232425
    2627282930  
           
    1234567
    891011121314
    15161718192021
    22232425262728
    293031    
           
         12
    3456789
    10111213141516
    17181920212223
    24252627282930
           
      12345
    6789101112
    13141516171819
    20212223242526
    2728293031  
           
      12345
    6789101112
    13141516171819
    20212223242526
    2728     
           
          1
    2345678
    9101112131415
    16171819202122
    23242526272829
    3031     
     123456
    78910111213
    14151617181920
    21222324252627
    282930    
           
         12
    3456789
    10111213141516
    17181920212223
    24252627282930
    31      
    1234567
    891011121314
    15161718192021
    22232425262728
    293031    
           
        123
    45678910
    11121314151617
    18192021222324
    252627282930 
           
     123456
    78910111213
    14151617181920
    21222324252627
    28293031   
           
     123456
    78910111213
    14151617181920
    21222324252627
    28293031   
           
       1234
    567891011
    12131415161718
    19202122232425
    262728293031 
           
     123456
    78910111213
    14151617181920
    21222324252627
    282930    
           
         12
    3456789
    10111213141516
    17181920212223
    24252627282930
    31      
      12345
    6789101112
    13141516171819
    20212223242526
    2728293031  
           
    1234567
    891011121314
    15161718192021
    22232425262728
    2930     
           
        123
    45678910
    11121314151617
    18192021222324
    25262728293031
           
      12345
    6789101112
    13141516171819
    20212223242526
    27282930   
           
          1
    2345678
    9101112131415
    16171819202122
    23242526272829
    3031     
          1
    2345678
    9101112131415
    16171819202122
    232425262728 
           
       1234
    567891011
    12131415161718
    19202122232425
    262728293031 
           
    1234567
    891011121314
    15161718192021
    22232425262728
    293031    
           
         12
    3456789
    10111213141516
    17181920212223
    24252627282930
           
      12345
    6789101112
    13141516171819
    20212223242526
    2728293031  
           
    1234567
    891011121314
    15161718192021
    22232425262728
    2930     
           
        123
    45678910
    11121314151617
    18192021222324
    25262728293031
           
  • wxWidgets,wxSizerでのレイアウトメモ

    // https://docs.wxwidgets.org/3.0/overview_helloworld.html
    
    // プリプロセッサに以下二つを追加
    // __WXMSW__
    // WXUSINGDLL
    
    // サブシステムをWindowsに設定(WinMainで呼び出すので)
    // Windows (/SUBSYSTEM:WINDOWS)
    
    #ifndef WX_PRECOMP
    #include <wx/wx.h>
    #endif
    
    #include <wx/gdicmn.h> // wxPointに必要
    #include <wx/frame.h>  // wxFrameに必要
    
    
    /////////////////////////////////////
    /////////////////////////////////////
    /////////////////////////////////////
    
    #include <string>
    
    
    
    // ウィンドウ作成
    class MyFrame : public wxFrame
    {
    
    public:
    
        void PostCreate() {
    
            // ウィンドウサイズ
            this->SetSize(wxSize(200, 200)); // ウィンドウのサイズを設定
    
            this->Layout(); // レイアウトの更新
        }
    
    
        void func1();
        void func2();
        void func3();
        void func4();
        void func5();
        void func6();
        void func7();
        void func8();
        void func9();
        void func10();
    
        MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size)
            : wxFrame(NULL, wxID_ANY, title, pos, size)
        
        {
            // CallAfter : 現在処理中のイベントが終わったらPostCreateを実行
            // コンストラクタはウィンドウ生成イベント扱い
            CallAfter(&MyFrame::PostCreate);
    
            //func1();
            //func2();
            //func3();
            func4();
            //func5();
            //func6();
            //func7();
            //func8();
            //func9();
            //func10();
        }
    
    
    private:
    };
    
    
    
    
    /////////////////////////////////////
    /////////////////////////////////////
    /////////////////////////////////////
    
    // wxWidgetsのアプリケーション作成
    class MyApp : public wxApp {
    public:
    
        virtual bool OnInit() {
            MyFrame* frame = new MyFrame("Hello World", wxPoint(50, 50), wxSize(450, 340));
            frame->Show(true);
    
            return true;
        }
    
    };
    
    /////////////////////////////////////
    /////////////////////////////////////
    /////////////////////////////////////
    
    // WinMainをマクロで定義
    wxIMPLEMENT_APP(MyApp);
    

    各配置コード

    ① 全体に広げる

    // 全体に広げる
    void MyFrame::func1() {
        wxButton* mybutton = new wxButton(
            this,
            wxID_ANY,
            "button",
            wxDefaultPosition,
            wxSize(100, 100),
            wxTAB_TRAVERSAL | wxBORDER_SIMPLE
        );
    
        // 縦方向のBoxSizer
        wxBoxSizer* sizer = new wxBoxSizer(wxVERTICAL);
    
        // ウィジェットをSizerに追加
        // wxEXPANDでフルサイズに広げる(1=比率)
        sizer->Add(mybutton, 1, wxEXPAND | wxALL, 0);
    
        // パネルにSizerを適用
        this->SetSizer(sizer);
    }
    

    ② 上下に広げる

    // 上下に平等
    void MyFrame::func2() {
        wxButton* mybutton1 = new wxButton(
            this,
            wxID_ANY,
            "1",
            wxDefaultPosition,
            wxSize(100, 100),
            wxTAB_TRAVERSAL | wxBORDER_SIMPLE
        );
        mybutton1->SetMinSize(wxSize(20, 20));
        wxButton* mybutton2 = new wxButton(
            this,
            wxID_ANY,
            "2",
            wxDefaultPosition,
            wxSize(100, 100),
            wxTAB_TRAVERSAL | wxBORDER_SIMPLE
        );
        mybutton2->SetMinSize(wxSize(20, 20));
    
        // 上下に並べて表示
        wxBoxSizer* sizer = new wxBoxSizer(wxVERTICAL);
        // ウィジェットをSizerに追加
        // wxEXPANDでフルサイズに広げる(1=比率)
        sizer->Add(mybutton1, 1, wxEXPAND | wxALL, 0);
        sizer->Add(mybutton2, 1, wxEXPAND | wxALL, 0);
        // パネルにSizerを適用
        this->SetSizer(sizer);
        // レイアウトの更新
        this->Layout();
    }
    

    ③ 左右に平等

    // 左右に平等
    void MyFrame::func3() {
        wxButton* mybutton1 = new wxButton(
            this,
            wxID_ANY,
            "1",
            wxDefaultPosition,
            wxSize(100, 100),
            wxTAB_TRAVERSAL | wxBORDER_SIMPLE
        );
        mybutton1->SetMinSize(wxSize(20, 20));
        wxButton* mybutton2 = new wxButton(
            this,
            wxID_ANY,
            "2",
            wxDefaultPosition,
            wxSize(100, 100),
            wxTAB_TRAVERSAL | wxBORDER_SIMPLE
        );
        mybutton2->SetMinSize(wxSize(20, 20));
    
        // 左右に並べて表示
        wxBoxSizer* sizer = new wxBoxSizer(wxHORIZONTAL);
        // ウィジェットをSizerに追加
        // wxEXPANDでフルサイズに広げる(1=比率)
        sizer->Add(mybutton1, 1, wxEXPAND | wxALL, 0);
        sizer->Add(mybutton2, 1, wxEXPAND | wxALL, 0);
        // パネルにSizerを適用
        this->SetSizer(sizer);
        // レイアウトの更新
        this->Layout();
    }
    

    ④ 画面中央 固定サイズ

    // 画面中央 固定サイズ
    void MyFrame::func4() {
        wxButton* mybutton1 = new wxButton(
            this,
            wxID_ANY,
            "1",
            wxDefaultPosition,
            wxSize(100, 100), // ボタンのサイズを指定
            wxTAB_TRAVERSAL | wxBORDER_SIMPLE
        );
    
        wxBoxSizer* sizer = new wxBoxSizer(wxHORIZONTAL);
        sizer->Add(0, 0, 1, wxEXPAND, 0); // ダミー。proportion=1で「残りスペースを埋める」設定
        sizer->Add(mybutton1, 0, wxALIGN_CENTER | wxALL, 0); // proportion=0 で固定サイズ
        sizer->Add(0, 0, 1, wxEXPAND, 0); // ダミー。proportion=1で「残りスペースを埋める」設定
        this->SetSizer(sizer);
    
    }
    

    ⑤ 画面四分割 wxGridSizer

    // 画面四分割 wxGridSizer
    void MyFrame::func5() {
        // 2x2のGridSizerを作成(行数:2, 列数:2, 両マージン:0)
        wxGridSizer* sizer = new wxGridSizer(2, 2, 0, 0);
    
        // 4つのボタンを作成して追加
        wxButton* button1 = new wxButton(this, wxID_ANY, "1");
        wxButton* button2 = new wxButton(this, wxID_ANY, "2");
        wxButton* button3 = new wxButton(this, wxID_ANY, "3");
        wxButton* button4 = new wxButton(this, wxID_ANY, "4");
    
        // 各ボタンをSizerに追加(比率1、フル展開)
        sizer->Add(button1, 1, wxEXPAND | wxALL, 0);
        sizer->Add(button2, 1, wxEXPAND | wxALL, 0);
        sizer->Add(button3, 1, wxEXPAND | wxALL, 0);
        sizer->Add(button4, 1, wxEXPAND | wxALL, 0);
    
        this->SetSizer(sizer);
        this->Layout();
    }
    

    ⑥ 画面四分割 wxSizer

    // 画面四分割 wxSizer
    void MyFrame::func6() {
        wxButton* button1 = new wxButton(this, wxID_ANY, "1");
        wxButton* button2 = new wxButton(this, wxID_ANY, "2");
        wxButton* button3 = new wxButton(this, wxID_ANY, "3");
        wxButton* button4 = new wxButton(this, wxID_ANY, "4");
    
        // 大きな縦方向Sizer(2行)
        wxBoxSizer* mainSizer = new wxBoxSizer(wxVERTICAL);
    
        // 1行目
        wxBoxSizer* row1 = new wxBoxSizer(wxHORIZONTAL);
        row1->Add(button1, 1, wxEXPAND | wxALL, 0);
        row1->Add(button2, 1, wxEXPAND | wxALL, 0);
        mainSizer->Add(row1, 1, wxEXPAND | wxALL, 0);
    
        // 2行目
        wxBoxSizer* row2 = new wxBoxSizer(wxHORIZONTAL);
        row2->Add(button3, 1, wxEXPAND | wxALL, 0);
        row2->Add(button4, 1, wxEXPAND | wxALL, 0);
        mainSizer->Add(row2, 1, wxEXPAND | wxALL, 0);
    
        // フレームにSizerを適用
        this->SetSizer(mainSizer);
        this->Layout();
    }
    

    ⑦ 左側幅固定

    // 左側幅固定
    void MyFrame::func7() {
        wxBoxSizer* sizer = new wxBoxSizer(wxHORIZONTAL);
    
        // 左のボタン(幅50px固定)
        wxButton* leftButton = new wxButton(this, wxID_ANY, "Left");
        leftButton->SetMinSize(wxSize(50, -1));// 幅50px, 高さは自動調整
        leftButton->SetMaxSize(wxSize(50, -1));
    
        // 右のボタン(残りスペースを埋める)
        wxButton* rightButton = new wxButton(this, wxID_ANY, "Right");
    
        // Sizerに追加
        sizer->Add(leftButton, 0, wxEXPAND | wxALL, 0); // 右は proportion=0 で固定サイズ
        sizer->Add(rightButton, 1, wxEXPAND | wxALL, 0);// 左は proportion=1 で残りを埋める
    
        // フレームに適用
        this->SetSizer(sizer);
        this->Layout();
    
    }
    

    ⑧ 右側幅固定

    // 右側幅固定
    void MyFrame::func8() {
        wxBoxSizer* sizer = new wxBoxSizer(wxHORIZONTAL);
    
        // 左のボタン(残りスペースを埋める)
        wxButton* leftButton = new wxButton(this, wxID_ANY, "Left");
    
        // 右のボタン(幅500px固定)
        wxButton* rightButton = new wxButton(this, wxID_ANY, "Right");
    
        // 幅を固定するための設定
        rightButton->SetMinSize(wxSize(50, -1));
        rightButton->SetMaxSize(wxSize(50, -1));
    
        // Sizerに追加
        sizer->Add(leftButton, 1, wxEXPAND | wxALL, 0);  // 左は proportion=1 で残りを埋める
        sizer->Add(rightButton, 0, wxEXPAND | wxALL, 0); // 右は proportion=0 で固定サイズ
    
        // フレームに適用
        this->SetSizer(sizer);
        this->Layout();
    
    }
    

    ⑨ 上側高さ固定

    // 上側高さ固定
    void MyFrame::func9() {
    
        wxBoxSizer* sizer = new wxBoxSizer(wxVERTICAL);
    
        // 上のボタン(高さ固定)
        wxButton* topButton = new wxButton(this, wxID_ANY, "Top");
        topButton->SetMinSize(wxSize(-1, 50));  // 高さ100pxを保証
        topButton->SetMaxSize(wxSize(-1, 50));  // 高さ100pxに固定
    
        // 下のボタン(残りスペースを埋める)
        wxButton* bottomButton = new wxButton(this, wxID_ANY, "Bottom");
    
        // Sizerに追加
        sizer->Add(topButton, 0, wxEXPAND | wxALL, 0);    // proportion=0 で固定サイズ
        sizer->Add(bottomButton, 1, wxEXPAND | wxALL, 0); // proportion=1 で残りスペース
    
        // フレームに適用
        this->SetSizer(sizer);
        this->Layout();
    
    }
    

    ⑩ 下側高さ固定

    // 下側高さ固定
    void MyFrame::func10() {
        wxBoxSizer* sizer = new wxBoxSizer(wxVERTICAL);
    
        // 上のボタン
        wxButton* topButton = new wxButton(this, wxID_ANY, "Top");
    
        // 下のボタン
        wxButton* bottomButton = new wxButton(this, wxID_ANY, "Bottom");
        // 高さを固定するための設定
        bottomButton->SetMinSize(wxSize(-1, 50));
        bottomButton->SetMaxSize(wxSize(-1, 50));
    
        // Sizerに追加
        sizer->Add(topButton, 1, wxEXPAND | wxALL, 0);      // proportion=1 で残りスペース
        sizer->Add(bottomButton, 0, wxEXPAND | wxALL, 0);   // proportion=0 で固定サイズ
    
        // フレームに適用
        this->SetSizer(sizer);
        this->Layout();
    
    }