# WxRuby "source code"

**URL:** <https://www.ruby-forum.com/t/wxruby-source-code/166816>\
**Category:** Ruby\
**Created:** [April 29, 2009, 8:50pm UTC](https://www.ruby-forum.com/t/wxruby-source-code/166816 "2009-04-29T20:50:13Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![pitosalas](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/a4c791/32.png) [@pitosalas](https://www.ruby-forum.com/u/pitosalas)\
**Post date:** [April 29, 2009, 8:50pm UTC](https://www.ruby-forum.com/t/wxruby-source-code/166816/1 "2009-04-29T20:50:13Z")

</div>

I was trying to figure out what the correct parameters are for  
ScrolledWindow.new.

In the doc I saw some detrails  
([http://wxruby.rubyforge.org/doc/scrolledwindow.html#ScrolledWindow\_new](http://wxruby.rubyforge.org/doc/scrolledwindow.html#ScrolledWindow_new))  
but I still couldnt see what I was doing wrong.

So I looked at the sources for the gem, and found no explicit definition  
of the class and methods, but a mention of wxruby2, the ‘binary  
library’. What’s that?

Then looking deeper I found the wxruby2 gem’s sources, where again no  
explicit mention about ScrolledWindow.new. It looks to me like wxruby2  
is a ruby “api” to the underlying c library. There’s mention of Swig,  
what’s that?

And then within wxruby2/swig/classes/scrolledwindow.i I find this  
inscrutable stuff (see below)… Does that somehow explain what the  
RUBY parameters are for ScrolledWindow?

I think I am almost but not grasping the mapping. Can anyone clarify or  
point me to a clarification? Thanks!

Pito

----- Referenced above -----

// Copyright 2004-2008, wxRuby development team  
// released under the MIT-like wxRuby2 license

%include “…/common.i”

%{  
#include \<wx/scrolwin.h\>  
%}

%module(directors=“1”) wxScrolledWindow  
GC\_MANAGE\_AS\_WINDOW(wxScrolledWindow);  
SWIG\_WXWINDOW\_NO\_USELESS\_VIRTUALS(wxScrolledWindow);

%apply int \* OUTPUT { int \* }

%import “include/wxObject.h”  
%import “include/wxEvtHandler.h”  
%import “include/wxWindow.h”  
%import “include/wxPanel.h”

%include “include/wxScrolledWindow.h”

---

<div class="post-metadata">

**Author:** ![pitosalas](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/a4c791/32.png) [@pitosalas](https://www.ruby-forum.com/u/pitosalas)\
**Post date:** [April 29, 2009, 9:41pm UTC](https://www.ruby-forum.com/t/wxruby-source-code/166816/2 "2009-04-29T21:41:22Z")

</div>

On Wednesday 29 April 2009, Pito S. wrote:

> |  
> |Then looking deeper I found the wxruby2 gem’s sources, where again no  
> |explicit mention about ScrolledWindow.new. It looks to me like wxruby2  
> |is a ruby “api” to the underlying c library. There’s mention of Swig,  
> |what’s that?

You’re right, wxruby2 is a ruby binding to the WxWidgets C++ library  
([http://wxwidgets.org/](http://wxwidgets.org/)). Swig ([http://www.swig.org/](http://www.swig.org/)) is a tool which  
makes  
eaiser to generate bindings from C(++) to several other language,  
including  
ruby by automatically create some of the code needed to do so. The  
scrolledwindow.i file you mention below is one of the files needed by  
Swig  
and, if I’m not mistaken (I’ve never used Swig myself) it plays a role  
similar  
to those of .h files in C.

As for your problem, I think the wxwidgets web site may have some more  
documentation, but it will be for C++, so there will be differences from  
ruby.  
Other than that, you can ask on the wxruby mailing list  
([http://wxruby.rubyforge.org/wiki/wiki.pl?MailingLists](http://wxruby.rubyforge.org/wiki/wiki.pl?MailingLists)), or even here.  
In any  
case, you’ll need to post the code which causes the problem, or at least  
explain what the problem is and post any error message you think  
relevant.

I hope this helps

Stefano

---

<div class="post-metadata">

**Author:** ![pitosalas](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/a4c791/32.png) [@pitosalas](https://www.ruby-forum.com/u/pitosalas)\
**Post date:** [April 30, 2009, 12:10am UTC](https://www.ruby-forum.com/t/wxruby-source-code/166816/3 "2009-04-30T00:10:54Z")

</div>

Pito S. wrote:

> I was trying to figure out what the correct parameters are for  
> ScrolledWindow.new.
> 
> In the doc I saw some detrails  
> ([http://wxruby.rubyforge.org/doc/scrolledwindow.html#ScrolledWindow\_new](http://wxruby.rubyforge.org/doc/scrolledwindow.html#ScrolledWindow_new))  
> but I still couldnt see what I was doing wrong.

The parameters in the docs are correct I think. After you create the  
ScrolledWindow you need to set up the scroll bars (eg using  
set\_virtual\_size and set\_scroll\_rate) as described at the top of the doc  
page.

There are examples of using ScrolledWindow in the samples (though the  
sample is a bit over-elaborate), or here:  
[http://weft-qda.rubyforge.org/svn/trunk/weft-qda/lib/weft/wxgui/controls/image\_viewer.rb](http://weft-qda.rubyforge.org/svn/trunk/weft-qda/lib/weft/wxgui/controls/image_viewer.rb)

As Stefan says, you can get help on the mailing list if you post some  
code, and a description of an error message or what’s not working.

> So I looked at the sources for the gem, and found no explicit definition  
> of the class and methods, but a mention of wxruby2, the ‘binary  
> library’. What’s that?

It’s the compiled file (called wxruby2.so or similar) which provides  
most of the core wxRuby API.

> Then looking deeper I found the wxruby2 gem’s sources, where again no  
> explicit mention about ScrolledWindow.new. It looks to me like wxruby2  
> is a ruby “api” to the underlying c library. There’s mention of Swig,  
> what’s that?
> 
> And then within wxruby2/swig/classes/scrolledwindow.i I find this  
> inscrutable stuff (see below)… Does that somehow explain what the  
> RUBY parameters are for ScrolledWindow?

Partly, and also a file included from there,  
swig/classes/include/wxScrolledWindow.h, and various other inscrutable  
bits of SWIG stuff.

For learning and using the API I would definitely stick to the samples  
and docs which should cover all the API, and feel free to ask for help  
on the list.

alex
