1 /* 2 * this file is part of the oxygen gtk engine 3 * Copyright (c) 2010 Hugo Pereira Da Costa <hugo.pereira@free.fr> 4 * 5 * This library is free software; you can redistribute it and/or 6 * modify it under the terms of the GNU Lesser General Public 7 * License as published by the Free Software Foundation; either 8 * version 2 of the License, or(at your option ) any later version. 9 * 10 * This library 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 GNU 13 * Lesser General Public License for more details. 14 * 15 * You should have received a copy of the GNU Lesser General Public 16 * License along with this library; if not, write to the Free 17 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, 18 * MA 02110-1301, USA. 19 */ 20 21 #include "oxygenpaneddata.h" 22 23 #include <cassert> 24 25 namespace Oxygen 26 { 27 28 //_______________________________________________ connect(GtkWidget * widget)29 void PanedData::connect( GtkWidget* widget ) 30 { 31 updateCursor( widget ); 32 _realizeId.connect( G_OBJECT(widget), "realize", G_CALLBACK( realizeEvent ), this ); 33 } 34 35 //_______________________________________________ disconnect(GtkWidget *)36 void PanedData::disconnect( GtkWidget* ) 37 { _realizeId.disconnect(); } 38 39 //_______________________________________________ realizeEvent(GtkWidget * widget,gpointer data)40 void PanedData::realizeEvent( GtkWidget* widget, gpointer data ) 41 { static_cast<PanedData*>( data )->updateCursor( widget ); } 42 43 //_______________________________________________ updateCursor(GtkWidget * widget)44 void PanedData::updateCursor( GtkWidget* widget ) 45 { 46 47 // do nothing if incorrect widget type 48 if( !GTK_IS_PANED( widget ) ) return; 49 50 // load cursor if needed 51 if( !_cursorLoaded ) 52 { 53 assert( !_cursor ); 54 55 GdkDisplay *display( gtk_widget_get_display( widget ) ); 56 _cursor = gdk_cursor_new_from_name( display, GTK_IS_VPANED( widget ) ? "col-resize":"row-resize" ); 57 _cursorLoaded = true; 58 59 } 60 61 // assign to widget 62 if( _cursor ) 63 { 64 65 // load handle window 66 #if GTK_CHECK_VERSION(2, 20, 0) 67 GdkWindow* window( gtk_paned_get_handle_window( GTK_PANED( widget ) ) ); 68 #else 69 GdkWindow* window( GTK_PANED( widget )->handle ); 70 #endif 71 72 // assign cursor 73 gdk_window_set_cursor( window, _cursor ); 74 75 } 76 77 } 78 79 } 80