<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/src/widgets/qmenudata.cpp:1461 --> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>TQCustomMenuItem Class</title> <style type="text/css"><!-- fn { margin-left: 1cm; text-indent: -1cm; } a:link { color: #004faf; text-decoration: none } a:visited { color: #672967; text-decoration: none } body { background: #ffffff; color: black; } --></style> </head> <body> <table border="0" cellpadding="0" cellspacing="0" width="100%"> <tr bgcolor="#E5E5E5"> <td valign=center> <a href="index.html"> <font color="#004faf">Home</font></a> | <a href="classes.html"> <font color="#004faf">All Classes</font></a> | <a href="mainclasses.html"> <font color="#004faf">Main Classes</font></a> | <a href="annotated.html"> <font color="#004faf">Annotated</font></a> | <a href="groups.html"> <font color="#004faf">Grouped Classes</font></a> | <a href="functions.html"> <font color="#004faf">Functions</font></a> </td> <td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>TQCustomMenuItem Class Reference</h1> <p>The TQCustomMenuItem class is an abstract base class for custom menu items in popup menus. <a href="#details">More...</a> <p><tt>#include <<a href="qmenudata-h.html">ntqmenudata.h</a>></tt> <p>Inherits <a href="ntqt.html">TQt</a>. <p><a href="qcustommenuitem-members.html">List of all member functions.</a> <h2>Public Members</h2> <ul> <li class=fn><a href="#TQCustomMenuItem"><b>TQCustomMenuItem</b></a> ()</li> <li class=fn>virtual <a href="#~TQCustomMenuItem"><b>~TQCustomMenuItem</b></a> ()</li> <li class=fn>virtual bool <a href="#fullSpan"><b>fullSpan</b></a> () const</li> <li class=fn>virtual bool <a href="#isSeparator"><b>isSeparator</b></a> () const</li> <li class=fn>virtual void <a href="#setFont"><b>setFont</b></a> ( const TQFont & font )</li> <li class=fn>virtual void <a href="#paint"><b>paint</b></a> ( TQPainter * p, const TQColorGroup & cg, bool act, bool enabled, int x, int y, int w, int h ) = 0</li> <li class=fn>virtual TQSize <a href="#sizeHint"><b>sizeHint</b></a> () = 0</li> </ul> <hr><a name="details"></a><h2>Detailed Description</h2> The TQCustomMenuItem class is an abstract base class for custom menu items in popup menus. <p> <p> A custom menu item is a menu item that is defined by two pure virtual functions, <a href="#paint">paint</a>() and <a href="#sizeHint">sizeHint</a>(). The size hint tells the menu how much space it needs to reserve for this item, and paint is called whenever the item needs painting. <p> This simple mechanism allows you to create all kinds of application specific menu items. Examples are items showing different fonts in a word processor or menus that allow the selection of drawing utilities in a vector drawing program. <p> A custom item is inserted into a popup menu with <a href="ntqmenudata.html#insertItem">TQPopupMenu::insertItem</a>(). <p> By default, a custom item can also have an icon and a keyboard accelerator. You can reimplement <a href="#fullSpan">fullSpan</a>() to return TRUE if you want the item to span the entire popup menu width. This is particularly useful for labels. <p> If you want the custom item to be treated just as a separator, reimplement <a href="#isSeparator">isSeparator</a>() to return TRUE. <p> Note that you can insert pixmaps or bitmaps as items into a popup menu without needing to create a TQCustomMenuItem. However, custom menu items offer more flexibility, and -- especially important with Windows style -- provide the possibility of drawing the item with a different color when it is highlighted. <p> <a href="menu-example.html">menu/menu.cpp</a> shows a simple example how custom menu items can be used. <p> Note: the current implementation of TQCustomMenuItem will not recognize shortcut keys that are from text with ampersands. Normal accelerators work though. <p> <img src=qpopmenu-fancy.png> <p> <p>See also <a href="ntqmenudata.html">TQMenuData</a>, <a href="ntqpopupmenu.html">TQPopupMenu</a>, and <a href="misc.html">Miscellaneous Classes</a>. <hr><h2>Member Function Documentation</h2> <h3 class=fn><a name="TQCustomMenuItem"></a>TQCustomMenuItem::TQCustomMenuItem () </h3> Constructs a TQCustomMenuItem <h3 class=fn><a name="~TQCustomMenuItem"></a>TQCustomMenuItem::~TQCustomMenuItem ()<tt> [virtual]</tt> </h3> Destroys a TQCustomMenuItem <h3 class=fn>bool <a name="fullSpan"></a>TQCustomMenuItem::fullSpan () const<tt> [virtual]</tt> </h3> Returns TRUE if this item wants to span the entire popup menu width; otherwise returns FALSE. The default is FALSE, meaning that the menu may show an icon and an accelerator key for this item as well. <h3 class=fn>bool <a name="isSeparator"></a>TQCustomMenuItem::isSeparator () const<tt> [virtual]</tt> </h3> Returns TRUE if this item is just a separator; otherwise returns FALSE. <h3 class=fn>void <a name="paint"></a>TQCustomMenuItem::paint ( <a href="ntqpainter.html">TQPainter</a> * p, const <a href="qcolorgroup.html">TQColorGroup</a> & cg, bool act, bool enabled, int x, int y, int w, int h )<tt> [pure virtual]</tt> </h3> <p> Paints this item. When this function is invoked, the painter <em>p</em> is set to a font and foreground color suitable for a menu item text using color group <em>cg</em>. The item is active if <em>act</em> is TRUE and enabled if <em>enabled</em> is TRUE. The geometry values <em>x</em>, <em>y</em>, <em>w</em> and <em>h</em> specify where to draw the item. <p> Do not draw any background, this has already been done by the popup menu according to the current GUI style. <h3 class=fn>void <a name="setFont"></a>TQCustomMenuItem::setFont ( const <a href="ntqfont.html">TQFont</a> & font )<tt> [virtual]</tt> </h3> Sets the font of the custom menu item to <em>font</em>. <p> This function is called whenever the font in the popup menu changes. For menu items that show their own individual font entry, you want to ignore this. <h3 class=fn><a href="ntqsize.html">TQSize</a> <a name="sizeHint"></a>TQCustomMenuItem::sizeHint ()<tt> [pure virtual]</tt> </h3> <p> Returns the item's size hint. <!-- eof --> <hr><p> This file is part of the <a href="index.html">TQt toolkit</a>. Copyright © 1995-2007 <a href="http://www.trolltech.com/">Trolltech</a>. All Rights Reserved.<p><address><hr><div align=center> <table width=100% cellspacing=0 border=0><tr> <td>Copyright © 2007 <a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a> <td align=right><div align=right>TQt 3.3.8</div> </table></div></address></body> </html>