nobody at rubyforge.org
2006-Oct-22 00:45 UTC
[Wxruby-development] [704] trunk/wxruby2/lib: Auto-load classes from lib/wx/classes; implement Window#paint in Ruby
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type"
content="text/html; charset=utf-8" /><style
type="text/css"><!--
#msg dl { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:'':'';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer { font-family:
verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;
font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fc0 solid; padding:
6px; }
#msg ul, pre { overflow: auto; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid;
padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family:
verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch
.binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<title>[704] trunk/wxruby2/lib: Auto-load classes from lib/wx/classes;
implement Window#paint in Ruby</title>
</head>
<body>
<div id="msg">
<dl>
<dt>Revision</dt> <dd>704</dd>
<dt>Author</dt> <dd>brokentoy</dd>
<dt>Date</dt> <dd>2006-10-21 20:45:22 -0400 (Sat, 21 Oct
2006)</dd>
</dl>
<h3>Log Message</h3>
<pre>Auto-load classes from lib/wx/classes; implement Window#paint in
Ruby</pre>
<h3>Modified Paths</h3>
<ul>
<li><a
href="#trunkwxruby2libwxrb">trunk/wxruby2/lib/wx.rb</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a
href="#trunkwxruby2libwxclassesapprb">trunk/wxruby2/lib/wx/classes/app.rb</a></li>
<li><a
href="#trunkwxruby2libwxclasseswindowrb">trunk/wxruby2/lib/wx/classes/window.rb</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwxruby2libwxclassesapprb"></a>
<div class="addfile"><h4>Added:
trunk/wxruby2/lib/wx/classes/app.rb (0 => 704)</h4>
<pre class="diff"><span>
<span class="info">---
trunk/wxruby2/lib/wx/classes/app.rb        
(rev 0)
+++
trunk/wxruby2/lib/wx/classes/app.rb        2006-10-22
00:45:22 UTC (rev 704)
</span><span class="lines">@@ -0,0 +1,10 @@
</span><ins>+# Copyright 2004-2006 by Kevin Smith
+# released under the MIT-style wxruby2 license
+
+class Wx::App
+ def on_assert(file, line, condition, message)
+ warn "ASSERT: #{file} #{line}"
+ warn condition
+ raise message
+ end
+end
</ins></span></pre></div>
<a id="trunkwxruby2libwxclasseswindowrb"></a>
<div class="addfile"><h4>Added:
trunk/wxruby2/lib/wx/classes/window.rb (0 => 704)</h4>
<pre class="diff"><span>
<span class="info">---
trunk/wxruby2/lib/wx/classes/window.rb        
(rev 0)
+++
trunk/wxruby2/lib/wx/classes/window.rb        2006-10-22
00:45:22 UTC (rev 704)
</span><span class="lines">@@ -0,0 +1,9 @@
</span><ins>+# Copyright 2004-2006 by Kevin Smith
+# released under the MIT-style wxruby2 license
+
+class Wx::Window
+ # create a DC for drawing on the window, run the block passing in the DC
+ def paint
+ yield Wx::PaintDC.new(self)
+ end
+end
</ins></span></pre></div>
<a id="trunkwxruby2libwxrb"></a>
<div class="modfile"><h4>Modified: trunk/wxruby2/lib/wx.rb
(703 => 704)</h4>
<pre class="diff"><span>
<span class="info">---
trunk/wxruby2/lib/wx.rb        2006-10-21
19:55:03 UTC (rev 703)
+++
trunk/wxruby2/lib/wx.rb        2006-10-22
00:45:22 UTC (rev 704)
</span><span class="lines">@@ -1,23 +1,23 @@
</span><del>-# rakewx.rb
-# Copyright 2004-2006 by Kevin Smith
-# released under the MIT-style wxruby2 license
</del><ins>+# Copyright 2004-2006 by Kevin Smith
+# released under the MIT-style wxruby2 license
</ins><span class="cx">
</span><del>-# This wrapper serves two functions:
-# 1. It allows apps to require ''wx'' but still have the binary
-# library properly named wxruby2.so or wxruby2.dll
-# 2. Later, we can add wrapper classes and methods here that can
-# expose a friendlier API than the C++ code provides
</del><ins>+# This wrapper serves three functions:
+# 1. It loads the binary library ''wxruby2.so'' or
''wxruby.dll'', while
+# still allowing applications to just require ''wx''.
+# 2. It sets up the version information
+# 3. It loads in ruby extensions to the core Wx classes.
</ins><span class="cx">
</span><span class="cx"> begin
</span><del>-        require
''wxruby2''
</del><ins>+ require ''wxruby2''
</ins><span class="cx"> rescue LoadError => e
</span><del>-        puts("Unable
to load wxruby. Searched:")
-        puts($LOAD_PATH)
-        exit(1)
</del><ins>+ warn "LoadError: unable to load wxruby2 binary.
Searched:"
+ warn $LOAD_PATH.inspect
+ exit 1
</ins><span class="cx"> end
</span><span class="cx">
</span><span class="cx"> Wx = Wxruby2
</span><span class="cx">
</span><ins>+# Load the version information (should be bundled with
all released versions)
</ins><span class="cx"> begin
</span><span class="cx"> require
''wx/version''
</span><span class="cx"> rescue LoadError
</span><span class="lines">@@ -25,11 +25,8 @@
</span><span class="cx"> Wx::WXRUBY_VERSION =
''0.0.0''
</span><span class="cx"> end
</span><span class="cx">
</span><del>-class Wx::App
-        def
on_assert(file, line, condition, message)
-                puts("ASSERT:
#{file} #{line}")
-                puts(condition)
-                puts(message)
-                raise
-        end
</del><ins>+# Load in all the class extension methods written in
ruby
+class_files = File.join( File.dirname(__FILE__), ''wx'',
''classes'', ''*.rb'')
+Dir.glob(class_files) do | class_file |
+ require ''wx/classes/'' + class_file[/\w+\.rb$/]
</ins><span class="cx"> end
</span></span></pre>
</div>
</div>
</body>
</html>
Maybe Matching Threads
- [1068] trunk/wxruby2/lib/wx.rb: Ensure evthandler.rb is loaded before other classes which might modify
- [750] trunk/wxruby2/lib/wx/classes/app.rb: Show messages generated by assertion failures, but don''t raise an
- [1003] trunk/wxruby2: Create correct WXWIDGETS_VERSION string constant instead of hardcoding
- [783] trunk/wxruby2: Tweak load error handling so failures with binary lib are reported correctly
- [794] trunk/wxruby2: Fix get_ruby_object so it works with SWIG tracking, move find_window_xx
