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 * Conversion parameters: 26 * inFile = GtkPaned.html 27 * outPack = gtk 28 * outFile = Paned 29 * strct = GtkPaned 30 * realStrct= 31 * ctorStrct= 32 * clss = Paned 33 * interf = 34 * class Code: Yes 35 * interface Code: No 36 * template for: 37 * extend = 38 * implements: 39 * - OrientableIF 40 * prefixes: 41 * - gtk_paned_ 42 * - gtk_ 43 * omit structs: 44 * omit prefixes: 45 * omit code: 46 * omit signals: 47 * imports: 48 * - gdk.Window 49 * - gtk.Widget 50 * - gtk.OrientableIF 51 * - gtk.OrientableT 52 * structWrap: 53 * - GdkWindow* -> Window 54 * - GtkWidget* -> Widget 55 * module aliases: 56 * local aliases: 57 * overrides: 58 */ 59 60 module gtk.Paned; 61 62 public import gtkc.gtktypes; 63 64 private import gtkc.gtk; 65 private import glib.ConstructionException; 66 private import gobject.ObjectG; 67 68 private import gobject.Signals; 69 public import gtkc.gdktypes; 70 71 private import gdk.Window; 72 private import gtk.Widget; 73 private import gtk.OrientableIF; 74 private import gtk.OrientableT; 75 76 77 78 private import gtk.Container; 79 80 /** 81 * Description 82 * GtkPaned is the base class for widgets with two panes, 83 * arranged either horizontally (GtkHPaned) or 84 * vertically (GtkVPaned). Child widgets are 85 * added to the panes of the widget with 86 * gtk_paned_pack1() and gtk_paned_pack2(). The division 87 * beween the two children is set by default from the 88 * size requests of the children, but it can be adjusted 89 * by the user. 90 * A paned widget draws a separator between the two 91 * child widgets and a small handle that the user 92 * can drag to adjust the division. It does not 93 * draw any relief around the children or around 94 * the separator. (The space in which the separator 95 * is called the gutter.) Often, it is useful 96 * to put each child inside a GtkFrame with the 97 * shadow type set to GTK_SHADOW_IN so that the 98 * gutter appears as a ridge. No separator is drawn 99 * if one of the children is missing. 100 * Each child has two options that can be set, 101 * resize and shrink. If resize is true, then when the 102 * GtkPaned is resized, that child will expand 103 * or shrink along with the paned widget. If shrink 104 * is true, then when that child can be made smaller 105 * than its requisition by the user. Setting shrink 106 * to FALSE allows the application to set a minimum 107 * size. If resize is false for both children, then 108 * this is treated as if resize is true for both 109 * children. 110 * The application can set the position of the slider 111 * as if it were set by the user, by calling 112 * gtk_paned_set_position(). 113 * $(DDOC_COMMENT example) 114 */ 115 public class Paned : Container, OrientableIF 116 { 117 118 /** the main Gtk struct */ 119 protected GtkPaned* gtkPaned; 120 121 122 public GtkPaned* getPanedStruct() 123 { 124 return gtkPaned; 125 } 126 127 128 /** the main Gtk struct as a void* */ 129 protected override void* getStruct() 130 { 131 return cast(void*)gtkPaned; 132 } 133 134 /** 135 * Sets our main struct and passes it to the parent class 136 */ 137 public this (GtkPaned* gtkPaned) 138 { 139 super(cast(GtkContainer*)gtkPaned); 140 this.gtkPaned = gtkPaned; 141 } 142 143 protected override void setStruct(GObject* obj) 144 { 145 super.setStruct(obj); 146 gtkPaned = cast(GtkPaned*)obj; 147 } 148 149 // add the Orientable capabilities 150 mixin OrientableT!(GtkPaned); 151 152 /** */ 153 public void add(Widget child1, Widget child2) 154 { 155 add1(child1); 156 add2(child2); 157 } 158 159 /** 160 */ 161 int[string] connectedSignals; 162 163 bool delegate(Paned)[] onAcceptPositionListeners; 164 /** 165 * The ::accept-position signal is a 166 * keybinding signal 167 * which gets emitted to accept the current position of the handle when 168 * moving it using key bindings. 169 * The default binding for this signal is Return or Space. 170 * Since 2.0 171 */ 172 void addOnAcceptPosition(bool delegate(Paned) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 173 { 174 if ( !("accept-position" in connectedSignals) ) 175 { 176 Signals.connectData( 177 getStruct(), 178 "accept-position", 179 cast(GCallback)&callBackAcceptPosition, 180 cast(void*)this, 181 null, 182 connectFlags); 183 connectedSignals["accept-position"] = 1; 184 } 185 onAcceptPositionListeners ~= dlg; 186 } 187 extern(C) static gboolean callBackAcceptPosition(GtkPaned* widgetStruct, Paned _paned) 188 { 189 foreach ( bool delegate(Paned) dlg ; _paned.onAcceptPositionListeners ) 190 { 191 if ( dlg(_paned) ) 192 { 193 return 1; 194 } 195 } 196 197 return 0; 198 } 199 200 bool delegate(Paned)[] onCancelPositionListeners; 201 /** 202 * The ::cancel-position signal is a 203 * keybinding signal 204 * which gets emitted to cancel moving the position of the handle using key 205 * bindings. The position of the handle will be reset to the value prior to 206 * moving it. 207 * The default binding for this signal is Escape. 208 * Since 2.0 209 */ 210 void addOnCancelPosition(bool delegate(Paned) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 211 { 212 if ( !("cancel-position" in connectedSignals) ) 213 { 214 Signals.connectData( 215 getStruct(), 216 "cancel-position", 217 cast(GCallback)&callBackCancelPosition, 218 cast(void*)this, 219 null, 220 connectFlags); 221 connectedSignals["cancel-position"] = 1; 222 } 223 onCancelPositionListeners ~= dlg; 224 } 225 extern(C) static gboolean callBackCancelPosition(GtkPaned* widgetStruct, Paned _paned) 226 { 227 foreach ( bool delegate(Paned) dlg ; _paned.onCancelPositionListeners ) 228 { 229 if ( dlg(_paned) ) 230 { 231 return 1; 232 } 233 } 234 235 return 0; 236 } 237 238 bool delegate(gboolean, Paned)[] onCycleChildFocusListeners; 239 /** 240 * The ::cycle-child-focus signal is a 241 * keybinding signal 242 * which gets emitted to cycle the focus between the children of the paned. 243 * The default binding is f6. 244 * Since 2.0 245 */ 246 void addOnCycleChildFocus(bool delegate(gboolean, Paned) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 247 { 248 if ( !("cycle-child-focus" in connectedSignals) ) 249 { 250 Signals.connectData( 251 getStruct(), 252 "cycle-child-focus", 253 cast(GCallback)&callBackCycleChildFocus, 254 cast(void*)this, 255 null, 256 connectFlags); 257 connectedSignals["cycle-child-focus"] = 1; 258 } 259 onCycleChildFocusListeners ~= dlg; 260 } 261 extern(C) static gboolean callBackCycleChildFocus(GtkPaned* widgetStruct, gboolean reversed, Paned _paned) 262 { 263 foreach ( bool delegate(gboolean, Paned) dlg ; _paned.onCycleChildFocusListeners ) 264 { 265 if ( dlg(reversed, _paned) ) 266 { 267 return 1; 268 } 269 } 270 271 return 0; 272 } 273 274 bool delegate(gboolean, Paned)[] onCycleHandleFocusListeners; 275 /** 276 * The ::cycle-handle-focus signal is a 277 * keybinding signal 278 * which gets emitted to cycle whether the paned should grab focus to allow 279 * the user to change position of the handle by using key bindings. 280 * The default binding for this signal is f8. 281 * Since 2.0 282 */ 283 void addOnCycleHandleFocus(bool delegate(gboolean, Paned) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 284 { 285 if ( !("cycle-handle-focus" in connectedSignals) ) 286 { 287 Signals.connectData( 288 getStruct(), 289 "cycle-handle-focus", 290 cast(GCallback)&callBackCycleHandleFocus, 291 cast(void*)this, 292 null, 293 connectFlags); 294 connectedSignals["cycle-handle-focus"] = 1; 295 } 296 onCycleHandleFocusListeners ~= dlg; 297 } 298 extern(C) static gboolean callBackCycleHandleFocus(GtkPaned* widgetStruct, gboolean reversed, Paned _paned) 299 { 300 foreach ( bool delegate(gboolean, Paned) dlg ; _paned.onCycleHandleFocusListeners ) 301 { 302 if ( dlg(reversed, _paned) ) 303 { 304 return 1; 305 } 306 } 307 308 return 0; 309 } 310 311 bool delegate(GtkScrollType, Paned)[] onMoveHandleListeners; 312 /** 313 * The ::move-handle signal is a 314 * keybinding signal 315 * which gets emitted to move the handle when the user is using key bindings 316 * to move it. 317 * Since 2.0 318 */ 319 void addOnMoveHandle(bool delegate(GtkScrollType, Paned) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 320 { 321 if ( !("move-handle" in connectedSignals) ) 322 { 323 Signals.connectData( 324 getStruct(), 325 "move-handle", 326 cast(GCallback)&callBackMoveHandle, 327 cast(void*)this, 328 null, 329 connectFlags); 330 connectedSignals["move-handle"] = 1; 331 } 332 onMoveHandleListeners ~= dlg; 333 } 334 extern(C) static gboolean callBackMoveHandle(GtkPaned* widgetStruct, GtkScrollType scrollType, Paned _paned) 335 { 336 foreach ( bool delegate(GtkScrollType, Paned) dlg ; _paned.onMoveHandleListeners ) 337 { 338 if ( dlg(scrollType, _paned) ) 339 { 340 return 1; 341 } 342 } 343 344 return 0; 345 } 346 347 bool delegate(Paned)[] onToggleHandleFocusListeners; 348 /** 349 * The ::toggle-handle-focus is a 350 * keybinding signal 351 * which gets emitted to accept the current position of the handle and then 352 * move focus to the next widget in the focus chain. 353 * The default binding is Tab. 354 * Since 2.0 355 */ 356 void addOnToggleHandleFocus(bool delegate(Paned) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 357 { 358 if ( !("toggle-handle-focus" in connectedSignals) ) 359 { 360 Signals.connectData( 361 getStruct(), 362 "toggle-handle-focus", 363 cast(GCallback)&callBackToggleHandleFocus, 364 cast(void*)this, 365 null, 366 connectFlags); 367 connectedSignals["toggle-handle-focus"] = 1; 368 } 369 onToggleHandleFocusListeners ~= dlg; 370 } 371 extern(C) static gboolean callBackToggleHandleFocus(GtkPaned* widgetStruct, Paned _paned) 372 { 373 foreach ( bool delegate(Paned) dlg ; _paned.onToggleHandleFocusListeners ) 374 { 375 if ( dlg(_paned) ) 376 { 377 return 1; 378 } 379 } 380 381 return 0; 382 } 383 384 385 /** 386 * Adds a child to the top or left pane with 387 * default parameters. This is equivalent 388 * to gtk_paned_pack1 (paned, child, FALSE, TRUE). 389 * Params: 390 * child = the child to add 391 */ 392 public void add1(Widget child) 393 { 394 // void gtk_paned_add1 (GtkPaned *paned, GtkWidget *child); 395 gtk_paned_add1(gtkPaned, (child is null) ? null : child.getWidgetStruct()); 396 } 397 398 /** 399 * Adds a child to the bottom or right pane with default 400 * parameters. This is equivalent to 401 * gtk_paned_pack2 (paned, child, TRUE, TRUE). 402 * Params: 403 * child = the child to add 404 */ 405 public void add2(Widget child) 406 { 407 // void gtk_paned_add2 (GtkPaned *paned, GtkWidget *child); 408 gtk_paned_add2(gtkPaned, (child is null) ? null : child.getWidgetStruct()); 409 } 410 411 /** 412 * Adds a child to the top or left pane. 413 * Params: 414 * child = the child to add 415 * resize = should this child expand when the paned widget is resized. 416 * shrink = can this child be made smaller than its requisition. 417 */ 418 public void pack1(Widget child, int resize, int shrink) 419 { 420 // void gtk_paned_pack1 (GtkPaned *paned, GtkWidget *child, gboolean resize, gboolean shrink); 421 gtk_paned_pack1(gtkPaned, (child is null) ? null : child.getWidgetStruct(), resize, shrink); 422 } 423 424 /** 425 * Adds a child to the bottom or right pane. 426 * Params: 427 * child = the child to add 428 * resize = should this child expand when the paned widget is resized. 429 * shrink = can this child be made smaller than its requisition. 430 */ 431 public void pack2(Widget child, int resize, int shrink) 432 { 433 // void gtk_paned_pack2 (GtkPaned *paned, GtkWidget *child, gboolean resize, gboolean shrink); 434 gtk_paned_pack2(gtkPaned, (child is null) ? null : child.getWidgetStruct(), resize, shrink); 435 } 436 437 /** 438 * Obtains the first child of the paned widget. 439 * Since 2.4 440 * Returns: first child, or NULL if it is not set. [transfer none] 441 */ 442 public Widget getChild1() 443 { 444 // GtkWidget * gtk_paned_get_child1 (GtkPaned *paned); 445 auto p = gtk_paned_get_child1(gtkPaned); 446 447 if(p is null) 448 { 449 return null; 450 } 451 452 return ObjectG.getDObject!(Widget)(cast(GtkWidget*) p); 453 } 454 455 /** 456 * Obtains the second child of the paned widget. 457 * Since 2.4 458 * Returns: second child, or NULL if it is not set. [transfer none] 459 */ 460 public Widget getChild2() 461 { 462 // GtkWidget * gtk_paned_get_child2 (GtkPaned *paned); 463 auto p = gtk_paned_get_child2(gtkPaned); 464 465 if(p is null) 466 { 467 return null; 468 } 469 470 return ObjectG.getDObject!(Widget)(cast(GtkWidget*) p); 471 } 472 473 /** 474 * Sets the position of the divider between the two panes. 475 * Params: 476 * position = pixel position of divider, a negative value means that the position 477 * is unset. 478 */ 479 public void setPosition(int position) 480 { 481 // void gtk_paned_set_position (GtkPaned *paned, gint position); 482 gtk_paned_set_position(gtkPaned, position); 483 } 484 485 /** 486 * Obtains the position of the divider between the two panes. 487 * Returns: position of the divider 488 */ 489 public int getPosition() 490 { 491 // gint gtk_paned_get_position (GtkPaned *paned); 492 return gtk_paned_get_position(gtkPaned); 493 } 494 495 /** 496 * Returns the GdkWindow of the handle. This function is 497 * useful when handling button or motion events because it 498 * enables the callback to distinguish between the window 499 * of the paned, a child and the handle. 500 * Since 2.20 501 * Returns: the paned's handle window. [transfer none] 502 */ 503 public Window getHandleWindow() 504 { 505 // GdkWindow * gtk_paned_get_handle_window (GtkPaned *paned); 506 auto p = gtk_paned_get_handle_window(gtkPaned); 507 508 if(p is null) 509 { 510 return null; 511 } 512 513 return ObjectG.getDObject!(Window)(cast(GdkWindow*) p); 514 } 515 }