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 ){
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 {
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 ){