+ SubclassWin(m_hWnd);
+ SetFont(*wxSMALL_FONT);
+ SetXComp(0);
+ SetYComp(0);
+ SetSize( nX
+ ,nY
+ ,nWidth
+ ,nHeight
+ );
+ return TRUE;
+} // end of wxStaticText::Create
+
+wxSize wxStaticText::DoGetBestSize() const
+{
+ wxString sText(wxGetWindowText(GetHWND()));
+ int nWidthTextMax = 0;
+ int nWidthLine = 0;
+ int nHeightTextTotal = 0;
+ int nHeightLineDefault = 0;
+ int nHeightLine = 0;
+ wxString sCurLine;
+ bool bLastWasTilde = FALSE;
+
+ for (const wxChar *pc = sText; ; pc++)
+ {
+ if ( *pc == wxT('\n') || *pc == wxT('\0') )
+ {
+ if (!sCurLine )
+ {
+ //
+ // We can't use GetTextExtent - it will return 0 for both width
+ // and height and an empty line should count in height
+ // calculation
+ //
+ if (!nHeightLineDefault)
+ nHeightLineDefault = nHeightLine;
+ if (!nHeightLineDefault)
+ GetTextExtent(_T("W"), NULL, &nHeightLineDefault);
+ nHeightTextTotal += nHeightLineDefault;
+ }
+ else
+ {
+ GetTextExtent( sCurLine
+ ,&nWidthLine
+ ,&nHeightLine
+ );
+ if (nWidthLine > nWidthTextMax)
+ nWidthTextMax = nWidthLine;
+ nHeightTextTotal += nHeightLine;
+ }
+
+ if ( *pc == wxT('\n') )
+ {
+ sCurLine.Empty();
+ }
+ else
+ {
+ break;
+ }
+ }
+ else
+ {
+ //
+ // We shouldn't take into account the '~' which just introduces the
+ // mnemonic characters and so are not shown on the screen -- except
+ // when it is preceded by another '~' in which case it stands for a
+ // literal tilde
+ //
+ if (*pc == _T('~'))
+ {
+ if (!bLastWasTilde)
+ {
+ bLastWasTilde = TRUE;
+
+ //
+ // Skip the statement adding pc to curLine below
+ //
+ continue;
+ }
+
+ //
+ // It is a literal tilde
+ //
+ bLastWasTilde = FALSE;
+ }
+ sCurLine += *pc;
+ }
+ }
+ return wxSize( nWidthTextMax
+ ,nHeightTextTotal
+ );
+} // end of wxStaticText::DoGetBestSize
+
+void wxStaticText::DoSetSize(
+ int nX
+, int nY
+, int nWidth
+, int nHeight
+, int nSizeFlags
+)