#include "wx/caret.h"
#endif // wxUSE_CARET
+#if wxUSE_DISPLAY
+ #include "wx/display.h"
+#endif
+
#if wxUSE_SYSTEM_OPTIONS
#include "wx/sysopt.h"
#endif
// static data
// ----------------------------------------------------------------------------
-#if defined(__WXPM__)
+#if defined(__WXPALMOS__)
+int wxWindowBase::ms_lastControlId = 32767;
+#elif defined(__WXPM__)
int wxWindowBase::ms_lastControlId = 2000;
#else
int wxWindowBase::ms_lastControlId = -200;
int widthParent, heightParent;
wxWindow *parent = NULL;
+ wxTopLevelWindow *winTop = NULL;
if ( !(direction & wxCENTRE_ON_SCREEN) )
{
// Windows, for example, this places it completely off the screen
if ( parent )
{
- wxTopLevelWindow *winTop = wxDynamicCast(parent, wxTopLevelWindow);
+ winTop = wxDynamicCast(parent, wxTopLevelWindow);
if ( winTop && winTop->IsIconized() )
{
+ winTop = NULL;
parent = NULL;
}
}
if ( direction & wxCENTRE_ON_SCREEN )
{
+ //RN: If we are using wxDisplay we get
+ //the dimensions of the monitor the window is on,
+ //otherwise we get the dimensions of the primary monitor
+ //FIXME: wxDisplay::GetFromWindow only implemented on MSW
+#if wxUSE_DISPLAY && defined(__WXMSW__)
+ int nDisplay = wxDisplay::GetFromWindow((wxWindow*)this);
+ if(nDisplay != wxNOT_FOUND)
+ {
+ wxDisplay windowDisplay(nDisplay);
+ wxRect displayRect = windowDisplay.GetGeometry();
+ widthParent = displayRect.width;
+ heightParent = displayRect.height;
+ }
+ else
+#endif
// centre with respect to the whole screen
wxDisplaySize(&widthParent, &heightParent);
}
{
if ( IsTopLevel() )
{
- // centre on the parent
- parent->GetSize(&widthParent, &heightParent);
+ if(winTop)
+ winTop->GetRectForTopLevelChildren(&posParent.x, &posParent.y, &widthParent, &heightParent);
+ else
+ {
+ // centre on the parent
+ parent->GetSize(&widthParent, &heightParent);
- // adjust to the parents position
- posParent = parent->GetPosition();
+ // adjust to the parents position
+ posParent = parent->GetPosition();
+ }
}
else
{
xNew += posParent.x;
yNew += posParent.y;
+ // FIXME: This needs to get the client display rect of the display
+ // the window is (via wxDisplay::GetFromWindow).
+
// Base size of the visible dimensions of the display
// to take into account the taskbar. And the Mac menu bar at top.
wxRect clientrect = wxGetClientDisplayRect();
{
if ( GetChildren().GetCount() > 0 )
{
- SetClientSize(GetBestSize());
+ SetSize(GetBestSize());
}
//else: do nothing if we have no children
}
return (realChildCount > 0);
}
#endif
-
+
void wxWindowBase::InvalidateBestSize()
{
m_bestSizeCache = wxDefaultSize;
// return the size best suited for the current window
wxSize wxWindowBase::DoGetBestSize() const
{
+ wxSize best;
+
if ( m_windowSizer )
{
- return m_windowSizer->GetMinSize();
+ best = m_windowSizer->GetMinSize();
}
#if wxUSE_CONSTRAINTS
else if ( m_constraints )
// will never return a size bigger than the current one :-(
}
- return wxSize(maxX, maxY);
+ best = wxSize(maxX, maxY);
}
#endif // wxUSE_CONSTRAINTS
else if ( !GetChildren().empty()
maxX += 7;
maxY += 14;
- return wxSize(maxX, maxY);
+ best = wxSize(maxX, maxY);
}
else // ! has children
{
- // for a generic window there is no natural best size - just use either the
- // minimum size if there is one, or the current size
+ // For a generic window there is no natural best size - just use
+ // either the minimum size if there is one, or the current size.
+ // These are returned as-is, unadjusted by the client size difference.
if ( GetMinSize().IsFullySpecified() )
return GetMinSize();
else
return GetSize();
}
+
+ // Add any difference between size and client size
+ wxSize diff = GetSize() - GetClientSize();
+ best.x += wxMax(0, diff.x);
+ best.y += wxMax(0, diff.y);
+
+ return best;
}
// by default the origin is not shifted
wxPoint wxWindowBase::GetClientAreaOrigin() const
{
- return wxPoint(0, 0);
+ return wxPoint(0,0);
}
// set the min/max size of the window
wxSize wxWindowBase::DoGetVirtualSize() const
{
- wxSize s( GetClientSize() );
+ if ( m_virtualSize.IsFullySpecified() )
+ return m_virtualSize;
+
+ wxSize size = GetClientSize();
+ if ( m_virtualSize.x != wxDefaultCoord )
+ size.x = m_virtualSize.x;
- return wxSize( wxMax( m_virtualSize.GetWidth(), s.GetWidth() ),
- wxMax( m_virtualSize.GetHeight(), s.GetHeight() ) );
+ if ( m_virtualSize.y != wxDefaultCoord )
+ size.y = m_virtualSize.y;
+
+ return size;
}
// ----------------------------------------------------------------------------
if ( parent->m_inheritFgCol && !m_hasFgCol )
SetForegroundColour(parent->GetForegroundColour());
+ // inheriting (solid) background colour is wrong as it totally breaks
+ // any kind of themed backgrounds
+ //
+ // instead, the controls should use the same background as their parent
+ // (ideally by not drawing it at all)
+#if 0
if ( parent->m_inheritBgCol && !m_hasBgCol )
SetBackgroundColour(parent->GetBackgroundColour());
+#endif // 0
}
}
return false;
m_hasBgCol = colour.Ok();
+ if ( m_backgroundStyle != wxBG_STYLE_CUSTOM )
+ m_backgroundStyle = m_hasBgCol ? wxBG_STYLE_COLOUR : wxBG_STYLE_SYSTEM;
+
m_inheritBgCol = m_hasBgCol;
m_backgroundColour = colour;
SetThemeEnabled( !m_hasBgCol && !m_foregroundColour.Ok() );
// find child window by id or name
// ----------------------------------------------------------------------------
-wxWindow *wxWindowBase::FindWindow( long id )
+wxWindow *wxWindowBase::FindWindow(long id) const
{
if ( id == m_windowId )
return (wxWindow *)this;
return (wxWindow *)res;
}
-wxWindow *wxWindowBase::FindWindow( const wxString& name )
+wxWindow *wxWindowBase::FindWindow(const wxString& name) const
{
if ( name == m_windowName )
return (wxWindow *)this;
wxWindow *
wxWindowBase::FindWindowById( long id, const wxWindow* parent )
{
- return wxFindWindowHelper(parent, _T(""), id, wxFindWindowCmpIds);
+ return wxFindWindowHelper(parent, wxEmptyString, id, wxFindWindowCmpIds);
}
// ----------------------------------------------------------------------------
void wxWindowBase::UpdateWindowUI(long flags)
{
wxUpdateUIEvent event(GetId());
- event.m_eventObject = this;
+ event.SetEventObject(this);
if ( GetEventHandler()->ProcessEvent(event) )
{
if ( !win->IsTopLevel() )
{
wxSysColourChangedEvent event2;
- event.m_eventObject = win;
+ event.SetEventObject(win);
win->GetEventHandler()->ProcessEvent(event2);
}
wxMessageBox(wxString::Format(
_T(
- " wxWidgets Library (%s port)\nVersion %u.%u.%u%s%s, compiled at %s %s\n Copyright (c) 1995-2004 wxWidgets team"
+ " wxWidgets Library (%s port)\nVersion %u.%u.%u%s%s, compiled at %s %s\n Copyright (c) 1995-2005 wxWidgets team"
),
port.c_str(),
wxMAJOR_VERSION,
#else
"",
#endif
-#if __WXDEBUG__
+#ifdef __WXDEBUG__
_T(" Debug build"),
#else
- _T(""),
+ wxEmptyString,
#endif
__TDATE__,
__TTIME__
#endif
-#if !wxUSE_STL
// ----------------------------------------------------------------------------
// list classes implementation
// ----------------------------------------------------------------------------
+#if wxUSE_STL
+
+#include <wx/listimpl.cpp>
+WX_DEFINE_LIST(wxWindowList);
+
+#else
+
void wxWindowListNode::DeleteData()
{
delete (wxWindow *)GetData();
}
+
#endif
// ----------------------------------------------------------------------------
wxCHECK_RET( GetParent(),
_T("MoveBefore/AfterInTabOrder() don't work for TLWs!") );
+ // detect the special case when we have nothing to do anyhow and when the
+ // code below wouldn't work
+ if ( win == this )
+ return;
+
// find the target window in the siblings list
wxWindowList& siblings = GetParent()->GetChildren();
wxWindowList::compatibility_iterator i = siblings.Find(win);
#endif
title = GetWindow()->GetName();
- if (!title.IsEmpty())
+ if (!title.empty())
{
*name = title;
return wxACC_OK;
return wxACC_FAIL;
wxString ht(GetWindow()->GetHelpText());
- if (!ht.IsEmpty())
+ if (!ht.empty())
{
*description = ht;
return wxACC_OK;
return wxACC_FAIL;
wxString ht(GetWindow()->GetHelpText());
- if (!ht.IsEmpty())
+ if (!ht.empty())
{
*helpText = ht;
return wxACC_OK;