From: Minero Aoki Date: 2000-03-21T18:22:32+09:00 Subject: [ruby-talk:02049] Re: English Ruby/Gtk Tutorial? Hi, In mail "[ruby-talk:02014] Re: English Ruby/Gtk Tutorial?" SUGIHARA Hiroshi (SuHi or SugHimsi) wrote: > SugHimsi(%HeIsSaidJustToLoseHisPatienceOnThisSubject;-). > The entire documents (and their translators -- all non-native) are below: > (((pressure?! :-):-):-) ^^;;; > * clist.html (aamine) > * text.html (aamine) Then, here's my part. Minero Aoki #====================================================================== /nextfile clist.html /chap CList widget Gtk::CList is a multi-column list widget. It will replace Gtk::List class (of course, Gtk::List is still available). #---------------------------------------------------------------------- /section ex: Display Environmental Variables Here is the simple example of CList class. This program displayes all environmental variables.

/proginsert clist.rb Result
(attention: this result depends gtk-1.0.x. If you execute this program with version 1.2.x, little changes will be occur in look & feel.)

Discription

#---------------------------------------------------------------------- /section Methods of CList Widget
=d Gtk::CList.new(columns) =d Gtk::CList.new(['title1', 'title2', ... ])
This method creates a CList widget. When using first style, created CList have "columns" columns but no title. When using second style, created CList have columns with title. =d set_policy(vscrollbar_policy, hscrollbar_polic y)
#/write #====================================================================== #=begin /nextfile text.html /chap Text Widget #---------------------------------------------------------------------- /section Creating Text Widget Gtk::Text is the widget to edit multi-lines text. Gtk::Text.new creates Text widget.

/proginsert text.rb Result

Text widget doesn't receive user's input as default. It is done by using "set_editable" method.

text = Gtk::Text.new
text.set_editable true
#---------------------------------------------------------------------- /section Using Scrollbar with Text Widget Gtk::Adjustment class represents abstruct data structure to fetch a part of fuge data (Gtk::Adjustment is NOT a widget).

Using the Gtk::Adjustment enable to scroll text in Text widget.

Here's a sample of Text widget with a scroll bar.

/proginsert text3.rb Result

Discription

#---------------------------------------------------------------------- /section Methods of Text widget Here's main methods of Text widget.
=d text.set_point(index)
This method set the "inserting point". index is the index of the string in Text widget. =d index = text.get_point
This method returns the current "inserting point". =d length = text.get_length
This method returns the length of the string in Text widget. It also includes the length of carrige return or line feed. =d text.insert_text(chars, index)
This method insert string to Text widget. It is inherited from Gtk::Editable. This insert the string chars into the index. =d text.get_chars(start_pos, end_pos)
This method returns the string from start_pos to end_pos. Gtk::Text.get_chars is inherited from Gtk::Editable. =d text.insert(font, fore, back, ch ars)
This method inserts string into current "inserting point". Font, foreground color, Background color, can be designated. font is Gdk::Font、fore and back is Gdk::Color object. Argument "nil" for font/color means using default value (one of widget style). =d text.backward_delete(nchars) =d text.forward_delete(nchars)
These methods delete nchars characters from current "inserting point". "backward_delete" delete string from right to left. "forward_delete" delete string from left to right.
#/write