| 1 |
/* Copyright (C) 1998-2002 The gtkmm Development Team |
| 2 |
* |
| 3 |
* This library is free software; you can redistribute it and/or |
| 4 |
* modify it under the terms of the GNU Lesser General Public |
| 5 |
* License as published by the Free Software Foundation; either |
| 6 |
* version 2.1 of the License, or (at your option) any later version. |
| 7 |
* |
| 8 |
* This library is distributed in the hope that it will be useful, |
| 9 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 11 |
* Lesser General Public License for more details. |
| 12 |
* |
| 13 |
* You should have received a copy of the GNU Lesser General Public |
| 14 |
* License along with this library; if not, see <https://www.gnu.org/licenses/>. |
| 15 |
*/ |
| 16 |
|
| 17 |
#include <gtkmm/bin.h> |
| 18 |
_DEFS(gtkmm,gtk) |
| 19 |
_PINCLUDE(gtkmm/private/bin_p.h) |
| 20 |
|
| 21 |
namespace Gtk |
| 22 |
{ |
| 23 |
|
| 24 |
class GTKMM_API Adjustment; |
| 25 |
class GTKMM_API Scrollbar; |
| 26 |
|
| 27 |
/** Adds scrollbars to its child widget. |
| 28 |
* |
| 29 |
* This container accepts a single child widget and makes that child scrollable |
| 30 |
* using either internally added scrollbars or externally associated adjustments. |
| 31 |
* |
| 32 |
* Widgets with native scrolling support, i.e. those whose classes implement the |
| 33 |
* Gtk::Scrollable interface, are added directly. For other types of widget, the |
| 34 |
* class Gtk::Viewport acts as an adaptor, giving scrollability to other widgets. |
| 35 |
* %Gtk::ScrolledWindow’s implementation of Gtk::Container::add() intelligently |
| 36 |
* accounts for whether or not the added child is a %Gtk::Scrollable. If it isn’t, |
| 37 |
* %Gtk::ScrolledWindow wraps the child in a %Gtk::Viewport and adds that for you. |
| 38 |
* Therefore, you can just add any child widget and not worry about the details. |
| 39 |
* |
| 40 |
* Unless property_hscrollbar_policy() and property_vscrollbar_policy() are |
| 41 |
* Gtk::POLICY_NEVER or Gtk::POLICY_EXTERNAL, |
| 42 |
* %Gtk::ScrolledWindow adds internal Gtk::Scrollbar widgets around its child. The |
| 43 |
* scroll position of the child, and if applicable the scrollbars, is controlled |
| 44 |
* by the property_hadjustment() and property_vadjustment() |
| 45 |
* that are associated with the %Gtk::ScrolledWindow. See the docs on Gtk::Scrollbar |
| 46 |
* for the details, but note that the “step_increment” and “page_increment” |
| 47 |
* fields are only effective if the policy causes scrollbars to be present. |
| 48 |
* |
| 49 |
* If a %Gtk::ScrolledWindow doesn’t behave quite as you would like, or |
| 50 |
* doesn’t have exactly the right layout, it’s very possible to set up |
| 51 |
* your own scrolling with Gtk::Scrollbar and for example a Gtk::Grid. |
| 52 |
* |
| 53 |
* # Touch support |
| 54 |
* |
| 55 |
* %Gtk::ScrolledWindow has built-in support for touch devices. When a |
| 56 |
* touchscreen is used, swiping will move the scrolled window, and will |
| 57 |
* expose 'kinetic' behavior. This can be turned off with |
| 58 |
* property_kinetic_scrolling() if it is undesired. |
| 59 |
* |
| 60 |
* %Gtk::ScrolledWindow also displays visual 'overshoot' indication when |
| 61 |
* the content is pulled beyond the end, and this situation can be |
| 62 |
* captured with signal_edge_overshot(). |
| 63 |
* |
| 64 |
* If no mouse device is present, the scrollbars will be overlayed as |
| 65 |
* narrow, auto-hiding indicators over the content. If traditional |
| 66 |
* scrollbars are desired although no mouse is present, this behavior |
| 67 |
* can be turned off with property_overlay_scrolling(). |
| 68 |
* |
| 69 |
* @ingroup Widgets |
| 70 |
* @ingroup Containers |
| 71 |
*/ |
| 72 |
class GTKMM_API ScrolledWindow : public Bin |
| 73 |
{ |
| 74 |
_CLASS_GTKOBJECT(ScrolledWindow,GtkScrolledWindow,GTK_SCROLLED_WINDOW,Gtk::Bin,GtkBin,,,GTKMM_API) |
| 75 |
|
| 76 |
public: |
| 77 |
_CTOR_DEFAULT |
| 78 |
_WRAP_CTOR(ScrolledWindow(const Glib::RefPtr<Adjustment>& hadjustment, const Glib::RefPtr<Adjustment>& vadjustment), gtk_scrolled_window_new) |
| 79 |
|
| 80 |
//TODO: Add unset_*adjustment(). |
| 81 |
//But the C API does not do that. murrayc. |
| 82 |
_WRAP_METHOD(void set_hadjustment(const Glib::RefPtr<Adjustment>& hadjustment), gtk_scrolled_window_set_hadjustment) |
| 83 |
_WRAP_METHOD(void set_vadjustment(const Glib::RefPtr<Adjustment>& vadjustment), gtk_scrolled_window_set_vadjustment) |
| 84 |
|
| 85 |
_WRAP_METHOD(Glib::RefPtr<Adjustment> get_hadjustment(), gtk_scrolled_window_get_hadjustment, refreturn) |
| 86 |
_WRAP_METHOD(Glib::RefPtr<const Adjustment> get_hadjustment() const, gtk_scrolled_window_get_hadjustment, refreturn, constversion) |
| 87 |
_WRAP_METHOD(Glib::RefPtr<Adjustment> get_vadjustment(), gtk_scrolled_window_get_vadjustment, refreturn) |
| 88 |
_WRAP_METHOD(Glib::RefPtr<const Adjustment> get_vadjustment() const, gtk_scrolled_window_get_vadjustment, refreturn, constversion) |
| 89 |
|
| 90 |
_WRAP_METHOD(void set_policy(PolicyType hscrollbar_policy, PolicyType vscrollbar_policy), gtk_scrolled_window_set_policy) |
| 91 |
_WRAP_METHOD(void get_policy(PolicyType& hscrollbar_policy, PolicyType& vscrollbar_policy) const, gtk_scrolled_window_get_policy) |
| 92 |
|
| 93 |
_WRAP_METHOD(void set_placement(CornerType window_placement), gtk_scrolled_window_set_placement) |
| 94 |
_WRAP_METHOD(void unset_placement(), gtk_scrolled_window_unset_placement) |
| 95 |
_WRAP_METHOD(CornerType get_placement() const, gtk_scrolled_window_get_placement) |
| 96 |
|
| 97 |
_WRAP_METHOD(void set_shadow_type(ShadowType type), gtk_scrolled_window_set_shadow_type) |
| 98 |
_WRAP_METHOD(ShadowType get_shadow_type() const, gtk_scrolled_window_get_shadow_type) |
| 99 |
|
| 100 |
///Puts the child inside a Gtk::Viewport if it doesn't have native scrolling capability. |
| 101 |
void add(Gtk::Widget& widget) override; |
| 102 |
_IGNORE(gtk_scrolled_window_add_with_viewport) |
| 103 |
|
| 104 |
_DEPRECATE_IFDEF_START |
| 105 |
/** Removes the contained widget, possibly also a Gtk::Viewport. |
| 106 |
* Since this can only hold one widget it is not necessary to specify which |
| 107 |
* widget to remove, like containers that don't derive from Gtk::Bin. |
| 108 |
* |
| 109 |
* This method is useful if you have added a widget without native scrolling |
| 110 |
* capability, and ScrolledWindow::add() has created a Gtk::Viewport. |
| 111 |
* |
| 112 |
* If the child of the ScrolledWindow is a Gtk::Viewport that was created by add(), |
| 113 |
* remove_with_viewport() removes the Viewport's child from the Viewport, |
| 114 |
* and removes the Viewport from the ScrolledWindow. The Viewport is destroyed. |
| 115 |
* |
| 116 |
* @newin{3,8} |
| 117 |
* @deprecated Use Bin::remove() instead. It's now identical to remove_with_viewport(). |
| 118 |
*/ |
| 119 |
void remove_with_viewport(); |
| 120 |
_DEPRECATE_IFDEF_END |
| 121 |
|
| 122 |
#m4 _CONVERSION(`GtkWidget*',`Scrollbar*',`Glib::wrap((GtkScrollbar*)$3)') |
| 123 |
#m4 _CONVERSION(`GtkWidget*',`const Scrollbar*',`Glib::wrap((GtkScrollbar*)$3)') |
| 124 |
_WRAP_METHOD(Scrollbar* get_vscrollbar(), gtk_scrolled_window_get_vscrollbar) |
| 125 |
_WRAP_METHOD(const Scrollbar* get_vscrollbar() const, gtk_scrolled_window_get_vscrollbar) |
| 126 |
|
| 127 |
_WRAP_METHOD(Scrollbar* get_hscrollbar(), gtk_scrolled_window_get_hscrollbar) |
| 128 |
_WRAP_METHOD(const Scrollbar* get_hscrollbar() const, gtk_scrolled_window_get_hscrollbar) |
| 129 |
|
| 130 |
_WRAP_METHOD(int get_min_content_width() const, gtk_scrolled_window_get_min_content_width) |
| 131 |
_WRAP_METHOD(void set_min_content_width(int width), gtk_scrolled_window_set_min_content_width) |
| 132 |
_WRAP_METHOD(int get_min_content_height() const, gtk_scrolled_window_get_min_content_height) |
| 133 |
_WRAP_METHOD(void set_min_content_height(int height), gtk_scrolled_window_set_min_content_height) |
| 134 |
|
| 135 |
_WRAP_METHOD(void set_kinetic_scrolling(bool kinetic_scrolling = true), gtk_scrolled_window_set_kinetic_scrolling) |
| 136 |
_WRAP_METHOD(bool get_kinetic_scrolling() const, gtk_scrolled_window_get_kinetic_scrolling) |
| 137 |
|
| 138 |
_WRAP_METHOD(void set_capture_button_press(bool capture_button_press), gtk_scrolled_window_set_capture_button_press) |
| 139 |
_WRAP_METHOD(bool get_capture_button_press() const, gtk_scrolled_window_get_capture_button_press) |
| 140 |
|
| 141 |
_WRAP_METHOD(void set_overlay_scrolling(bool overlay_scrolling = true), gtk_scrolled_window_set_overlay_scrolling) |
| 142 |
_WRAP_METHOD(bool get_overlay_scrolling() const, gtk_scrolled_window_get_overlay_scrolling) |
| 143 |
|
| 144 |
_WRAP_METHOD(void set_max_content_width(int width), gtk_scrolled_window_set_max_content_width) |
| 145 |
_WRAP_METHOD(int get_max_content_width() const, gtk_scrolled_window_get_max_content_width) |
| 146 |
_WRAP_METHOD(void set_max_content_height(int height), gtk_scrolled_window_set_max_content_height) |
| 147 |
_WRAP_METHOD(int get_max_content_height() const, gtk_scrolled_window_get_max_content_height) |
| 148 |
|
| 149 |
_WRAP_METHOD(void set_propagate_natural_width(bool propagate = true), gtk_scrolled_window_set_propagate_natural_width) |
| 150 |
_WRAP_METHOD(bool get_propagate_natural_width() const, gtk_scrolled_window_get_propagate_natural_width) |
| 151 |
_WRAP_METHOD(void set_propagate_natural_height(bool propagate = true), gtk_scrolled_window_set_propagate_natural_height) |
| 152 |
_WRAP_METHOD(bool get_propagate_natural_height() const, gtk_scrolled_window_get_propagate_natural_height) |
| 153 |
|
| 154 |
//Keybinding signals: |
| 155 |
_IGNORE_SIGNAL("scroll_child") |
| 156 |
_IGNORE_SIGNAL("move_focus_out") |
| 157 |
|
| 158 |
// no_default_handler because the wrapped C signals have no default handlers. |
| 159 |
_WRAP_SIGNAL(void edge_overshot(Gtk::PositionType pos), "edge-overshot", no_default_handler) |
| 160 |
_WRAP_SIGNAL(void edge_reached(Gtk::PositionType pos), "edge-reached", no_default_handler) |
| 161 |
|
| 162 |
_WRAP_PROPERTY("hadjustment", Glib::RefPtr<Adjustment>) |
| 163 |
_WRAP_PROPERTY("vadjustment", Glib::RefPtr<Adjustment>) |
| 164 |
_WRAP_PROPERTY("hscrollbar-policy", PolicyType) |
| 165 |
_WRAP_PROPERTY("vscrollbar-policy", PolicyType) |
| 166 |
_WRAP_PROPERTY("window-placement", CornerType) |
| 167 |
_WRAP_PROPERTY("window-placement-set", bool, deprecated "This value is ignored and the property_window_placement() value is always honored.") |
| 168 |
_WRAP_PROPERTY("shadow-type", ShadowType) |
| 169 |
_WRAP_PROPERTY("min-content-width", int) |
| 170 |
_WRAP_PROPERTY("min-content-height", int) |
| 171 |
_WRAP_PROPERTY("kinetic-scrolling", bool) |
| 172 |
_WRAP_PROPERTY("overlay-scrolling", bool) |
| 173 |
_WRAP_PROPERTY("max-content-width", int) |
| 174 |
_WRAP_PROPERTY("max-content-height", int) |
| 175 |
_WRAP_PROPERTY("propagate-natural-width", bool) |
| 176 |
_WRAP_PROPERTY("propagate-natural-height", bool) |
| 177 |
}; |
| 178 |
|
| 179 |
} //namespace Gtk |