-rw-r--r-- | libopie/ofontmenu.h | 44 |
1 files changed, 37 insertions, 7 deletions
diff --git a/libopie/ofontmenu.h b/libopie/ofontmenu.h index 5fd515f..6e143ca 100644 --- a/libopie/ofontmenu.h +++ b/libopie/ofontmenu.h | |||
@@ -1,78 +1,108 @@ | |||
1 | 1 | ||
2 | /* | 2 | /* |
3 | 3 | ||
4 | =. This file is part of the OPIE Project | 4 | =. This file is part of the OPIE Project |
5 | .=l. Copyright (c) 2002 zecke <zecke@handhelds.org> | 5 | .=l. Copyright (c) 2002 zecke <zecke@handhelds.org> |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This library is free software; you can | 7 | _;:, .> :=|. This library is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This library is distributed in the hope that | 14 | .i_,=:_. -<s. This library is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
19 | ..}^=.= = ; Library General Public License for more | 19 | ..}^=.= = ; Library General Public License for more |
20 | ++= -. .` .: details. | 20 | ++= -. .` .: details. |
21 | : = ...= . :.=- | 21 | : = ...= . :.=- |
22 | -. .:....=;==+<; You should have received a copy of the GNU | 22 | -. .:....=;==+<; You should have received a copy of the GNU |
23 | -_. . . )=. = Library General Public License along with | 23 | -_. . . )=. = Library General Public License along with |
24 | -- :-=` this library; see the file COPYING.LIB. | 24 | -- :-=` this library; see the file COPYING.LIB. |
25 | If not, write to the Free Software Foundation, | 25 | If not, write to the Free Software Foundation, |
26 | Inc., 59 Temple Place - Suite 330, | 26 | Inc., 59 Temple Place - Suite 330, |
27 | Boston, MA 02111-1307, USA. | 27 | Boston, MA 02111-1307, USA. |
28 | 28 | ||
29 | */ | 29 | */ |
30 | 30 | ||
31 | 31 | ||
32 | 32 | ||
33 | 33 | ||
34 | #ifndef ofontmenu_h | 34 | #ifndef ofontmenu_h |
35 | #define ofontmenu_h | 35 | #define ofontmenu_h |
36 | 36 | ||
37 | #include <qpopupmenu.h> | 37 | #include <qpopupmenu.h> |
38 | #include <qlist.h> | 38 | #include <qlist.h> |
39 | 39 | ||
40 | 40 | /* | |
41 | * @internal | ||
42 | */ | ||
41 | namespace { | 43 | namespace { |
42 | struct WidSize { | 44 | struct WidSize { |
43 | QWidget *wid; | 45 | QWidget *wid; |
44 | int size; | 46 | int size; |
45 | }; | 47 | }; |
46 | 48 | ||
47 | }; | 49 | }; |
48 | 50 | ||
49 | // if i would be on kde this would be a KActionMenu... | 51 | // forward declarations |
50 | class Config; | 52 | class Config; |
53 | |||
54 | /** | ||
55 | * This class is a specialised QPopupMenu. It'll display three different | ||
56 | * font sizes. Small, Normal and large by adding widgets to the Menu | ||
57 | * you can control the font size of these widgets | ||
58 | * by using the save and restore method you can also apply font sizes | ||
59 | * over two different runtimes | ||
60 | * | ||
61 | * <pre> | ||
62 | * QTable* tbl = new QTable(); | ||
63 | * QList<QWidget> wid; | ||
64 | * wid.append( tbl ); | ||
65 | * OFontMenu* menu = new OFontMenu(this, "Popup Menu", wid ); | ||
66 | * Config cfg("mycfg"); | ||
67 | * menu->restore( cfg ); | ||
68 | * </pre> | ||
69 | * | ||
70 | * @author Holger Freyther ( zecke@handhelds.org ) | ||
71 | * @version 0.1 | ||
72 | * @short PopupMenu which can control the size of Widgets | ||
73 | * @see QPopupMenu | ||
74 | */ | ||
51 | class OFontMenu : public QPopupMenu { | 75 | class OFontMenu : public QPopupMenu { |
52 | Q_OBJECT | 76 | Q_OBJECT |
53 | public: | 77 | public: |
54 | OFontMenu(QWidget *parent, const char* name, const QList<QWidget> &list ); | 78 | OFontMenu(QWidget *parent, const char* name, const QList<QWidget> &list ); |
55 | void save(Config *cfg ); | 79 | void save(Config *cfg ); |
56 | void restore(Config *cfg ); | 80 | void restore(Config *cfg ); |
57 | void setWidgets(const QList<QWidget> &list ); | 81 | void setWidgets(const QList<QWidget> &list ); |
58 | void addWidget(QWidget *wid ); | 82 | void addWidget(QWidget *wid ); |
59 | void forceSize(QWidget *wid, int size ); | 83 | void forceSize(QWidget *wid, int size ); |
60 | void removeWidget(QWidget *wid ); | 84 | void removeWidget(QWidget *wid ); |
61 | const QList<QWidget> &widgets()const; | 85 | const QList<QWidget> &widgets()const; |
62 | 86 | ||
63 | signals: | 87 | signals: |
88 | /** | ||
89 | * this signal gets emitted when the font size gets changed | ||
90 | * @param size The new size of font | ||
91 | */ | ||
64 | void fontChanged(int size ); | 92 | void fontChanged(int size ); |
93 | |||
65 | private: | 94 | private: |
66 | QList<QWidget> m_list; | 95 | QList<QWidget> m_list; |
67 | QList<WidSize> m_wids; | 96 | QList<WidSize> m_wids; |
68 | int m_size; | 97 | int m_size; |
69 | class OFontMenuPrivate; | 98 | class OFontMenuPrivate; |
70 | OFontMenuPrivate *d; | 99 | OFontMenuPrivate *d; |
100 | |||
71 | private slots: | 101 | private slots: |
72 | virtual void slotSmall(); | 102 | virtual void slotSmall(); |
73 | virtual void slotMedium(); | 103 | virtual void slotMedium(); |
74 | virtual void slotLarge(); | 104 | virtual void slotLarge(); |
75 | void setFontSize(int size ); | 105 | void setFontSize(int size ); |
76 | }; | 106 | }; |
77 | 107 | ||
78 | #endif | 108 | #endif |