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 );
{
wxSizerItem *item = (wxSizerItem*) node->Data();
- int weight = 1;
- if (item->GetOption())
- weight = item->GetOption();
-
+ m_stretchable += item->GetOption();
+
wxSize size( item->CalcMin() );
if (m_orient == wxHORIZONTAL)
{
- m_minWidth += (size.x * weight);
+ m_minWidth += size.x;
m_minHeight = wxMax( m_minHeight, size.y );
}
else
{
- m_minHeight += (size.y * weight);
+ m_minHeight += size.y;
m_minWidth = wxMax( m_minWidth, size.x );
}
- if (item->GetOption())
- {
- m_stretchable += weight;
- }
- else
+ if (item->GetOption() == 0)
{
if (m_orient == wxVERTICAL)
{
m_fixedWidth = wxMax( m_fixedWidth, size.x );
}
else
- {
+ {
m_fixedWidth += size.x;
m_fixedHeight = wxMax( m_fixedHeight, size.y );
}