// Modified by:
// Created: 13/07/98
// RCS-ID: $Id$
-// Copyright: (c) wxWindows team
+// Copyright: (c) wxWidgets team
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#include "wx/dcclient.h"
#endif //WX_PRECOMP
+#if defined(__WXMAC__) && wxUSE_SCROLLBAR
+ #include "wx/scrolbar.h"
+#endif
+
#if wxUSE_CONSTRAINTS
#include "wx/layout.h"
#endif // wxUSE_CONSTRAINTS
// no constraints on the minimal window size
m_minWidth =
+ m_maxWidth = wxDefaultSize.x;
m_minHeight =
- m_maxWidth =
- m_maxHeight = -1;
+ m_maxHeight = wxDefaultSize.y;
// window are created enabled and visible by default
m_isShown =
m_virtualSize = wxDefaultSize;
m_minVirtualWidth =
+ m_maxVirtualWidth = wxDefaultSize.x;
m_minVirtualHeight =
- m_maxVirtualWidth =
- m_maxVirtualHeight = -1;
+ m_maxVirtualHeight = wxDefaultSize.y;
m_windowVariant = wxWINDOW_VARIANT_NORMAL;
// ids are limited to 16 bits under MSW so if you care about portability,
// it's not a good idea to use ids out of this range (and negative ids are
- // reserved for wxWindows own usage)
+ // reserved for wxWidgets own usage)
wxASSERT_MSG( id == wxID_ANY || (id >= 0 && id < 32767),
_T("invalid id value") );
int width, height;
GetSize(&width, &height);
- int xNew = -1,
- yNew = -1;
+ int xNew = wxDefaultPosition.x,
+ yNew = wxDefaultPosition.y;
if ( direction & wxHORIZONTAL )
xNew = (widthParent - width)/2;
}
}
+// On Mac, scrollbars are explicitly children.
+#ifdef __WXMAC__
+static bool wxHasRealChildren(const wxWindowBase* win)
+{
+ int realChildCount = 0;
+
+ for ( wxWindowList::compatibility_iterator node = win->GetChildren().GetFirst();
+ node;
+ node = node->GetNext() )
+ {
+ wxWindow *win = node->GetData();
+ if ( !win->IsTopLevel() && win->IsShown() && !win->IsKindOf(CLASSINFO(wxScrollBar)))
+ realChildCount ++;
+ }
+ return (realChildCount > 0);
+}
+#endif
+
// return the size best suited for the current window
wxSize wxWindowBase::DoGetBestSize() const
{
return wxSize(maxX, maxY);
}
#endif // wxUSE_CONSTRAINTS
- else if ( !GetChildren().empty() )
+ else if ( !GetChildren().empty()
+#ifdef __WXMAC__
+ && wxHasRealChildren(this)
+#endif
+ )
{
// our minimal acceptable size is such that all our visible child windows fit inside
int maxX = 0,
// if the window hadn't been positioned yet, assume that it is in
// the origin
- if ( wx == -1 )
+ if ( wx == wxDefaultPosition.x )
wx = 0;
- if ( wy == -1 )
+ if ( wy == wxDefaultPosition.y )
wy = 0;
win->GetSize(&ww, &wh);
void wxWindowBase::SetBestSize(const wxSize& size)
{
- // the size only needs to be changed if the current size is incomplete,
- // i.e. one of the components was specified as default -- so if both
- // were given, simply don't do anything and in particular don't call
- // potentially expensive DoGetBestSize()
+ // If the given size is incomplete then merge with the best size.
wxSize sizeBest;
- if ( size.x == -1 || size.y == -1 )
+ if ( size.x == wxDefaultSize.x || size.y == wxDefaultSize.y )
{
sizeBest = DoGetBestSize();
- if ( size.x != -1 )
+ if ( size.x != wxDefaultSize.x )
sizeBest.x = size.x;
- if ( size.y != -1 )
+ if ( size.y != wxDefaultSize.y )
sizeBest.y = size.y;
-
- SetSize(sizeBest);
}
- else // have explicit size
+ else // have complete explicit size
{
sizeBest = size;
}
+ // 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;
{
// setting min width greater than max width leads to infinite loops under
// X11 and generally doesn't make any sense, so don't allow it
- wxCHECK_RET( (minW == -1 || maxW == -1 || minW <= maxW) &&
- (minH == -1 || maxH == -1 || minH <= maxH),
+ wxCHECK_RET( (minW == wxDefaultSize.x || maxW == wxDefaultSize.x || minW <= maxW) &&
+ (minH == wxDefaultSize.y || maxH == wxDefaultSize.y || minH <= maxH),
_T("min width/height must be less than max width/height!") );
m_minWidth = minW;
void wxWindowBase::DoSetVirtualSize( int x, int y )
{
- if ( m_minVirtualWidth != -1 && m_minVirtualWidth > x )
+ if ( m_minVirtualWidth != wxDefaultSize.x && m_minVirtualWidth > x )
x = m_minVirtualWidth;
- if ( m_maxVirtualWidth != -1 && m_maxVirtualWidth < x )
+ if ( m_maxVirtualWidth != wxDefaultSize.x && m_maxVirtualWidth < x )
x = m_maxVirtualWidth;
- if ( m_minVirtualHeight != -1 && m_minVirtualHeight > y )
+ if ( m_minVirtualHeight != wxDefaultSize.y && m_minVirtualHeight > y )
y = m_minVirtualHeight;
- if ( m_maxVirtualHeight != -1 && m_maxVirtualHeight < y )
+ if ( m_maxVirtualHeight != wxDefaultSize.y && m_maxVirtualHeight < y )
y = m_maxVirtualHeight;
m_virtualSize = wxSize(x, y);
// we must return some valid colour to avoid redoing this every time
// and also to avoid surprizing the applications written for older
- // wxWindows versions where GetBackgroundColour() always returned
+ // wxWidgets versions where GetBackgroundColour() always returned
// something -- so give them something even if it doesn't make sense
// for this window (e.g. it has a themed background)
if ( !colBg.Ok() )
wxLayoutConstraints *constr = GetConstraints();
if ( constr )
{
- if ( x != -1 )
+ if ( x != wxDefaultPosition.x )
{
constr->left.SetValue(x);
constr->left.SetDone(true);
}
- if ( y != -1 )
+ if ( y != wxDefaultPosition.y )
{
constr->top.SetValue(y);
constr->top.SetDone(true);
}
- if ( w != -1 )
+ if ( w != wxDefaultSize.x )
{
constr->width.SetValue(w);
constr->width.SetDone(true);
}
- if ( h != -1 )
+ if ( h != wxDefaultSize.y )
{
constr->height.SetValue(h);
constr->height.SetDone(true);
wxLayoutConstraints *constr = GetConstraints();
if ( constr )
{
- if ( x != -1 )
+ if ( x != wxDefaultPosition.x )
{
constr->left.SetValue(x);
constr->left.SetDone(true);
}
- if ( y != -1 )
+ if ( y != wxDefaultPosition.y )
{
constr->top.SetValue(y);
constr->top.SetDone(true);
wxMessageBox(wxString::Format(
_T(
- " wxWindows Library (%s port)\nVersion %u.%u.%u%s, compiled at %s %s\n Copyright (c) 1995-2002 wxWindows team"
+ " wxWidgets Library (%s port)\nVersion %u.%u.%u%s, compiled at %s %s\n Copyright (c) 1995-2002 wxWidgets team"
),
port.c_str(),
wxMAJOR_VERSION,
__TDATE__,
__TTIME__
),
- _T("wxWindows information"),
+ _T("wxWidgets information"),
wxICON_INFORMATION | wxOK,
(wxWindow *)this);
}
wxString title;
- // If a child, leave wxWindows to call the function on the actual
+ // If a child, leave wxWidgets to call the function on the actual
// child object.
if (childId > 0)
return wxACC_NOT_IMPLEMENTED;
// This will eventually be replaced by specialised
- // accessible classes, one for each kind of wxWindows
+ // accessible classes, one for each kind of wxWidgets
// control or window.
+#if wxUSE_BUTTON
if (GetWindow()->IsKindOf(CLASSINFO(wxButton)))
title = ((wxButton*) GetWindow())->GetLabel();
else
+#endif
title = GetWindow()->GetName();
if (!title.IsEmpty())
if (!GetWindow())
return wxACC_FAIL;
- // If a child, leave wxWindows to call the function on the actual
+ // If a child, leave wxWidgets to call the function on the actual
// child object.
if (childId > 0)
return wxACC_NOT_IMPLEMENTED;
if (!GetWindow())
return wxACC_FAIL;
- // If a child, leave wxWindows to call the function on the actual
+ // If a child, leave wxWidgets to call the function on the actual
// child object.
if (childId > 0)
return wxACC_NOT_IMPLEMENTED;