2 Copyright (C) 2001-2006, William Joseph.
5 This file is part of GtkRadiant.
7 GtkRadiant is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 GtkRadiant is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GtkRadiant; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
36 gboolean hpaned_allocate(ui::Widget widget, GtkAllocation* allocation, PanedState* paned ){
37 if ( paned->size != allocation->width ) {
38 paned->size = allocation->width;
39 gtk_paned_set_position( GTK_PANED( widget ), static_cast<int>( paned->size * paned->position ) );
44 gboolean vpaned_allocate(ui::Widget widget, GtkAllocation* allocation, PanedState* paned ){
45 if ( paned->size != allocation->height ) {
46 paned->size = allocation->height;
47 gtk_paned_set_position( GTK_PANED( widget ), static_cast<int>( paned->size * paned->position ) );
52 gboolean paned_position(ui::Widget widget, gpointer dummy, PanedState* paned ){
53 if ( paned->size != -1 ) {
54 paned->position = gtk_paned_get_position( GTK_PANED( widget ) ) / static_cast<float>( paned->size );
59 PanedState g_hpaned = { 0.5f, -1, };
60 PanedState g_vpaned1 = { 0.5f, -1, };
61 PanedState g_vpaned2 = { 0.5f, -1, };
63 ui::Widget create_split_views( ui::Widget topleft, ui::Widget topright, ui::Widget botleft, ui::Widget botright, ui::Widget& vsplit1, ui::Widget& vsplit2 ){
64 auto hsplit = ui::HPaned(ui::New);
67 hsplit.connect( "size_allocate", G_CALLBACK( hpaned_allocate ), &g_hpaned );
68 hsplit.connect( "notify::position", G_CALLBACK( paned_position ), &g_hpaned );
71 auto vsplit = ui::VPaned(ui::New);
73 gtk_paned_add1( GTK_PANED( hsplit ), GTK_WIDGET( vsplit ) );
74 gtk_widget_show( GTK_WIDGET( vsplit ) );
76 vsplit.connect( "size_allocate", G_CALLBACK( vpaned_allocate ), &g_vpaned1 );
77 vsplit.connect( "notify::position", G_CALLBACK( paned_position ), &g_vpaned1 );
79 gtk_paned_add1( GTK_PANED( vsplit ), GTK_WIDGET( create_framed_widget( topleft ) ) );
80 gtk_paned_add2( GTK_PANED( vsplit ), GTK_WIDGET( create_framed_widget( botleft ) ) );
83 auto vsplit = ui::VPaned(ui::New);
85 gtk_paned_add2( GTK_PANED( hsplit ), GTK_WIDGET( vsplit ) );
86 gtk_widget_show( GTK_WIDGET( vsplit ) );
88 vsplit.connect( "size_allocate", G_CALLBACK( vpaned_allocate ), &g_vpaned2 );
89 vsplit.connect( "notify::position", G_CALLBACK( paned_position ), &g_vpaned2 );
91 gtk_paned_add1( GTK_PANED( vsplit ), GTK_WIDGET( create_framed_widget( topright ) ) );
92 gtk_paned_add2( GTK_PANED( vsplit ), GTK_WIDGET( create_framed_widget( botright ) ) );