Debian Codegraph @

src/af/xap/gtk/xap_UnixCustomWidget.cpp

raw
1 /* AbiSource Application Framework
2 * Copyright (C) 2010 Patrik Fimml
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17 * 02110-1301 USA.
18 */
19
20 #include "xap_UnixCustomWidget.h"
21
22 void XAP_UnixCustomWidget::queueDraw(const UT_Rect *clip)
23 {
24 GtkWidget *widget = getWidget();
25 UT_ASSERT(widget);
26
27 if (!clip)
28 gtk_widget_queue_draw(widget);
29 else
30 {
31 gtk_widget_queue_draw_area(
32 widget,
33 clip->left,
34 clip->top,
35 clip->width,
36 clip->height
37 );
38 }
39 }
40
41 #if GTK_CHECK_VERSION(3,0,0)
42 void XAP_UnixCustomWidget::_fe::draw(XAP_UnixCustomWidget *self, cairo_t *cr)
43 #else
44 void XAP_UnixCustomWidget::_fe::expose(XAP_UnixCustomWidget *self, GdkEventExpose *ev)
45 #endif
46 {
47 #if GTK_CHECK_VERSION(3,0,0)
48 self->m_cr = cr;
49 double x1, y1, x2, y2;
50 cairo_clip_extents(cr, &x1, &y1, &x2, &y2);
51
52 UT_Rect r(x1, y1, x2 - x1, y2 - y1);
53 #else
54 UT_Rect r(
55 ev->area.x,
56 ev->area.y,
57 ev->area.width,
58 ev->area.height
59 );
60 #endif
61 self->draw(&r);
62 }