Code_TYMPAN  4.4.0
Industrial site acoustic simulation
TYMenuItem.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) <2012-2024> <EDF-DTG> <FRANCE>
3  * This file is part of Code_TYMPAN (R).
4  * Code_TYMPAN (R) is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  * Code_TYMPAN (R) is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11  * See the GNU General Public License for more details.
12  * You should have received a copy of the GNU General Public License along
13  * with Code_TYMPAN (R). If not, see <https://www.gnu.org/licenses/>.
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