Re: problem with the scrollbar inside the notebook

Zoran Bošnjak <[email protected]>
Newsgroups gmane.comp.lib.wxwindows.general
Message-ID <[email protected]>
Hi Vadim,
thanks for testing the C++ code. From what I can see from the code, fill 
is defined as a composition 'stretch' after 'expand' and both functions 
has simple definition in the same file:

https://codeberg.org/wxHaskell/wxHaskell/src/commit/cbcb56f1b3d49fbea716902994fe7c73619a5582/wxcore/src/haskell/Graphics/UI/WXCore/Layout.hs#L225

Based on your suggestion, I have run some printf style debugging on all 
windows, on both: old (working) and new (non-working) wxhaskell version.

p1 is exactly the same on both, however, there are some small size 
differences on other windows. Could you tell from this output what to 
check next?

Debug output on the old wxhaskell (scrollbar is visible)

--- f ---
Size {sizeW = 400, sizeH = 200} <- outerSize
Point {pointX = 0, pointY = 0} <- position
Rect {rectLeft = 0, rectTop = 0, rectWidth = 400, rectHeight = 200} <- 
area
Size {sizeW = 6, sizeH = 18} <- bestSize
Size {sizeW = 400, sizeH = 200} <- clientSize
Size {sizeW = 400, sizeH = 200} <- virtualSize
--- p ---
Size {sizeW = 57, sizeH = 489} <- outerSize
Point {pointX = 0, pointY = 0} <- position
Rect {rectLeft = 0, rectTop = 0, rectWidth = 57, rectHeight = 489} <- 
area
Size {sizeW = 57, sizeH = 489} <- bestSize
Size {sizeW = 57, sizeH = 489} <- clientSize
Size {sizeW = 57, sizeH = 489} <- virtualSize
--- nb ---
Size {sizeW = 57, sizeH = 489} <- outerSize
Point {pointX = 0, pointY = 0} <- position
Rect {rectLeft = 0, rectTop = 0, rectWidth = 57, rectHeight = 489} <- 
area
Size {sizeW = 57, sizeH = 489} <- bestSize
Size {sizeW = 57, sizeH = 489} <- clientSize
Size {sizeW = 57, sizeH = 489} <- virtualSize
--- p1 ---
Size {sizeW = 36, sizeH = 435} <- outerSize
Point {pointX = 0, pointY = 0} <- position
Rect {rectLeft = 0, rectTop = 0, rectWidth = 36, rectHeight = 435} <- 
area
Size {sizeW = 36, sizeH = 435} <- bestSize
Size {sizeW = 36, sizeH = 435} <- clientSize
Size {sizeW = 36, sizeH = 435} <- virtualSize

Debug output on the new wxhaskell (scrollbar is not present)

--- f ---
Size {sizeW = 400, sizeH = 200} <- outerSize
Point {pointX = 0, pointY = 0} <- position
Rect {rectLeft = 0, rectTop = 0, rectWidth = 400, rectHeight = 200} <- 
area
Size {sizeW = 0, sizeH = 29} <- bestSize
Size {sizeW = 400, sizeH = 200} <- clientSize
Size {sizeW = 400, sizeH = 200} <- virtualSize
--- p ---
Size {sizeW = 52, sizeH = 480} <- outerSize
Point {pointX = 0, pointY = 0} <- position
Rect {rectLeft = 0, rectTop = 0, rectWidth = 52, rectHeight = 480} <- 
area
Size {sizeW = 52, sizeH = 480} <- bestSize
Size {sizeW = 52, sizeH = 480} <- clientSize
Size {sizeW = 52, sizeH = 480} <- virtualSize
--- nb ---
Size {sizeW = 52, sizeH = 480} <- outerSize
Point {pointX = 0, pointY = 0} <- position
Rect {rectLeft = 0, rectTop = 0, rectWidth = 52, rectHeight = 480} <- 
area
Size {sizeW = 52, sizeH = 480} <- bestSize
Size {sizeW = 52, sizeH = 480} <- clientSize
Size {sizeW = 52, sizeH = 480} <- virtualSize
--- p1 ---
Size {sizeW = 36, sizeH = 435} <- outerSize
Point {pointX = 0, pointY = 0} <- position
Rect {rectLeft = 0, rectTop = 0, rectWidth = 36, rectHeight = 435} <- 
area
Size {sizeW = 36, sizeH = 435} <- bestSize
Size {sizeW = 36, sizeH = 435} <- clientSize
Size {sizeW = 36, sizeH = 435} <- virtualSize

For the reference, this is the test program used to create debug output.

---
module Main where
import Control.Monad (join)
import Graphics.UI.WXCore
import Graphics.UI.WX

debug :: (Dimensions a, Show a) => String -> a -> IO [String]
debug name w = sequence
     [ pure ("--- " <> name <> " ---")
     , (<> " <- outerSize") . show <$> get w outerSize
     , (<> " <- position") . show <$> get w position
     , (<> " <- area") . show <$> get w area
     , (<> " <- bestSize") . show <$> get w bestSize
     , (<> " <- clientSize") . show <$> get w clientSize
     , (<> " <- virtualSize") . show <$> get w virtualSize
     ]

gui :: IO ()
gui = do
     f <- frame [text := "Frame"]
     p <- panel f []
     nb <- notebook p []
     p1 <- scrolledWindow nb
         [ scrollRate := sz 20 20
         ]
     texts <- mapM (\n -> staticText p1 [text := ("test" <> show n) ]) 
[1::Int ..20]
     set f
         [ layout := fill $ widget p
         , clientSize := sz 400 200
         ]
     set p
         [ layout := fill $ tabs nb
           [ tab "tab1" $ container p1 $ column 5 (fmap widget texts)
           ]
         ]

     result <- join <$> sequence
         [ debug "f" f
         , debug "p" p
         , debug "nb" nb
         , debug "p1" p1
         ]

     mapM_ putStrLn result

main :: IO ()
main = start gui
---

regards,
Zoran

On 2024-10-26 14:57, Vadim Zeitlin wrote:
> On Thu, 24 Oct 2024 13:59:30 +0200 Zoran Bošnjak wrote:
> 
> ZB> I am using wxHaskell bindings of the wxWidgets library. With the 
> latest
> ZB> version, I am facing the problem with missing scrollbar inside the
> ZB> notebook. The same sample from a few years back was working fine. I
> ZB> belive the wxWidget version was 2.9.3 at the time. Now, it's build
> ZB> against version 3.2.
> ZB>
> ZB> The issue (together with a short sample in haskell language) is 
> filed
> ZB> under the wxHaskell project:
> ZB> https://codeberg.org/wxHaskell/wxHaskell/issues/48
> ZB>
> ZB> I was wandering is someone from this list is able to recreate the 
> same
> ZB> sample as a plain C/C++ program or using other language bindings 
> (like
> ZB> python) and help me determine:
> 
>  I am not sure how does "fill" and some other functions work in 
> wxHaskell
> but here is a rough translation of your code in C++:
> 
> --------------------------------- >8 
> --------------------------------------
> #include <wx/app.h>
> #include <wx/frame.h>
> #include <wx/notebook.h>
> #include <wx/scrolwin.h>
> #include <wx/sizer.h>
> #include <wx/stattext.h>
> 
> class TestApp : public wxApp {
> public:
>     bool OnInit() override {
>         auto f = new wxFrame(nullptr, wxID_ANY, "Frame");
>         auto nb = new wxNotebook(f, wxID_ANY);
> 
>         auto p1 = new wxScrolledWindow(nb);
>         p1->SetScrollRate(20, 20);
>         auto sizer = new wxBoxSizer(wxVERTICAL);
>         for ( int i = 0; i < 20; i++ ) {
>             sizer->Add(new wxStaticText(p1, wxID_ANY, "test " + 
> std::to_string(i)));
>         }
>         p1->SetSizer(sizer);
> 
>         nb->AddPage(p1, "tab1");
>         f->SetClientSize(400, 200);
>         f->Show();
>         return true;
>     }
> };
> 
> wxIMPLEMENT_APP(TestApp);
> --------------------------------- >8 
> --------------------------------------
> 
> This works just fine for me with the latest wx and GTK 3.
> 
> ZB> - Is this a wxWidget or wxHaskell binding problem?
> 
>  I'd check the implementation of "fill" to understand what exactly it 
> does.
> 
> ZB> - Was there any change in wxWidgets over time that requires a 
> different
> ZB> approach (like any new attributes regarding the scrollbar)?
> 
>  No, or at least definitely not intentionally.
> 
> ZB> - Or any other ideas how to workaround the problem and have the
> ZB> scrollbar present again?
> 
>  You should try debugging (either using gdb, which should work for C++ 
> code
> even when using wxHaskell, or using printf-debugging style) the sizes 
> of
> the different windows, e.g. start by checking the size and the virtual 
> size
> of "p1".
> 
>  Good luck
> VZ

-- 
Please read https://www.wxwidgets.org/support/mlhowto.htm before posting.
--- 
You received this message because you are subscribed to the Google Groups "wx-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To view this discussion visit https://groups.google.com/d/msgid/wx-users/4d690a3246dcf18f1370ee9f5aab64b4%40via.si.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.