Re: scrolledWindow
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 ()
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 whereimport Graphics.UI.WXCoreimport Graphics.UI.WXimport Data.Bitsmain :: IO()main = start guigui :: 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 <jeremy.odonoghue-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>-- Jeremy O'Donoghue jeremy.odonoghue-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.orgHi 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.Bitstcl <- textCtrl f [text := "This is an example of using an scroll bar with wxhaskell, it looks like don't work, so it's true?",
import Graphics.UI.WXCore
import Graphics.UI.WX
main :: IO ()
main = start gui
gui :: IO ()
gui = do f <- frame [text := "Frame"]
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 regardsJeremyOn Tue, 22 Dec 2009 20:41 -0400, "carlos gomez" <carliros.g-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:Hi allI am trying to use scrolled windows with wxhaskell, but it doesn't work,Am I doing rightly?here is the code:----------------------------------------------------module Gui whereimport Graphics.UI.WXCoreimport Graphics.UI.WXmain :: IO ()main = start guigui :: 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
------------------------------------------------------------------------------ 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
------------------------------------------------------------------------------ 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
Personally, I always build via cabal these days. More info in section
2.4 of:
RSS Feed