[#1649] Re: New Ruby projects — Yukihiro Matsumoto <matz@...>
The following message is a courtesy copy of an article
[#1672] Re: Ruby 1.4 stable manual bug? — Yukihiro Matsumoto <matz@...>
The following message is a courtesy copy of an article
[#1673] Re: Possible problem with ext/socket in 1.5.2 — itojun@...
[#1694] Conventions for our Ruby book — Dave Thomas <Dave@...>
[#1715] Install postgresql support — Ikhlasul Amal <amal@...>
Hi all,
Hi,
[#1786] Is this a bug? — Clemens Hintze <clemens.hintze@...>
(mailed & posted)
[#1814] Objects nested sometimes. — Hugh Sasse Staff Elec Eng <hgs@...>
I am attemptiong to write a package which consists of a workspace
[#1816] Ruby 1.5.3 under Tru64 (Alpha)? — Clemens Hintze <clemens.hintze@...>
Hi all,
Hi,
Yukihiro Matsumoto writes:
Hi,
Hi,
[#1834] enum examples? — Hugh Sasse Staff Elec Eng <hgs@...>
Has anyone any examplse of using the Enumerable module? I've had a
[#1844] Minor irritation, can't figure out how to patch it though! — Hugh Sasse Staff Elec Eng <hgs@...>
I was considering how difficult it would be to patch Ruby to accept
[#1889] [ruby-1.5.3] require / SAFE — ts <decoux@...>
[#1896] Ruby Syntax similar to other languages? — "David Douthitt" <DDouthitt@...>
[#1900] Enumerations and all that. — Hugh Sasse Staff Elec Eng <hgs@...>
Thank you to the people who responded to my questions about Enumerated
Hugh Sasse Staff Elec Eng <hgs@dmu.ac.uk> writes:
On 16 Mar 2000, Dave Thomas wrote:
[#1929] Re: Class Variables — "David Douthitt" <DDouthitt@...>
| "David Douthitt" <DDouthitt@cuna.com> writes:
[#1942] no Fixnum#new ? — Quinn Dunkan <quinn@...>
Ok, I can add methods to a built-in class well enough (yes I know about succ,
[#1981] Time::at — "David Douthitt" <DDouthitt@...>
or whatever the right syntax is :-)
[#1989] English Ruby/Gtk Tutorial? — schneik@...
Hi,
SugHimsi(%HeIsSaidJustToLoseHisPatienceOnThisSubject;-).
[#2022] rb_global_entry — ts <decoux@...>
[#2036] Anonymous and Singleton Classes — B_DAVISON <Bob.Davison@...>
I am a Ruby newbie and having some problems getting my mind around certain
[#2069] Ruby/GTK+ question about imlib --> gdk-pixbug — schneik@...
[#2073] Re: eval.rb fails — "Dat Nguyen" <thucdat@...>
The doc is fine, this happens only if you try to execute 'until' block
On Wed, 22 Mar 2000, Dat Nguyen wrote:
[#2084] Scope violated by import via 'require'? — Clemens Hintze <c.hintze@...>
Hi,
[#2104] ARGF or $< — Hugh Sasse Staff Elec Eng <hgs@...>
Has anyone any examples of how to use ARGF or $< as I cannot find much
Hi.
[#2165] Ruby strict mode and stand-alone executables. — "Conrad Schneiker" <schneiker@...>
Some people want Ruby to have a strict compile mode.
[#2203] Re: parse bug in 1.5 — schneik@...
[#2212] Re: Ruby/Glade usage questions. — ts <decoux@...>
>>>>> "m" == mrilu <mrilu@ale.cx> writes:
[#2241] setter() for local variables — ts <decoux@...>
[#2256] Multiple assignment of pattern match results. — schneik@...
[#2267] Re: Ruby and Eiffel — h.fulton@...
[#2309] Question about attribute writers — Dave Thomas <Dave@...>
[ruby-talk:02049] Re: English Ruby/Gtk Tutorial?
Hi,
In mail "[ruby-talk:02014] Re: English Ruby/Gtk Tutorial?"
SUGIHARA Hiroshi (SuHi or SugHimsi) <manamist@white.diamond.ne.jp> 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.
<p>
/proginsert clist.rb
Result<br>
(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.)<br>
<img src="imgs/clist.gif">
<p>
Discription<br>
<ul>
=c clist = Gtk::CList.new(['name', 'value'])
This creates a 2 columns CList widget object, which titles are
'name' and 'value'.
=c clist.set_usize(300, 200)
This set the widget 300 pixels width, 200 pixels height.
=c clist.set_column_width 0, 100
This set the first column 100 pixels width.
The index of the first column is 0.
=c ENV.keys.sort.each {|k| clist.append [k, ENV[k]]}
"ENV" is built-in constant of Ruby. It is (pseudo) Hash which contains
environment variable.
This adds the pair of one variable name and its value to list.
The length of array for "append" method must be equal to the number of
CList columns.
</ul>
#----------------------------------------------------------------------
/section Methods of CList Widget
<dl>
=d <code><b>Gtk::CList.new</b></code>(<i>columns</i>)
=d <code><b>Gtk::CList.new</b></code>([<i>'title1', 'title2', ... </i>])
<dd>
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 <code><b>set_policy</b></code>(<i>vscrollbar_policy</i>, <i>hscrollbar_polic
y</i>)
</dl>
#/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.
<p>
/proginsert text.rb
Result<br>
<img src="imgs/text.gif">
<p>
Text widget doesn't receive user's input as default.
It is done by using "set_editable" method.
<pre>
text = Gtk::Text.new
text.set_editable true
</pre>
#----------------------------------------------------------------------
/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).
<p>
Using the Gtk::Adjustment enable to scroll text in Text widget.
<p>
Here's a sample of Text widget with a scroll bar.
<p>
/proginsert text3.rb
Result<br>
<img src="imgs/text-scroll.gif">
<p>
Discription<br>
<ul>
=c vadj = Gtk::Adjustment.new(0,0,0,0,0,0)
This creates Adjustment object.
Both Text widget and Scrollbar widget owns this object.
=c text = Gtk::Text.new(nil, vadj)
This creates Text widget.
First argument is the Adjustment for horizontal direction, and
second is also the Adjustmen for vertical direction.
Argument "nil" means using default adjustments.
(attention: Text widget does not support horizontal Adjustment yet)
=c vs = Gtk::VScrollbar.new(vadj)
This creates scrollbar. VScrollbar is vertical scrollbar,
HScrollbar is horizontal one.
Argument "vadj" is the Adjustment object which is same one for Text widget.
=c hbox = Gtk::HBox.new(false, 0)
=c hbox.pack_start text, true, true, 0
=c hbox.pack_start vs, false, false, 0
This creates horizontal box and pack Text and Scrollbar.
</ul>
#----------------------------------------------------------------------
/section Methods of Text widget
Here's main methods of Text widget.
<dl>
=d <i>text</i>.<code><b>set_point</b>(<i>index</i>)</code>
<dd>
This method set the "inserting point".
<i>index</i> is the index of the string in Text widget.
=d <code><i>index</i> = <i>text</i>.<b>get_point</b></code>
<dd>
This method returns the current "inserting point".
=d <code><i>length</i> = <i>text</i>.<b>get_length</b></code>
<dd>
This method returns the length of the string in Text widget.
It also includes the length of carrige return or line feed.
=d <i>text</i>.<code><b>insert_text</b>(<i>chars</i>, <i>index</i>)</code>
<dd>
This method insert string to Text widget.
It is inherited from Gtk::Editable.
This insert the string <i>chars</i> into the <i>index</i>.
=d <i>text</i>.<code><b>get_chars</b>(<i>start_pos</i>, <i>end_pos</i>)</code>
<dd>
This method returns the string from <i>start_pos</i> to <i>end_pos</i>.
Gtk::Text.get_chars is inherited from Gtk::Editable.
=d <i>text</i>.<code><b>insert</b>(<i>font</i>, <i>fore</i>, <i>back</i>, <i>ch
ars</i>)</code>
<dd>
This method inserts string into current "inserting point".
Font, foreground color, Background color, can be designated.
<i>font</i> is Gdk::Font、<i>fore</i> and <i>back</i> is Gdk::Color object.
Argument "nil" for font/color means using default value (one of widget style).
=d <i>text</i>.<code><b>backward_delete</b>(<i>nchars</i>)</code>
=d <i>text</i>.<code><b>forward_delete</b>(<i>nchars</i>)</code>
<dd>
These methods delete <i>nchars</i> characters from current "inserting point".
"backward_delete" delete string from right to left.
"forward_delete" delete string from left to right.
</dl>
#/write