wxSmith wxDialog problems when program is run

Do you have a question about makefiles, a compiler or IDE you are using and need to know how to set it up for wxWidgets or why it doesn't compile but other IDE's do ? Post your questions here.
User avatar
Asimov
Experienced Solver
Experienced Solver
Posts: 72
Joined: Tue Nov 17, 2020 6:43 pm

Re: wxSmith wxDialog problems when program is run

Post by Asimov » Sun Nov 22, 2020 2:01 pm

Damn I found out that if I have my buttons in a panel. I can use the following code to change all the buttons.

Code: Select all

auto children = Panel1->GetChildren();
for ( auto node = children.GetFirst(); node; node = node->GetNext() )
 {
        wxWindow* current = node->GetData();
        current->SetBackgroundColour(wxColour(*wxBLUE));
}
Unfortunately all my buttons are not in a panel, and there is no way to copy and paste them into a panel. I will have to move them in one at a time grrrr.
I am getting to really hate wxSmith LOL

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

Re: wxSmith wxDialog problems when program is run

Post by doublemax » Sun Nov 22, 2020 4:30 pm

Unfortunately all my buttons are not in a panel, and there is no way to copy and paste them into a panel. I will have to move them in one at a time grrrr.
The buttons don't have to be in a panel, just use the parent of the buttons (which is probably the mainframe in your case).
Use the source, Luke!

User avatar
Asimov
Experienced Solver
Experienced Solver
Posts: 72
Joined: Tue Nov 17, 2020 6:43 pm

Re: wxSmith wxDialog problems when program is run

Post by Asimov » Sun Nov 22, 2020 4:48 pm

Hi doublemax,

I tried that. The main name of my frame which is a wxDialog is called AddShortcut, but when I try to use that I get the error: unexpected primary expression before -> token

Code: Select all

auto children = AddShortcut->GetChildren();
What I would have liked to do is to create a plane, and go into the heirachy in the left pane, and drag my buttons onto the new plane, but wxSmith won't let you do that. It is so annoying.

wxSmith needs a major re-write to be user freindly. I mean in wxFormbuilder you can drag things around much easier.

PB
Part Of The Furniture
Part Of The Furniture
Posts: 2675
Joined: Sun Jan 03, 2010 5:45 pm

Re: wxSmith wxDialog problems when program is run

Post by PB » Sun Nov 22, 2020 4:58 pm

I am using wxFormBuilder but I tried wxSmith once. My first impression was terrible, one of the reasons was that I just could not drag and drop controls around, e.g. moving them between the sizers.

But I learned that it was possible, except that unlike in wxFB, in wxSmith you do not drag controls in the resource tree view but you need to drag the actual controls in the designer view which can get tricky.

Regarding that GetChildren thing: Is AddShortcut really the name of the variable with the frame instance. Is it not the type (=class) name? Anyway, I believe that generally child controls should not be directly on the frame but on a wxPanel. wxPanel among other things handles navigating between the controls using <Tab>.
Last edited by PB on Sun Nov 22, 2020 5:03 pm, edited 1 time in total.

User avatar
Asimov
Experienced Solver
Experienced Solver
Posts: 72
Joined: Tue Nov 17, 2020 6:43 pm

Re: wxSmith wxDialog problems when program is run

Post by Asimov » Sun Nov 22, 2020 5:01 pm

Hi PB,

Yeh I know you can drag them in the design view,but my buttons are already in the right place. I wish I could drag them using the side panel so I could keep the x and y coordinates the same. I used wxFormbuilder for my main interface, but thought I would try the inbuilt one for this. What a mistake LOL

PB
Part Of The Furniture
Part Of The Furniture
Posts: 2675
Joined: Sun Jan 03, 2010 5:45 pm

Re: wxSmith wxDialog problems when program is run

Post by PB » Sun Nov 22, 2020 5:04 pm

IMO, using absolute coordinates is not a good idea. Have you tried how your application looks when run on a non-default DPI system?

I think the design could be achieved with sizer even if it could take some time and thinking.

User avatar
Asimov
Experienced Solver
Experienced Solver
Posts: 72
Joined: Tue Nov 17, 2020 6:43 pm

Re: wxSmith wxDialog problems when program is run

Post by Asimov » Sun Nov 22, 2020 5:12 pm

Hi PB,
I tried doing it with sizers, but it kept separating my buttons. Plus the gridsizers won't work as it isn't in a grid.
I haven't got a non DPI system. Only got windows 10.

I have only been playing with wxWidgets for a week, and these sizers even though useful, are quite hard to use.
I am not sure how I could achieve the keyboard layout using sizers.

regards
Asimov

PB
Part Of The Furniture
Part Of The Furniture
Posts: 2675
Joined: Sun Jan 03, 2010 5:45 pm

Re: wxSmith wxDialog problems when program is run

Post by PB » Sun Nov 22, 2020 5:22 pm

I I would try designing the US keyboard with a wxBoxSizer for each row. It would be tricky as there are several sizes sizes of keys but perhaps could be done.

OTOH, layouts using absolute coordinates break easily. High DPI systems are very common now. You can try with yourself increasing your Windows DPI to e.g. 125%. Such a small decrease may not even break the layout though and much larger ratios (e.g. 200%) are commonly used on small 4k screens.

Of course, that assumes your application is DPI aware, but DPI-unaware applications look very bad on non-default DPI systems, they get blurry.

User avatar
Asimov
Experienced Solver
Experienced Solver
Posts: 72
Joined: Tue Nov 17, 2020 6:43 pm

Re: wxSmith wxDialog problems when program is run

Post by Asimov » Sun Nov 22, 2020 5:27 pm

Hi PB,
I will give it a go.
So would I put the boxsizers in a panel first?
I am not sure of the best heirachy for it. One big sizer,then a panel, then Boxsizers.

Although when I did this yesterday I had a gap between the top of the button and the next row.

PB
Part Of The Furniture
Part Of The Furniture
Posts: 2675
Joined: Sun Jan 03, 2010 5:45 pm

Re: wxSmith wxDialog problems when program is run

Post by PB » Sun Nov 22, 2020 5:37 pm

I do not want to sound like Negative Nancy all the time, but before I would start investing time into actual implementation, I would think hard about the following:

1. Is US English layout the optimum layout to have for the software keyboard? For example, if you take a look at MS Windows on-screen keyboard you will see that it looks different. These days, there is not even an actual US English keyboard layout standard, as many e.g. many laptops use different layouts. And there other layouts frequently used in mobile devices many users are accustomed to.

2. Is using wxButtons for keys the best solution? At least some keys have two labels, this would be impossible to achieve with a wxButton.

User avatar
Asimov
Experienced Solver
Experienced Solver
Posts: 72
Joined: Tue Nov 17, 2020 6:43 pm

Re: wxSmith wxDialog problems when program is run

Post by Asimov » Sun Nov 22, 2020 5:52 pm

Hi PB,

I am using toggle buttons. I am making a system where they select their shortcut keys by clicking the keys, so I need two states for each button.
Plus it isn't a US keyboard. I am not American, I am British.

I am not worried about what is on the top row of the keys. Because the shortcut will be eg Shift 4, or alt shift 3 etc. So itis better that way, because on a British keyboard we have the £ sign and on an American keyboard they have $, so I don't need to show that.


regards
Thomas

PB
Part Of The Furniture
Part Of The Furniture
Posts: 2675
Joined: Sun Jan 03, 2010 5:45 pm

Re: wxSmith wxDialog problems when program is run

Post by PB » Sun Nov 22, 2020 5:57 pm

Well, you must know best.


BTW, you are not using the UK layout, you are using the US layout:
https://en.wikipedia.org/wiki/British_a ... _keyboards

UK layout would be impossible using wxButtons which must be rectangular, as its Enter is L shaped.

User avatar
Asimov
Experienced Solver
Experienced Solver
Posts: 72
Joined: Tue Nov 17, 2020 6:43 pm

Re: wxSmith wxDialog problems when program is run

Post by Asimov » Sun Nov 22, 2020 6:05 pm

Hi PB,

I based the layout on my Lenovo W520 laptop. So Lenovo are a Chinese company, so really it is a Chinese layout LOL. No seriously it is a British layout because it has the £ sign above the 3. American keyboards don't have that sign. Plus British keyboads have the hash sign next to the return key.

regards
Asimov

PB
Part Of The Furniture
Part Of The Furniture
Posts: 2675
Joined: Sun Jan 03, 2010 5:45 pm

Re: wxSmith wxDialog problems when program is run

Post by PB » Sun Nov 22, 2020 6:12 pm

Well, how do you explain that keyboards can have Czech characters and use either US or UK layout?

Nah, I was kidding, please don't. The difference is clearly explained in the link above and lies in the number and shape of the keys, the labels are secondary.

User avatar
Asimov
Experienced Solver
Experienced Solver
Posts: 72
Joined: Tue Nov 17, 2020 6:43 pm

Re: wxSmith wxDialog problems when program is run

Post by Asimov » Sun Nov 22, 2020 6:55 pm

Hi PB,
I tried using the sizer method. Problem is that I cannot easily offset rows to create the keyboard look, and even when I get almost square buttons, they get squished when I run the program. I am finding it very hard to get it to look right by using this method.

I created a splitter box, then put in a plane, then a box sizer, and rows of box sizers in that. Good thing is that it is helping me to learn, bad thing is that it doesn't look good, like my original keyboard layout. I first made my buttons 50x50, but with the sizers it made no difference, so then I tried expanding all my buttons. I am not sure what I am doing wrong, but I can't make it look like a keyboard using this method, and I have been trying for the last 2 hours LOL.

By the way I put it in a splitter because I want an input box in the lower area, plus an ok and cancel button.

regards
Asimov
Attachments
squish.jpg

Post Reply