LibreOffice Module svtools (master) 1
brwhead.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20
21#include <svtools/brwhead.hxx>
22#include <svtools/brwbox.hxx>
23#include <vcl/commandevent.hxx>
24
25
27 :HeaderBar( pParent, nWinBits )
28 ,_pBrowseBox( pParent )
29{
30 tools::Long nHeight = pParent->IsZoom() ? pParent->CalcZoom(pParent->GetTitleHeight()) : pParent->GetTitleHeight();
31
32 SetPosSizePixel( Point( 0, 0),
33 Size( pParent->GetOutputSizePixel().Width(),
34 nHeight ) );
35 Show();
36}
37
38
40{
42}
43
45{
48}
49
50
52{
53 if ( !GetCurItemId() && CommandEventId::ContextMenu == rCEvt.GetCommand() )
54 {
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() ) );
61 }
62}
63
64
66{
67 // call before other actions, it looks more nice in most cases
70
71 // not aborted?
72 sal_uInt16 nId = GetCurItemId();
73 if ( !nId )
74 return;
75
76 // handle column?
77 if ( nId == USHRT_MAX-1 )
78 nId = 0;
79
80 if ( !IsItemMode() )
81 {
82 // column resize
83 _pBrowseBox->SetColumnWidth( nId, GetItemSize( nId ) );
84 _pBrowseBox->ColumnResized( nId );
85 SetItemSize( nId, _pBrowseBox->GetColumnWidth( nId ) );
86 }
87 else
88 {
89 // column drag
90 // did the position actually change?
91 // take the handle column into account
92 sal_uInt16 nOldPos = _pBrowseBox->GetColumnPos(nId),
93 nNewPos = GetItemPos( nId );
94
95 if (_pBrowseBox->GetColumnId(0) == BrowseBox::HandleColumnId)
96 nNewPos++;
97
98 if (nOldPos != nNewPos)
99 {
100 _pBrowseBox->SetColumnPos( nId, nNewPos );
101 _pBrowseBox->ColumnMoved( nId );
102 }
103 }
104}
105
106
107/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
tools::Long GetTitleHeight() const
Definition: brwbox1.cxx:2307
static const sal_uInt16 HandleColumnId
Definition: brwbox.hxx:267
virtual void dispose() override
Definition: brwhead.cxx:44
virtual ~BrowserHeader() override
Definition: brwhead.cxx:39
VclPtr< BrowseBox > _pBrowseBox
Definition: brwhead.hxx:30
virtual void Command(const CommandEvent &rCEvt) override
Definition: brwhead.cxx:51
BrowserHeader(BrowseBox *pParent, WinBits nWinBits=WB_STDHEADERBAR|WB_DRAG)
Definition: brwhead.cxx:26
virtual void EndDrag() override
Definition: brwhead.cxx:65
CommandEventId GetCommand() const
const Point & GetMousePosPixel() const
bool IsMouseEvent() const
void SetItemSize(sal_uInt16 nItemId, tools::Long nNewSize)
bool IsItemMode() const
tools::Long GetItemSize(sal_uInt16 nItemId) const
sal_uInt16 GetItemPos(sal_uInt16 nItemId) const
sal_uInt16 GetCurItemId() const
virtual void EndDrag()
constexpr tools::Long Y() const
tools::Long AdjustX(tools::Long nHorzMove)
constexpr tools::Long X() const
constexpr tools::Long Width() const
void clear()
virtual void dispose() override
void PaintImmediately()
tools::Long CalcZoom(tools::Long n) const
void Show(bool bVisible=true, ShowFlags nFlags=ShowFlags::NONE)
bool IsZoom() const
virtual Size GetSizePixel() const
Size GetOutputSizePixel() const
virtual void SetPosSizePixel(const Point &rNewPos, const Size &rNewSize)
long Long
sal_Int16 nId
sal_Int64 WinBits