4 XCSoar Glide Computer - http://www.xcsoar.org/
5 Copyright (C) 2000-2013 The XCSoar Project
6 A detailed list of copyright holders can be found in the file "AUTHORS".
8 This program is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License
10 as published by the Free Software Foundation; either version 2
11 of the License, or (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 #include "ButtonPanelWidget.hpp"
25 #include "Form/ButtonPanel.hpp"
26 #include "Screen/Layout.hpp"
27 #include "UIGlobals.hpp"
31 ButtonPanelWidget::~ButtonPanelWidget()
38 ButtonPanelWidget::UpdateLayout(const PixelRect
&rc
)
40 assert(buttons
!= nullptr);
44 return buttons
->UpdateLayout(rc
);
47 return buttons
->LeftLayout(rc
);
49 case Alignment::BOTTOM
:
50 return buttons
->BottomLayout(rc
);
57 ButtonPanelWidget::GetMinimumSize() const
59 PixelSize size
= widget
->GetMinimumSize();
61 size
.cy
+= Layout::GetMinimumControlHeight();
66 ButtonPanelWidget::GetMaximumSize() const
68 PixelSize size
= widget
->GetMaximumSize();
70 size
.cy
+= Layout::GetMaximumControlHeight();
75 ButtonPanelWidget::Initialise(ContainerWindow
&parent
, const PixelRect
&rc
)
77 assert(buttons
== nullptr);
79 buttons
= new ButtonPanel(parent
, UIGlobals::GetDialogLook());
80 buttons
->SetDefaultHidden();
82 /* initialise with full dimensions for now, buttons will be added
84 widget
->Initialise(parent
, rc
);
88 ButtonPanelWidget::Prepare(ContainerWindow
&parent
, const PixelRect
&rc
)
90 assert(buttons
!= nullptr);
92 /* initialise with full dimensions for now, buttons may be added
93 during this call, and the final layout will be set by Show() */
94 widget
->Prepare(parent
, rc
);
98 ButtonPanelWidget::Unprepare()
100 assert(buttons
!= nullptr);
104 ButtonPanelWidget::Save(bool &changed
)
106 return widget
->Save(changed
);
110 ButtonPanelWidget::Click()
112 return widget
->Click();
116 ButtonPanelWidget::ReClick()
118 assert(buttons
!= nullptr);
124 ButtonPanelWidget::Show(const PixelRect
&rc
)
126 assert(buttons
!= nullptr);
128 widget
->Show(UpdateLayout(rc
));
133 ButtonPanelWidget::Leave()
135 return widget
->Leave();
139 ButtonPanelWidget::Hide()
146 ButtonPanelWidget::Move(const PixelRect
&rc
)
148 widget
->Move(UpdateLayout(rc
));
152 ButtonPanelWidget::SetFocus()
154 return widget
->SetFocus();