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 "WiContainer.h" 00010 00011 //----------------------------------------------------------------- 00012 /** 00013 * Create new container around given widget. 00014 * @param new_content subwidget inside 00015 * @param border border around subwidget 00016 */ 00017 WiContainer::WiContainer(IWidget *new_content, int border) 00018 { 00019 m_content = new_content; 00020 m_border = border; 00021 } 00022 //----------------------------------------------------------------- 00023 /** 00024 * Release subwidget. 00025 */ 00026 WiContainer::~WiContainer() 00027 { 00028 delete m_content; 00029 } 00030 //----------------------------------------------------------------- 00031 int 00032 WiContainer::getW() const 00033 { 00034 return 2 * m_border + m_content->getW(); 00035 } 00036 //----------------------------------------------------------------- 00037 int 00038 WiContainer::getH() const 00039 { 00040 return 2 * m_border + m_content->getH(); 00041 } 00042 //----------------------------------------------------------------- 00043 void 00044 WiContainer::setShift(const V2 &shift) 00045 { 00046 m_shift = shift; 00047 m_content->setShift(m_shift.plus(V2(m_border, m_border))); 00048 } 00049 //----------------------------------------------------------------- 00050 /** 00051 * Let subwidget to draw. 00052 */ 00053 void 00054 WiContainer::drawOn(SDL_Surface *screen) 00055 { 00056 m_content->drawOn(screen); 00057 } 00058 //----------------------------------------------------------------- 00059 /** 00060 * Default action is to propagate mouse press to subwidget. 00061 */ 00062 void 00063 WiContainer::own_mouseButton(const MouseStroke &stroke) 00064 { 00065 m_content->mouseButton(stroke); 00066 } 00067