File: sample_inputline.cpp

package info (click to toggle)
fityk 1.3.1-6
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 3,784 kB
  • sloc: cpp: 34,396; ansic: 4,673; python: 971; makefile: 366; sh: 117; java: 31; ruby: 27; perl: 25; xml: 16
file content (45 lines) | stat: -rw-r--r-- 1,081 bytes parent folder | download | duplicates (5)
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
// InputLine sample, by Marcin Wojdyr, public domain

#include <wx/wx.h>
#include "inputline.h"

class Frame : public wxFrame, public InputLineObserver
{
public:
    Frame();
    // implementation of InputLineObserver
    virtual void ProcessInputLine(const wxString& s)
        { m_output->AppendText(s + wxT("\n")); }

private:
    InputLine* m_input;
    wxTextCtrl* m_output;
};

class App : public wxApp
{
public:
    bool OnInit()
    {
        wxApp::OnInit();
        Frame *frame = new Frame;
        frame->Show(true);
        return true;
    }
};

IMPLEMENT_APP(App)

Frame::Frame() : wxFrame(0, wxID_ANY, wxT("InputLine sample"))
{
    wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL);
    m_input = new InputLine(this, wxID_ANY, this, wxEmptyString);
    m_output = new wxTextCtrl(this, wxID_ANY, wxEmptyString,
                              wxDefaultPosition, wxDefaultSize,
                              wxTE_MULTILINE|wxTE_READONLY);
    sizer->Add(m_input, 0, wxEXPAND);
    sizer->Add(m_output, 1, wxEXPAND);
    SetSizerAndFit(sizer);
    m_input->SetFocus();
}