wxWidgets windows version / linux version difference (wxList

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
gabre
Knows some wx things
Knows some wx things
Posts: 29
Joined: Sat Mar 02, 2013 9:45 am

wxWidgets windows version / linux version difference (wxList

Post by gabre » Sun Apr 28, 2013 9:46 am

I use the following code, to get the text of a column of a wxListCtrl:
listctrl_nth_row_getter(ListCtrl, Column) ->
fun(S) ->
Item0 = wxListItem:new(),
wxListItem:setId(Item0, S),
wxListItem:setColumn(Item0, Column),
wxListCtrl:getItem(ListCtrl, Item0),
wxListItem:getText(Item0) end.
As you can see, this code returns a lambda function, which parameter is is the row-id, and if you call it, it returns the text of a column (with number Column).

Under Linux, it works great, but under Windows, it always returns an empty string. I also tried to get the text of the first (0.) column, because I thought that I misnumbered something and I was trying to access to a non-existing column, but there was no problem with that. I am sure that there was (non-empty) text in the column I wanted to get.

User avatar
doublemax
Moderator
Moderator
Posts: 14982
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: wxWidgets windows version / linux version difference (wx

Post by doublemax » Sun Apr 28, 2013 10:37 am

Try using wxListItem::SetMask and set the flag(s) for the data you're interested in, wxLIST_MASK_TEXT
Use the source, Luke!

gabre
Knows some wx things
Knows some wx things
Posts: 29
Joined: Sat Mar 02, 2013 9:45 am

Re: wxWidgets windows version / linux version difference (wx

Post by gabre » Sun Apr 28, 2013 12:27 pm

nice, it work fine! thank you very much!

I have another but a little bit stupid question. I have a miniframe, and I use it as a special context menu, I added controls to it, and some events so it works quite good. My problem is that under linux my controls fitted the area I provided to them (I adjusted its size manually, the controls are generated dinamically, sometimes there are 5 sometimes there are 10 buttons, etc, so I multiplicated a constant value according to the number of controls) but under windows it is too small for them. Is there any way to ask Wx to calculate the proper frame size itself but only the height, the width should be user-given?

User avatar
doublemax
Moderator
Moderator
Posts: 14982
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: wxWidgets windows version / linux version difference (wx

Post by doublemax » Sun Apr 28, 2013 2:34 pm

Is there any way to ask Wx to calculate the proper frame size itself but only the height, the width should be user-given?
Assuming that the window is under the control of a sizer, try wxWindow::GetBestSize() or wxSizer::ComputeFittingWindowSize()
Use the source, Luke!

gabre
Knows some wx things
Knows some wx things
Posts: 29
Joined: Sat Mar 02, 2013 9:45 am

Re: wxWidgets windows version / linux version difference (wx

Post by gabre » Sun Apr 28, 2013 10:31 pm

Thank you!
Another Windows related problem: I have a notebook in my program and on two pages of it I use my own paint events to draw graphs. On Windows, if you change to one of these pages the controls don't appear (or appear incorrectly) and buttons didn't work. If I remove the line from my code where I connect my callback to paint event everything works fine (but I need to draw on those pages).

User avatar
doublemax
Moderator
Moderator
Posts: 14982
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: wxWidgets windows version / linux version difference (wx

Post by doublemax » Sun Apr 28, 2013 11:20 pm

On Windows, if you change to one of these pages the controls don't appear (or appear incorrectly) and buttons didn't work. If I remove the line from my code where I connect my callback to paint event everything works fine (but I need to draw on those pages).
Hard to tell wthout seeing code. If it's just a redraw problem, try calling Refresh() after a notebook page has been changed.

Also make sure you always create a wxPaintDC in a paint event handler, even if you don't use it. And if you use Connect/Bind to connect the paint event handler, make sure you create the wxPaintDC for the correct window, the one that "owns" the paint event.
Use the source, Luke!

gabre
Knows some wx things
Knows some wx things
Posts: 29
Joined: Sat Mar 02, 2013 9:45 am

Re: wxWidgets windows version / linux version difference (wx

Post by gabre » Tue May 28, 2013 2:46 pm

I have another problem (there is no problem on Linux, but on Windows). See the attached image that shows what I need.
There is my code: (in Erlang, but it is quite easy to understand as it is just Wx :) )
( TitleSz.add(NameBox) is the same as wxSizer:add(TitleSz, NameBox) )

Code: Select all

    wxSizer:add(TitleSz, NameBox), %% NameBox is a textbox (input)
    wxSizer:add(TitleSz, MenuBtn, [{flag, ?wxALIGN_RIGHT}]), %% MenuBtn is a button which can hide/show a menu
    
    wxSizer:add(TitleSz, TitleSz2, [{proportion,1},{flag,?wxEXPAND bor ?wxALL}]), 
    wxSizer:add(TitleSz2, HideBtn, [{flag, ?wxALIGN_RIGHT}]), %% HideBtn is the button with text "Hide" (hides/shows the whole box/panel)

    wxSizer:add(BtnSz1, AddBtn), %% These are the four buttons of the menu (which can be shown or hidden)
    wxSizer:add(BtnSz1, DelBtn),
    wxSizer:add(BtnSz2, MovBtn),
    wxSizer:add(BtnSz2, NewBtn),
    wxSizer:addSpacer(Sz, 5),
    wxSizer:add(Sz, TitleSz, [{flag, ?wxEXPAND bor ?wxALL}]),
    wxSizer:add(BtnSz, BtnSz1),
    wxSizer:add(BtnSz, BtnSz2),
    wxSizer:add(Sz, BtnSz),
    wxSizer:add(Sz, HTextBox, [{border,2},{flag,?wxALL}]), %% HTextBox (text label) IS ONLY SHOWN when the box/panel is in its HIDDEN state, 
    wxSizer:add(TxtSz,Brw,[{proportion, 1}, {flag, ?wxEXPAND}]), %% Brw is a code browser (see the attached pic)
    wxSizer:add(Sz,TxtSz,[{proportion, 1}, {flag, ?wxEXPAND}]),
    wxSizer:addSpacer(Sz, 3),
    wxPanel:setSizer(Box, Sz),
    wxSizer:layout(Sz),
    wxWindow:hide(HTextBox),
    wxWindow:setToolTip(Box, ToolTip),
    wxSizer:hide(Sz, Menu, [{recursive, true}]), %% At startup, the MENU of the box/panel is hidden
    wxFrame:show(Box),
image.png
image.png (42.2 KiB) Viewed 6702 times

User avatar
doublemax
Moderator
Moderator
Posts: 14982
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: wxWidgets windows version / linux version difference (wx

Post by doublemax » Tue May 28, 2013 3:20 pm

This is too hard to follow for me if i can't test it myself. I can only suggest to rebuild the layout in C++ and check if the same problem happens there.

One general comment: I personally never hide/show sizers, i only hide/show controls. I would try to put the four buttons (add, delete, move, new) onto a wxPanel and just hide/show that panel.
Use the source, Luke!

gabre
Knows some wx things
Knows some wx things
Posts: 29
Joined: Sat Mar 02, 2013 9:45 am

Re: wxWidgets windows version / linux version difference (wx

Post by gabre » Tue May 28, 2013 5:30 pm

I did the following:

Code: Select all

...
    wxSizer:add(Sz, BtnSz),
    wxSizer:add(Sz, HTextBox, [{border,2},{flag,?wxALL}]),
  %  wxSizer:add(TxtSz,Brw,[{proportion, 1}, {flag, ?wxEXPAND}]), <---- I REMOVED THIS
    wxSizer:add(Sz,Brw, [{flag, ?wxEXPAND},  {proportion, 1}]) %% <--- And added Brw itself to the Sz sizer
    wxSizer:addSpacer(Sz, 3),
...
When I add Brw like this:
wxSizer:add(Sz,Brw, [{flag, ?wxEXPAND}, {proportion, 1}])
...then its WIDTH value is 0, but when I add it without expand and proportion:
wxSizer:add(Sz,Brw, [])
it gets a "normal" width (it is not expanded so it doesn't fill the whole window)

User avatar
doublemax
Moderator
Moderator
Posts: 14982
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: wxWidgets windows version / linux version difference (wx

Post by doublemax » Tue May 28, 2013 5:58 pm

I can't say anything about this. Are you sure the problem lies not in wxErlang itself? I really think you should try to build a C++ sample.
Use the source, Luke!

gabre
Knows some wx things
Knows some wx things
Posts: 29
Joined: Sat Mar 02, 2013 9:45 am

Re: wxWidgets windows version / linux version difference (wx

Post by gabre » Tue May 28, 2013 7:23 pm

I've managed to solve it with the following line:

Code: Select all

  wxWindow:layout(Box), %% Box is the name of my custom panel
No other changes needed.

gabre
Knows some wx things
Knows some wx things
Posts: 29
Joined: Sat Mar 02, 2013 9:45 am

Re: wxWidgets windows version / linux version difference (wx

Post by gabre » Tue May 28, 2013 7:55 pm

My next problem (I m trying to bring my wx app to life which worked under Linux well) is in connection with bitmap buttons and drawing.
The situation (simplified) is the following:
I have bitmap buttons as graph nodes and I paint edges to connect them. Edges include lines and arrows. Firstly, I place the bitmap buttons (they have a totally black bitmap, and a mask with a circle, so the user only sees black circles), then I connect them with edges (it is a not so easy graph calculation...) BUT my problem is that those parts of the edges (arrows, some part of the lines) that are near the buttons are covered by the buttons (covered by their system-default colour). By the way, I also want to draw on these buttons in my Paint event. (On GTK this is possible, and I can draw my graph easily: the background of the panel where I draw should be set to wxBG_STYLE_CUSTOM)

Is it possible (somehow) to draw on the buttons (like on GTK) or make their surroundings transparent?
graph.png
graph.png (34.12 KiB) Viewed 6673 times

User avatar
doublemax
Moderator
Moderator
Posts: 14982
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: wxWidgets windows version / linux version difference (wx

Post by doublemax » Tue May 28, 2013 8:47 pm

I would not use bitmap buttons for the circles, but draw them myself, too.
Use the source, Luke!

gabre
Knows some wx things
Knows some wx things
Posts: 29
Joined: Sat Mar 02, 2013 9:45 am

Re: wxWidgets windows version / linux version difference (wx

Post by gabre » Wed May 29, 2013 11:08 am

That is okay, but I have to use bitmap buttons because they have to be clickable, and it is also not a solution that I track mouse positions and decide if the user clicked on a graph node.

User avatar
doublemax
Moderator
Moderator
Posts: 14982
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: wxWidgets windows version / linux version difference (wx

Post by doublemax » Wed May 29, 2013 11:20 am

it is also not a solution that I track mouse positions and decide if the user clicked on a graph node.
Why not? Keeping a list of nodes and iterating over their positions to check if they were clicked doesn't sound too hard.

Can you try if a wxStaticBitmap is displayed correctly ( transparent over a custom background)? In the "erase" sample that works.
Use the source, Luke!

Post Reply