-rw-r--r-- | libopie2/opieui/otabbar.cpp | 50 | ||||
-rw-r--r-- | libopie2/opieui/otabbar.h | 46 | ||||
-rw-r--r-- | libopie2/opieui/otabwidget.cpp | 1 |
3 files changed, 50 insertions, 47 deletions
diff --git a/libopie2/opieui/otabbar.cpp b/libopie2/opieui/otabbar.cpp index a62e18b..dc5df42 100644 --- a/libopie2/opieui/otabbar.cpp +++ b/libopie2/opieui/otabbar.cpp | |||
@@ -1,83 +1,87 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | 3 | ||
4 | Copyright (c) 2002 Dan Williams <williamsdr@acm.org> | 4 | Copyright (c) 2002 Dan Williams <williamsdr@acm.org> |
5 | =. | 5 | =. |
6 | .=l. | 6 | .=l. |
7 | .>+-= | 7 | .>+-= |
8 | _;:, .> :=|. This program is free software; you can | 8 | _;:, .> :=|. This program is free software; you can |
9 | .> <`_, > . <= redistribute it and/or modify it under | 9 | .> <`_, > . <= redistribute it and/or modify it under |
10 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 10 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
11 | .="- .-=="i, .._ License as published by the Free Software | 11 | .="- .-=="i, .._ License as published by the Free Software |
12 | - . .-<_> .<> Foundation; either version 2 of the License, | 12 | - . .-<_> .<> Foundation; either version 2 of the License, |
13 | ._= =} : or (at your option) any later version. | 13 | ._= =} : or (at your option) any later version. |
14 | .%`+i> _;_. | 14 | .%`+i> _;_. |
15 | .i_,=:_. -<s. This program is distributed in the hope that | 15 | .i_,=:_. -<s. This program is distributed in the hope that |
16 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 16 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
17 | : .. .:, . . . without even the implied warranty of | 17 | : .. .:, . . . without even the implied warranty of |
18 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 18 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
19 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 19 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
20 | ..}^=.= = ; Library General Public License for more | 20 | ..}^=.= = ; Library General Public License for more |
21 | ++= -. .` .: details. | 21 | ++= -. .` .: details. |
22 | : = ...= . :.=- | 22 | : = ...= . :.=- |
23 | -. .:....=;==+<; You should have received a copy of the GNU | 23 | -. .:....=;==+<; You should have received a copy of the GNU |
24 | -_. . . )=. = Library General Public License along with | 24 | -_. . . )=. = Library General Public License along with |
25 | -- :-=` this library; see the file COPYING.LIB. | 25 | -- :-=` this library; see the file COPYING.LIB. |
26 | If not, write to the Free Software Foundation, | 26 | If not, write to the Free Software Foundation, |
27 | Inc., 59 Temple Place - Suite 330, | 27 | Inc., 59 Temple Place - Suite 330, |
28 | Boston, MA 02111-1307, USA. | 28 | Boston, MA 02111-1307, USA. |
29 | 29 | ||
30 | */ | 30 | */ |
31 | 31 | ||
32 | #include <opie2/otabbar.h> | 32 | #include <opie2/otabbar.h> |
33 | 33 | ||
34 | #include <qpe/applnk.h> | ||
35 | |||
36 | #include <stdio.h> | ||
37 | |||
34 | using namespace Opie::Ui; | 38 | using namespace Opie::Ui; |
35 | 39 | ||
36 | OTabBar::OTabBar( QWidget *parent , const char *name ) | 40 | OTabBar::OTabBar( QWidget *parent , const char *name ) |
37 | :QTabBar( parent, name ) | 41 | :QTabBar( parent, name ) |
38 | {} | 42 | {} |
39 | 43 | ||
40 | void OTabBar::paintLabel( QPainter* p, const QRect& br, QTab* t, bool has_focus ) const | 44 | void OTabBar::paintLabel( QPainter* p, const QRect& br, QTab* t, bool has_focus ) const |
41 | { | 45 | { |
42 | 46 | ||
43 | QRect r = br; | 47 | QRect r = br; |
44 | if ( t->iconset) | 48 | if ( t->iconset) |
45 | { | 49 | { |
46 | QIconSet::Mode mode = (t->enabled && isEnabled()) ? QIconSet::Normal : QIconSet::Disabled; | 50 | QIconSet::Mode mode = (t->enabled && isEnabled()) ? QIconSet::Normal : QIconSet::Disabled; |
47 | if ( mode == QIconSet::Normal && has_focus ) | 51 | if ( mode == QIconSet::Normal && has_focus ) |
48 | { | 52 | { |
49 | mode = QIconSet::Active; | 53 | mode = QIconSet::Active; |
50 | } | 54 | } |
51 | QPixmap pixmap = t->iconset->pixmap( QIconSet::Small, mode ); | 55 | QPixmap pixmap = t->iconset->pixmap(); |
52 | int pixw = pixmap.width(); | 56 | int pixw = pixmap.width(); |
53 | int pixh = pixmap.height(); | 57 | int pixh = pixmap.height(); |
54 | r.setLeft( r.left() + pixw + 2 ); | 58 | r.setLeft( r.left() + pixw + 2 ); |
55 | p->drawPixmap( br.left()+2, br.center().y()-pixh/2, pixmap ); | 59 | p->drawPixmap( br.left()+2, br.center().y()-pixh/2, pixmap ); |
56 | } | 60 | } |
57 | 61 | ||
58 | QRect tr = r; | 62 | QRect tr = r; |
59 | if ( t->id == currentTab() ) | 63 | if ( t->id == currentTab() ) |
60 | { | 64 | { |
61 | tr.setBottom( tr.bottom() - style().defaultFrameWidth() ); | 65 | tr.setBottom( tr.bottom() - style().defaultFrameWidth() ); |
62 | } | 66 | } |
63 | 67 | ||
64 | if ( t->enabled && isEnabled() ) | 68 | if ( t->enabled && isEnabled() ) |
65 | { | 69 | { |
66 | p->setPen( colorGroup().foreground() ); | 70 | p->setPen( colorGroup().foreground() ); |
67 | p->drawText( tr, AlignCenter | ShowPrefix, t->label ); | 71 | p->drawText( tr, AlignCenter | ShowPrefix, t->label ); |
68 | } | 72 | } |
69 | else if ( style() == MotifStyle ) | 73 | else if ( style() == MotifStyle ) |
70 | { | 74 | { |
71 | p->setPen( palette().disabled().foreground() ); | 75 | p->setPen( palette().disabled().foreground() ); |
72 | p->drawText( tr, AlignCenter | ShowPrefix, t->label ); | 76 | p->drawText( tr, AlignCenter | ShowPrefix, t->label ); |
73 | } | 77 | } |
74 | else | 78 | else |
75 | { | 79 | { |
76 | p->setPen( colorGroup().light() ); | 80 | p->setPen( colorGroup().light() ); |
77 | QRect wr = tr; | 81 | QRect wr = tr; |
78 | wr.moveBy( 1, 1 ); | 82 | wr.moveBy( 1, 1 ); |
79 | p->drawText( wr, AlignCenter | ShowPrefix, t->label ); | 83 | p->drawText( wr, AlignCenter | ShowPrefix, t->label ); |
80 | p->setPen( palette().disabled().foreground() ); | 84 | p->setPen( palette().disabled().foreground() ); |
81 | p->drawText( tr, AlignCenter | ShowPrefix, t->label ); | 85 | p->drawText( tr, AlignCenter | ShowPrefix, t->label ); |
82 | } | 86 | } |
83 | } | 87 | } |
diff --git a/libopie2/opieui/otabbar.h b/libopie2/opieui/otabbar.h index 925ae96..1044bdd 100644 --- a/libopie2/opieui/otabbar.h +++ b/libopie2/opieui/otabbar.h | |||
@@ -1,77 +1,77 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | 3 | ||
4 | Copyright (c) 2002 Dan Williams <williamsdr@acm.org> | 4 | Copyright (c) 2002 Dan Williams <williamsdr@acm.org> |
5 | =. | 5 | =. |
6 | .=l. | 6 | .=l. |
7 | .>+-= | 7 | .>+-= |
8 | _;:, .> :=|. This program is free software; you can | 8 | _;:, .> :=|. This program is free software; you can |
9 | .> <`_, > . <= redistribute it and/or modify it under | 9 | .> <`_, > . <= redistribute it and/or modify it under |
10 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 10 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
11 | .="- .-=="i, .._ License as published by the Free Software | 11 | .="- .-=="i, .._ License as published by the Free Software |
12 | - . .-<_> .<> Foundation; either version 2 of the License, | 12 | - . .-<_> .<> Foundation; either version 2 of the License, |
13 | ._= =} : or (at your option) any later version. | 13 | ._= =} : or (at your option) any later version. |
14 | .%`+i> _;_. | 14 | .%`+i> _;_. |
15 | .i_,=:_. -<s. This program is distributed in the hope that | 15 | .i_,=:_. -<s. This program is distributed in the hope that |
16 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 16 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
17 | : .. .:, . . . without even the implied warranty of | 17 | : .. .:, . . . without even the implied warranty of |
18 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 18 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
19 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 19 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
20 | ..}^=.= = ; Library General Public License for more | 20 | ..}^=.= = ; Library General Public License for more |
21 | ++= -. .` .: details. | 21 | ++= -. .` .: details. |
22 | : = ...= . :.=- | 22 | : = ...= . :.=- |
23 | -. .:....=;==+<; You should have received a copy of the GNU | 23 | -. .:....=;==+<; You should have received a copy of the GNU |
24 | -_. . . )=. = Library General Public License along with | 24 | -_. . . )=. = Library General Public License along with |
25 | -- :-=` this library; see the file COPYING.LIB. | 25 | -- :-=` this library; see the file COPYING.LIB. |
26 | If not, write to the Free Software Foundation, | 26 | If not, write to the Free Software Foundation, |
27 | Inc., 59 Temple Place - Suite 330, | 27 | Inc., 59 Temple Place - Suite 330, |
28 | Boston, MA 02111-1307, USA. | 28 | Boston, MA 02111-1307, USA. |
29 | 29 | ||
30 | */ | 30 | */ |
31 | 31 | ||
32 | #ifndef OTABBAR_H | 32 | #ifndef OTABBAR_H |
33 | #define OTABBAR_H | 33 | #define OTABBAR_H |
34 | 34 | ||
35 | /* QT */ | 35 | /* QT */ |
36 | #include <qtabbar.h> | 36 | #include <qtabbar.h> |
37 | 37 | ||
38 | namespace Opie { | 38 | namespace Opie { |
39 | namespace Ui { | 39 | namespace Ui { |
40 | 40 | ||
41 | /** | 41 | /** |
42 | * @class OTabBar | 42 | * @class OTabBar |
43 | * @brief The OTabBar class is a derivative of QTabBar. | 43 | * @brief The OTabBar class is a derivative of QTabBar. |
44 | * | 44 | * |
45 | * OTabBar is a derivation of TrollTech's QTabBar which provides | 45 | * OTabBar is a derivation of TrollTech's QTabBar which provides |
46 | * a row of tabs for selection. The only difference between this | 46 | * a row of tabs for selection. The only difference between this |
47 | * class and QTabBar is that there is no dotted line box around | 47 | * class and QTabBar is that there is no dotted line box around |
48 | * the label of the tab with the current focus. | 48 | * the label of the tab with the current focus. |
49 | */ | 49 | */ |
50 | class OTabBar : public QTabBar | 50 | class OTabBar : public QTabBar |
51 | { | 51 | { |
52 | Q_OBJECT | 52 | Q_OBJECT |
53 | 53 | ||
54 | public: | 54 | public: |
55 | /** | 55 | /** |
56 | * @fn OTabBar( QWidget *parent = 0, const char *name = 0 ) | 56 | * @fn OTabBar( QWidget *parent = 0, const char *name = 0 ) |
57 | * @brief Object constructor. | 57 | * @brief Object constructor. |
58 | * | 58 | * |
59 | * @param parent Pointer to parent of this control. | 59 | * @param parent Pointer to parent of this control. |
60 | * @param name Name of control. | 60 | * @param name Name of control. |
61 | * | 61 | * |
62 | * Constructs a new OTabBar control with parent and name. | 62 | * Constructs a new OTabBar control with parent and name. |
63 | */ | 63 | */ |
64 | OTabBar( QWidget * = 0, const char * = 0 ); | 64 | OTabBar( QWidget * = 0, const char * = 0 ); |
65 | 65 | ||
66 | protected: | 66 | protected: |
67 | /** | 67 | /** |
68 | * @fn paintLabel( QPainter* p, const QRect& br , QTab* t, bool has_focus)const | 68 | * @fn paintLabel( QPainter* p, const QRect& br , QTab* t, bool has_focus)const |
69 | * @brief Internal function to draw a tab's label. | 69 | * @brief Internal function to draw a tab's label. |
70 | * | 70 | * |
71 | * @param p Pointer to QPainter used for drawing. | 71 | * @param p Pointer to QPainter used for drawing. |
72 | * @param br QRect providing region to draw label in. | 72 | * @param br QRect providing region to draw label in. |
73 | * @param t Tab to draw label for. | 73 | * @param t Tab to draw label for. |
74 | * @param has_focus Boolean value not used, retained for compatibility reasons. | 74 | * @param has_focus Boolean value not used, retained for compatibility reasons. |
75 | */ | 75 | */ |
76 | void paintLabel( QPainter *, const QRect &, QTab *, bool ) const; | 76 | void paintLabel( QPainter *, const QRect &, QTab *, bool ) const; |
77 | 77 | ||
diff --git a/libopie2/opieui/otabwidget.cpp b/libopie2/opieui/otabwidget.cpp index 7333f5e..d617a9c 100644 --- a/libopie2/opieui/otabwidget.cpp +++ b/libopie2/opieui/otabwidget.cpp | |||
@@ -1,85 +1,84 @@ | |||
1 | /* | 1 | /* |
2 | Â Â Â Â Â Â Â Â This file is part of the Opie Project | 2 | Â Â Â Â Â Â Â Â This file is part of the Opie Project |
3 | 3 | ||
4 | Copyright (C) 2002, 2005 Dan Williams <drw@handhelds.org> | 4 | Copyright (C) 2002, 2005 Dan Williams <drw@handhelds.org> |
5 | =. | 5 | =. |
6 | .=l. | 6 | .=l. |
7 | Â Â Â Â Â Â .>+-= | 7 | Â Â Â Â Â Â .>+-= |
8 | Â _;:, Â Â .> Â Â :=|. This program is free software; you can | 8 | Â _;:, Â Â .> Â Â :=|. This program is free software; you can |
9 | .> <`_, Â > Â . Â <= redistribute it and/or modify it under | 9 | .> <`_, Â > Â . Â <= redistribute it and/or modify it under |
10 | :`=1 )Y*s>-.-- Â : the terms of the GNU Library General Public | 10 | :`=1 )Y*s>-.-- Â : the terms of the GNU Library General Public |
11 | .="- .-=="i, Â Â .._ License as published by the Free Software | 11 | .="- .-=="i, Â Â .._ License as published by the Free Software |
12 | Â - . Â .-<_> Â Â .<> Foundation; either version 2 of the License, | 12 | Â - . Â .-<_> Â Â .<> Foundation; either version 2 of the License, |
13 | Â Â Â ._= =} Â Â Â : or (at your option) any later version. | 13 | Â Â Â ._= =} Â Â Â : or (at your option) any later version. |
14 | Â Â .%`+i> Â Â Â _;_. | 14 | Â Â .%`+i> Â Â Â _;_. |
15 | Â Â .i_,=:_. Â Â Â -<s. This program is distributed in the hope that | 15 | Â Â .i_,=:_. Â Â Â -<s. This program is distributed in the hope that |
16 | Â Â Â + Â . Â -:. Â Â Â = it will be useful, but WITHOUT ANY WARRANTY; | 16 | Â Â Â + Â . Â -:. Â Â Â = it will be useful, but WITHOUT ANY WARRANTY; |
17 | : .. Â Â .:, Â Â . . . without even the implied warranty of | 17 | : .. Â Â .:, Â Â . . . without even the implied warranty of |
18 | Â Â =_ Â Â Â Â + Â Â =;=|` MERCHANTABILITY or FITNESS FOR A | 18 | Â Â =_ Â Â Â Â + Â Â =;=|` MERCHANTABILITY or FITNESS FOR A |
19 | Â _.=:. Â Â Â : Â Â :=>`: PARTICULAR PURPOSE. See the GNU | 19 | Â _.=:. Â Â Â : Â Â :=>`: PARTICULAR PURPOSE. See the GNU |
20 | ..}^=.= Â Â Â = Â Â Â ; Library General Public License for more | 20 | ..}^=.= Â Â Â = Â Â Â ; Library General Public License for more |
21 | ++= Â -. Â Â .` Â Â .: details. | 21 | ++= Â -. Â Â .` Â Â .: details. |
22 | : Â Â = Â ...= . :.=- | 22 | : Â Â = Â ...= . :.=- |
23 | Â -. Â .:....=;==+<; You should have received a copy of the GNU | 23 | Â -. Â .:....=;==+<; You should have received a copy of the GNU |
24 | Â -_. . . Â )=. Â = Library General Public License along with | 24 | Â -_. . . Â )=. Â = Library General Public License along with |
25 | Â Â -- Â Â Â Â :-=` this library; see the file COPYING.LIB. | 25 | Â Â -- Â Â Â Â :-=` this library; see the file COPYING.LIB. |
26 | If not, write to the Free Software Foundation, | 26 | If not, write to the Free Software Foundation, |
27 | Inc., 59 Temple Place - Suite 330, | 27 | Inc., 59 Temple Place - Suite 330, |
28 | Boston, MA 02111-1307, USA. | 28 | Boston, MA 02111-1307, USA. |
29 | */ | 29 | */ |
30 | 30 | ||
31 | #include <opie2/otabwidget.h> | 31 | #include <opie2/otabwidget.h> |
32 | 32 | ||
33 | /* OPIE */ | 33 | /* OPIE */ |
34 | #include <opie2/oresource.h> | 34 | #include <opie2/oresource.h> |
35 | #include <opie2/otabbar.h> | 35 | #include <opie2/otabbar.h> |
36 | 36 | ||
37 | #include <qpe/applnk.h> | ||
38 | #include <qpe/config.h> | 37 | #include <qpe/config.h> |
39 | 38 | ||
40 | /* QT */ | 39 | /* QT */ |
41 | #include <qcombobox.h> | 40 | #include <qcombobox.h> |
42 | #include <qwidgetstack.h> | 41 | #include <qwidgetstack.h> |
43 | 42 | ||
44 | using namespace Opie::Ui; | 43 | using namespace Opie::Ui; |
45 | 44 | ||
46 | OTabWidget::OTabWidget( QWidget *parent, const char *name, TabStyle s, TabPosition p ) | 45 | OTabWidget::OTabWidget( QWidget *parent, const char *name, TabStyle s, TabPosition p ) |
47 | : QWidget( parent, name ) | 46 | : QWidget( parent, name ) |
48 | , m_currTab( 0l ) | 47 | , m_currTab( 0l ) |
49 | , m_tabBarStyle( Global ) | 48 | , m_tabBarStyle( Global ) |
50 | , m_tabBarPosition( Top ) | 49 | , m_tabBarPosition( Top ) |
51 | , m_usingTabs( true ) | 50 | , m_usingTabs( true ) |
52 | , m_tabBar( 0l ) | 51 | , m_tabBar( 0l ) |
53 | , m_tabList( 0l ) | 52 | , m_tabList( 0l ) |
54 | { | 53 | { |
55 | if ( s == Global ) | 54 | if ( s == Global ) |
56 | { | 55 | { |
57 | // Read Opie global settings for style and position | 56 | // Read Opie global settings for style and position |
58 | Config config( "qpe" ); | 57 | Config config( "qpe" ); |
59 | config.setGroup( "Appearance" ); | 58 | config.setGroup( "Appearance" ); |
60 | 59 | ||
61 | // Style | 60 | // Style |
62 | s = ( TabStyle ) config.readNumEntry( "TabStyle", (int) IconTab ); | 61 | s = ( TabStyle ) config.readNumEntry( "TabStyle", (int) IconTab ); |
63 | if ( s <= Global || s > IconList) | 62 | if ( s <= Global || s > IconList) |
64 | s = IconTab; | 63 | s = IconTab; |
65 | 64 | ||
66 | // Position | 65 | // Position |
67 | ( config.readEntry( "TabPosition", "Top" ) == "Bottom" ) ? p = Bottom | 66 | ( config.readEntry( "TabPosition", "Top" ) == "Bottom" ) ? p = Bottom |
68 | : p = Top; | 67 | : p = Top; |
69 | } | 68 | } |
70 | 69 | ||
71 | // Initialize widget stack for tab widgets | 70 | // Initialize widget stack for tab widgets |
72 | m_widgetStack = new QWidgetStack( this ); | 71 | m_widgetStack = new QWidgetStack( this ); |
73 | m_widgetStack->setFrameStyle( QFrame::NoFrame ); | 72 | m_widgetStack->setFrameStyle( QFrame::NoFrame ); |
74 | m_widgetStack->setLineWidth( style().defaultFrameWidth() ); | 73 | m_widgetStack->setLineWidth( style().defaultFrameWidth() ); |
75 | 74 | ||
76 | // Set initial selector control style and position | 75 | // Set initial selector control style and position |
77 | setTabStyle( s ); | 76 | setTabStyle( s ); |
78 | setTabPosition( p ); | 77 | setTabPosition( p ); |
79 | } | 78 | } |
80 | 79 | ||
81 | OTabWidget::~OTabWidget() | 80 | OTabWidget::~OTabWidget() |
82 | { | 81 | { |
83 | m_tabs.setAutoDelete( true ); | 82 | m_tabs.setAutoDelete( true ); |
84 | m_tabs.clear(); | 83 | m_tabs.clear(); |
85 | } | 84 | } |