ruby-****@sourc*****
ruby-****@sourc*****
2012年 9月 3日 (月) 06:55:14 JST
------------------------- REMOTE_ADDR = 70.49.49.99 REMOTE_HOST = URL = http://ruby-gnome2.sourceforge.jp/hiki.cgi?tut-gtk2-txtw-textview ------------------------- @@ -222,7 +222,7 @@ In ((*make_tab_array*))method we use Pango::Layout object and a set of other Pango devices to set up our ((*TAB.*))We start up with Gtk::Widget#create_pango_layout(text=nil). In general Pango::Layout object is created by Pango::Layout.new, which creates a new Pango::Layout object with attributes initialized to default values for a particular Pango::Context. However, in our sample program we are employing Gtk::Widget#create_pango_layout, with a string parameter containing as many spaces as we would like our TAB to expand. instead. API documentation tells us that Gtk::Widget#create_pango_layout(text=nil) creates a new Pango::Layout with the appropriate colormap, font description, and base direction for drawing text for this widget. -Next we need to tell our Pango::Layout object what is the font we are using in the text buffer, for which we wish to calculate TAB size. At this point we can request the pixel size, which returns an array of width and height elements. As TAB is concerned with the horizontal layout only, we are interested in width only. We will need to convey the size to Pango::TabArray, which we create next. We will accomplish this with Pango::TabArray#set_tab to which just obtained pixel width is passed as the third argument. Finally we pass our tab array object to our text buffer. +Next we need to tell our Pango::Layout object what is the font we are using in the text buffer, for which we wish to calculate TAB size. At this point we can request the pixel size, which returns an array of width and height elements. As TAB is concerned with the horizontal layout only, we are interested in width only. We will need to convey the size to Pango::TabArray, which we create next. We will accomplish this with Pango::TabArray#set_tab to which just obtained pixel width is passed as the third argument. Finally we set the tabs for our text buffer and pass it our tab array object as the argument. Between the following are the descriptions of the methods we used in order to implement our tab size altering functionality: