+ void OnWindowCreate(wxWindowCreateEvent& event)
+ {
+ event.Skip();
+
+ // Attach a few event handlers to all parts of the composite window.
+ // This makes the composite window behave more like a simple control
+ // and allows other code (such as wxDataViewCtrl's inline editing
+ // support) to hook into its event processing.
+
+ wxWindow *child = event.GetWindow();
+ if ( child == this )
+ return; // not a child, we don't want to Connect() to ourselves
+
+ // Always capture wxEVT_KILL_FOCUS:
+ child->Connect(wxEVT_KILL_FOCUS,
+ wxFocusEventHandler(wxCompositeWindow::OnKillFocus),
+ NULL, this);
+
+ // Some events should be only handled for non-toplevel children. For
+ // example, we want to close the control in wxDataViewCtrl when Enter
+ // is pressed in the inline editor, but not when it's pressed in a
+ // popup dialog it opens.
+ wxWindow *win = child;
+ while ( win && win != this )
+ {
+ if ( win->IsTopLevel() )
+ return;
+ win = win->GetParent();
+ }
+
+ child->Connect(wxEVT_CHAR,
+ wxKeyEventHandler(wxCompositeWindow::OnChar),
+ NULL, this);
+ }
+
+ void OnChar(wxKeyEvent& event)
+ {
+ if ( !this->ProcessWindowEvent(event) )
+ event.Skip();
+ }
+
+ void OnKillFocus(wxFocusEvent& event)
+ {
+ // Ignore focus changes within the composite control:
+ wxWindow *win = event.GetWindow();
+ while ( win )
+ {
+ if ( win == this )
+ {
+ event.Skip();
+ return;
+ }
+
+ // Note that we don't use IsTopLevel() check here, because we do
+ // want to ignore focus changes going to toplevel window that have
+ // the composite control as its parent; these would typically be
+ // some kind of control's popup window.
+ win = win->GetParent();
+ }
+
+ // The event shouldn't be ignored, forward it to the main control:
+ if ( !this->ProcessWindowEvent(event) )
+ event.Skip();
+ }
+
+#ifndef __VISUALC6__
+ template <class T>
+ void SetForAllParts(bool (wxWindowBase::*func)(const T&), const T& arg)
+ {
+ DoSetForAllParts<const T&>(func, arg);
+ }
+