wxTextCtrl Height no work!

Do you have a typical platform dependent issue you're battling with ? Ask it here. Make sure you mention your platform, compiler, and wxWidgets version.
Post Reply
Nick
Earned some good credits
Earned some good credits
Posts: 107
Joined: Thu Apr 11, 2019 12:50 am

wxTextCtrl Height no work!

Post by Nick » Sat May 30, 2020 4:57 am

I created the example below to serve as a base.
It doesn't work to change the height of the control because it doesn't obey.
And in doing so, he even leaves his original position!

I wonder if I'm doing something wrong or if this is a BUG

Code: Select all

#include <wx/app.h>
#include <wx/frame.h>
#include <wx/textctrl.h>

class MyProgram: public wxApp {
bool OnInit() {
   wxFrame *FrmMain = new wxFrame(NULL, wxID_ANY, wxEmptyString);
   FrmMain->SetClientSize(wxSize(310,80));

   new wxTextCtrl(FrmMain, wxID_ANY, "wxEmptyString", wxPoint(5, 5), wxSize(300,10));
   new wxTextCtrl(FrmMain, wxID_ANY, "wxEmptyString", wxPoint(5,43), wxSize(300,33));

   FrmMain->Show();
   return true;
}}; wxIMPLEMENT_APP(MyProgram);

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

Re: wxTextCtrl Height no work!

Post by PB » Sat May 30, 2020 8:06 am

My advice: Do not use hardcoded numbers for positions and sizes, use sizers instead.

Besides, 10 pixels tall edit control makes little sense even on standard DPI, where the height for a singe line control is over 20 pixels

Nevertheless, your code seems to "work":
textctrl-height.png
textctrl-height.png (2.4 KiB) Viewed 710 times

BTW, if you think a very basic thing does not work and find yourself wonder whether you are doing something wrong or if it is a bug in wxWidgets, the former is much more likely.

Nick
Earned some good credits
Earned some good credits
Posts: 107
Joined: Thu Apr 11, 2019 12:50 am

Re: wxTextCtrl Height no work!

Post by Nick » Sat May 30, 2020 11:26 pm

PB wrote:
Sat May 30, 2020 8:06 am
My advice: Do not use hardcoded numbers for positions and sizes, use sizers instead.

Besides, 10 pixels tall edit control makes little sense even on standard DPI, where the height for a singe line control is over 20 pixels

Nevertheless, your code seems to "work":
Thanks for the advice, but I set just one example to demonstrate the problem.
Your window is on Windows, I use Linux
I put a very small height to make a difference in the example. What I really tried to do was change the default size 33 to 25 which is what I would like to use.
I put in example 10 to show that it made no difference in size and still changed the position of the control, I will show in the figure below
BTW, if you think a very basic thing does not work and find yourself wonder whether you are doing something wrong or if it is a bug in wxWidgets, the former is much more likely.
Yes, that's why I asked!

For me on Linux it shows like this.
Notice that what it decreased was the text space not controlling it. Notice the blue marquises on the sides of the control.
Image

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

Re: wxTextCtrl Height no work!

Post by doublemax » Sat May 30, 2020 11:36 pm

That looks like that particular window manager under Linux overrides the size, or at least enforces a minimum size. In that case, there is nothing wxWidgets or you can do about it.
Use the source, Luke!

Nick
Earned some good credits
Earned some good credits
Posts: 107
Joined: Thu Apr 11, 2019 12:50 am

Re: wxTextCtrl Height no work!

Post by Nick » Sun May 31, 2020 8:38 am

doublemax wrote:
Sat May 30, 2020 11:36 pm
That looks like that particular window manager under Linux overrides the size, or at least enforces a minimum size. In that case, there is nothing wxWidgets or you can do about it.
doublemax wrote:
Sat May 30, 2020 11:36 pm
That looks like that particular window manager under Linux overrides the size, or at least enforces a minimum size. In that case, there is nothing wxWidgets or you can do about it.
A good idea, I'll test it with other window managers. I'm currently using Xfce. I'll enjoy it and test it with other Linux too.

But it's a bit weird, because this doesn't happen with other libraries like Qt and FLTK. I haven't tested with Gtk yet.

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

Re: wxTextCtrl Height no work!

Post by doublemax » Sun May 31, 2020 8:49 am

But it's a bit weird, because this doesn't happen with other libraries like Qt and FLTK.
Both don't use native controls, they draw everything themselves.
Use the source, Luke!

Nick
Earned some good credits
Earned some good credits
Posts: 107
Joined: Thu Apr 11, 2019 12:50 am

Re: wxTextCtrl Height no work!

Post by Nick » Sun May 31, 2020 11:47 am

doublemax wrote:
Sun May 31, 2020 8:49 am
But it's a bit weird, because this doesn't happen with other libraries like Qt and FLTK.
Both don't use native controls, they draw everything themselves.
I believe then that the problem is with Linux in general. I tested it in Fedora, Ubuntu, Debian, in my Slackware, I used the window managers: Xfce, Kde, Gnome, WindowMaker, fluxbox, blackbox
In all of them the problem persists! :(

ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 4245
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: wxTextCtrl Height no work!

Post by ONEEYEMAN » Sun May 31, 2020 4:08 pm

Hi,
Nick wrote:
Sat May 30, 2020 11:26 pm
PB wrote:
Sat May 30, 2020 8:06 am
My advice: Do not use hardcoded numbers for positions and sizes, use sizers instead.

Besides, 10 pixels tall edit control makes little sense even on standard DPI, where the height for a singe line control is over 20 pixels

Nevertheless, your code seems to "work":
Thanks for the advice, but I set just one example to demonstrate the problem.
Your window is on Windows, I use Linux
I put a very small height to make a difference in the example. What I really tried to do was change the default size 33 to 25 which is what I would like to use.
I put in example 10 to show that it made no difference in size and still changed the position of the control, I will show in the figure below
Why do you want a control with a non-default size, that is less?
Are you going to use a smaller font with it?

Besides - there is a UI guidelines that every developer has to follow in order for their applicarion to look nice and presentable to the user...

As being suggested already - I'd use sizers and disregard any and all hardcoded position/sizing attempts.
After all - you are using a cross-platform library which is designed to eliminate differences in hardware/OS (HiDPI monitor be a good example).

Thank you.

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

Re: wxTextCtrl Height no work!

Post by doublemax » Sun May 31, 2020 7:51 pm

Just tested on a KDE desktop and it worked for me (wxWidgets 3.1.3, GTK3):
snapshot2.png
snapshot2.png (4.99 KiB) Viewed 595 times
Use the source, Luke!

Nick
Earned some good credits
Earned some good credits
Posts: 107
Joined: Thu Apr 11, 2019 12:50 am

Re: wxTextCtrl Height no work!

Post by Nick » Mon Jun 01, 2020 6:48 am

doublemax wrote:
Sun May 31, 2020 7:51 pm
Just tested on a KDE desktop and it worked for me (wxWidgets 3.1.3, GTK3):
snapshot2.png
Thanks doublemax so there is something wrong with the way I install my Linux, some library maybe, or maybe it's some graphical setup I didn't do. Because when I tested on different Linux, I didn't configure any of them and left them default.

Nick
Earned some good credits
Earned some good credits
Posts: 107
Joined: Thu Apr 11, 2019 12:50 am

Re: wxTextCtrl Height no work!

Post by Nick » Mon Jun 01, 2020 6:52 am

ONEEYEMAN wrote:
Sun May 31, 2020 4:08 pm
Why do you want a control with a non-default size, that is less?
Are you going to use a smaller font with it?
I'll use font 9, the goal is to make room in the window. But still nothing is definitive, I'm exploring what I can do with the wxWidgets controls. And size, color, style, control are options we use all the time!

ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 4245
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: wxTextCtrl Height no work!

Post by ONEEYEMAN » Mon Jun 01, 2020 3:34 pm

Hi,
I understand changing the style and colors of the controls.
What is you scenario for changing the position/size of the controls? Are you working to make a RAD tool?

Thank you.

Post Reply