m_minHeight =
m_maxHeight = wxDefaultSize.y;
+ // invalidiated cache value
+ m_bestSizeCache = wxDefaultSize;
+
// window are created enabled and visible by default
m_isShown =
m_isEnabled = true;
m_hasBgCol =
m_hasFgCol =
m_hasFont = false;
+ m_inheritBgCol =
+ m_inheritFgCol =
+ m_inheritFont = false;
// no style bits
m_exStyle =
{
if ( GetChildren().GetCount() > 0 )
{
- SetClientSize(DoGetBestSize());
+ SetClientSize(GetBestSize());
}
//else: do nothing if we have no children
}
}
}
-void wxWindowBase::SetBestFittingSize(const wxSize& size)
+
+wxSize wxWindowBase::GetBestFittingSize() const
{
- // If the given size is incomplete then merge with the best size.
- wxSize sizeBest;
- if ( size.x == wxDefaultSize.x || size.y == wxDefaultSize.y )
+ // merge the best size with the min size, giving priority to the min size
+ wxSize min = GetMinSize();
+ if (min.x == wxDefaultCoord || min.y == wxDefaultCoord)
{
- sizeBest = DoGetBestSize();
- if ( size.x != wxDefaultSize.x )
- sizeBest.x = size.x;
- if ( size.y != wxDefaultSize.y )
- sizeBest.y = size.y;
- }
- else // have complete explicit size
- {
- sizeBest = size;
+ wxSize best = GetBestSize();
+ if (min.x == wxDefaultCoord) min.x = best.x;
+ if (min.y == wxDefaultCoord) min.y = best.y;
}
+ return min;
+}
- // Change the size if needed
- if (GetSize() != sizeBest)
- SetSize(sizeBest);
- // don't shrink the control below its best size
- m_minWidth = sizeBest.x;
- m_minHeight = sizeBest.y;
+void wxWindowBase::SetBestFittingSize(const wxSize& size)
+{
+ // Set the min size to the size passed in. This will usually either be
+ // wxDefaultSize or the size passed to this window's ctor/Create function.
+ SetMinSize(size);
+
+ // Merge the size with the best size if needed
+ wxSize best = GetBestFittingSize();
+
+ // If the current size doesn't match then change it
+ if (GetSize() != best)
+ SetSize(best);
}
+
// by default the origin is not shifted
wxPoint wxWindowBase::GetClientAreaOrigin() const
{
// which ensures that this only happens if the user really wants it and
// not by default which wouldn't make any sense in modern GUIs where the
// controls don't all use the same fonts (nor colours)
- if ( parent->m_hasFont && !m_hasFont )
+ if ( parent->m_inheritFont && !m_hasFont )
SetFont(parent->GetFont());
// in addition, there is a possibility to explicitly forbid inheriting
// colours at each class level by overriding ShouldInheritColours()
if ( ShouldInheritColours() )
{
- if ( parent->m_hasFgCol && !m_hasFgCol )
+ if ( parent->m_inheritFgCol && !m_hasFgCol )
SetForegroundColour(parent->GetForegroundColour());
- if ( parent->m_hasBgCol && !m_hasBgCol )
+ if ( parent->m_inheritBgCol && !m_hasBgCol )
SetBackgroundColour(parent->GetBackgroundColour());
}
}
return false;
m_hasBgCol = colour.Ok();
+ m_inheritBgCol = m_hasBgCol;
m_backgroundColour = colour;
SetThemeEnabled( !m_hasBgCol && !m_foregroundColour.Ok() );
return true;
return false;
m_hasFgCol = colour.Ok();
+ m_inheritFgCol = m_hasFgCol;
m_foregroundColour = colour;
SetThemeEnabled( !m_hasFgCol && !m_backgroundColour.Ok() );
return true;
m_font = font;
m_hasFont = font.Ok();
+ m_inheritFont = m_hasFont;
return true;
}
}
// ----------------------------------------------------------------------------
-// navigation
+// keyboard navigation
// ----------------------------------------------------------------------------
// Navigates in the specified direction.
return false;
}
+void wxWindowBase::DoMoveInTabOrder(wxWindow *win, MoveKind move)
+{
+ // check that we're not a top level window
+ wxCHECK_RET( GetParent(),
+ _T("MoveBefore/AfterInTabOrder() don't work for TLWs!") );
+
+ // find the target window in the siblings list
+ wxWindowList& siblings = GetParent()->GetChildren();
+ wxWindowList::compatibility_iterator i = siblings.Find(win);
+ wxCHECK_RET( i, _T("MoveBefore/AfterInTabOrder(): win is not a sibling") );
+
+ // unfortunately, when wxUSE_STL == 1 DetachNode() is not implemented so we
+ // can't just move the node around
+ wxWindow *self = (wxWindow *)this;
+ siblings.DeleteObject(self);
+ if ( move == MoveAfter )
+ {
+ i = i->GetNext();
+ }
+
+ if ( i )
+ {
+ siblings.Insert(i, self);
+ }
+ else // MoveAfter and win was the last sibling
+ {
+ siblings.Append(self);
+ }
+}
+
// ----------------------------------------------------------------------------
// global functions
// ----------------------------------------------------------------------------