1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_svtools.hxx" 30 31 #include <svtools/brwhead.hxx> 32 #include <svtools/brwbox.hxx> 33 34 #ifndef GCC 35 #endif 36 37 //=================================================================== 38 39 BrowserHeader::BrowserHeader( BrowseBox* pParent, WinBits nWinBits ) 40 :HeaderBar( pParent, nWinBits ) 41 ,_pBrowseBox( pParent ) 42 { 43 long nHeight = pParent->IsZoom() ? pParent->CalcZoom(pParent->GetTitleHeight()) : pParent->GetTitleHeight(); 44 45 SetPosSizePixel( Point( 0, 0), 46 Size( pParent->GetOutputSizePixel().Width(), 47 nHeight ) ); 48 Show(); 49 } 50 51 //------------------------------------------------------------------- 52 53 void BrowserHeader::Command( const CommandEvent& rCEvt ) 54 { 55 if ( !GetCurItemId() && COMMAND_CONTEXTMENU == rCEvt.GetCommand() ) 56 { 57 Point aPos( rCEvt.GetMousePosPixel() ); 58 if ( _pBrowseBox->IsFrozen(0) ) 59 aPos.X() += _pBrowseBox->GetColumnWidth(0); 60 _pBrowseBox->GetDataWindow().Command( CommandEvent( 61 Point( aPos.X(), aPos.Y() - GetSizePixel().Height() ), 62 COMMAND_CONTEXTMENU, rCEvt.IsMouseEvent() ) ); 63 } 64 } 65 66 //------------------------------------------------------------------- 67 68 void BrowserHeader::Select() 69 { 70 HeaderBar::Select(); 71 } 72 73 //------------------------------------------------------------------- 74 75 void BrowserHeader::EndDrag() 76 { 77 // call before other actions, it looks more nice in most cases 78 HeaderBar::EndDrag(); 79 Update(); 80 81 // not aborted? 82 sal_uInt16 nId = GetCurItemId(); 83 if ( nId ) 84 { 85 // Handle-Column? 86 if ( nId == USHRT_MAX-1 ) 87 nId = 0; 88 89 if ( !IsItemMode() ) 90 { 91 // column resize 92 _pBrowseBox->SetColumnWidth( nId, GetItemSize( nId ) ); 93 _pBrowseBox->ColumnResized( nId ); 94 SetItemSize( nId, _pBrowseBox->GetColumnWidth( nId ) ); 95 } 96 else 97 { 98 // column drag 99 // Hat sich die Position eigentlich veraendert 100 // Handlecolumn beruecksichtigen 101 sal_uInt16 nOldPos = _pBrowseBox->GetColumnPos(nId), 102 nNewPos = GetItemPos( nId ); 103 104 if (!_pBrowseBox->GetColumnId(0)) // Handle 105 nNewPos++; 106 107 if (nOldPos != nNewPos) 108 { 109 _pBrowseBox->SetColumnPos( nId, nNewPos ); 110 _pBrowseBox->ColumnMoved( nId ); 111 } 112 } 113 } 114 } 115 // ----------------------------------------------------------------------------- 116 117 118 119 120