From d97cd7a1f0b06f7edea9c1ab96237a1f1b6e7255 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Sat, 3 Aug 2019 19:43:06 +0100 Subject: move Roadmap to vcl MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I3ddb2a4906351d4134c14a1e9af710c9e7aeb5c6 Reviewed-on: https://gerrit.libreoffice.org/76900 Tested-by: Jenkins Reviewed-by: Caolán McNamara Tested-by: Caolán McNamara --- svtools/Library_svt.mk | 1 - svtools/inc/roadmap.hxx | 113 ----- svtools/source/control/roadmap.cxx | 836 ------------------------------- svtools/source/dialogs/roadmapwizard.cxx | 26 +- svtools/source/inc/unoiface.hxx | 2 +- svtools/source/uno/unoiface.cxx | 32 +- 6 files changed, 30 insertions(+), 980 deletions(-) delete mode 100644 svtools/inc/roadmap.hxx delete mode 100644 svtools/source/control/roadmap.cxx (limited to 'svtools') diff --git a/svtools/Library_svt.mk b/svtools/Library_svt.mk index 0c811012b30a..e240d5492f9b 100644 --- a/svtools/Library_svt.mk +++ b/svtools/Library_svt.mk @@ -108,7 +108,6 @@ $(eval $(call gb_Library_add_exception_objects,svt,\ svtools/source/control/indexentryres \ svtools/source/control/inettbc \ svtools/source/control/managedmenubutton \ - svtools/source/control/roadmap \ svtools/source/control/ruler \ svtools/source/control/scriptedtext \ svtools/source/control/scrwin \ diff --git a/svtools/inc/roadmap.hxx b/svtools/inc/roadmap.hxx deleted file mode 100644 index b09afcd4e238..000000000000 --- a/svtools/inc/roadmap.hxx +++ /dev/null @@ -1,113 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . - */ -#ifndef INCLUDED_SVTOOLS_INC_ROADMAP_HXX -#define INCLUDED_SVTOOLS_INC_ROADMAP_HXX - -#include -#include -#include -#include -#include - -class Bitmap; - -namespace svt -{ - -struct RoadmapTypes -{ -public: - typedef sal_Int16 ItemId; - typedef sal_Int32 ItemIndex; -}; - -class RoadmapImpl; -class RoadmapItem; - -class SVT_DLLPUBLIC ORoadmap final : public Control, public RoadmapTypes -{ -public: - ORoadmap( vcl::Window* _pParent, WinBits _nWinStyle ); - virtual ~ORoadmap( ) override; - virtual void dispose() override; - - void SetRoadmapBitmap( const BitmapEx& maBitmap ); - - void EnableRoadmapItem( ItemId _nItemId, bool _bEnable ); - - void ChangeRoadmapItemLabel( ItemId _nID, const OUString& sLabel ); - void ChangeRoadmapItemID( ItemId _nID, ItemId NewID ); - - void SetRoadmapInteractive( bool _bInteractive ); - bool IsRoadmapInteractive(); - - void SetRoadmapComplete( bool _bComplete ); - bool IsRoadmapComplete() const; - - ItemIndex GetItemCount() const; - ItemId GetItemID( ItemIndex _nIndex ) const; - - void InsertRoadmapItem( ItemIndex Index, const OUString& RoadmapItem, ItemId _nUniqueId, bool _bEnabled ); - void ReplaceRoadmapItem( ItemIndex Index, const OUString& RoadmapItem, ItemId _nUniqueId, bool _bEnabled ); - void DeleteRoadmapItem( ItemIndex _nIndex ); - - ItemId GetCurrentRoadmapItemID() const; - bool SelectRoadmapItemByID( ItemId _nItemID ); - - void SetItemSelectHdl( const Link& _rHdl ); - Link const & GetItemSelectHdl( ) const; - virtual void DataChanged( const DataChangedEvent& rDCEvt ) override; - virtual void GetFocus() override; - virtual void ApplySettings( vcl::RenderContext& rRenderContext ) override; - -private: - bool PreNotify( NotifyEvent& rNEvt ) override; - - /// called when an item has been selected by any means - void Select(); - - DECL_LINK(ImplClickHdl, vcl::HyperLabel*, void); - - RoadmapItem* GetByIndex( ItemIndex _nItemIndex ); - const RoadmapItem* GetByIndex( ItemIndex _nItemIndex ) const; - - RoadmapItem* GetByID( ItemId _nID ); - const RoadmapItem* GetByID( ItemId _nID ) const; - RoadmapItem* GetPreviousHyperLabel( ItemIndex Index); - - void DrawHeadline(vcl::RenderContext& rRenderContext); - void DeselectOldRoadmapItems(); - ItemId GetNextAvailableItemId( ItemIndex NewIndex ); - ItemId GetPreviousAvailableItemId( ItemIndex NewIndex ); - RoadmapItem* GetByPointer(vcl::Window const * pWindow); - RoadmapItem* InsertHyperLabel( ItemIndex Index, const OUString& _aStr, ItemId RMID, bool _bEnabled, bool _bIncomplete ); - void UpdatefollowingHyperLabels( ItemIndex Index ); - - // Window overridables - void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& _rRect) override; - void implInit(vcl::RenderContext& rRenderContext); - - std::unique_ptr m_pImpl; -}; - -} // namespace svt - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svtools/source/control/roadmap.cxx b/svtools/source/control/roadmap.cxx deleted file mode 100644 index 7813a2394a0f..000000000000 --- a/svtools/source/control/roadmap.cxx +++ /dev/null @@ -1,836 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . - */ - -#include - -#include -#include -#include -#include -#include -#include - -#define ROADMAP_INDENT_X 4 -#define ROADMAP_INDENT_Y 27 -#define ROADMAP_ITEM_DISTANCE_Y 6 - -namespace svt -{ - -typedef std::vector< RoadmapItem* > HL_Vector; - -//= ColorChanger - -class IDLabel : public FixedText -{ -public: - IDLabel( vcl::Window* _pParent, WinBits _nWinStyle ); - virtual void DataChanged( const DataChangedEvent& rDCEvt ) override; - virtual void ApplySettings(vcl::RenderContext& rRenderContext) override; -}; - -class RoadmapItem : public RoadmapTypes -{ -private: - VclPtr mpID; - VclPtr mpDescription; - const Size m_aItemPlayground; - -public: - RoadmapItem( ORoadmap& _rParent, const Size& _rItemPlayground ); - ~RoadmapItem(); - - void SetID( sal_Int16 ID ); - sal_Int16 GetID() const; - - void SetIndex( ItemIndex Index ); - ItemIndex GetIndex() const; - - void Update( ItemIndex RMIndex, const OUString& _rText ); - - void SetPosition( RoadmapItem const * OldHyperLabel ); - - void ToggleBackgroundColor( const Color& _rGBColor ); - void SetInteractive( bool _bInteractive ); - - void SetClickHdl( const Link& rLink ); - void Enable( bool bEnable ); - bool IsEnabled() const; - void GrabFocus(); - - bool Contains( const vcl::Window* _pWindow ) const; - -private: - void ImplUpdateIndex( const ItemIndex _nIndex ); - void ImplUpdatePosSize(); -}; - -//= RoadmapImpl - -class RoadmapImpl : public RoadmapTypes -{ -protected: - const ORoadmap& m_rAntiImpl; - Link m_aSelectHdl; - BitmapEx m_aPicture; - HL_Vector m_aRoadmapSteps; - ItemId m_iCurItemID; - bool m_bInteractive : 1; - bool m_bComplete : 1; - Size m_aItemSizePixel; -public: - bool m_bPaintInitialized : 1; - -public: - explicit RoadmapImpl(const ORoadmap& rAntiImpl) - : m_rAntiImpl(rAntiImpl) - , m_iCurItemID(-1) - , m_bInteractive(true) - , m_bComplete(true) - , m_bPaintInitialized(false) - , InCompleteHyperLabel(nullptr) - {} - - RoadmapItem* InCompleteHyperLabel; - - HL_Vector& getHyperLabels() - { - return m_aRoadmapSteps; - } - - void insertHyperLabel(ItemIndex Index, RoadmapItem* _rRoadmapStep) - { - m_aRoadmapSteps.insert(m_aRoadmapSteps.begin() + Index, _rRoadmapStep); - } - - ItemIndex getItemCount() const - { - return m_aRoadmapSteps.size(); - } - - void setCurItemID(ItemId i) - { - m_iCurItemID = i; - } - ItemId getCurItemID() const - { - return m_iCurItemID; - } - - void setInteractive(const bool _bInteractive) - { - m_bInteractive = _bInteractive; - } - bool isInteractive() const - { - return m_bInteractive; - } - - void setComplete(const bool _bComplete) - { - m_bComplete = _bComplete; - } - bool isComplete() const - { - return m_bComplete; - } - - void setPicture(const BitmapEx& _rPic) - { - m_aPicture = _rPic; - } - const BitmapEx& getPicture() const - { - return m_aPicture; - } - - void setSelectHdl(const Link& _rHdl) - { - m_aSelectHdl = _rHdl; - } - const Link& getSelectHdl() const - { - return m_aSelectHdl; - } - - void initItemSize(); - const Size& getItemSize() const - { - return m_aItemSizePixel; - } - - void removeHyperLabel(ItemIndex Index) - { - if ((Index > -1) && (Index < getItemCount())) - { - delete m_aRoadmapSteps[Index]; - m_aRoadmapSteps.erase(m_aRoadmapSteps.begin() + Index); - } - } -}; - -void RoadmapImpl::initItemSize() -{ - Size aLabelSize( m_rAntiImpl.GetOutputSizePixel() ); - aLabelSize.setHeight( m_rAntiImpl.LogicToPixel(Size(0, LABELBASEMAPHEIGHT), MapMode(MapUnit::MapAppFont)).Height() ); - aLabelSize.AdjustWidth( -(m_rAntiImpl.LogicToPixel(Size(2 * ROADMAP_INDENT_X, 0), MapMode(MapUnit::MapAppFont)).Width()) ); - m_aItemSizePixel = aLabelSize; -} - -//= Roadmap - -ORoadmap::ORoadmap(vcl::Window* _pParent, WinBits _nWinStyle) - : Control(_pParent, _nWinStyle) - , m_pImpl(new RoadmapImpl(*this)) -{ -} - -void ORoadmap::implInit(vcl::RenderContext& rRenderContext) -{ - m_pImpl->InCompleteHyperLabel = nullptr; - m_pImpl->setCurItemID(-1); - m_pImpl->setComplete(true); - m_pImpl->m_bPaintInitialized = true; - - // Roadmap control should be reachable as one unit with a Tab key - // the next Tab key should spring out of the control. - // To reach it the control itself should get focus and set it - // on entries. The entries themself should not be reachable with - // the Tab key directly. So each entry should have WB_NOTABSTOP. - - // In other words the creator should create the control with the following - // flags: - // SetStyle( ( GetStyle() | WB_TABSTOP ) & ~WB_DIALOGCONTROL ); - -// TODO: if somebody sets a new font from outside (OutputDevice::SetFont), we would have to react -// on this with calculating a new bold font. -// Unfortunately, the OutputDevice does not offer a notify mechanism for a changed font. -// So settings the font from outside is simply a forbidden scenario at the moment - rRenderContext.EnableMapMode(false); -} - -ORoadmap::~ORoadmap() -{ - disposeOnce(); -} - -void ORoadmap::dispose() -{ - HL_Vector aItemsCopy = m_pImpl->getHyperLabels(); - m_pImpl->getHyperLabels().clear(); - for (auto const& itemCopy : aItemsCopy) - { - delete itemCopy; - } - if ( ! m_pImpl->isComplete() ) - delete m_pImpl->InCompleteHyperLabel; - m_pImpl.reset(); - Control::dispose(); -} - -RoadmapTypes::ItemId ORoadmap::GetCurrentRoadmapItemID() const -{ - return m_pImpl->getCurItemID(); -} - -RoadmapItem* ORoadmap::GetPreviousHyperLabel(ItemIndex Index) -{ - RoadmapItem* pOldItem = nullptr; - if ( Index > 0 ) - pOldItem = m_pImpl->getHyperLabels().at( Index - 1 ); - return pOldItem; -} - -RoadmapItem* ORoadmap::InsertHyperLabel(ItemIndex Index, const OUString& _sLabel, ItemId RMID, bool _bEnabled, bool _bIncomplete) -{ - if (m_pImpl->getItemCount() == 0) - m_pImpl->initItemSize(); - - RoadmapItem* pItem = nullptr; - RoadmapItem* pOldItem = GetPreviousHyperLabel( Index ); - - pItem = new RoadmapItem( *this, m_pImpl->getItemSize() ); - if ( _bIncomplete ) - { - pItem->SetInteractive( false ); - } - else - { - pItem->SetInteractive( m_pImpl->isInteractive() ); - m_pImpl->insertHyperLabel( Index, pItem ); - } - pItem->SetPosition( pOldItem ); - pItem->Update( Index, _sLabel ); - pItem->SetClickHdl(LINK( this, ORoadmap, ImplClickHdl ) ); - pItem->SetID( RMID ); - pItem->SetIndex( Index ); - if (!_bEnabled) - pItem->Enable( _bEnabled ); - return pItem; -} - -void ORoadmap::SetRoadmapBitmap(const BitmapEx& _rBmp) -{ - m_pImpl->setPicture( _rBmp ); - Invalidate( ); -} - -void ORoadmap::SetRoadmapInteractive(bool _bInteractive) -{ - m_pImpl->setInteractive( _bInteractive ); - - const HL_Vector& rItems = m_pImpl->getHyperLabels(); - for (auto const& item : rItems) - { - item->SetInteractive( _bInteractive ); - } -} - -bool ORoadmap::IsRoadmapInteractive() -{ - return m_pImpl->isInteractive(); -} - -void ORoadmap::SetRoadmapComplete(bool _bComplete) -{ - bool bWasComplete = m_pImpl->isComplete(); - m_pImpl->setComplete( _bComplete ); - if (_bComplete) - { - if (m_pImpl->InCompleteHyperLabel != nullptr) - { - delete m_pImpl->InCompleteHyperLabel; - m_pImpl->InCompleteHyperLabel = nullptr; - } - } - else if (bWasComplete) - m_pImpl->InCompleteHyperLabel = InsertHyperLabel(m_pImpl->getItemCount(), "...", -1, true/*bEnabled*/, true/*bIncomplete*/ ); -} - -void ORoadmap::UpdatefollowingHyperLabels(ItemIndex _nIndex) -{ - const HL_Vector& rItems = m_pImpl->getHyperLabels(); - if ( _nIndex < static_cast(rItems.size()) ) - { - for ( HL_Vector::const_iterator i = rItems.begin() + _nIndex; - i != rItems.end(); - ++i, ++_nIndex - ) - { - RoadmapItem* pItem = *i; - - pItem->SetIndex( _nIndex ); - pItem->SetPosition( GetPreviousHyperLabel( _nIndex ) ); - } - - } - if ( ! m_pImpl->isComplete() ) - { - RoadmapItem* pOldItem = GetPreviousHyperLabel( m_pImpl->getItemCount() ); - m_pImpl->InCompleteHyperLabel->SetPosition( pOldItem ); - m_pImpl->InCompleteHyperLabel->Update( m_pImpl->getItemCount(), "..." ); - } -} - -void ORoadmap::ReplaceRoadmapItem(ItemIndex Index, const OUString& roadmapItem, ItemId RMID, bool _bEnabled) -{ - RoadmapItem* pItem = GetByIndex( Index); - if ( pItem != nullptr ) - { - pItem->Update( Index, roadmapItem ); - pItem->SetID( RMID ); - pItem->Enable( _bEnabled ); - } -} - -RoadmapTypes::ItemIndex ORoadmap::GetItemCount() const -{ - return m_pImpl->getItemCount(); -} - -RoadmapTypes::ItemId ORoadmap::GetItemID(ItemIndex _nIndex) const -{ - const RoadmapItem* pHyperLabel = GetByIndex( _nIndex ); - if ( pHyperLabel ) - return pHyperLabel->GetID(); - return -1; -} - -void ORoadmap::InsertRoadmapItem(ItemIndex Index, const OUString& RoadmapItem, ItemId _nUniqueId, bool _bEnabled) -{ - InsertHyperLabel( Index, RoadmapItem, _nUniqueId, _bEnabled, false/*bIncomplete*/ ); - // TODO YPos is superfluous, if items are always appended - UpdatefollowingHyperLabels( Index + 1 ); -} - -void ORoadmap::DeleteRoadmapItem(ItemIndex Index) -{ - if ( m_pImpl->getItemCount() > 0 && ( Index > -1) && ( Index < m_pImpl->getItemCount() ) ) - { - m_pImpl->removeHyperLabel( Index ); - UpdatefollowingHyperLabels( Index ); - } -} - -bool ORoadmap::IsRoadmapComplete() const -{ - return m_pImpl->isComplete(); -} - -void ORoadmap::EnableRoadmapItem( ItemId _nItemId, bool _bEnable ) -{ - RoadmapItem* pItem = GetByID( _nItemId ); - if ( pItem != nullptr ) - pItem->Enable( _bEnable ); -} - -void ORoadmap::ChangeRoadmapItemLabel( ItemId _nID, const OUString& _sLabel ) -{ - RoadmapItem* pItem = GetByID( _nID ); - if ( pItem == nullptr ) - return; - - pItem->Update( pItem->GetIndex(), _sLabel ); - - const HL_Vector& rItems = m_pImpl->getHyperLabels(); - size_t nPos = 0; - for (auto const& item : rItems) - { - item->SetPosition( GetPreviousHyperLabel(nPos) ); - ++nPos; - } -} - -void ORoadmap::ChangeRoadmapItemID(ItemId _nID, ItemId NewID) -{ - RoadmapItem* pItem = GetByID( _nID ); - if ( pItem != nullptr ) - pItem->SetID( NewID ); -} - -RoadmapItem* ORoadmap::GetByID(ItemId _nID) -{ - ItemId nLocID = 0; - const HL_Vector& rItems = m_pImpl->getHyperLabels(); - for (auto const& item : rItems) - { - nLocID = item->GetID(); - if ( nLocID == _nID ) - return item; - } - return nullptr; -} - -const RoadmapItem* ORoadmap::GetByID(ItemId _nID) const -{ - return const_cast< ORoadmap* >( this )->GetByID( _nID ); -} - -RoadmapItem* ORoadmap::GetByIndex(ItemIndex _nItemIndex) -{ - const HL_Vector& rItems = m_pImpl->getHyperLabels(); - if ( ( _nItemIndex > -1 ) && ( _nItemIndex < static_cast(rItems.size()) ) ) - { - return rItems.at( _nItemIndex ); - } - return nullptr; -} - -const RoadmapItem* ORoadmap::GetByIndex(ItemIndex _nItemIndex) const -{ - return const_cast< ORoadmap* >( this )->GetByIndex( _nItemIndex ); -} - -RoadmapTypes::ItemId ORoadmap::GetNextAvailableItemId(ItemIndex _nNewIndex) -{ - ItemIndex searchIndex = ++_nNewIndex; - while ( searchIndex < m_pImpl->getItemCount() ) - { - RoadmapItem* pItem = GetByIndex( searchIndex ); - if ( pItem->IsEnabled() ) - return pItem->GetID( ); - - ++searchIndex; - } - return -1; -} - -RoadmapTypes::ItemId ORoadmap::GetPreviousAvailableItemId(ItemIndex _nNewIndex) -{ - ItemIndex searchIndex = --_nNewIndex; - while ( searchIndex > -1 ) - { - RoadmapItem* pItem = GetByIndex( searchIndex ); - if ( pItem->IsEnabled() ) - return pItem->GetID( ); - - searchIndex--; - } - return -1; -} - -void ORoadmap::DeselectOldRoadmapItems() -{ - const HL_Vector& rItems = m_pImpl->getHyperLabels(); - for (auto const& item : rItems) - { - item->ToggleBackgroundColor( COL_TRANSPARENT ); - } -} - -void ORoadmap::SetItemSelectHdl(const Link& _rHdl) -{ - m_pImpl->setSelectHdl(_rHdl); -} - -Link const & ORoadmap::GetItemSelectHdl() const -{ - return m_pImpl->getSelectHdl(); -} - -void ORoadmap::Select() -{ - GetItemSelectHdl().Call( nullptr ); - CallEventListeners( VclEventId::RoadmapItemSelected ); -} - -void ORoadmap::GetFocus() -{ - RoadmapItem* pCurHyperLabel = GetByID( GetCurrentRoadmapItemID() ); - if ( pCurHyperLabel != nullptr ) - pCurHyperLabel->GrabFocus(); -} - -bool ORoadmap::SelectRoadmapItemByID( ItemId _nNewID ) -{ - DeselectOldRoadmapItems(); - RoadmapItem* pItem = GetByID( _nNewID ); - if ( pItem != nullptr ) - { - if ( pItem->IsEnabled() ) - { - const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings(); - pItem->ToggleBackgroundColor( rStyleSettings.GetHighlightColor() ); //HighlightColor - - pItem->GrabFocus(); - m_pImpl->setCurItemID(_nNewID); - - Select(); - return true; - } - } - return false; -} - -void ORoadmap::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& _rRect) -{ - if (!m_pImpl->m_bPaintInitialized) - implInit(rRenderContext); - Control::Paint(rRenderContext, _rRect); - - // draw the bitmap - if (!!m_pImpl->getPicture()) - { - Size aBitmapSize = m_pImpl->getPicture().GetSizePixel(); - Size aMySize(GetOutputSizePixel()); - - Point aBitmapPos(aMySize.Width() - aBitmapSize.Width(), aMySize.Height() - aBitmapSize.Height()); - - // draw it - rRenderContext.DrawBitmapEx( aBitmapPos, m_pImpl->getPicture() ); - } - - // draw the headline - DrawHeadline(rRenderContext); -} - -void ORoadmap::DrawHeadline(vcl::RenderContext& rRenderContext) -{ - Point aTextPos = LogicToPixel(Point(ROADMAP_INDENT_X, 8), MapMode(MapUnit::MapAppFont)); - - Size aOutputSize(GetOutputSizePixel()); - - // draw it - rRenderContext.DrawText(tools::Rectangle(aTextPos, aOutputSize), GetText(), - DrawTextFlags::Left | DrawTextFlags::Top | DrawTextFlags::MultiLine | DrawTextFlags::WordBreak); - rRenderContext.DrawTextLine(aTextPos, aOutputSize.Width(), STRIKEOUT_NONE, LINESTYLE_SINGLE, LINESTYLE_NONE); - const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings(); - rRenderContext.SetLineColor(rStyleSettings.GetFieldTextColor()); - rRenderContext.SetTextColor(rStyleSettings.GetFieldTextColor()); -} - -RoadmapItem* ORoadmap::GetByPointer(vcl::Window const * pWindow) -{ - const HL_Vector& rItems = m_pImpl->getHyperLabels(); - for (auto const& item : rItems) - { - if ( item->Contains( pWindow ) ) - return item; - } - return nullptr; -} - -bool ORoadmap::PreNotify(NotifyEvent& _rNEvt) -{ - // capture KeyEvents for taskpane cycling - if ( _rNEvt.GetType() == MouseNotifyEvent::KEYINPUT ) - { - vcl::Window* pWindow = _rNEvt.GetWindow(); - RoadmapItem* pItem = GetByPointer( pWindow ); - if ( pItem != nullptr ) - { - sal_Int16 nKeyCode = _rNEvt.GetKeyEvent()->GetKeyCode().GetCode(); - switch( nKeyCode ) - { - case KEY_UP: - { // Note: Performancewise this is not optimal, because we search for an ID in the labels - // and afterwards we search again for a label with the appropriate ID -> - // unnecessarily we search twice!!! - ItemId nPrevItemID = GetPreviousAvailableItemId( pItem->GetIndex() ); - if ( nPrevItemID != -1 ) - return SelectRoadmapItemByID( nPrevItemID ); - } - break; - case KEY_DOWN: - { - ItemId nNextItemID = GetNextAvailableItemId( pItem->GetIndex() ); - if ( nNextItemID != -1 ) - return SelectRoadmapItemByID( nNextItemID ); - } - break; - case KEY_SPACE: - return SelectRoadmapItemByID( pItem->GetID() ); - } - } - } - return Window::PreNotify( _rNEvt ); -} - -IMPL_LINK(ORoadmap, ImplClickHdl, vcl::HyperLabel*, CurHyperLabel, void) -{ - SelectRoadmapItemByID( CurHyperLabel->GetID() ); -} - -void ORoadmap::DataChanged(const DataChangedEvent& rDCEvt) -{ - if (!((( rDCEvt.GetType() == DataChangedEventType::SETTINGS ) || - ( rDCEvt.GetType() == DataChangedEventType::DISPLAY )) && - ( rDCEvt.GetFlags() & AllSettingsFlags::STYLE ))) - return; - - const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings(); - SetBackground( Wallpaper( rStyleSettings.GetFieldColor() ) ); - Color aTextColor = rStyleSettings.GetFieldTextColor(); - vcl::Font aFont = GetFont(); - aFont.SetColor( aTextColor ); - SetFont( aFont ); - RoadmapTypes::ItemId curItemID = GetCurrentRoadmapItemID(); - RoadmapItem* pLabelItem = GetByID( curItemID ); - if (pLabelItem != nullptr) - { - pLabelItem->ToggleBackgroundColor(rStyleSettings.GetHighlightColor()); - } - Invalidate(); -} - -void ORoadmap::ApplySettings(vcl::RenderContext& rRenderContext) -{ - const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings(); - Color aTextColor = rStyleSettings.GetFieldTextColor(); - vcl::Font aFont = rRenderContext.GetFont(); - aFont.SetColor(aTextColor); - aFont.SetWeight(WEIGHT_BOLD); - aFont.SetUnderline(LINESTYLE_SINGLE); - rRenderContext.SetFont(aFont); - rRenderContext.SetBackground(rStyleSettings.GetFieldColor()); -} - -RoadmapItem::RoadmapItem(ORoadmap& _rParent, const Size& _rItemPlayground) - : m_aItemPlayground(_rItemPlayground) -{ - mpID = VclPtr::Create( &_rParent, WB_WORDBREAK ); - mpID->Show(); - mpDescription = VclPtr::Create( &_rParent, WB_NOTABSTOP | WB_WORDBREAK ); - mpDescription->Show(); -} - -RoadmapItem::~RoadmapItem() -{ - mpID.disposeAndClear(); - mpDescription.disposeAndClear(); -} - -bool RoadmapItem::Contains(const vcl::Window* _pWindow) const -{ - return ( mpID == _pWindow ) || ( mpDescription == _pWindow ); -} - -void RoadmapItem::GrabFocus() -{ - if ( mpDescription ) - mpDescription->GrabFocus(); -} - -void RoadmapItem::SetInteractive(bool _bInteractive) -{ - if ( mpDescription ) - mpDescription->SetInteractive(_bInteractive); -} - -void RoadmapItem::SetID(sal_Int16 ID) -{ - if ( mpDescription ) - mpDescription->SetID(ID); -} - -sal_Int16 RoadmapItem::GetID() const -{ - return mpDescription ? mpDescription->GetID() : sal_Int16(-1); -} - -void RoadmapItem::ImplUpdateIndex(const ItemIndex _nIndex) -{ - mpDescription->SetIndex( _nIndex ); - - OUString aIDText = OUString::number( _nIndex + 1 ) + "."; - mpID->SetText( aIDText ); - - // update the geometry of both controls - ImplUpdatePosSize(); -} - -void RoadmapItem::SetIndex(ItemIndex Index) -{ - ImplUpdateIndex(Index); -} - -RoadmapTypes::ItemIndex RoadmapItem::GetIndex() const -{ - return mpDescription ? mpDescription->GetIndex() : ItemIndex(-1); -} - -void RoadmapItem::SetPosition(RoadmapItem const * _pOldItem) -{ - Point aIDPos; - if ( _pOldItem == nullptr ) - { - aIDPos = mpID->LogicToPixel(Point(ROADMAP_INDENT_X, ROADMAP_INDENT_Y), MapMode(MapUnit::MapAppFont)); - } - else - { - Size aOldSize = _pOldItem->mpDescription->GetSizePixel(); - - aIDPos = _pOldItem->mpID->GetPosPixel(); - aIDPos.AdjustY(aOldSize.Height() ); - aIDPos.AdjustY(mpID->GetParent()->LogicToPixel( Size( 0, ROADMAP_ITEM_DISTANCE_Y ) ).Height() ); - } - mpID->SetPosPixel( aIDPos ); - - sal_Int32 nDescPos = aIDPos.X() + mpID->GetSizePixel().Width(); - mpDescription->SetPosPixel( Point( nDescPos, aIDPos.Y() ) ); -} - -void RoadmapItem::Enable(bool _bEnable) -{ - mpID->Enable(_bEnable); - mpDescription->Enable(_bEnable); -} - -bool RoadmapItem::IsEnabled() const -{ - return mpID->IsEnabled(); -} - -void RoadmapItem::ToggleBackgroundColor(const Color& _rGBColor) -{ - if (_rGBColor == COL_TRANSPARENT) - mpID->SetControlBackground(); - else - mpID->SetControlBackground( mpID->GetSettings().GetStyleSettings().GetHighlightColor() ); - mpDescription->ToggleBackgroundColor(_rGBColor); -} - -void RoadmapItem::ImplUpdatePosSize() -{ - // calculate widths - long nIDWidth = mpID->GetTextWidth( mpID->GetText() ); - long nMaxIDWidth = mpID->GetTextWidth( "100." ); - nIDWidth = ::std::min( nIDWidth, nMaxIDWidth ); - - // check how many space the description would need - Size aDescriptionSize = mpDescription->CalcMinimumSize( m_aItemPlayground.Width() - nIDWidth ); - - // position and size both controls - Size aIDSize( nIDWidth, aDescriptionSize.Height() ); - mpID->SetSizePixel( aIDSize ); - - Point aIDPos = mpID->GetPosPixel(); - mpDescription->SetPosPixel( Point( aIDPos.X() + nIDWidth, aIDPos.Y() ) ); - mpDescription->SetSizePixel( aDescriptionSize ); -} - -void RoadmapItem::Update(ItemIndex RMIndex, const OUString& _rText) -{ - // update description label - mpDescription->SetLabel( _rText ); - - // update the index in both controls, which triggers updating the geometry of both - ImplUpdateIndex( RMIndex ); -} - -void RoadmapItem::SetClickHdl(const Link& rLink) -{ - if ( mpDescription ) - mpDescription->SetClickHdl( rLink); -} - -IDLabel::IDLabel(vcl::Window* _pParent, WinBits _nWinStyle) - : FixedText(_pParent, _nWinStyle) -{ -} - -void IDLabel::ApplySettings(vcl::RenderContext& rRenderContext) -{ - FixedText::ApplySettings(rRenderContext); - - const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings(); - if (GetControlBackground() == COL_TRANSPARENT) - rRenderContext.SetTextColor(rStyleSettings.GetFieldTextColor()); - else - rRenderContext.SetTextColor(rStyleSettings.GetHighlightTextColor()); -} - -void IDLabel::DataChanged(const DataChangedEvent& rDCEvt) -{ - FixedText::DataChanged( rDCEvt ); - - if ((( rDCEvt.GetType() == DataChangedEventType::SETTINGS ) || - ( rDCEvt.GetType() == DataChangedEventType::DISPLAY )) && - ( rDCEvt.GetFlags() & AllSettingsFlags::STYLE )) - { - const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings(); - if (GetControlBackground() != COL_TRANSPARENT) - SetControlBackground(rStyleSettings.GetHighlightColor()); - Invalidate(); - } -} - -} // namespace svt - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svtools/source/dialogs/roadmapwizard.cxx b/svtools/source/dialogs/roadmapwizard.cxx index d5e43b1e6171..6139634edfe1 100644 --- a/svtools/source/dialogs/roadmapwizard.cxx +++ b/svtools/source/dialogs/roadmapwizard.cxx @@ -21,7 +21,7 @@ #include #include #include -#include +#include #include #include @@ -52,7 +52,7 @@ namespace svt struct RoadmapWizardImpl : public RoadmapWizardTypes { - ScopedVclPtr pRoadmap; + ScopedVclPtr pRoadmap; Paths aPaths; PathId nActivePath; StateDescriptions aStateDescriptors; @@ -128,7 +128,7 @@ namespace svt SetLeftAlignedButtonCount( 1 ); SetEmptyViewMargin(); - m_pImpl->pRoadmap.disposeAndReset( VclPtr::Create( this, WB_TABSTOP ) ); + m_pImpl->pRoadmap.disposeAndReset( VclPtr::Create( this, WB_TABSTOP ) ); m_pImpl->pRoadmap->SetText( SvtResId( STR_WIZDLG_ROADMAP_TITLE ) ); m_pImpl->pRoadmap->SetPosPixel( Point( 0, 0 ) ); m_pImpl->pRoadmap->SetItemSelectHdl( LINK( this, RoadmapWizard, OnRoadmapItemSelected ) ); @@ -243,7 +243,7 @@ namespace svt return; // determine up to which index (in the new path) we have to display the items - RoadmapTypes::ItemIndex nUpperStepBoundary = static_cast(rActivePath.size()); + vcl::RoadmapTypes::ItemIndex nUpperStepBoundary = static_cast(rActivePath.size()); bool bIncompletePath = false; if ( !m_pImpl->bActivePathIsDefinite ) { @@ -278,8 +278,8 @@ namespace svt // now, we have to remove all items after nCurrentStatePathIndex, and insert the items from the active // path, up to (excluding) nUpperStepBoundary - RoadmapTypes::ItemIndex nLoopUntil = ::std::max( nUpperStepBoundary, m_pImpl->pRoadmap->GetItemCount() ); - for ( RoadmapTypes::ItemIndex nItemIndex = nCurrentStatePathIndex; nItemIndex < nLoopUntil; ++nItemIndex ) + vcl::RoadmapTypes::ItemIndex nLoopUntil = ::std::max( nUpperStepBoundary, m_pImpl->pRoadmap->GetItemCount() ); + for ( vcl::RoadmapTypes::ItemIndex nItemIndex = nCurrentStatePathIndex; nItemIndex < nLoopUntil; ++nItemIndex ) { bool bExistentItem = ( nItemIndex < m_pImpl->pRoadmap->GetItemCount() ); bool bNeedItem = ( nItemIndex < nUpperStepBoundary ); @@ -297,7 +297,7 @@ namespace svt { // there is an item with this index in the roadmap - does it match what is requested by // the respective state in the active path? - RoadmapTypes::ItemId nPresentItemId = m_pImpl->pRoadmap->GetItemID( nItemIndex ); + vcl::RoadmapTypes::ItemId nPresentItemId = m_pImpl->pRoadmap->GetItemID( nItemIndex ); WizardState nRequiredState = rActivePath[ nItemIndex ]; if ( nPresentItemId != nRequiredState ) { @@ -424,7 +424,7 @@ namespace svt IMPL_LINK_NOARG(RoadmapWizard, OnRoadmapItemSelected, LinkParamNone*, void) { - RoadmapTypes::ItemId nCurItemId = m_pImpl->pRoadmap->GetCurrentRoadmapItemID(); + vcl::RoadmapTypes::ItemId nCurItemId = m_pImpl->pRoadmap->GetCurrentRoadmapItemID(); if ( nCurItemId == getCurrentState() ) // nothing to do return; @@ -518,7 +518,7 @@ namespace svt } // if the state is currently in the roadmap, reflect it's new status - m_pImpl->pRoadmap->EnableRoadmapItem( static_cast(_nState), _bEnable ); + m_pImpl->pRoadmap->EnableRoadmapItem( static_cast(_nState), _bEnable ); } @@ -543,21 +543,21 @@ namespace svt void RoadmapWizard::updateRoadmapItemLabel( WizardState _nState ) { const WizardPath& rActivePath( m_pImpl->aPaths[ m_pImpl->nActivePath ] ); - RoadmapTypes::ItemIndex nUpperStepBoundary = static_cast(rActivePath.size()); - RoadmapTypes::ItemIndex nLoopUntil = ::std::max( nUpperStepBoundary, m_pImpl->pRoadmap->GetItemCount() ); + vcl::RoadmapTypes::ItemIndex nUpperStepBoundary = static_cast(rActivePath.size()); + vcl::RoadmapTypes::ItemIndex nLoopUntil = ::std::max( nUpperStepBoundary, m_pImpl->pRoadmap->GetItemCount() ); sal_Int32 nCurrentStatePathIndex = -1; if ( m_pImpl->nActivePath != -1 ) nCurrentStatePathIndex = m_pImpl->getStateIndexInPath( getCurrentState(), m_pImpl->nActivePath ); if (nCurrentStatePathIndex < 0) return; - for ( RoadmapTypes::ItemIndex nItemIndex = nCurrentStatePathIndex; nItemIndex < nLoopUntil; ++nItemIndex ) + for ( vcl::RoadmapTypes::ItemIndex nItemIndex = nCurrentStatePathIndex; nItemIndex < nLoopUntil; ++nItemIndex ) { bool bExistentItem = ( nItemIndex < m_pImpl->pRoadmap->GetItemCount() ); if ( bExistentItem ) { // there is an item with this index in the roadmap - does it match what is requested by // the respective state in the active path? - RoadmapTypes::ItemId nPresentItemId = m_pImpl->pRoadmap->GetItemID( nItemIndex ); + vcl::RoadmapTypes::ItemId nPresentItemId = m_pImpl->pRoadmap->GetItemID( nItemIndex ); WizardState nRequiredState = rActivePath[ nItemIndex ]; if ( _nState == nRequiredState ) { diff --git a/svtools/source/inc/unoiface.hxx b/svtools/source/inc/unoiface.hxx index efdd1a8cfe79..9088a11ebeb2 100644 --- a/svtools/source/inc/unoiface.hxx +++ b/svtools/source/inc/unoiface.hxx @@ -215,7 +215,7 @@ protected: // class SVTXRoadmap -namespace svt +namespace vcl { class ORoadmap; } diff --git a/svtools/source/uno/unoiface.cxx b/svtools/source/uno/unoiface.cxx index dcaa46182e90..43cb1d85711e 100644 --- a/svtools/source/uno/unoiface.cxx +++ b/svtools/source/uno/unoiface.cxx @@ -26,7 +26,7 @@ #include #include #include -#include +#include #include #include #include @@ -118,7 +118,7 @@ SAL_DLLPUBLIC_EXPORT vcl::Window* CreateWindow( VCLXWindow** ppNewComp, const cs } else if (aServiceName.equalsIgnoreAsciiCase("roadmap") ) { - pWindow = VclPtr< ::svt::ORoadmap>::Create( pParent, WB_TABSTOP ); + pWindow = VclPtr< ::vcl::ORoadmap>::Create( pParent, WB_TABSTOP ); *ppNewComp = new SVTXRoadmap; } else if ( aServiceName.equalsIgnoreAsciiCase( "ProgressBar" ) ) @@ -1416,7 +1416,7 @@ void SVTXRoadmap::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent ) case VclEventId::RoadmapItemSelected: { SolarMutexGuard aGuard; - VclPtr<::svt::ORoadmap> pField = GetAs< svt::ORoadmap >(); + VclPtr<::vcl::ORoadmap> pField = GetAs< vcl::ORoadmap >(); if ( pField ) { sal_Int16 CurItemID = pField->GetCurrentRoadmapItemID(); @@ -1438,7 +1438,7 @@ void SVTXRoadmap::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent ) void SVTXRoadmap::propertyChange( const css::beans::PropertyChangeEvent& evt ) { SolarMutexGuard aGuard; - VclPtr<::svt::ORoadmap> pField = GetAs< svt::ORoadmap >(); + VclPtr<::vcl::ORoadmap> pField = GetAs< vcl::ORoadmap >(); if ( !pField ) return; @@ -1453,20 +1453,20 @@ void SVTXRoadmap::propertyChange( const css::beans::PropertyChangeEvent& evt ) { bool bEnable = false; evt.NewValue >>= bEnable; - pField->EnableRoadmapItem( static_cast(nID) , bEnable ); + pField->EnableRoadmapItem( static_cast(nID) , bEnable ); } else if ( sPropertyName == "Label" ) { OUString sLabel; evt.NewValue >>= sLabel; - pField->ChangeRoadmapItemLabel( static_cast(nID) , sLabel ); + pField->ChangeRoadmapItemLabel( static_cast(nID) , sLabel ); } else if ( sPropertyName == "ID" ) { sal_Int32 nNewID = 0; evt.NewValue >>= nNewID; evt.OldValue >>= nID; - pField->ChangeRoadmapItemID( static_cast(nID), static_cast(nNewID) ); + pField->ChangeRoadmapItemID( static_cast(nID), static_cast(nNewID) ); } // else // TODO handle Interactive appropriately @@ -1509,20 +1509,20 @@ RMItemData SVTXRoadmap::GetRMItemData( const css::container::ContainerEvent& _rE void SVTXRoadmap::elementInserted( const css::container::ContainerEvent& _rEvent ) { SolarMutexGuard aGuard; - VclPtr<::svt::ORoadmap> pField = GetAs< svt::ORoadmap >(); + VclPtr<::vcl::ORoadmap> pField = GetAs< vcl::ORoadmap >(); if ( pField ) { RMItemData CurItemData = GetRMItemData( _rEvent ); sal_Int32 InsertIndex = 0; _rEvent.Accessor >>= InsertIndex; - pField->InsertRoadmapItem( InsertIndex, CurItemData.Label, static_cast(CurItemData.n_ID), CurItemData.b_Enabled ); + pField->InsertRoadmapItem( InsertIndex, CurItemData.Label, static_cast(CurItemData.n_ID), CurItemData.b_Enabled ); } } void SVTXRoadmap::elementRemoved( const css::container::ContainerEvent& _rEvent ) { SolarMutexGuard aGuard; - VclPtr<::svt::ORoadmap> pField = GetAs< svt::ORoadmap >(); + VclPtr<::vcl::ORoadmap> pField = GetAs< vcl::ORoadmap >(); if ( pField ) { sal_Int32 DelIndex = 0; @@ -1534,13 +1534,13 @@ void SVTXRoadmap::elementRemoved( const css::container::ContainerEvent& _rEvent void SVTXRoadmap::elementReplaced( const css::container::ContainerEvent& _rEvent ) { SolarMutexGuard aGuard; - VclPtr<::svt::ORoadmap> pField = GetAs< svt::ORoadmap >(); + VclPtr<::vcl::ORoadmap> pField = GetAs< vcl::ORoadmap >(); if ( pField ) { RMItemData CurItemData = GetRMItemData( _rEvent ); sal_Int32 ReplaceIndex = 0; _rEvent.Accessor >>= ReplaceIndex; - pField->ReplaceRoadmapItem( ReplaceIndex, CurItemData.Label, static_cast(CurItemData.n_ID), CurItemData.b_Enabled ); + pField->ReplaceRoadmapItem( ReplaceIndex, CurItemData.Label, static_cast(CurItemData.n_ID), CurItemData.b_Enabled ); } } @@ -1549,7 +1549,7 @@ void SVTXRoadmap::setProperty( const OUString& PropertyName, const css::uno::Any { SolarMutexGuard aGuard; - VclPtr<::svt::ORoadmap> pField = GetAs< svt::ORoadmap >(); + VclPtr<::vcl::ORoadmap> pField = GetAs< vcl::ORoadmap >(); if ( pField ) { sal_uInt16 nPropType = GetPropertyId( PropertyName ); @@ -1575,7 +1575,7 @@ void SVTXRoadmap::setProperty( const OUString& PropertyName, const css::uno::Any { sal_Int32 nId = 0; Value >>= nId; - pField->SelectRoadmapItemByID( static_cast(nId) ); + pField->SelectRoadmapItemByID( static_cast(nId) ); } break; @@ -1605,7 +1605,7 @@ css::uno::Any SVTXRoadmap::getProperty( const OUString& PropertyName ) css::uno::Any aReturn; - VclPtr<::svt::ORoadmap> pField = GetAs< svt::ORoadmap >(); + VclPtr<::vcl::ORoadmap> pField = GetAs< vcl::ORoadmap >(); if ( pField ) { sal_uInt16 nPropType = GetPropertyId( PropertyName ); @@ -1631,7 +1631,7 @@ css::uno::Any SVTXRoadmap::getProperty( const OUString& PropertyName ) void SVTXRoadmap::ImplSetNewImage() { OSL_PRECOND( GetWindow(), "SVTXRoadmap::ImplSetNewImage: window is required to be not-NULL!" ); - VclPtr< ::svt::ORoadmap > pButton = GetAs< ::svt::ORoadmap >(); + VclPtr< ::vcl::ORoadmap > pButton = GetAs< ::vcl::ORoadmap >(); pButton->SetRoadmapBitmap( GetImage().GetBitmapEx() ); } -- cgit