Line data Source code
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 :
24 :
25 :
26 40 : BrowserHeader::BrowserHeader( BrowseBox* pParent, WinBits nWinBits )
27 : :HeaderBar( pParent, nWinBits )
28 40 : ,_pBrowseBox( pParent )
29 : {
30 40 : long nHeight = pParent->IsZoom() ? pParent->CalcZoom(pParent->GetTitleHeight()) : pParent->GetTitleHeight();
31 :
32 : SetPosSizePixel( Point( 0, 0),
33 80 : Size( pParent->GetOutputSizePixel().Width(),
34 40 : nHeight ) );
35 40 : Show();
36 40 : }
37 :
38 :
39 100 : BrowserHeader::~BrowserHeader()
40 : {
41 40 : disposeOnce();
42 60 : }
43 :
44 40 : void BrowserHeader::dispose()
45 : {
46 40 : _pBrowseBox.clear();
47 40 : HeaderBar::dispose();
48 40 : }
49 :
50 :
51 :
52 0 : void BrowserHeader::Command( const CommandEvent& rCEvt )
53 : {
54 0 : if ( !GetCurItemId() && CommandEventId::ContextMenu == rCEvt.GetCommand() )
55 : {
56 0 : Point aPos( rCEvt.GetMousePosPixel() );
57 0 : if ( _pBrowseBox->IsFrozen(0) )
58 0 : aPos.X() += _pBrowseBox->GetColumnWidth(0);
59 0 : _pBrowseBox->GetDataWindow().Command( CommandEvent(
60 0 : Point( aPos.X(), aPos.Y() - GetSizePixel().Height() ),
61 0 : CommandEventId::ContextMenu, rCEvt.IsMouseEvent() ) );
62 : }
63 0 : }
64 :
65 :
66 :
67 0 : void BrowserHeader::Select()
68 : {
69 0 : HeaderBar::Select();
70 0 : }
71 :
72 :
73 :
74 0 : void BrowserHeader::EndDrag()
75 : {
76 : // call before other actions, it looks more nice in most cases
77 0 : HeaderBar::EndDrag();
78 0 : Update();
79 :
80 : // not aborted?
81 0 : sal_uInt16 nId = GetCurItemId();
82 0 : if ( nId )
83 : {
84 : // handle column?
85 0 : if ( nId == USHRT_MAX-1 )
86 0 : nId = 0;
87 :
88 0 : if ( !IsItemMode() )
89 : {
90 : // column resize
91 0 : _pBrowseBox->SetColumnWidth( nId, GetItemSize( nId ) );
92 0 : _pBrowseBox->ColumnResized( nId );
93 0 : SetItemSize( nId, _pBrowseBox->GetColumnWidth( nId ) );
94 : }
95 : else
96 : {
97 : // column drag
98 : // did the position actually change?
99 : // take the handle column into account
100 0 : sal_uInt16 nOldPos = _pBrowseBox->GetColumnPos(nId),
101 0 : nNewPos = GetItemPos( nId );
102 :
103 0 : if (_pBrowseBox->GetColumnId(0) == BrowseBox::HandleColumnId)
104 0 : nNewPos++;
105 :
106 0 : if (nOldPos != nNewPos)
107 : {
108 0 : _pBrowseBox->SetColumnPos( nId, nNewPos );
109 0 : _pBrowseBox->ColumnMoved( nId );
110 : }
111 : }
112 : }
113 0 : }
114 :
115 :
116 :
117 :
118 :
119 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|