[wxruby-users] how can I use draw line in wxruby??

Mario Steele mario at ruby-im.net
Wed Jan 2 04:00:32 EST 2008


Hello Bass Guitar,

Unfortunately, you cannot instantiate the DC (Device Context) directly from
the DC Class.  You need to utilize Window#draw or Window#paint to create a
DC.  The difference between these two methods, is that when you are in a
paint event (EG: evt_paint), you utilize the Window#paint method to acquire
a Device Context.  When your outside of the paint event, you utilize
Window#draw to acquire the Device Context.

An Example of inside an paint event would be this:

evt_paint() do
  self.paint do |dc|
    dc.draw_line(50, 50, 100, 100)
  end
end

And an example of how to draw outside of a paint event:

def run_draw()
  self.draw do |dc|
    dc.draw_line(50, 50, 100, 100)
  end
end

Once you implement this, it will work.

L8ers,

Mario Steele

On 1/2/08, Bass Guitar <lists at ruby-forum.com> wrote:
>
> I use
>
> dc = DC.new()
> dc.draw_line(50,  50,  100, 100)
>
> but it can't be compiled
> I don't know how to declare DC variable??
> in http://wxruby.rubyforge.org/doc/dc.html
> it don't tell me how to declare now variable
> plese tell me :'(
> --
> Posted via http://www.ruby-forum.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/20080102/130bb4e7/attachment-0001.html 


More information about the wxruby-users mailing list