39 m_activeDockArea(true),
45 m_highlightColor(0xc80000)
91 setLayout(Container::Horizontal);
103 setLayout(Container::Vertical);
115 setLayout(Container::Horizontal);
127 setLayout(Container::Vertical);
168 Widget* placeBefore = NULL;
169 Widget* placeAfter = NULL;
171 Rectangle dim = widget->getDimension();
172 widget->getAbsolutePosition(dim.x, dim.y);
173 std::list<Widget*>::const_iterator currChild(mChildren.begin());
174 std::list<Widget*>::const_iterator endChildren(mChildren.end());
175 for(; currChild != endChildren; ++currChild) {
176 if (!(*currChild)->isVisible() || (*currChild) == widget) {
179 Rectangle childDim = (*currChild)->getDimension();
180 (*currChild)->getAbsolutePosition(childDim.x, childDim.y);
181 if (childDim.isIntersecting(dim)) {
182 if (getLayout() == Container::Horizontal) {
183 if (dim.x < childDim.x) {
184 if (dim.x + dim.width <= childDim.x + childDim.width / 2) {
185 placeBefore = *currChild;
187 placeAfter = *currChild;
189 }
else if (dim.x >= childDim.x) {
190 if (dim.x <= childDim.x + childDim.width / 2) {
191 placeBefore = *currChild;
193 placeAfter = *currChild;
197 if (getLayout() == Container::Vertical) {
198 if (dim.y < childDim.y) {
199 if (dim.y + dim.height <= childDim.y + childDim.height / 2) {
200 placeBefore = *currChild;
202 placeAfter = *currChild;
204 }
else if (dim.y >= childDim.y) {
205 if (dim.y <= childDim.y + childDim.height / 2) {
206 placeBefore = *currChild;
208 placeAfter = *currChild;
214 if (placeBefore || placeAfter) {
215 mChildren.remove(widget);
217 std::list<Widget*>::iterator it = std::find(mChildren.begin(), mChildren.end(), placeBefore);
218 mChildren.insert(it, widget);
220 std::list<Widget*>::iterator it = std::find(mChildren.begin(), mChildren.end(), placeAfter);
222 mChildren.insert(it, widget);
229 Widget* parent = getParent();
235 std::list<Widget*> widgets = parent->getWidgetsIn(parent->getChildrenArea());
236 std::list<Widget*>::iterator it = widgets.begin();
237 for (; it != widgets.end(); ++it) {
256 if (top->getY() + top->getHeight() >= right->getY() || top->getY() + top->getHeight() + 1 < right->getY()) {
257 int32_t newY = top->getY() + top->getHeight() + 1;
258 int32_t diff = newY - right->getY();
260 right->setHeight(right->getHeight() + diff);
264 if (top->getY() + top->getHeight() >= left->getY() || top->getY() + top->getHeight() + 1 < left->getY()) {
265 int32_t newY = top->getY() + top->getHeight() + 1;
266 int32_t diff = newY - left->getY();
268 left->setHeight(left->getHeight() + diff);
272 if (top->getY() + top->getHeight() >= bottom->getY()) {
273 int32_t newY = top->getY() + top->getHeight() + 1;
274 int32_t diff = newY - bottom->getY();
276 bottom->setHeight(bottom->getHeight() + diff);
283 if (right->getY() + right->getHeight() >= bottom->getY() || right->getY() + right->getHeight() + 1 < bottom->getY()) {
284 Size min = right->getMinSize();
286 right->setMinSize(tmp);
287 int32_t diff = bottom->getY() - (right->getY() + right->getHeight() + 1);
288 right->setHeight(right->getHeight() + diff);
289 right->setMinSize(min);
293 if (left->getY() + left->getHeight() >= bottom->getY() || left->getY() + left->getHeight() + 1 < bottom->getY()) {
294 Size min = left->getMinSize();
296 left->setMinSize(tmp);
297 int32_t diff = bottom->getY() - (left->getY() + left->getHeight() + 1);
298 left->setHeight(left->getHeight() + diff);
299 left->setMinSize(min);
307 Widget* parent = getParent();
311 Rectangle childArea = parent->getChildrenArea();
312 Rectangle childDim = getDimension();
313 if (childDim.x < childArea.x) {
316 if (childDim.y < childArea.y) {
321 if ((childDim.y + childDim.height) > childArea.height) {
322 setHeight(childArea.height - childDim.y);
325 if ((childDim.x + childDim.width) > childArea.width) {
326 if (childDim.width > childArea.width) {
328 setWidth(childArea.width);
330 setX(childArea.width - childDim.width);
334 if ((childDim.y + childDim.height) > childArea.height) {
335 if (childDim.height > childArea.height) {
337 setHeight(childArea.height);
339 setY(childArea.height - childDim.height);
343 if ((childDim.x + childDim.width) > childArea.width) {
344 setWidth(childArea.width - childDim.x);
350 ResizableWindow::add(widget);
351 int32_t x = widget->getX();
352 int32_t y = widget->getY();
354 widget->setPosition(x, y);
360 ResizableWindow::remove(widget);
365 Rectangle oldDimension = getDimension();
369 Window::resizeToContent(recursiv);
372 int32_t wDiff = oldDimension.width - getWidth();
373 setX(oldDimension.x + wDiff);
375 int32_t hDiff = oldDimension.height - getHeight();
376 setY(oldDimension.y + hDiff);
382 Rectangle oldDimension = getDimension();
384 ResizableWindow::expandContent(recursiv);
386 Window::expandContent(recursiv);
389 int32_t wDiff = oldDimension.width - getWidth();
390 setX(oldDimension.x + wDiff);
392 int32_t hDiff = oldDimension.height - getHeight();
393 setY(oldDimension.y + hDiff);
virtual void mouseEntered(MouseEvent &mouseEvent)
virtual void mouseExited(MouseEvent &mouseEvent)
virtual void mousePressed(MouseEvent &mouseEvent)
virtual void mouseExited(MouseEvent &mouseEvent)
virtual void mouseReleased(MouseEvent &mouseEvent)
void setHighlighted(bool highlighted)
virtual void mouseMoved(MouseEvent &mouseEvent)
void setHighlightColor(const Color &color)
Sets the highlight color of the widget.
void setBottomResizable(bool resizable)
Sets if the widget is resizable at bottom.
void repositionDockAreas()
void setTopSide(bool side)
virtual void mouseDragged(MouseEvent &mouseEvent)
virtual void resizeToContent(bool recursiv=true)
void setLeftSide(bool side)
virtual void mouseMoved(MouseEvent &mouseEvent)
virtual void add(Widget *widget)
virtual void resizeToContent(bool recursiv=true)
bool isBottomSide() const
bool isActiveDockArea() const
void setTopResizable(bool resizable)
Sets if the widget is resizable at top.
virtual void remove(Widget *widget)
bool isHighlighted() const
void setLeftResizable(bool resizable)
Sets if the widget is resizable at left.
virtual void mouseReleased(MouseEvent &mouseEvent)
void setBottomSide(bool side)
void undockWidget(Widget *widget)
void repositionWidget(Widget *widget)
void setRightSide(bool side)
virtual void mouseDragged(MouseEvent &mouseEvent)
virtual void mousePressed(MouseEvent &mouseEvent)
const Color & getHighlightColor() const
Gets the highlight color.
virtual void mouseEntered(MouseEvent &mouseEvent)
void setActiveDockArea(bool active)
void setRightResizable(bool resizable)
Sets if the widget is resizable at right.
virtual void expandContent(bool recursiv=true)
void dockWidget(Widget *widget)