1 /*
2  * Copyright (C) 2004 Ivo Danihelka (ivo@danihelka.net)
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 "WiContainer.h"
10 
11 //-----------------------------------------------------------------
12 /**
13  * Create new container around given widget.
14  * @param new_content subwidget inside
15  * @param border border around subwidget
16  */
WiContainer(IWidget * new_content,int border)17 WiContainer::WiContainer(IWidget *new_content, int border)
18 {
19     m_content = new_content;
20     m_border = border;
21 }
22 //-----------------------------------------------------------------
23 /**
24  * Release subwidget.
25  */
~WiContainer()26 WiContainer::~WiContainer()
27 {
28     delete m_content;
29 }
30 //-----------------------------------------------------------------
31 int
getW() const32 WiContainer::getW() const
33 {
34     return 2 * m_border + m_content->getW();
35 }
36 //-----------------------------------------------------------------
37 int
getH() const38 WiContainer::getH() const
39 {
40     return 2 * m_border + m_content->getH();
41 }
42 //-----------------------------------------------------------------
43 void
setShift(const V2 & shift)44 WiContainer::setShift(const V2 &shift)
45 {
46     m_shift = shift;
47     m_content->setShift(m_shift.plus(V2(m_border, m_border)));
48 }
49 //-----------------------------------------------------------------
50 /**
51  * Let subwidget to draw.
52  */
53 void
drawOn(SDL_Surface * screen)54 WiContainer::drawOn(SDL_Surface *screen)
55 {
56     m_content->drawOn(screen);
57 }
58 //-----------------------------------------------------------------
59 /**
60  * Default action is to propagate mouse press to subwidget.
61  */
62     void
own_mouseButton(const MouseStroke & stroke)63 WiContainer::own_mouseButton(const MouseStroke &stroke)
64 {
65     m_content->mouseButton(stroke);
66 }
67 
68