Layout fixes for wxPlotWindow [#1192416] + source cleaning to the wxW 2.6 coding starndards.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@33941 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -1,11 +1,13 @@
|
||||
/*
|
||||
* Program: wxPlotWindow
|
||||
*
|
||||
* Author: Robert Roebling
|
||||
*
|
||||
* Copyright: (C) 1999, Robert Roebling
|
||||
*
|
||||
*/
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: plot.cpp
|
||||
// Purpose: wxPlotWindow sample
|
||||
// Author: Robert Roebling
|
||||
// Modified by:
|
||||
// Created:
|
||||
// Copyright: (C) 1999, Robert Roebling
|
||||
// RCS-ID: $Id$
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// For compilers that support precompilation, includes "wx/wx.h".
|
||||
#include "wx/wxprec.h"
|
||||
@@ -25,8 +27,7 @@
|
||||
#include "wx/sizer.h"
|
||||
#include "wx/log.h"
|
||||
#include "wx/intl.h"
|
||||
|
||||
#include <math.h>
|
||||
#include "wx/math.h"
|
||||
|
||||
// derived classes
|
||||
|
||||
@@ -39,16 +40,16 @@ class MyApp;
|
||||
class MyPlotCurve: public wxPlotCurve
|
||||
{
|
||||
public:
|
||||
MyPlotCurve( int offsetY, double startY, double endY ) :
|
||||
MyPlotCurve( int offsetY, double startY, double endY ) :
|
||||
wxPlotCurve( offsetY, startY, endY ) {}
|
||||
|
||||
|
||||
virtual wxInt32 GetStartX()
|
||||
{ return 0; }
|
||||
virtual wxInt32 GetEndX()
|
||||
{ return 7000; }
|
||||
|
||||
|
||||
virtual double GetY( wxInt32 x )
|
||||
{
|
||||
{
|
||||
double dx = x;
|
||||
dx /= 100;
|
||||
return sin( dx );
|
||||
@@ -64,16 +65,17 @@ public:
|
||||
|
||||
void OnAbout( wxCommandEvent &event );
|
||||
void OnQuit( wxCommandEvent &event );
|
||||
|
||||
|
||||
void OnPlotClick( wxPlotEvent &event );
|
||||
void OnPlotDClick( wxPlotEvent &event );
|
||||
|
||||
private:
|
||||
|
||||
wxPlotWindow *m_plot;
|
||||
#if wxUSE_LOG
|
||||
wxTextCtrl *m_log;
|
||||
#endif // wxUSE_LOG
|
||||
|
||||
private:
|
||||
DECLARE_DYNAMIC_CLASS(MyFrame)
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
@@ -92,30 +94,30 @@ IMPLEMENT_APP(MyApp)
|
||||
|
||||
// MyFrame
|
||||
|
||||
const int ID_QUIT = 108;
|
||||
const int ID_ABOUT = 109;
|
||||
|
||||
IMPLEMENT_DYNAMIC_CLASS( MyFrame, wxFrame )
|
||||
|
||||
BEGIN_EVENT_TABLE(MyFrame,wxFrame)
|
||||
EVT_MENU (ID_ABOUT, MyFrame::OnAbout)
|
||||
EVT_MENU (ID_QUIT, MyFrame::OnQuit)
|
||||
EVT_PLOT_CLICKED ( -1, MyFrame::OnPlotClick)
|
||||
EVT_PLOT_DOUBLECLICKED ( -1, MyFrame::OnPlotDClick)
|
||||
EVT_MENU (wxID_ABOUT, MyFrame::OnAbout)
|
||||
EVT_MENU (wxID_EXIT, MyFrame::OnQuit)
|
||||
EVT_PLOT_CLICKED (wxID_ANY, MyFrame::OnPlotClick)
|
||||
EVT_PLOT_DOUBLECLICKED (wxID_ANY, MyFrame::OnPlotDClick)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
MyFrame::MyFrame()
|
||||
: wxFrame( (wxFrame *)NULL, -1, _T("wxPlotWindow sample"),
|
||||
: wxFrame( (wxFrame *)NULL, wxID_ANY, _T("wxPlotWindow sample"),
|
||||
wxPoint(20,20), wxSize(470,500) )
|
||||
{
|
||||
wxMenu *file_menu = new wxMenu();
|
||||
file_menu->Append( ID_ABOUT, _T("&About.."));
|
||||
file_menu->Append( ID_QUIT, _T("E&xit\tAlt-X"));
|
||||
wxMenu *fileMenu = new wxMenu();
|
||||
fileMenu->Append( wxID_EXIT, _T("E&xit\tAlt-X"), _T("Quit this program"));
|
||||
|
||||
wxMenuBar *menu_bar = new wxMenuBar();
|
||||
menu_bar->Append(file_menu, _T("&File"));
|
||||
wxMenu *helpMenu = new wxMenu;
|
||||
helpMenu->Append(wxID_ABOUT, _T("&About...\tF1"), _T("Show about dialog"));
|
||||
|
||||
SetMenuBar( menu_bar );
|
||||
wxMenuBar *menuBar = new wxMenuBar();
|
||||
menuBar->Append(fileMenu, _T("&File"));
|
||||
menuBar->Append(helpMenu, _T("&Help"));
|
||||
|
||||
SetMenuBar( menuBar );
|
||||
|
||||
#if wxUSE_STATUSBAR
|
||||
CreateStatusBar(2);
|
||||
@@ -123,9 +125,9 @@ MyFrame::MyFrame()
|
||||
SetStatusWidths( 2, widths );
|
||||
#endif // wxUSE_STATUSBAR
|
||||
|
||||
m_plot = new wxPlotWindow( this, -1, wxPoint(0,0), wxSize(100,100), wxSUNKEN_BORDER | wxPLOT_DEFAULT );
|
||||
m_plot = new wxPlotWindow( this, wxID_ANY, wxPoint(0,0), wxSize(100,100), wxSUNKEN_BORDER | wxPLOT_DEFAULT );
|
||||
m_plot->SetUnitsPerValue( 0.01 );
|
||||
// m_plot->SetScrollOnThumbRelease( TRUE );
|
||||
// m_plot->SetScrollOnThumbRelease( true );
|
||||
|
||||
m_plot->Add( new MyPlotCurve( 0, -1.5, 1.5 ) );
|
||||
m_plot->Add( new MyPlotCurve( 50, -1.5, 1.5 ) );
|
||||
@@ -135,15 +137,15 @@ MyFrame::MyFrame()
|
||||
oo->Add( 100, 400 );
|
||||
oo->Add( 1000, 2000 );
|
||||
m_plot->Add( oo );
|
||||
|
||||
|
||||
#if wxUSE_LOG
|
||||
m_log = new wxTextCtrl( this, -1, _T("This is the log window.\n"), wxPoint(0,0), wxSize(100,100), wxTE_MULTILINE );
|
||||
m_log = new wxTextCtrl( this, wxID_ANY, _T("This is the log window.\n"), wxPoint(0,0), wxSize(100,100), wxTE_MULTILINE );
|
||||
wxLog *old_log = wxLog::SetActiveTarget( new wxLogTextCtrl( m_log ) );
|
||||
delete old_log;
|
||||
#endif // wxUSE_LOG
|
||||
|
||||
|
||||
wxBoxSizer *topsizer = new wxBoxSizer( wxVERTICAL );
|
||||
|
||||
|
||||
topsizer->Add( m_plot, 1, wxEXPAND );
|
||||
#if wxUSE_LOG
|
||||
topsizer->Add( m_log, 0, wxEXPAND );
|
||||
@@ -151,18 +153,20 @@ MyFrame::MyFrame()
|
||||
|
||||
SetAutoLayout( true );
|
||||
SetSizer( topsizer );
|
||||
topsizer->Fit(this);
|
||||
topsizer->SetSizeHints(this);
|
||||
}
|
||||
|
||||
void MyFrame::OnQuit( wxCommandEvent &WXUNUSED(event) )
|
||||
{
|
||||
Close( true );
|
||||
Close( true );
|
||||
}
|
||||
|
||||
void MyFrame::OnAbout( wxCommandEvent &WXUNUSED(event) )
|
||||
{
|
||||
(void)wxMessageBox( _T("wxPlotWindow Demo\n")
|
||||
_T("Robert Roebling (c) 1999,2000"),
|
||||
_T("About wxPlotWindow Demo"), wxICON_INFORMATION | wxOK );
|
||||
(void)wxMessageBox( _T("wxPlotWindow Demo\n")
|
||||
_T("Robert Roebling (c) 1999,2000"),
|
||||
_T("About wxPlotWindow Demo"), wxICON_INFORMATION | wxOK );
|
||||
}
|
||||
|
||||
void MyFrame::OnPlotClick( wxPlotEvent &event )
|
||||
@@ -186,8 +190,8 @@ void MyFrame::OnPlotDClick( wxPlotEvent &event )
|
||||
bool MyApp::OnInit()
|
||||
{
|
||||
wxFrame *frame = new MyFrame();
|
||||
frame->Show( TRUE );
|
||||
frame->Show( true );
|
||||
|
||||
return TRUE;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user