Use reasonable size for wxPreviewFrame by default

Give a reasonable default size to wxPreviewCanvas and fit wxPreviewFrame
to its contents.

Remove the useless call to Fit() from SizerWithButtons: the size set
inside it was just ignored anyhow.

This also allows to stop hardcoding the size in the sample, so don't do
this any more.

See #22439.
This commit is contained in:
Vadim Zeitlin
2022-05-19 17:57:03 +02:00
parent 93a6784c5f
commit f0de5a93f8
2 changed files with 7 additions and 5 deletions

View File

@@ -390,8 +390,7 @@ void MyFrame::OnPrintPreview(wxCommandEvent& WXUNUSED(event))
return;
}
wxPreviewFrame *frame =
new wxPreviewFrame(preview, this, "Demo Print Preview", wxDefaultPosition, FromDIP(wxSize(600, 700)));
wxPreviewFrame *frame = new wxPreviewFrame(preview, this, "Demo Print Preview");
frame->Centre(wxBOTH);
frame->InitializeWithModality(m_previewModality);
frame->Show();
@@ -425,8 +424,7 @@ void MyFrame::OnPrintPreviewPS(wxCommandEvent& WXUNUSED(event))
// Pass two printout objects: for preview, and possible printing.
wxPrintDialogData printDialogData(* g_printData);
wxPrintPreview *preview = new wxPrintPreview(new MyPrintout(this), new MyPrintout(this), &printDialogData);
wxPreviewFrame *frame =
new wxPreviewFrame(preview, this, "Demo Print Preview", wxDefaultPosition, FromDIP(wxSize(600, 700)));
wxPreviewFrame *frame = new wxPreviewFrame(preview, this, "Demo Print Preview");
frame->Centre(wxBOTH);
frame->Initialize();
frame->Show();

View File

@@ -936,6 +936,10 @@ wxScrolledWindow(parent, wxID_ANY, pos, size, style | wxFULL_REPAINT_ON_RESIZE,
SetBackgroundColour(wxSystemSettings::GetColour(colourIndex));
SetScrollbars(10, 10, 100, 100);
// Use some reasonable default size for this window, roughly proportional
// to the paper sheet.
SetInitialSize(wxSize(600, 750));
}
wxPreviewCanvas::~wxPreviewCanvas()
@@ -1486,7 +1490,6 @@ public:
~SizerWithButtons()
{
m_parent->SetSizer(m_sizer);
m_sizer->Fit(m_parent);
}
@@ -1766,6 +1769,7 @@ void wxPreviewFrame::InitializeWithModality(wxPreviewFrameModalityKind kind)
sizer->Add( m_previewCanvas, wxSizerFlags(1).Expand().Border() );
SetSizer( sizer );
sizer->Fit(this);
m_modalityKind = kind;
switch ( m_modalityKind )