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