aboutsummaryrefslogtreecommitdiff
path: root/src/Container.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/Container.cc')
-rw-r--r--src/Container.cc63
1 files changed, 46 insertions, 17 deletions
diff --git a/src/Container.cc b/src/Container.cc
index d3072a6..b6bc5b8 100644
--- a/src/Container.cc
+++ b/src/Container.cc
@@ -20,7 +20,7 @@
20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21// DEALINGS IN THE SOFTWARE. 21// DEALINGS IN THE SOFTWARE.
22 22
23// $Id: Container.cc,v 1.8 2003/12/07 15:45:28 fluxgen Exp $ 23// $Id: Container.cc,v 1.9 2003/12/12 14:35:34 fluxgen Exp $
24 24
25#include "Container.hh" 25#include "Container.hh"
26 26
@@ -28,7 +28,10 @@
28#include "FbTk/EventManager.hh" 28#include "FbTk/EventManager.hh"
29 29
30Container::Container(const FbTk::FbWindow &parent): 30Container::Container(const FbTk::FbWindow &parent):
31 FbTk::FbWindow(parent, 0, 0, 1, 1, ExposureMask), m_selected(0), 31 FbTk::FbWindow(parent, 0, 0, 1, 1, ExposureMask),
32 m_align(RELATIVE),
33 m_max_size_per_client(60),
34 m_selected(0),
32 m_update_lock(false) { 35 m_update_lock(false) {
33 FbTk::EventManager::instance()->add(*this, *this); 36 FbTk::EventManager::instance()->add(*this, *this);
34} 37}
@@ -161,6 +164,14 @@ void Container::setSelected(int pos) {
161 164
162} 165}
163 166
167void Container::setMaxSizePerClient(unsigned int size) {
168 m_max_size_per_client = size;
169}
170
171void Container::setAlignment(Container::Alignment a) {
172 m_align = a;
173}
174
164void Container::exposeEvent(XExposeEvent &event) { 175void Container::exposeEvent(XExposeEvent &event) {
165 if (!m_update_lock) 176 if (!m_update_lock)
166 clearArea(event.x, event.y, event.width, event.height); 177 clearArea(event.x, event.y, event.width, event.height);
@@ -182,15 +193,21 @@ void Container::repositionItems() {
182 193
183 int next_x = -borderW; // zero so the border of the first shows 194 int next_x = -borderW; // zero so the border of the first shows
184 int extra = 0; 195 int extra = 0;
185 for (; it != it_end; ++it, next_x += max_width_per_client + borderW + extra) { 196 int direction = 1;
197 if (alignment() == RIGHT) {
198 direction = -1;
199 next_x = width() - max_width_per_client + borderW;
200 }
201
202 for (; it != it_end; ++it, next_x += direction*(max_width_per_client + borderW + extra)) {
186 //!! TODO: check this more carefully, seems like error doesn't work with even numbers 203 //!! TODO: check this more carefully, seems like error doesn't work with even numbers
187 /* 204 /*
188 if (rounding_error != 0) { 205 if (rounding_error != 0) {
189 --rounding_error; 206 --rounding_error;
190 extra = 0; 207 extra = 0;
191 } else { 208 } else {
192 extra = 0; 209 extra = 0;
193 } 210 }
194 */ 211 */
195 // resize each clients including border in size 212 // resize each clients including border in size
196 (*it)->moveResize(next_x, 213 (*it)->moveResize(next_x,
@@ -199,17 +216,29 @@ void Container::repositionItems() {
199 height()); 216 height());
200 (*it)->clear(); 217 (*it)->clear();
201 } 218 }
219
202} 220}
203 221
204 222
205unsigned int Container::maxWidthPerClient() const { 223unsigned int Container::maxWidthPerClient() const {
206 int count = size(); 224 switch (alignment()) {
207 if (count == 0) 225 case RIGHT:
208 return width(); 226 case LEFT:
209 else { 227 return m_max_size_per_client;
210 int borderW = m_item_list.front()->borderWidth(); 228 break;
211 // there're count-1 borders to fit in with the windows 229 case RELATIVE:
212 // -> 1 per window plus end 230 int count = size();
213 return (width() - (count - 1) * borderW) / count; 231 if (count == 0)
232 return width();
233 else {
234 int borderW = m_item_list.front()->borderWidth();
235 // there're count-1 borders to fit in with the windows
236 // -> 1 per window plus end
237 return (width() - (count - 1) * borderW) / count;
238 }
239 break;
214 } 240 }
241
242 // this will never happen anyway
243 return 1;
215} 244}