0
|
1
|
|
2 #include "myframe.h"
|
|
3
|
|
4 MyFrame::MyFrame( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style )
|
|
5 : wxFrame( parent, id, title, pos, size, style )
|
|
6 {
|
|
7 this->SetIcon( wxIcon( wxT("sample") ) );
|
|
8 this->SetSizeHints( wxDefaultSize, wxDefaultSize );
|
|
9 this->SetBackgroundColour( wxColour( 0, 0, 0 ) );
|
|
10
|
|
11 wxBoxSizer* bSizerTop = new wxBoxSizer( wxVERTICAL );
|
|
12
|
|
13 wxBoxSizer* bSizer = new wxBoxSizer( wxHORIZONTAL );
|
|
14
|
|
15 m_textCtrlPos = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
|
|
16 bSizer->Add( m_textCtrlPos, 0, wxALL, 5 );
|
|
17
|
|
18 m_buttonRec = new wxButton( this, ID_REC, wxT("Record"), wxDefaultPosition, wxSize( -1,-1 ), 0 );
|
|
19 bSizer->Add( m_buttonRec, 1, wxALL, 5 );
|
|
20
|
|
21 bSizerTop->Add( bSizer, 0, wxEXPAND, 5 );
|
|
22
|
|
23 m_textCtrlRec = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE );
|
|
24 m_textCtrlRec->SetFocus();
|
|
25 bSizerTop->Add( m_textCtrlRec, 1, wxALL|wxEXPAND, 5 );
|
|
26
|
|
27 this->SetSizer( bSizerTop );
|
|
28 this->Layout();
|
|
29
|
|
30 this->Centre( wxBOTH );
|
|
31 }
|
|
32
|
|
33 MyFrame::~MyFrame()
|
|
34 {
|
|
35 }
|
|
36
|
|
37 // Event Table
|
|
38 BEGIN_EVENT_TABLE( MyFrame, wxFrame )
|
|
39 EVT_MOVE( MyFrame::OnWinMove )
|
|
40 EVT_BUTTON( ID_REC, MyFrame::OnRec )
|
|
41 END_EVENT_TABLE()
|
|
42
|
|
43 // Event Handlers & Functions
|
|
44 /* ウィンドウ移動したら位置とサイズを表示 */
|
|
45 void MyFrame::OnWinMove( wxMoveEvent& WXUNUSED(event) )
|
|
46 {
|
|
47 wxRect r = this->GetRect();
|
|
48 int x = r.GetX();
|
|
49 int y = r.GetY();
|
|
50 int w = r.GetWidth();
|
|
51 int h = r.GetHeight();
|
|
52
|
|
53 m_textCtrlPos->SetValue( wxString::Format(wxT( "%5d,%5d"), x, y ) );
|
|
54 }
|
|
55
|
|
56 void MyFrame::OnRec( wxCommandEvent& WXUNUSED(event) )
|
|
57 {
|
|
58 wxString pos;
|
|
59 pos = m_textCtrlPos->GetValue();
|
|
60 m_textCtrlRec->AppendText( pos );
|
|
61 m_textCtrlRec->WriteText( wxT("\n") );
|
|
62 }
|
|
63
|