[#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@...>
From: Yukihiro Matsumoto <matz@netlab.co.jp>
[#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,
[#1989] English Ruby/Gtk Tutorial? — schneik@...
Hi,
[#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@...>
Clemens Hintze <c.hintze@gmx.net> writes:
[ruby-talk:02055] Re: English Ruby/Gtk Tutorial?
SugHimsi again. I wrote: > * gtkrc.html (Dai.K.) > => (I have it, and will ask him...) Here's his part (-; with a little refinement > Dai). -- SugHimsi (SUGIHARA Hiroshi) manamist@white.diamond.ne.jp ---- 8< ---- 8< ---- 8< ---- 8< ---- 8< ---- 8< ---- 8< ----
Attachments (1)
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html>
<head>
<title>Ruby/Gtk Programming; Gtkrc</title>
<!-- This baselink is temporal one. -->
<base href="http://ruby.freak.ne.jp/gtk/">
</head>
<!-- Background white, links blue (unvisited), red (active) -->
<BODY
BGCOLOR="#FFFFFF"
TEXT="#000000"
LINK="#0000FF"
VLINK="#800080"
ALINK="#FF0000"
>
<h2>RC file</h2>
GTK gives you a way to set a style(colors, fonts, etc..) of just about any widgets by using its own rc files.
<hr noshade><strong>+ Gtk::RC</strong><p>
<hr noshade><strong>* Gtk::RC</strong><p>
Using an rc file, you should invoke a method defined in the Gtk::RC module:
<dl>
<dt><code>Gtk::RC.parse</code> '<i>filename</i>'
<dd>This method parses the file assigned by <i>filename</i>, and use the style defined there.<br>
<dt><code>Gtk::RC.parse_string</code> <i>string</i>
<dd>This method parses a given string and use the style described in it.<br>
This way is usually used with here document. for example:
<pre>
Gtk::RC.parse_string <<EOS
style "default"
{
fontset = "-*-helvetica-medium-r-normal--14-*,-*-fixed-medium-r-normal--14-*"
}
widget_class "*" style "default"
EOS
</pre>
</dl>
<hr noshade><strong>* simple examples</strong><p>
Generally speaking, in the GTK's rc file, <code>style</code> statement defines a style, and <code>widget</code> or <code>widget_class</code> statement assigns its style to a widget.
<p>
Following sample shows a pink button:
sample script <a href="rc-hello.rb">rc-hello.rb</a>:<br>
<pre>
require 'gtk'
<b>
Gtk::RC.parse_string <<EOS
style "button"
{
bg[NORMAL] = {1.0, 0.8, 0.8}
}
widget_class "*GtkButton" style "button"
EOS
</b>
window = Gtk::Window.new(Gtk::WINDOW_TOPLEVEL)
button = Gtk::Button.new('Hello World')
window.add button
button.show
window.show
Gtk.main
</pre><p>
result screen shot:<br>
<img src="imgs/rc-hello.gif">
<p>
The "<code>Gtk::RC.parse_string</code>" loads GTK's rc strings and sets the style. The following documents to the line of EOS is passed to <code>Gtk::RC.parse_string</code> as an argument and parsed by GTK.<p>
Here is a description of the string:
<ul>
<li><code>style "button"</code><br>
It creates the new style named as a "button" defined by following strings between <code>{</code> and <code>}</code>.
<li><code>bg[NORMAL] = {1.0, 0.8, 0.8}</code><br>
It sets the background color in the "NORMAL" state.
The following 3 decimals means the three primary colors, Red, Green, Blue in the order of appearance, are values in the range from 0.0 to 1.0. They must be in floating-point style, or they will register as 0. So note that simple "1" will not work, it must be "1.0".
<li><code>widget_class "*GtkButton" style "button"</code><br>
This sets a style of a widget of "GtkButton" class to the "button" style defined above.
The directive of "widget_class" uses a class name to determine widgets. Note that the word of ``class name'' in this context is NOT Ruby's class name but GTK's class name, which is equals to Ruby's class name except "::".
(ex: The GTK's classname of Gtk::Button is "GtkButton".)
</ul>
<hr noshade><strong>+ RC file format</strong><p>
<dl>
<dt><code>style "<i>style name</i>"</code>
<dt><code>style "<i>style name</i>" = "<i>existing style name</i>"</code>
<dd>
It defines a style.
The content closed by {} is the definition itself.
You can copy a existing style then describe differences with second syntax.
<p>
<ul>
<li><code>To specify a color:</code><br>
You can specify a color with following format:
<ul>
<li><code>fg[state] = {red, green, blue} # set a foreground color of a widget.</code><br>
<li><code>bg[state] = {red, green, blue} # set a background color of a widget.</code><br>
</ul>
The 3 decimals means the three primary colors, Red, Green, Blue in the order of appearance, are values in the range from 0.0 to 1.0. They must be in floating-point format. A black is expressed by {0.0, 0.0, 0.0}, and a white is by {1.0, 1.0, 1.0}.<br>
ex:<br>
<code>fg[NORMAL] = {0.0, 0.0, 0.0}<br>
bg[NORMAL] = {0.8, 0.8, 0.8}</code>
<li><code>state:</code><br>
<ul>
<li><code>NORMAL -- a normal state of the widget.</code><br>
<li><code>PRELIGHT -- a mouse cursor is over the widget(but not pressed).</code><br>
<li><code>ACTIVE -- the widget is pressed or clicked.</code><br>
<li><code>INSENSITIVE -- non-active state of the widget.</code><br>
<li><code>SELECTED -- the widget is selected.</code><br>
</ul>
<li><code>To specify a background pixmap:</code><br>
you can specify a background pixmap with following format.
<ul>
<li><code>bg_pixmap[state] = "<i>filename</i>"</code><br>
</ul>
a pixmap file is searched in the pixmap_path(mentioned later).
<li><code>font:</code><br>
<ul>
<li><code>font = "<i>font name</i>"</code><br>
<li><code>fontset = "<i>font name</i>"</code><br>
</ul>
This specifies a font or fontset in the XLFD format.
</ul>
<p>
<dt><code>pixmap_path "<i>path</i>:<i>path</i>:..."</code>
<dd>
This is used for searching a pixmap file specified by the bg_pixmap.
Searching path is separated by a colon(:).
<p>
<dt><code>widget_class "<i>widget class set</i>" style "<i>style name</i>"</code>
<dt><code>widget "<i>widget set</i>" style "<i>style name</i>"</code>
<dd>
This assignes the style specified by a "style name" to the widget given by a "widget class set" or "widget set".
<p>
The directive of <code>widget_class</code> uses a class name to determine widgets. Note that the word of ``class name'' in this context is not Ruby's class name but GTK's class name, which is equals to Ruby's class name except "::".
(ex: The GTK's classname of Gtk::Button is "GtkButton".)
The directive of <code>widget</code> is specified by name. widget name is set by a method of Gtk::Widget#set_name. On my experience, if you don't set it, it becomes same to class name.
<p>
A widget class set or a widget set is specified widget has-a tree. For example, if a Gtk::Button is added to Gtk::Window, the button is specified by "GtkWindow.GtkButton" in a class name form. A wildcard `*' is also available in this syntax, so "*GtkButton" expresses all widget of GtkButton class.
</dl>
ex:
<pre>
Gtk::RC.parse_string <<EOS
pixmap_path "."
style "default"
{
fg[NORMAL] = {0.0, 0.0, 1.0}
bg_pixmap[NORMAL] = "stone.xpm"
font = "-adobe-courier-bold-r-normal--18-*"
}
widget_class "*" style "default"
EOS
</pre>
This code sets whole widgets' foreground color to blue, background to stone.xpm, and font to courier 18pt bold.
<br>
Following snapshot show this sample:<br>
<img src="imgs/rc-menu.gif">
<p>
<a href="diff.html">next</a>
<hr noshade>
<a href="../">[TOP]</a>
<a href="../ml/topics.html">[ML topics]</a>
<a href="./">[GTK]</a>
<a href="../goo/">[Today's goo analyzer]</a>
<br>
Written by
<a href="mailto:akaishi@ruby.freak.ne.jp">akaishi@ruby.freak.ne.jp</a>
<br>
Translated by
<a href="mailto:MAP2303@mapletown.net">MAP2303@mapletown.net</a>
<br>
</body>
</html>