'2024/02/12'에 해당되는 글 2건

  1. 2024.02.12 [wxWidgets] 상태바 On/Off 설정하기 1
  2. 2024.02.12 [wxWidgets] 새 창 만들기 기능 구현하기. 1

 View라는 메뉴를 추가하여 StatusBar를 On/Off하는 기능을 적용하기 위해서 다음과 같이 한다.

 

 wxMain.h

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#pragma once
#include "wx/wx.h"
#include <wx/filedlg.h>
#include <wx/textctrl.h>
#include <wx/splitter.h>
 
// Font Dialog
#include <wx/fontdlg.h>
 
// 파일을 읽어 들이기 위한 용도.
#include <fstream>
#include <sstream>
 
#include "wxOptionsDialog.h"
 
enum
{
    ID_QUIT,
    ID_WordWarp,
    ID_FontSetting,
    ID_StatusBar,
};
 
enum {
    MY_EVENT_ID = 10001,
};
 
// 메뉴 항목 ID 정의
enum
{
    ID_NEW_WINDOW = wxID_HIGHEST + 1 // 새 창을 위한 고유 ID
};
 
class MyApp : public wxApp
{
public:
    virtual bool OnInit();
};
 
class MyFrame : public wxFrame
{
public:
    MyFrame(const wxString& title);
 
    void OnQuit(wxCommandEvent& event);
 
private:
    wxTextCtrl* m_textControl;
    //wxOptionDialog* m_dialog;
    wxFont* m_font;
 
    wxStatusBar* m_statusBar;
 
    // 메뉴바 및 메뉴 변수.
    wxMenuBar* m_menuBar;
    wxMenu* m_menuFile;
    wxMenu* m_menuFormat;
    wxMenu* m_menuView;
 
    void OnNew(wxCommandEvent& event);
    void OnNewWindow(wxCommandEvent& event);
    void OnOpen(wxCommandEvent& event);
    void OnSave(wxCommandEvent& event);
    void OnButtonClick(wxCommandEvent& event);
 
    // Format 메뉴에 적용할 이벤트 핸들러
    void OnToggleWordWrap(wxCommandEvent& event);
    void OnFontSetting(wxCommandEvent& event);
 
    // View 메뉴에 적용할 이벤트 핸들러
    void OnToggleStatusBar(wxCommandEvent& event);
 
 
    // 이벤트를 받기 위한 메소드
    void OnMyCustomEvent(MyCustomEvent& event);
};
 
cs

 

 여기서 추가 된것은

 m_statusBar이다.

 m_statusBar를 이용해서 상태바를 보이고, 보이지 않게 할 수 있다.

 

 wxMain.cpp

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
#include "wxMain.h"
 
wxIMPLEMENT_APP(MyApp);
 
bool MyApp::OnInit()
{
    MyFrame* frame = new MyFrame("No Title - Notepad");
    frame->Show(true);
    return true;
}
 
MyFrame::MyFrame(const wxString& title)
    : wxFrame(NULL, wxID_ANY, title)
{
    m_menuFile = new wxMenu;
    m_menuFile->Append(wxID_NEW, "&New\tCtrl-N""New a Notepad");
    m_menuFile->Append(ID_NEW_WINDOW, "&New Windows\tCtrl+Shift+N""Open a new window.");
    m_menuFile->Append(wxID_OPEN, "&Open\tCtrl-O""Open a file");
    m_menuFile->Append(wxID_SAVE, "&Save\tCtrl-S""Save the file");
    m_menuFile->AppendSeparator();
    m_menuFile->Append(ID_QUIT, "E&xit\tAlt-X""프로그램 종료");
 
    m_menuFormat = new wxMenu;
    m_menuFormat->AppendCheckItem(ID_WordWarp, "Word &Wrap\tCtrl+W""Toggle word wrapping.");
    m_menuFormat->Append(ID_FontSetting, "&Font""Font Set Menu");
 
    m_menuView = new wxMenu;
    m_menuView->AppendCheckItem(ID_StatusBar, "Show &StatusBar""Toggle Status Bar.");
    
    m_menuBar = new wxMenuBar;
    m_menuBar->Append(m_menuFile, "&File");
    m_menuBar->Append(m_menuFormat, "F&omat");
    m_menuBar->Append(m_menuView, "&View");
 
    SetMenuBar(m_menuBar);
 
    m_textControl = new wxTextCtrl(this, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE);
 
    // sizer를 생성하여 텍스트 컨트롤의 크기를 조정합니다.
    wxBoxSizer* sizer = new wxBoxSizer(wxVERTICAL);
    sizer->Add(m_textControl, 1, wxEXPAND | wxALL, 0); // wxEXPAND는 컨트롤이 sizer의 가능한 모든 공간을 차지하도록 합니다. 1은 비율을 의미하며, 이 경우 다른 컨트롤이 없으므로 전체 크기를 차지합니다.
 
    // 프레임에 sizer를 설정합니다.
    this->SetSizer(sizer);
    this->Layout(); // sizer를 강제로 다시 계산하여 적용합니다.
 
    // 폰트 설정
    wxFont font(16, wxFONTFAMILY_TELETYPE, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD);
    m_textControl->SetFont(font);
 
    //m_statusBar = new wxStatusBar(this);
    m_statusBar = CreateStatusBar();
    SetStatusText("Ready");
    // ID_StatusBar 메뉴 항목을 자동으로 체크되어 있도록 설정
    m_menuView->Check(ID_StatusBar, true);
 
    // 이벤트 핸들러 연결
    Bind(wxEVT_MENU, &MyFrame::OnNew, this, wxID_NEW);
 
    // MyFrame 생성자 또는 초기화 함수 내
    Bind(wxEVT_MENU, &MyFrame::OnNewWindow, this, ID_NEW_WINDOW);
 
    Bind(wxEVT_MENU, &MyFrame::OnOpen, this, wxID_OPEN);
    Bind(wxEVT_MENU, &MyFrame::OnSave, this, wxID_SAVE);
 
    Bind(wxEVT_MENU, &MyFrame::OnQuit, this, ID_QUIT);
 
    // 메뉴 Format에 관련된 이벤트 핸들러
    Bind(wxEVT_MENU, &MyFrame::OnToggleWordWrap, this, ID_WordWarp);
    Bind(wxEVT_MENU, &MyFrame::OnFontSetting, this, ID_FontSetting);
 
    // 메뉴 View에 관련된 이벤트 핸들러
    Bind(wxEVT_MENU, &MyFrame::OnToggleStatusBar, this, ID_StatusBar);
 
    // 이벤트 처리기 등록
    Bind(MY_CUSTOM_EVENT, &MyFrame::OnMyCustomEvent, this);
}
 
void MyFrame::OnQuit(wxCommandEvent& event)
{
    Close(true);
}
 
void MyFrame::OnNew(wxCommandEvent& event) {
    // 텍스트 컨트롤의 내용을 비웁니다.
    m_textControl->Clear();
 
    // 타이틀에 메시지를 새로 작성합니다.
    wxString titleNames = "No Title";
    titleNames += " - Notepad";
    SetTitle(titleNames);
 
    // 상태 표시줄에 메시지를 표시합니다.
    SetStatusText("New document created.");
}
 
// MyFrame 클래스 내
void MyFrame::OnNewWindow(wxCommandEvent& event)
{
    // 새로운 창을 생성하고 표시
    MyFrame* newFrame = new MyFrame("No Title - Notepad");
    newFrame->Show(true);
}
 
void MyFrame::OnOpen(wxCommandEvent& event)
{
    wxFileDialog openFileDialog(this, _("Open TXT file"), """",
        "TXT files (*.txt)|*.txt", wxFD_OPEN | wxFD_FILE_MUST_EXIST);
    if (openFileDialog.ShowModal() == wxID_CANCEL)
        return// 사용자가 취소했을 때
 
    std::ifstream file(openFileDialog.GetPath().ToStdString());
    // 파일을 열고 텍스트 컨트롤에 내용을 로드합니다.
    if (m_textControl->LoadFile(openFileDialog.GetPath())) {
        std::stringstream buffer;
        buffer << file.rdbuf(); // 파일의 내용을 buffer에 읽어 들입니다.
        file.close(); // 파일을 닫습니다.
 
        // textControl의 내용을 갱신합니다.
        m_textControl->SetValue(buffer.str());
        //textControl->SetLabelText(buffer.str());
        
        wxString titleNames = openFileDialog.GetFilename();
        titleNames += " - Notepad";
        // 타이틀을 열린 파일의 이름으로 설정합니다.
        SetTitle(titleNames);
 
    }
    else {
        wxMessageBox("Cannot open File!""Error", wxOK | wxICON_ERROR);
    }
}
 
void MyFrame::OnSave(wxCommandEvent& event)
{
    wxFileDialog saveFileDialog(this, _("Save TXT file"), """",
        "TXT files (*.txt)|*.txt", wxFD_SAVE | wxFD_OVERWRITE_PROMPT);
    if (saveFileDialog.ShowModal() == wxID_CANCEL)
        return// 사용자가 취소했을 때
 
    // 현재 텍스트 컨트롤의 내용을 파일에 저장합니다.
    m_textControl->SaveFile(saveFileDialog.GetPath());
 
    wxString titleNames = saveFileDialog.GetFilename();
    titleNames += " - Notepad";
    // 타이틀을 열린 파일의 이름으로 설정합니다.
    SetTitle(titleNames);
}
 
void MyFrame::OnToggleWordWrap(wxCommandEvent& event)
{
    bool isChecked = m_menuFormat->IsChecked(ID_WordWarp);
    m_textControl->SetWindowStyleFlag(isChecked ? (m_textControl->GetWindowStyleFlag() | wxTE_WORDWRAP) : (m_textControl->GetWindowStyleFlag() & ~wxTE_WORDWRAP));
    m_textControl->Refresh(); // 화면 갱신
}
 
void MyFrame::OnFontSetting(wxCommandEvent& event)
{
    /*dialog = new wxOptionDialog(this, wxID_ANY, "Settings");
    dialog->ShowModal();*/
 
    wxFontData fontData;
    fontData.SetInitialFont(m_textControl->GetFont());
    fontData.SetColour(m_textControl->GetForegroundColour());
 
    wxFontDialog fontDialog(this, fontData);
    if (fontDialog.ShowModal() == wxID_OK)
    {
        wxFontData retData = fontDialog.GetFontData();
        wxFont font = retData.GetChosenFont();
        wxColour colour = retData.GetColour();
 
        m_textControl->SetFont(font);
        m_textControl->SetForegroundColour(colour);
    }
}
 
void MyFrame::OnToggleStatusBar(wxCommandEvent& event)
{
    bool isChecked = m_menuView->IsChecked(ID_StatusBar);
 
    // StatusBar의 보임/숨김 상태를 설정합니다.
    if (m_statusBar) { // m_statusBar가 유효한지 확인합니다.
        m_statusBar->Show(isChecked);
    }
 
    // 프레임의 레이아웃을 갱신하여 m_textControl이 남은 공간을 가득 채우도록 합니다.
    this->Layout();
 
    // 프레임의 크기를 조정하여 내부 컨트롤들이 적절하게 배치되도록 합니다.
    // 이 부분은 필요에 따라 추가하거나 생략할 수 있습니다.
    this->SendSizeEvent();
}
 
// 이벤트 처리 함수 구현
void MyFrame::OnMyCustomEvent(MyCustomEvent& event)
{
    const wxFont info = event.GetwxFont();
 
    int fontSize = info.GetPointSize();
    // 이벤트와 함께 전달된 정보 처리
    m_textControl->SetFont(info);
 
    //textControl->SetFont(font);
    //m_dialog->Destroy(); // dialog를 안전하게 삭제
    //delete m_dialog;
}
cs

 

 CreateStatusBar()는 wxStatusBar라는 클래스를 반환한다. 그래서, m_statusBar에 저장하면, 컨트롤하기 편해진다.

1
    m_statusBar = CreateStatusBar();
cs

 

View 메뉴에서 StatusBar를 컨트롤하기 위해서 이벤트 핸들러를 적용한다.

1
2
3
 
    // 메뉴 View에 관련된 이벤트 핸들러
    Bind(wxEVT_MENU, &MyFrame::OnToggleStatusBar, this, ID_StatusBar);
cs

 

 메뉴 이벤트 핸들러 및 Check을 컨트롤하기 위해서

 ID_StatusBar라는 열거형을 작성해줘야한다.

1
2
3
4
5
6
7
8
9
 
enum
{
    ID_QUIT,
    ID_WordWarp,
    ID_FontSetting,
    ID_StatusBar,
};
 
cs

 

이제, 이벤트 핸들러인 OnToggleStatusBar을 구현한다.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
 
void MyFrame::OnToggleStatusBar(wxCommandEvent& event)
{
    bool isChecked = m_menuView->IsChecked(ID_StatusBar);
 
    // StatusBar의 보임/숨김 상태를 설정합니다.
    if (m_statusBar) { // m_statusBar가 유효한지 확인합니다.
        m_statusBar->Show(isChecked);
    }
 
    // 프레임의 레이아웃을 갱신하여 m_textControl이 남은 공간을 가득 채우도록 합니다.
    this->Layout();
 
    // 프레임의 크기를 조정하여 내부 컨트롤들이 적절하게 배치되도록 합니다.
    // 이 부분은 필요에 따라 추가하거나 생략할 수 있습니다.
    this->SendSizeEvent();
}
 
cs

 

 이렇게 하면, StatusBar가 보여지는거와 보이지 않는 것에 따라서 TextCtrl의 크기를 재정의 하여 비어지는 경우가 없어진다.

 

 여기서 CheckItem들은 기본이 Checked가 false인 상태이다.

 그래서 강제로 Checked true로 설정해준다면, 'm_menuView->Check(ID_StatusBar, true);'을 추가해주면 된다.

 

Posted by JunkMam
,

 wxMain에서 새 창을 만들면서 새 창을 띄우는 방식으로 개별로 윈도우를 만들어서 작업 할 수 있는 기능이다.

 

 wxMain.h

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#pragma once
#include "wx/wx.h"
#include <wx/filedlg.h>
#include <wx/textctrl.h>
#include <wx/splitter.h>
 
// Font Dialog
#include <wx/fontdlg.h>
 
// 파일을 읽어 들이기 위한 용도.
#include <fstream>
#include <sstream>
 
#include "wxOptionsDialog.h"
 
enum
{
    ID_QUIT,
    ID_WORD_WRAP,
    ID_FontSetting,
};
 
enum {
    MY_EVENT_ID = 10001,
};
 
// 메뉴 항목 ID 정의
enum
{
    ID_NEW_WINDOW = wxID_HIGHEST + 1 // 새 창을 위한 고유 ID
};
 
class MyApp : public wxApp
{
public:
    virtual bool OnInit();
};
 
class MyFrame : public wxFrame
{
public:
    MyFrame(const wxString& title);
 
    void OnQuit(wxCommandEvent& event);
 
private:
    wxTextCtrl* textControl;
    wxOptionDialog* dialog;
    wxFont* font;
 
    // 메뉴바 및 메뉴 변수.
    wxMenuBar* menuBar;
    wxMenu* menuFile;
    wxMenu* menuFormat;
 
    void OnNew(wxCommandEvent& event);
    void OnNewWindow(wxCommandEvent& event);
    void OnOpen(wxCommandEvent& event);
    void OnSave(wxCommandEvent& event);
    void OnButtonClick(wxCommandEvent& event);
 
    // 세팅 창을 띄우기 위한 메소드
    void OnToggleWordWrap(wxCommandEvent& event);
    void OnFontSetting(wxCommandEvent& event);
 
    // 이벤트를 받기 위한 메소드
    void OnMyCustomEvent(MyCustomEvent& event);
};
 
cs

 

 wxMain.cpp

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
#include "wxMain.h"
 
wxIMPLEMENT_APP(MyApp);
 
bool MyApp::OnInit()
{
    MyFrame* frame = new MyFrame("No Title - Notepad");
    frame->Show(true);
    return true;
}
 
MyFrame::MyFrame(const wxString& title)
    : wxFrame(NULL, wxID_ANY, title)
{
    menuFile = new wxMenu;
    menuFile->Append(wxID_NEW, "&New\tCtrl-N""New a Notepad");
    menuFile->Append(ID_NEW_WINDOW, "&New Windows\tCtrl+Shift+N""Open a new window.");
    menuFile->Append(wxID_OPEN, "&Open\tCtrl-O""Open a file");
    menuFile->Append(wxID_SAVE, "&Save\tCtrl-S""Save the file");
    menuFile->AppendSeparator();
    menuFile->Append(ID_QUIT, "E&xit\tAlt-X""프로그램 종료");
 
    menuFormat = new wxMenu;
    menuFormat->AppendCheckItem(ID_WORD_WRAP, "Word &Wrap\tCtrl+W""Toggle word wrapping.");
    menuFormat->Append(ID_FontSetting, "&Font""Font Set Menu");
    
 
    menuBar = new wxMenuBar;
    menuBar->Append(menuFile, "&File");
    menuBar->Append(menuFormat, "&F&omat");
 
    SetMenuBar(menuBar);
 
    textControl = new wxTextCtrl(this, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE);
 
    // sizer를 생성하여 텍스트 컨트롤의 크기를 조정합니다.
    wxBoxSizer* sizer = new wxBoxSizer(wxVERTICAL);
    sizer->Add(textControl, 1, wxEXPAND | wxALL, 0); // wxEXPAND는 컨트롤이 sizer의 가능한 모든 공간을 차지하도록 합니다. 1은 비율을 의미하며, 이 경우 다른 컨트롤이 없으므로 전체 크기를 차지합니다.
 
    // 프레임에 sizer를 설정합니다.
    this->SetSizer(sizer);
    this->Layout(); // sizer를 강제로 다시 계산하여 적용합니다.
 
    // 폰트 설정
    wxFont font(16, wxFONTFAMILY_TELETYPE, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD);
    textControl->SetFont(font);
 
    CreateStatusBar();
    SetStatusText("Ready");
 
    // 이벤트 핸들러 연결
    Bind(wxEVT_MENU, &MyFrame::OnNew, this, wxID_NEW);
 
    // MyFrame 생성자 또는 초기화 함수 내
    Bind(wxEVT_MENU, &MyFrame::OnNewWindow, this, ID_NEW_WINDOW);
 
    Bind(wxEVT_MENU, &MyFrame::OnOpen, this, wxID_OPEN);
    Bind(wxEVT_MENU, &MyFrame::OnSave, this, wxID_SAVE);
 
    Bind(wxEVT_MENU, &MyFrame::OnQuit, this, ID_QUIT);
 
    // 메뉴 Format에 관련된 이벤트 핸들러
    Bind(wxEVT_MENU, &MyFrame::OnToggleWordWrap, this, ID_WORD_WRAP);
    Bind(wxEVT_MENU, &MyFrame::OnFontSetting, this, ID_FontSetting);
 
    // 이벤트 처리기 등록
    Bind(MY_CUSTOM_EVENT, &MyFrame::OnMyCustomEvent, this);
}
 
void MyFrame::OnQuit(wxCommandEvent& event)
{
    Close(true);
}
 
void MyFrame::OnNew(wxCommandEvent& event) {
    // 텍스트 컨트롤의 내용을 비웁니다.
    textControl->Clear();
 
    // 타이틀에 메시지를 새로 작성합니다.
    wxString titleNames = "No Title";
    titleNames += " - Notepad";
    SetTitle(titleNames);
 
    // 상태 표시줄에 메시지를 표시합니다.
    SetStatusText("New document created.");
}
 
// MyFrame 클래스 내
void MyFrame::OnNewWindow(wxCommandEvent& event)
{
    // 새로운 창을 생성하고 표시
    MyFrame* newFrame = new MyFrame("No Title - Notepad");
    newFrame->Show(true);
}
 
void MyFrame::OnOpen(wxCommandEvent& event)
{
    wxFileDialog openFileDialog(this, _("Open TXT file"), """",
        "TXT files (*.txt)|*.txt", wxFD_OPEN | wxFD_FILE_MUST_EXIST);
    if (openFileDialog.ShowModal() == wxID_CANCEL)
        return// 사용자가 취소했을 때
 
    std::ifstream file(openFileDialog.GetPath().ToStdString());
    // 파일을 열고 텍스트 컨트롤에 내용을 로드합니다.
    if (textControl->LoadFile(openFileDialog.GetPath())) {
        std::stringstream buffer;
        buffer << file.rdbuf(); // 파일의 내용을 buffer에 읽어 들입니다.
        file.close(); // 파일을 닫습니다.
 
        // textControl의 내용을 갱신합니다.
        textControl->SetValue(buffer.str());
        //textControl->SetLabelText(buffer.str());
        
        wxString titleNames = openFileDialog.GetFilename();
        titleNames += " - Notepad";
        // 타이틀을 열린 파일의 이름으로 설정합니다.
        SetTitle(titleNames);
 
    }
    else {
        wxMessageBox("Cannot open File!""Error", wxOK | wxICON_ERROR);
    }
}
 
void MyFrame::OnSave(wxCommandEvent& event)
{
    wxFileDialog saveFileDialog(this, _("Save TXT file"), """",
        "TXT files (*.txt)|*.txt", wxFD_SAVE | wxFD_OVERWRITE_PROMPT);
    if (saveFileDialog.ShowModal() == wxID_CANCEL)
        return// 사용자가 취소했을 때
 
    // 현재 텍스트 컨트롤의 내용을 파일에 저장합니다.
    textControl->SaveFile(saveFileDialog.GetPath());
 
    wxString titleNames = saveFileDialog.GetFilename();
    titleNames += " - Notepad";
    // 타이틀을 열린 파일의 이름으로 설정합니다.
    SetTitle(titleNames);
}
 
void MyFrame::OnToggleWordWrap(wxCommandEvent& event)
{
    bool isChecked = menuFormat->IsChecked(ID_WORD_WRAP);
    textControl->SetWindowStyleFlag(isChecked ? (textControl->GetWindowStyleFlag() | wxTE_WORDWRAP) : (textControl->GetWindowStyleFlag() & ~wxTE_WORDWRAP));
    textControl->Refresh(); // 화면 갱신
}
 
void MyFrame::OnFontSetting(wxCommandEvent& event)
{
    /*dialog = new wxOptionDialog(this, wxID_ANY, "Settings");
    dialog->ShowModal();*/
 
    wxFontData fontData;
    fontData.SetInitialFont(textControl->GetFont());
    fontData.SetColour(textControl->GetForegroundColour());
 
    wxFontDialog fontDialog(this, fontData);
    if (fontDialog.ShowModal() == wxID_OK)
    {
        wxFontData retData = fontDialog.GetFontData();
        wxFont font = retData.GetChosenFont();
        wxColour colour = retData.GetColour();
 
        textControl->SetFont(font);
        textControl->SetForegroundColour(colour);
    }
}
 
// 이벤트 처리 함수 구현
void MyFrame::OnMyCustomEvent(MyCustomEvent& event)
{
    const wxFont info = event.GetwxFont();
 
    int fontSize = info.GetPointSize();
    // 이벤트와 함께 전달된 정보 처리
    textControl->SetFont(info);
 
    //textControl->SetFont(font);
    dialog->Destroy(); // dialog를 안전하게 삭제
    delete dialog;
}
cs

 

 이렇게 하면, Ctrl+Shift+N을 눌을때마다 새 창을 띄우는게 가능해진다.

Posted by JunkMam
,