ruby-****@sourc*****
ruby-****@sourc*****
2009年 2月 23日 (月) 23:45:30 JST
------------------------- REMOTE_ADDR = 74.15.84.244 REMOTE_HOST = URL = http://ruby-gnome2.sourceforge.jp/hiki.cgi?tut-gtk2-mnstbs-mnui ------------------------- @@ -7,17 +7,32 @@ === Submenus +Submenus in GTK+ are not created by separate type of menu item widget but by calling Gtk::MenuItem#submenu= method. This method calls Gtk::Menu#attach_to_widget to attach the submenu to the menu item and places an arrow beside the menu item to show that it now has a submenu. If the menu item already has a submenu, it will be replaced with the given Gtk::Menu widget. +Submenus are useful if you have a list of very specific items that would clutter an otherwise organized menu structure. When using a submenu, you can use the ((*active-item*)) signal provided by the Gtk::MenuItem widget, which will be emitted when the menu item displays its submenu. + === Image Menu Items +Gtk::ImageMenuItem is very similar to its parent class Gtk::MenuItem except it shows a small image to the left of the menu item label. There are more ways to create new image menu item. If you do not specify any argument to Gtk::ImageMenuItem.new(label = nil, use_underline = true) method or you set the label to nil, you create a new Gtk::ImageMenuItem object with an empty label. You can then use ((*image*)) accessor method to set the image displayed by the menu item. The second argument is true if an underscore in the label indicates a mnemonics. + +Additionally you can use Gtk::ImageMenuItem.new(stock_id, accel_group = nil) to create a new image menu item from a stock identifier. This method creates a menu item with the label and the image associated with the stock identifier. The second argument of this function accepts an accelerator group, which will be set to the default accelerator of the stock item. You should set this argument to nil, if you would like to set the key accelerator by yourself manually. + === Check Menu Items -=== Radio Menu Items +Gtk::CheckMenuItem allows you to create a menu item that will display a check box symbol beside the label. It will be checked or unchecked depending on the Boolean property managed by accessor ((*active.*)) A new check menu item is created with Gtk::CheckMenuItem.new(label = nil, use_underline = true) class method. +As with check button widgets, you are able to use the ((*toggled*)) signal also with the check menu item, which is emitted when the user toggles the state. GTK+ takes care of updating the state of the check button, so the signal is emitted simply to allow you to update your application accordingly. + +The check menu item also provides Gtk::CheckMenuItem#inconsistent and Gtk::CheckMenuItem#inconsistent=(Boolean) methods that display a third, "in-between" state that is neither active nor inactive, to show to the user that a conscious selection has to be made. + +=== Radio Menu Items -{{image_right("mnstbs-mnui-01.png")}} +Gtk::RadioMenuItem is a widget derived from Gtk::CheckMenuItem. It is rendered as a radio button instead of a check button. A radio menu item is a check menu item that belongs to a group. At each instant exactly one of the radio menu items from a group is selected. +The first radio button should be created with Gtk::RadioMenuItem.new(label = nil, use_underline = true). All other radio menu items should be created with Gtk::RadioMenuItem.new(group, label = nil, use_underline = true). -{{br}} -((*menui.rb*)) + radio_mi1 = Gtk::RadioMenuItem.new("_I want to be clicked!", true) + radio_mi2 = Gtk::RadioMenuItem.new(radio_mi1, "_Click me instead!", true) + radio_mi3 = Gtk::RadioMenuItem.new(radio_mi1, "No! Click _me!", true) + radio_mi4 = Gtk::RadioMenuItem.new(radio_mi1, "_No! Click me instead!", true)