Re: wxtextCtrl text placement

Vadim Zeitlin <[email protected]>
Newsgroups gmane.comp.lib.wxwindows.general
Message-ID <[email protected]>
On Fri, 11 Oct 2024 19:15:55 -0500 Andre F wrote:

AF> I'm trying to figure out why the text doesn't stay vertically centered
AF> inside the box when I increase the size of the text.  The box clearly has
AF> enough room, but the text starts to go out of view instead of staying
AF> vertically centered.  I've tried various things, but am unable to keep it
AF> centered.
AF> 
AF> Can someone tell me what's wrong?
AF> 
AF> cstm5_e_textCtrl = new wxTextCtrl(panel2, wxID_ANY, wxT(""),
AF> wxDefaultPosition, wxSize(box_w, box_ht), wxNO_BORDER | wxTE_CENTER);
AF> p2rowThree->Add(cstm5_e_textCtrl, 0, wxEXPAND | wxALL, 10);

 What is p2rowThree, i.e. what kind of sizer is it? If it's a box sizer,
you need to use a non-zero proportion to allow the text to expand at all.

AF> contents << cstm_wrd[cstm_cnt];
AF> wxFont font = textCtrl->GetFont();
AF> font.SetWeight(wxFONTWEIGHT_NORMAL);
AF> font.SetPointSize(boxtext_size);
AF> textCtrl->SetFont(font);

 In any case, setting the font doesn't result in a re-layout, so you have
to call Layout() on some parent window containing this text control for the
text size to change.

 Regards,
VZ

-- 
TT-Solutions: wxWidgets consultancy and technical support
              https://www.tt-solutions.com/
signature.asc (application/pgp-signature, 195 B)
-----BEGIN PGP SIGNATURE-----

iF0EABECAB0WIQQx+vLQdOwioQqkxtoG6kHeT2wehgUCZwpf+QAKCRAG6kHeT2we
ht1YAJ4/fXwtdtqKU3oUnLIZZlmeCSREaQCdHe02YuTrW1eAMNW/wtIEe5VLe+s=
=MBaa
-----END PGP SIGNATURE-----
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.