diff options
Diffstat (limited to 'dbaccess/source/ui/app/AppSwapWindow.cxx')
-rw-r--r-- | dbaccess/source/ui/app/AppSwapWindow.cxx | 143 |
1 files changed, 47 insertions, 96 deletions
diff --git a/dbaccess/source/ui/app/AppSwapWindow.cxx b/dbaccess/source/ui/app/AppSwapWindow.cxx index e291bdb8a6ac..b1edf21f28a6 100644 --- a/dbaccess/source/ui/app/AppSwapWindow.cxx +++ b/dbaccess/source/ui/app/AppSwapWindow.cxx @@ -20,161 +20,112 @@ #include "AppSwapWindow.hxx" #include <helpids.h> #include "AppView.hxx" +#include <sfx2/thumbnailviewitem.hxx> #include <vcl/event.hxx> #include <vcl/mnemonic.hxx> -#include <vcl/settings.hxx> +#include <vcl/svapp.hxx> #include "AppController.hxx" 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; - -OApplicationSwapWindow::OApplicationSwapWindow( vcl::Window* _pParent, OAppBorderWindow& _rBorderWindow ) - :Window(_pParent,WB_DIALOGCONTROL ) - ,m_aIconControl(VclPtr<OApplicationIconControl>::Create(this)) - ,m_eLastType(E_NONE) - ,m_rBorderWin( _rBorderWindow ) -{ - ImplInitSettings(); - - m_aIconControl->SetClickHdl(LINK(this, OApplicationSwapWindow, OnContainerSelectHdl)); - m_aIconControl->setControlActionListener( &m_rBorderWin.getView()->getAppController() ); - m_aIconControl->SetHelpId(HID_APP_SWAP_ICONCONTROL); - m_aIconControl->Show(); -} -OApplicationSwapWindow::~OApplicationSwapWindow() +OApplicationSwapWindow::OApplicationSwapWindow(weld::Container* pParent, + OAppBorderWindow& rBorderWindow) + : OChildWindow(pParent, u"dbaccess/ui/appswapwindow.ui"_ustr, u"AppSwapWindow"_ustr) + , m_xIconControl( + new OApplicationIconControl(m_xBuilder->weld_scrolled_window(u"scroll"_ustr, true))) + , m_xIconControlWin(new weld::CustomWeld(*m_xBuilder, u"valueset"_ustr, *m_xIconControl)) + , m_eLastType(E_NONE) + , m_rBorderWin(rBorderWindow) + , m_nChangeEvent(nullptr) { - disposeOnce(); -} + m_xContainer->set_stack_background(); -void OApplicationSwapWindow::dispose() -{ - m_aIconControl.disposeAndClear(); - vcl::Window::dispose(); + m_xIconControl->SetHelpId(HID_APP_SWAP_ICONCONTROL); + m_xIconControl->Fill(); + m_xIconControl->setItemStateHdl(LINK(this, OApplicationSwapWindow, OnContainerSelectHdl)); + m_xIconControl->setControlActionListener(&m_rBorderWin.getView()->getAppController()); } -void OApplicationSwapWindow::Resize() +void OApplicationSwapWindow::GrabFocus() { - Size aFLSize = LogicToPixel(Size(8, 0), MapMode(MapUnit::MapAppFont)); - long nX = 0; - if ( m_aIconControl->GetEntryCount() != 0 ) - nX = m_aIconControl->GetBoundingBox( m_aIconControl->GetEntry(0) ).GetWidth() + aFLSize.Width(); - - Size aOutputSize = GetOutputSize(); - - m_aIconControl->SetPosSizePixel( Point(static_cast<long>((aOutputSize.Width() - nX)*0.5), 0) ,Size(nX,aOutputSize.Height())); - m_aIconControl->ArrangeIcons(); + if (m_xIconControl) + m_xIconControl->GrabFocus(); } -void OApplicationSwapWindow::ImplInitSettings() +bool OApplicationSwapWindow::HasChildPathFocus() const { - // FIXME RenderContext - const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings(); - vcl::Font aFont = rStyleSettings.GetFieldFont(); - aFont.SetColor( rStyleSettings.GetWindowTextColor() ); - SetPointFont(*this, aFont); - - SetTextColor( rStyleSettings.GetFieldTextColor() ); - SetTextFillColor(); - - SetBackground( rStyleSettings.GetFieldColor() ); + return m_xIconControl && m_xIconControl->HasFocus(); } -void OApplicationSwapWindow::DataChanged( const DataChangedEvent& rDCEvt ) +OApplicationSwapWindow::~OApplicationSwapWindow() { - Window::DataChanged( rDCEvt ); - if ( (rDCEvt.GetType() == DataChangedEventType::FONTS) || - (rDCEvt.GetType() == DataChangedEventType::DISPLAY) || - (rDCEvt.GetType() == DataChangedEventType::FONTSUBSTITUTION) || - ((rDCEvt.GetType() == DataChangedEventType::SETTINGS) && - (rDCEvt.GetFlags() & AllSettingsFlags::STYLE)) ) - { - ImplInitSettings(); - Invalidate(); - } + if (m_nChangeEvent) + Application::RemoveUserEvent(m_nChangeEvent); } void OApplicationSwapWindow::clearSelection() { - m_aIconControl->SetNoSelection(); - SvxIconChoiceCtrlEntry* pEntry = m_aIconControl->GetSelectedEntry(); - if ( pEntry ) - m_aIconControl->InvalidateEntry(pEntry); - m_aIconControl->GetClickHdl().Call(m_aIconControl.get()); + m_xIconControl->deselectItems(); + onContainerSelected(E_NONE); } -void OApplicationSwapWindow::createIconAutoMnemonics( MnemonicGenerator& _rMnemonics ) +void OApplicationSwapWindow::createIconAutoMnemonics(MnemonicGenerator& rMnemonics) { - m_aIconControl->CreateAutoMnemonics( _rMnemonics ); + m_xIconControl->createIconAutoMnemonics(rMnemonics); } -bool OApplicationSwapWindow::interceptKeyInput( const KeyEvent& _rEvent ) +bool OApplicationSwapWindow::interceptKeyInput(const KeyEvent& _rEvent) { const vcl::KeyCode& rKeyCode = _rEvent.GetKeyCode(); - if ( rKeyCode.GetModifier() == KEY_MOD2 ) - return m_aIconControl->DoKeyInput( _rEvent ); - + if (rKeyCode.GetModifier() == KEY_MOD2) + return m_xIconControl->DoKeyShortCut(_rEvent); // not handled return false; } ElementType OApplicationSwapWindow::getElementType() const { - SvxIconChoiceCtrlEntry* pEntry = m_aIconControl->GetSelectedEntry(); - return pEntry ? *static_cast<ElementType*>(pEntry->GetUserData()) : E_NONE; + return m_xIconControl->GetSelectedItem(); } -bool OApplicationSwapWindow::onContainerSelected( ElementType _eType ) +bool OApplicationSwapWindow::onContainerSelected(ElementType _eType) { - if ( m_eLastType == _eType ) + if (m_eLastType == _eType) return true; - if ( m_rBorderWin.getView()->getAppController().onContainerSelect( _eType ) ) + if (m_rBorderWin.getView()->getAppController().onContainerSelect(_eType)) { - if ( _eType != E_NONE ) + if (_eType != E_NONE) m_eLastType = _eType; return true; } - PostUserEvent( LINK( this, OApplicationSwapWindow, ChangeToLastSelected ), nullptr, true ); + if (!m_nChangeEvent) + m_nChangeEvent + = Application::PostUserEvent(LINK(this, OApplicationSwapWindow, ChangeToLastSelected)); return false; } -IMPL_LINK(OApplicationSwapWindow, OnContainerSelectHdl, SvtIconChoiceCtrl*, _pControl, void) +IMPL_LINK(OApplicationSwapWindow, OnContainerSelectHdl, const ThumbnailViewItem*, pEntry, void) { - SvxIconChoiceCtrlEntry* pEntry = _pControl->GetSelectedEntry(); - ElementType eType = E_NONE; - if ( pEntry ) + if (pEntry->mbSelected) { - eType = *static_cast<ElementType*>(pEntry->GetUserData()); - onContainerSelected( eType ); // i87582 + ElementType eType = static_cast<ElementType>(pEntry->mnId - 1); + onContainerSelected(eType); // i87582 } } IMPL_LINK_NOARG(OApplicationSwapWindow, ChangeToLastSelected, void*, void) { + m_nChangeEvent = nullptr; selectContainer(m_eLastType); } -void OApplicationSwapWindow::selectContainer(ElementType _eType) +void OApplicationSwapWindow::selectContainer(ElementType eType) { - sal_Int32 nCount = m_aIconControl->GetEntryCount(); - SvxIconChoiceCtrlEntry* pEntry = nullptr; - for (sal_Int32 i=0; i < nCount; ++i) - { - pEntry = m_aIconControl->GetEntry(i); - if ( pEntry && *static_cast<ElementType*>(pEntry->GetUserData()) == _eType ) - break; - pEntry = nullptr; - } - - if ( pEntry ) - m_aIconControl->SetCursor(pEntry); // this call also initiates a onContainerSelected call - else - onContainerSelected( _eType ); + m_xIconControl->deselectItems(); + m_xIconControl->SelectItem(eType + 1); // will trigger onContainerSelected } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |