nobody at rubyforge.org
2007-Mar-22 00:22 UTC
[Wxruby-development] [910] branches/wxruby2/wxwidgets_282: Moved paint() method back into C++, so DC object is destroyed in timely
<!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>[910] branches/wxruby2/wxwidgets_282: Moved paint() method back
into C++, so DC object is destroyed in timely</title>
</head>
<body>
<div id="msg">
<dl>
<dt>Revision</dt> <dd>910</dd>
<dt>Author</dt> <dd>brokentoy</dd>
<dt>Date</dt> <dd>2007-03-21 20:22:49 -0400 (Wed, 21 Mar
2007)</dd>
</dl>
<h3>Log Message</h3>
<pre>Moved paint() method back into C++, so DC object is destroyed in
timely
fashion, preventing stream of Paint events (Artur Kuptel)</pre>
<h3>Modified Paths</h3>
<ul>
<li><a
href="#brancheswxruby2wxwidgets_282libwxclasseswindowrb">branches/wxruby2/wxwidgets_282/lib/wx/classes/window.rb</a></li>
<li><a
href="#brancheswxruby2wxwidgets_282swigclassesWindowi">branches/wxruby2/wxwidgets_282/swig/classes/Window.i</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a
id="brancheswxruby2wxwidgets_282libwxclasseswindowrb"></a>
<div class="modfile"><h4>Modified:
branches/wxruby2/wxwidgets_282/lib/wx/classes/window.rb (909 =>
910)</h4>
<pre class="diff"><span>
<span class="info">---
branches/wxruby2/wxwidgets_282/lib/wx/classes/window.rb        2007-03-21
10:54:07 UTC (rev 909)
+++
branches/wxruby2/wxwidgets_282/lib/wx/classes/window.rb        2007-03-22
00:22:49 UTC (rev 910)
</span><span class="lines">@@ -2,13 +2,6 @@
</span><span class="cx"> # released under the MIT-style
wxruby2 license
</span><span class="cx">
</span><span class="cx"> class Wx::Window
</span><del>- # Creates a device context which can be used for
drawing on the
- # window, and passes it into a block. Note that this method should
- # only be used within an on_paint handler.
- def paint
- yield Wx::PaintDC.new(self)
- end
-
</del><span class="cx"> # Recursively searches all
windows below +self+ and returns the first
</span><span class="cx"> # window which has the id
+an_id+. This corresponds to the find_window
</span><span class="cx"> # method method in WxWidgets
when called with an integer.
</span></span></pre></div>
<a
id="brancheswxruby2wxwidgets_282swigclassesWindowi"></a>
<div class="modfile"><h4>Modified:
branches/wxruby2/wxwidgets_282/swig/classes/Window.i (909 => 910)</h4>
<pre class="diff"><span>
<span class="info">---
branches/wxruby2/wxwidgets_282/swig/classes/Window.i        2007-03-21
10:54:07 UTC (rev 909)
+++
branches/wxruby2/wxwidgets_282/swig/classes/Window.i        2007-03-22
00:22:49 UTC (rev 910)
</span><span class="lines">@@ -105,6 +105,12 @@
</span><span class="cx"> %import
"include/wxObject.h"
</span><span class="cx"> %import
"include/wxEvtHandler.h"
</span><span class="cx">
</span><ins>+// needed for SWIG''s knowledge of PaintDC
type, for paint() method
+%import "include/wxDC.h"
+%import "include/wxWindowDC.h"
+%import "include/wxPaintDC.h"
+
+
</ins><span class="cx"> %include
"include/wxWindow.h"
</span><span class="cx">
</span><span class="cx"> %extend wxWindow {
</span><span class="lines">@@ -137,4 +143,17 @@
</span><span class="cx">
</span><span class="cx"> return returnVal;
</span><span class="cx"> }
</span><ins>+ VALUE paint()
+ {
+        wxWindow
*ptr = self;
+        if (
rb_block_given_p() )
+         {
+                wxPaintDC
dc(ptr);
+                VALUE
dcVal = SWIG_NewPointerObj((void *) &dc,SWIGTYPE_p_wxPaintDC, 0);
+                rb_yield(dcVal);
+                SWIG_RubyRemoveTracking((void
*) &dc);
+                DATA_PTR(dcVal)
= NULL;
+         }
+        return
Qnil;
+ }
</ins><span class="cx"> }
</span></span></pre>
</div>
</div>
</body>
</html>
Reasonably Related Threads
- [983] branches/wxruby2/wxwidgets_282: Make Window#paint work both inside and outside a paint event handler,
- [992] branches/wxruby2/wxwidgets_282/lib/wx/classes/window.rb: Fix passing of PaintEvent object in paint handler
- [973] branches/wxruby2/wxwidgets_282/swig/classes/Window.i: Fix crasher with Window#get_handle, also comment the paint method
- [980] branches/wxruby2/wxwidgets_282/samples/bigdemo/ShapedWindow.rbw: Use Window#paint instead of PaintDC.new
- [981] branches/wxruby2/wxwidgets_282/samples/caret/caret.rb: Don''t call PaintDC.new; just refresh() instead of duplicating paint code
