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