// ----------------------------------------------------------------------------
// the default initialization
// ----------------------------------------------------------------------------
// the default initialization
{
// no window yet, no parent nor children
m_parent = (wxWindow *)NULL;
{
// no window yet, no parent nor children
m_parent = (wxWindow *)NULL;
const wxPoint& WXUNUSED(pos),
const wxSize& WXUNUSED(size),
long style,
const wxPoint& WXUNUSED(pos),
const wxSize& WXUNUSED(size),
long style,
- // m_isWindow is set to TRUE in wxWindowBase::Init() as well as many other
- // member variables - check that it has been called (will catch the case
- // when a new ctor is added which doesn't call InitWindow)
- wxASSERT_MSG( m_isWindow, wxT("Init() must have been called before!") );
-
#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
#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
// Just in case we've loaded a top-level window via LoadNativeDialog but
// we weren't a dialog class
// Just in case we've loaded a top-level window via LoadNativeDialog but
// we weren't a dialog class
}
bool wxWindowBase::Close(bool force)
{
wxCloseEvent event(wxEVT_CLOSE_WINDOW, m_windowId);
event.SetEventObject(this);
}
bool wxWindowBase::Close(bool force)
{
wxCloseEvent event(wxEVT_CLOSE_WINDOW, m_windowId);
event.SetEventObject(this);
// close event
return GetEventHandler()->ProcessEvent(event) && !event.GetVeto();
}
bool wxWindowBase::DestroyChildren()
{
// close event
return GetEventHandler()->ProcessEvent(event) && !event.GetVeto();
}
bool wxWindowBase::DestroyChildren()
{
- wxASSERT_MSG( child, wxT("children list contains empty nodes") );
-
- child->Show(FALSE);
+ // note that we really want to call delete and not ->Destroy() here
+ // because we want to delete the child immediately, before we are
+ // deleted, and delayed deletion would result in problems as our (top
+ // level) child could outlive its parent
delete child;
wxASSERT_MSG( !GetChildren().Find(child),
wxT("child didn't remove itself using RemoveChild()") );
}
delete child;
wxASSERT_MSG( !GetChildren().Find(child),
wxT("child didn't remove itself using RemoveChild()") );
}
// this should never happen and it will lead to a crash later if it does
// because RemoveChild() will remove only one node from the children list
// and the other(s) one(s) will be left with dangling pointers in them
// this should never happen and it will lead to a crash later if it does
// because RemoveChild() will remove only one node from the children list
// and the other(s) one(s) will be left with dangling pointers in them
wxEvtHandler *handlerPrev = NULL,
*handlerCur = GetEventHandler();
wxEvtHandler *handlerPrev = NULL,
*handlerCur = GetEventHandler();
bool wxWindowBase::SetBackgroundColour( const wxColour &colour )
{
if ( !colour.Ok() || (colour == m_backgroundColour) )
bool wxWindowBase::SetBackgroundColour( const wxColour &colour )
{
if ( !colour.Ok() || (colour == m_backgroundColour) )
}
bool wxWindowBase::SetForegroundColour( const wxColour &colour )
{
if ( !colour.Ok() || (colour == m_foregroundColour) )
}
bool wxWindowBase::SetForegroundColour( const wxColour &colour )
{
if ( !colour.Ok() || (colour == m_foregroundColour) )
return m_updateRegion.Contains(x, y, w, h) != wxOutRegion;
}
return m_updateRegion.Contains(x, y, w, h) != wxOutRegion;
}
+void wxWindowBase::ClearBackground()
+{
+ // wxGTK uses its own version, no need to add never used code
+#ifndef __WXGTK__
+ wxClientDC dc((wxWindow *)this);
+ wxBrush brush(GetBackgroundColour(), wxSOLID);
+ dc.SetBackground(brush);
+ dc.Clear();
+#endif // __WXGTK__
+}
+
// ----------------------------------------------------------------------------
// find child window by id or name
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// find child window by id or name
// ----------------------------------------------------------------------------
for ( node = m_children.GetFirst(); node && !res; node = node->GetNext() )
{
wxWindowBase *child = node->GetData();
for ( node = m_children.GetFirst(); node && !res; node = node->GetNext() )
{
wxWindowBase *child = node->GetData();
for ( node = m_children.GetFirst(); node && !res; node = node->GetNext() )
{
wxWindow *child = node->GetData();
for ( node = m_children.GetFirst(); node && !res; node = node->GetNext() )
{
wxWindow *child = node->GetData();
return (wxWindow *)parent;
// It wasn't, so check all its children
return (wxWindow *)parent;
// It wasn't, so check all its children
for ( node = m_children.GetFirst(); node; node = node->GetNext() )
{
wxWindowBase *child = node->GetData();
wxValidator *validator = child->GetValidator();
if ( validator && !validator->Validate((wxWindow *)this) )
{
for ( node = m_children.GetFirst(); node; node = node->GetNext() )
{
wxWindowBase *child = node->GetData();
wxValidator *validator = child->GetValidator();
if ( validator && !validator->Validate((wxWindow *)this) )
{
for ( node = m_children.GetFirst(); node; node = node->GetNext() )
{
wxWindowBase *child = node->GetData();
for ( node = m_children.GetFirst(); node; node = node->GetNext() )
{
wxWindowBase *child = node->GetData();
for ( node = m_children.GetFirst(); node; node = node->GetNext() )
{
wxWindow *child = node->GetData();
for ( node = m_children.GetFirst(); node; node = node->GetNext() )
{
wxWindow *child = node->GetData();
// nop warning here because the application is supposed to give
// one itself - we don't know here what might have gone wrongly
// nop warning here because the application is supposed to give
// one itself - we don't know here what might have gone wrongly
- if ( !m_constraintsInvolvedIn->Find(otherWin) )
- m_constraintsInvolvedIn->Append(otherWin);
+ if ( !m_constraintsInvolvedIn->Find((wxWindow *)otherWin) )
+ m_constraintsInvolvedIn->Append((wxWindow *)otherWin);
}
// REMOVE back-pointer to other windows we're involved with.
void wxWindowBase::RemoveConstraintReference(wxWindowBase *otherWin)
{
if ( m_constraintsInvolvedIn )
}
// REMOVE back-pointer to other windows we're involved with.
void wxWindowBase::RemoveConstraintReference(wxWindowBase *otherWin)
{
if ( m_constraintsInvolvedIn )
- constr->left.SetDone(FALSE);
- constr->top.SetDone(FALSE);
- constr->right.SetDone(FALSE);
- constr->bottom.SetDone(FALSE);
- constr->width.SetDone(FALSE);
- constr->height.SetDone(FALSE);
- constr->centreX.SetDone(FALSE);
- constr->centreY.SetDone(FALSE);
+ constr->left.SetDone(false);
+ constr->top.SetDone(false);
+ constr->right.SetDone(false);
+ constr->bottom.SetDone(false);
+ constr->width.SetDone(false);
+ constr->height.SetDone(false);
+ constr->centreX.SetDone(false);
+ constr->centreY.SetDone(false);
// do Update UI processing for child controls
// ----------------------------------------------------------------------------
// do Update UI processing for child controls
// ----------------------------------------------------------------------------
-// TODO: should this be implemented for the child window rather
-// than the parent? Then you can override it e.g. for wxCheckBox
-// to do the Right Thing rather than having to assume a fixed number
-// of control classes.
-void wxWindowBase::UpdateWindowUI()
+void wxWindowBase::UpdateWindowUI(long flags)
wxUpdateUIEvent event(GetId());
event.m_eventObject = this;
if ( GetEventHandler()->ProcessEvent(event) )
{
wxUpdateUIEvent event(GetId());
event.m_eventObject = this;
if ( GetEventHandler()->ProcessEvent(event) )
{
- wxControl *control = wxDynamicCastThis(wxControl);
- if ( control )
- {
-#if wxUSE_TEXTCTRL
- wxTextCtrl *text = wxDynamicCast(control, wxTextCtrl);
- if ( text )
- {
- if ( event.GetText() != text->GetValue() )
- text->SetValue(event.GetText());
- }
- else
-#endif // wxUSE_TEXTCTRL
- {
- if ( event.GetText() != control->GetLabel() )
- control->SetLabel(event.GetText());
- }
- }
+ wxWindow* child = (wxWindow*) node->GetData();
+ child->UpdateWindowUI(flags);
+ node = node->GetNext();
+ }
+}
+
+// do the window-specific processing after processing the update event
+// TODO: take specific knowledge out of this function and
+// put in each control's base class. Unfortunately we don't
+// yet have base implementation files for wxCheckBox and wxRadioButton.
+void wxWindowBase::DoUpdateWindowUI(wxUpdateUIEvent& event)
+{
+ if ( event.GetSetEnabled() )
+ Enable(event.GetEnabled());
+#if 0
+// call internal idle recursively
+// may be obsolete (wait until OnIdle scheme stabilises)
+void wxWindowBase::ProcessInternalIdle()
+{
+ OnInternalIdle();
+
+ wxWindowList::compatibility_iterator node = GetChildren().GetFirst();
+ while (node)
+ {
+ wxWindow *child = node->GetData();
+ child->ProcessInternalIdle();
+ node = node->GetNext();
+ }
+}
+#endif
+
// ----------------------------------------------------------------------------
// dialog units translations
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// dialog units translations
// ----------------------------------------------------------------------------
// propagate the colour change event to the subwindows
void wxWindowBase::OnSysColourChanged(wxSysColourChangedEvent& event)
{
// propagate the colour change event to the subwindows
void wxWindowBase::OnSysColourChanged(wxSysColourChangedEvent& event)
{
-// the default action is to populate dialog with data when it's created
+// the default action is to populate dialog with data when it's created,
+// and nudge the UI into displaying itself correctly in case
+// we've turned the wxUpdateUIEvents frequency down low.
// ----------------------------------------------------------------------------
// list classes implementation
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// list classes implementation
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// borders
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// borders
// ----------------------------------------------------------------------------
//else: stack is empty, no previous capture
wxLogTrace(_T("mousecapture"),
//else: stack is empty, no previous capture
wxLogTrace(_T("mousecapture"),
// Can only use the validator of the window which
// is receiving the event
if ( event.GetEventObject() == this )
// Can only use the validator of the window which
// is receiving the event
if ( event.GetEventObject() == this )
- // Carry on up the parent-child hierarchy, but only if event is a command
- // event: it wouldn't make sense for a parent to receive a child's size
- // event, for example
- if ( event.IsCommandEvent() )
+ // carry on up the parent-child hierarchy if the propgation count hasn't
+ // reached zero yet
+ if ( event.ShouldPropagate() )
{
// honour the requests to stop propagation at this window: this is
// used by the dialogs, for example, to prevent processing the events
{
// honour the requests to stop propagation at this window: this is
// used by the dialogs, for example, to prevent processing the events
// Can return either a child object, or an integer
// representing the child element, starting from 1.
// Can return either a child object, or an integer
// representing the child element, starting from 1.
-wxAccStatus wxWindowAccessible::HitTest(const wxPoint& pt, int* childId, wxAccessible** childObject)
+wxAccStatus wxWindowAccessible::HitTest(const wxPoint& WXUNUSED(pt), int* WXUNUSED(childId), wxAccessible** WXUNUSED(childObject))
// Navigates from fromId to toId/toObject.
wxAccStatus wxWindowAccessible::Navigate(wxNavDir navDir, int fromId,
// Navigates from fromId to toId/toObject.
wxAccStatus wxWindowAccessible::Navigate(wxNavDir navDir, int fromId,
// or > 0 (the action for a child).
// Return wxACC_NOT_SUPPORTED if there is no default action for this
// window (e.g. an edit control).
// or > 0 (the action for a child).
// Return wxACC_NOT_SUPPORTED if there is no default action for this
// window (e.g. an edit control).
// The retrieved string describes the action that is performed on an object,
// not what the object does as a result. For example, a toolbar button that prints
// a document has a default action of "Press" rather than "Prints the current document."
// The retrieved string describes the action that is performed on an object,
// not what the object does as a result. For example, a toolbar button that prints
// a document has a default action of "Press" rather than "Prints the current document."
// If childId is 0 and child is NULL, no object in
// this subhierarchy has the focus.
// If this object has the focus, child should be 'this'.
// If childId is 0 and child is NULL, no object in
// this subhierarchy has the focus.
// If this object has the focus, child should be 'this'.
// - an integer representing the selected child element,
// or 0 if this object is selected (GetType() == wxT("long")
// - a "void*" pointer to a wxAccessible child object
// - an integer representing the selected child element,
// or 0 if this object is selected (GetType() == wxT("long")
// - a "void*" pointer to a wxAccessible child object