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