OpenASIP  2.0
UnitContainerFigure.cc
Go to the documentation of this file.
1 /*
2  Copyright (c) 2002-2009 Tampere University.
3 
4  This file is part of TTA-Based Codesign Environment (TCE).
5 
6  Permission is hereby granted, free of charge, to any person obtaining a
7  copy of this software and associated documentation files (the "Software"),
8  to deal in the Software without restriction, including without limitation
9  the rights to use, copy, modify, merge, publish, distribute, sublicense,
10  and/or sell copies of the Software, and to permit persons to whom the
11  Software is furnished to do so, subject to the following conditions:
12 
13  The above copyright notice and this permission notice shall be included in
14  all copies or substantial portions of the Software.
15 
16  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22  DEALINGS IN THE SOFTWARE.
23  */
24 /**
25  * @file UnitContainerFigure.cc
26  *
27  * Definition of UnitContainerFigure class.
28  *
29  * @author Ari Metsähalme 2003 (ari.metsahalme-no.spam-tut.fi)
30  * @note rating: yellow
31  * @note reviewed Jul 22 2004 by tr, ml, jm, am
32  */
33 
34 #include <vector>
35 
36 #include "UnitContainerFigure.hh"
38 
39 using std::vector;
40 
41 /**
42  * The Constructor.
43  */
45 }
46 
47 /**
48  * The Destructor.
49  */
51 }
52 
53 /**
54  * Lays out the units in a row, spaced evenly.
55  *
56  * @param dc Device context.
57  */
58 void
60 
61  int unitX = location_.x;
62  int unitY = location_.y;
63 
64  for(unsigned int i = 0; i < children_.size(); i++) {
65 
66  if (!children_[i]->xSet()) {
67  children_[i]->setLocation(wxPoint(unitX, unitY));
68  children_[i]->layout(dc);
69  unitX += children_[i]->bounds().GetWidth() +
71 
72  } else {
73  children_[i]->layout(dc);
74  unitX = children_[i]->location().x +
75  children_[i]->bounds().GetWidth() +
77  }
78  }
79 }
80 
81 /**
82  * Calculates and sets the size of the container.
83  *
84  * Depends on the amount and position of the units.
85  */
86 void
88 
89  int maxIndex = 0;
90  int maxX = 0;
91 
92  for (unsigned int i = 0; i < children_.size(); i++) {
93  if (children_[i]->location().x > maxX) {
94  maxX = children_[i]->location().x;
95  maxIndex = i;
96  }
97  }
98 
99  int width = maxX + children_[maxIndex]->bounds().GetWidth() -
100  location_.x;
101 
102  if (width > size_.GetWidth()) {
103  size_.SetWidth(width);
104  }
105 
106  if (size_.GetHeight() == 0) {
107  size_.SetHeight(children_[0]->bounds().GetHeight());
108  }
109 }
UnitContainerFigure::UnitContainerFigure
UnitContainerFigure()
Definition: UnitContainerFigure.cc:44
Figure::bounds
virtual wxRect bounds() const
UnitContainerFigure.hh
Figure::children_
std::vector< Figure * > children_
Figure's children.
Definition: Figure.hh:90
Figure::location
wxPoint location() const
Figure::size_
wxSize size_
wxSize of the Figure's bounding rectangle.
Definition: Figure.hh:86
UnitContainerFigure::~UnitContainerFigure
virtual ~UnitContainerFigure()
Definition: UnitContainerFigure.cc:50
Figure
Definition: Figure.hh:50
UnitContainerFigure::layoutChildren
virtual void layoutChildren(wxDC *)
Definition: UnitContainerFigure.cc:59
Figure::location_
wxPoint location_
Top-left location of the Figure's bounding rectangle.
Definition: Figure.hh:84
Figure::xSet
bool xSet() const
MachineCanvasLayoutConstraints.hh
UnitContainerFigure::layoutSelf
virtual void layoutSelf(wxDC *)
Definition: UnitContainerFigure.cc:87
MachineCanvasLayoutConstraints::UNIT_SPACE
static const int UNIT_SPACE
Space between units.
Definition: MachineCanvasLayoutConstraints.hh:47