1*96de5490SAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*96de5490SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*96de5490SAndrew Rist * or more contributor license agreements. See the NOTICE file
5*96de5490SAndrew Rist * distributed with this work for additional information
6*96de5490SAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*96de5490SAndrew Rist * to you under the Apache License, Version 2.0 (the
8*96de5490SAndrew Rist * "License"); you may not use this file except in compliance
9*96de5490SAndrew Rist * with the License. You may obtain a copy of the License at
10cdf0e10cSrcweir *
11*96de5490SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir *
13*96de5490SAndrew Rist * Unless required by applicable law or agreed to in writing,
14*96de5490SAndrew Rist * software distributed under the License is distributed on an
15*96de5490SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*96de5490SAndrew Rist * KIND, either express or implied. See the License for the
17*96de5490SAndrew Rist * specific language governing permissions and limitations
18*96de5490SAndrew Rist * under the License.
19cdf0e10cSrcweir *
20*96de5490SAndrew Rist *************************************************************/
21*96de5490SAndrew Rist
22*96de5490SAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_dbaccess.hxx"
26cdf0e10cSrcweir #ifndef DBAUI_VERTSPLITVIEW_HXX
27cdf0e10cSrcweir #include "VertSplitView.hxx"
28cdf0e10cSrcweir #endif
29cdf0e10cSrcweir
30cdf0e10cSrcweir #ifndef _TOOLS_DEBUG_HXX
31cdf0e10cSrcweir #include <tools/debug.hxx>
32cdf0e10cSrcweir #endif
33cdf0e10cSrcweir
34cdf0e10cSrcweir #define SPLITTER_WIDTH 80
35cdf0e10cSrcweir
36cdf0e10cSrcweir using namespace ::dbaui;
37cdf0e10cSrcweir
38cdf0e10cSrcweir //==================================================================
39cdf0e10cSrcweir // class OSplitterView
40cdf0e10cSrcweir //==================================================================
DBG_NAME(OSplitterView)41cdf0e10cSrcweir DBG_NAME(OSplitterView)
42cdf0e10cSrcweir OSplitterView::OSplitterView(Window* _pParent,sal_Bool _bVertical) : Window(_pParent,WB_DIALOGCONTROL) // ,WB_BORDER
43cdf0e10cSrcweir ,m_pSplitter( NULL )
44cdf0e10cSrcweir ,m_pLeft(NULL)
45cdf0e10cSrcweir ,m_pRight(NULL)
46cdf0e10cSrcweir ,m_bVertical(_bVertical)
47cdf0e10cSrcweir {
48cdf0e10cSrcweir DBG_CTOR(OSplitterView,NULL);
49cdf0e10cSrcweir ImplInitSettings( sal_True, sal_True, sal_True );
50cdf0e10cSrcweir }
51cdf0e10cSrcweir // -----------------------------------------------------------------------------
~OSplitterView()52cdf0e10cSrcweir OSplitterView::~OSplitterView()
53cdf0e10cSrcweir {
54cdf0e10cSrcweir DBG_DTOR(OSplitterView,NULL);
55cdf0e10cSrcweir m_pRight = m_pLeft = NULL;
56cdf0e10cSrcweir }
57cdf0e10cSrcweir //------------------------------------------------------------------------------
58cdf0e10cSrcweir IMPL_LINK( OSplitterView, SplitHdl, Splitter*, /*pSplit*/ )
59cdf0e10cSrcweir {
60cdf0e10cSrcweir OSL_ENSURE(m_pSplitter, "Splitter is NULL!");
61cdf0e10cSrcweir if ( m_bVertical )
62cdf0e10cSrcweir {
63cdf0e10cSrcweir long nPosY = m_pSplitter->GetPosPixel().Y();
64cdf0e10cSrcweir m_pSplitter->SetPosPixel( Point( m_pSplitter->GetSplitPosPixel(), nPosY ) );
65cdf0e10cSrcweir }
66cdf0e10cSrcweir else
67cdf0e10cSrcweir m_pSplitter->SetPosPixel( Point( m_pSplitter->GetPosPixel().X(),m_pSplitter->GetSplitPosPixel() ) );
68cdf0e10cSrcweir
69cdf0e10cSrcweir Resize();
70cdf0e10cSrcweir return 0L;
71cdf0e10cSrcweir }
72cdf0e10cSrcweir // -----------------------------------------------------------------------------
ImplInitSettings(sal_Bool bFont,sal_Bool bForeground,sal_Bool bBackground)73cdf0e10cSrcweir void OSplitterView::ImplInitSettings( sal_Bool bFont, sal_Bool bForeground, sal_Bool bBackground )
74cdf0e10cSrcweir {
75cdf0e10cSrcweir const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
76cdf0e10cSrcweir
77cdf0e10cSrcweir if ( bFont )
78cdf0e10cSrcweir {
79cdf0e10cSrcweir Font aFont = rStyleSettings.GetAppFont();
80cdf0e10cSrcweir if ( IsControlFont() )
81cdf0e10cSrcweir aFont.Merge( GetControlFont() );
82cdf0e10cSrcweir SetPointFont( aFont );
83cdf0e10cSrcweir // Set/*Zoomed*/PointFont( aFont );
84cdf0e10cSrcweir }
85cdf0e10cSrcweir
86cdf0e10cSrcweir if ( bFont || bForeground )
87cdf0e10cSrcweir {
88cdf0e10cSrcweir Color aTextColor = rStyleSettings.GetButtonTextColor();
89cdf0e10cSrcweir if ( IsControlForeground() )
90cdf0e10cSrcweir aTextColor = GetControlForeground();
91cdf0e10cSrcweir SetTextColor( aTextColor );
92cdf0e10cSrcweir }
93cdf0e10cSrcweir
94cdf0e10cSrcweir if ( bBackground )
95cdf0e10cSrcweir {
96cdf0e10cSrcweir if( IsControlBackground() )
97cdf0e10cSrcweir SetBackground( GetControlBackground() );
98cdf0e10cSrcweir else
99cdf0e10cSrcweir SetBackground( rStyleSettings.GetFaceColor() );
100cdf0e10cSrcweir }
101cdf0e10cSrcweir }
102cdf0e10cSrcweir // -----------------------------------------------------------------------
DataChanged(const DataChangedEvent & rDCEvt)103cdf0e10cSrcweir void OSplitterView::DataChanged( const DataChangedEvent& rDCEvt )
104cdf0e10cSrcweir {
105cdf0e10cSrcweir Window::DataChanged( rDCEvt );
106cdf0e10cSrcweir
107cdf0e10cSrcweir if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
108cdf0e10cSrcweir (rDCEvt.GetFlags() & SETTINGS_STYLE) )
109cdf0e10cSrcweir {
110cdf0e10cSrcweir ImplInitSettings( sal_True, sal_True, sal_True );
111cdf0e10cSrcweir Invalidate();
112cdf0e10cSrcweir }
113cdf0e10cSrcweir }
114cdf0e10cSrcweir // -----------------------------------------------------------------------------
GetFocus()115cdf0e10cSrcweir void OSplitterView::GetFocus()
116cdf0e10cSrcweir {
117cdf0e10cSrcweir Window::GetFocus();
118cdf0e10cSrcweir
119cdf0e10cSrcweir // forward the focus to the current cell of the editor control
120cdf0e10cSrcweir if ( m_pLeft )
121cdf0e10cSrcweir m_pLeft->GrabFocus();
122cdf0e10cSrcweir else if ( m_pRight )
123cdf0e10cSrcweir m_pRight->GrabFocus();
124cdf0e10cSrcweir }
125cdf0e10cSrcweir
126cdf0e10cSrcweir // -------------------------------------------------------------------------
Resize()127cdf0e10cSrcweir void OSplitterView::Resize()
128cdf0e10cSrcweir {
129cdf0e10cSrcweir Window::Resize();
130cdf0e10cSrcweir OSL_ENSURE( m_pRight, "No init called!");
131cdf0e10cSrcweir
132cdf0e10cSrcweir Point aSplitPos;
133cdf0e10cSrcweir Size aSplitSize;
134cdf0e10cSrcweir Point aPlaygroundPos( 0,0 );
135cdf0e10cSrcweir Size aPlaygroundSize( GetOutputSizePixel() );
136cdf0e10cSrcweir
137cdf0e10cSrcweir if ( m_pLeft && m_pLeft->IsVisible() && m_pSplitter )
138cdf0e10cSrcweir {
139cdf0e10cSrcweir aSplitPos = m_pSplitter->GetPosPixel();
140cdf0e10cSrcweir aSplitSize = m_pSplitter->GetOutputSizePixel();
141cdf0e10cSrcweir if ( m_bVertical )
142cdf0e10cSrcweir {
143cdf0e10cSrcweir // calculate the splitter pos and size
144cdf0e10cSrcweir aSplitPos.Y() = aPlaygroundPos.Y();
145cdf0e10cSrcweir aSplitSize.Height() = aPlaygroundSize.Height();
146cdf0e10cSrcweir
147cdf0e10cSrcweir if( ( aSplitPos.X() + aSplitSize.Width() ) > ( aPlaygroundSize.Width() ))
148cdf0e10cSrcweir aSplitPos.X() = aPlaygroundSize.Width() - aSplitSize.Width();
149cdf0e10cSrcweir
150cdf0e10cSrcweir if( aSplitPos.X() <= aPlaygroundPos.X() )
151cdf0e10cSrcweir aSplitPos.X() = aPlaygroundPos.X() + sal_Int32(aPlaygroundSize.Width() * 0.3);
152cdf0e10cSrcweir
153cdf0e10cSrcweir // the tree pos and size
154cdf0e10cSrcweir Point aTreeViewPos( aPlaygroundPos );
155cdf0e10cSrcweir Size aTreeViewSize( aSplitPos.X(), aPlaygroundSize.Height() );
156cdf0e10cSrcweir
157cdf0e10cSrcweir // set the size of treelistbox
158cdf0e10cSrcweir m_pLeft->SetPosSizePixel( aTreeViewPos, aTreeViewSize );
159cdf0e10cSrcweir
160cdf0e10cSrcweir //set the size of the splitter
161cdf0e10cSrcweir m_pSplitter->SetPosSizePixel( aSplitPos, Size( aSplitSize.Width(), aPlaygroundSize.Height() ) );
162cdf0e10cSrcweir m_pSplitter->SetDragRectPixel( Rectangle(aPlaygroundPos,aPlaygroundSize) );
163cdf0e10cSrcweir }
164cdf0e10cSrcweir else
165cdf0e10cSrcweir {
166cdf0e10cSrcweir aSplitPos.X() = aPlaygroundPos.X();
167cdf0e10cSrcweir aSplitSize.Width() = aPlaygroundSize.Width();
168cdf0e10cSrcweir
169cdf0e10cSrcweir if( ( aSplitPos.Y() + aSplitSize.Height() ) > ( aPlaygroundSize.Height() ))
170cdf0e10cSrcweir aSplitPos.Y() = aPlaygroundSize.Height() - aSplitSize.Height();
171cdf0e10cSrcweir
172cdf0e10cSrcweir if( aSplitPos.Y() <= aPlaygroundPos.Y() )
173cdf0e10cSrcweir aSplitPos.Y() = aPlaygroundPos.Y() + sal_Int32(aPlaygroundSize.Height() * 0.3);
174cdf0e10cSrcweir
175cdf0e10cSrcweir // the tree pos and size
176cdf0e10cSrcweir Point aTreeViewPos( aPlaygroundPos );
177cdf0e10cSrcweir Size aTreeViewSize( aPlaygroundSize.Width() ,aSplitPos.Y());
178cdf0e10cSrcweir
179cdf0e10cSrcweir // set the size of treelistbox
180cdf0e10cSrcweir m_pLeft->SetPosSizePixel( aTreeViewPos, aTreeViewSize );
181cdf0e10cSrcweir
182cdf0e10cSrcweir //set the size of the splitter
183cdf0e10cSrcweir m_pSplitter->SetPosSizePixel( aSplitPos, Size( aPlaygroundSize.Width(), aSplitSize.Height() ) );
184cdf0e10cSrcweir m_pSplitter->SetDragRectPixel( Rectangle(aPlaygroundPos,aPlaygroundSize) );
185cdf0e10cSrcweir }
186cdf0e10cSrcweir }
187cdf0e10cSrcweir
188cdf0e10cSrcweir if ( m_pRight )
189cdf0e10cSrcweir {
190cdf0e10cSrcweir if ( m_bVertical )
191cdf0e10cSrcweir m_pRight->SetPosSizePixel( aSplitPos.X() + aSplitSize.Width(), aPlaygroundPos.Y(),
192cdf0e10cSrcweir aPlaygroundSize.Width() - aSplitSize.Width() - aSplitPos.X(), aPlaygroundSize.Height());
193cdf0e10cSrcweir else
194cdf0e10cSrcweir m_pRight->SetPosSizePixel( aSplitPos.X(), aPlaygroundPos.Y() + aSplitPos.Y() + aSplitSize.Height(),
195cdf0e10cSrcweir aPlaygroundSize.Width() , aPlaygroundSize.Height() - aSplitSize.Height() - aSplitPos.Y());
196cdf0e10cSrcweir }
197cdf0e10cSrcweir
198cdf0e10cSrcweir }
199cdf0e10cSrcweir // -----------------------------------------------------------------------------
set(Window * _pRight,Window * _pLeft)200cdf0e10cSrcweir void OSplitterView::set(Window* _pRight,Window* _pLeft)
201cdf0e10cSrcweir {
202cdf0e10cSrcweir m_pLeft = _pLeft;
203cdf0e10cSrcweir m_pRight = _pRight;
204cdf0e10cSrcweir }
205cdf0e10cSrcweir // -----------------------------------------------------------------------------
setSplitter(Splitter * _pSplitter)206cdf0e10cSrcweir void OSplitterView::setSplitter(Splitter* _pSplitter)
207cdf0e10cSrcweir {
208cdf0e10cSrcweir m_pSplitter = _pSplitter;
209cdf0e10cSrcweir if ( m_pSplitter )
210cdf0e10cSrcweir {
211cdf0e10cSrcweir m_pSplitter->SetSplitPosPixel( LogicToPixel( Size( SPLITTER_WIDTH, 0 ), MAP_APPFONT ).Width() );
212cdf0e10cSrcweir m_pSplitter->SetSplitHdl( LINK(this, OSplitterView, SplitHdl) );
213cdf0e10cSrcweir m_pSplitter->Show();
214cdf0e10cSrcweir LINK( this, OSplitterView, SplitHdl ).Call(m_pSplitter);
215cdf0e10cSrcweir }
216cdf0e10cSrcweir }
217