mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Gtk3: replace expose_event size_request functions
expose_event has been replaced with draw size_request has become get_preferred_width and get_preferred_height
This commit is contained in:
parent
2ca938bd67
commit
f07ad114c4
@ -83,7 +83,7 @@ static void gnc_dense_cal_dispose(GObject *object);
|
|||||||
static void gnc_dense_cal_realize(GtkWidget *widget, gpointer user_data);
|
static void gnc_dense_cal_realize(GtkWidget *widget, gpointer user_data);
|
||||||
static void gnc_dense_cal_configure(GtkWidget *widget, GdkEventConfigure *event, gpointer user_data);
|
static void gnc_dense_cal_configure(GtkWidget *widget, GdkEventConfigure *event, gpointer user_data);
|
||||||
static void gnc_dense_cal_draw_to_buffer(GncDenseCal *dcal);
|
static void gnc_dense_cal_draw_to_buffer(GncDenseCal *dcal);
|
||||||
static gboolean gnc_dense_cal_expose(GtkWidget *widget, GdkEventExpose *event, gpointer user_data);
|
static gboolean gnc_dense_cal_draw(GtkWidget *widget, cairo_t *cr, gpointer user_data);
|
||||||
|
|
||||||
static void gdc_reconfig(GncDenseCal *dcal);
|
static void gdc_reconfig(GncDenseCal *dcal);
|
||||||
|
|
||||||
@ -300,7 +300,7 @@ gnc_dense_cal_init(GncDenseCal *dcal)
|
|||||||
| GDK_POINTER_MOTION_MASK
|
| GDK_POINTER_MOTION_MASK
|
||||||
| GDK_POINTER_MOTION_HINT_MASK));
|
| GDK_POINTER_MOTION_HINT_MASK));
|
||||||
gtk_box_pack_start(GTK_BOX(dcal), GTK_WIDGET(dcal->cal_drawing_area), TRUE, TRUE, 0);
|
gtk_box_pack_start(GTK_BOX(dcal), GTK_WIDGET(dcal->cal_drawing_area), TRUE, TRUE, 0);
|
||||||
g_signal_connect(G_OBJECT(dcal->cal_drawing_area), "expose_event", G_CALLBACK(gnc_dense_cal_expose), (gpointer)dcal);
|
g_signal_connect(G_OBJECT(dcal->cal_drawing_area), "draw", G_CALLBACK(gnc_dense_cal_draw), (gpointer)dcal);
|
||||||
g_signal_connect(G_OBJECT(dcal->cal_drawing_area), "realize", G_CALLBACK(gnc_dense_cal_realize), (gpointer)dcal);
|
g_signal_connect(G_OBJECT(dcal->cal_drawing_area), "realize", G_CALLBACK(gnc_dense_cal_realize), (gpointer)dcal);
|
||||||
g_signal_connect(G_OBJECT(dcal->cal_drawing_area), "configure_event", G_CALLBACK(gnc_dense_cal_configure), (gpointer)dcal);
|
g_signal_connect(G_OBJECT(dcal->cal_drawing_area), "configure_event", G_CALLBACK(gnc_dense_cal_configure), (gpointer)dcal);
|
||||||
|
|
||||||
@ -865,25 +865,18 @@ free_rect(gpointer data, gpointer ud)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
gnc_dense_cal_expose(GtkWidget *widget,
|
gnc_dense_cal_draw(GtkWidget *widget, cairo_t *cr, gpointer user_data)
|
||||||
GdkEventExpose *event,
|
|
||||||
gpointer user_data)
|
|
||||||
{
|
{
|
||||||
GncDenseCal *dcal;
|
GncDenseCal *dcal;
|
||||||
cairo_t *cr;
|
|
||||||
|
|
||||||
g_return_val_if_fail(widget != NULL, FALSE);
|
g_return_val_if_fail(widget != NULL, FALSE);
|
||||||
g_return_val_if_fail(GNC_IS_DENSE_CAL(user_data), FALSE);
|
g_return_val_if_fail(GNC_IS_DENSE_CAL(user_data), FALSE);
|
||||||
g_return_val_if_fail(event != NULL, FALSE);
|
|
||||||
|
|
||||||
if (event->count > 0)
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
dcal = GNC_DENSE_CAL(user_data);
|
dcal = GNC_DENSE_CAL(user_data);
|
||||||
cr = gdk_cairo_create (gtk_widget_get_window (GTK_WIDGET(dcal->cal_drawing_area)));
|
cairo_save (cr);;
|
||||||
cairo_set_source_surface (cr, dcal->surface, 0, 0);
|
cairo_set_source_surface (cr, dcal->surface, 0, 0);
|
||||||
cairo_paint (cr);
|
cairo_paint (cr);
|
||||||
cairo_destroy (cr);
|
cairo_restore (cr);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -49,24 +49,18 @@ enum
|
|||||||
};
|
};
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
gnc_header_expose (GtkWidget *header,
|
gnc_header_draw (GtkWidget *header, cairo_t *cr)
|
||||||
GdkEventExpose *event)
|
|
||||||
{
|
{
|
||||||
cairo_t *cr;
|
cairo_save (cr);
|
||||||
GdkWindow *binwin = gtk_layout_get_bin_window(GTK_LAYOUT(header));
|
|
||||||
|
|
||||||
cr = gdk_cairo_create (binwin);
|
|
||||||
cairo_set_source_surface (cr, GNC_HEADER(header)->surface, 0, 0);
|
cairo_set_source_surface (cr, GNC_HEADER(header)->surface, 0, 0);
|
||||||
cairo_paint (cr);
|
cairo_paint (cr);
|
||||||
cairo_destroy (cr);
|
cairo_restore (cr);
|
||||||
|
|
||||||
GTK_WIDGET_CLASS (parent_class)->expose_event (header, event);
|
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gnc_header_draw (GncHeader *header)
|
gnc_header_draw_offscreen (GncHeader *header)
|
||||||
{
|
{
|
||||||
SheetBlockStyle *style = header->style;
|
SheetBlockStyle *style = header->style;
|
||||||
Table *table = header->sheet->table;
|
Table *table = header->sheet->table;
|
||||||
@ -216,7 +210,7 @@ gnc_header_request_redraw (GncHeader *header)
|
|||||||
if (!header->style)
|
if (!header->style)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
gnc_header_draw (header);
|
gnc_header_draw_offscreen (header);
|
||||||
gtk_widget_queue_draw (GTK_WIDGET(header));
|
gtk_widget_queue_draw (GTK_WIDGET(header));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -636,10 +630,8 @@ gnc_header_class_init (GncHeaderClass *header_class)
|
|||||||
|
|
||||||
|
|
||||||
item_class->unrealize = gnc_header_unrealize;
|
item_class->unrealize = gnc_header_unrealize;
|
||||||
// item_class->update = gnc_header_update;
|
item_class->draw = gnc_header_draw;
|
||||||
item_class->expose_event = gnc_header_expose;
|
|
||||||
item_class->event = gnc_header_event;
|
item_class->event = gnc_header_event;
|
||||||
// item_class->point = gnc_header_point;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -629,11 +629,15 @@ draw_block (GnucashSheet *sheet,
|
|||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
gnucash_sheet_draw_internal (GnucashSheet *sheet, cairo_t *cr,
|
gnucash_sheet_draw_internal (GnucashSheet* sheet, cairo_t* cr,
|
||||||
int x, int y, int width, int height)
|
GtkAllocation* alloc)
|
||||||
{
|
{
|
||||||
VirtualLocation virt_loc;
|
VirtualLocation virt_loc;
|
||||||
SheetBlock *sheet_block;
|
SheetBlock *sheet_block;
|
||||||
|
int x = alloc->x;
|
||||||
|
int y = alloc->y;
|
||||||
|
int width = alloc->width;
|
||||||
|
int height = alloc->height;
|
||||||
|
|
||||||
if (x < 0 || y < 0)
|
if (x < 0 || y < 0)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -697,45 +697,42 @@ gnucash_sheet_create (Table *table)
|
|||||||
return sheet;
|
return sheet;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gint
|
static void
|
||||||
compute_optimal_width (GnucashSheet *sheet)
|
gnucash_sheet_get_preferred_width (G_GNUC_UNUSED GtkWidget *widget,
|
||||||
|
gint *minimal_width,
|
||||||
|
gint *natural_width)
|
||||||
{
|
{
|
||||||
return DEFAULT_SHEET_WIDTH;
|
*minimal_width = *natural_width = DEFAULT_SHEET_WIDTH;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Compute the height needed to show DEFAULT_REGISTER_INITIAL_ROWS rows */
|
/* Compute the height needed to show DEFAULT_REGISTER_INITIAL_ROWS rows */
|
||||||
static gint
|
static void
|
||||||
compute_optimal_height (GnucashSheet *sheet)
|
gnucash_sheet_get_preferred_height (G_GNUC_UNUSED GtkWidget *widget,
|
||||||
|
gint *minimal_width,
|
||||||
|
gint *natural_width)
|
||||||
{
|
{
|
||||||
|
GnucashSheet *sheet = GNUCASH_SHEET(widget);
|
||||||
SheetBlockStyle *style;
|
SheetBlockStyle *style;
|
||||||
CellDimensions *cd;
|
CellDimensions *cd;
|
||||||
gint row_height;
|
gint row_height;
|
||||||
|
|
||||||
|
*minimal_width = *natural_width = DEFAULT_SHEET_HEIGHT;
|
||||||
|
|
||||||
if (!sheet)
|
if (!sheet)
|
||||||
return DEFAULT_SHEET_HEIGHT;
|
return;
|
||||||
|
|
||||||
style = gnucash_sheet_get_style_from_cursor (sheet, CURSOR_HEADER);
|
style = gnucash_sheet_get_style_from_cursor (sheet, CURSOR_HEADER);
|
||||||
if (!style)
|
if (!style)
|
||||||
return DEFAULT_SHEET_HEIGHT;
|
return;
|
||||||
|
|
||||||
cd = gnucash_style_get_cell_dimensions (style, 0, 0);
|
cd = gnucash_style_get_cell_dimensions (style, 0, 0);
|
||||||
if (cd == NULL)
|
if (cd == NULL)
|
||||||
return DEFAULT_SHEET_HEIGHT;
|
return;
|
||||||
|
|
||||||
row_height = cd->pixel_height;
|
row_height = cd->pixel_height;
|
||||||
|
|
||||||
return row_height * DEFAULT_SHEET_INITIAL_ROWS;
|
*minimal_width = *natural_width = row_height * DEFAULT_SHEET_INITIAL_ROWS;
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static void
|
|
||||||
gnucash_sheet_size_request (GtkWidget *widget, GtkRequisition *requisition)
|
|
||||||
{
|
|
||||||
GnucashSheet *sheet = GNUCASH_SHEET(widget);
|
|
||||||
|
|
||||||
requisition->width = compute_optimal_width (sheet);
|
|
||||||
requisition->height = compute_optimal_height (sheet);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *
|
const char *
|
||||||
@ -1050,23 +1047,17 @@ gnucash_sheet_delete_cb (GtkWidget *widget,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
gnucash_sheet_draw (GtkWidget *widget, GdkEventExpose *event)
|
gnucash_sheet_draw (GtkWidget *widget, cairo_t *cr)
|
||||||
{
|
{
|
||||||
GnucashSheet *sheet = GNUCASH_SHEET (widget);
|
GnucashSheet *sheet = GNUCASH_SHEET (widget);
|
||||||
int x = event->area.x;
|
GtkAllocation alloc;
|
||||||
int y = event->area.y;
|
gtk_widget_get_allocation(widget, &alloc);
|
||||||
int width = event->area.width;
|
|
||||||
int height = event->area.height;
|
|
||||||
GdkWindow *binwin = gtk_layout_get_bin_window(GTK_LAYOUT(sheet));
|
|
||||||
cairo_t *cr;
|
|
||||||
gboolean result;
|
gboolean result;
|
||||||
|
|
||||||
cr = gdk_cairo_create (binwin);
|
cairo_save (cr);
|
||||||
result = gnucash_sheet_draw_internal (sheet, cr, x, y, width, height);
|
result = gnucash_sheet_draw_internal (sheet, cr, &alloc);
|
||||||
|
|
||||||
gnucash_sheet_draw_cursor (sheet->cursor, cr);
|
gnucash_sheet_draw_cursor (sheet->cursor, cr);
|
||||||
|
cairo_restore (cr);
|
||||||
cairo_destroy(cr);
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -2457,7 +2448,8 @@ gnucash_sheet_class_init (GnucashSheetClass *klass)
|
|||||||
/* Method override */
|
/* Method override */
|
||||||
gobject_class->finalize = gnucash_sheet_finalize;
|
gobject_class->finalize = gnucash_sheet_finalize;
|
||||||
|
|
||||||
widget_class->size_request = gnucash_sheet_size_request;
|
widget_class->get_preferred_width = gnucash_sheet_get_preferred_width;
|
||||||
|
widget_class->get_preferred_height = gnucash_sheet_get_preferred_height;
|
||||||
widget_class->size_allocate = gnucash_sheet_size_allocate;
|
widget_class->size_allocate = gnucash_sheet_size_allocate;
|
||||||
|
|
||||||
widget_class->focus_in_event = gnucash_sheet_focus_in_event;
|
widget_class->focus_in_event = gnucash_sheet_focus_in_event;
|
||||||
@ -2469,7 +2461,7 @@ gnucash_sheet_class_init (GnucashSheetClass *klass)
|
|||||||
widget_class->button_release_event = gnucash_button_release_event;
|
widget_class->button_release_event = gnucash_button_release_event;
|
||||||
widget_class->scroll_event = gnucash_scroll_event;
|
widget_class->scroll_event = gnucash_scroll_event;
|
||||||
|
|
||||||
widget_class->expose_event = gnucash_sheet_draw;
|
widget_class->draw = gnucash_sheet_draw;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -135,7 +135,7 @@ void gnucash_sheet_refresh_from_prefs (GnucashSheet *sheet);
|
|||||||
gboolean gnucash_sheet_find_loc_by_pixel (GnucashSheet *sheet, gint x, gint y,
|
gboolean gnucash_sheet_find_loc_by_pixel (GnucashSheet *sheet, gint x, gint y,
|
||||||
VirtualLocation *vcell_loc);
|
VirtualLocation *vcell_loc);
|
||||||
gboolean gnucash_sheet_draw_internal (GnucashSheet *sheet, cairo_t *cr,
|
gboolean gnucash_sheet_draw_internal (GnucashSheet *sheet, cairo_t *cr,
|
||||||
int x, int y, int width, int height);
|
GtkAllocation *alloc);
|
||||||
void gnucash_sheet_draw_cursor (GnucashCursor *cursor, cairo_t *cr);
|
void gnucash_sheet_draw_cursor (GnucashCursor *cursor, cairo_t *cr);
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user