From dc8c0f94dd230b2484f7049e7b6e88f78e0db9ee Mon Sep 17 00:00:00 2001 From: TimePath Date: Thu, 18 Feb 2016 12:56:20 +1100 Subject: [PATCH] -DGDK_DISABLE_DEPRECATED --- CMakeLists.txt | 2 +- libs/gtkutil/cursor.cpp | 14 +------------- libs/gtkutil/xorrectangle.h | 24 +++++++++--------------- 3 files changed, 11 insertions(+), 29 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 37ca39a6..141b62b6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -66,7 +66,7 @@ add_definitions(-DRADIANT_EXECUTABLE="${RADIANT_EXECUTABLE}") add_definitions( -DGTK_DISABLE_SINGLE_INCLUDES -DGSEAL_ENABLE - #-DGDK_DISABLE_DEPRECATED + -DGDK_DISABLE_DEPRECATED #-DGTK_DISABLE_DEPRECATED ) diff --git a/libs/gtkutil/cursor.cpp b/libs/gtkutil/cursor.cpp index 0fe946f6..431f60fe 100644 --- a/libs/gtkutil/cursor.cpp +++ b/libs/gtkutil/cursor.cpp @@ -28,19 +28,7 @@ GdkCursor* create_blank_cursor(){ - GdkPixmap *pixmap; - GdkBitmap *mask; - char buffer [( 32 * 32 ) / 8]; - memset( buffer, 0, ( 32 * 32 ) / 8 ); - GdkColor white = {0, 0xffff, 0xffff, 0xffff}; - GdkColor black = {0, 0x0000, 0x0000, 0x0000}; - pixmap = gdk_bitmap_create_from_data( 0, buffer, 32, 32 ); - mask = gdk_bitmap_create_from_data( 0, buffer, 32, 32 ); - GdkCursor *cursor = gdk_cursor_new_from_pixmap( pixmap, mask, &white, &black, 1, 1 ); - gdk_drawable_unref( pixmap ); - gdk_drawable_unref( mask ); - - return cursor; + return gdk_cursor_new(GDK_BLANK_CURSOR); } void blank_cursor( GtkWidget* widget ){ diff --git a/libs/gtkutil/xorrectangle.h b/libs/gtkutil/xorrectangle.h index f5ff5aa5..cf75e42b 100644 --- a/libs/gtkutil/xorrectangle.h +++ b/libs/gtkutil/xorrectangle.h @@ -65,23 +65,14 @@ class XORRectangle rectangle_t m_rectangle; GtkWidget* m_widget; -GdkGC* m_gc; +cairo_t *cr; bool initialised() const { - return m_gc != 0; + return cr != nullptr; } void lazy_init(){ if ( !initialised() ) { - m_gc = gdk_gc_new( gtk_widget_get_window(m_widget) ); - - GdkColor color = { 0, 0xffff, 0xffff, 0xffff, }; - GdkColormap* colormap = gdk_window_get_colormap( gtk_widget_get_window(m_widget) ); - gdk_colormap_alloc_color( colormap, &color, FALSE, TRUE ); - gdk_gc_copy( m_gc, gtk_widget_get_style(m_widget)->white_gc ); - gdk_gc_set_foreground( m_gc, &color ); - gdk_gc_set_background( m_gc, &color ); - - gdk_gc_set_function( m_gc, GDK_INVERT ); + cr = gdk_cairo_create(gtk_widget_get_window(m_widget)); } } void draw() const { @@ -91,15 +82,18 @@ void draw() const { const int h = float_to_integer( m_rectangle.h ); GtkAllocation allocation; gtk_widget_get_allocation(m_widget, &allocation); - gdk_draw_rectangle( gtk_widget_get_window(m_widget), m_gc, FALSE, x, -( h ) - ( y - allocation.height ), w, h ); + cairo_rectangle(cr, x, -(h) - (y - allocation.height), w, h); + cairo_set_source_rgb(cr, 1, 1, 1); + cairo_set_operator(cr, CAIRO_OPERATOR_DIFFERENCE); + cairo_stroke(cr); } public: -XORRectangle( ui::Widget widget ) : m_widget( widget ), m_gc( 0 ){ +XORRectangle( ui::Widget widget ) : m_widget( widget ), cr( nullptr ) { } ~XORRectangle(){ if ( initialised() ) { - gdk_gc_unref( m_gc ); + cairo_destroy(cr); } } void set( rectangle_t rectangle ){ -- 2.39.2