]> git.saurik.com Git - wxWidgets.git/blobdiff - src/propgrid/propgrid.cpp
Mark a couple of labels for translation.
[wxWidgets.git] / src / propgrid / propgrid.cpp
index 83462b36a5f4f2fbea3ea53fa2b981c555ac3739..62459e647616ff0b9350769afcc3127442938757 100644 (file)
@@ -551,7 +551,9 @@ void wxPropertyGrid::Init2()
 
     // Hook the top-level parent
     m_tlp = NULL;
 
     // Hook the top-level parent
     m_tlp = NULL;
-    OnTLPChanging(NULL);
+    m_tlpClosed = NULL;
+    m_tlpClosedTime = 0;
+    OnTLPChanging(::wxGetTopLevelParent(this));
 
     // set virtual size to this window size
     wxSize wndsize = GetSize();
 
     // set virtual size to this window size
     wxSize wndsize = GetSize();
@@ -588,20 +590,8 @@ wxPropertyGrid::~wxPropertyGrid()
     if ( m_iFlags & wxPG_FL_MOUSE_CAPTURED )
         m_canvas->ReleaseMouse();
 
     if ( m_iFlags & wxPG_FL_MOUSE_CAPTURED )
         m_canvas->ReleaseMouse();
 
-    // Do TLP check, recommend use of OnTLPChanging()
-    wxWindow* tlp = ::wxGetTopLevelParent(this);
-    if ( tlp == m_tlp )
-    {
-        m_tlp->Disconnect( wxEVT_CLOSE_WINDOW,
-                           wxCloseEventHandler(wxPropertyGrid::OnTLPClose),
-                           NULL, this );
-    }
-    else if ( tlp )
-    {
-        wxLogError("Top-level parent of wxPropertyGrid has changed. "
-                   "Consider calling wxPropertyGrid::OnTLPChanging() "
-                   "when appropriate.");
-    }
+    // Call with NULL to disconnect event handling
+    OnTLPChanging(NULL);
 
     wxASSERT_MSG( !IsEditorsValueModified(),
                   wxS("Most recent change in property editor was lost!!! ")
 
     wxASSERT_MSG( !IsEditorsValueModified(),
                   wxS("Most recent change in property editor was lost!!! ")
@@ -816,31 +806,42 @@ wxSize wxPropertyGrid::DoGetBestSize() const
     return sz;
 }
 
     return sz;
 }
 
- // -----------------------------------------------------------------------
+// -----------------------------------------------------------------------
 
 void wxPropertyGrid::OnTLPChanging( wxWindow* newTLP )
 {
 
 void wxPropertyGrid::OnTLPChanging( wxWindow* newTLP )
 {
+    wxLongLong currentTime = ::wxGetLocalTimeMillis();
+
     //
     // Parent changed so let's redetermine and re-hook the
     // correct top-level window.
     if ( m_tlp )
     {
     //
     // Parent changed so let's redetermine and re-hook the
     // correct top-level window.
     if ( m_tlp )
     {
-        wxASSERT_MSG( m_tlp == ::wxGetTopLevelParent(this),
-                      "You must call OnTLPChanging() before the "
-                      "top-level parent has changed.");
-
         m_tlp->Disconnect( wxEVT_CLOSE_WINDOW,
                            wxCloseEventHandler(wxPropertyGrid::OnTLPClose),
                            NULL, this );
         m_tlp->Disconnect( wxEVT_CLOSE_WINDOW,
                            wxCloseEventHandler(wxPropertyGrid::OnTLPClose),
                            NULL, this );
+        m_tlpClosed = m_tlp;
+        m_tlpClosedTime = currentTime;
     }
 
     }
 
-    if ( !newTLP )
-        newTLP = ::wxGetTopLevelParent(this);
+    if ( newTLP )
+    {
+        // Only accept new tlp if same one was not just dismissed.
+        if ( newTLP != m_tlpClosed ||
+             m_tlpClosedTime+250 < currentTime )
+        {
+            newTLP->Connect( wxEVT_CLOSE_WINDOW,
+                             wxCloseEventHandler(wxPropertyGrid::OnTLPClose),
+                             NULL, this );
+            m_tlpClosed = NULL;
+        }
+        else
+        {
+            newTLP = NULL;
+        }
+    }
 
     m_tlp = newTLP;
 
     m_tlp = newTLP;
-    m_tlp->Connect( wxEVT_CLOSE_WINDOW,
-                    wxCloseEventHandler(wxPropertyGrid::OnTLPClose),
-                    NULL, this );
 }
 
 // -----------------------------------------------------------------------
 }
 
 // -----------------------------------------------------------------------
@@ -854,6 +855,11 @@ void wxPropertyGrid::OnTLPClose( wxCloseEvent& event )
         return;
     }
 
         return;
     }
 
+    // Ok, it can close, set tlp pointer to NULL. Some other event
+    // handler can of course veto the close, but our OnIdle() should
+    // then be able to regain the tlp pointer.
+    OnTLPChanging(NULL);
+
     event.Skip();
 }
 
     event.Skip();
 }
 
@@ -2593,7 +2599,7 @@ void wxPropertyGrid::DoShowPropertyError( wxPGProperty* WXUNUSED(property), cons
     }
 #endif
 
     }
 #endif
 
-    ::wxMessageBox(msg, _T("Property Error"));
+    ::wxMessageBox(msg, wxT("Property Error"));
 }
 
 // -----------------------------------------------------------------------
 }
 
 // -----------------------------------------------------------------------
@@ -2668,7 +2674,7 @@ bool wxPropertyGrid::DoOnValidationFailure( wxPGProperty* property, wxVariant& W
         wxString msg = m_validationInfo.m_failureMessage;
 
         if ( !msg.length() )
         wxString msg = m_validationInfo.m_failureMessage;
 
         if ( !msg.length() )
-            msg = _T("You have entered invalid value. Press ESC to cancel editing.");
+            msg = wxT("You have entered invalid value. Press ESC to cancel editing.");
 
         DoShowPropertyError(property, msg);
     }
 
         DoShowPropertyError(property, msg);
     }
@@ -3239,10 +3245,14 @@ bool wxPropertyGrid::DoSelectProperty( wxPGProperty* p, unsigned int flags )
 {
     /*
     if (p)
 {
     /*
     if (p)
+    {
         wxLogDebug(wxT("SelectProperty( %s (%s[%i]) )"),p->m_label.c_str(),
             p->m_parent->m_label.c_str(),p->GetIndexInParent());
         wxLogDebug(wxT("SelectProperty( %s (%s[%i]) )"),p->m_label.c_str(),
             p->m_parent->m_label.c_str(),p->GetIndexInParent());
+    }
     else
     else
+    {
         wxLogDebug(wxT("SelectProperty( NULL, -1 )"));
         wxLogDebug(wxT("SelectProperty( NULL, -1 )"));
+    }
     */
 
     if ( m_inDoSelectProperty )
     */
 
     if ( m_inDoSelectProperty )
@@ -4957,6 +4967,14 @@ void wxPropertyGrid::OnIdle( wxIdleEvent& WXUNUSED(event) )
 
     if ( newFocused != m_curFocused )
         HandleFocusChange( newFocused );
 
     if ( newFocused != m_curFocused )
         HandleFocusChange( newFocused );
+
+    //
+    // Check if top-level parent has changed
+    wxWindow* tlp = ::wxGetTopLevelParent(this);
+    if ( tlp != m_tlp )
+    {
+        OnTLPChanging(tlp);
+    }
 }
 
 bool wxPropertyGrid::IsEditorFocused() const
 }
 
 bool wxPropertyGrid::IsEditorFocused() const
@@ -5231,7 +5249,6 @@ wxPGChoiceEntry::wxPGChoiceEntry()
 
 wxPGChoicesData::wxPGChoicesData()
 {
 
 wxPGChoicesData::wxPGChoicesData()
 {
-    m_refCount = 1;
 }
 
 wxPGChoicesData::~wxPGChoicesData()
 }
 
 wxPGChoicesData::~wxPGChoicesData()