2 * Copyright (c) 2007-2013, Czirkos Zoltan http://code.google.com/p/gdash/
4 * Permission is hereby granted, free of charge, to any person obtaining
5 * a copy of this software and associated documentation files (the
6 * "Software"), to deal in the Software without restriction, including
7 * without limitation the rights to use, copy, modify, merge, publish,
8 * distribute, sublicense, and/or sell copies of the Software, and to
9 * permit persons to whom the Software is furnished to do so, subject to
10 * the following conditions:
12 * The above copyright notice and this permission notice shall be
13 * included in all copies or substantial portions of the Software.
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
19 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
20 * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 #ifndef GTKSCREEN_HPP_INCLUDED
24 #define GTKSCREEN_HPP_INCLUDED
30 #include "gfx/screen.hpp"
35 /** Implementation of the Pixmap interface, using GTK+ cairo functions. */
36 class GTKPixmap
: public Pixmap
{
39 cairo_surface_t
*surface
;
42 friend class GTKScreen
;
43 friend class GTKPixbufFactory
;
45 GTKPixmap(GdkPixbuf
*pixbuf
, cairo_surface_t
*surface
): pixbuf(pixbuf
), surface(surface
) {
49 virtual int get_width() const;
50 virtual int get_height() const;
52 /** Return the GdkPixbuf* associated with the object. */
53 cairo_surface_t
*get_cairo_surface() {
56 /** Return the GdkPixbuf* associated with the object. */
57 cairo_surface_t
const *get_cairo_surface() const {
66 * This is a Screen, which uses Cairo for drawing.
67 * It can render to a window (if given a GtkDrawingArea), or it can
68 * render to a software back buffer (if the given GtkDrawingArea is NULL).
70 class GTKScreen
: public Screen
{
72 GtkWidget
*drawing_area
;
74 cairo_surface_t
*back
;
76 GTKScreen(const GTKScreen
&); // not impl
77 GTKScreen
&operator=(const GTKScreen
&); // not impl
79 virtual void configure_size();
83 /** Creates a new GTKScreen, using the drawing area given as canvas.
84 * @param drawing_area A GtkDrawingArea. If NULL pointer, the Screen renders to
87 GTKScreen(PixbufFactory
&pixbuf_factory
, GtkWidget
*drawing_area
);
89 virtual void set_title(char const *title
);
91 void set_drawing_area(GtkWidget
*drawing_area
);
92 cairo_t
*get_cairo_t() { return cr
; }
94 virtual Pixmap
*create_pixmap_from_pixbuf(const Pixbuf
&pb
, bool keep_alpha
) const;
96 virtual void fill_rect(int x
, int y
, int w
, int h
, const GdColor
&c
);
97 virtual void blit(Pixmap
const &src
, int dx
, int dy
) const;
98 virtual void draw_particle_set(int dx
, int dy
, ParticleSet
const &ps
);
100 virtual void set_clip_rect(int x1
, int y1
, int w
, int h
);
101 virtual void remove_clip_rect();