Bump version to 5.0-14
[LibreOffice.git] / svtools / source / brwbox / brwhead.cxx
blobc0b99ef473ad29e075365644af7240020cbcca3d
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #include <svtools/brwhead.hxx>
22 #include <svtools/brwbox.hxx>
26 BrowserHeader::BrowserHeader( BrowseBox* pParent, WinBits nWinBits )
27 :HeaderBar( pParent, nWinBits )
28 ,_pBrowseBox( pParent )
30 long nHeight = pParent->IsZoom() ? pParent->CalcZoom(pParent->GetTitleHeight()) : pParent->GetTitleHeight();
32 SetPosSizePixel( Point( 0, 0),
33 Size( pParent->GetOutputSizePixel().Width(),
34 nHeight ) );
35 Show();
39 BrowserHeader::~BrowserHeader()
41 disposeOnce();
44 void BrowserHeader::dispose()
46 _pBrowseBox.clear();
47 HeaderBar::dispose();
52 void BrowserHeader::Command( const CommandEvent& rCEvt )
54 if ( !GetCurItemId() && CommandEventId::ContextMenu == rCEvt.GetCommand() )
56 Point aPos( rCEvt.GetMousePosPixel() );
57 if ( _pBrowseBox->IsFrozen(0) )
58 aPos.X() += _pBrowseBox->GetColumnWidth(0);
59 _pBrowseBox->GetDataWindow().Command( CommandEvent(
60 Point( aPos.X(), aPos.Y() - GetSizePixel().Height() ),
61 CommandEventId::ContextMenu, rCEvt.IsMouseEvent() ) );
67 void BrowserHeader::Select()
69 HeaderBar::Select();
74 void BrowserHeader::EndDrag()
76 // call before other actions, it looks more nice in most cases
77 HeaderBar::EndDrag();
78 Update();
80 // not aborted?
81 sal_uInt16 nId = GetCurItemId();
82 if ( nId )
84 // handle column?
85 if ( nId == USHRT_MAX-1 )
86 nId = 0;
88 if ( !IsItemMode() )
90 // column resize
91 _pBrowseBox->SetColumnWidth( nId, GetItemSize( nId ) );
92 _pBrowseBox->ColumnResized( nId );
93 SetItemSize( nId, _pBrowseBox->GetColumnWidth( nId ) );
95 else
97 // column drag
98 // did the position actually change?
99 // take the handle column into account
100 sal_uInt16 nOldPos = _pBrowseBox->GetColumnPos(nId),
101 nNewPos = GetItemPos( nId );
103 if (_pBrowseBox->GetColumnId(0) == BrowseBox::HandleColumnId)
104 nNewPos++;
106 if (nOldPos != nNewPos)
108 _pBrowseBox->SetColumnPos( nId, nNewPos );
109 _pBrowseBox->ColumnMoved( nId );
119 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */