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>
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(),
39 BrowserHeader::~BrowserHeader()
44 void BrowserHeader::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()
74 void BrowserHeader::EndDrag()
76 // call before other actions, it looks more nice in most cases
81 sal_uInt16 nId
= GetCurItemId();
85 if ( nId
== USHRT_MAX
-1 )
91 _pBrowseBox
->SetColumnWidth( nId
, GetItemSize( nId
) );
92 _pBrowseBox
->ColumnResized( nId
);
93 SetItemSize( nId
, _pBrowseBox
->GetColumnWidth( nId
) );
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
)
106 if (nOldPos
!= nNewPos
)
108 _pBrowseBox
->SetColumnPos( nId
, nNewPos
);
109 _pBrowseBox
->ColumnMoved( nId
);
119 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */