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
) : Window(_pParent
,WB_DIALOGCONTROL
) // ,WB_BORDER
32 ,m_pSplitter( nullptr )
40 OSplitterView::~OSplitterView()
45 void OSplitterView::dispose()
50 vcl::Window::dispose();
53 IMPL_LINK_NOARG_TYPED( OSplitterView
, SplitHdl
, Splitter
*, void )
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() ) );
67 void OSplitterView::ImplInitSettings()
69 // FIXME RenderContext
70 const StyleSettings
& rStyleSettings
= GetSettings().GetStyleSettings();
72 vcl::Font aFont
= rStyleSettings
.GetAppFont();
73 if ( IsControlFont() )
74 aFont
.Merge( GetControlFont() );
75 SetPointFont(*this, aFont
);
76 // Set/*Zoomed*/PointFont( aFont );
78 Color aTextColor
= rStyleSettings
.GetButtonTextColor();
79 if ( IsControlForeground() )
80 aTextColor
= GetControlForeground();
81 SetTextColor( aTextColor
);
83 if( IsControlBackground() )
84 SetBackground( GetControlBackground() );
86 SetBackground( rStyleSettings
.GetFaceColor() );
89 void OSplitterView::DataChanged( const DataChangedEvent
& rDCEvt
)
91 Window::DataChanged( rDCEvt
);
93 if ( (rDCEvt
.GetType() == DataChangedEventType::SETTINGS
) &&
94 (rDCEvt
.GetFlags() & AllSettingsFlags::STYLE
) )
101 void OSplitterView::GetFocus()
105 // forward the focus to the current cell of the editor control
107 m_pLeft
->GrabFocus();
109 m_pRight
->GrabFocus();
112 void OSplitterView::Resize()
115 OSL_ENSURE( m_pRight
, "No init called!");
119 Point
aPlaygroundPos( 0,0 );
120 Size
aPlaygroundSize( GetOutputSizePixel() );
122 if ( m_pLeft
&& m_pLeft
->IsVisible() && m_pSplitter
)
124 aSplitPos
= m_pSplitter
->GetPosPixel();
125 aSplitSize
= m_pSplitter
->GetOutputSizePixel();
128 // calculate the splitter pos and size
129 aSplitPos
.Y() = aPlaygroundPos
.Y();
130 aSplitSize
.Height() = aPlaygroundSize
.Height();
132 if( ( aSplitPos
.X() + aSplitSize
.Width() ) > ( aPlaygroundSize
.Width() ))
133 aSplitPos
.X() = aPlaygroundSize
.Width() - aSplitSize
.Width();
135 if( aSplitPos
.X() <= aPlaygroundPos
.X() )
136 aSplitPos
.X() = aPlaygroundPos
.X() + sal_Int32(aPlaygroundSize
.Width() * 0.3);
138 // the tree pos and size
139 Point
aTreeViewPos( aPlaygroundPos
);
140 Size
aTreeViewSize( aSplitPos
.X(), aPlaygroundSize
.Height() );
142 // set the size of treelistbox
143 m_pLeft
->SetPosSizePixel( aTreeViewPos
, aTreeViewSize
);
145 //set the size of the splitter
146 m_pSplitter
->SetPosSizePixel( aSplitPos
, Size( aSplitSize
.Width(), aPlaygroundSize
.Height() ) );
147 m_pSplitter
->SetDragRectPixel( Rectangle(aPlaygroundPos
,aPlaygroundSize
) );
151 aSplitPos
.X() = aPlaygroundPos
.X();
152 aSplitSize
.Width() = aPlaygroundSize
.Width();
154 if( ( aSplitPos
.Y() + aSplitSize
.Height() ) > ( aPlaygroundSize
.Height() ))
155 aSplitPos
.Y() = aPlaygroundSize
.Height() - aSplitSize
.Height();
157 if( aSplitPos
.Y() <= aPlaygroundPos
.Y() )
158 aSplitPos
.Y() = aPlaygroundPos
.Y() + sal_Int32(aPlaygroundSize
.Height() * 0.3);
160 // the tree pos and size
161 Point
aTreeViewPos( aPlaygroundPos
);
162 Size
aTreeViewSize( aPlaygroundSize
.Width() ,aSplitPos
.Y());
164 // set the size of treelistbox
165 m_pLeft
->SetPosSizePixel( aTreeViewPos
, aTreeViewSize
);
167 //set the size of the splitter
168 m_pSplitter
->SetPosSizePixel( aSplitPos
, Size( aPlaygroundSize
.Width(), aSplitSize
.Height() ) );
169 m_pSplitter
->SetDragRectPixel( Rectangle(aPlaygroundPos
,aPlaygroundSize
) );
176 m_pRight
->setPosSizePixel( aSplitPos
.X() + aSplitSize
.Width(), aPlaygroundPos
.Y(),
177 aPlaygroundSize
.Width() - aSplitSize
.Width() - aSplitPos
.X(), aPlaygroundSize
.Height());
179 m_pRight
->setPosSizePixel( aSplitPos
.X(), aPlaygroundPos
.Y() + aSplitPos
.Y() + aSplitSize
.Height(),
180 aPlaygroundSize
.Width() , aPlaygroundSize
.Height() - aSplitSize
.Height() - aSplitPos
.Y());
185 void OSplitterView::set(vcl::Window
* _pRight
,Window
* _pLeft
)
191 void OSplitterView::setSplitter(Splitter
* _pSplitter
)
193 m_pSplitter
= _pSplitter
;
196 m_pSplitter
->SetSplitPosPixel( LogicToPixel( Size( SPLITTER_WIDTH
, 0 ), MAP_APPFONT
).Width() );
197 m_pSplitter
->SetSplitHdl( LINK(this, OSplitterView
, SplitHdl
) );
199 LINK( this, OSplitterView
, SplitHdl
).Call(m_pSplitter
);
203 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */