Ticket #15980: MainWindow.cpp

File MainWindow.cpp, 2.8 KB (added by Malco, 4 years ago)

Simple to reproduce the bug of wxTextCtrl

Line 
1
2
3// For compilers that support precompilation, includes "wx/wx.h".
4#include "wx/wxprec.h"
5
6// for all others, include the necessary headers (this file is usually all you
7// need because it includes almost all "standard" wxWidgets headers)
8#ifndef WX_PRECOMP
9    #include "wx/wx.h"
10#endif
11
12// Define a new frame type: this is going to be our main frame
13class MainWindow : public wxFrame
14{
15public:
16    // ctor(s)
17    MainWindow();
18
19    void initAndCreate(void);
20};
21
22
23// Define a new application type, each program should derive a class from wxApp
24class MyApp : public wxApp
25{
26public:
27    virtual bool OnInit();
28};
29
30// Create a new application object: this macro will allow wxWidgets to create
31// the application object during program execution (it's better than using a
32// static object for many reasons) and also implements the accessor function
33// wxGetApp() which will return the reference of the right type (i.e. MyApp and
34// not wxApp)
35IMPLEMENT_APP(MyApp)
36
37
38// 'Main program' equivalent: the program execution "starts" here
39bool MyApp::OnInit()
40{
41    // call the base class initialization method, currently it only parses a
42    // few common command-line options but it could be do more in the future
43    if ( !wxApp::OnInit() )
44        return false;
45
46    // create the main application window
47    MainWindow *frame = new MainWindow;
48    frame->initAndCreate();
49
50    // success: wxApp::OnRun() will be called which will enter the main message
51    // loop and the application will run. If we returned false here, the
52    // application would exit immediately.
53    return true;
54}
55
56
57// ----------------------------------------------------------------------------
58// main frame
59// ----------------------------------------------------------------------------
60
61// frame constructor
62MainWindow::MainWindow() : wxFrame(NULL, wxID_ANY, "")
63{
64}
65
66void 
67MainWindow::initAndCreate(void)
68{
69    Show(true);
70        Maximize();
71    SetIcon(wxICON(sample));
72    SetTitle("Bug wxTextCtrl");
73
74    //Main panel
75        wxPanel *panel = new wxPanel(this);
76        panel->SetSize(GetClientSize());
77
78    wxBoxSizer *sizerCol = new wxBoxSizer(wxVERTICAL);
79   
80    wxTextCtrl *textLog = new wxTextCtrl(panel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE);
81    char txt[1000];
82    for (int i = 0; i < 150; i++) {
83        sprintf(txt, "[%3d] ", i);
84        textLog->AppendText(txt);
85        textLog->AppendText("aaazzzeeerrrtttaaazzzeeerrrtttaaazzzeeerrrtttaaazzzeeerrrtttyyyaaazzzeeerrrtttaaazzzeeerrrttteerrraaazzzeeerrraaazzzeeerrraaazzzeeerrraaazzzeeerrrtttaaazzzeeerrrtttaaazzzzeeerrrtttaaazzzeeerrrtttaaazzzeeerrrtttaaazzz\n");
86    }
87
88
89    sizerCol->Add(textLog, 1, wxGROW | wxALL, 10);
90   
91   
92    panel->SetSizer(sizerCol);
93    panel->Layout();
94
95    Refresh();
96    Update();
97}
98
99
100