1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_dbaccess.hxx" 30*cdf0e10cSrcweir #ifndef DBAUI_VERTSPLITVIEW_HXX 31*cdf0e10cSrcweir #include "VertSplitView.hxx" 32*cdf0e10cSrcweir #endif 33*cdf0e10cSrcweir 34*cdf0e10cSrcweir #ifndef _TOOLS_DEBUG_HXX 35*cdf0e10cSrcweir #include <tools/debug.hxx> 36*cdf0e10cSrcweir #endif 37*cdf0e10cSrcweir 38*cdf0e10cSrcweir #define SPLITTER_WIDTH 80 39*cdf0e10cSrcweir 40*cdf0e10cSrcweir using namespace ::dbaui; 41*cdf0e10cSrcweir 42*cdf0e10cSrcweir //================================================================== 43*cdf0e10cSrcweir // class OSplitterView 44*cdf0e10cSrcweir //================================================================== 45*cdf0e10cSrcweir DBG_NAME(OSplitterView) 46*cdf0e10cSrcweir OSplitterView::OSplitterView(Window* _pParent,sal_Bool _bVertical) : Window(_pParent,WB_DIALOGCONTROL) // ,WB_BORDER 47*cdf0e10cSrcweir ,m_pSplitter( NULL ) 48*cdf0e10cSrcweir ,m_pLeft(NULL) 49*cdf0e10cSrcweir ,m_pRight(NULL) 50*cdf0e10cSrcweir ,m_bVertical(_bVertical) 51*cdf0e10cSrcweir { 52*cdf0e10cSrcweir DBG_CTOR(OSplitterView,NULL); 53*cdf0e10cSrcweir ImplInitSettings( sal_True, sal_True, sal_True ); 54*cdf0e10cSrcweir } 55*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 56*cdf0e10cSrcweir OSplitterView::~OSplitterView() 57*cdf0e10cSrcweir { 58*cdf0e10cSrcweir DBG_DTOR(OSplitterView,NULL); 59*cdf0e10cSrcweir m_pRight = m_pLeft = NULL; 60*cdf0e10cSrcweir } 61*cdf0e10cSrcweir //------------------------------------------------------------------------------ 62*cdf0e10cSrcweir IMPL_LINK( OSplitterView, SplitHdl, Splitter*, /*pSplit*/ ) 63*cdf0e10cSrcweir { 64*cdf0e10cSrcweir OSL_ENSURE(m_pSplitter, "Splitter is NULL!"); 65*cdf0e10cSrcweir if ( m_bVertical ) 66*cdf0e10cSrcweir { 67*cdf0e10cSrcweir long nPosY = m_pSplitter->GetPosPixel().Y(); 68*cdf0e10cSrcweir m_pSplitter->SetPosPixel( Point( m_pSplitter->GetSplitPosPixel(), nPosY ) ); 69*cdf0e10cSrcweir } 70*cdf0e10cSrcweir else 71*cdf0e10cSrcweir m_pSplitter->SetPosPixel( Point( m_pSplitter->GetPosPixel().X(),m_pSplitter->GetSplitPosPixel() ) ); 72*cdf0e10cSrcweir 73*cdf0e10cSrcweir Resize(); 74*cdf0e10cSrcweir return 0L; 75*cdf0e10cSrcweir } 76*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 77*cdf0e10cSrcweir void OSplitterView::ImplInitSettings( sal_Bool bFont, sal_Bool bForeground, sal_Bool bBackground ) 78*cdf0e10cSrcweir { 79*cdf0e10cSrcweir const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings(); 80*cdf0e10cSrcweir 81*cdf0e10cSrcweir if ( bFont ) 82*cdf0e10cSrcweir { 83*cdf0e10cSrcweir Font aFont = rStyleSettings.GetAppFont(); 84*cdf0e10cSrcweir if ( IsControlFont() ) 85*cdf0e10cSrcweir aFont.Merge( GetControlFont() ); 86*cdf0e10cSrcweir SetPointFont( aFont ); 87*cdf0e10cSrcweir // Set/*Zoomed*/PointFont( aFont ); 88*cdf0e10cSrcweir } 89*cdf0e10cSrcweir 90*cdf0e10cSrcweir if ( bFont || bForeground ) 91*cdf0e10cSrcweir { 92*cdf0e10cSrcweir Color aTextColor = rStyleSettings.GetButtonTextColor(); 93*cdf0e10cSrcweir if ( IsControlForeground() ) 94*cdf0e10cSrcweir aTextColor = GetControlForeground(); 95*cdf0e10cSrcweir SetTextColor( aTextColor ); 96*cdf0e10cSrcweir } 97*cdf0e10cSrcweir 98*cdf0e10cSrcweir if ( bBackground ) 99*cdf0e10cSrcweir { 100*cdf0e10cSrcweir if( IsControlBackground() ) 101*cdf0e10cSrcweir SetBackground( GetControlBackground() ); 102*cdf0e10cSrcweir else 103*cdf0e10cSrcweir SetBackground( rStyleSettings.GetFaceColor() ); 104*cdf0e10cSrcweir } 105*cdf0e10cSrcweir } 106*cdf0e10cSrcweir // ----------------------------------------------------------------------- 107*cdf0e10cSrcweir void OSplitterView::DataChanged( const DataChangedEvent& rDCEvt ) 108*cdf0e10cSrcweir { 109*cdf0e10cSrcweir Window::DataChanged( rDCEvt ); 110*cdf0e10cSrcweir 111*cdf0e10cSrcweir if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) && 112*cdf0e10cSrcweir (rDCEvt.GetFlags() & SETTINGS_STYLE) ) 113*cdf0e10cSrcweir { 114*cdf0e10cSrcweir ImplInitSettings( sal_True, sal_True, sal_True ); 115*cdf0e10cSrcweir Invalidate(); 116*cdf0e10cSrcweir } 117*cdf0e10cSrcweir } 118*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 119*cdf0e10cSrcweir void OSplitterView::GetFocus() 120*cdf0e10cSrcweir { 121*cdf0e10cSrcweir Window::GetFocus(); 122*cdf0e10cSrcweir 123*cdf0e10cSrcweir // forward the focus to the current cell of the editor control 124*cdf0e10cSrcweir if ( m_pLeft ) 125*cdf0e10cSrcweir m_pLeft->GrabFocus(); 126*cdf0e10cSrcweir else if ( m_pRight ) 127*cdf0e10cSrcweir m_pRight->GrabFocus(); 128*cdf0e10cSrcweir } 129*cdf0e10cSrcweir 130*cdf0e10cSrcweir // ------------------------------------------------------------------------- 131*cdf0e10cSrcweir void OSplitterView::Resize() 132*cdf0e10cSrcweir { 133*cdf0e10cSrcweir Window::Resize(); 134*cdf0e10cSrcweir OSL_ENSURE( m_pRight, "No init called!"); 135*cdf0e10cSrcweir 136*cdf0e10cSrcweir Point aSplitPos; 137*cdf0e10cSrcweir Size aSplitSize; 138*cdf0e10cSrcweir Point aPlaygroundPos( 0,0 ); 139*cdf0e10cSrcweir Size aPlaygroundSize( GetOutputSizePixel() ); 140*cdf0e10cSrcweir 141*cdf0e10cSrcweir if ( m_pLeft && m_pLeft->IsVisible() && m_pSplitter ) 142*cdf0e10cSrcweir { 143*cdf0e10cSrcweir aSplitPos = m_pSplitter->GetPosPixel(); 144*cdf0e10cSrcweir aSplitSize = m_pSplitter->GetOutputSizePixel(); 145*cdf0e10cSrcweir if ( m_bVertical ) 146*cdf0e10cSrcweir { 147*cdf0e10cSrcweir // calculate the splitter pos and size 148*cdf0e10cSrcweir aSplitPos.Y() = aPlaygroundPos.Y(); 149*cdf0e10cSrcweir aSplitSize.Height() = aPlaygroundSize.Height(); 150*cdf0e10cSrcweir 151*cdf0e10cSrcweir if( ( aSplitPos.X() + aSplitSize.Width() ) > ( aPlaygroundSize.Width() )) 152*cdf0e10cSrcweir aSplitPos.X() = aPlaygroundSize.Width() - aSplitSize.Width(); 153*cdf0e10cSrcweir 154*cdf0e10cSrcweir if( aSplitPos.X() <= aPlaygroundPos.X() ) 155*cdf0e10cSrcweir aSplitPos.X() = aPlaygroundPos.X() + sal_Int32(aPlaygroundSize.Width() * 0.3); 156*cdf0e10cSrcweir 157*cdf0e10cSrcweir // the tree pos and size 158*cdf0e10cSrcweir Point aTreeViewPos( aPlaygroundPos ); 159*cdf0e10cSrcweir Size aTreeViewSize( aSplitPos.X(), aPlaygroundSize.Height() ); 160*cdf0e10cSrcweir 161*cdf0e10cSrcweir // set the size of treelistbox 162*cdf0e10cSrcweir m_pLeft->SetPosSizePixel( aTreeViewPos, aTreeViewSize ); 163*cdf0e10cSrcweir 164*cdf0e10cSrcweir //set the size of the splitter 165*cdf0e10cSrcweir m_pSplitter->SetPosSizePixel( aSplitPos, Size( aSplitSize.Width(), aPlaygroundSize.Height() ) ); 166*cdf0e10cSrcweir m_pSplitter->SetDragRectPixel( Rectangle(aPlaygroundPos,aPlaygroundSize) ); 167*cdf0e10cSrcweir } 168*cdf0e10cSrcweir else 169*cdf0e10cSrcweir { 170*cdf0e10cSrcweir aSplitPos.X() = aPlaygroundPos.X(); 171*cdf0e10cSrcweir aSplitSize.Width() = aPlaygroundSize.Width(); 172*cdf0e10cSrcweir 173*cdf0e10cSrcweir if( ( aSplitPos.Y() + aSplitSize.Height() ) > ( aPlaygroundSize.Height() )) 174*cdf0e10cSrcweir aSplitPos.Y() = aPlaygroundSize.Height() - aSplitSize.Height(); 175*cdf0e10cSrcweir 176*cdf0e10cSrcweir if( aSplitPos.Y() <= aPlaygroundPos.Y() ) 177*cdf0e10cSrcweir aSplitPos.Y() = aPlaygroundPos.Y() + sal_Int32(aPlaygroundSize.Height() * 0.3); 178*cdf0e10cSrcweir 179*cdf0e10cSrcweir // the tree pos and size 180*cdf0e10cSrcweir Point aTreeViewPos( aPlaygroundPos ); 181*cdf0e10cSrcweir Size aTreeViewSize( aPlaygroundSize.Width() ,aSplitPos.Y()); 182*cdf0e10cSrcweir 183*cdf0e10cSrcweir // set the size of treelistbox 184*cdf0e10cSrcweir m_pLeft->SetPosSizePixel( aTreeViewPos, aTreeViewSize ); 185*cdf0e10cSrcweir 186*cdf0e10cSrcweir //set the size of the splitter 187*cdf0e10cSrcweir m_pSplitter->SetPosSizePixel( aSplitPos, Size( aPlaygroundSize.Width(), aSplitSize.Height() ) ); 188*cdf0e10cSrcweir m_pSplitter->SetDragRectPixel( Rectangle(aPlaygroundPos,aPlaygroundSize) ); 189*cdf0e10cSrcweir } 190*cdf0e10cSrcweir } 191*cdf0e10cSrcweir 192*cdf0e10cSrcweir if ( m_pRight ) 193*cdf0e10cSrcweir { 194*cdf0e10cSrcweir if ( m_bVertical ) 195*cdf0e10cSrcweir m_pRight->SetPosSizePixel( aSplitPos.X() + aSplitSize.Width(), aPlaygroundPos.Y(), 196*cdf0e10cSrcweir aPlaygroundSize.Width() - aSplitSize.Width() - aSplitPos.X(), aPlaygroundSize.Height()); 197*cdf0e10cSrcweir else 198*cdf0e10cSrcweir m_pRight->SetPosSizePixel( aSplitPos.X(), aPlaygroundPos.Y() + aSplitPos.Y() + aSplitSize.Height(), 199*cdf0e10cSrcweir aPlaygroundSize.Width() , aPlaygroundSize.Height() - aSplitSize.Height() - aSplitPos.Y()); 200*cdf0e10cSrcweir } 201*cdf0e10cSrcweir 202*cdf0e10cSrcweir } 203*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 204*cdf0e10cSrcweir void OSplitterView::set(Window* _pRight,Window* _pLeft) 205*cdf0e10cSrcweir { 206*cdf0e10cSrcweir m_pLeft = _pLeft; 207*cdf0e10cSrcweir m_pRight = _pRight; 208*cdf0e10cSrcweir } 209*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 210*cdf0e10cSrcweir void OSplitterView::setSplitter(Splitter* _pSplitter) 211*cdf0e10cSrcweir { 212*cdf0e10cSrcweir m_pSplitter = _pSplitter; 213*cdf0e10cSrcweir if ( m_pSplitter ) 214*cdf0e10cSrcweir { 215*cdf0e10cSrcweir m_pSplitter->SetSplitPosPixel( LogicToPixel( Size( SPLITTER_WIDTH, 0 ), MAP_APPFONT ).Width() ); 216*cdf0e10cSrcweir m_pSplitter->SetSplitHdl( LINK(this, OSplitterView, SplitHdl) ); 217*cdf0e10cSrcweir m_pSplitter->Show(); 218*cdf0e10cSrcweir LINK( this, OSplitterView, SplitHdl ).Call(m_pSplitter); 219*cdf0e10cSrcweir } 220*cdf0e10cSrcweir } 221