wxTextCtrl what wrap the text?
Volker Bartheld
dr_versaeg at freenet.de
Wed Oct 17 04:18:33 PDT 2007
Hi!
>>> 2. when hit enter a would like to add text to big wxtextCtrl.
> I show You idea in images
> http://www.fotosik.pl/pokaz_obrazek/7f3ff2974de59b8f.html
> when I write many charts the textctrl will be biggest
OK. Got it. You want an "auto-growing" text control that extends
itself (and the surrounding parent) vertically as your adding new
lines.
I think, there's nothing "ready made" in the wxWidgets-box. You'll
probably have to derive a class from wxTextCtrl, use the
wxTE_PROCESS_ENTER-style, override the handler for the "Enter"-key
and then add the initial height every time the user hits enter (or
do some calculation with text extent). Your wxTextCtrl will then have
to call vSizeToContent() (see [1] below that I stole somewhere from
one of Vadim's examples) or something likewise that makes it fit
snugly around the child windows.
Good luck.
Volker
[1]
void wxWindow::vSizeToContent()
{
// in any case, our vertical size changed - re-layout everything and set new hints
// -------------------------------------------------------------------------------
// we have to reset min size constraints or Fit() would never reduce the
// dialog size when collapsing it and we have to reset max constraint
// because it wouldn't expand it otherwise
m_minHeight=m_maxHeight=-1;
// wxSizer::FitSize() is private, otherwise we might use it directly...
wxSize
sizeTotal=GetSize(),
sizeClient=GetClientSize(),
size=GetSizer()->GetMinSize();
size.x=sizeTotal.x; // originally: size.x+=sizeTotal.x-sizeClient.x; // why??
size.y+=sizeTotal.y-sizeClient.y;
SetSizeHints(size.x, size.y, m_maxWidth, m_maxHeight);
SetSize(wxDefaultCoord, size.y); // don't change the width when resizing vertically
# ifdef __WXGTK__
// VS: this is necessary in order to force frame redraw under
// WindowMaker or fvwm2 (and probably other broken WMs).
Show();
# endif // wxGTK
}
void wxWindow::hSizeToContent()
{
// in any case, our horizontal size changed - re-layout everything and set new hints
// -------------------------------------------------------------------------------
// we have to reset min size constraints or Fit() would never reduce the
// dialog size when collapsing it and we have to reset max constraint
// because it wouldn't expand it otherwise
m_minWidth=m_maxWidth=-1;
// wxSizer::FitSize() is private, otherwise we might use it directly...
wxSize
sizeTotal=GetSize(),
sizeClient=GetClientSize(),
size=GetSizer()->GetMinSize();
size.x+=sizeTotal.x-sizeClient.x; // originally: size.y+=sizeTotal.y-sizeClient.y; // why??
size.y=sizeTotal.y;
SetSizeHints(size.x, size.y, m_maxWidth, m_maxHeight);
SetSize(size.x, wxDefaultCoord); // don't change the height when resizing horizontally
# ifdef __WXGTK__
// VS: this is necessary in order to force frame redraw under
// WindowMaker or fvwm2 (and probably other broken WMs).
Show();
# endif // wxGTK
}
--
mailto: V B A R T H E L D at G M X dot D E
More information about the wx-users
mailing list