1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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>
23 #include <vcl/commandevent.hxx>
26 BrowserHeader::BrowserHeader( BrowseBox
* pParent
, WinBits nWinBits
)
27 :HeaderBar( pParent
, nWinBits
)
28 ,_pBrowseBox( pParent
)
30 tools::Long nHeight
= pParent
->IsZoom() ? pParent
->CalcZoom(pParent
->GetTitleHeight()) : pParent
->GetTitleHeight();
32 SetPosSizePixel( Point( 0, 0),
33 Size( pParent
->GetOutputSizePixel().Width(),
39 BrowserHeader::~BrowserHeader()
44 void BrowserHeader::dispose()
51 void BrowserHeader::Command( const CommandEvent
& rCEvt
)
53 if ( !GetCurItemId() && CommandEventId::ContextMenu
== rCEvt
.GetCommand() )
55 Point
aPos( rCEvt
.GetMousePosPixel() );
56 if ( _pBrowseBox
->IsFrozen(0) )
57 aPos
.AdjustX(_pBrowseBox
->GetColumnWidth(0) );
58 _pBrowseBox
->GetDataWindow().Command( CommandEvent(
59 Point( aPos
.X(), aPos
.Y() - GetSizePixel().Height() ),
60 CommandEventId::ContextMenu
, rCEvt
.IsMouseEvent() ) );
65 void BrowserHeader::EndDrag()
67 // call before other actions, it looks more nice in most cases
72 sal_uInt16 nId
= GetCurItemId();
77 if ( nId
== USHRT_MAX
-1 )
83 _pBrowseBox
->SetColumnWidth( nId
, GetItemSize( nId
) );
84 _pBrowseBox
->ColumnResized( nId
);
85 SetItemSize( nId
, _pBrowseBox
->GetColumnWidth( nId
) );
90 // did the position actually change?
91 // take the handle column into account
92 sal_uInt16 nOldPos
= _pBrowseBox
->GetColumnPos(nId
),
93 nNewPos
= GetItemPos( nId
);
95 if (_pBrowseBox
->GetColumnId(0) == BrowseBox::HandleColumnId
)
98 if (nOldPos
!= nNewPos
)
100 _pBrowseBox
->SetColumnPos( nId
, nNewPos
);
101 _pBrowseBox
->ColumnMoved( nId
);
107 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */