[gtkmm] Add Gdk::DrawingContext



commit 38917eecc95378bbbfe7b14801426fdad0672a1c
Author: Kjell Ahlstedt <kjell ahlstedt bredband net>
Date:   Thu Jun 16 18:25:34 2016 +0200

    Add Gdk::DrawingContext
    
    * .gitignore: Add gdk/gdkmm/drawingcontext.[h|cc].
    * gdk/gdkmm.h: Add drawingcontext.h.
    * gdk/src/filelist.am: Add drawningcontext.hg.
    * gdk/src/drawingcontext.[hg|ccg]: New files.
    * tools/m4/convert_gdk.m4: Add conversions for Gdk::DrawingContext.

 .gitignore                 |    2 +
 gdk/gdkmm.h                |    1 +
 gdk/src/drawingcontext.ccg |   17 ++++++++++
 gdk/src/drawingcontext.hg  |   73 ++++++++++++++++++++++++++++++++++++++++++++
 gdk/src/filelist.am        |    1 +
 tools/m4/convert_gdk.m4    |    2 +
 6 files changed, 96 insertions(+), 0 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index 68f56d7..f1f7eb1 100644
--- a/.gitignore
+++ b/.gitignore
@@ -64,6 +64,8 @@ gdk/gdkmm/displaymanager.cc
 gdk/gdkmm/displaymanager.h
 gdk/gdkmm/dragcontext.cc
 gdk/gdkmm/dragcontext.h
+gdk/gdkmm/drawingcontext.cc
+gdk/gdkmm/drawingcontext.h
 gdk/gdkmm/event.cc
 gdk/gdkmm/event.h
 gdk/gdkmm/glcontext.cc
diff --git a/gdk/gdkmm.h b/gdk/gdkmm.h
index 6027387..3969510 100644
--- a/gdk/gdkmm.h
+++ b/gdk/gdkmm.h
@@ -30,6 +30,7 @@
 #include <gdkmm/pixbufloader.h>
 #include <gdkmm/applaunchcontext.h>
 #include <gdkmm/cursor.h>
+#include <gdkmm/drawingcontext.h>
 #include <gdkmm/glcontext.h>
 #include <gdkmm/rectangle.h>
 #include <gdkmm/display.h>
diff --git a/gdk/src/drawingcontext.ccg b/gdk/src/drawingcontext.ccg
new file mode 100644
index 0000000..6c73b72
--- /dev/null
+++ b/gdk/src/drawingcontext.ccg
@@ -0,0 +1,17 @@
+/* Copyright (C) 2016 The gtkmm Development Team
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <gdkmm/window.h>
diff --git a/gdk/src/drawingcontext.hg b/gdk/src/drawingcontext.hg
new file mode 100644
index 0000000..4634a1a
--- /dev/null
+++ b/gdk/src/drawingcontext.hg
@@ -0,0 +1,73 @@
+/* Copyright (C) 2016 The gtkmm Development Team
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <glibmm/object.h>
+#include <cairomm/context.h>
+#include <cairomm/region.h>
+
+_DEFS(gdkmm,gdk)
+_PINCLUDE(glibmm/private/object_p.h)
+
+namespace Gdk
+{
+class Window;
+
+/** Drawing context for GDK windows.
+ *
+ * Gdk::DrawingContext is an object that represents the current drawing
+ * state of a Gdk::Window.
+ *
+ * It's possible to use a Gdk::DrawingContext to draw on a Gdk::Window
+ * via rendering API like Cairo or OpenGL.
+ *
+ * A Gdk::DrawingContext can only be created by calling Gdk::Window::begin_draw_frame()
+ * and will be valid until a call to Gdk::Window::end_draw_frame().
+ *
+ * @newin{3,22}
+ */
+class DrawingContext : public Glib::Object
+{
+  _CLASS_GOBJECT(DrawingContext, GdkDrawingContext, GDK_DRAWING_CONTEXT, Glib::Object, GObject)
+
+protected:
+  _CTOR_DEFAULT()
+
+public:
+  _WRAP_METHOD(Glib::RefPtr<Window> get_window(), gdk_drawing_context_get_window, refreturn)
+  _WRAP_METHOD(Glib::RefPtr<const Window> get_window() const, gdk_drawing_context_get_window, refreturn, 
constversion)
+
+#m4 _CONVERSION(`cairo_region_t*',`::Cairo::RefPtr< ::Cairo::Region>',`::Cairo::RefPtr< ::Cairo::Region>(new 
::Cairo::Region($3, true /* do not take ref */))')
+  // This is const because it returns a copy.
+  _WRAP_METHOD(::Cairo::RefPtr< ::Cairo::Region> get_clip() const, gdk_drawing_context_get_clip)
+
+  _WRAP_METHOD(bool is_valid() const, gdk_drawing_context_is_valid)
+
+#m4 _CONVERSION(`cairo_t*',`::Cairo::RefPtr< ::Cairo::Context>',`::Cairo::RefPtr< ::Cairo::Context>(new 
::Cairo::Context($3, false /* take reference */))')
+  _WRAP_METHOD(::Cairo::RefPtr< ::Cairo::Context> get_cairo_context(), gdk_drawing_context_get_cairo_context)
+  _WRAP_METHOD(::Cairo::RefPtr<const ::Cairo::Context> get_cairo_context() const, 
gdk_drawing_context_get_cairo_context, constversion)
+
+#m4 _CONVERSION(`const ::Cairo::RefPtr< ::Cairo::Context>&',`cairo_t*',`($3)->cobj()')
+  _WRAP_METHOD(static Glib::RefPtr<DrawingContext> get_drawing_context_from_cairo_context(const 
::Cairo::RefPtr< ::Cairo::Context>& cr), gdk_cairo_get_drawing_context, refreturn)
+
+  _WRAP_PROPERTY("window", Glib::RefPtr<Window>)
+  // A wrapped property_clip() would require a template specialization
+  // Glib::Value<Cairo::RefPtr<T>>.
+  //_WRAP_PROPERTY("clip", ::Cairo::RefPtr< ::Cairo::Region>)
+
+  // There are no signals or vfuncs.
+};
+
+} // namespace Gdk
diff --git a/gdk/src/filelist.am b/gdk/src/filelist.am
index e7e3dd2..0cdff5c 100644
--- a/gdk/src/filelist.am
+++ b/gdk/src/filelist.am
@@ -20,6 +20,7 @@ gdkmm_files_any_hg =          \
        display.hg              \
        displaymanager.hg       \
        dragcontext.hg          \
+       drawingcontext.hg               \
        event.hg                \
        glcontext.hg            \
        monitor.hg \
diff --git a/tools/m4/convert_gdk.m4 b/tools/m4/convert_gdk.m4
index 972460a..e0000e2 100644
--- a/tools/m4/convert_gdk.m4
+++ b/tools/m4/convert_gdk.m4
@@ -119,6 +119,7 @@ _CONVERSION(`const Glib::RefPtr<Gdk::Window>&',`GdkWindow*',__CONVERT_REFPTR_TO_
 _CONVERSION(`const Glib::RefPtr<Window>&',`GdkWindow*',__CONVERT_REFPTR_TO_P)
 _CONVERSION(`const Glib::RefPtr<GLContext>&',`GdkGLContext*',__CONVERT_REFPTR_TO_P)
 _CONVERSION(`const Glib::RefPtr<Gdk::GLContext>&',`GdkGLContext*',__CONVERT_REFPTR_TO_P)
+_CONVERSION(`const Glib::RefPtr<DrawingContext>&',`GdkDrawingContext*',__CONVERT_REFPTR_TO_P)
 _CONVERSION(`const Glib::RefPtr<Pixmap>&',`GdkPixmap*',__CONVERT_REFPTR_TO_P)
 _CONVERSION(`const Glib::RefPtr<Gdk::Pixmap>&',`GdkPixmap*',__CONVERT_REFPTR_TO_P)
 _CONVERSION(`const Glib::RefPtr<Bitmap>&',`GdkBitmap*',__CONVERT_REFPTR_TO_P)
@@ -198,6 +199,7 @@ _CONVERSION(`GdkGLContext*',`Glib::RefPtr<GLContext>', `Glib::wrap($3)')
 _CONVERSION(`GdkGLContext*',`Glib::RefPtr<const GLContext>', `Glib::wrap($3)')
 _CONVERSION(`GdkGLContext*',`Glib::RefPtr<Gdk::GLContext>', `Glib::wrap($3)')
 _CONVERSION(`GdkGLContext*',`Glib::RefPtr<const Gdk::GLContext>', `Glib::wrap($3)')
+_CONVERSION(`GdkDrawingContext*',`Glib::RefPtr<DrawingContext>', `Glib::wrap($3)')
 _CONVERSION(`GdkPixmap*',`Glib::RefPtr<Pixmap>', `Glib::wrap((GdkPixmapObject*)($3))')
 _CONVERSION(`GdkPixmap*',`Glib::RefPtr<const Pixmap>', `Glib::wrap((GdkPixmapObject*)($3))')
 _CONVERSION(`GdkPixmap*',`Glib::RefPtr<const Gdk::Pixmap>', `Glib::wrap((GdkPixmapObject*)($3))')


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]