nobody at rubyforge.org
2007-Jul-20 18:15 UTC
[Wxruby-development] [1124] trunk/wxruby2/samples/bigdemo/wxGauge.rbw: Use Wx::Timer instead of evt_idle to drive Gauge sample, to avoid 100%
<!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>[1124] trunk/wxruby2/samples/bigdemo/wxGauge.rbw: Use Wx::Timer
instead of evt_idle to drive Gauge sample, to avoid 100%</title>
</head>
<body>
<div id="msg">
<dl>
<dt>Revision</dt> <dd>1124</dd>
<dt>Author</dt> <dd>brokentoy</dd>
<dt>Date</dt> <dd>2007-07-20 14:15:11 -0400 (Fri, 20 Jul
2007)</dd>
</dl>
<h3>Log Message</h3>
<pre>Use Wx::Timer instead of evt_idle to drive Gauge sample, to avoid
100%
CPU usage</pre>
<h3>Modified Paths</h3>
<ul>
<li><a
href="#trunkwxruby2samplesbigdemowxGaugerbw">trunk/wxruby2/samples/bigdemo/wxGauge.rbw</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwxruby2samplesbigdemowxGaugerbw"></a>
<div class="modfile"><h4>Modified:
trunk/wxruby2/samples/bigdemo/wxGauge.rbw (1123 => 1124)</h4>
<pre class="diff"><span>
<span class="info">---
trunk/wxruby2/samples/bigdemo/wxGauge.rbw        2007-07-20
08:58:51 UTC (rev 1123)
+++
trunk/wxruby2/samples/bigdemo/wxGauge.rbw        2007-07-20
18:15:11 UTC (rev 1124)
</span><span class="lines">@@ -12,55 +12,58 @@
</span><span class="cx"> end
</span><span class="cx">
</span><span class="cx"> class TestPanel < Wx::Panel
</span><del>- def initialize(parent, log)
- super(parent, -1)
- @log = log
- @count = 0
-
- Wx::StaticText.new(self, -1, "This example shows the wxGauge
control.", Wx::Point.new(45,15))
-
- @g1 = Wx::Gauge.new(self, -1, 50, Wx::Point.new(110,50),
Wx::Size.new(250,25))
- @g1.set_bezel_face(3)
- @g1.set_shadow_width(3)
-
- @g2 = Wx::Gauge.new(self, -1, 50, Wx::Point.new(110,95),
Wx::Size.new(250,25), Wx::GA_HORIZONTAL | Wx::GA_SMOOTH)
- @g2.set_bezel_face(5)
- @g2.set_shadow_width(5)
-
- @g3 = Wx::Gauge.new(self, -1, 50, Wx::Point.new(110, 140),
Wx::Size.new(25,250), Wx::GA_VERTICAL)
- @g3.set_bezel_face(3)
- @g3.set_shadow_width(3)
-
- evt_idle {|event| idle_handler(event)}
- end
</del><ins>+ def initialize(parent, log)
+ super(parent, -1)
+ @log = log
+ @count = 0
</ins><span class="cx">
</span><del>- def idle_handler(event)
- @count = @count + 1
- if @count > 50
- @count = 0
- end
- @g1.set_value(@count)
- @g2.set_value(@count)
- @g3.set_value(@count)
-
- # Tells wxWindows that more processing is required. This function can
be called by an OnIdle handler
- # for a window or window event handler to indicate that wxApp::OnIdle
should forward the OnIdle event
- # once more to the application windows. If no window calls this
function during OnIdle, then the
- # application will remain in a passive event loop (not calling OnIdle)
until a new event is posted to
- # the application by the windowing system.
- event.request_more()
</del><ins>+ Wx::StaticText.new( self, -1, "This example
shows the wxGauge control.",
+ Wx::Point.new(45,15))
+
+ @g1 = Wx::Gauge.new( self, -1, 50,
+ Wx::Point.new(110,50), Wx::Size.new(250,25))
+ @g1.set_bezel_face(3)
+ @g1.set_shadow_width(3)
+
+ @g2 = Wx::Gauge.new( self, -1, 50,
+ Wx::Point.new(110,95), Wx::Size.new(250,25),
+ Wx::GA_HORIZONTAL|Wx::GA_SMOOTH)
+ @g2.set_bezel_face(5)
+ @g2.set_shadow_width(5)
+
+ @g3 = Wx::Gauge.new( self, -1, 50,
+ Wx::Point.new(110, 140), Wx::Size.new(25,250),
+ Wx::GA_VERTICAL)
+ @g3.set_bezel_face(3)
+ @g3.set_shadow_width(3)
+
+ # start a timer to move the gauges forward every 1/4 s
+ timer = Wx::Timer.new(self, 5001)
+ evt_timer(5001) { move_gauges }
+ timer.start(250)
+ end
+
+ # advance the gauges
+ def move_gauges
+ @count +=1
+ if @count > 50
+ @count = 0
</ins><span class="cx"> end
</span><ins>+ @g1.set_value(@count)
+ @g2.set_value(@count)
+ @g3.set_value(@count)
+ end
</ins><span class="cx"> end
</span><span class="cx">
</span><span class="cx"> module Demo
</span><del>- def Demo.run(frame, nb, log)
- win = TestPanel.new(nb, log)
- return win
- end
-
- def Demo.overview
- return "A gauge is a horizontal or vertical bar which shows a
quantity (often time). "
- end
</del><ins>+ def Demo.run(frame, nb, log)
+ win = TestPanel.new(nb, log)
+ return win
+ end
+
+ def Demo.overview
+ return "A gauge is a horizontal or vertical bar which shows a quantity
(often time). "
+ end
</ins><span class="cx"> end
</span><span class="cx">
</span><span class="cx"> if __FILE__ == $0
</span></span></pre>
</div>
</div>
</body>
</html>
Reasonably Related Threads
- [949] branches/wxruby2/wxwidgets_282: Changes in Gauge API 2.6->2.8, remove comment cruft in header
- Refreshing the GUI and packing images
- getGraphicsEvent() alternative for cairo graphics device?
- [1078] trunk/wxruby2: Map evt_spinctrl to SpinEvent instead of CommandEvent; add example to bigdemo
- find_window_by_xxx doesn''t find Gauge or BitmapButton
