00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef POPUPMENUTITLE_H
00026 #define POPUPMENUTITLE_H
00027
00028 #include <tqfont.h>
00029 #include <tqstring.h>
00030 #include <tqstyle.h>
00031 #include <tqpainter.h>
00032 #include <tqmenudata.h>
00033
00034 #include <kapplication.h>
00035
00036 class PopupMenuTitle : public QCustomMenuItem
00037 {
00038 public:
00039 PopupMenuTitle(const TQString &name, const TQFont &font);
00040
00041 bool fullSpan () const { return true; }
00042
00043 void paint(TQPainter* p, const TQColorGroup& cg,
00044 bool , bool ,
00045 int x, int y, int w, int h)
00046 {
00047 p->save();
00048 TQRect r(x, y, w, h);
00049 kapp->style().drawPrimitive(TQStyle::PE_HeaderSection,
00050 p, r, cg);
00051
00052 if (!m_desktopName.isEmpty())
00053 {
00054 p->setPen(cg.buttonText());
00055 p->setFont(m_font);
00056 p->drawText(x, y, w, h,
00057 AlignCenter | SingleLine,
00058 m_desktopName);
00059 }
00060
00061 p->setPen(cg.highlight());
00062 p->drawLine(0, 0, r.right(), 0);
00063 p->restore();
00064 }
00065
00066 void setFont(const TQFont &font)
00067 {
00068 m_font = font;
00069 m_font.setBold(true);
00070 }
00071
00072 TQSize sizeHint()
00073 {
00074 TQSize size = TQFontMetrics(m_font).size(AlignHCenter, m_desktopName);
00075 size.setHeight(size.height() +
00076 (kapp->style().pixelMetric(TQStyle::PM_DefaultFrameWidth) * 2 + 1));
00077 return size;
00078 }
00079
00080 private:
00081 TQString m_desktopName;
00082 TQFont m_font;
00083 };
00084
00085 #endif