Hi Carlos,

Sorry for the delay in replying - family takes priority over the
Christmas period.

I think I understand what you are looking for. The key, I think
(and I must admit that I have always found Layout to be a little
confusing - it probably deserves more investigation and better
documentation), is to understand that using layout makes a strong
effort to make all widgets appear on the controlled window
without any need for scrolling.

I performed many experiments, and whenever the Frame in the code
below is given a Layout, the size of the ScrolledWindow is
expanded to be large enough to fit all widgets. I haven't yet
determined whether this is a bug or designed behaviour, but it is
not what I expected.

The example below is closer to what you want - although I should
note that setting the ScrolledWindow style to force vertical and
horizontal scroll bars doesn't seem to have any effect - you only
get the scroll bars you need.

In the example, instead of doing something like:

set f [layout := container pnl $ column 5 [....

I instead perform the layout in the ScrolledWindow, taking care
to set the clientSize to the size I need the ScrolledWindow to
take up (this is critical).

I then call windowReLayoutMinimal f, which causes the Frame to be
fitted to the smallest size required to contain the child window
(i.e. pnl - in this case 100 x 100).

Hope this helps.

Best regards
Jeremy

module Main where
import Data.Bits
import Graphics.UI.WXCore
import Graphics.UI.WX
main :: IO ()
main = start gui
gui :: IO ()
gui = do f   <- frame   [text := "Frame"]
         pnl <- scrolledWindow f [ scrollRate  := sz 20 20 ]
         sal1 <- staticText pnl [ text := "This is an example of
using an scroll bar with wxhaskell, it looks like don't work, so
it's true?" ]
         sal2 <- staticText pnl [ text := "staticText2" ]
         sal3 <- staticText pnl [ text := "staticText3" ]
         sal4 <- staticText pnl [ text := "staticText4" ]
         sal5 <- staticText pnl [ text := "staticText5" ]
         sal6 <- staticText pnl [ text := "staticText6" ]
         set pnl  [ layout := column 5 [ widget sal1,
                                         widget sal2,
                                         widget sal3,
                                         widget sal4,
                                         widget sal5,
                                         widget sal6],
                    clientSize := sz 100 100,
                    style := wxHSCROLL .|. wxVSCROLL]
         windowReLayoutMinimal f
         return ()
On Fri, 25 Dec 2009 23:15 -0400, "carlos gomez"
<carliro...@gmail.com> wrote:

  The example you put is good, but it is not what I want.

I want to use the scroll bar of a window (like panel or
scrolledwindow), and move the scroll bar to see the parts not
visible of elements that can contain the panel.

In your example, every textCtrl could have his own scroll bar,
but I want only one for all elements, and it have to be in the
panel container of the elements.



As I read in wxwidget, an easy and automatic way to configure the
scroll bar in a scrolledWindow is using scrollRate. Then the
scrolledWindow will use the Sizer (Layout in wxHaskell) to set
the virtualSize and the clientSize of the panel to set the
pageSize of the scrolledWindow.



I wrote an example in wxwidget, and the same example in wxhaskell
didn't work. I wonder why didn't work and how can i fix.



-----------------------------------------------------------

#include <wx/wx.h>
#include <wx/wxhtml.h>
#include <wx/scrolwin.h>

class MyApp: public wxApp
{
    virtual bool OnInit();
};

class MyFrame: public wxFrame
{
public:
    MyFrame(const wxString& title, const wxPoint& pos, const
wxSize& size);
};

IMPLEMENT_APP(MyApp)

bool MyApp::OnInit()
{
    MyFrame *frame = new MyFrame( _("Hello World"), wxPoint(50,
50), wxSize(450, 340) );
    frame->Show(true);
    SetTopWindow(frame);
    return true;
}

MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const
wxSize& size)
       : wxFrame(NULL, -1, title, pos, size)
{

    wxScrolledWindow* scrolledWindow = new wxScrolledWindow (
            this, wxID_ANY, wxPoint (0, 0), wxSize (400, 400),
            wxVSCROLL | wxHSCROLL);

    //scrolledWindow->SetScrollbars(20, 20, 200, 200);

    scrolledWindow->SetScrollRate(10, 10);

    wxStaticText* staticText1 = new wxStaticText(
        scrolledWindow,
        wxID_STATIC,
        wxT("This is an example to verify the functionality of
scrolledWindow in wxwidget, so let's go to see what's going
on!!!!."),
        wxDefaultPosition,
        wxDefaultSize,
        wxALIGN_LEFT);

    wxStaticText* staticText2 = new wxStaticText(
        scrolledWindow,
        wxID_STATIC,
        wxT("staticText 2."),
        wxDefaultPosition,
        wxDefaultSize,
        wxALIGN_LEFT);


    wxBoxSizer *topSizerSW = new wxBoxSizer (wxVERTICAL);
    topSizerSW->Add(staticText1, 1, wxEXPAND | wxALL, 10);
    topSizerSW->Add(staticText2, 1, wxEXPAND | wxALL, 10);

    scrolledWindow->SetSizer(topSizerSW);

}
---------------------------------------------------------



---------------------------------------------------------

module Main where

import Graphics.UI.WXCore
import Graphics.UI.WX
import Data.Bits

main :: IO()
main = start gui

gui :: IO()
gui = do f  <- frame [text := "Frame"]
         sw <- scrolledWindow f [ scrollRate := sz 10 10
                                           , style      :=
wxVSCROLL .|. wxHSCROLL
                                           ]
         st1 <- staticText sw [text := "This is an example to
verify the functionality of scrolledWindow in wxwidget, so let's
go to see what's going on!!!!."]
         st2 <- staticText sw [text := "staticText 2."]
         set sw [layout := column 5 [ expand $ widget st1
                                                , expand $ widget
st2
                                                 ]
                    ]
         set f [layout := fill $ widget sw]
         return ()

---------------------------------------------------------
2009/12/23 Jeremy O'Donoghue <[1]jeremy.odonog...@gmail.com>

Hi Carlos,

I assume from the posted code that what you really want is a
StaticText widget with a scroll bar, and that you wish to 'force'
the scroll bar to be present at all times (default behaviour of
all widgets is that scroll bars appear only when they are
needed).

The code I have just tested to do this is:

module Main where
import Data.Bits
import Graphics.UI.WXCore
import Graphics.UI.WX
main :: IO ()
main = start gui
gui :: IO ()
gui = do f   <- frame   [text := "Frame"]
         tcl <- textCtrl f [text := "This is an example of using
an scroll bar with wxhaskell, it looks like don't work, so it's
true?",
                            style := wxTE_READONLY .|. wxHSCROLL
.|. wxVSCROLL]
         set f  [layout := fill $ widget tcl, clientSize := sz
200 200]
         return ()

Compared to your code, there are a few differences:

It is sufficient, for simple cases, to simply set the wxHSCROLL
and/or wxVSCROLL style on most windows if you want them to have
permanent scroll bars. The wxTE_READONLY style replicates a
StaticText (i.e. it sets text control to be read only) but with
multiple lines. If you just want a single line, StaticText can be
used instead.

You should set a clientSize on the parent frame - if you do not,
all widgets will be fittedt to their minimum possible size. The
use of the fill combinator in the layout indicates that I want
the TextCtrl to fit the whole of the allocated space.

Hope this helps.

Best regards
Jeremy


On Tue, 22 Dec 2009 20:41 -0400, "carlos gomez"
<[2]carliro...@gmail.com> wrote:

  Hi all



I am trying to use scrolled windows with wxhaskell, but it
doesn't work,



Am I doing rightly?



here is the code:

----------------------------------------------------

module Gui where

import Graphics.UI.WXCore
import Graphics.UI.WX

main :: IO ()
main = start gui

gui :: IO ()
gui = do f   <- frame   [text := "Frame"]
         pnl <- scrolledWindow f [scrollRate := sz 20 20]
         sal <- staticText pnl [text := "This is an example of
using an scroll bar with wxhaskell, it looks like don't work, so
it's true?"]
         set pnl [layout := widget sal]
         set f  [layout := column 5 [widget pnl]]
         return ()
----------------------------------------------------

--carlos

--
  Jeremy O'Donoghue
  [3]jeremy.odonog...@gmail.com

References

1. mailto:jeremy.odonog...@gmail.com
2. mailto:carliro...@gmail.com
3. mailto:jeremy.odonog...@gmail.com
-- 
  Jeremy O'Donoghue
  jeremy.odonog...@gmail.com

------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
_______________________________________________
wxhaskell-users mailing list
wxhaskell-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wxhaskell-users

Reply via email to