| 1 |
/* |
| 2 |
* Copyright (C) 2004 Ivo Danihelka ([email protected]) |
| 3 |
* |
| 4 |
* This program is free software; you can redistribute it and/or modify |
| 5 |
* it under the terms of the GNU General Public License as published by |
| 6 |
* the Free Software Foundation; either version 2 of the License, or |
| 7 |
* (at your option) any later version. |
| 8 |
*/ |
| 9 |
#include "HBox.h" |
| 10 |
|
| 11 |
#include "minmax.h" |
| 12 |
|
| 13 |
//----------------------------------------------------------------- |
| 14 |
/** |
| 15 |
* Starts as empty box. |
| 16 |
*/ |
| 17 |
HBox::HBox() |
| 18 |
{ |
| 19 |
m_w = 0; |
| 20 |
m_h = 0; |
| 21 |
} |
| 22 |
//----------------------------------------------------------------- |
| 23 |
/** |
| 24 |
* Place widget to the most right place. |
| 25 |
*/ |
| 26 |
void |
| 27 |
HBox::addWidget(IWidget *new_widget) |
| 28 |
{ |
| 29 |
m_widgets.push_back(new_widget); |
| 30 |
new_widget->setShift(m_shift.plus(V2(m_w, 0))); |
| 31 |
m_w += new_widget->getW(); |
| 32 |
m_h = max(m_h, new_widget->getH()); |
| 33 |
} |
| 34 |
//----------------------------------------------------------------- |
| 35 |
/** |
| 36 |
* Update shift for all subwidgets. |
| 37 |
*/ |
| 38 |
void |
| 39 |
HBox::setShift(const V2 &shift) |
| 40 |
{ |
| 41 |
m_shift = shift; |
| 42 |
int width = 0; |
| 43 |
t_widgets::iterator end = m_widgets.end(); |
| 44 |
for (t_widgets::iterator i = m_widgets.begin(); i != end; ++i) { |
| 45 |
(*i)->setShift(m_shift.plus(V2(width, 0))); |
| 46 |
width += (*i)->getW(); |
| 47 |
} |
| 48 |
} |
| 49 |
|
| 50 |
|