1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: wx/generic/private/markuptext.h
3 // Purpose: Generic wxMarkupText class for managing text with markup.
4 // Author: Vadim Zeitlin
6 // Copyright: (c) 2011 Vadim Zeitlin <vadim@wxwidgets.org>
7 // Licence: wxWindows licence
8 ///////////////////////////////////////////////////////////////////////////////
10 #ifndef _WX_GENERIC_PRIVATE_MARKUPTEXT_H_
11 #define _WX_GENERIC_PRIVATE_MARKUPTEXT_H_
15 class WXDLLIMPEXP_FWD_CORE wxDC
;
16 class WXDLLIMPEXP_FWD_CORE wxRect
;
18 // ----------------------------------------------------------------------------
19 // wxMarkupText: allows to measure and draw the text containing markup.
20 // ----------------------------------------------------------------------------
22 class WXDLLIMPEXP_CORE wxMarkupText
25 // Constants for Render() flags.
28 Render_Default
= 0, // Don't show mnemonics visually.
29 Render_ShowAccels
= 1 // Underline mnemonics.
33 // Initialize with the given string containing markup (which is supposed to
34 // be valid, the caller must check for it before constructing this object).
36 // Notice that the usual rules for mnemonics apply to the markup text: if
37 // it contains any '&' characters they must be escaped by doubling them,
38 // otherwise they indicate that the next character is the mnemonic for this
41 // TODO-MULTILINE-MARKUP: Currently only single line labels are supported,
42 // search for other occurrences of this comment to find the places which
43 // need to be updated to support multiline labels with markup.
44 wxMarkupText(const wxString
& markup
)
49 // Default copy ctor, assignment operator and dtor are ok.
51 // Update the markup string.
53 // The same rules for mnemonics as in the ctor apply to this string.
54 void SetMarkup(const wxString
& markup
) { m_markup
= markup
; }
57 // Return the width and height required by the given string and optionally
58 // the height of the visible part above the baseline (i.e. ascent minus
61 // The font currently selected into the DC is used for measuring (notice
62 // that it is changed by this function but normally -- i.e. if markup is
63 // valid -- restored to its original value when it returns).
64 wxSize
Measure(wxDC
& dc
, int *visibleHeight
= NULL
) const;
66 // Render the markup string into the given DC in the specified rectangle.
68 // Notice that while the function uses the provided rectangle for alignment
69 // (it centers the text in it), no clipping is done by it so use Measure()
70 // and set the clipping region before rendering if necessary.
71 void Render(wxDC
& dc
, const wxRect
& rect
, int flags
);
77 #endif // _WX_GENERIC_PRIVATE_MARKUPTEXT_H_