1*5900e8ecSAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*5900e8ecSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*5900e8ecSAndrew Rist * or more contributor license agreements. See the NOTICE file
5*5900e8ecSAndrew Rist * distributed with this work for additional information
6*5900e8ecSAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*5900e8ecSAndrew Rist * to you under the Apache License, Version 2.0 (the
8*5900e8ecSAndrew Rist * "License"); you may not use this file except in compliance
9*5900e8ecSAndrew Rist * with the License. You may obtain a copy of the License at
10*5900e8ecSAndrew Rist *
11*5900e8ecSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12*5900e8ecSAndrew Rist *
13*5900e8ecSAndrew Rist * Unless required by applicable law or agreed to in writing,
14*5900e8ecSAndrew Rist * software distributed under the License is distributed on an
15*5900e8ecSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*5900e8ecSAndrew Rist * KIND, either express or implied. See the License for the
17*5900e8ecSAndrew Rist * specific language governing permissions and limitations
18*5900e8ecSAndrew Rist * under the License.
19*5900e8ecSAndrew Rist *
20*5900e8ecSAndrew Rist *************************************************************/
21*5900e8ecSAndrew Rist
22*5900e8ecSAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_svtools.hxx"
26cdf0e10cSrcweir
27cdf0e10cSrcweir #include <svtools/brwhead.hxx>
28cdf0e10cSrcweir #include <svtools/brwbox.hxx>
29cdf0e10cSrcweir
30cdf0e10cSrcweir #ifndef GCC
31cdf0e10cSrcweir #endif
32cdf0e10cSrcweir
33cdf0e10cSrcweir //===================================================================
34cdf0e10cSrcweir
BrowserHeader(BrowseBox * pParent,WinBits nWinBits)35cdf0e10cSrcweir BrowserHeader::BrowserHeader( BrowseBox* pParent, WinBits nWinBits )
36cdf0e10cSrcweir :HeaderBar( pParent, nWinBits )
37cdf0e10cSrcweir ,_pBrowseBox( pParent )
38cdf0e10cSrcweir {
39cdf0e10cSrcweir long nHeight = pParent->IsZoom() ? pParent->CalcZoom(pParent->GetTitleHeight()) : pParent->GetTitleHeight();
40cdf0e10cSrcweir
41cdf0e10cSrcweir SetPosSizePixel( Point( 0, 0),
42cdf0e10cSrcweir Size( pParent->GetOutputSizePixel().Width(),
43cdf0e10cSrcweir nHeight ) );
44cdf0e10cSrcweir Show();
45cdf0e10cSrcweir }
46cdf0e10cSrcweir
47cdf0e10cSrcweir //-------------------------------------------------------------------
48cdf0e10cSrcweir
Command(const CommandEvent & rCEvt)49cdf0e10cSrcweir void BrowserHeader::Command( const CommandEvent& rCEvt )
50cdf0e10cSrcweir {
51cdf0e10cSrcweir if ( !GetCurItemId() && COMMAND_CONTEXTMENU == rCEvt.GetCommand() )
52cdf0e10cSrcweir {
53cdf0e10cSrcweir Point aPos( rCEvt.GetMousePosPixel() );
54cdf0e10cSrcweir if ( _pBrowseBox->IsFrozen(0) )
55cdf0e10cSrcweir aPos.X() += _pBrowseBox->GetColumnWidth(0);
56cdf0e10cSrcweir _pBrowseBox->GetDataWindow().Command( CommandEvent(
57cdf0e10cSrcweir Point( aPos.X(), aPos.Y() - GetSizePixel().Height() ),
58cdf0e10cSrcweir COMMAND_CONTEXTMENU, rCEvt.IsMouseEvent() ) );
59cdf0e10cSrcweir }
60cdf0e10cSrcweir }
61cdf0e10cSrcweir
62cdf0e10cSrcweir //-------------------------------------------------------------------
63cdf0e10cSrcweir
Select()64cdf0e10cSrcweir void BrowserHeader::Select()
65cdf0e10cSrcweir {
66cdf0e10cSrcweir HeaderBar::Select();
67cdf0e10cSrcweir }
68cdf0e10cSrcweir
69cdf0e10cSrcweir //-------------------------------------------------------------------
70cdf0e10cSrcweir
EndDrag()71cdf0e10cSrcweir void BrowserHeader::EndDrag()
72cdf0e10cSrcweir {
73cdf0e10cSrcweir // call before other actions, it looks more nice in most cases
74cdf0e10cSrcweir HeaderBar::EndDrag();
75cdf0e10cSrcweir Update();
76cdf0e10cSrcweir
77cdf0e10cSrcweir // not aborted?
78cdf0e10cSrcweir sal_uInt16 nId = GetCurItemId();
79cdf0e10cSrcweir if ( nId )
80cdf0e10cSrcweir {
81cdf0e10cSrcweir // Handle-Column?
82cdf0e10cSrcweir if ( nId == USHRT_MAX-1 )
83cdf0e10cSrcweir nId = 0;
84cdf0e10cSrcweir
85cdf0e10cSrcweir if ( !IsItemMode() )
86cdf0e10cSrcweir {
87cdf0e10cSrcweir // column resize
88cdf0e10cSrcweir _pBrowseBox->SetColumnWidth( nId, GetItemSize( nId ) );
89cdf0e10cSrcweir _pBrowseBox->ColumnResized( nId );
90cdf0e10cSrcweir SetItemSize( nId, _pBrowseBox->GetColumnWidth( nId ) );
91cdf0e10cSrcweir }
92cdf0e10cSrcweir else
93cdf0e10cSrcweir {
94cdf0e10cSrcweir // column drag
95cdf0e10cSrcweir // Hat sich die Position eigentlich veraendert
96cdf0e10cSrcweir // Handlecolumn beruecksichtigen
97cdf0e10cSrcweir sal_uInt16 nOldPos = _pBrowseBox->GetColumnPos(nId),
98cdf0e10cSrcweir nNewPos = GetItemPos( nId );
99cdf0e10cSrcweir
100cdf0e10cSrcweir if (!_pBrowseBox->GetColumnId(0)) // Handle
101cdf0e10cSrcweir nNewPos++;
102cdf0e10cSrcweir
103cdf0e10cSrcweir if (nOldPos != nNewPos)
104cdf0e10cSrcweir {
105cdf0e10cSrcweir _pBrowseBox->SetColumnPos( nId, nNewPos );
106cdf0e10cSrcweir _pBrowseBox->ColumnMoved( nId );
107cdf0e10cSrcweir }
108cdf0e10cSrcweir }
109cdf0e10cSrcweir }
110cdf0e10cSrcweir }
111cdf0e10cSrcweir // -----------------------------------------------------------------------------
112cdf0e10cSrcweir
113cdf0e10cSrcweir
114cdf0e10cSrcweir
115cdf0e10cSrcweir
116