Main Page | Class Hierarchy | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

VBox.cpp

Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2004 Ivo Danihelka (ivo@danihelka.net)
00003  *
00004  * This program is free software; you can redistribute it and/or modify
00005  * it under the terms of the GNU General Public License as published by
00006  * the Free Software Foundation; either version 2 of the License, or
00007  * (at your option) any later version.
00008  */
00009 #include "VBox.h"
00010 
00011 #include "minmax.h"
00012 
00013 //-----------------------------------------------------------------
00014 /**
00015  * Starts as empty box.
00016  */
00017 VBox::VBox()
00018 {
00019     m_w = 0;
00020     m_h = 0;
00021     m_centered = false;
00022 }
00023 //-----------------------------------------------------------------
00024 /**
00025  * Place widget to the lowest vertical place.
00026  */
00027 void
00028 VBox::addWidget(IWidget *new_widget)
00029 {
00030     m_widgets.push_back(new_widget);
00031     m_w = max(m_w, new_widget->getW());
00032     int shiftX = 0;
00033     if (m_centered) {
00034         shiftX = (m_w - new_widget->getW()) / 2;
00035     }
00036     new_widget->setShift(m_shift.plus(V2(shiftX, m_h)));
00037     m_h += new_widget->getH();
00038 }
00039 //-----------------------------------------------------------------
00040 /**
00041  * Update shift for all subwidgets.
00042  */
00043 void
00044 VBox::setShift(const V2 &shift)
00045 {
00046     m_shift = shift;
00047     int height = 0;
00048     t_widgets::iterator end = m_widgets.end();
00049     for (t_widgets::iterator i = m_widgets.begin(); i != end; ++i) {
00050         int shiftX = 0;
00051         if (m_centered) {
00052             shiftX = (m_w - (*i)->getW()) / 2;
00053         }
00054         (*i)->setShift(m_shift.plus(V2(shiftX, height)));
00055         height += (*i)->getH();
00056     }
00057 }
00058 
00059 

Generated on Wed Jun 1 09:54:32 2005 for Fish Fillets - Next Generation by  doxygen 1.4.2