Provides a set of flags which determine how text is drawn and measured by the DrawText and MeasureText methods of ControlRenderer.
This enumeration has a FlagsAttribute attribute that allows a bitwise combination of its member values.
This example includes the two event handlers required to owner-draw a menu item. Assume that there is a themed Rebar control on the same form called rebar1.
/// <summary>
/// Handles the MeasureItem event for a menu item.
/// </summary>
private void menuItem1_MeasureItem(object sender, System.Windows.Forms.MeasureItemEventArgs e)
{
// obtain the menu renderer used by the rebar control
RebarMenuItemRenderer rend = rebar1.Theme.CreateMenuItemRenderer(sender as MenuItem, e);
// set our custom text
rend.Text = "Custom long text";
// measure the size of the item
Size sz = rend.MeasureItem();
e.ItemHeight = sz.Height;
e.ItemWidth = sz.Width;
}
/// <summary>
/// Handles the DrawItem event for a menu item.
/// </summary>
private void menuItem1_DrawItem(object sender, System.Windows.Forms.DrawItemEventArgs e)
{
// obtain the menu renderer used by the rebar control
RebarMenuItemRenderer rend = rebar1.Theme.CreateMenuItemRenderer(sender as MenuItem, e);
// invoke the standard background, image and arrow drawing methods
rend.DrawBackground(e.Graphics);
rend.DrawImage(e.Graphics);
rend.DrawArrow(e.Graphics);
// draw our custom text
ControlRenderer.DrawText(e.Graphics, "Custom long text", rend.Font, rend.ForeColor, rend.GetTextBounds(),
rend.GetTextRenderFlags());
// draw the shortcut text
ControlRenderer.DrawText(e.Graphics, rend.ShortcutText, rend.Font, rend.ForeColor, rend.GetTextBounds(),
rend.GetTextRenderFlags() | TextRenderFlags.AlignFar);
}
| Member Name | Description | Value |
|---|---|---|
| AlignNear | Text is aligned on the near edge of the bounding rectangle. For left-to-right layouts, this is the left edge. This is the default alignment. | 0 |
| AlignFar | Text is aligned on the far edge of the bounding rectangle. For left-to-right layouts, this is the right edge. | 1 |
| AlignCenter | Text is centered within the bounding rectangle. | 2 |
| MaskAlignHoriz | A bitmask to extract the horizontal alignment portion of the flags. | 3 |
| AlignTop | Text is aligned at the top of the bounding rectangle. The is the default vertical alignment. | 0 |
| AlignMiddle | Text is vertically centered within the bounding rectangle. When this alignment value is specified, no word-wrapping is performed. | 4 |
| AlignBottom | Text is aligned at the bottom of the bounding rectangle. | 8 |
| MaskAlignVert | A bitmask to extract the vertical alignment portion of the flags. | 12 |
| HotkeyPrefixShow | An underline is drawn below hotkey characters. | 0 |
| HotkeyPrefixHide | No underline is drawn below hotkey characters. | 16 |
| HotkeyPrefixNone | The ampersand character (&) is drawn normally, and not treated as a hotkey prefix. | 32 |
| MaskHotkeyPrefix | A bitmask to extract the hotkey prefix portion of the flags. | 48 |
| RightToLeft | Text is layed out with a right-to-left reading order. | 64 |
| WordWrap | Text should be word-wrapped within the bounding rectangle. | 128 |
| OverflowEllipsis | Text which extends outside the bounding rectangle should be truncated, and an ellipsis (...) appended to the end. | 256 |
| StandardDrawing | Text is drawn using a Graphics object (GDI+). By default, text is drawn using Windows GDI. | 512 |
Namespace: Skybound.Rebar.Rendering
Assembly: Skybound.Rebar (in Skybound.Rebar.dll)
Skybound.Rebar.Rendering Namespace