- Added wxWrapSizer (Arne Steinarson).
- Added wxSpinCtrlDouble (John Labenski).
- Support custom labels in wxMessageDialog (Gareth Simpson for wxMac version).
+- Added wxScrolledWindow::ShowScrollbars().
- Also added wxCANCEL_DEFAULT to wxMessageDialog.
- Allow copying text in the log dialogs.
- Added multisample (anti-aliasing) support to wxGLCanvas (Olivier Playez).
int pixelsPerLine,
int *posOld);
+ // implement the base class methods
virtual void DoScroll(int x, int y);
+ virtual void DoShowScrollbars(wxScrollbarVisibility horz,
+ wxScrollbarVisibility vert);
private:
DECLARE_NO_COPY_CLASS(wxScrollHelperNative)
// default scrolled window style: scroll in both directions
#define wxScrolledWindowStyle (wxHSCROLL | wxVSCROLL)
+// values for the second argument of wxScrollHelper::ShowScrollbars()
+enum wxScrollbarVisibility
+{
+ wxSHOW_SB_NEVER = -1, // never show the scrollbar at all
+ wxSHOW_SB_DEFAULT, // show scrollbar only if it is needed
+ wxSHOW_SB_ALWAYS // always show scrollbar, even if not needed
+};
+
// ----------------------------------------------------------------------------
// The hierarchy of scrolling classes is a bit complicated because we want to
// put as much functionality as possible in a mix-in class not deriving from
virtual void GetScrollPixelsPerUnit(int *pixelsPerUnitX,
int *pixelsPerUnitY) const;
+ // Set scrollbar visibility: it is possible to show scrollbar only if it is
+ // needed (i.e. if our virtual size is greater than the current size of the
+ // associated window), always (as wxALWAYS_SHOW_SB style does) or never (in
+ // which case you should provide some other way to scroll the window as the
+ // user wouldn't be able to do it at all)
+ void ShowScrollbars(wxScrollbarVisibility horz, wxScrollbarVisibility vert);
+
// Enable/disable Windows scrolling in either direction. If true, wxWidgets
// scrolls the canvas and only a bit of the canvas is invalidated; no
// Clear() is necessary. If false, the whole canvas is invalidated and a
// implementation of public methods with the same name
virtual void DoGetViewStart(int *x, int *y) const;
virtual void DoScroll(int x, int y);
+ virtual void DoShowScrollbars(wxScrollbarVisibility horz,
+ wxScrollbarVisibility vert);
// implementations of various wxWindow virtual methods which should be
// forwarded to us (this can be done by WX_FORWARD_TO_SCROLL_HELPER())
// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
+/**
+ Possible values for the second argument of wxScrolled::ShowScrollbars().
+ */
+enum wxScrollbarVisibility
+{
+ wxSHOW_SB_NEVER = -1, ///< Never show the scrollbar at all.
+ wxSHOW_SB_DEFAULT, ///< Show scrollbar only if it is needed.
+ wxSHOW_SB_ALWAYS ///< Always show scrollbar, even if not needed.
+};
+
/**
The wxScrolled class manages scrolling for its client area, transforming
*/
void EnableScrolling(bool xScrolling, bool yScrolling);
+ /**
+ Set the scrollbar visibility.
+
+ By default the scrollbar in the corresponding direction is only shown
+ if it is needed, i.e. if the virtual size of the scrolled window in
+ this direction is greater than the current physical window size. Using
+ this function the scrollbar visibility can be changed to be:
+ - wxSHOW_SB_ALWAYS: To always show the scrollbar, even if it is
+ not needed currently (wxALWAYS_SHOW_SB style can be used during
+ the window creation to achieve the same effect but it applies
+ in both directions).
+ - wxSHOW_SB_NEVER: To never show the scrollbar at all. In this case
+ the program should presumably provide some other way for the
+ user to scroll the window.
+ - wxSHOW_SB_DEFAULT: To restore the default behaviour described
+ above.
+
+ @param horz
+ The desired visibility for the horizontal scrollbar.
+ @param vert
+ The desired visibility for the vertical scrollbar.
+
+ @since 2.9.0
+ */
+ void ShowScrollbars(wxScrollbarVisibility horz, wxScrollbarVisibility vert);
+
/**
Get the number of pixels per scroll unit (line), in each direction, as
set by SetScrollbars(). A value of zero indicates no scrolling in that
void OnTestAuto(wxCommandEvent& WXUNUSED(event)) { new MyAutoFrame(this); }
void OnToggleSync(wxCommandEvent& event);
+ void OnToggleScrollbar(wxCommandEvent& event);
MyScrolledWindowBase *m_win1,
*m_win2;
const wxWindowID Scroll_Test_Auto = wxWindow::NewControlId();
const wxWindowID Scroll_TglBtn_Sync = wxWindow::NewControlId();
+const wxWindowID Scroll_TglBtn_Scrollbar = wxWindow::NewControlId();
BEGIN_EVENT_TABLE(MyFrame,wxFrame)
EVT_MENU(wxID_ABOUT, MyFrame::OnAbout)
EVT_MENU(Scroll_Test_Auto, MyFrame::OnTestAuto)
EVT_TOGGLEBUTTON(Scroll_TglBtn_Sync, MyFrame::OnToggleSync)
+ EVT_TOGGLEBUTTON(Scroll_TglBtn_Scrollbar, MyFrame::OnToggleScrollbar)
END_EVENT_TABLE()
MyFrame::MyFrame()
sizerScrollWin->Add(m_win2, flagsExpand);
topsizer->Add(sizerScrollWin, flagsExpand);
+ const wxSizerFlags flagsHBorder(wxSizerFlags().Border(wxLEFT | wxRIGHT));
+
wxSizer *sizerBtns = new wxBoxSizer(wxHORIZONTAL);
- sizerBtns->Add(new wxToggleButton(this, Scroll_TglBtn_Sync, "&Synchronize"));
+ sizerBtns->Add(new wxToggleButton(this, Scroll_TglBtn_Sync, "S&ynchronize"),
+ flagsHBorder);
+
+ wxToggleButton *btn =new wxToggleButton(this, Scroll_TglBtn_Scrollbar,
+ "&Show scrollbar");
+ btn->SetValue(true);
+ sizerBtns->Add(btn, flagsHBorder);
topsizer->Add(sizerBtns, wxSizerFlags().Centre().Border());
SetSizer(topsizer);
}
}
+void MyFrame::OnToggleScrollbar(wxCommandEvent& event)
+{
+ m_win1->ShowScrollbars(wxSHOW_SB_NEVER,
+ event.IsChecked() ? wxSHOW_SB_ALWAYS
+ : wxSHOW_SB_NEVER);
+}
+
void MyFrame::OnQuit(wxCommandEvent &WXUNUSED(event))
{
Close(true);
m_yScrollingEnabled = y_scroll;
}
+void wxScrollHelper::ShowScrollbars(wxScrollbarVisibility horz,
+ wxScrollbarVisibility vert)
+{
+ DoShowScrollbars(horz, vert);
+}
+
+void wxScrollHelper::DoShowScrollbars(wxScrollbarVisibility horz,
+ wxScrollbarVisibility vert)
+{
+ // TODO
+}
+
// Where the current view starts from
void wxScrollHelper::DoGetViewStart (int *x, int *y) const
{
DoScrollOneDir(wxHORIZONTAL, x_pos, m_xScrollPixelsPerLine, &m_xScrollPosition);
DoScrollOneDir(wxVERTICAL, y_pos, m_yScrollPixelsPerLine, &m_yScrollPosition);
}
+
+// ----------------------------------------------------------------------------
+// scrollbars visibility
+// ----------------------------------------------------------------------------
+
+namespace
+{
+
+GtkPolicyType GtkPolicyFromWX(wxScrollbarVisibility visibility)
+{
+ GtkPolicyType policy;
+ switch ( visibility )
+ {
+ case wxSHOW_SB_NEVER:
+ policy = GTK_POLICY_NEVER;
+ break;
+
+ case wxSHOW_SB_DEFAULT:
+ policy = GTK_POLICY_AUTOMATIC;
+ break;
+
+ case wxSHOW_SB_ALWAYS:
+ policy = GTK_POLICY_ALWAYS;
+ break;
+ }
+
+ return policy;
+}
+
+} // anonymous namespace
+
+void wxScrollHelperNative::DoShowScrollbars(wxScrollbarVisibility horz,
+ wxScrollbarVisibility vert)
+{
+ GtkScrolledWindow * const scrolled = GTK_SCROLLED_WINDOW(m_win->m_widget);
+ wxCHECK_RET( scrolled, "window must be created" );
+
+ gtk_scrolled_window_set_policy(scrolled,
+ GtkPolicyFromWX(horz),
+ GtkPolicyFromWX(vert));
+}
+