From: David R. <dr...@jd...> - 2003-10-05 22:48:27
|
Hello. I'm unclear as to how to get a scrolledWindow to work properly with sizers. In the following example, I don't get a scrollbar, and can't seem to figure out how to make the size of the ScrolledWindow be smaller than the size of its contents: main = start $ do f<- frame [text := "Test"] scrolled <- scrolledWindow f [layout := column 0 $ take 47 labels, scrollRate := size 10 10] quit <- button f [text := "Quit", on command := close f] set f [layout := column 5 [fill $ widget scrolled, centre $ widget quit] labels = map (floatLeft . label . ("Label "++) . show) [1..] I've essentially been trying things at random, but have no real idea as to how to make this work right. -- David Roundy http://www.abridgegame.org/darcs |
From: carlos g. <car...@gm...> - 2009-12-23 00:41:21
|
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 |
From: Jeremy O'D. <jer...@gm...> - 2009-12-23 16:35:09
|
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" <car...@gm...> 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 jer...@gm... |
From: carlos g. <car...@gm...> - 2009-12-26 03:15:30
|
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 <jer...@gm...> > 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" <car...@gm...> > 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 > jer...@gm... > > |
From: Jeremy O'D. <jer...@gm...> - 2010-01-04 11:56:55
|
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" <car...@gm...> 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]jer...@gm...> 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]car...@gm...> 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]jer...@gm... References 1. mailto:jer...@gm... 2. mailto:car...@gm... 3. mailto:jer...@gm... -- Jeremy O'Donoghue jer...@gm... |
From: Daan L. <daa...@xs...> - 2003-10-07 09:22:53
|
Hi David, > Hello. I'm unclear as to how to get a scrolledWindow to work > properly with sizers. In the following example, I don't get a scrollbar, Well, I am not a wxWindows expert either. However, I think that you always have to set the "virtualSize" of a scrolled window to get the sizer working. In your example, you set the "scrollRate", but forget to set the "virtualSize". Maybe that is the cause of the problems? Hope this helps, Daan. > and can't seem > to figure out how to make the size of the ScrolledWindow be > smaller than > the size of its contents: > > main = start $ do f<- frame [text := "Test"] > scrolled <- scrolledWindow f > [layout := column 0 $ take 47 labels, > scrollRate := size 10 10] > quit <- button f [text := "Quit", on > command := close f] > set f [layout := column 5 [fill $ widget scrolled, > centre $ widget quit] > > labels = map (floatLeft . label . ("Label "++) . show) [1..] > > I've essentially been trying things at random, but have no > real idea as to > how to make this work right. > -- > David Roundy > http://www.abridgegame.org/darcs > > > ------------------------------------------------------- > This sf.net email is sponsored by:ThinkGeek > Welcome to geek heaven. > http://thinkgeek.com/sf > _______________________________________________ > wxhaskell-users mailing list > wxh...@li... > https://lists.sourceforge.net/lists/listinfo/wxhaskell-users > > |
From: David R. <dr...@jd...> - 2003-10-07 11:51:50
|
On Tue, Oct 07, 2003 at 11:22:47AM +0200, Daan Leijen wrote: > Hi David, > > > Hello. I'm unclear as to how to get a scrolledWindow to work properly > > with sizers. In the following example, I don't get a scrollbar, > > Well, I am not a wxWindows expert either. However, I think that you > always have to set the "virtualSize" of a scrolled window to get the > sizer working. In your example, you set the "scrollRate", but forget to > set the "virtualSize". Maybe that is the cause of the problems? According to the wxwin docs, it seems that if you use a sizer with the wxScrolledWindow, it can determine the virtualSize from the sizer data. My problem is in making the actual size of the window smaller than the virtual size. I've figured out a rather ugly solution. The following code works: \begin{code} module Main where import Graphics.UI.WX import Graphics.UI.WXCore.WxcClasses ( windowSetSizeHints ) main = start $ hello hello = do f <- frame [text := "Hello Scrollbars!"] scrolled <- scrolledWindow f [layout := rigid $ column 0 $ take 47 labels, scrollRate := size 10 10] windowSetSizeHints scrolled (-1) (-1) (-1) (-1) (-1) (-1) set f [clientSize := size 100 100] quit <- button f [text := "Quit", on command := close f] set f [layout := column 0 [fill $ widget scrolled, centre $ hstretch $ margin 5 $ widget quit]] where labels = map (floatLeft . label . ("Label Number "++) . show) [1..] \end{code} Interestingly, if you move the set f clientSize either after the "quit <-" line or before the windowSetSizeHints line, the code no longer works. In either case, "scrolled" is set to be the size of its contents, and cannot be resized to be smaller. The windowSetSizeHints call is interesting, as it just sets the size hints to their default values (that's what all the -1s are about), so it suggests that someone is setting them to non-default values... (since without that call, the code won't work). -- David Roundy http://www.abridgegame.org |