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

HBox.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 "HBox.h"
00010 
00011 #include "minmax.h"
00012 
00013 //-----------------------------------------------------------------
00014 /**
00015  * Starts as empty box.
00016  */
00017 HBox::HBox()
00018 {
00019     m_w = 0;
00020     m_h = 0;
00021 }
00022 //-----------------------------------------------------------------
00023 /**
00024  * Place widget to the most right place.
00025  */
00026 void
00027 HBox::addWidget(IWidget *new_widget)
00028 {
00029     m_widgets.push_back(new_widget);
00030     new_widget->setShift(m_shift.plus(V2(m_w, 0)));
00031     m_w += new_widget->getW();
00032     m_h = max(m_h, new_widget->getH());
00033 }
00034 //-----------------------------------------------------------------
00035 /**
00036  * Update shift for all subwidgets.
00037  */
00038 void
00039 HBox::setShift(const V2 &shift)
00040 {
00041     m_shift = shift;
00042     int width = 0;
00043     t_widgets::iterator end = m_widgets.end();
00044     for (t_widgets::iterator i = m_widgets.begin(); i != end; ++i) {
00045         (*i)->setShift(m_shift.plus(V2(width, 0)));
00046         width += (*i)->getW();
00047     }
00048 }
00049 
00050 

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