Ann Maybury
2011-May-08 23:59 UTC
Device context (get_dc) Question from printing.rb in wxRuby samples
I am using Windows XP SP 3 but want to stay general.
Below is a method within printing.rb. I have added comments marked by #--.
My question is about get_dc. The device context is obviously created and
the code works as presented.
It also works as documented below. Why does just get_dc satisfy the
linkage?
When does one use the Wx:: or the Wx::PrintOut format? How does one decide
to use just the short form?
Where could I have found this answer?
<Code>
def on_print_page(page)
dc = get_dc #-- don;''t understand where get_dc comes from
#--Wx::get_dc works
#-- Wx::PrintOut.get_dc also works
#--PrintOut.get_dc also works
#-- looks like just get_dc is ok, why and
when
#-- the variable dc is probably a class
or module but
#-- where do I find its definition?
if dc
if page == 1
draw_page_one(dc) ##-- dc = device context passed in
elsif (page == 2)
draw_page_two(dc) ##-- dc = device context passed in
end
dc.set_device_origin(0, 0)
dc.set_user_scale(1.0, 1.0)
buf = "PAGE #{page}"
dc.draw_text(buf, 10, 10)
return true
else
return false
end
end #--end of on_print_page
--
Ann Maybury
ann.maybury@gmail.com
_______________________________________________
wxruby-users mailing list
wxruby-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/wxruby-users
Phillip & Kerrie Shelton
2011-May-10 23:31 UTC
[wxruby-users] Device context (get_dc) Question from printing.rb in wxRuby samples
It has a lot to do with scope.
On 09/05/2011 10:38 AM, "Ann Maybury" <ann.maybury at gmail.com>
wrote:
I am using Windows XP SP 3 but want to stay general.
Below is a method within printing.rb. I have added comments marked by #--.
My question is about get_dc. The device context is obviously created and
the code works as presented.
It also works as documented below. Why does just get_dc satisfy the
linkage?
When does one use the Wx:: or the Wx::PrintOut format? How does one decide
to use just the short form?
Where could I have found this answer?
<Code>
def on_print_page(page)
dc = get_dc #-- don;''t understand where get_dc comes from
#--Wx::get_dc works
#-- Wx::PrintOut.get_dc also works
#--PrintOut.get_dc also works
#-- looks like just get_dc is ok, why and
when
#-- the variable dc is probably a class
or module but
#-- where do I find its definition?
if dc
if page == 1
draw_page_one(dc) ##-- dc = device context passed in
elsif (page == 2)
draw_page_two(dc) ##-- dc = device context passed in
end
dc.set_device_origin(0, 0)
dc.set_user_scale(1.0, 1.0)
buf = "PAGE #{page}"
dc.draw_text(buf, 10, 10)
return true
else
return false
end
end #--end of on_print_page
--
Ann Maybury
ann.maybury at gmail.com
_______________________________________________
wxruby-users mailing list
wxruby-users at rubyforge.org
http://rubyforge.org/mailman/listinfo/wxruby-users
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://rubyforge.org/pipermail/wxruby-users/attachments/20110511/7a26413b/attachment.html>
Alex Fenton
2011-May-15 21:09 UTC
[wxruby-users] Device context (get_dc) Question from printing.rb in wxRuby samples
On 09/05/11 00:59, Ann Maybury wrote:> Below is a method within printing.rb. I have added comments marked > by #--. > My question is about get_dc. The device context is obviously created > and the code works as presented. > It also works as documented below. Why does just get_dc satisfy the > linkage? > When does one use the Wx:: or the Wx::PrintOut format? How does one > decide to use just the short form?get_dc is an instance method of Wx::Printout, and in the sample, it''s called from within a class that inherits from that.> Where could I have found this answer?http://wxruby.rubyforge.org/doc/printout.html#Printout_getdc> <Code> > def on_print_page(page) > dc = get_dc #-- don;''t understand where get_dc comes from > #--Wx::get_dc works > #-- Wx::PrintOut.get_dc also works > #--PrintOut.get_dc also works > #-- looks like just get_dc is ok, > why and when > #-- the variable dc is probably a > class or module but > #-- where do I find its definition?I don''t think PrintOut.get_dc or Wx::get_dc will work? There are no such class/module methods in either Wx::Printout or the global Wx:: module. alex -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/wxruby-users/attachments/20110515/b66aa56f/attachment.html>
Maybe Matching Threads
- 0.0.39 etc
- [680] trunk/wxruby2/samples/printing/printing.rb: Cleaned up to use the Ruby naming convention, added #! line, now uses Wx default ID''s in standard menu items.
- First drop of new memory management
- Wine release 2.17
- [922] branches/wxruby2/wxwidgets_282: Changes, additions and deprecations 2.6 -> 2.8 Wx API