]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/wincmn.cpp
moved OLE files group under MSW files -- this is more logical
[wxWidgets.git] / src / common / wincmn.cpp
index 65fdad6ae3053458280df79c5f4a0fe835e11315..aa805541dab4eed34953bd7f7e5afa5a6d20c4d7 100644 (file)
@@ -38,6 +38,7 @@
     #include "wx/control.h"
     #include "wx/checkbox.h"
     #include "wx/radiobut.h"
+    #include "wx/statbox.h"
     #include "wx/textctrl.h"
     #include "wx/settings.h"
     #include "wx/dialog.h"
 // static data
 // ----------------------------------------------------------------------------
 
+#if defined(__WXPM__)
+int wxWindowBase::ms_lastControlId = 2000;
+#else
 int wxWindowBase::ms_lastControlId = -200;
+#endif
 
 IMPLEMENT_ABSTRACT_CLASS(wxWindowBase, wxEvtHandler)
 
@@ -199,6 +204,17 @@ bool wxWindowBase::CreateBase(wxWindowBase *parent,
     // 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
+    // the user about it
+
+    // if you get this assert, the correct solution is to create the controls
+    // as siblings of the static box
+    wxASSERT_MSG( !parent || !wxDynamicCast(parent, wxStaticBox),
+                  _T("wxStaticBox can't be used as a window parent!") );
+#endif // wxUSE_STATBOX
+
     // generate a new id if the user doesn't care about it
     m_windowId = id == -1 ? NewControlId() : id;
 
@@ -270,7 +286,7 @@ wxWindowBase::~wxWindowBase()
 #endif // wxUSE_CONSTRAINTS
 
     if ( m_containingSizer )
-        m_containingSizer->Remove((wxWindow*)this);
+        m_containingSizer->Detach( (wxWindow*)this );
 
     if ( m_windowSizer )
         delete m_windowSizer;
@@ -364,6 +380,20 @@ void wxWindowBase::Centre(int direction)
             }
         }
 
+        // there is no wxTopLevelWindow under wxMotif yet
+#ifndef __WXMOTIF__
+        // we shouldn't center the dialog on the iconized window: under
+        // Windows, for example, this places it completely off the screen
+        if ( parent )
+        {
+            wxTopLevelWindow *winTop = wxDynamicCast(parent, wxTopLevelWindow);
+            if ( winTop && winTop->IsIconized() )
+            {
+                parent = NULL;
+            }
+        }
+#endif // __WXMOTIF__
+
         // did we find the parent?
         if ( !parent )
         {
@@ -452,6 +482,15 @@ void wxWindowBase::Fit()
     //else: do nothing if we have no children
 }
 
+// fits virtual size (ie. scrolled area etc.) around children
+void wxWindowBase::FitInside()
+{
+    if ( GetChildren().GetCount() > 0 )
+    {
+        SetVirtualSize( GetBestVirtualSize() );
+    }
+}
+
 // return the size best suited for the current window
 wxSize wxWindowBase::DoGetBestSize() const
 {
@@ -575,8 +614,6 @@ void wxWindowBase::SetVirtualSizeHints( int minW, int minH,
     m_maxVirtualWidth = maxW;
     m_minVirtualHeight = minH;
     m_maxVirtualHeight = maxH;
-
-    SetVirtualSize( GetClientSize() );
 }
 
 void wxWindowBase::DoSetVirtualSize( int x, int y )
@@ -708,7 +745,13 @@ bool wxWindowBase::Reparent(wxWindowBase *newParent)
 
 void wxWindowBase::PushEventHandler(wxEvtHandler *handler)
 {
-    handler->SetNextHandler(GetEventHandler());
+    wxEvtHandler *handlerOld = GetEventHandler();
+
+    handler->SetNextHandler(handlerOld);
+
+    if ( handlerOld )
+        GetEventHandler()->SetPreviousHandler(handler);
+
     SetEventHandler(handler);
 }
 
@@ -719,7 +762,11 @@ wxEvtHandler *wxWindowBase::PopEventHandler(bool deleteHandler)
     {
         wxEvtHandler *handlerB = handlerA->GetNextHandler();
         handlerA->SetNextHandler((wxEvtHandler *)NULL);
+
+        if ( handlerB )
+            handlerB->SetPreviousHandler((wxEvtHandler *)NULL);
         SetEventHandler(handlerB);
+
         if ( deleteHandler )
         {
             delete handlerA;
@@ -751,6 +798,10 @@ bool wxWindowBase::RemoveEventHandler(wxEvtHandler *handler)
                 SetEventHandler(handlerNext);
             }
 
+            if ( handlerNext )
+            {
+                handlerNext->SetPreviousHandler ( handlerPrev );
+            }
             handler->SetNextHandler(NULL);
 
             return TRUE;
@@ -1126,7 +1177,9 @@ bool wxWindowBase::TransferDataToWindow()
         if ( validator && !validator->TransferToWindow() )
         {
             wxLogWarning(_("Could not transfer data to window"));
+#if wxUSE_LOG
             wxLog::FlushActive();
+#endif // wxUSE_LOG
 
             return FALSE;
         }
@@ -1725,10 +1778,16 @@ void wxWindowBase::UpdateWindowUI()
 #if wxUSE_TEXTCTRL
                 wxTextCtrl *text = wxDynamicCast(control, wxTextCtrl);
                 if ( text )
-                    text->SetValue(event.GetText());
+                {
+                       if ( event.GetText() != text->GetValue() )
+                       text->SetValue(event.GetText());
+                }
                 else
 #endif // wxUSE_TEXTCTRL
-                    control->SetLabel(event.GetText());
+                               {
+                                       if ( event.GetText() != control->GetLabel() )
+                       control->SetLabel(event.GetText());
+                }
             }
         }
 
@@ -1827,27 +1886,27 @@ void wxWindowBase::OnMiddleClick( wxMouseEvent& event )
 
         switch ( wxGetOsVersion() )
         {
-            case wxMOTIF_X:     port = _T("Motif"); break;
+            case wxMOTIF_X:     port += _T("Motif"); break;
             case wxMAC:
-            case wxMAC_DARWIN:  port = _T("Mac"); break;
-            case wxBEOS:        port = _T("BeOS"); break;
+            case wxMAC_DARWIN:  port += _T("Mac"); break;
+            case wxBEOS:        port += _T("BeOS"); break;
             case wxGTK:
             case wxGTK_WIN32:
             case wxGTK_OS2:
-            case wxGTK_BEOS:    port = _T("GTK"); break;
+            case wxGTK_BEOS:    port += _T("GTK"); break;
             case wxWINDOWS:
             case wxPENWINDOWS:
             case wxWINDOWS_NT:
             case wxWIN32S:
             case wxWIN95:
-            case wxWIN386:      port = _T("MS Windows"); break;
+            case wxWIN386:      port += _T("MS Windows"); break;
             case wxMGL_UNIX:
             case wxMGL_X:
             case wxMGL_WIN32:
-            case wxMGL_OS2:     port = _T("MGL"); break;
+            case wxMGL_OS2:     port += _T("MGL"); break;
             case wxWINDOWS_OS2:
-            case wxOS2_PM:      port = _T("OS/2"); break;
-            default:            port = _T("unknown"); break;
+            case wxOS2_PM:      port += _T("OS/2"); break;
+            default:            port += _T("unknown"); break;
         }
 
         wxMessageBox(wxString::Format(
@@ -1938,13 +1997,13 @@ struct WXDLLEXPORT wxWindowNext
 
 void wxWindowBase::CaptureMouse()
 {
-    wxLogTrace(_T("mousecapture"), _T("CaptureMouse(0x%08x)"), this);
+    wxLogTrace(_T("mousecapture"), _T("CaptureMouse(%p)"), this);
 
     wxWindow *winOld = GetCapture();
     if ( winOld )
     {
         ((wxWindowBase*) winOld)->DoReleaseMouse();
-       
+
         // save it on stack
         wxWindowNext *item = new wxWindowNext;
         item->win = winOld;
@@ -1958,16 +2017,16 @@ void wxWindowBase::CaptureMouse()
 
 void wxWindowBase::ReleaseMouse()
 {
-    wxLogTrace(_T("mousecapture"), _T("ReleaseMouse(0x%08x)"), this);
+    wxLogTrace(_T("mousecapture"), _T("ReleaseMouse(%p)"), this);
 
-    wxASSERT_MSG( GetCapture() == this, wxT("attempt to release mouse, but this window hasn't captured it") )
+    wxASSERT_MSG( GetCapture() == this, wxT("attempt to release mouse, but this window hasn't captured it") );
 
     DoReleaseMouse();
 
     if ( ms_winCaptureNext )
     {
         ((wxWindowBase*)ms_winCaptureNext->win)->DoCaptureMouse();
-       
+
         wxWindowNext *item = ms_winCaptureNext;
         ms_winCaptureNext = item->next;
         delete item;
@@ -1975,7 +2034,7 @@ void wxWindowBase::ReleaseMouse()
     //else: stack is empty, no previous capture
 
     wxLogTrace(_T("mousecapture"),
-               _T("After ReleaseMouse() mouse is captured by 0x%08x"),
+               _T("After ReleaseMouse() mouse is captured by %p"),
                GetCapture());
 }
 
@@ -1991,3 +2050,4 @@ wxWindow* wxGetTopLevelParent(wxWindow *win)
     return win;
 }
 
+// vi:sts=4:sw=4:et