Files
libreoffice/dbaccess/source/ui/app/AppSwapWindow.cxx
Jens-Heiner Rechtien 461760a4fc INTEGRATION: CWS insight01 (1.1.2); FILE ADDED
2004/03/19 07:45:46 oj 1.1.2.12: #111075# ongoing work
2004/03/18 10:15:50 oj 1.1.2.11: #111075# ongoing work
2004/01/09 11:12:47 oj 1.1.2.10: #111075# ongoing work
2003/12/18 13:53:17 oj 1.1.2.9: #111075# ongoing work
2003/12/17 13:54:58 oj 1.1.2.8: #111075# ongoing work
2003/11/26 12:17:52 oj 1.1.2.7: #111075# ongoing work
2003/11/07 07:24:09 oj 1.1.2.6: #111075# new helpid for the iconcontrol
2003/10/24 06:38:46 oj 1.1.2.5: #111075# further changes
2003/09/18 05:59:27 oj 1.1.2.4: #111075# ongoing work
2003/08/29 09:36:31 oj 1.1.2.3: #111090# ongoning work
2003/08/20 06:43:13 oj 1.1.2.2: #111075# ongoning work
2003/08/15 08:55:38 oj 1.1.2.1: #111075# ongoing new dbaapp work
2004-08-02 14:29:56 +00:00

227 lines
7.7 KiB
C++

/*************************************************************************
*
* $RCSfile: AppSwapWindow.cxx,v $
*
* $Revision: 1.2 $
*
* last change: $Author: hr $ $Date: 2004-08-02 15:29:56 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the License); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an AS IS basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): Ocke Janssen
*
*
************************************************************************/
#ifndef DBAUI_APPSWAPWINDOW_HXX
#include "AppSwapWindow.hxx"
#endif
#ifndef _TOOLS_DEBUG_HXX
#include <tools/debug.hxx>
#endif
#ifndef _DBA_DBACCESS_HELPID_HRC_
#include "dbaccess_helpid.hrc"
#endif
#ifndef _DBU_APP_HRC_
#include "dbu_app.hrc"
#endif
#ifndef DBAUI_APPVIEW_HXX
#include "AppView.hxx"
#endif
#ifndef DBAUI_IAPPELEMENTNOTIFICATION_HXX
#include "IAppElementNotification.hxx"
#endif
#ifndef _DBAUI_MODULE_DBU_HXX_
#include "moduledbu.hxx"
#endif
#ifndef _SV_SVAPP_HXX
#include <vcl/svapp.hxx>
#endif
#include <memory>
using namespace ::dbaui;
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::sdbc;
using namespace ::com::sun::star::lang;
using namespace ::com::sun::star::container;
//==================================================================
// class OApplicationSwapWindow
//==================================================================
OApplicationSwapWindow::OApplicationSwapWindow(Window* _pParent,OAppBorderWindow* _pBorderWindow) : Control(_pParent,WB_DIALOGCONTROL )
,m_aIconControl(this)
,m_pBorderWin(_pBorderWindow)
,m_eLastType(E_NONE)
{
ImplInitSettings( sal_True, sal_True, sal_True );
m_aIconControl.SetClickHdl(LINK(this, OApplicationSwapWindow, OnContainerSelectHdl));
m_aIconControl.setControlActionListener(_pBorderWindow->getView()->getActionListener());
m_aIconControl.SetHelpId(HID_APP_SWAP_ICONCONTROL);
m_aIconControl.Show();
m_aIconControl.Enable(TRUE);
}
// -----------------------------------------------------------------------------
OApplicationSwapWindow::~OApplicationSwapWindow()
{
}
// -----------------------------------------------------------------------------
void OApplicationSwapWindow::Resize()
{
m_aIconControl.SetPosSizePixel( Point(0, 0 ),
GetOutputSize() );
m_aIconControl.ArrangeIcons();
}
// -----------------------------------------------------------------------------
void OApplicationSwapWindow::ImplInitSettings( sal_Bool bFont, sal_Bool bForeground, sal_Bool bBackground )
{
const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
if ( bFont )
{
Font aFont = rStyleSettings.GetAppFont();
if ( IsControlFont() )
aFont.Merge( GetControlFont() );
SetPointFont( aFont );
// Set/*Zoomed*/PointFont( aFont );
}
if ( bFont || bForeground )
{
Color aTextColor = rStyleSettings.GetButtonTextColor();
if ( IsControlForeground() )
aTextColor = GetControlForeground();
SetTextColor( aTextColor );
}
if ( bBackground )
{
if( IsControlBackground() )
SetBackground( GetControlBackground() );
else
SetBackground( rStyleSettings.GetFaceColor() );
}
}
// -----------------------------------------------------------------------
void OApplicationSwapWindow::DataChanged( const DataChangedEvent& rDCEvt )
{
Window::DataChanged( rDCEvt );
if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
(rDCEvt.GetFlags() & SETTINGS_STYLE) )
{
ImplInitSettings( sal_True, sal_True, sal_True );
Invalidate();
}
}
// -----------------------------------------------------------------------------
void OApplicationSwapWindow::clearSelection()
{
m_aIconControl.SetNoSelection();
ULONG nPos = 0;
SvxIconChoiceCtrlEntry* pEntry = m_aIconControl.GetSelectedEntry(nPos);
if ( pEntry )
m_aIconControl.InvalidateEntry(pEntry);
m_aIconControl.GetClickHdl().Call(&m_aIconControl);
}
// -----------------------------------------------------------------------------
ElementType OApplicationSwapWindow::getElementType() const
{
ULONG nPos = 0;
SvxIconChoiceCtrlEntry* pEntry = m_aIconControl.GetSelectedEntry(nPos);
return ( pEntry ) ? *static_cast<ElementType*>(pEntry->GetUserData()) : E_NONE;
}
// -----------------------------------------------------------------------------
IMPL_LINK(OApplicationSwapWindow, OnContainerSelectHdl, SvtIconChoiceCtrl*, _pControl)
{
ULONG nPos = 0;
SvxIconChoiceCtrlEntry* pEntry = _pControl->GetSelectedEntry( nPos );
ElementType eType = E_NONE;
if ( pEntry )
eType = *static_cast<ElementType*>(pEntry->GetUserData());
if ( m_eLastType != eType && eType != E_NONE )
{
if ( m_pBorderWin->getView()->getElementNotification()->onContainerSelect(eType) )
m_eLastType = eType;
else
{
PostUserEvent(LINK(this, OApplicationSwapWindow, ChangeToLastSelected));
}
}
return 1L;
}
//------------------------------------------------------------------------------
IMPL_LINK(OApplicationSwapWindow, ChangeToLastSelected, void*, EMPTYARG)
{
changeContainer(m_eLastType);
return 0L;
}
// -----------------------------------------------------------------------------
void OApplicationSwapWindow::changeContainer(ElementType _eType)
{
ULONG nCount = m_aIconControl.GetEntryCount();
SvxIconChoiceCtrlEntry* pEntry = NULL;
for (ULONG i=0; i < nCount; ++i)
{
pEntry = m_aIconControl.GetEntry(i);
if ( pEntry && *static_cast<ElementType*>(pEntry->GetUserData()) == _eType )
break;
pEntry = NULL;
}
if ( pEntry )
{
m_aIconControl.SetCursor(pEntry);
OnContainerSelectHdl(&m_aIconControl);
}
else
m_eLastType = E_NONE;
}