fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / dbaccess / source / ui / app / AppSwapWindow.cxx
blobd3654738e329a69bc45691b06f6f6647e4023da8
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 "AppSwapWindow.hxx"
21 #include <tools/debug.hxx>
22 #include "dbaccess_helpid.hrc"
23 #include "dbu_app.hrc"
24 #include "AppView.hxx"
25 #include <vcl/svapp.hxx>
26 #include <vcl/syswin.hxx>
27 #include <vcl/menu.hxx>
28 #include <vcl/mnemonic.hxx>
29 #include <vcl/settings.hxx>
30 #include "IApplicationController.hxx"
32 using namespace ::dbaui;
33 using namespace ::com::sun::star::uno;
34 using namespace ::com::sun::star::sdbc;
35 using namespace ::com::sun::star::lang;
36 using namespace ::com::sun::star::container;
38 // class OApplicationSwapWindow
39 OApplicationSwapWindow::OApplicationSwapWindow( vcl::Window* _pParent, OAppBorderWindow& _rBorderWindow )
40 :Window(_pParent,WB_DIALOGCONTROL )
41 ,m_aIconControl(VclPtr<OApplicationIconControl>::Create(this))
42 ,m_eLastType(E_NONE)
43 ,m_rBorderWin( _rBorderWindow )
46 ImplInitSettings( true, true, true );
48 m_aIconControl->SetClickHdl(LINK(this, OApplicationSwapWindow, OnContainerSelectHdl));
49 m_aIconControl->setControlActionListener( &m_rBorderWin.getView()->getAppController() );
50 m_aIconControl->SetHelpId(HID_APP_SWAP_ICONCONTROL);
51 m_aIconControl->Show();
54 OApplicationSwapWindow::~OApplicationSwapWindow()
56 disposeOnce();
59 void OApplicationSwapWindow::dispose()
61 m_aIconControl.disposeAndClear();
62 vcl::Window::dispose();
65 void OApplicationSwapWindow::Resize()
67 Size aFLSize = LogicToPixel( Size( 8, 0 ), MAP_APPFONT );
68 long nX = 0;
69 if ( m_aIconControl->GetEntryCount() != 0 )
70 nX = m_aIconControl->GetBoundingBox( m_aIconControl->GetEntry(0) ).GetWidth() + aFLSize.Width();
72 Size aOutputSize = GetOutputSize();
74 m_aIconControl->SetPosSizePixel( Point(static_cast<long>((aOutputSize.Width() - nX)*0.5), 0) ,Size(nX,aOutputSize.Height()));
75 m_aIconControl->ArrangeIcons();
78 void OApplicationSwapWindow::ImplInitSettings( bool bFont, bool bForeground, bool bBackground )
80 // FIXME RenderContext
81 const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
82 if( bFont )
84 vcl::Font aFont;
85 aFont = rStyleSettings.GetFieldFont();
86 aFont.SetColor( rStyleSettings.GetWindowTextColor() );
87 SetPointFont(*this, aFont);
90 if( bForeground || bFont )
92 SetTextColor( rStyleSettings.GetFieldTextColor() );
93 SetTextFillColor();
96 if( bBackground )
97 SetBackground( rStyleSettings.GetFieldColor() );
100 void OApplicationSwapWindow::DataChanged( const DataChangedEvent& rDCEvt )
102 Window::DataChanged( rDCEvt );
103 if ( (rDCEvt.GetType() == DataChangedEventType::FONTS) ||
104 (rDCEvt.GetType() == DataChangedEventType::DISPLAY) ||
105 (rDCEvt.GetType() == DataChangedEventType::FONTSUBSTITUTION) ||
106 ((rDCEvt.GetType() == DataChangedEventType::SETTINGS) &&
107 (rDCEvt.GetFlags() & AllSettingsFlags::STYLE)) )
109 ImplInitSettings( true, true, true );
110 Invalidate();
114 void OApplicationSwapWindow::clearSelection()
116 m_aIconControl->SetNoSelection();
117 sal_uLong nPos = 0;
118 SvxIconChoiceCtrlEntry* pEntry = m_aIconControl->GetSelectedEntry(nPos);
119 if ( pEntry )
120 m_aIconControl->InvalidateEntry(pEntry);
121 m_aIconControl->GetClickHdl().Call(m_aIconControl.get());
124 void OApplicationSwapWindow::createIconAutoMnemonics( MnemonicGenerator& _rMnemonics )
126 m_aIconControl->CreateAutoMnemonics( _rMnemonics );
129 bool OApplicationSwapWindow::interceptKeyInput( const KeyEvent& _rEvent )
131 const vcl::KeyCode& rKeyCode = _rEvent.GetKeyCode();
132 if ( rKeyCode.GetModifier() == KEY_MOD2 )
133 return m_aIconControl->DoKeyInput( _rEvent );
135 // not handled
136 return false;
139 ElementType OApplicationSwapWindow::getElementType() const
141 sal_uLong nPos = 0;
142 SvxIconChoiceCtrlEntry* pEntry = m_aIconControl->GetSelectedEntry(nPos);
143 return ( pEntry ) ? *static_cast<ElementType*>(pEntry->GetUserData()) : E_NONE;
146 bool OApplicationSwapWindow::onContainerSelected( ElementType _eType )
148 if ( m_eLastType == _eType )
149 return true;
151 if ( m_rBorderWin.getView()->getAppController().onContainerSelect( _eType ) )
153 if ( _eType != E_NONE )
154 m_eLastType = _eType;
155 return true;
158 PostUserEvent( LINK( this, OApplicationSwapWindow, ChangeToLastSelected ), NULL, true );
159 return false;
162 IMPL_LINK(OApplicationSwapWindow, OnContainerSelectHdl, SvtIconChoiceCtrl*, _pControl)
164 sal_uLong nPos = 0;
165 SvxIconChoiceCtrlEntry* pEntry = _pControl->GetSelectedEntry( nPos );
166 ElementType eType = E_NONE;
167 if ( pEntry )
169 eType = *static_cast<ElementType*>(pEntry->GetUserData());
170 onContainerSelected( eType ); // i87582
173 return 1L;
176 IMPL_LINK_NOARG(OApplicationSwapWindow, ChangeToLastSelected)
178 selectContainer(m_eLastType);
179 return 0L;
182 void OApplicationSwapWindow::selectContainer(ElementType _eType)
184 sal_uLong nCount = m_aIconControl->GetEntryCount();
185 SvxIconChoiceCtrlEntry* pEntry = NULL;
186 for (sal_uLong i=0; i < nCount; ++i)
188 pEntry = m_aIconControl->GetEntry(i);
189 if ( pEntry && *static_cast<ElementType*>(pEntry->GetUserData()) == _eType )
190 break;
191 pEntry = NULL;
194 if ( pEntry )
195 m_aIconControl->SetCursor(pEntry); // this call also initiates a onContainerSelected call
196 else
197 onContainerSelected( _eType );
200 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */