[gtkmm] Wrapped gdk_device_get_history().



commit e2efdc7c007a8ef175b3fd19fca095df341f22ee
Author: Krzesimir Nowak <qdlacz gmail com>
Date:   Thu Jan 6 16:50:59 2011 +0100

    Wrapped gdk_device_get_history().
    
    * gdk/src/device.[hg|ccg]: Wrapped gdk_device_wrap_history().
    * gdk/src/timecoord.[hg|ccg]: New files.
    * gdk/src/filelist.am: Added new files to build.
    * .gitignore: Ignore the new generated files.

 .gitignore            |    2 +
 ChangeLog             |    8 ++++++
 gdk/src/device.ccg    |   11 ++++++++
 gdk/src/device.hg     |   10 +++++--
 gdk/src/filelist.am   |    7 +++--
 gdk/src/timecoord.ccg |   36 ++++++++++++++++++++++++++
 gdk/src/timecoord.hg  |   67 +++++++++++++++++++++++++++++++++++++++++++++++++
 7 files changed, 135 insertions(+), 6 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index 4194621..205341e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -142,6 +142,8 @@ gdk/gdkmm/rgbcmap.cc
 gdk/gdkmm/rgbcmap.h
 gdk/gdkmm/screen.cc
 gdk/gdkmm/screen.h
+gdk/gdkmm/timecoord.cc
+gdk/gdkmm/timecoord.h
 gdk/gdkmm/types.cc
 gdk/gdkmm/types.h
 gdk/gdkmm/visual.cc
diff --git a/ChangeLog b/ChangeLog
index 7e8718f..901ac5e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2011-01-06  Krzesimir Nowak  <qdlacz gmail com>
+
+	Wrapped gdk_device_get_history().
+
+	* gdk/src/device.[hg|ccg]: Wrapped gdk_device_wrap_history().
+	* gdk/src/timecoord.[hg|ccg]: New files.
+	* gdk/src/filelist.am: Added new files to build.
+
 2011-01-06  Murray Cumming  <murrayc murrayc com>
 
 	Range: Remove get/set_update_policy(), to fix the build.
diff --git a/gdk/src/device.ccg b/gdk/src/device.ccg
index ec137d2..3a54378 100644
--- a/gdk/src/device.ccg
+++ b/gdk/src/device.ccg
@@ -25,6 +25,17 @@
 namespace Gdk
 {
 
+ArrayHandle_TimeCoords Device::get_history(const Glib::RefPtr<Window>& window, guint32 start, guint32 stop) const
+{
+  GdkTimeCoord** coords = 0;
+  int events_count = 0;
+
+  // we don't care about returned value - false means that either getting history is unsupported or no motion events happened.
+  // it is undistinguishable.
+  gdk_device_get_history(const_cast<GdkDevice*>(gobj()), Glib::unwrap(window), start, stop, &coords, &events_count);
+  return ArrayHandle_TimeCoords(coords, events_count, Glib::OWNERSHIP_DEEP);
+}
+
 void Device::get_position(int& x, int& y) const
 {
   gdk_device_get_position(const_cast<GdkDevice*>(gobj()), 0, &x, &y);
diff --git a/gdk/src/device.hg b/gdk/src/device.hg
index 10d54b3..c88e134 100644
--- a/gdk/src/device.hg
+++ b/gdk/src/device.hg
@@ -19,7 +19,7 @@
 
 #include <gdkmm/window.h>
 #include <gdkmm/event.h>
-//#include <gdkmm/display.h>
+#include <gdkmm/timecoord.h>
 #include <gdk/gdk.h>
 
 
@@ -60,8 +60,12 @@ public:
   _WRAP_METHOD(void set_axis_use(guint index_, AxisUse use), gdk_device_set_axis_use)
   _WRAP_METHOD(void get_state(const Glib::RefPtr<Window>& window, double& axes, ModifierType& mask), gdk_device_get_state)
 
-  //TODO: Return a list instead because this is ugly and C-like:
-  _WRAP_METHOD(bool get_history(const Glib::RefPtr<Window>& window, guint32 start, guint32 stop, GdkTimeCoord**& events, int& n_events), gdk_device_get_history)
+  // TODO: docs.
+  ArrayHandle_TimeCoords get_history(const Glib::RefPtr<Window>& window, guint32 start, guint32 stop) const;
+  _IGNORE(gdk_device_get_history)
+//#m4 _CONVERSION(`GList*',`Glib::ListHandle<Glib::RefPtr<Gdk::Device> >',`$2($3, Glib::OWNERSHIP_SHALLOW)')
+  //_WRAP_METHOD(Glib::ListHandle<Glib::RefPtr<Gdk::Device> > list_slave_devices(), gdk_device_list_slave_devices)
+  //_WRAP_METHOD(Glib::ListHandle<Glib::RefPtr<const Gdk::Device> > list_slave_devices() const, gdk_device_list_slave_devices, constversion)
 
   _WRAP_METHOD(int get_n_axes() const, gdk_device_get_n_axes)
  //TODO: A list of GdkAtom, which we should show as strings: _WRAP_METHOD(GList *  gdk_device_list_axes      () const, gdk_device_list_axes)
diff --git a/gdk/src/filelist.am b/gdk/src/filelist.am
index 067e172..1916fed 100644
--- a/gdk/src/filelist.am
+++ b/gdk/src/filelist.am
@@ -6,7 +6,7 @@ gdkmm_files_defs =		\
 	gdk_extra.defs		\
 	gdk_methods.defs	\
 	gdk_extra_objects.defs	\
-	gdk_pixbuf_methods.defs		\
+	gdk_pixbuf_methods.defs	\
 	gdk_pixbuf_enums.defs	\
 	gdk_signals.defs	\
 	gdk_docs.xml		\
@@ -16,7 +16,7 @@ gdkmm_files_hg =		\
 	color.hg		\
 	cursor.hg		\
 	device.hg		\
-	devicemanager.hg		\
+	devicemanager.hg	\
 	display.hg		\
 	displaymanager.hg	\
 	dragcontext.hg		\
@@ -27,8 +27,9 @@ gdkmm_files_hg =		\
 	pixbufformat.hg		\
 	pixbufloader.hg		\
 	rectangle.hg		\
-	rgba.hg \
+	rgba.hg			\
 	screen.hg		\
+	timecoord.hg		\
 	types.hg		\
 	visual.hg		\
 	window.hg
diff --git a/gdk/src/timecoord.ccg b/gdk/src/timecoord.ccg
new file mode 100644
index 0000000..9c45122
--- /dev/null
+++ b/gdk/src/timecoord.ccg
@@ -0,0 +1,36 @@
+/* Copyright (C) 2010 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, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <gdk/gdk.h>
+
+namespace Gdk
+{
+
+TimeCoord::TimeCoord(GdkTimeCoord* castitem)
+: gobject_(castitem)
+{}
+
+double TimeCoord::get_value_at_axis(guint index) const
+{
+  if (gobject_)
+  {
+    return gobject_->axes[index];
+  }
+  return 0;
+}
+
+} // namespace Gdk
diff --git a/gdk/src/timecoord.hg b/gdk/src/timecoord.hg
new file mode 100644
index 0000000..7f79824
--- /dev/null
+++ b/gdk/src/timecoord.hg
@@ -0,0 +1,67 @@
+/* Copyright (C) 2011 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, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <gdk/gdk.h>
+
+_DEFS(gdkmm,gdk)
+
+namespace Gdk
+{
+
+/** A Gdk::TimeCoord instance contains a single event of motion history.
+ * You shouldn't be using it as a standalone object.
+ */
+class TimeCoord
+{
+  _CLASS_GENERIC(TimeCoord, GdkTimeCoord)
+public:
+  explicit TimeCoord(GdkTimeCoord* castitem);
+
+  _MEMBER_GET(time, time, guint32, guint32);
+  /** Gets value at @a index axis.
+   * @note
+   * Gdk::Device::get_n_axes() will tell you how many axes are stored here.
+   *
+   * @param index Index of an axis from which the value will be taken.
+   * @return A value at @a index.
+   */
+  double get_value_at_axis(guint index) const;
+ 
+  ///Provides access to the underlying C object.
+  GdkTimeCoord* gobj() {return gobject_;}
+  ///Provides access to the underlying C object.
+  const GdkTimeCoord* gobj() const {return gobject_;}
+protected:
+  GdkTimeCoord* gobject_;
+};
+
+#ifndef DOXYGEN_SHOULD_SKIP_THIS
+struct TimeCoordPtrTraits
+{
+  typedef Gdk::TimeCoord CppType;
+  typedef GdkTimeCoord* CType;
+  typedef GdkTimeCoord* CTypeNonConst;
+
+  static CType to_c_type(const CppType& obj) { return const_cast<CType>(obj.gobj()); }
+  static CType to_c_type(const CType& obj) { return obj; }
+  static CppType to_cpp_type(const CType& obj) { return CppType(const_cast<CType>(obj)); }
+  static void release_c_type(const CType& obj) { g_free(const_cast<CType>(obj)); }
+};
+#endif
+typedef Glib::ArrayHandle<TimeCoord, TimeCoordPtrTraits> ArrayHandle_TimeCoords;
+
+} // namespace Gdk



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