]>
git.saurik.com Git - wxWidgets.git/blob - samples/plot/plot.cpp
2 * Program: wxPlotWindow
4 * Author: Robert Roebling
6 * Copyright: (C) 1999, Robert Roebling
10 // For compilers that support precompilation, includes "wx/wx.h".
11 #include "wx/wxprec.h"
24 #include "wx/listctrl.h"
39 class MyPlotCurve
: public wxPlotCurve
42 MyPlotCurve( int offsetY
, double startY
, double endY
) :
43 wxPlotCurve( offsetY
, startY
, endY
) {}
45 virtual wxInt32
GetStartX()
47 virtual wxInt32
GetEndX()
50 virtual double GetY( wxInt32 x
)
60 class MyFrame
: public wxFrame
65 void OnAbout( wxCommandEvent
&event
);
66 void OnQuit( wxCommandEvent
&event
);
72 DECLARE_DYNAMIC_CLASS(MyFrame
)
78 class MyApp
: public wxApp
81 virtual bool OnInit();
90 const int ID_QUIT
= 108;
91 const int ID_ABOUT
= 109;
93 IMPLEMENT_DYNAMIC_CLASS( MyFrame
, wxFrame
)
95 BEGIN_EVENT_TABLE(MyFrame
,wxFrame
)
96 EVT_MENU (ID_ABOUT
, MyFrame::OnAbout
)
97 EVT_MENU (ID_QUIT
, MyFrame::OnQuit
)
101 : wxFrame( (wxFrame
*)NULL
, -1, "wxPlotWindow sample",
102 wxPoint(20,20), wxSize(470,500) )
104 wxMenu
*file_menu
= new wxMenu();
105 file_menu
->Append( ID_ABOUT
, "&About..");
106 file_menu
->Append( ID_QUIT
, "E&xit\tAlt-X");
108 wxMenuBar
*menu_bar
= new wxMenuBar();
109 menu_bar
->Append(file_menu
, "&File");
111 SetMenuBar( menu_bar
);
114 int widths
[] = { -1, 100 };
115 SetStatusWidths( 2, widths
);
117 m_plot
= new wxPlotWindow( this, -1, wxPoint(0,0), wxSize(100,100), wxSUNKEN_BORDER
);
118 m_plot
->SetScrollbars( 10, 10, 500, 0 );
120 m_plot
->Add( new MyPlotCurve( 0, -1.5, 1.5 ) );
121 m_plot
->Add( new MyPlotCurve( 50, -1.5, 1.5 ) );
123 m_log
= new wxTextCtrl( this, -1, "This is the log window.\n", wxPoint(0,0), wxSize(100,100), wxTE_MULTILINE
);
124 wxLog
*old_log
= wxLog::SetActiveTarget( new wxLogTextCtrl( m_log
) );
127 wxBoxSizer
*topsizer
= new wxBoxSizer( wxVERTICAL
);
129 topsizer
->Add( m_plot
, 1, wxEXPAND
);
130 topsizer
->Add( m_log
, 0, wxEXPAND
);
132 SetAutoLayout( TRUE
);
133 SetSizer( topsizer
);
136 void MyFrame::OnQuit( wxCommandEvent
&WXUNUSED(event
) )
141 void MyFrame::OnAbout( wxCommandEvent
&WXUNUSED(event
) )
143 (void)wxMessageBox( "wxPlotWindow Demo\n"
144 "Robert Roebling (c) 1999,2000",
145 "About wxPlotWindow Demo", wxICON_INFORMATION
| wxOK
);
148 //-----------------------------------------------------------------------------
150 //-----------------------------------------------------------------------------
154 wxFrame
*frame
= new MyFrame();