diff options
author | Kai Ahrens <ka@openoffice.org> | 2002-06-20 08:52:54 +0000 |
---|---|---|
committer | Kai Ahrens <ka@openoffice.org> | 2002-06-20 08:52:54 +0000 |
commit | 8126280b1f9387566ba04b5a7d4ade6d8594cf10 (patch) | |
tree | 6a220fca2c8fee87670da9548090357ac1806ccb /svx/source/gallery2 | |
parent | 7dc74b823818ea0b0658c303df9f313905db3647 (diff) |
#100248#: show popup menu's at the correct position
Diffstat (limited to 'svx/source/gallery2')
-rw-r--r-- | svx/source/gallery2/galbrws1.cxx | 13 | ||||
-rw-r--r-- | svx/source/gallery2/galbrws2.cxx | 47 | ||||
-rw-r--r-- | svx/source/gallery2/galctrl.cxx | 22 |
3 files changed, 60 insertions, 22 deletions
diff --git a/svx/source/gallery2/galbrws1.cxx b/svx/source/gallery2/galbrws1.cxx index e34eac14284c..c25d04d9ccdf 100644 --- a/svx/source/gallery2/galbrws1.cxx +++ b/svx/source/gallery2/galbrws1.cxx @@ -2,9 +2,9 @@ * * $RCSfile: galbrws1.cxx,v $ * - * $Revision: 1.16 $ + * $Revision: 1.17 $ * - * last change: $Author: ka $ $Date: 2002-04-18 14:57:27 $ + * last change: $Author: ka $ $Date: 2002-06-20 09:52:54 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -587,7 +587,14 @@ IMPL_LINK( GalleryBrowser1, ShowContextMenuHdl, void*, p ) aMenu.EnableItem( MN_PROPERTIES, ::std::find( aExecVector.begin(), aExecVector.end(), MN_PROPERTIES ) != aExecVector.end() ); aMenu.SetSelectHdl( LINK( this, GalleryBrowser1, PopupMenuHdl ) ); aMenu.RemoveDisabledEntries(); - aMenu.Execute( this, GetPointerPosPixel() ); + + const Rectangle aThemesRect( mpThemes->GetPosPixel(), mpThemes->GetOutputSizePixel() ); + Point aSelPos( mpThemes->GetBoundingRectangle( mpThemes->GetSelectEntryPos() ).Center() ); + + aSelPos.X() = Max( Min( aSelPos.X(), aThemesRect.Right() ), aThemesRect.Left() ); + aSelPos.Y() = Max( Min( aSelPos.Y(), aThemesRect.Bottom() ), aThemesRect.Top() ); + + aMenu.Execute( this, aSelPos ); } return 0L; diff --git a/svx/source/gallery2/galbrws2.cxx b/svx/source/gallery2/galbrws2.cxx index dcddfd7c2adb..8913cd02e3ff 100644 --- a/svx/source/gallery2/galbrws2.cxx +++ b/svx/source/gallery2/galbrws2.cxx @@ -2,9 +2,9 @@ * * $RCSfile: galbrws2.cxx,v $ * - * $Revision: 1.30 $ + * $Revision: 1.31 $ * - * last change: $Author: ka $ $Date: 2002-04-18 11:29:25 $ + * last change: $Author: ka $ $Date: 2002-06-20 09:52:54 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -473,8 +473,9 @@ sal_Int8 GalleryBrowser2::ExecuteDrop( DropTargetHelper& rTarget, const ExecuteD if( mpCurTheme ) { - const ULONG nItemId = ImplGetSelectedItemId( &rEvt.maPosPixel ); - const ULONG nInsertPos = ( nItemId ? ( nItemId - 1 ) : LIST_APPEND ); + Point aSelPos; + const ULONG nItemId = ImplGetSelectedItemId( &rEvt.maPosPixel, aSelPos ); + const ULONG nInsertPos = ( nItemId ? ( nItemId - 1 ) : LIST_APPEND ); if( mpCurTheme->IsDragging() ) mpCurTheme->ChangeObjectPos( mpCurTheme->GetDragPos(), nInsertPos ); @@ -491,7 +492,8 @@ void GalleryBrowser2::StartDrag( Window* pWindow, const Point* pDragPoint ) { if( mpCurTheme ) { - const ULONG nItemId = ImplGetSelectedItemId( pDragPoint ); + Point aSelPos; + const ULONG nItemId = ImplGetSelectedItemId( pDragPoint, aSelPos ); if( nItemId ) mpCurTheme->StartDrag( this, nItemId - 1 ); @@ -509,7 +511,8 @@ void GalleryBrowser2::TogglePreview( Window* pWindow, const Point* pPreviewPoint void GalleryBrowser2::ShowContextMenu( Window* pWindow, const Point* pContextPoint ) { - const ULONG nItemId = ImplGetSelectedItemId( pContextPoint ); + Point aSelPos; + const ULONG nItemId = ImplGetSelectedItemId( pContextPoint, aSelPos ); if( mpCurTheme && nItemId && ( nItemId <= mpCurTheme->GetObjectCount() ) ) { @@ -520,7 +523,7 @@ void GalleryBrowser2::ShowContextMenu( Window* pWindow, const Point* pContextPoi GalleryThemePopup aMenu( mpCurTheme, nItemId - 1, GALLERYBROWSERMODE_PREVIEW == GetMode() ); rBindings.LEAVEREGISTRATIONS(); aMenu.SetSelectHdl( LINK( this, GalleryBrowser2, MenuSelectHdl ) ); - aMenu.Execute( this, GetPointerPosPixel() ); + aMenu.Execute( this, aSelPos ); } } @@ -528,7 +531,8 @@ void GalleryBrowser2::ShowContextMenu( Window* pWindow, const Point* pContextPoi BOOL GalleryBrowser2::KeyInput( const KeyEvent& rKEvt, Window* pWindow ) { - const ULONG nItemId = ImplGetSelectedItemId( NULL ); + Point aSelPos; + const ULONG nItemId = ImplGetSelectedItemId( NULL, aSelPos ); BOOL bRet = static_cast< GalleryBrowser* >( GetParent() )->KeyInput( rKEvt, pWindow ); if( !bRet && !maViewBox.HasFocus() && nItemId && mpCurTheme ) @@ -689,7 +693,8 @@ void GalleryBrowser2::SetMode( GalleryBrowserMode eMode ) case( GALLERYBROWSERMODE_PREVIEW ): { Graphic aGraphic; - const ULONG nItemId = ImplGetSelectedItemId( NULL ); + Point aSelPos; + const ULONG nItemId = ImplGetSelectedItemId( NULL, aSelPos ); if( nItemId ) { @@ -744,7 +749,8 @@ void GalleryBrowser2::Travel( GalleryBrowserTravel eTravel ) { if( mpCurTheme ) { - const ULONG nItemId = ImplGetSelectedItemId( NULL ); + Point aSelPos; + const ULONG nItemId = ImplGetSelectedItemId( NULL, aSelPos ); if( nItemId ) { @@ -829,7 +835,8 @@ void GalleryBrowser2::ImplUpdateInfoBar() if( mpCurTheme ) { - const ULONG nItemId = ImplGetSelectedItemId( NULL ); + Point aSelPos; + const ULONG nItemId = ImplGetSelectedItemId( NULL, aSelPos ); if( nItemId ) { @@ -855,15 +862,28 @@ void GalleryBrowser2::ImplUpdateInfoBar() // ----------------------------------------------------------------------------- -ULONG GalleryBrowser2::ImplGetSelectedItemId( const Point* pSelPos ) +ULONG GalleryBrowser2::ImplGetSelectedItemId( const Point* pSelPos, Point& rSelPos ) { + const Size aOutputSizePixel( GetOutputSizePixel() ); const GalleryBrowserMode eValidMode = ( ( GALLERYBROWSERMODE_PREVIEW == GetMode() ) ? meLastMode : GetMode() ); ULONG nRet = 0; if( GALLERYBROWSERMODE_ICON == eValidMode ) + { nRet = pSelPos ? mpIconView->GetItemId( *pSelPos ) : mpIconView->GetSelectItemId(); + rSelPos = pSelPos ? GetPointerPosPixel() : mpIconView->GetItemRect( (USHORT) nRet ).Center(); + } else + { nRet = ( pSelPos ? mpListView->GetRowAtYPosPixel( pSelPos->Y() ) : mpListView->FirstSelectedRow() ) + 1; + rSelPos = pSelPos ? GetPointerPosPixel() : mpListView->GetFieldRectPixel( (USHORT) nRet, 1 ).Center(); + } + + if( !pSelPos && ( GALLERYBROWSERMODE_PREVIEW == GetMode() ) ) + rSelPos = Point( aOutputSizePixel.Width() >> 1, aOutputSizePixel.Height() >> 1 ); + + rSelPos.X() = Max( Min( rSelPos.X(), aOutputSizePixel.Width() - 1L ), 0L ); + rSelPos.Y() = Max( Min( rSelPos.Y(), aOutputSizePixel.Height() - 1L ), 0L ); return nRet; } @@ -883,7 +903,8 @@ void GalleryBrowser2::ImplSelectItemId( ULONG nItemId ) void GalleryBrowser2::ImplExecute( USHORT nId ) { - const ULONG nItemId = ImplGetSelectedItemId( NULL ); + Point aSelPos; + const ULONG nItemId = ImplGetSelectedItemId( NULL, aSelPos ); if( mpCurTheme && nItemId ) { diff --git a/svx/source/gallery2/galctrl.cxx b/svx/source/gallery2/galctrl.cxx index 623957e6d252..479d39fc2e3a 100644 --- a/svx/source/gallery2/galctrl.cxx +++ b/svx/source/gallery2/galctrl.cxx @@ -2,9 +2,9 @@ * * $RCSfile: galctrl.cxx,v $ * - * $Revision: 1.12 $ + * $Revision: 1.13 $ * - * last change: $Author: oj $ $Date: 2002-04-09 07:36:55 $ + * last change: $Author: ka $ $Date: 2002-06-20 09:52:54 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -390,7 +390,10 @@ void GalleryIconView::Command( const CommandEvent& rCEvt ) ValueSet::Command( rCEvt ); if( rCEvt.GetCommand() == COMMAND_CONTEXTMENU ) - ( (GalleryBrowser2*) GetParent() )->ShowContextMenu( this, &rCEvt.GetMousePosPixel() ); + { + ( (GalleryBrowser2*) GetParent() )->ShowContextMenu( this, + ( rCEvt.IsMouseEvent() ? &rCEvt.GetMousePosPixel() : NULL ) ); + } } // ------------------------------------------------------------------------ @@ -465,7 +468,7 @@ BOOL GalleryListView::SeekRow( long nRow ) String GalleryListView::GetCellText(long _nRow, USHORT nColumnId) const { String sRet; - if( mpTheme && ( _nRow < mpTheme->GetObjectCount() ) ) + if( mpTheme && ( _nRow < static_cast< long >( mpTheme->GetObjectCount() ) ) ) { SgaObject* pObj = mpTheme->AcquireObject( _nRow ); @@ -557,8 +560,15 @@ void GalleryListView::Command( const CommandEvent& rCEvt ) { BrowseBox::Command( rCEvt ); - if( ( GetRowAtYPosPixel( rCEvt.GetMousePosPixel().Y() ) != BROWSER_ENDOFSELECTION ) && ( rCEvt.GetCommand() == COMMAND_CONTEXTMENU ) ) - ( (GalleryBrowser2*) GetParent() )->ShowContextMenu( this, &rCEvt.GetMousePosPixel() ); + if( rCEvt.GetCommand() == COMMAND_CONTEXTMENU ) + { + const Point* pPos = NULL; + + if( rCEvt.IsMouseEvent() && ( GetRowAtYPosPixel( rCEvt.GetMousePosPixel().Y() ) != BROWSER_ENDOFSELECTION ) ) + pPos = &rCEvt.GetMousePosPixel(); + + ( (GalleryBrowser2*) GetParent() )->ShowContextMenu( this, pPos ); + } } // ------------------------------------------------------------------------ |