1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include "VertSplitView.hxx"
22 #include <tools/debug.hxx>
23 #include <vcl/split.hxx>
24 #include <vcl/settings.hxx>
26 #define SPLITTER_WIDTH 80
28 using namespace ::dbaui
;
30 // class OSplitterView
31 OSplitterView::OSplitterView(vcl::Window
* _pParent
,bool _bVertical
) : Window(_pParent
,WB_DIALOGCONTROL
) // ,WB_BORDER
35 ,m_bVertical(_bVertical
)
37 ImplInitSettings( true, true, true );
40 OSplitterView::~OSplitterView()
45 void OSplitterView::dispose()
50 vcl::Window::dispose();
53 IMPL_LINK( OSplitterView
, SplitHdl
, Splitter
*, /*pSplit*/ )
55 OSL_ENSURE(m_pSplitter
, "Splitter is NULL!");
58 long nPosY
= m_pSplitter
->GetPosPixel().Y();
59 m_pSplitter
->SetPosPixel( Point( m_pSplitter
->GetSplitPosPixel(), nPosY
) );
62 m_pSplitter
->SetPosPixel( Point( m_pSplitter
->GetPosPixel().X(),m_pSplitter
->GetSplitPosPixel() ) );
68 void OSplitterView::ImplInitSettings( bool bFont
, bool bForeground
, bool bBackground
)
70 // FIXME RenderContext
71 const StyleSettings
& rStyleSettings
= GetSettings().GetStyleSettings();
75 vcl::Font aFont
= rStyleSettings
.GetAppFont();
76 if ( IsControlFont() )
77 aFont
.Merge( GetControlFont() );
78 SetPointFont(*this, aFont
);
79 // Set/*Zoomed*/PointFont( aFont );
82 if ( bFont
|| bForeground
)
84 Color aTextColor
= rStyleSettings
.GetButtonTextColor();
85 if ( IsControlForeground() )
86 aTextColor
= GetControlForeground();
87 SetTextColor( aTextColor
);
92 if( IsControlBackground() )
93 SetBackground( GetControlBackground() );
95 SetBackground( rStyleSettings
.GetFaceColor() );
99 void OSplitterView::DataChanged( const DataChangedEvent
& rDCEvt
)
101 Window::DataChanged( rDCEvt
);
103 if ( (rDCEvt
.GetType() == DataChangedEventType::SETTINGS
) &&
104 (rDCEvt
.GetFlags() & AllSettingsFlags::STYLE
) )
106 ImplInitSettings( true, true, true );
111 void OSplitterView::GetFocus()
115 // forward the focus to the current cell of the editor control
117 m_pLeft
->GrabFocus();
119 m_pRight
->GrabFocus();
122 void OSplitterView::Resize()
125 OSL_ENSURE( m_pRight
, "No init called!");
129 Point
aPlaygroundPos( 0,0 );
130 Size
aPlaygroundSize( GetOutputSizePixel() );
132 if ( m_pLeft
&& m_pLeft
->IsVisible() && m_pSplitter
)
134 aSplitPos
= m_pSplitter
->GetPosPixel();
135 aSplitSize
= m_pSplitter
->GetOutputSizePixel();
138 // calculate the splitter pos and size
139 aSplitPos
.Y() = aPlaygroundPos
.Y();
140 aSplitSize
.Height() = aPlaygroundSize
.Height();
142 if( ( aSplitPos
.X() + aSplitSize
.Width() ) > ( aPlaygroundSize
.Width() ))
143 aSplitPos
.X() = aPlaygroundSize
.Width() - aSplitSize
.Width();
145 if( aSplitPos
.X() <= aPlaygroundPos
.X() )
146 aSplitPos
.X() = aPlaygroundPos
.X() + sal_Int32(aPlaygroundSize
.Width() * 0.3);
148 // the tree pos and size
149 Point
aTreeViewPos( aPlaygroundPos
);
150 Size
aTreeViewSize( aSplitPos
.X(), aPlaygroundSize
.Height() );
152 // set the size of treelistbox
153 m_pLeft
->SetPosSizePixel( aTreeViewPos
, aTreeViewSize
);
155 //set the size of the splitter
156 m_pSplitter
->SetPosSizePixel( aSplitPos
, Size( aSplitSize
.Width(), aPlaygroundSize
.Height() ) );
157 m_pSplitter
->SetDragRectPixel( Rectangle(aPlaygroundPos
,aPlaygroundSize
) );
161 aSplitPos
.X() = aPlaygroundPos
.X();
162 aSplitSize
.Width() = aPlaygroundSize
.Width();
164 if( ( aSplitPos
.Y() + aSplitSize
.Height() ) > ( aPlaygroundSize
.Height() ))
165 aSplitPos
.Y() = aPlaygroundSize
.Height() - aSplitSize
.Height();
167 if( aSplitPos
.Y() <= aPlaygroundPos
.Y() )
168 aSplitPos
.Y() = aPlaygroundPos
.Y() + sal_Int32(aPlaygroundSize
.Height() * 0.3);
170 // the tree pos and size
171 Point
aTreeViewPos( aPlaygroundPos
);
172 Size
aTreeViewSize( aPlaygroundSize
.Width() ,aSplitPos
.Y());
174 // set the size of treelistbox
175 m_pLeft
->SetPosSizePixel( aTreeViewPos
, aTreeViewSize
);
177 //set the size of the splitter
178 m_pSplitter
->SetPosSizePixel( aSplitPos
, Size( aPlaygroundSize
.Width(), aSplitSize
.Height() ) );
179 m_pSplitter
->SetDragRectPixel( Rectangle(aPlaygroundPos
,aPlaygroundSize
) );
186 m_pRight
->setPosSizePixel( aSplitPos
.X() + aSplitSize
.Width(), aPlaygroundPos
.Y(),
187 aPlaygroundSize
.Width() - aSplitSize
.Width() - aSplitPos
.X(), aPlaygroundSize
.Height());
189 m_pRight
->setPosSizePixel( aSplitPos
.X(), aPlaygroundPos
.Y() + aSplitPos
.Y() + aSplitSize
.Height(),
190 aPlaygroundSize
.Width() , aPlaygroundSize
.Height() - aSplitSize
.Height() - aSplitPos
.Y());
195 void OSplitterView::set(vcl::Window
* _pRight
,Window
* _pLeft
)
201 void OSplitterView::setSplitter(Splitter
* _pSplitter
)
203 m_pSplitter
= _pSplitter
;
206 m_pSplitter
->SetSplitPosPixel( LogicToPixel( Size( SPLITTER_WIDTH
, 0 ), MAP_APPFONT
).Width() );
207 m_pSplitter
->SetSplitHdl( LINK(this, OSplitterView
, SplitHdl
) );
209 LINK( this, OSplitterView
, SplitHdl
).Call(m_pSplitter
);
213 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */