]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/wincmn.cpp
Compile fixes.
[wxWidgets.git] / src / common / wincmn.cpp
index 542345c472dcd57f4bb5b7dbe73cf276e72a52d2..92b73efe7915423b350324eb282aa34cbb1877de 100644 (file)
 // headers
 // ----------------------------------------------------------------------------
 
 // headers
 // ----------------------------------------------------------------------------
 
+#ifdef __GNUG__
+    #pragma implementation "windowbase.h"
+#endif
+
 // For compilers that support precompilation, includes "wx.h".
 #include "wx/wxprec.h"
 
 // For compilers that support precompilation, includes "wx.h".
 #include "wx/wxprec.h"
 
     #include "wx/tooltip.h"
 #endif // wxUSE_TOOLTIPS
 
     #include "wx/tooltip.h"
 #endif // wxUSE_TOOLTIPS
 
+#if wxUSE_CARET
+    #include "wx/caret.h"
+#endif // wxUSE_CARET
+
 // ----------------------------------------------------------------------------
 // static data
 // ----------------------------------------------------------------------------
 
 // ----------------------------------------------------------------------------
 // static data
 // ----------------------------------------------------------------------------
 
-int wxWindowBase::ms_lastControlId = 0;
+int wxWindowBase::ms_lastControlId = -200;
 
 IMPLEMENT_ABSTRACT_CLASS(wxWindowBase, wxEvtHandler)
 
 
 IMPLEMENT_ABSTRACT_CLASS(wxWindowBase, wxEvtHandler)
 
@@ -78,7 +86,6 @@ END_EVENT_TABLE()
 void wxWindowBase::InitBase()
 {
     // no window yet, no parent nor children
 void wxWindowBase::InitBase()
 {
     // no window yet, no parent nor children
-    m_widget = (WXWidget)0;
     m_parent = (wxWindow *)NULL;
     m_windowId = -1;
     m_children.DeleteContents( FALSE ); // don't auto delete node data
     m_parent = (wxWindow *)NULL;
     m_windowId = -1;
     m_children.DeleteContents( FALSE ); // don't auto delete node data
@@ -100,8 +107,10 @@ void wxWindowBase::InitBase()
     // the default event handler is just this window
     m_eventHandler = this;
 
     // the default event handler is just this window
     m_eventHandler = this;
 
+#if wxUSE_VALIDATORS
     // no validator
     m_windowValidator = (wxValidator *) NULL;
     // no validator
     m_windowValidator = (wxValidator *) NULL;
+#endif // wxUSE_VALIDATORS
 
     // use the system default colours
     wxSystemSettings settings;
 
     // use the system default colours
     wxSystemSettings settings;
@@ -133,13 +142,17 @@ void wxWindowBase::InitBase()
 #if wxUSE_TOOLTIPS
     m_tooltip = (wxToolTip *)NULL;
 #endif // wxUSE_TOOLTIPS
 #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
 bool wxWindowBase::CreateBase(wxWindowBase *parent,
                               wxWindowID id,
 }
 
 // common part of window creation process
 bool wxWindowBase::CreateBase(wxWindowBase *parent,
                               wxWindowID id,
-                              const wxPoint& pos,
-                              const wxSize& size,
+                              const wxPoint& WXUNUSED(pos),
+                              const wxSize& WXUNUSED(size),
                               long style,
                               const wxString& name)
 {
                               long style,
                               const wxString& name)
 {
@@ -176,10 +189,17 @@ wxWindowBase::~wxWindowBase()
     // we weren't a dialog class
     wxTopLevelWindows.DeleteObject(this);
 
     // we weren't a dialog class
     wxTopLevelWindows.DeleteObject(this);
 
-    DestroyChildren();
+    wxASSERT_MSG( GetChildren().GetCount() == 0, _T("children not destroyed") );
+
+#if wxUSE_CARET
+    if ( m_caret )
+        delete m_caret;
+#endif // wxUSE_CARET
 
 
+#if wxUSE_VALIDATORS
     if ( m_windowValidator )
         delete m_windowValidator;
     if ( m_windowValidator )
         delete m_windowValidator;
+#endif // wxUSE_VALIDATORS
 
     if ( m_clientObject )
         delete m_clientObject;
 
     if ( m_clientObject )
         delete m_clientObject;
@@ -241,13 +261,21 @@ bool wxWindowBase::Close(bool force)
 bool wxWindowBase::DestroyChildren()
 {
     wxWindowList::Node *node;
 bool wxWindowBase::DestroyChildren()
 {
     wxWindowList::Node *node;
-    for ( node = GetChildren().GetFirst(); node; node = node->GetNext() )
+    for ( ;; )
     {
     {
+        // we iterate until the list becomes empty
+        node = GetChildren().GetFirst();
+        if ( !node )
+            break;
+
         wxWindow *child = node->GetData();
         wxWindow *child = node->GetData();
-        if ( child )
-        {
-            delete child;
-        }
+
+        wxASSERT_MSG( child, _T("children list contains empty nodes") );
+
+        delete child;
+
+        wxASSERT_MSG( !GetChildren().Find(child),
+                      _T("child didn't remove itself using RemoveChild()") );
     }
 
     return TRUE;
     }
 
     return TRUE;
@@ -298,6 +326,14 @@ void wxWindowBase::Fit()
     while ( node )
     {
         wxWindow *win = node->GetData();
     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);
         int wx, wy, ww, wh;
         win->GetPosition(&wx, &wy);
         win->GetSize(&ww, &wh);
@@ -493,6 +529,25 @@ bool wxWindowBase::SetFont(const wxFont& font)
     return TRUE;
 }
 
     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
+
+#if wxUSE_VALIDATORS
 // ----------------------------------------------------------------------------
 // validators
 // ----------------------------------------------------------------------------
 // ----------------------------------------------------------------------------
 // validators
 // ----------------------------------------------------------------------------
@@ -507,6 +562,7 @@ void wxWindowBase::SetValidator(const wxValidator& validator)
     if ( m_windowValidator )
         m_windowValidator->SetWindow(this) ;
 }
     if ( m_windowValidator )
         m_windowValidator->SetWindow(this) ;
 }
+#endif // wxUSE_VALIDATORS
 
 // ----------------------------------------------------------------------------
 // update region testing
 
 // ----------------------------------------------------------------------------
 // update region testing
@@ -562,29 +618,32 @@ wxWindow *wxWindowBase::FindWindow( const wxString& name )
 // dialog oriented functions
 // ----------------------------------------------------------------------------
 
 // dialog oriented functions
 // ----------------------------------------------------------------------------
 
-void wxWindowBase::MakeModal(bool modal)
+void wxWindowBase::MakeModal(bool WXUNUSED(modal))
 {
 {
-    wxFAIL_MSG("TODO");
+    wxFAIL_MSG(_T("TODO"));
 }
 
 bool wxWindowBase::Validate()
 {
 }
 
 bool wxWindowBase::Validate()
 {
+#if wxUSE_VALIDATORS
     wxWindowList::Node *node;
     for ( node = m_children.GetFirst(); node; node = node->GetNext() )
     {
         wxWindowBase *child = node->GetData();
         wxValidator *validator = child->GetValidator();
     wxWindowList::Node *node;
     for ( node = m_children.GetFirst(); node; node = node->GetNext() )
     {
         wxWindowBase *child = node->GetData();
         wxValidator *validator = child->GetValidator();
-        if ( validator && validator->Validate(this) )
+        if ( validator && !validator->Validate((wxWindow *)this) )
         {
             return FALSE;
         }
     }
         {
             return FALSE;
         }
     }
+#endif // wxUSE_VALIDATORS
 
     return TRUE;
 }
 
 bool wxWindowBase::TransferDataToWindow()
 {
 
     return TRUE;
 }
 
 bool wxWindowBase::TransferDataToWindow()
 {
+#if wxUSE_VALIDATORS
     wxWindowList::Node *node;
     for ( node = m_children.GetFirst(); node; node = node->GetNext() )
     {
     wxWindowList::Node *node;
     for ( node = m_children.GetFirst(); node; node = node->GetNext() )
     {
@@ -602,12 +661,14 @@ bool wxWindowBase::TransferDataToWindow()
             return FALSE;
         }
     }
             return FALSE;
         }
     }
+#endif // wxUSE_VALIDATORS
 
     return TRUE;
 }
 
 bool wxWindowBase::TransferDataFromWindow()
 {
 
     return TRUE;
 }
 
 bool wxWindowBase::TransferDataFromWindow()
 {
+#if wxUSE_VALIDATORS
     wxWindowList::Node *node;
     for ( node = m_children.GetFirst(); node; node = node->GetNext() )
     {
     wxWindowList::Node *node;
     for ( node = m_children.GetFirst(); node; node = node->GetNext() )
     {
@@ -618,6 +679,7 @@ bool wxWindowBase::TransferDataFromWindow()
             return FALSE;
         }
     }
             return FALSE;
         }
     }
+#endif // wxUSE_VALIDATORS
 
     return TRUE;
 }
 
     return TRUE;
 }
@@ -1100,19 +1162,21 @@ void wxWindowBase::UpdateWindowUI()
             if ( event.GetSetText() && IsKindOf(CLASSINFO(wxControl)) )
                 ((wxControl*)this)->SetLabel(event.GetText());
 
             if ( event.GetSetText() && IsKindOf(CLASSINFO(wxControl)) )
                 ((wxControl*)this)->SetLabel(event.GetText());
 
+#if wxUSE_CHECKBOX
             if ( IsKindOf(CLASSINFO(wxCheckBox)) )
             {
                 if ( event.GetSetChecked() )
                     ((wxCheckBox *)this)->SetValue(event.GetChecked());
             }
             if ( IsKindOf(CLASSINFO(wxCheckBox)) )
             {
                 if ( event.GetSetChecked() )
                     ((wxCheckBox *)this)->SetValue(event.GetChecked());
             }
-            // TODO No radio buttons in wxGTK yet
-#ifndef __WXGTK__
-            else if ( IsKindOf(CLASSINFO(wxRadioButton)) )
+#endif // wxUSE_CHECKBOX
+
+#if wxUSE_RADIOBUTTON
+            if ( IsKindOf(CLASSINFO(wxRadioButton)) )
             {
                 if ( event.GetSetChecked() )
                     ((wxRadioButton *) this)->SetValue(event.GetChecked());
             }
             {
                 if ( event.GetSetChecked() )
                     ((wxRadioButton *) this)->SetValue(event.GetChecked());
             }
-#endif // !wxGTK
+#endif // wxUSE_RADIOBUTTON
         }
     }
 }
         }
     }
 }