#include "wx/settings.h"
#include "wx/dialog.h"
#include "wx/msgdlg.h"
+ #include "wx/msgout.h"
#include "wx/statusbr.h"
#include "wx/toolbar.h"
#include "wx/dcclient.h"
#include "wx/sysopt.h"
#endif
-// For reporting compile- and runtime version of GTK+ in the ctrl+alt+mclick dialog.
-// The gtk includes don't pull any other headers in, at least not on my system - MR
-#ifdef __WXGTK__
- #ifdef __WXGTK20__
- #include <gtk/gtkversion.h>
- #else
- #include <gtk/gtkfeatures.h>
- #endif
-#endif
-
#include "wx/platinfo.h"
// Windows List
EVT_HELP(wxID_ANY, wxWindowBase::OnHelp)
#endif // wxUSE_HELP
+ EVT_SIZE(wxWindowBase::InternalOnSize)
END_EVENT_TABLE()
// ============================================================================
m_exStyle =
m_windowStyle = 0;
- m_backgroundStyle = wxBG_STYLE_SYSTEM;
+ m_backgroundStyle = wxBG_STYLE_ERASE;
#if wxUSE_CONSTRAINTS
// no constraints whatsoever
const wxValidator& wxVALIDATOR_PARAM(validator),
const wxString& name)
{
-#if wxUSE_STATBOX
- // wxGTK doesn't allow to create controls with static box as the parent so
- // this will result in a crash when the program is ported to wxGTK so warn
- // the user about it
-
- // if you get this assert, the correct solution is to create the controls
- // as siblings of the static box
- wxASSERT_MSG( !parent || !wxDynamicCast(parent, wxStaticBox),
- _T("wxStaticBox can't be used as a window parent!") );
-#endif // wxUSE_STATBOX
-
// 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 wxWidgets own usage)
}
// On Mac, scrollbars are explicitly children.
-#ifdef __WXMAC__
+#if defined( __WXMAC__ ) && !defined(__WXUNIVERSAL__)
static bool wxHasRealChildren(const wxWindowBase* win)
{
int realChildCount = 0;
}
#endif // wxUSE_CONSTRAINTS
else if ( !GetChildren().empty()
-#ifdef __WXMAC__
+#if defined( __WXMAC__ ) && !defined(__WXUNIVERSAL__)
&& wxHasRealChildren(this)
#endif
)
{
// merge the best size with the min size, giving priority to the min size
wxSize min = GetMinSize();
-
+
if (min.x == wxDefaultCoord || min.y == wxDefaultCoord)
{
wxSize best = GetBestSize();
if (min.x == wxDefaultCoord) min.x = best.x;
if (min.y == wxDefaultCoord) min.y = best.y;
}
-
+
return min;
}
wxSize wxWindowBase::GetBestSize() const
{
- if ((!m_windowSizer) && (m_bestSizeCache.IsFullySpecified()))
+ if ( !m_windowSizer && m_bestSizeCache.IsFullySpecified() )
return m_bestSizeCache;
-
+
+ // call DoGetBestClientSize() first, if a derived class overrides it wants
+ // it to be used
+ wxSize size = DoGetBestClientSize();
+ if ( size != wxDefaultSize )
+ {
+ size += DoGetBorderSize();
+
+ CacheBestSize(size);
+ return size;
+ }
+
return DoGetBestSize();
}
void wxWindowBase::SetMinSize(const wxSize& minSize)
-{
- m_minWidth = minSize.x;
- m_minHeight = minSize.y;
+{
+ m_minWidth = minSize.x;
+ m_minHeight = minSize.y;
}
void wxWindowBase::SetMaxSize(const wxSize& maxSize)
-{
- m_maxWidth = maxSize.x;
+{
+ m_maxWidth = maxSize.x;
m_maxHeight = maxSize.y;
}
SetEventHandler(handlerToPush);
-#ifdef __WXDEBUG__
+#if wxDEBUG_LEVEL
// final checks of the operations done above:
wxASSERT_MSG( handlerToPush->GetPreviousHandler() == NULL,
- "the first handler of the wxWindow stack should have no previous handlers set" );
+ "the first handler of the wxWindow stack should "
+ "have no previous handlers set" );
wxASSERT_MSG( handlerToPush->GetNextHandler() != NULL,
- "the first handler of the wxWindow stack should have non-NULL next handler" );
+ "the first handler of the wxWindow stack should "
+ "have non-NULL next handler" );
wxEvtHandler* pLast = handlerToPush;
- while (pLast && pLast != this)
+ while ( pLast && pLast != this )
pLast = pLast->GetNextHandler();
wxASSERT_MSG( pLast->GetNextHandler() == NULL,
- "the last handler of the wxWindow stack should have this window as next handler" );
-#endif
+ "the last handler of the wxWindow stack should "
+ "have this window as next handler" );
+#endif // wxDEBUG_LEVEL
}
wxEvtHandler *wxWindowBase::PopEventHandler(bool deleteHandler)
return false;
m_hasBgCol = colour.IsOk();
- if ( m_backgroundStyle != wxBG_STYLE_CUSTOM )
- m_backgroundStyle = m_hasBgCol ? wxBG_STYLE_COLOUR : wxBG_STYLE_SYSTEM;
m_inheritBgCol = m_hasBgCol;
m_backgroundColour = colour;
return true;
}
+void wxWindowBase::InternalOnSize(wxSizeEvent& event)
+{
+ if ( GetAutoLayout() )
+ Layout();
+
+ event.Skip();
+}
+
#if wxUSE_CONSTRAINTS
// first phase of the constraints evaluation: set our own constraints
static void DrawSizers(wxWindowBase *win);
-static void DrawBorder(wxWindowBase *win, const wxRect& rect, bool fill = false)
+static void DrawBorder(wxWindowBase *win, const wxRect& rect, bool fill, const wxPen* pen)
{
wxClientDC dc((wxWindow *)win);
- dc.SetPen(*wxRED_PEN);
- dc.SetBrush(fill ? wxBrush(*wxRED, wxBRUSHSTYLE_CROSSDIAG_HATCH) : *wxTRANSPARENT_BRUSH);
+ dc.SetPen(*pen);
+ dc.SetBrush(fill ? wxBrush(pen->GetColour(), wxBRUSHSTYLE_CROSSDIAG_HATCH) :
+ *wxTRANSPARENT_BRUSH);
dc.DrawRectangle(rect.Deflate(1, 1));
}
wxSizerItem *item = *i;
if ( item->IsSizer() )
{
- DrawBorder(win, item->GetRect().Deflate(2));
+ DrawBorder(win, item->GetRect().Deflate(2), false, wxRED_PEN);
DrawSizer(win, item->GetSizer());
}
else if ( item->IsSpacer() )
{
- DrawBorder(win, item->GetRect().Deflate(2), true);
+ DrawBorder(win, item->GetRect().Deflate(2), true, wxBLUE_PEN);
}
else if ( item->IsWindow() )
{
DrawSizers(item->GetWindow());
}
+ else
+ wxFAIL_MSG("inconsistent wxSizerItem status!");
}
}
static void DrawSizers(wxWindowBase *win)
{
+ DrawBorder(win, win->GetClientSize(), false, wxGREEN_PEN);
+
wxSizer *sizer = win->GetSizer();
if ( sizer )
{
- DrawBorder(win, win->GetClientSize());
DrawSizer(win, sizer);
}
else // no sizer, still recurse into the children
{
DrawSizers(*i);
}
+
+ // show all kind of sizes of this window; see the "window sizing" topic
+ // overview for more info about the various differences:
+ wxSize fullSz = win->GetSize();
+ wxSize clientSz = win->GetClientSize();
+ wxSize bestSz = win->GetBestSize();
+ wxSize minSz = win->GetMinSize();
+ wxSize maxSz = win->GetMaxSize();
+ wxSize virtualSz = win->GetVirtualSize();
+
+ wxMessageOutputDebug dbgout;
+ dbgout.Printf(
+ "%-10s => fullsz=%4d;%-4d clientsz=%4d;%-4d bestsz=%4d;%-4d minsz=%4d;%-4d maxsz=%4d;%-4d virtualsz=%4d;%-4d\n",
+ win->GetName(),
+ fullSz.x, fullSz.y,
+ clientSz.x, clientSz.y,
+ bestSz.x, bestSz.y,
+ minSz.x, minSz.y,
+ maxSz.x, maxSz.y,
+ virtualSz.x, virtualSz.y);
}
}
// event processing
// ----------------------------------------------------------------------------
-bool wxWindowBase::TryValidator(wxEvent& wxVALIDATOR_PARAM(event))
+bool wxWindowBase::TryBefore(wxEvent& event)
{
#if wxUSE_VALIDATORS
// Can only use the validator of the window which
}
#endif // wxUSE_VALIDATORS
- return false;
+ return wxEvtHandler::TryBefore(event);
}
-bool wxWindowBase::TryParent(wxEvent& event)
+bool wxWindowBase::TryAfter(wxEvent& event)
{
// carry on up the parent-child hierarchy if the propagation count hasn't
// reached zero yet
}
}
- return wxEvtHandler::TryParent(event);
+ return wxEvtHandler::TryAfter(event);
}
// ----------------------------------------------------------------------------
private:
wxWindowBase * const m_win;
- DECLARE_NO_COPY_CLASS(DragAcceptFilesTarget)
+ wxDECLARE_NO_COPY_CLASS(DragAcceptFilesTarget);
};