changeset 9:9d46c05b49f6

Added GdkColor, GdkEventKey and keys
author unexist
date Mon, 14 Dec 2009 00:34:27 +0100
parents da4347585d4f
children c28e7dc088fd
files subtly/gdk.rb
diffstat 1 files changed, 45 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/subtly/gdk.rb	Mon Dec 14 00:34:06 2009 +0100
+++ b/subtly/gdk.rb	Mon Dec 14 00:34:27 2009 +0100
@@ -42,14 +42,52 @@
     attach_function(:ffi_parse_color,
       :gdk_color_parse, [ :string, :pointer ], :void
     )
-  end
 
-  class GdkColor < FFI::Struct
-    layout(
-      :pixel, :uint,
-      :red,   :uint,
-      :green, :uint,
-      :blue,  :uint
+    ## ffi_parse_key
+    # Parse key name
+    #
+    # @param  [String,  #read]   Color name
+    # @return [Uint] Converted keyval
+    ##
+
+    attach_function(:ffi_parse_key,
+      :gdk_keyval_from_name, [ :string ], :uint
+    )
+
+    # Color {{{
+    class Color < FFI::Struct
+      layout(
+        :pixel, :uint,
+        :red,   :uint,
+        :green, :uint,
+        :blue,  :uint
+      )
+    end # }}}
+
+    # EventKey {{{
+    class EventKey < FFI::Struct
+      layout(
+        :type,             :int,
+        :window,           :pointer,
+        :send_event,       :int8,
+        :time,             :uint32,
+        :state,            :uint,
+        :keyval,           :uint,
+        :length,           :int,
+        :string,           :string,
+        :hardware_keycode, :uint16,
+        :group,            :uint8,
+        :is_modifier,      :int8
+      )
+    end # }}}
+
+    Keys = enum(
+      :return,    0xff0d,
+      :escape,    0xff1b,
+      :delete,    0xffff,
+      :backspace, 0xff08,
+      :tab,       0xff09,
+      :colon,     0x10020a1
     )
   end
 end