]> git.saurik.com Git - wxWidgets.git/blobdiff - contrib/src/fl/frmview.cpp
fix evaluation order bug (patch 1158099)
[wxWidgets.git] / contrib / src / fl / frmview.cpp
index 8b6763d4d3b69348c0e44fa47929ddd28c00da94..22e59c57ad46c234655276e4c5a00ab9dbce9145 100644 (file)
@@ -1,12 +1,12 @@
 /////////////////////////////////////////////////////////////////////////////
-// Name:        No names yet.
-// Purpose:     Contrib. demo
+// Name:        frmview.cpp
+// Purpose:     wxFrameView implementation. NOT USED IN FL.
 // Author:      Aleksandras Gluchovas
 // Modified by:
 // Created:     02/01/99
 // RCS-ID:      $Id$
 // Copyright:   (c) Aleksandras Gluchovas
-// Licence:    wxWindows license
+// Licence:     wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
  
 #ifdef __GNUG__
 
 BEGIN_EVENT_TABLE( wxFrameView, wxEvtHandler )
 
-       EVT_IDLE( wxFrameView::OnIdle )
+    EVT_IDLE( wxFrameView::OnIdle )
 
 END_EVENT_TABLE()
 
 void wxFrameView::OnIdle( wxIdleEvent& event)
 {
-       event.Skip();
+    event.Skip();
 
-       if ( mDoToolUpdates )
-       {
-               int o = 0;  //glt
-               ++o;
-
-               // TBD::
-       }
+    if ( mDoToolUpdates )
+    {
+        // TBD::
+    }
 }
 
 /*** public methods ***/
 
 wxFrameView::wxFrameView()
 
-       : mpLayout( NULL ),
-         mpFrameMgr( NULL )
+    : mpLayout( NULL ),
+      mpFrameMgr( NULL )
 {}
 
 wxFrameView::~wxFrameView()
 {
-       if ( mpLayout ) delete mpLayout;
+    if ( mpLayout ) delete mpLayout;
 }
 
 wxFrame* wxFrameView::GetParentFrame()
 {
-       return mpFrameMgr->GetParentFrame();
+    return mpFrameMgr->GetParentFrame();
 }
 
 wxWindow* wxFrameView::GetClientWindow()
 {
-       return mpFrameMgr->GetClientWindow();
+    return mpFrameMgr->GetClientWindow();
 }
 
 void wxFrameView::Activate()
 {
-       mpFrameMgr->ActivateView( this );
+    mpFrameMgr->ActivateView( this );
 }
 
 void wxFrameView::Deactivate()
 {
-       mpFrameMgr->DeactivateCurrentView();
+    mpFrameMgr->DeactivateCurrentView();
 }
 
 void wxFrameView::CreateLayout()
 {
-       mpLayout = new wxFrameLayout( GetParentFrame(), mpFrameMgr->GetClientWindow(), FALSE );
+    mpLayout = new wxFrameLayout( GetParentFrame(), mpFrameMgr->GetClientWindow(), false );
 }
 
 wxFrameLayout* wxFrameView::GetLayout()
 {
-       return mpLayout;
+    return mpLayout;
 }
 
 void wxFrameView::SetToolUpdates( bool doToolUpdates )
 {
-       mDoToolUpdates = doToolUpdates;
+    mDoToolUpdates = doToolUpdates;
 }
 
 void wxFrameView::SetLayout( wxFrameLayout* pLayout )
 {
-       if ( mpLayout ) delete mpLayout;
+    if ( mpLayout ) delete mpLayout;
 
-       mpLayout = pLayout;
+    mpLayout = pLayout;
 }
 
 wxFrameManager& wxFrameView::GetFrameManager()
 {
-       return *mpFrameMgr;
+    return *mpFrameMgr;
 }
 
 void wxFrameView::RegisterMenu( const wxString& topMenuName )
 {
-       mTopMenus.Add( topMenuName );
+    mTopMenus.Add( topMenuName );
 }
 
 #if 0
@@ -121,298 +118,297 @@ void wxFrameView::RegisterMenu( const wxString& topMenuName )
 
 class wxFrameViewSerializer : public wxEvtHandlerSerializer
 {
-       DECLARE_SERIALIZER_CLASS( wxFrameViewSerializer );
+    DECLARE_SERIALIZER_CLASS( wxFrameViewSerializer );
 
-       static void Serialize( wxObject* pObj, wxObjectStorage& store );
+    static void Serialize( wxObject* pObj, wxObjectStorage& store );
 };
 
 IMPLEMENT_SERIALIZER_CLASS( wxFrameView, 
-                                                       wxFrameViewSerializer,
-                                                       wxFrameViewSerializer::Serialize,
-                                                       NO_CLASS_INIT )
+                            wxFrameViewSerializer,
+                            wxFrameViewSerializer::Serialize,
+                            NO_CLASS_INIT )
 
 void wxFrameViewSerializer::Serialize( wxObject* pObj, wxObjectStorage& store )
 {
-       // wxFrameViewSerializer is a kind of wxEvtHandler - peform serialization of
-       // the base class first
+    // wxFrameViewSerializer is a kind of wxEvtHandler - peform serialization of
+    // the base class first
 
-       info.SerializeInherited( pObj, store );
+    info.SerializeInherited( pObj, store );
 
-       wxFrameView* pView = (wxFrameView*)pObj;
+    wxFrameView* pView = (wxFrameView*)pObj;
 
-       store.XchgObjPtr( (wxObject**) &pView->mpFrameMgr );
-       store.XchgObjPtr( (wxObject**) &pView->mpLayout );
-       store.XchgBool  ( pView->mDoToolUpdates );
+    store.XchgObjPtr( (wxObject**) &pView->mpFrameMgr );
+    store.XchgObjPtr( (wxObject**) &pView->mpLayout );
+    store.XchgBool  ( pView->mDoToolUpdates );
 
-       // serialize members in derived classes
+    // serialize members in derived classes
 
-       pView->OnSerialize( store );
+    pView->OnSerialize( store );
 }
 
 #endif
 
 /***** Implementation for class wxFrameManager *****/
 
-void wxFrameManager::DoSerialize( wxObjectStorage& store )
+void wxFrameManager::DoSerialize( wxObjectStorage& WXUNUSED(store) )
 {
 #if 0
-       store.AddInitialRef( mpFrameWnd );
-       store.AddInitialRef( this );
-       if ( mpClientWnd ) store.AddInitialRef( mpClientWnd );
+    store.AddInitialRef( mpFrameWnd );
+    store.AddInitialRef( this );
+    if ( mpClientWnd ) store.AddInitialRef( mpClientWnd );
 
-       store.XchgObj( (wxObject*) &mViews );
-       store.XchgInt( mActiveViewNo );
+    store.XchgObj( (wxObject*) &mViews );
+    store.XchgInt( mActiveViewNo );
 
-       store.Finalize(); // finish serialization
+    store.Finalize(); // finish serialization
 #endif 
 }
 
 void wxFrameManager::DestroyViews()
 {
-       DeactivateCurrentView();
+    DeactivateCurrentView();
 
-       wxNode* pNode = mViews.First();
+    wxObjectList::compatibility_iterator pNode = mViews.GetFirst();
 
-       while( pNode )
-       {
-               delete (wxFrameView*)pNode->Data();
+    while ( pNode )
+    {
+        delete (wxFrameView*)pNode->GetData();
 
-               pNode = pNode->Next();
-       }
+        pNode = pNode->GetNext();
+    }
 
-       if ( mActiveViewNo != -1 && GetParentFrame() )
+    if ( mActiveViewNo != -1 && GetParentFrame() )
 
-               GetParentFrame()->SetNextHandler( NULL );
+        GetParentFrame()->SetNextHandler( NULL );
 }
 
 int wxFrameManager::GetViewNo( wxFrameView* pView )
 {
-       wxNode* pNode = mViews.First();
-       int n = 0;
+    wxObjectList::compatibility_iterator pNode = mViews.GetFirst();
+    int n = 0;
 
-       while( pNode )
-       {
-               if ( (wxFrameView*)pNode->Data() == pView )
+    while ( pNode )
+    {
+        if ( (wxFrameView*)pNode->GetData() == pView )
 
-                       return n;
+            return n;
 
-               ++n;
-               pNode = pNode->Next();
-       }
+        ++n;
+        pNode = pNode->GetNext();
+    }
 
-       return -1;
+    return -1;
 }
 
 void wxFrameManager::EnableMenusForView( wxFrameView* pView, bool enable )
 {
-       wxMenuBar* pMenuBar = GetParentFrame()->GetMenuBar();
-       int count = pMenuBar->GetMenuCount();
-
-       if ( !pMenuBar ) return;
+    wxMenuBar* pMenuBar = GetParentFrame()->GetMenuBar();
+    int count = pMenuBar->GetMenuCount();
 
-       wxStringListNode* pNode = pView->mTopMenus.GetFirst();
+    if ( !pMenuBar )
+        return;
 
-       while( pNode )
-       {
-               for( int i = 0; i != count; ++i )
-               {
-                       if ( pMenuBar->GetMenu(i)->GetTitle() == pNode->GetData() )
+    wxStringList::compatibility_iterator pNode = pView->mTopMenus.GetFirst();
 
-                               pMenuBar->EnableTop( i, enable );
-               }
+    int i;
+    while ( pNode )
+    {
+        for ( i = 0; i != count; ++i )
+        {
+            if ( pMenuBar->GetMenu(i)->GetTitle() == pNode->GetData() )
+                pMenuBar->EnableTop( i, enable );
+        }
 
-               pNode = pNode->GetNext();
-       }
+        pNode = pNode->GetNext();
+    }
 }
 
 void wxFrameManager::SyncAllMenus()
 {
-       wxNode* pNode = mViews.First();
-       int i = 0;
+    wxObjectList::compatibility_iterator pNode = mViews.GetFirst();
+    int i = 0;
 
-       while( pNode )
-       {
-               if ( i != mActiveViewNo )
+    while ( pNode )
+    {
+        if ( i != mActiveViewNo )
 
-                       EnableMenusForView( (wxFrameView*)pNode->GetData(), FALSE );
+            EnableMenusForView( (wxFrameView*)pNode->GetData(), false );
 
-               pNode = pNode->Next();
-       }
+        pNode = pNode->GetNext();
+    }
 
-       EnableMenusForView( GetView( mActiveViewNo ), TRUE );
+    EnableMenusForView( GetView( mActiveViewNo ), true );
 }
 
 /*** public methods ***/
 
 wxFrameManager::wxFrameManager()
 
-       : mpFrameWnd( NULL  ),
-         mActiveViewNo( -1 ),
-         mpClientWnd( NULL )
+    : mpFrameWnd( NULL  ),
+      mActiveViewNo( -1 ),
+      mpClientWnd( NULL )
 {
 }
 
 wxFrameManager::~wxFrameManager()
 {
-       SaveViewsNow();
-       DestroyViews();
+    SaveViewsNow();
+    DestroyViews();
 }
 
 void wxFrameManager::Init( wxWindow* pMainFrame, const wxString& settingsFile )
 {
-       mSettingsFile = settingsFile;
-       mpFrameWnd    = pMainFrame;
+    mSettingsFile = settingsFile;
+    mpFrameWnd    = pMainFrame;
 
-       wxNode* pNode = mViews.First();
+    wxObjectList::compatibility_iterator pNode = mViews.GetFirst();
 
-       while( pNode )
-       {
-               wxFrameView* pView = (wxFrameView*)pNode->Data();
+    while ( pNode )
+    {
+        wxFrameView* pView = (wxFrameView*)pNode->GetData();
 
-               pView->OnInit();
-               pView->OnInitMenus();
+        pView->OnInit();
+        pView->OnInitMenus();
 
-               pNode = pNode->Next();
-       }
+        pNode = pNode->GetNext();
+    }
 
-       if ( !ReloadViews() )
-       {
-               // if loading of settings file failed (e.g. was not found), 
-               // do recreation of items in each view
+    if ( !ReloadViews() )
+    {
+        // if loading of settings file failed (e.g. was not found), 
+        // do recreation of items in each view
 
-               pNode = mViews.First();
+        pNode = mViews.GetFirst();
 
-               while( pNode )
-               {
-                       wxFrameView* pView = (wxFrameView*)pNode->Data();
+        while ( pNode )
+        {
+            wxFrameView* pView = (wxFrameView*)pNode->GetData();
 
-                       pView->OnRecreate();
+            pView->OnRecreate();
 
-                       pNode = pNode->Next();
-               }
-       }
+            pNode = pNode->GetNext();
+        }
+    }
 
-       if ( mActiveViewNo >= mViews.Number() )
-       
-               mActiveViewNo = -1;
+    if ( mActiveViewNo >= (int)mViews.GetCount() )
+        mActiveViewNo = -1;
 
-       ActivateView( GetView( ( mActiveViewNo == -1 ) ? 0 : mActiveViewNo ) );
+    ActivateView( GetView( ( mActiveViewNo == -1 ) ? 0 : mActiveViewNo ) );
 
-       SyncAllMenus();
+    SyncAllMenus();
 }
 
 void wxFrameManager::AddView( wxFrameView* pFrmView )
 {
-       mViews.Append( pFrmView );
+    mViews.Append( pFrmView );
 
-       pFrmView->mpFrameMgr = this; // back ref.
+    pFrmView->mpFrameMgr = this; // back ref.
 }
 
-void wxFrameManager::RemoveView( wxFrameView* pFrmView )
+void wxFrameManager::RemoveView( wxFrameView* WXUNUSED(pFrmView) )
 {
-       // TBD::
-       int avoidCompilerWarning = 0;
-       wxASSERT(avoidCompilerWarning);
+    // TBD::
+    wxFAIL_MSG( _T("wxFrameManager::RemoveView() has not been implemented yet.") );
 }
 
 int wxFrameManager::GetActiveViewNo()
 {
-       return mActiveViewNo;
+    return mActiveViewNo;
 }
 
 wxFrameView* wxFrameManager::GetActiveView()
 {
-       wxNode* pNode = mViews.Nth( mActiveViewNo );
+    wxObjectList::compatibility_iterator pNode = mViews.Item( mActiveViewNo );
 
-       if ( pNode ) return (wxFrameView*)pNode->Data();
-                       else return NULL;
+    if ( pNode ) return (wxFrameView*)pNode->GetData();
+            else return NULL;
 }
 
-wxNode* wxFrameManager::GetActiveViewNode()
+wxObjectList::compatibility_iterator wxFrameManager::GetActiveViewNode()
 {
-       return mViews.Nth( mActiveViewNo );
+    return mViews.Item( mActiveViewNo );
 }
 
 wxFrame* wxFrameManager::GetParentFrame()
 {
-       return ((wxFrame*)mpFrameWnd);
+    return ((wxFrame*)mpFrameWnd);
 }
 
 wxWindow* wxFrameManager::GetParentWindow()
 {
-       return mpFrameWnd;
+    return mpFrameWnd;
 }
 
 wxFrameView* wxFrameManager::GetView( int viewNo )
 {
-       wxNode* pNode = mViews.Nth( viewNo );
+    wxObjectList::compatibility_iterator pNode = mViews.Item( viewNo );
 
-       if ( pNode ) return (wxFrameView*)pNode->Data();
-                       else return NULL;
+    if ( pNode ) return (wxFrameView*)pNode->GetData();
+            else return NULL;
 }
 
 void wxFrameManager::ActivateView( int viewNo )
 {
-       ActivateView( GetView( viewNo ) );
+    ActivateView( GetView( viewNo ) );
 }
 
 void wxFrameManager::ActivateView( wxFrameView* pFrmView )
 {
-       DeactivateCurrentView();
+    DeactivateCurrentView();
 
-       mActiveViewNo = GetViewNo( pFrmView );
+    mActiveViewNo = GetViewNo( pFrmView );
 
-       if ( pFrmView->mpLayout )
+    if ( pFrmView->mpLayout )
 
-               pFrmView->mpLayout->Activate();
+        pFrmView->mpLayout->Activate();
 
-       // FIXME:: we would have used PushEventHandler(),
-       //         but wxFrame bypasses attached handlers when
-       //         handling wxCommand events!
+    // FIXME:: we would have used PushEventHandler(),
+    //         but wxFrame bypasses attached handlers when
+    //         handling wxCommand events!
 
-       GetParentFrame()->PushEventHandler( pFrmView );
+    GetParentFrame()->PushEventHandler( pFrmView );
 
-       EnableMenusForView( pFrmView, TRUE );
+    EnableMenusForView( pFrmView, true );
 }
 
 void wxFrameManager::SetClinetWindow( wxWindow* pFrameClient )
 {
-       if ( mpClientWnd ) mpClientWnd->Destroy();
+    if ( mpClientWnd ) mpClientWnd->Destroy();
 
-       mpClientWnd = pFrameClient;
+    mpClientWnd = pFrameClient;
 }
 
 wxWindow* wxFrameManager::GetClientWindow()
 {
-       if ( !mpClientWnd )
+    if ( !mpClientWnd )
 
-               mpClientWnd = new wxWindow( GetParentFrame(), -1 );
+        mpClientWnd = new wxWindow( GetParentFrame(), -1 );
 
-       return mpClientWnd;
+    return mpClientWnd;
 }
 
 void wxFrameManager::DeactivateCurrentView()
 {
-       if ( mActiveViewNo == -1 ) return;
-
-       wxFrameView* pView = GetActiveView();
+    if ( mActiveViewNo == -1 )
+        return;
 
-       // FOR NOW::
-       wxASSERT( GetParentFrame()->GetEventHandler() == pView );
+    wxFrameView* pView = GetActiveView();
 
-       GetParentFrame()->PopEventHandler();
+    // FOR NOW::
+    wxASSERT( GetParentFrame()->GetEventHandler() == pView );
 
-       if ( pView->mpLayout )
+    GetParentFrame()->PopEventHandler();
 
-               pView->mpLayout->Deactivate();
+    if ( pView->mpLayout )
+        pView->mpLayout->Deactivate();
 
-       EnableMenusForView( pView, FALSE );
+    EnableMenusForView( pView, false );
 }
 
 void wxFrameManager::SaveViewsNow()
 {
 #if 0
-       if ( mSettingsFile == "" ) return;
+    if ( mSettingsFile == "" ) return;
 
     wxIOStreamWrapper stm;
     stm.CreateForOutput( mSettingsFile );
@@ -424,15 +420,14 @@ void wxFrameManager::SaveViewsNow()
 
 bool wxFrameManager::ReloadViews()
 {
-       return FALSE;
+    return false;
 
-       // TBD: ????
+    // TBD: ????
 #if 0
-       if ( mSettingsFile == "" || !wxFileExists( mSettingsFile ) ) 
-               
-               return FALSE;
+    if ( mSettingsFile == "" || !wxFileExists( mSettingsFile ) ) 
+        return false;
 
-       DestroyViews();
+    DestroyViews();
 
     wxIOStreamWrapper stm;
     stm.CreateForInput( mSettingsFile );
@@ -440,12 +435,12 @@ bool wxFrameManager::ReloadViews()
     mStore.SetDataStream( stm );
     DoSerialize( mStore );
 
-       return TRUE;
+    return true;
 #endif
 }
 
 bool wxFrameManager::ViewsAreLoaded()
 {
-       return ( mViews.Number() != 0 );
+    return ( mViews.GetCount() != 0 );
 }