author | zecke <zecke> | 2003-08-30 20:28:13 (UTC) |
---|---|---|
committer | zecke <zecke> | 2003-08-30 20:28:13 (UTC) |
commit | 43bcb5d6caf7bf2e8a31b61b7284a7c9299b6fd7 (patch) (unidiff) | |
tree | 020698c057a9193c9547415a65defe004534ab89 /libopie/big-screen/osplitter.cpp | |
parent | 2f7bf038add502d20ab4c4e7faadba72e03d68fd (diff) | |
download | opie-43bcb5d6caf7bf2e8a31b61b7284a7c9299b6fd7.zip opie-43bcb5d6caf7bf2e8a31b61b7284a7c9299b6fd7.tar.gz opie-43bcb5d6caf7bf2e8a31b61b7284a7c9299b6fd7.tar.bz2 |
Add IDEAS for Opie bigscreen extensions
and the first sketch of the OSplitter please take a look
and comment
Diffstat (limited to 'libopie/big-screen/osplitter.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | libopie/big-screen/osplitter.cpp | 213 |
1 files changed, 213 insertions, 0 deletions
diff --git a/libopie/big-screen/osplitter.cpp b/libopie/big-screen/osplitter.cpp new file mode 100644 index 0000000..dcb5cc5 --- a/dev/null +++ b/libopie/big-screen/osplitter.cpp | |||
@@ -0,0 +1,213 @@ | |||
1 | /* | ||
2 | =. This file is part of the OPIE Project | ||
3 | .=l. Copyright (c) 2002 hOlgAr <zecke@handhelds.org> | ||
4 | .>+-= | ||
5 | _;:, .> :=|. This library is free software; you can | ||
6 | .> <`_, > . <= redistribute it and/or modify it under | ||
7 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | ||
8 | .="- .-=="i, .._ License as published by the Free Software | ||
9 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
10 | ._= =} : or (at your option) any later version. | ||
11 | .%`+i> _;_. | ||
12 | .i_,=:_. -<s. This library is distributed in the hope that | ||
13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
14 | : .. .:, . . . without even the implied warranty of | ||
15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | ||
17 | ..}^=.= = ; Library General Public License for more | ||
18 | ++= -. .` .: details. | ||
19 | : = ...= . :.=- | ||
20 | -. .:....=;==+<; You should have received a copy of the GNU | ||
21 | -_. . . )=. = Library General Public License along with | ||
22 | -- :-=` this library; see the file COPYING.LIB. | ||
23 | If not, write to the Free Software Foundation, | ||
24 | Inc., 59 Temple Place - Suite 330, | ||
25 | Boston, MA 02111-1307, USA. | ||
26 | |||
27 | */ | ||
28 | |||
29 | #include <qvaluelist.h> | ||
30 | #include <qvbox.h> | ||
31 | |||
32 | #include <opie/otabwidget.h> | ||
33 | |||
34 | #include "osplitter.h" | ||
35 | |||
36 | |||
37 | struct OSplitterContainer { | ||
38 | QWidget* widget; | ||
39 | const QString& icon | ||
40 | const QString& name; | ||
41 | }; | ||
42 | |||
43 | |||
44 | /** | ||
45 | * | ||
46 | * This is the constructor of OSplitter | ||
47 | * You might want to call setSizeChange to tell | ||
48 | * OSplitter to change its layout when a specefic | ||
49 | * mark was crossed. OSplitter sets a default value. | ||
50 | * | ||
51 | * You cann add widget with addWidget to the OSplitter. | ||
52 | * | ||
53 | * @param orient The orientation wether to layout horizontal or vertical | ||
54 | * @param parent The parent of this widget | ||
55 | * @param name The name passed on to QObject | ||
56 | * @param fl Additional widgets flags passed to QWidget | ||
57 | * | ||
58 | * @short single c'tor of the OSplitter | ||
59 | */ | ||
60 | OSplitter::OSplitter( Orientation orient, QWidget* parent, const char* name, WFlags fl ) | ||
61 | : QWidget( parent, name, fl ) | ||
62 | { | ||
63 | m_orient = orient; | ||
64 | m_hbox = 0; | ||
65 | m_tabWidget = 0; | ||
66 | m_size_policy = 330; | ||
67 | } | ||
68 | |||
69 | |||
70 | /** | ||
71 | * Destructor destructs this object and cleans up. All child | ||
72 | * widgets will be deleted | ||
73 | * @see addWidget | ||
74 | */ | ||
75 | OSplitter::~OSplitter() { | ||
76 | delete m_hbox; | ||
77 | delete m_tabWidget; | ||
78 | } | ||
79 | |||
80 | |||
81 | /** | ||
82 | * This function sets the size change policy of the splitter. | ||
83 | * If this size marked is crossed the splitter will relayout. | ||
84 | * Note that depending on the set Orientation it'll either look | ||
85 | * at the width or height. | ||
86 | * | ||
87 | * @param width_height The mark that will be watched. Interpreted depending on the Orientation of the Splitter. | ||
88 | * @return void | ||
89 | */ | ||
90 | void OSplitter::setSizeChange( int width_height ) { | ||
91 | m_size_policy = width_height; | ||
92 | relayout(); | ||
93 | } | ||
94 | |||
95 | /** | ||
96 | * Adds a widget to the Splitter. The widgets gets inserted | ||
97 | * at the end of either the Box or TabWidget. | ||
98 | * Ownership gets transfered and the widgets gets reparented. | ||
99 | * Note: icon and label is only available on small screensizes | ||
100 | * if size is smaller than the mark | ||
101 | * Warning: No null checking of the widget is done. Only on debug | ||
102 | * a message will be outputtet | ||
103 | * | ||
104 | * @param wid The widget which will be added | ||
105 | * @param icon The icon of the possible Tab | ||
106 | * @param label The label of the possible Tab | ||
107 | */ | ||
108 | void OSplitter::addWidget( QWidget* wid, const QString& icon, const QString& label ) { | ||
109 | #ifdef DEBUG | ||
110 | if (!wid ) { | ||
111 | qWarning("Widget is not valid!"); | ||
112 | return; | ||
113 | } | ||
114 | #endif | ||
115 | OSplitterContainer cont; | ||
116 | cont.widget = wid; | ||
117 | cont.icon =icon; | ||
118 | cont.label = label; | ||
119 | |||
120 | m_container.append( cont ); | ||
121 | |||
122 | if (m_hbox ) | ||
123 | addToBox( cont ); | ||
124 | else | ||
125 | addToTab( cont ); | ||
126 | } | ||
127 | |||
128 | |||
129 | /** | ||
130 | * Removes the widget from the tab widgets. OSplitter drops ownership | ||
131 | * of this widget and the widget will be reparented to 0. | ||
132 | * The widget will not be deleted. | ||
133 | * | ||
134 | * @param w The widget to be removed | ||
135 | */ | ||
136 | void OSplitter::removeWidget( QWidget* w) { | ||
137 | /* if not widget nor parent or parent not any of my master childs return */ | ||
138 | if (!w && w->parent() && ( w->parent() != m_hbox || w->parent() != m_tabWidget ) ) | ||
139 | return; | ||
140 | |||
141 | /* only tab needs to be removed.. box recognizes it */ | ||
142 | if ( !m_hbox ) | ||
143 | removeFromTab( w ); | ||
144 | |||
145 | |||
146 | /* Find the widget, reparent it and remove it from our list */ | ||
147 | ContainerList::Iterator it; | ||
148 | for ( it = m_container.begin(); it != m_container.end(); ++it ) | ||
149 | if ( (*it).widget == w ) { | ||
150 | w.reparent( 0, w.getWFlags ); | ||
151 | it = m_container.remove( it ); | ||
152 | break; | ||
153 | } | ||
154 | |||
155 | |||
156 | } | ||
157 | |||
158 | |||
159 | /** | ||
160 | * This method will give focus to the widget. If in a tabwidget | ||
161 | * the tabbar will be changed | ||
162 | * | ||
163 | * @param w The widget which will be set the current one | ||
164 | */ | ||
165 | void OSplitter::setCurrentWidget( QWidget* w) { | ||
166 | if (m_tabWidget ) | ||
167 | m_tabWidget->setCurrentWidget( w ); | ||
168 | else | ||
169 | m_hbox->setFocus( w ); | ||
170 | |||
171 | } | ||
172 | |||
173 | /** | ||
174 | * This is an overloaded member function and only differs in the argument it takes. | ||
175 | * Searches list of widgets for label. It'll pick the first label it finds | ||
176 | * | ||
177 | * @param label Label to look for. First match will be taken | ||
178 | */ | ||
179 | void OSplitter::setCurrentWidget( const QString& label ) { | ||
180 | ContainerList::Iterator it; | ||
181 | for (it = m_container.begin(); it != m_container.end(); ++it ) { | ||
182 | if ( (*it).name == label ) { | ||
183 | setCurrentWidget( (*it).widget ); | ||
184 | break; | ||
185 | } | ||
186 | } | ||
187 | } | ||
188 | |||
189 | /** | ||
190 | * return the currently activated widget if in tab widget moud | ||
191 | * or null because all widgets are visible | ||
192 | */ | ||
193 | QWidget* OSplitter::currentWidget() { | ||
194 | if ( m_hbox ) | ||
195 | return 0l; | ||
196 | else | ||
197 | return m_tabWidget->currentWidget(); | ||
198 | } | ||
199 | |||
200 | |||
201 | /** | ||
202 | * @reimplented for internal reasons | ||
203 | * returns the sizeHint of one of its sub widgets | ||
204 | */ | ||
205 | QSize OSplitter::sizeHint()const { | ||
206 | } | ||
207 | |||
208 | /** | ||
209 | * @reimplemented for internal reasons | ||
210 | */ | ||
211 | void OSplitter::resizeEvent( QResizeEvent* res ) { | ||
212 | |||
213 | } | ||