Skip to content

Commit 0a1ff58

Browse files
committed
Fixed initial aspect ratio of plot in wxPLViewer
1 parent 8ec8573 commit 0a1ff58

4 files changed

Lines changed: 33 additions & 4 deletions

File tree

drivers/wxwidgets_dev.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,8 @@ wxPLDevice::wxPLDevice( PLStream *pls, char * mfo, PLINT text, PLINT hrshsym )
113113
else
114114
//assume we will be outputting to the default
115115
//memory map until we are given a dc to draw to
116-
//strcpy(m_mfo, "plplotMemoryMap");
117-
strcpy( m_mfo, "plplotMemoryMap??????????" );
116+
strcpy(m_mfo, "plplotMemoryMap");
117+
//strcpy( m_mfo, "plplotMemoryMap??????????" );
118118

119119
// be verbose and write out debug messages
120120
#ifdef _DEBUG

utils/wxplframe.cpp

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,10 +184,31 @@ void wxPlFrame::OnCheckTimer( wxTimerEvent &event )
184184
}
185185
void wxPlFrame::OnToggleFixAspect( wxCommandEvent &event )
186186
{
187-
m_stream.SetFixedAspectRatio( event.IsChecked() );
188-
if ( !event.IsChecked() )
187+
fixAspect( event.IsChecked() );
188+
}
189+
190+
void wxPlFrame::fixAspect( bool fix )
191+
{
192+
m_stream.SetFixedAspectRatio( fix );
193+
if ( !fix )
189194
this->Refresh();
190195
}
196+
void wxPlFrame::SetClientSize ( int width, int height )
197+
{
198+
wxFrame::SetClientSize( width, height );
199+
m_stream.SetSize( width, height );
200+
}
201+
202+
void wxPlFrame::SetClientSize ( const wxSize &size )
203+
{
204+
SetClientSize( size.GetWidth(), size.GetHeight() );
205+
}
206+
207+
void wxPlFrame::SetClientSize ( const wxRect &rect )
208+
{
209+
SetClientSize( rect.GetWidth(), rect.GetHeight() );
210+
}
211+
191212
void wxPlFrame::OnNextPage( wxCommandEvent& event )
192213
{
193214
SetPageAndUpdate( m_viewingPage + 1 );

utils/wxplframe.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,12 @@ class wxPlFrame : public wxPLplotwindow<wxFrame>
4545
const wxPoint &pos = wxDefaultPosition, const wxSize &size = wxDefaultSize, long style = wxDEFAULT_FRAME_STYLE,
4646
const wxString &name = wxFrameNameStr );
4747
~wxPlFrame();
48+
void fixAspect( bool fix );
49+
//overloads of SetClientSize that ensure the wxStream size is changed
50+
//immediately
51+
void SetClientSize ( int width, int height );
52+
void SetClientSize ( const wxSize &size );
53+
void SetClientSize ( const wxRect &rect );
4854
private:
4955
void setupMenus();
5056
void OnExit( wxCommandEvent& event );

utils/wxplviewer.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,9 @@ bool wxPlViewerApp::OnInit()
5959
#endif
6060
wxPlFrame* frame = new wxPlFrame( NULL, wxID_ANY, wxT( "wxPlViewer" ), file,
6161
PLINT( fileSize ), wxDefaultPosition, wxDefaultSize );
62+
frame->fixAspect( false );
6263
frame->SetClientSize( width, height );
64+
frame->fixAspect( true );
6365
frame->Show();
6466
return true;
6567
}

0 commit comments

Comments
 (0)