+void wxPreviewControlBar::DoZoomOut()
+{
+ if (IsZoomOutEnabled())
+ {
+ m_zoomControl->SetSelection(m_zoomControl->GetSelection() - 1);
+ DoZoom();
+ }
+}
+
+namespace
+{
+
+// Helper class used by wxPreviewControlBar::CreateButtons() to add buttons
+// sequentially to it in the simplest way possible.
+class SizerWithButtons
+{
+public:
+ // Constructor creates the sizer that will hold the buttons and stores the
+ // parent that will be used for their creation.
+ SizerWithButtons(wxWindow *parent)
+ : m_sizer(new wxBoxSizer(wxHORIZONTAL)),
+ m_parent(parent)
+ {
+ m_hasContents =
+ m_needsSeparator = false;
+ }
+
+ // Destructor associates the sizer with the parent window.
+ ~SizerWithButtons()
+ {
+ m_parent->SetSizer(m_sizer);
+ m_sizer->Fit(m_parent);
+ }
+
+
+ // Add an arbitrary window to the sizer.
+ void Add(wxWindow *win)
+ {
+ if ( m_needsSeparator )
+ {
+ m_needsSeparator = false;
+
+ m_sizer->AddSpacer(2*wxSizerFlags::GetDefaultBorder());
+ }
+
+ m_hasContents = true;
+
+ m_sizer->Add(win,
+ wxSizerFlags().Border(wxLEFT | wxTOP | wxBOTTOM).Center());
+ }
+
+ // Add a button with the specified id, bitmap and tooltip.
+ void AddButton(wxWindowID btnId,
+ const wxArtID& artId,
+ const wxString& tooltip)
+ {
+ // We don't use (smaller) images inside a button with a text label but
+ // rather toolbar-like bitmap buttons hence use wxART_TOOLBAR and not
+ // wxART_BUTTON here.
+ wxBitmap bmp = wxArtProvider::GetBitmap(artId, wxART_TOOLBAR);
+ wxBitmapButton * const btn = new wxBitmapButton(m_parent, btnId, bmp);
+ btn->SetToolTip(tooltip);
+
+ Add(btn);
+ }
+
+ // Add a control at the right end of the window. This should be called last
+ // as everything else added after it will be added on the right side too.
+ void AddAtEnd(wxWindow *win)
+ {
+ m_sizer->AddStretchSpacer();
+ m_sizer->Add(win,
+ wxSizerFlags().Border(wxTOP | wxBOTTOM | wxRIGHT).Center());
+ }
+
+ // Indicates the end of a group of buttons, a separator will be added after
+ // it.
+ void EndOfGroup()
+ {
+ if ( m_hasContents )
+ {
+ m_needsSeparator = true;
+ m_hasContents = false;
+ }
+ }
+
+private:
+ wxSizer * const m_sizer;
+ wxWindow * const m_parent;
+
+ // If true, we have some controls since the last group beginning. This is
+ // used to avoid inserting two consecutive separators if EndOfGroup() is
+ // called twice.
+ bool m_hasContents;
+
+ // If true, a separator should be inserted before adding the next button.
+ bool m_needsSeparator;
+
+ wxDECLARE_NO_COPY_CLASS(SizerWithButtons);
+};
+
+} // anonymous namespace
+
+void wxPreviewControlBar::CreateButtons()
+{
+ SizerWithButtons sizer(this);
+
+ // Print button group (a single button).
+ if (m_buttonFlags & wxPREVIEW_PRINT)
+ {
+ sizer.AddButton(wxID_PREVIEW_PRINT, wxART_PRINT, _("Print"));
+ sizer.EndOfGroup();
+ }