Code_TYMPAN  4.4.0
Industrial site acoustic simulation
TYMenuItem.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) <2012> <EDF-R&D> <FRANCE>
3  * This program is free software; you can redistribute it and/or modify
4  * it under the terms of the GNU General Public License as published by
5  * the Free Software Foundation; either version 2 of the License, or
6  * (at your option) any later version.
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10  * See the GNU General Public License for more details.
11  * You should have received a copy of the GNU General Public License along
12  * with this program; if not, write to the Free Software Foundation, Inc.,
13  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
14  */
15 
16 /*
17  *
18  *
19  */
20 
27 #ifndef __TY_MENU_ITEM__
28 #define __TY_MENU_ITEM__
29 
30 #include "TYAppDefines.h"
31 #include <qpainter.h>
32 
37 class TYMenuItem : public QAction
38 {
39 public:
40  TYMenuItem(const QString& s, const QFont& f) : QAction(NULL), _string(s), _font(f)
41  {
42  setObjectName(s);
43  };
45 
46  void paint(QPainter* p, int x, int y, int w, int h)
47  {
48  p->setFont(_font);
49  p->drawText(x, y, w, h, Qt::AlignLeft | Qt::AlignVCenter | Qt::TextDontClip, _string);
50  }
51 
52  QSize sizeHint()
53  {
54  return QFontMetrics(_font).size(Qt::AlignLeft | Qt::AlignVCenter | Qt::TextDontClip, _string);
55  }
56 
57 private:
58  QString _string;
59  QFont _font;
60 };
61 
62 #endif // __TY_MENU_ITEM__
NxReal s
Definition: NxVec3.cpp:317
gestion des items de menu avec une police et des styles particuliers (gras, italique....
Definition: TYMenuItem.h:38
QString _string
Definition: TYMenuItem.h:58
void paint(QPainter *p, int x, int y, int w, int h)
Definition: TYMenuItem.h:46
TYMenuItem(const QString &s, const QFont &f)
Definition: TYMenuItem.h:40
QSize sizeHint()
Definition: TYMenuItem.h:52
QFont _font
Definition: TYMenuItem.h:59