OpenASIP  2.0
SocketContainerFigure.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 SocketContainerFigure.cc
26  *
27  * Definition of SocketContainerFigure 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 "SocketContainerFigure.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 child sockets.
55  *
56  * @param dc Device context.
57  */
58 void
60 
61  int unknownSocketX = location_.x + size_.GetWidth();
62 
63  // set locations for sockets not connected to any port
64 
65  vector<Figure*>::iterator i = children_.begin();
66  for(; i != children_.end(); i++) {
67 
68  if ((*i)->location().x == 0) {
69  (*i)->setX(unknownSocketX);
72  }
73 
74  (*i)->setY(location_.y);
75  if (size_.GetHeight() > (*i)->bounds().GetHeight()) {
76  (*i)->setHeight(size_.GetHeight());
77  }
78  (*i)->layout(dc);
79  (*i)->clearXSetFlag();
80  }
81 }
82 
83 /**
84  * Calculates and sets the width of the container.
85  *
86  * Depends on the amount and position of sockets.
87  */
88 void
90 
91  int maxIndex = 0;
92  int maxX = 0;
93 
94  for (unsigned int i = 0; i < children_.size(); i++) {
95  if (children_[i]->location().x > maxX) {
96  maxX = children_[i]->location().x;
97  maxIndex = i;
98  }
99  }
100 
101  int rightBound = maxX + children_[maxIndex]->bounds().GetWidth() +
103 
104  if (rightBound > location_.x + size_.GetWidth()) {
105  size_.SetWidth(rightBound - location_.x);
106  }
107 
108  if (children_[0]->bounds().GetHeight() > size_.GetHeight()) {
109  size_.SetHeight(children_[0]->bounds().GetHeight());
110  }
111 }
Figure::bounds
virtual wxRect bounds() const
SocketContainerFigure::~SocketContainerFigure
virtual ~SocketContainerFigure()
Definition: SocketContainerFigure.cc:50
SocketContainerFigure::layoutSelf
virtual void layoutSelf(wxDC *)
Definition: SocketContainerFigure.cc:89
MachineCanvasLayoutConstraints::SOCKET_SPACE
static const int SOCKET_SPACE
Space dividing unconnected sockets.
Definition: MachineCanvasLayoutConstraints.hh:63
Figure::children_
std::vector< Figure * > children_
Figure's children.
Definition: Figure.hh:90
MachineCanvasLayoutConstraints::SOCKET_WIDTH
static const int SOCKET_WIDTH
Width of a socket.
Definition: MachineCanvasLayoutConstraints.hh:59
Figure::location
wxPoint location() const
Figure::size_
wxSize size_
wxSize of the Figure's bounding rectangle.
Definition: Figure.hh:86
Figure
Definition: Figure.hh:50
Figure::location_
wxPoint location_
Top-left location of the Figure's bounding rectangle.
Definition: Figure.hh:84
SocketContainerFigure.hh
SocketContainerFigure::layoutChildren
virtual void layoutChildren(wxDC *)
Definition: SocketContainerFigure.cc:59
MachineCanvasLayoutConstraints.hh
SocketContainerFigure::SocketContainerFigure
SocketContainerFigure()
Definition: SocketContainerFigure.cc:44