diff options
author | Joseph Powers <jpowers27@cox.net> | 2011-02-18 18:20:54 -0800 |
---|---|---|
committer | Joseph Powers <jpowers27@cox.net> | 2011-02-18 18:20:54 -0800 |
commit | 92afab4044d82feceb4de506ee83d23489ff2df9 (patch) | |
tree | e63caa5b6c83c69662e54828c8b5827af66b5922 | |
parent | 4e5ef3598e0d7e9ce82c93af6b9f2762ad220fe5 (diff) |
Remove DECLARE_LIST( ImplStatusItemList, ImplStatusItem* )
-rw-r--r-- | vcl/inc/vcl/status.hxx | 4 | ||||
-rw-r--r-- | vcl/source/window/status.cxx | 229 |
2 files changed, 100 insertions, 133 deletions
diff --git a/vcl/inc/vcl/status.hxx b/vcl/inc/vcl/status.hxx index 7d5a9a1c9f2d..9df46e99d14b 100644 --- a/vcl/inc/vcl/status.hxx +++ b/vcl/inc/vcl/status.hxx @@ -32,8 +32,10 @@ #include <vcl/sv.h> #include <vcl/dllapi.h> #include <vcl/window.hxx> +#include <vector> -class ImplStatusItemList; +struct ImplStatusItem; +typedef ::std::vector< ImplStatusItem* > ImplStatusItemList; // -------------------- // - Progress-Ausgabe - diff --git a/vcl/source/window/status.cxx b/vcl/source/window/status.cxx index dc0905c8a2de..924cb837545c 100644 --- a/vcl/source/window/status.cxx +++ b/vcl/source/window/status.cxx @@ -28,7 +28,6 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_vcl.hxx" -#include <tools/list.hxx> #include <tools/debug.hxx> #include <tools/rc.h> @@ -95,8 +94,6 @@ struct ImplStatusItem XubString maCommand; }; -DECLARE_LIST( ImplStatusItemList, ImplStatusItem* ) - // ======================================================================= inline long ImplCalcProgessWidth( USHORT nMax, long nSize ) @@ -196,18 +193,13 @@ StatusBar::StatusBar( Window* pParent, const ResId& rResId ) : StatusBar::~StatusBar() { // Alle Items loeschen - ImplStatusItem* pItem = mpItemList->First(); - while ( pItem ) - { - delete pItem; - pItem = mpItemList->Next(); + for ( size_t i = 0, n = mpItemList->size(); i < n; ++i ) { + delete (*mpItemList)[ i ]; } - delete mpItemList; // VirtualDevice loeschen delete mpImplData->mpVirDev; - delete mpImplData; } @@ -279,19 +271,17 @@ void StatusBar::ImplFormat() // Breiten zusammenrechnen mnItemsWidth = STATUSBAR_OFFSET_X; long nOffset = 0; - pItem = mpItemList->First(); - while ( pItem ) - { + for ( size_t i = 0, n = mpItemList->size(); i < n; ++i ) { + pItem = (*mpItemList)[ i ]; if ( pItem->mbVisible ) { - if ( pItem->mnBits & SIB_AUTOSIZE ) + if ( pItem->mnBits & SIB_AUTOSIZE ) { nAutoSizeItems++; + } mnItemsWidth += pItem->mnWidth + nOffset; nOffset = pItem->mnOffset; } - - pItem = mpItemList->Next(); } if ( GetStyle() & WB_RIGHT ) @@ -321,28 +311,22 @@ void StatusBar::ImplFormat() nX = STATUSBAR_OFFSET_X; } - pItem = mpItemList->First(); - while ( pItem ) - { - if ( pItem->mbVisible ) - { - if ( pItem->mnBits & SIB_AUTOSIZE ) - { + for ( size_t i = 0, n = mpItemList->size(); i < n; ++i ) { + pItem = (*mpItemList)[ i ]; + if ( pItem->mbVisible ) { + if ( pItem->mnBits & SIB_AUTOSIZE ) { pItem->mnExtraWidth = nExtraWidth; - if ( nExtraWidth2 ) - { + if ( nExtraWidth2 ) { pItem->mnExtraWidth++; nExtraWidth2--; } - } - else + } else { pItem->mnExtraWidth = 0; + } pItem->mnX = nX; nX += pItem->mnWidth + pItem->mnExtraWidth + pItem->mnOffset; } - - pItem = mpItemList->Next(); } mbFormat = FALSE; @@ -354,7 +338,7 @@ Rectangle StatusBar::ImplGetItemRectPos( USHORT nPos ) const { Rectangle aRect; ImplStatusItem* pItem; - pItem = mpItemList->GetObject( nPos ); + pItem = ( nPos < mpItemList->size() ) ? (*mpItemList)[ nPos ] : NULL; if ( pItem ) { if ( pItem->mbVisible ) @@ -377,13 +361,13 @@ USHORT StatusBar::ImplGetFirstVisiblePos() const { ImplStatusItem* pItem; - for( USHORT nPos = 0; nPos < mpItemList->Count(); nPos++ ) + for( size_t nPos = 0; nPos < mpItemList->size(); nPos++ ) { - pItem = mpItemList->GetObject( nPos ); + pItem = (*mpItemList)[ nPos ]; if ( pItem ) { if ( pItem->mbVisible ) - return nPos; + return USHORT(nPos); } } @@ -437,7 +421,7 @@ void StatusBar::ImplDrawItem( BOOL bOffScreen, USHORT nPos, BOOL bDrawText, BOOL return; // Ausgabebereich berechnen - ImplStatusItem* pItem = mpItemList->GetObject( nPos ); + ImplStatusItem* pItem = (*mpItemList)[ nPos ]; long nW = mpImplData->mnItemBorderWidth + 1; Rectangle aTextRect( aRect.Left()+nW, aRect.Top()+nW, aRect.Right()-nW, aRect.Bottom()-nW ); @@ -740,14 +724,13 @@ void StatusBar::MouseButtonDown( const MouseEvent& rMEvt ) if ( mbVisibleItems ) { Point aMousePos = rMEvt.GetPosPixel(); - USHORT i = 0; // Item suchen, das geklickt wurde - ImplStatusItem* pItem = mpItemList->First(); - while ( pItem ) + for ( size_t i = 0; i < mpItemList->size(); ++i ) { + ImplStatusItem* pItem = (*mpItemList)[ i ]; // Ist es dieses Item - if ( ImplGetItemRectPos( i ).IsInside( aMousePos ) ) + if ( ImplGetItemRectPos( USHORT(i) ).IsInside( aMousePos ) ) { mnCurItemId = pItem->mnId; if ( rMEvt.GetClicks() == 2 ) @@ -759,9 +742,6 @@ void StatusBar::MouseButtonDown( const MouseEvent& rMEvt ) // Item wurde gefunden return; } - - i++; - pItem = mpItemList->Next(); } } @@ -780,7 +760,7 @@ void StatusBar::Paint( const Rectangle& ) if ( mbFormat ) ImplFormat(); - USHORT nItemCount = (USHORT)mpItemList->Count(); + USHORT nItemCount = USHORT( mpItemList->size() ); if ( mbProgressMode ) ImplDrawProgress( TRUE, 0, mnPercent ); @@ -959,22 +939,23 @@ void StatusBar::DataChanged( const DataChangedEvent& rDCEvt ) { Window::DataChanged( rDCEvt ); - if ( (rDCEvt.GetType() == DATACHANGED_DISPLAY) || - (rDCEvt.GetType() == DATACHANGED_FONTS) || - (rDCEvt.GetType() == DATACHANGED_FONTSUBSTITUTION) || - ((rDCEvt.GetType() == DATACHANGED_SETTINGS) && - (rDCEvt.GetFlags() & SETTINGS_STYLE)) ) + if ( (rDCEvt.GetType() == DATACHANGED_DISPLAY ) + || (rDCEvt.GetType() == DATACHANGED_FONTS ) + || (rDCEvt.GetType() == DATACHANGED_FONTSUBSTITUTION) + || ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) + && (rDCEvt.GetFlags() & SETTINGS_STYLE ) + ) + ) { mbFormat = TRUE; ImplInitSettings( TRUE, TRUE, TRUE ); - ImplStatusItem* pItem = mpItemList->First(); long nFudge = GetTextHeight() / 4; - while ( pItem ) + for ( size_t i = 0, n = mpItemList->size(); i < n; ++i ) { + ImplStatusItem* pItem = (*mpItemList)[ i ]; long nWidth = GetTextWidth( pItem->maText ) + nFudge; if( nWidth > pItem->mnWidth + STATUSBAR_OFFSET ) pItem->mnWidth = nWidth + STATUSBAR_OFFSET; - pItem = mpItemList->Next(); } Size aSize = GetSizePixel(); // do not disturb current width, since @@ -1035,7 +1016,11 @@ void StatusBar::InsertItem( USHORT nItemId, ULONG nWidth, pItem->mbVisible = TRUE; // Item in die Liste einfuegen - mpItemList->Insert( pItem, nPos ); + if ( nPos < mpItemList->size() ) { + mpItemList->insert( mpItemList->begin() + nPos, pItem ); + } else { + mpItemList->push_back( pItem ); + } mbFormat = TRUE; if ( ImplIsItemUpdate() ) @@ -1051,8 +1036,8 @@ void StatusBar::RemoveItem( USHORT nItemId ) USHORT nPos = GetItemPos( nItemId ); if ( nPos != STATUSBAR_ITEM_NOTFOUND ) { - ImplStatusItem* pItem = mpItemList->Remove( nPos ); - delete pItem; + delete (*mpItemList)[ nPos ]; + mpItemList->erase( mpItemList->begin() + nPos ); mbFormat = TRUE; if ( ImplIsItemUpdate() ) @@ -1070,7 +1055,7 @@ void StatusBar::ShowItem( USHORT nItemId ) if ( nPos != STATUSBAR_ITEM_NOTFOUND ) { - ImplStatusItem* pItem = mpItemList->GetObject( nPos ); + ImplStatusItem* pItem = (*mpItemList)[ nPos ]; if ( !pItem->mbVisible ) { pItem->mbVisible = TRUE; @@ -1092,7 +1077,7 @@ void StatusBar::HideItem( USHORT nItemId ) if ( nPos != STATUSBAR_ITEM_NOTFOUND ) { - ImplStatusItem* pItem = mpItemList->GetObject( nPos ); + ImplStatusItem* pItem = (*mpItemList)[ nPos ]; if ( pItem->mbVisible ) { pItem->mbVisible = FALSE; @@ -1113,7 +1098,7 @@ BOOL StatusBar::IsItemVisible( USHORT nItemId ) const USHORT nPos = GetItemPos( nItemId ); if ( nPos != STATUSBAR_ITEM_NOTFOUND ) - return mpItemList->GetObject( nPos )->mbVisible; + return (*mpItemList)[ nPos ]->mbVisible; else return FALSE; } @@ -1151,24 +1136,14 @@ void StatusBar::HideItems() void StatusBar::CopyItems( const StatusBar& rStatusBar ) { // Alle Items entfernen - ImplStatusItem* pItem = mpItemList->First(); - while ( pItem ) - { - delete pItem; - pItem = mpItemList->Next(); + for ( size_t i = 0, n = mpItemList->size(); i < n; ++i ) { + delete (*mpItemList)[ i ]; } - - // Items aus der Liste loeschen - mpItemList->Clear(); + mpItemList->clear(); // Items kopieren - ULONG i = 0; - pItem = rStatusBar.mpItemList->GetObject( i ); - while ( pItem ) - { - mpItemList->Insert( new ImplStatusItem( *pItem ), LIST_APPEND ); - i++; - pItem = rStatusBar.mpItemList->GetObject( i ); + for ( size_t i = 0, n = rStatusBar.mpItemList->size(); i < n; ++i ) { + mpItemList->push_back( new ImplStatusItem( *(*rStatusBar.mpItemList)[ i ] ) ); } mbFormat = TRUE; @@ -1181,15 +1156,10 @@ void StatusBar::CopyItems( const StatusBar& rStatusBar ) void StatusBar::Clear() { // Alle Item loeschen - ImplStatusItem* pItem = mpItemList->First(); - while ( pItem ) - { - delete pItem; - pItem = mpItemList->Next(); + for ( size_t i = 0, n = mpItemList->size(); i < n; ++i ) { + delete (*mpItemList)[ i ]; } - - // Items aus der Liste loeschen - mpItemList->Clear(); + mpItemList->clear(); mbFormat = TRUE; if ( ImplIsItemUpdate() ) @@ -1202,31 +1172,26 @@ void StatusBar::Clear() USHORT StatusBar::GetItemCount() const { - return (USHORT)mpItemList->Count(); + return (USHORT)mpItemList->size(); } // ----------------------------------------------------------------------- USHORT StatusBar::GetItemId( USHORT nPos ) const { - ImplStatusItem* pItem = mpItemList->GetObject( nPos ); - if ( pItem ) - return pItem->mnId; - else - return 0; + if ( nPos < mpItemList->size() ) + return (*mpItemList)[ nPos ]->mnId; + return 0; } // ----------------------------------------------------------------------- USHORT StatusBar::GetItemPos( USHORT nItemId ) const { - ImplStatusItem* pItem = mpItemList->First(); - while ( pItem ) - { - if ( pItem->mnId == nItemId ) - return (USHORT)mpItemList->GetCurPos(); - - pItem = mpItemList->Next(); + for ( size_t i = 0, n = mpItemList->size(); i < n; ++i ) { + if ( (*mpItemList)[ i ]->mnId == nItemId ) { + return USHORT( i ); + } } return STATUSBAR_ITEM_NOTFOUND; @@ -1245,7 +1210,7 @@ USHORT StatusBar::GetItemId( const Point& rPos ) const // Rechteck holen Rectangle aRect = ImplGetItemRectPos( nPos ); if ( aRect.IsInside( rPos ) ) - return mpItemList->GetObject( nPos )->mnId; + return (*mpItemList)[ nPos ]->mnId; } } @@ -1287,7 +1252,7 @@ Point StatusBar::GetItemTextPos( USHORT nItemId ) const if ( nPos != STATUSBAR_ITEM_NOTFOUND ) { // Rechteck holen - ImplStatusItem* pItem = mpItemList->GetObject( nPos ); + ImplStatusItem* pItem = (*mpItemList)[ nPos ]; Rectangle aRect = ImplGetItemRectPos( nPos ); long nW = mpImplData->mnItemBorderWidth + 1; Rectangle aTextRect( aRect.Left()+nW, aRect.Top()+nW, @@ -1314,9 +1279,9 @@ ULONG StatusBar::GetItemWidth( USHORT nItemId ) const USHORT nPos = GetItemPos( nItemId ); if ( nPos != STATUSBAR_ITEM_NOTFOUND ) - return mpItemList->GetObject( nPos )->mnWidth; - else - return 0; + return (*mpItemList)[ nPos ]->mnWidth; + + return 0; } // ----------------------------------------------------------------------- @@ -1326,9 +1291,9 @@ StatusBarItemBits StatusBar::GetItemBits( USHORT nItemId ) const USHORT nPos = GetItemPos( nItemId ); if ( nPos != STATUSBAR_ITEM_NOTFOUND ) - return mpItemList->GetObject( nPos )->mnBits; - else - return 0; + return (*mpItemList)[ nPos ]->mnBits; + + return 0; } // ----------------------------------------------------------------------- @@ -1338,9 +1303,9 @@ long StatusBar::GetItemOffset( USHORT nItemId ) const USHORT nPos = GetItemPos( nItemId ); if ( nPos != STATUSBAR_ITEM_NOTFOUND ) - return mpItemList->GetObject( nPos )->mnOffset; - else - return 0; + return (*mpItemList)[ nPos ]->mnOffset; + + return 0; } // ----------------------------------------------------------------------- @@ -1351,7 +1316,7 @@ void StatusBar::SetItemText( USHORT nItemId, const XubString& rText ) if ( nPos != STATUSBAR_ITEM_NOTFOUND ) { - ImplStatusItem* pItem = mpItemList->GetObject( nPos ); + ImplStatusItem* pItem = (*mpItemList)[ nPos ]; if ( pItem->maText != rText ) { @@ -1387,9 +1352,9 @@ const XubString& StatusBar::GetItemText( USHORT nItemId ) const USHORT nPos = GetItemPos( nItemId ); if ( nPos != STATUSBAR_ITEM_NOTFOUND ) - return mpItemList->GetObject( nPos )->maText; - else - return ImplGetSVEmptyStr(); + return (*mpItemList)[ nPos ]->maText; + + return ImplGetSVEmptyStr(); } // ----------------------------------------------------------------------- @@ -1400,7 +1365,7 @@ void StatusBar::SetItemCommand( USHORT nItemId, const XubString& rCommand ) if ( nPos != STATUSBAR_ITEM_NOTFOUND ) { - ImplStatusItem* pItem = mpItemList->GetObject( nPos ); + ImplStatusItem* pItem = (*mpItemList)[ nPos ]; if ( pItem->maCommand != rCommand ) pItem->maCommand = rCommand; @@ -1414,9 +1379,9 @@ const XubString& StatusBar::GetItemCommand( USHORT nItemId ) USHORT nPos = GetItemPos( nItemId ); if ( nPos != STATUSBAR_ITEM_NOTFOUND ) - return mpItemList->GetObject( nPos )->maCommand; - else - return ImplGetSVEmptyStr(); + return (*mpItemList)[ nPos ]->maCommand; + + return ImplGetSVEmptyStr(); } // ----------------------------------------------------------------------- @@ -1427,7 +1392,7 @@ void StatusBar::SetItemData( USHORT nItemId, void* pNewData ) if ( nPos != STATUSBAR_ITEM_NOTFOUND ) { - ImplStatusItem* pItem = mpItemList->GetObject( nPos ); + ImplStatusItem* pItem = (*mpItemList)[ nPos ]; pItem->mpUserData = pNewData; // Wenn es ein User-Item ist, DrawItem-Aufrufen @@ -1448,9 +1413,9 @@ void* StatusBar::GetItemData( USHORT nItemId ) const USHORT nPos = GetItemPos( nItemId ); if ( nPos != STATUSBAR_ITEM_NOTFOUND ) - return mpItemList->GetObject( nPos )->mpUserData; - else - return NULL; + return (*mpItemList)[ nPos ]->mpUserData; + + return NULL; } // ----------------------------------------------------------------------- @@ -1460,7 +1425,7 @@ void StatusBar::SetHelpText( USHORT nItemId, const XubString& rText ) USHORT nPos = GetItemPos( nItemId ); if ( nPos != STATUSBAR_ITEM_NOTFOUND ) - mpItemList->GetObject( nPos )->maHelpText = rText; + (*mpItemList)[ nPos ]->maHelpText = rText; } // ----------------------------------------------------------------------- @@ -1471,7 +1436,7 @@ const XubString& StatusBar::GetHelpText( USHORT nItemId ) const if ( nPos != STATUSBAR_ITEM_NOTFOUND ) { - ImplStatusItem* pItem = mpItemList->GetObject( nPos ); + ImplStatusItem* pItem = (*mpItemList)[ nPos ]; if ( !pItem->maHelpText.Len() && ( pItem->mnHelpId || pItem->maCommand.Len() )) { Help* pHelp = Application::GetHelp(); @@ -1497,7 +1462,7 @@ void StatusBar::SetQuickHelpText( USHORT nItemId, const XubString& rText ) USHORT nPos = GetItemPos( nItemId ); if ( nPos != STATUSBAR_ITEM_NOTFOUND ) - mpItemList->GetObject( nPos )->maQuickHelpText = rText; + (*mpItemList)[ nPos ]->maQuickHelpText = rText; } // ----------------------------------------------------------------------- @@ -1508,11 +1473,11 @@ const XubString& StatusBar::GetQuickHelpText( USHORT nItemId ) const if ( nPos != STATUSBAR_ITEM_NOTFOUND ) { - ImplStatusItem* pItem = mpItemList->GetObject( nPos ); + ImplStatusItem* pItem = (*mpItemList)[ nPos ]; return pItem->maQuickHelpText; } - else - return ImplGetSVEmptyStr(); + + return ImplGetSVEmptyStr(); } // ----------------------------------------------------------------------- @@ -1522,7 +1487,7 @@ void StatusBar::SetHelpId( USHORT nItemId, ULONG nHelpId ) USHORT nPos = GetItemPos( nItemId ); if ( nPos != STATUSBAR_ITEM_NOTFOUND ) - mpItemList->GetObject( nPos )->mnHelpId = nHelpId; + (*mpItemList)[ nPos ]->mnHelpId = nHelpId; } // ----------------------------------------------------------------------- @@ -1532,9 +1497,9 @@ ULONG StatusBar::GetHelpId( USHORT nItemId ) const USHORT nPos = GetItemPos( nItemId ); if ( nPos != STATUSBAR_ITEM_NOTFOUND ) - return mpItemList->GetObject( nPos )->mnHelpId; - else - return 0; + return (*mpItemList)[ nPos ]->mnHelpId; + + return 0; } // ----------------------------------------------------------------------- @@ -1700,15 +1665,15 @@ void StatusBar::SetText( const XubString& rText ) Size StatusBar::CalcWindowSizePixel() const { - ULONG i = 0; - ULONG nCount = mpItemList->Count(); + size_t i = 0; + size_t nCount = mpItemList->size(); long nOffset = 0; long nCalcWidth = (STATUSBAR_OFFSET_X*2); long nCalcHeight; while ( i < nCount ) { - ImplStatusItem* pItem = mpItemList->GetObject( i ); + ImplStatusItem* pItem = (*mpItemList)[ i ]; nCalcWidth += pItem->mnWidth + nOffset; nOffset = pItem->mnOffset; i++; @@ -1768,7 +1733,7 @@ void StatusBar::SetAccessibleName( USHORT nItemId, const XubString& rName ) if ( nPos != STATUSBAR_ITEM_NOTFOUND ) { - ImplStatusItem* pItem = mpItemList->GetObject( nPos ); + ImplStatusItem* pItem = (*mpItemList)[ nPos ]; if ( pItem->maAccessibleName != rName ) { @@ -1785,9 +1750,9 @@ const XubString& StatusBar::GetAccessibleName( USHORT nItemId ) const USHORT nPos = GetItemPos( nItemId ); if ( nPos != STATUSBAR_ITEM_NOTFOUND ) - return mpItemList->GetObject( nPos )->maAccessibleName; - else - return ImplGetSVEmptyStr(); + return (*mpItemList)[ nPos ]->maAccessibleName; + + return ImplGetSVEmptyStr(); } // ----------------------------------------------------------------------- |