1// Aseprite UI Library
2// Copyright (C) 2001-2013, 2015 David Capello
3//
4// This file is released under the terms of the MIT license.
5// Read LICENSE.txt for more information.
6
7#ifdef HAVE_CONFIG_H
8#include "config.h"
9#endif
10
11#include "ui/size_hint_event.h"
12#include "ui/widget.h"
13
14namespace ui {
15
16using namespace gfx;
17
18/**
19 Event generated to calculate the preferred size of a widget.
20
21 @param source
22 The widget that want to know its preferred size.
23
24 @param fitIn
25 This could be Size(0, 0) that means calculate the preferred size
26 without restrictions. If its width or height is greater than 0,
27 you could try to fit your widget to that width or height.
28*/
29SizeHintEvent::SizeHintEvent(Widget* source, const Size& fitIn)
30 : Event(source)
31 , m_fitIn(fitIn)
32 , m_sizeHint(0, 0)
33{
34}
35
36/**
37 Destroys the SizeHintEvent.
38*/
39SizeHintEvent::~SizeHintEvent()
40{
41}
42
43Size SizeHintEvent::fitInSize() const
44{
45 return m_fitIn;
46}
47
48int SizeHintEvent::fitInWidth() const
49{
50 return m_fitIn.w;
51}
52
53int SizeHintEvent::fitInHeight() const
54{
55 return m_fitIn.h;
56}
57
58Size SizeHintEvent::sizeHint() const
59{
60 return m_sizeHint;
61}
62
63void SizeHintEvent::setSizeHint(const Size& sz)
64{
65 m_sizeHint = sz;
66}
67
68/**
69 Sets the preferred size for the widget.
70*/
71void SizeHintEvent::setSizeHint(int w, int h)
72{
73 m_sizeHint.w = w;
74 m_sizeHint.h = h;
75}
76
77} // namespace ui
78