# Parallel lines in a ScrolledWindow

**URL:** <https://www.ruby-forum.com/t/parallel-lines-in-a-scrolledwindow/164635>\
**Category:** wxRuby\
**Created:** [April 3, 2009, 3:02pm UTC](https://www.ruby-forum.com/t/parallel-lines-in-a-scrolledwindow/164635 "2009-04-03T15:02:35Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Svend\_Haugaard\_SSSS](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c68b51/32.png) [@Svend\_Haugaard\_SSSS](https://www.ruby-forum.com/u/Svend_Haugaard_SSSS)\
**Post date:** [April 3, 2009, 3:02pm UTC](https://www.ruby-forum.com/t/parallel-lines-in-a-scrolledwindow/164635/1 "2009-04-03T15:02:35Z")

</div>

Hey.

I am trying to figure out how access all the  
client area in an evt\_paint in a scrolled window.

I have made a little demo program, where I try  
to draw 2 parallel lines, and when scrolling  
the lines, they should stay parallel and the  
distance between them should increse.

But since only the ‘new’ area gets redrawen  
the lines don’t become parallel.

How can I fix it so that they becomes parallel?

---

<div class="post-metadata">

**Author:** ![Svend\_Haugaard\_SSSS](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c68b51/32.png) [@Svend\_Haugaard\_SSSS](https://www.ruby-forum.com/u/Svend_Haugaard_SSSS)\
**Post date:** [April 5, 2009, 10:43am UTC](https://www.ruby-forum.com/t/parallel-lines-in-a-scrolledwindow/164635/2 "2009-04-05T10:43:37Z")

</div>

Hello Svend,

You may want to take a look at the wxScrolledWindow code in BigDemo.rb,  
in  
the samples directory. You should be able to find code in there, that  
offers references points in the client area, where to keep track of  
where  
the user draws lines, and you can start to scroll through things.

You should be able to see in the code, where the drawing of the user  
input  
with the mouse (MouseEvent), to see where it grabs the client position,  
and  
normalizes it to where you are in the actual view of the client view,  
compared to the Canvas.

hth,

Mario

2009/4/3 Svend Haugaard SÃ¸rensen [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![Svend\_Haugaard\_SSSS](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c68b51/32.png) [@Svend\_Haugaard\_SSSS](https://www.ruby-forum.com/u/Svend_Haugaard_SSSS)\
**Post date:** [April 5, 2009, 2:32pm UTC](https://www.ruby-forum.com/t/parallel-lines-in-a-scrolledwindow/164635/3 "2009-04-05T14:32:01Z")

</div>

> normalizes it to where you are in the actual view of the client view,  
> compared to the Canvas.

Thank your for the reply, unfortunately your have totally misunderstood  
the question.

Simple conversation of user input coordinates to window coordinates  
I have solve long ago.

Try to run my program and your and your will see that the parallel lines  
gets tilted when your scrool the window.  
I am tying to update the hole client area at once.

---

<div class="post-metadata">

**Author:** ![Svend\_Haugaard\_SSSS](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c68b51/32.png) [@Svend\_Haugaard\_SSSS](https://www.ruby-forum.com/u/Svend_Haugaard_SSSS)\
**Post date:** [April 5, 2009, 11:20pm UTC](https://www.ruby-forum.com/t/parallel-lines-in-a-scrolledwindow/164635/4 "2009-04-05T23:20:26Z")

</div>

Svend Haugaard Sørensen wrote:

> But since only the ‘new’ area gets redrawen  
> the lines don’t become parallel.
> 
> How can I fix it so that they becomes parallel?

I think you want something like (untested)

evt\_scroll { refresh }

Calling refresh() tells wxRuby that the whole window is invalidated and  
needs to be redrawn, not just the parts of the window that have newly  
been scrolled into view.

By the way, it’s useful to mention what OS you’re using. For example, I  
don’t see what you describe when I run your program on OS X- it works  
the way I think you want it to work - probably because different OSes  
handle drawing and buffering slightly differently.

alex
