void wxSizerItem::SetDimension( wxPoint pos, wxSize size )
{
- m_pos = pos;
-
- if (m_flag & wxWEST)
- {
- pos.x += m_border;
- size.x -= m_border;
- }
- if (m_flag & wxEAST)
- {
- size.x -= m_border;
- }
- if (m_flag & wxNORTH)
- {
- pos.y += m_border;
- size.y -= m_border;
- }
- if (m_flag & wxSOUTH)
+ if (m_flag & wxSHAPED)
{
- size.y -= m_border;
- }
- if (m_flag & wxSHAPED) {
// adjust aspect ratio
int rwidth = (int) (size.y * m_ratio);
- if (rwidth > size.x) {
+ if (rwidth > size.x)
+ {
// fit horizontally
int rheight = (int) (size.x / m_ratio);
// add vertical space
pos.y += (size.y - rheight);
// use reduced dimensions
size.y =rheight;
- } else if (rwidth < size.x) {
+ }
+ else if (rwidth < size.x)
+ {
// add horizontal space
if (m_flag & wxALIGN_CENTER_HORIZONTAL)
pos.x += (size.x - rwidth) / 2;
size.x = rwidth;
}
}
+
+ // This is what GetPosition() returns. Since we calculate
+ // borders afterwards, GetPosition() will be the left/top
+ // corner of the surrounding border.
+ m_pos = pos;
+
+ if (m_flag & wxWEST)
+ {
+ pos.x += m_border;
+ size.x -= m_border;
+ }
+ if (m_flag & wxEAST)
+ {
+ size.x -= m_border;
+ }
+ if (m_flag & wxNORTH)
+ {
+ pos.y += m_border;
+ size.y -= m_border;
+ }
+ if (m_flag & wxSOUTH)
+ {
+ size.y -= m_border;
+ }
if (IsSizer())
m_sizer->SetDimension( pos.x, pos.y, size.x, size.y );
//---------------------------------------------------------------------------
wxStaticBoxSizer::wxStaticBoxSizer( wxStaticBox *box, int orient )
- : wxBoxSizer( orient )
+ : wxBoxSizer( orient )
{
wxASSERT_MSG( box, wxT("wxStaticBoxSizer needs a static box") );
m_staticBox = box;
}
+static void GetStaticBoxBorders(wxStaticBox *box,
+ int *borderTop, int *borderOther)
+{
+ // this has to be done platform by platform as there is no way to
+ // guess the thickness of a wxStaticBox border
+#ifdef __WXGTK__
+ if ( box->GetLabel().IsEmpty() )
+ *borderTop = 5;
+ else
+#endif // __WXGTK__
+ *borderTop = 15;
+
+ *borderOther = 5;
+}
+
void wxStaticBoxSizer::RecalcSizes()
{
- // this will have to be done platform by platform
- // as there is no way to guess the thickness of
- // a wxStaticBox border
- int top_border = 15;
- if (m_staticBox->GetLabel().IsEmpty()) top_border = 5;
- int other_border = 5;
+ int top_border, other_border;
+ GetStaticBoxBorders(m_staticBox, &top_border, &other_border);
m_staticBox->SetSize( m_position.x, m_position.y, m_size.x, m_size.y );
wxSize wxStaticBoxSizer::CalcMin()
{
- // This will have to be done platform by platform
- // as there is no way to guess the thickness of
- // a wxStaticBox border.
-
- int top_border = 15;
- if (m_staticBox->GetLabel().IsEmpty()) top_border = 5;
- int other_border = 5;
+ int top_border, other_border;
+ GetStaticBoxBorders(m_staticBox, &top_border, &other_border);
wxSize ret( wxBoxSizer::CalcMin() );
ret.x += 2*other_border;