]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/wincmn.cpp
old makefiles removed
[wxWidgets.git] / src / common / wincmn.cpp
index 153a0408afaeed3b02aab2982ae1e799cf05f6a5..12e2f11fef3a0c00a5c129b8d6c93716f1890f1a 100644 (file)
     #include "wx/tooltip.h"
 #endif // wxUSE_TOOLTIPS
 
+#if wxUSE_CARET
+    #include "wx/caret.h"
+#endif // wxUSE_CARET
+
 // ----------------------------------------------------------------------------
 // static data
 // ----------------------------------------------------------------------------
 
-int wxWindowBase::ms_lastControlId = -2;
+int wxWindowBase::ms_lastControlId = -200;
 
 IMPLEMENT_ABSTRACT_CLASS(wxWindowBase, wxEvtHandler)
 
@@ -136,6 +140,10 @@ void wxWindowBase::InitBase()
 #if wxUSE_TOOLTIPS
     m_tooltip = (wxToolTip *)NULL;
 #endif // wxUSE_TOOLTIPS
+
+#if wxUSE_CARET
+    m_caret = (wxCaret *)NULL;
+#endif // wxUSE_CARET
 }
 
 // common part of window creation process
@@ -178,8 +186,13 @@ wxWindowBase::~wxWindowBase()
     // Just in case we've loaded a top-level window via LoadNativeDialog but
     // we weren't a dialog class
     wxTopLevelWindows.DeleteObject(this);
-    
-    wxASSERT_MSG( GetChildren().GetCount() == 0, "children not destroyed" );
+
+    wxASSERT_MSG( GetChildren().GetCount() == 0, _T("children not destroyed") );
+
+#if wxUSE_CARET
+    if ( m_caret )
+        delete m_caret;
+#endif // wxUSE_CARET
 
     if ( m_windowValidator )
         delete m_windowValidator;
@@ -244,15 +257,21 @@ bool wxWindowBase::Close(bool force)
 bool wxWindowBase::DestroyChildren()
 {
     wxWindowList::Node *node;
-    while ( (node = GetChildren().GetFirst()) )
+    for ( ;; )
     {
+        // we iterate until the list becomes empty
+        node = GetChildren().GetFirst();
+        if ( !node )
+            break;
+
         wxWindow *child = node->GetData();
-       
-       wxASSERT_MSG( child, "m_children contains empty nodes" );
-       
+
+        wxASSERT_MSG( child, _T("children list contains empty nodes") );
+
         delete child;
-       
-        wxASSERT_MSG( !GetChildren().Find(child), "child didn't remove itself using RemoveChild()" );
+
+        wxASSERT_MSG( !GetChildren().Find(child),
+                      _T("child didn't remove itself using RemoveChild()") );
     }
 
     return TRUE;
@@ -303,6 +322,14 @@ void wxWindowBase::Fit()
     while ( node )
     {
         wxWindow *win = node->GetData();
+        if ( win->IsKindOf(CLASSINFO(wxFrame)) ||
+             win->IsKindOf(CLASSINFO(wxDialog)) )
+        {
+            // dialogs and frames line in different top level windows - don't
+            // deal with them here
+            continue;
+        }
+
         int wx, wy, ww, wh;
         win->GetPosition(&wx, &wy);
         win->GetSize(&ww, &wh);
@@ -498,6 +525,24 @@ bool wxWindowBase::SetFont(const wxFont& font)
     return TRUE;
 }
 
+#if wxUSE_CARET
+void wxWindowBase::SetCaret(wxCaret *caret)
+{
+    if ( m_caret )
+    {
+        delete m_caret;
+    }
+
+    m_caret = caret;
+
+    if ( m_caret )
+    {
+        wxASSERT_MSG( m_caret->GetWindow() == this,
+                      "caret should be created associated to this window" );
+    }
+}
+#endif // wxUSE_CARET
+
 // ----------------------------------------------------------------------------
 // validators
 // ----------------------------------------------------------------------------
@@ -569,7 +614,7 @@ wxWindow *wxWindowBase::FindWindow( const wxString& name )
 
 void wxWindowBase::MakeModal(bool WXUNUSED(modal))
 {
-    wxFAIL_MSG("TODO");
+    wxFAIL_MSG(_T("TODO"));
 }
 
 bool wxWindowBase::Validate()
@@ -579,7 +624,7 @@ bool wxWindowBase::Validate()
     {
         wxWindowBase *child = node->GetData();
         wxValidator *validator = child->GetValidator();
-        if ( validator && validator->Validate(this) )
+        if ( validator && !validator->Validate((wxWindow *)this) )
         {
             return FALSE;
         }
@@ -1110,14 +1155,11 @@ void wxWindowBase::UpdateWindowUI()
                 if ( event.GetSetChecked() )
                     ((wxCheckBox *)this)->SetValue(event.GetChecked());
             }
-            // TODO No radio buttons in wxGTK yet
-#ifndef __WXGTK__
             else if ( IsKindOf(CLASSINFO(wxRadioButton)) )
             {
                 if ( event.GetSetChecked() )
                     ((wxRadioButton *) this)->SetValue(event.GetChecked());
             }
-#endif // !wxGTK
         }
     }
 }