At Thu, 29 Aug 2002 17:55:18 +0900,
english there. i’ve asked him to translate the Ruby/DL docs into
english. hopfully he’ll have the time to do it soon. i’ll pass them
along to you when he’s done.
Thank you very much,
jp docs
i’m inserting text into a Text widget. and i need to define
the GdkColor. how do i create s Struct to use with Ruby/DL? ex-
Gtk.gtk_text_insert(@native, Gtk.gdk_font_load(‘courier’), GdkColor?,
GdkColor?, @meta.value, -1)
Use `struct’ in the module which extends DL::Importable as follows:
require ‘dl/struct’ # load dl/struct.rb
module Gdk
extend DL::Importable
GdkColor = struct [ # see gdk/gdktypes.h
“long pixel”,
“short red”,
“short green”,
“short blue”,
]
end
Gdk::GdkColor.malloc allocates enough memory for GdkColor defined in
`gdk/gdktypes.h’, and you can access each member in the dot-notation:
c1 = Gdk::GdkColor.malloc
c1.pixel = …
…
c2 = Gdk::GdkColor.malloc
…
Gtk.gtk_text_insert(@native, Gtk.gdk_font_load(‘courier’),
c1, c2, @meta.value, -1)
However, `struct’ method have not been fully tested yet.
If you don’t want to use the module such as Gdk, use DL::PtrData.malloc
and DL::PtrData#struct! as follows:
c1 = DL::PtrData.malloc(DL.sizeof(‘LHHH’))
c1.struct!(‘LHHH’, :pixel, :red, :green, :blue)
c2 = DL::PtrData.malloc(DL.sizeof(‘LHHH’))
c2.struct!(‘LHHH’, :pixel, :red, :green, :blue)
c1[:pixel] = 0
…
Regards,
···
–
Takaaki Tateishi ttate@kt.jaist.ac.jp