1 /* 2 * This file is part of gtkD. 3 * 4 * gtkD is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU Lesser General Public License 6 * as published by the Free Software Foundation; either version 3 7 * of the License, or (at your option) any later version, with 8 * some exceptions, please read the COPYING file. 9 * 10 * gtkD is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU Lesser General Public License for more details. 14 * 15 * You should have received a copy of the GNU Lesser General Public License 16 * along with gtkD; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA 18 */ 19 20 // generated automatically - do not change 21 // find conversion definition on APILookup.txt 22 // implement new conversion functionalities on the wrap.utils pakage 23 24 25 module gtk.GridView; 26 27 private import glib.ConstructionException; 28 private import gobject.ObjectG; 29 private import gobject.Signals; 30 private import gtk.ListBase; 31 private import gtk.ListItemFactory; 32 private import gtk.SelectionModelIF; 33 private import gtk.Widget; 34 private import gtk.c.functions; 35 public import gtk.c.types; 36 private import std.algorithm; 37 38 39 /** 40 * `GtkGridView` presents a large dynamic grid of items. 41 * 42 * `GtkGridView` uses its factory to generate one child widget for each 43 * visible item and shows them in a grid. The orientation of the grid view 44 * determines if the grid reflows vertically or horizontally. 45 * 46 * `GtkGridView` allows the user to select items according to the selection 47 * characteristics of the model. For models that allow multiple selected items, 48 * it is possible to turn on _rubberband selection_, using 49 * [property@Gtk.GridView:enable-rubberband]. 50 * 51 * To learn more about the list widget framework, see the 52 * [overview](section-list-widget.html). 53 * 54 * # CSS nodes 55 * 56 * ``` 57 * gridview 58 * ├── child 59 * │ 60 * ├── child 61 * │ 62 * ┊ 63 * ╰── [rubberband] 64 * ``` 65 * 66 * `GtkGridView` uses a single CSS node with name gridview. Each child 67 * uses a single CSS node with name child. For rubberband selection, 68 * a subnode with name rubberband is used. 69 * 70 * # Accessibility 71 * 72 * `GtkGridView` uses the %GTK_ACCESSIBLE_ROLE_GRID role, and the items 73 * use the %GTK_ACCESSIBLE_ROLE_GRID_CELL role. 74 */ 75 public class GridView : ListBase 76 { 77 /** the main Gtk struct */ 78 protected GtkGridView* gtkGridView; 79 80 /** Get the main Gtk struct */ 81 public GtkGridView* getGridViewStruct(bool transferOwnership = false) 82 { 83 if (transferOwnership) 84 ownedRef = false; 85 return gtkGridView; 86 } 87 88 /** the main Gtk struct as a void* */ 89 protected override void* getStruct() 90 { 91 return cast(void*)gtkGridView; 92 } 93 94 /** 95 * Sets our main struct and passes it to the parent class. 96 */ 97 public this (GtkGridView* gtkGridView, bool ownedRef = false) 98 { 99 this.gtkGridView = gtkGridView; 100 super(cast(GtkListBase*)gtkGridView, ownedRef); 101 } 102 103 104 /** */ 105 public static GType getType() 106 { 107 return gtk_grid_view_get_type(); 108 } 109 110 /** 111 * Creates a new `GtkGridView` that uses the given @factory for 112 * mapping items to widgets. 113 * 114 * The function takes ownership of the 115 * arguments, so you can write code like 116 * ```c 117 * grid_view = gtk_grid_view_new (create_model (), 118 * gtk_builder_list_item_factory_new_from_resource ("/resource.ui")); 119 * ``` 120 * 121 * Params: 122 * model = the model to use, or %NULL 123 * factory = The factory to populate items with, or %NULL 124 * 125 * Returns: a new `GtkGridView` using the given @model and @factory 126 * 127 * Throws: ConstructionException GTK+ fails to create the object. 128 */ 129 public this(SelectionModelIF model, ListItemFactory factory) 130 { 131 auto __p = gtk_grid_view_new((model is null) ? null : model.getSelectionModelStruct(), (factory is null) ? null : factory.getListItemFactoryStruct()); 132 133 if(__p is null) 134 { 135 throw new ConstructionException("null returned by new"); 136 } 137 138 this(cast(GtkGridView*) __p); 139 } 140 141 /** 142 * Returns whether rows can be selected by dragging with the mouse. 143 * 144 * Returns: %TRUE if rubberband selection is enabled 145 */ 146 public bool getEnableRubberband() 147 { 148 return gtk_grid_view_get_enable_rubberband(gtkGridView) != 0; 149 } 150 151 /** 152 * Gets the factory that's currently used to populate list items. 153 * 154 * Returns: The factory in use 155 */ 156 public ListItemFactory getFactory() 157 { 158 auto __p = gtk_grid_view_get_factory(gtkGridView); 159 160 if(__p is null) 161 { 162 return null; 163 } 164 165 return ObjectG.getDObject!(ListItemFactory)(cast(GtkListItemFactory*) __p); 166 } 167 168 /** 169 * Gets the maximum number of columns that the grid will use. 170 * 171 * Returns: The maximum number of columns 172 */ 173 public uint getMaxColumns() 174 { 175 return gtk_grid_view_get_max_columns(gtkGridView); 176 } 177 178 /** 179 * Gets the minimum number of columns that the grid will use. 180 * 181 * Returns: The minimum number of columns 182 */ 183 public uint getMinColumns() 184 { 185 return gtk_grid_view_get_min_columns(gtkGridView); 186 } 187 188 /** 189 * Gets the model that's currently used to read the items displayed. 190 * 191 * Returns: The model in use 192 */ 193 public SelectionModelIF getModel() 194 { 195 auto __p = gtk_grid_view_get_model(gtkGridView); 196 197 if(__p is null) 198 { 199 return null; 200 } 201 202 return ObjectG.getDObject!(SelectionModelIF)(cast(GtkSelectionModel*) __p); 203 } 204 205 /** 206 * Returns whether items will be activated on single click and 207 * selected on hover. 208 * 209 * Returns: %TRUE if items are activated on single click 210 */ 211 public bool getSingleClickActivate() 212 { 213 return gtk_grid_view_get_single_click_activate(gtkGridView) != 0; 214 } 215 216 /** 217 * Sets whether selections can be changed by dragging with the mouse. 218 * 219 * Params: 220 * enableRubberband = %TRUE to enable rubberband selection 221 */ 222 public void setEnableRubberband(bool enableRubberband) 223 { 224 gtk_grid_view_set_enable_rubberband(gtkGridView, enableRubberband); 225 } 226 227 /** 228 * Sets the `GtkListItemFactory` to use for populating list items. 229 * 230 * Params: 231 * factory = the factory to use or %NULL for none 232 */ 233 public void setFactory(ListItemFactory factory) 234 { 235 gtk_grid_view_set_factory(gtkGridView, (factory is null) ? null : factory.getListItemFactoryStruct()); 236 } 237 238 /** 239 * Sets the maximum number of columns to use. 240 * 241 * This number must be at least 1. 242 * 243 * If @max_columns is smaller than the minimum set via 244 * [method@Gtk.GridView.set_min_columns], that value is used instead. 245 * 246 * Params: 247 * maxColumns = The maximum number of columns 248 */ 249 public void setMaxColumns(uint maxColumns) 250 { 251 gtk_grid_view_set_max_columns(gtkGridView, maxColumns); 252 } 253 254 /** 255 * Sets the minimum number of columns to use. 256 * 257 * This number must be at least 1. 258 * 259 * If @min_columns is smaller than the minimum set via 260 * [method@Gtk.GridView.set_max_columns], that value is ignored. 261 * 262 * Params: 263 * minColumns = The minimum number of columns 264 */ 265 public void setMinColumns(uint minColumns) 266 { 267 gtk_grid_view_set_min_columns(gtkGridView, minColumns); 268 } 269 270 /** 271 * Sets the imodel to use. 272 * 273 * This must be a [iface@Gtk.SelectionModel]. 274 * 275 * Params: 276 * model = the model to use or %NULL for none 277 */ 278 public void setModel(SelectionModelIF model) 279 { 280 gtk_grid_view_set_model(gtkGridView, (model is null) ? null : model.getSelectionModelStruct()); 281 } 282 283 /** 284 * Sets whether items should be activated on single click and 285 * selected on hover. 286 * 287 * Params: 288 * singleClickActivate = %TRUE to activate items on single click 289 */ 290 public void setSingleClickActivate(bool singleClickActivate) 291 { 292 gtk_grid_view_set_single_click_activate(gtkGridView, singleClickActivate); 293 } 294 295 /** 296 * Emitted when a cell has been activated by the user, 297 * usually via activating the GtkGridView|list.activate-item action. 298 * 299 * This allows for a convenient way to handle activation in a gridview. 300 * See [property@Gtk.ListItem:activatable] for details on how to use 301 * this signal. 302 * 303 * Params: 304 * position = position of item to activate 305 */ 306 gulong addOnActivate(void delegate(uint, GridView) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 307 { 308 return Signals.connect(this, "activate", dlg, connectFlags ^ ConnectFlags.SWAPPED); 309 } 310 }