Salome HOME
8934f9cddf64161c50c505f2592ff535827486cd
[modules/gui.git] / src / Qtx / QtxFontEdit.h
1 //  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 //  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 //  This library is free software; you can redistribute it and/or
7 //  modify it under the terms of the GNU Lesser General Public
8 //  License as published by the Free Software Foundation; either
9 //  version 2.1 of the License.
10 //
11 //  This library is distributed in the hope that it will be useful,
12 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 //  Lesser General Public License for more details.
15 //
16 //  You should have received a copy of the GNU Lesser General Public
17 //  License along with this library; if not, write to the Free Software
18 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 // File:      QtxFontEdit.h
23 // Author:    Sergey TELKOV
24 //
25 #ifndef QTXFONTEDIT_H
26 #define QTXFONTEDIT_H
27
28 #include "Qtx.h"
29
30 #include <QFrame>
31
32 class QtxComboBox;
33 class QComboBox;
34 class QToolButton;
35 class QFontComboBox;
36
37 class QTX_EXPORT QtxFontEdit : public QFrame
38 {
39   Q_OBJECT
40
41 public:
42   //! Font widget features
43   typedef enum { 
44     Family    = 0x01,                                      //!< show font family selection widget
45     Size      = 0x02,                                      //!< show font size widget
46     UserSize  = 0x04,                                      //!< allow font size direct change
47     Bold      = 0x08,                                      //!< show 'bold' widget
48     Italic    = 0x10,                                      //!< show 'italic' widget
49     Underline = 0x20,                                      //!< show 'underline' widget
50     Shadow    = 0x40,                                      //!< show 'shadow' widget
51     Preview   = 0x80,                                      //!< show font preview widget
52     Scripting = Bold | Italic | Underline,                 //!< show font scripting widgets ('bold','italic','underline')
53     All = Family | Size | UserSize | Scripting | Preview   //!< show all font widgets
54   } Features;
55
56   typedef enum 
57   {
58     Native, //!< Native mode intended for working with system fonts
59     Custom  //!< Custom mode intended for working with manually defined set of fonts
60   } Mode;
61
62 public:
63   QtxFontEdit( const int, QWidget* = 0 );
64   QtxFontEdit( QWidget* = 0 );
65   virtual ~QtxFontEdit();
66
67   QFont          currentFont() const;
68   void           setCurrentFont( const QFont& );
69
70   int            fontSize() const;
71   QString        fontFamily() const;
72   int            fontScripting() const;
73
74   void           setFontSize( const int );
75   void           setFontFamily( const QString& );
76   void           setFontScripting( const int );
77
78   int            features() const;
79   void           setFeatures( const int );
80
81   void           setMode( const int );
82   int            mode() const;
83
84   void           setFonts( const QStringList& );
85   QStringList    fonts() const;
86
87   void           setSizes( const QList<int>& = QList<int>() );
88   QList<int>     sizes() const;
89
90 signals:
91   void           changed( const QFont& );
92
93 private slots:
94   void           onPreview( bool );
95   void           onFontChanged( const QFont& );
96   void           onPropertyChanged();
97  
98 private:
99   void           initialize();
100   void           updateState();
101
102 private:
103   QtxComboBox*   mySize;
104   QFontComboBox* myFamily;
105   QToolButton*   myPreview;
106   int            myFeatures;
107   QToolButton    *myB, *myI, *myU, *myS;
108   int            myMode;
109   QComboBox*     myCustomFams;
110 };
111
112 #endif // QTXFONTEDIT_H