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