예제 #1
0
bool pxStaticText::_updateWrapping(bool textChanged)
{
    if (!m_autowrap) {
        //m_wrappedLabel = wxEmptyString;
        //m_wrappedWidth = -1;
        return false;
    }

    wxString wrappedLabel;
    int newWidth = GetSize().GetWidth();

    if (!textChanged && (newWidth == m_wrappedWidth))
        return false;

    // Note: during various stages of sizer-calc, width can be 1, 0, or -1.
    // We ignore wrapping in these cases.  (the PaintEvent also checks the wrapping
    // and updates it if needed, in case the control's size isn't figured out prior
    // to being painted).

    m_wrappedWidth = newWidth;
    if (m_wrappedWidth > 1)
        wrappedLabel = pxTextWrapper().Wrap(this, m_label, m_wrappedWidth).GetResult();

    if (m_wrappedLabel == wrappedLabel)
        return false;
    m_wrappedLabel = wrappedLabel;

    return true;
}
예제 #2
0
wxString pxFormatToolTipText( wxWindow* wind, const wxString& src )
{
	// Windows needs manual tooltip word wrapping (sigh).
	// GTK and Mac are a wee bit more clever (except in GTK tooltips don't show at all
	// half the time because of some other bug .. sigh)

#ifdef __WXMSW__
	if( wind == NULL ) return src;		// Silently ignore nulls
	int whee = wxGetDisplaySize().GetWidth() * 0.75;
	return pxTextWrapper().Wrap( *wind, src, std::min( whee, 600 ) ).GetResult();
#else
	return src;
#endif
}
예제 #3
0
pxStaticText &pxStaticText::WrapAt(int width)
{
    m_autowrap = false;

    if ((width <= 1) || (width == m_wrappedWidth))
        return *this;

    wxString wrappedLabel;
    m_wrappedWidth = width;

    if (width > 1)
        wrappedLabel = pxTextWrapper().Wrap(this, m_label, width).GetResult();

    if (m_wrappedLabel != wrappedLabel) {
        m_wrappedLabel = wrappedLabel;
        wxSize area = wxClientDC(this).GetMultiLineTextExtent(m_wrappedLabel);
        SetMinSize(wxSize(
            area.GetWidth() + calcPaddingWidth(area.GetWidth()),
            area.GetHeight() + calcPaddingHeight(area.GetHeight())));
    }
    return *this;
}
예제 #4
0
wxSize pxStaticText::GetBestWrappedSize(const wxClientDC &dc) const
{
    pxAssert(m_autowrap);

    // Find an ideal(-ish) width, based on a search of all parent controls and their
    // valid Minimum sizes.

    int idealWidth = wxDefaultCoord;
    int parentalAdjust = 0;
    double parentalFactor = 1.0;
    const wxWindow *millrun = this;

    while (millrun) {
        // IMPORTANT : wxWizard changes its min size and then expects everything else
        // to play nice and NOT resize according to the new min size.  (wtf stupid)
        // Anyway, this fixes it -- ignore min size specifier on wxWizard!
        if (wxIsKindOf(millrun, wxWizard))
            break;

        int min = (int)((millrun->GetMinWidth() - parentalAdjust) * parentalFactor);

        if (min > 0 && ((idealWidth < 0) || (min < idealWidth))) {
            idealWidth = min;
        }

        parentalAdjust += pxSizerFlags::StdPadding * 2;
        millrun = millrun->GetParent();
    }

    if (idealWidth <= 0) {
        // FIXME: The minimum size of this control is unknown, so let's just pick a guess based on
        // the size of the user's display area.

        idealWidth = (int)(wxGetDisplaySize().GetWidth() * 0.66) - (parentalAdjust * 2);
    }

    return dc.GetMultiLineTextExtent(pxTextWrapper().Wrap(this, m_label, idealWidth - calcPaddingWidth(idealWidth)).GetResult());
}