fdo#74697 Add Bluez 5 support for impress remote.
[LibreOffice.git] / svtools / source / brwbox / brwhead.cxx
blobd3b7a7e9d0f99c7b654e0f473b02ef0a966b8960
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>
24 //===================================================================
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();
38 //-------------------------------------------------------------------
40 void BrowserHeader::Command( const CommandEvent& rCEvt )
42 if ( !GetCurItemId() && COMMAND_CONTEXTMENU == rCEvt.GetCommand() )
44 Point aPos( rCEvt.GetMousePosPixel() );
45 if ( _pBrowseBox->IsFrozen(0) )
46 aPos.X() += _pBrowseBox->GetColumnWidth(0);
47 _pBrowseBox->GetDataWindow().Command( CommandEvent(
48 Point( aPos.X(), aPos.Y() - GetSizePixel().Height() ),
49 COMMAND_CONTEXTMENU, rCEvt.IsMouseEvent() ) );
53 //-------------------------------------------------------------------
55 void BrowserHeader::Select()
57 HeaderBar::Select();
60 //-------------------------------------------------------------------
62 void BrowserHeader::EndDrag()
64 // call before other actions, it looks more nice in most cases
65 HeaderBar::EndDrag();
66 Update();
68 // not aborted?
69 sal_uInt16 nId = GetCurItemId();
70 if ( nId )
72 // handle column?
73 if ( nId == USHRT_MAX-1 )
74 nId = 0;
76 if ( !IsItemMode() )
78 // column resize
79 _pBrowseBox->SetColumnWidth( nId, GetItemSize( nId ) );
80 _pBrowseBox->ColumnResized( nId );
81 SetItemSize( nId, _pBrowseBox->GetColumnWidth( nId ) );
83 else
85 // column drag
86 // did the position actually change?
87 // take the handle column into account
88 sal_uInt16 nOldPos = _pBrowseBox->GetColumnPos(nId),
89 nNewPos = GetItemPos( nId );
91 if (_pBrowseBox->GetColumnId(0) == BrowseBox::HandleColumnId)
92 nNewPos++;
94 if (nOldPos != nNewPos)
96 _pBrowseBox->SetColumnPos( nId, nNewPos );
97 _pBrowseBox->ColumnMoved( nId );
102 // -----------------------------------------------------------------------------
107 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */