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