質問編集履歴
1
プログラムの簡素化 タイトル変更
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
wxWidgets AUIが
|
1
|
+
wxWidgets AUI フローティング時に他コントロールとの連動ができない
|
test
CHANGED
@@ -1,40 +1,20 @@
|
|
1
|
-
MyFrameにwxAuiManager m_mgrを持たせて
|
2
|
-
|
3
|
-
OpenGLを絵画するためのTestGLCanvasと
|
4
|
-
|
5
|
-
|
1
|
+
wxTextCtrlとMyPanelを
|
6
|
-
|
2
|
+
|
7
|
-
|
3
|
+
wxAuiManagerで管理できるようにしました
|
8
|
-
|
4
|
+
|
9
|
-
MyPanel
|
5
|
+
MyPanel内にはwxButtonがあり、ボタンを押すと
|
10
|
-
|
6
|
+
|
11
|
-
|
7
|
+
wxTextCtrl内に"a"を追加していきます
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
ここまでは良いのですが
|
16
8
|
|
17
9
|
これが上手くいくのはMyPanelがドッキングされている時です
|
18
10
|
|
19
|
-
ドッキングを外し、フローティングしている状態で
|
11
|
+
ドッキングを外し、フローティングしている状態でボタンを押すと
|
20
|
-
|
21
|
-
|
12
|
+
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
ブレークポイントで少し見てみたらMyPanel::OnButton関数内の
|
26
|
-
|
27
|
-
TestGLCanvas* tempglc = ((MyFrame*)GetParent())->GetGLCanvas();
|
28
|
-
|
29
|
-
tempglcがドッキングしている時とフローティングしている時では
|
30
|
-
|
31
|
-
|
13
|
+
読み取りアクセス違反ということでエラー落ちしてしまいます
|
32
|
-
|
33
|
-
|
14
|
+
|
34
|
-
|
35
|
-
|
15
|
+
|
36
|
-
|
16
|
+
|
37
|
-
どのように修正すれば良いか
|
17
|
+
どのように修正すれば良いか教えてください
|
38
18
|
|
39
19
|
|
40
20
|
|
@@ -48,27 +28,31 @@
|
|
48
28
|
|
49
29
|
|
50
30
|
|
51
|
-
#include
|
31
|
+
#include <wx/wx.h>
|
52
32
|
|
53
33
|
#include "wx/aui/aui.h"
|
54
34
|
|
55
|
-
|
35
|
+
|
56
|
-
|
57
|
-
|
58
|
-
|
36
|
+
|
59
|
-
class
|
37
|
+
class MyPanel : public wxPanel
|
60
38
|
|
61
39
|
{
|
62
40
|
|
63
41
|
public:
|
64
42
|
|
43
|
+
enum {
|
44
|
+
|
45
|
+
ID_BUTTON = wxID_HIGHEST + 1
|
46
|
+
|
47
|
+
};
|
48
|
+
|
65
|
-
|
49
|
+
MyPanel(wxWindow* parent);
|
66
|
-
|
67
|
-
|
68
50
|
|
69
51
|
private:
|
70
52
|
|
53
|
+
wxButton* m_btn;
|
54
|
+
|
71
|
-
void On
|
55
|
+
void OnButton(wxCommandEvent& event);
|
72
56
|
|
73
57
|
DECLARE_EVENT_TABLE()
|
74
58
|
|
@@ -76,102 +60,44 @@
|
|
76
60
|
|
77
61
|
|
78
62
|
|
79
|
-
class
|
63
|
+
class MyApp : public wxApp
|
80
64
|
|
81
65
|
{
|
82
66
|
|
83
67
|
public:
|
84
68
|
|
85
|
-
TestGLContext(wxGLCanvas* canvas);
|
86
|
-
|
87
|
-
v
|
69
|
+
virtual bool OnInit();
|
88
70
|
|
89
71
|
};
|
90
72
|
|
91
73
|
|
92
74
|
|
93
|
-
class My
|
75
|
+
class MyFrame : public wxFrame
|
94
|
-
|
76
|
+
|
95
|
-
{
|
77
|
+
{
|
78
|
+
|
79
|
+
private:
|
80
|
+
|
81
|
+
wxAuiManager m_mgr;
|
82
|
+
|
83
|
+
MyPanel* m_panel;
|
84
|
+
|
85
|
+
wxTextCtrl* m_txt;
|
86
|
+
|
87
|
+
|
96
88
|
|
97
89
|
public:
|
98
90
|
|
99
|
-
My
|
91
|
+
MyFrame();
|
92
|
+
|
100
|
-
|
93
|
+
~MyFrame();
|
101
|
-
|
102
|
-
|
94
|
+
|
103
|
-
Te
|
95
|
+
wxTextCtrl* GetTextCtrl() { return m_txt; }
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
virtual bool OnInit();
|
108
|
-
|
109
|
-
virtual int OnExit();
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
private:
|
114
|
-
|
115
|
-
TestGLContext* m_glContext;
|
116
96
|
|
117
97
|
};
|
118
98
|
|
119
99
|
|
120
100
|
|
121
|
-
class MyFrame : public wxFrame
|
122
|
-
|
123
|
-
{
|
124
|
-
|
125
|
-
private:
|
126
|
-
|
127
|
-
wxAuiManager m_mgr;
|
128
|
-
|
129
|
-
TestGLCanvas* m_glc;
|
130
|
-
|
131
|
-
public:
|
132
|
-
|
133
|
-
TestGLCanvas* GetGLCanvas();
|
134
|
-
|
135
|
-
MyFrame();
|
136
|
-
|
137
|
-
~MyFrame();
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
private:
|
142
|
-
|
143
|
-
void OnClose(wxCommandEvent& event);
|
144
|
-
|
145
|
-
DECLARE_EVENT_TABLE()
|
146
|
-
|
147
|
-
};
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
class MyPanel : public wxPanel
|
152
|
-
|
153
|
-
{
|
154
|
-
|
155
|
-
public:
|
156
|
-
|
157
|
-
enum {
|
158
|
-
|
159
|
-
ID_BUTTON = wxID_HIGHEST + 1
|
160
|
-
|
161
|
-
};
|
162
|
-
|
163
|
-
MyPanel(wxWindow* parent);
|
164
|
-
|
165
|
-
private:
|
166
|
-
|
167
|
-
wxButton* btn;
|
168
|
-
|
169
|
-
void OnButton(wxCommandEvent& event);
|
170
|
-
|
171
|
-
DECLARE_EVENT_TABLE()
|
172
|
-
|
173
|
-
};
|
174
|
-
|
175
101
|
#endif // _WX_TEST_H_
|
176
102
|
|
177
103
|
|
@@ -184,82 +110,56 @@
|
|
184
110
|
|
185
111
|
//wxTest.cpp
|
186
112
|
|
187
|
-
#include "wx/wxprec.h"
|
188
|
-
|
189
113
|
#include "wxTest.h"
|
190
114
|
|
191
115
|
|
192
116
|
|
193
|
-
TestGLContext::TestGLContext(wxGLCanvas* canvas)
|
194
|
-
|
195
|
-
: wxGLContext(canvas)
|
196
|
-
|
197
|
-
{
|
198
|
-
|
199
|
-
SetCurrent(*canvas);
|
200
|
-
|
201
|
-
glEnable(GL_DEPTH_TEST);
|
202
|
-
|
203
|
-
glEnable(GL_LIGHTING);
|
204
|
-
|
205
|
-
glEnable(GL_LIGHT0);
|
206
|
-
|
207
|
-
glMatrixMode(GL_PROJECTION);
|
208
|
-
|
209
|
-
glLoadIdentity();
|
210
|
-
|
211
|
-
glFrustum(-0.5f, 0.5f, -0.5f, 0.5f, 1.0f, 3.0f);
|
212
|
-
|
213
|
-
}
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
void TestGLContext::Draw()
|
218
|
-
|
219
|
-
{
|
220
|
-
|
221
|
-
std::random_device rnd;
|
222
|
-
|
223
|
-
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
glMatrixMode(GL_MODELVIEW);
|
228
|
-
|
229
|
-
glLoadIdentity();
|
230
|
-
|
231
|
-
glTranslatef(0.0f, 0.0f, -2.0f);
|
232
|
-
|
233
|
-
glRotatef(rnd() % 360, 1.0f, 0.0f, 0.0f);
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
glBegin(GL_QUADS);
|
238
|
-
|
239
|
-
glNormal3f(0.0f, 0.0f, 1.0f);
|
240
|
-
|
241
|
-
glVertex3f(0.5f, 0.5f, 0.5f);
|
242
|
-
|
243
|
-
glVertex3f(-0.5f, 0.5f, 0.5f);
|
244
|
-
|
245
|
-
glVertex3f(-0.5f, -0.5f, 0.5f);
|
246
|
-
|
247
|
-
glVertex3f(0.5f, -0.5f, 0.5f);
|
248
|
-
|
249
|
-
glEnd();
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
glFlush();
|
254
|
-
|
255
|
-
}
|
256
|
-
|
257
|
-
|
258
|
-
|
259
117
|
IMPLEMENT_APP(MyApp)
|
260
118
|
|
261
119
|
|
262
120
|
|
121
|
+
BEGIN_EVENT_TABLE(MyPanel, wxPanel)
|
122
|
+
|
123
|
+
EVT_BUTTON(ID_BUTTON, MyPanel::OnButton)
|
124
|
+
|
125
|
+
END_EVENT_TABLE()
|
126
|
+
|
127
|
+
|
128
|
+
|
129
|
+
MyPanel::MyPanel(wxWindow* parent)
|
130
|
+
|
131
|
+
:wxPanel(parent, -1)
|
132
|
+
|
133
|
+
{
|
134
|
+
|
135
|
+
m_btn = new wxButton(this, ID_BUTTON, wxT("button"));
|
136
|
+
|
137
|
+
wxBoxSizer* vbox = new wxBoxSizer(wxVERTICAL);
|
138
|
+
|
139
|
+
wxBoxSizer* hbox = new wxBoxSizer(wxHORIZONTAL);
|
140
|
+
|
141
|
+
this->SetSizer(hbox);
|
142
|
+
|
143
|
+
vbox->Add(m_btn, 1, wxEXPAND);
|
144
|
+
|
145
|
+
hbox->Add(vbox, 1, wxEXPAND);
|
146
|
+
|
147
|
+
}
|
148
|
+
|
149
|
+
|
150
|
+
|
151
|
+
void MyPanel::OnButton(wxCommandEvent& event)
|
152
|
+
|
153
|
+
{
|
154
|
+
|
155
|
+
wxTextCtrl* temp = ((MyFrame*)GetParent())->GetTextCtrl();
|
156
|
+
|
157
|
+
temp->AppendText(wxT("a"));
|
158
|
+
|
159
|
+
}
|
160
|
+
|
161
|
+
|
162
|
+
|
263
163
|
bool MyApp::OnInit()
|
264
164
|
|
265
165
|
{
|
@@ -268,8 +168,6 @@
|
|
268
168
|
|
269
169
|
return false;
|
270
170
|
|
271
|
-
|
272
|
-
|
273
171
|
new MyFrame();
|
274
172
|
|
275
173
|
return true;
|
@@ -278,115 +176,21 @@
|
|
278
176
|
|
279
177
|
|
280
178
|
|
281
|
-
int MyApp::OnExit()
|
282
|
-
|
283
|
-
{
|
284
|
-
|
285
|
-
delete m_glContext;
|
286
|
-
|
287
|
-
return wxApp::OnExit();
|
288
|
-
|
289
|
-
}
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
TestGLContext& MyApp::GetContext(wxGLCanvas* canvas)
|
294
|
-
|
295
|
-
{
|
296
|
-
|
297
|
-
if (!m_glContext)
|
298
|
-
|
299
|
-
{
|
300
|
-
|
301
|
-
m_glContext = new TestGLContext(canvas);
|
302
|
-
|
303
|
-
}
|
304
|
-
|
305
|
-
m_glContext->SetCurrent(*canvas);
|
306
|
-
|
307
|
-
return *m_glContext;
|
308
|
-
|
309
|
-
}
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
BEGIN_EVENT_TABLE(TestGLCanvas, wxGLCanvas)
|
314
|
-
|
315
|
-
EVT_PAINT(TestGLCanvas::OnPaint)
|
316
|
-
|
317
|
-
END_EVENT_TABLE()
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
TestGLCanvas::TestGLCanvas(wxWindow* parent)
|
322
|
-
|
323
|
-
: wxGLCanvas(parent, wxID_ANY, NULL,
|
324
|
-
|
325
|
-
wxDefaultPosition, wxDefaultSize,
|
326
|
-
|
327
|
-
wxFULL_REPAINT_ON_RESIZE)
|
328
|
-
|
329
|
-
{
|
330
|
-
|
331
|
-
}
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
void TestGLCanvas::OnPaint(wxPaintEvent& WXUNUSED(event))
|
336
|
-
|
337
|
-
{
|
338
|
-
|
339
|
-
wxPaintDC dc(this);
|
340
|
-
|
341
|
-
const wxSize ClientSize = GetClientSize();
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
TestGLContext& canvas = wxGetApp().GetContext(this);
|
346
|
-
|
347
|
-
glViewport(0, 0, ClientSize.x, ClientSize.y);
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
canvas.Draw();
|
352
|
-
|
353
|
-
SwapBuffers();
|
354
|
-
|
355
|
-
}
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
BEGIN_EVENT_TABLE(MyFrame, wxFrame)
|
360
|
-
|
361
|
-
EVT_MENU(wxID_CLOSE, MyFrame::OnClose)
|
362
|
-
|
363
|
-
END_EVENT_TABLE()
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
179
|
MyFrame::MyFrame()
|
370
180
|
|
371
|
-
: wxFrame(NULL, wxID_ANY, wxT("
|
181
|
+
: wxFrame(NULL, wxID_ANY, wxT("sample"))
|
372
182
|
|
373
183
|
{
|
374
184
|
|
375
185
|
m_mgr.SetManagedWindow(this);
|
376
186
|
|
377
|
-
|
187
|
+
m_panel = new MyPanel(this);
|
188
|
+
|
378
|
-
|
189
|
+
m_txt = new wxTextCtrl(this, wxID_ANY);
|
190
|
+
|
191
|
+
m_mgr.AddPane(m_panel, wxAuiPaneInfo().MinSize(wxSize(100,100)));
|
192
|
+
|
379
|
-
m_mgr.AddPane(
|
193
|
+
m_mgr.AddPane(m_txt, wxAuiPaneInfo().CenterPane());
|
380
|
-
|
381
|
-
Caption(wxT("button")).
|
382
|
-
|
383
|
-
Right().MinSize(wxSize(100, 100))
|
384
|
-
|
385
|
-
);
|
386
|
-
|
387
|
-
m_glc = new TestGLCanvas(this);
|
388
|
-
|
389
|
-
m_mgr.AddPane(m_glc, wxAuiPaneInfo().Name(wxT("aui_gl_content")).CenterPane());
|
390
194
|
|
391
195
|
m_mgr.Update();
|
392
196
|
|
@@ -396,34 +200,6 @@
|
|
396
200
|
|
397
201
|
Show();
|
398
202
|
|
399
|
-
|
400
|
-
|
401
|
-
static const int attribs[] = { WX_GL_RGBA, WX_GL_DOUBLEBUFFER, 0 };
|
402
|
-
|
403
|
-
wxLogStatus("Double-buffered display %s supported",
|
404
|
-
|
405
|
-
wxGLCanvas::IsDisplaySupported(attribs) ? "is" : "not");
|
406
|
-
|
407
|
-
}
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
void MyFrame::OnClose(wxCommandEvent& WXUNUSED(event))
|
412
|
-
|
413
|
-
{
|
414
|
-
|
415
|
-
Close(true);
|
416
|
-
|
417
|
-
}
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
TestGLCanvas* MyFrame::GetGLCanvas()
|
422
|
-
|
423
|
-
{
|
424
|
-
|
425
|
-
return m_glc;
|
426
|
-
|
427
203
|
}
|
428
204
|
|
429
205
|
|
@@ -436,50 +212,4 @@
|
|
436
212
|
|
437
213
|
}
|
438
214
|
|
439
|
-
|
440
|
-
|
441
|
-
BEGIN_EVENT_TABLE(MyPanel, wxPanel)
|
442
|
-
|
443
|
-
EVT_BUTTON(ID_BUTTON, MyPanel::OnButton)
|
444
|
-
|
445
|
-
END_EVENT_TABLE()
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
MyPanel::MyPanel(wxWindow* parent)
|
450
|
-
|
451
|
-
:wxPanel(parent, -1)
|
452
|
-
|
453
|
-
{
|
454
|
-
|
455
|
-
btn = new wxButton(this, ID_BUTTON, wxT("button"));
|
456
|
-
|
457
|
-
wxBoxSizer* vbox = new wxBoxSizer(wxVERTICAL);
|
458
|
-
|
459
|
-
wxBoxSizer* hbox = new wxBoxSizer(wxHORIZONTAL);
|
460
|
-
|
461
|
-
this->SetSizer(hbox);
|
462
|
-
|
463
|
-
vbox->Add(btn, 1, wxEXPAND);
|
464
|
-
|
465
|
-
hbox->Add(vbox, 1, wxEXPAND);
|
466
|
-
|
467
|
-
}
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
void MyPanel::OnButton(wxCommandEvent& event)
|
472
|
-
|
473
|
-
{
|
474
|
-
|
475
|
-
TestGLCanvas* tempglc = ((MyFrame*)GetParent())->GetGLCanvas();
|
476
|
-
|
477
|
-
TestGLContext& canvas = wxGetApp().GetContext(tempglc);
|
478
|
-
|
479
|
-
canvas.Draw();
|
480
|
-
|
481
|
-
tempglc->SwapBuffers();
|
482
|
-
|
483
|
-
}
|
484
|
-
|
485
215
|
```
|