1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
---|
2 | <!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/src/widgets/qmenudata.cpp:1461 -->
|
---|
3 | <html>
|
---|
4 | <head>
|
---|
5 | <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
---|
6 | <title>QCustomMenuItem Class</title>
|
---|
7 | <style type="text/css"><!--
|
---|
8 | fn { margin-left: 1cm; text-indent: -1cm; }
|
---|
9 | a:link { color: #004faf; text-decoration: none }
|
---|
10 | a:visited { color: #672967; text-decoration: none }
|
---|
11 | body { background: #ffffff; color: black; }
|
---|
12 | --></style>
|
---|
13 | </head>
|
---|
14 | <body>
|
---|
15 |
|
---|
16 | <table border="0" cellpadding="0" cellspacing="0" width="100%">
|
---|
17 | <tr bgcolor="#E5E5E5">
|
---|
18 | <td valign=center>
|
---|
19 | <a href="index.html">
|
---|
20 | <font color="#004faf">Home</font></a>
|
---|
21 | | <a href="classes.html">
|
---|
22 | <font color="#004faf">All Classes</font></a>
|
---|
23 | | <a href="mainclasses.html">
|
---|
24 | <font color="#004faf">Main Classes</font></a>
|
---|
25 | | <a href="annotated.html">
|
---|
26 | <font color="#004faf">Annotated</font></a>
|
---|
27 | | <a href="groups.html">
|
---|
28 | <font color="#004faf">Grouped Classes</font></a>
|
---|
29 | | <a href="functions.html">
|
---|
30 | <font color="#004faf">Functions</font></a>
|
---|
31 | </td>
|
---|
32 | <td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>QCustomMenuItem Class Reference</h1>
|
---|
33 |
|
---|
34 | <p>The QCustomMenuItem class is an abstract base class for custom menu items in popup menus.
|
---|
35 | <a href="#details">More...</a>
|
---|
36 | <p><tt>#include <<a href="qmenudata-h.html">qmenudata.h</a>></tt>
|
---|
37 | <p>Inherits <a href="qt.html">Qt</a>.
|
---|
38 | <p><a href="qcustommenuitem-members.html">List of all member functions.</a>
|
---|
39 | <h2>Public Members</h2>
|
---|
40 | <ul>
|
---|
41 | <li class=fn><a href="#QCustomMenuItem"><b>QCustomMenuItem</b></a> ()</li>
|
---|
42 | <li class=fn>virtual <a href="#~QCustomMenuItem"><b>~QCustomMenuItem</b></a> ()</li>
|
---|
43 | <li class=fn>virtual bool <a href="#fullSpan"><b>fullSpan</b></a> () const</li>
|
---|
44 | <li class=fn>virtual bool <a href="#isSeparator"><b>isSeparator</b></a> () const</li>
|
---|
45 | <li class=fn>virtual void <a href="#setFont"><b>setFont</b></a> ( const QFont & font )</li>
|
---|
46 | <li class=fn>virtual void <a href="#paint"><b>paint</b></a> ( QPainter * p, const QColorGroup & cg, bool act, bool enabled, int x, int y, int w, int h ) = 0</li>
|
---|
47 | <li class=fn>virtual QSize <a href="#sizeHint"><b>sizeHint</b></a> () = 0</li>
|
---|
48 | </ul>
|
---|
49 | <hr><a name="details"></a><h2>Detailed Description</h2>
|
---|
50 |
|
---|
51 |
|
---|
52 | The QCustomMenuItem class is an abstract base class for custom menu items in popup menus.
|
---|
53 | <p>
|
---|
54 | <p> A custom menu item is a menu item that is defined by two pure
|
---|
55 | virtual functions, <a href="#paint">paint</a>() and <a href="#sizeHint">sizeHint</a>(). The size hint tells the
|
---|
56 | menu how much space it needs to reserve for this item, and paint
|
---|
57 | is called whenever the item needs painting.
|
---|
58 | <p> This simple mechanism allows you to create all kinds of
|
---|
59 | application specific menu items. Examples are items showing
|
---|
60 | different fonts in a word processor or menus that allow the
|
---|
61 | selection of drawing utilities in a vector drawing program.
|
---|
62 | <p> A custom item is inserted into a popup menu with
|
---|
63 | <a href="qmenudata.html#insertItem">QPopupMenu::insertItem</a>().
|
---|
64 | <p> By default, a custom item can also have an icon and a keyboard
|
---|
65 | accelerator. You can reimplement <a href="#fullSpan">fullSpan</a>() to return TRUE if you
|
---|
66 | want the item to span the entire popup menu width. This is
|
---|
67 | particularly useful for labels.
|
---|
68 | <p> If you want the custom item to be treated just as a separator,
|
---|
69 | reimplement <a href="#isSeparator">isSeparator</a>() to return TRUE.
|
---|
70 | <p> Note that you can insert pixmaps or bitmaps as items into a popup
|
---|
71 | menu without needing to create a QCustomMenuItem. However, custom
|
---|
72 | menu items offer more flexibility, and -- especially important
|
---|
73 | with Windows style -- provide the possibility of drawing the item
|
---|
74 | with a different color when it is highlighted.
|
---|
75 | <p> <a href="menu-example.html">menu/menu.cpp</a> shows a simple
|
---|
76 | example how custom menu items can be used.
|
---|
77 | <p> Note: the current implementation of QCustomMenuItem will not
|
---|
78 | recognize shortcut keys that are from text with ampersands. Normal
|
---|
79 | accelerators work though.
|
---|
80 | <p> <img src=qpopmenu-fancy.png>
|
---|
81 | <p> <p>See also <a href="qmenudata.html">QMenuData</a>, <a href="qpopupmenu.html">QPopupMenu</a>, and <a href="misc.html">Miscellaneous Classes</a>.
|
---|
82 |
|
---|
83 | <hr><h2>Member Function Documentation</h2>
|
---|
84 | <h3 class=fn><a name="QCustomMenuItem"></a>QCustomMenuItem::QCustomMenuItem ()
|
---|
85 | </h3>
|
---|
86 | Constructs a QCustomMenuItem
|
---|
87 |
|
---|
88 | <h3 class=fn><a name="~QCustomMenuItem"></a>QCustomMenuItem::~QCustomMenuItem ()<tt> [virtual]</tt>
|
---|
89 | </h3>
|
---|
90 | Destroys a QCustomMenuItem
|
---|
91 |
|
---|
92 | <h3 class=fn>bool <a name="fullSpan"></a>QCustomMenuItem::fullSpan () const<tt> [virtual]</tt>
|
---|
93 | </h3>
|
---|
94 | Returns TRUE if this item wants to span the entire popup menu
|
---|
95 | width; otherwise returns FALSE. The default is FALSE, meaning that
|
---|
96 | the menu may show an icon and an accelerator key for this item as
|
---|
97 | well.
|
---|
98 |
|
---|
99 | <h3 class=fn>bool <a name="isSeparator"></a>QCustomMenuItem::isSeparator () const<tt> [virtual]</tt>
|
---|
100 | </h3>
|
---|
101 | Returns TRUE if this item is just a separator; otherwise returns
|
---|
102 | FALSE.
|
---|
103 |
|
---|
104 | <h3 class=fn>void <a name="paint"></a>QCustomMenuItem::paint ( <a href="qpainter.html">QPainter</a> * p, const <a href="qcolorgroup.html">QColorGroup</a> & cg, bool act, bool enabled, int x, int y, int w, int h )<tt> [pure virtual]</tt>
|
---|
105 | </h3>
|
---|
106 |
|
---|
107 | <p> Paints this item. When this function is invoked, the painter <em>p</em>
|
---|
108 | is set to a font and foreground color suitable for a menu item
|
---|
109 | text using color group <em>cg</em>. The item is active if <em>act</em> is TRUE
|
---|
110 | and enabled if <em>enabled</em> is TRUE. The geometry values <em>x</em>, <em>y</em>,
|
---|
111 | <em>w</em> and <em>h</em> specify where to draw the item.
|
---|
112 | <p> Do not draw any background, this has already been done by the
|
---|
113 | popup menu according to the current GUI style.
|
---|
114 |
|
---|
115 | <h3 class=fn>void <a name="setFont"></a>QCustomMenuItem::setFont ( const <a href="qfont.html">QFont</a> & font )<tt> [virtual]</tt>
|
---|
116 | </h3>
|
---|
117 | Sets the font of the custom menu item to <em>font</em>.
|
---|
118 | <p> This function is called whenever the font in the popup menu
|
---|
119 | changes. For menu items that show their own individual font entry,
|
---|
120 | you want to ignore this.
|
---|
121 |
|
---|
122 | <h3 class=fn><a href="qsize.html">QSize</a> <a name="sizeHint"></a>QCustomMenuItem::sizeHint ()<tt> [pure virtual]</tt>
|
---|
123 | </h3>
|
---|
124 |
|
---|
125 | <p> Returns the item's size hint.
|
---|
126 |
|
---|
127 | <!-- eof -->
|
---|
128 | <hr><p>
|
---|
129 | This file is part of the <a href="index.html">Qt toolkit</a>.
|
---|
130 | Copyright © 1995-2007
|
---|
131 | <a href="http://www.trolltech.com/">Trolltech</a>. All Rights Reserved.<p><address><hr><div align=center>
|
---|
132 | <table width=100% cellspacing=0 border=0><tr>
|
---|
133 | <td>Copyright © 2007
|
---|
134 | <a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
|
---|
135 | <td align=right><div align=right>Qt 3.3.8</div>
|
---|
136 | </table></div></address></body>
|
---|
137 | </html>
|
---|