[Libreoffice-commits] core.git: Branch 'feature/sidebar' - officecfg/registry sfx2/source

Andre Fischer af at apache.org
Thu May 9 08:27:51 PDT 2013


 officecfg/registry/schema/org/openoffice/Office/UI/Sidebar.xcs |   28 ++++++
 sfx2/source/sidebar/Deck.hxx                                   |    2 
 sfx2/source/sidebar/DeckDescriptor.hxx                         |    2 
 sfx2/source/sidebar/PanelDescriptor.hxx                        |    2 
 sfx2/source/sidebar/ResourceManager.cxx                        |    8 +
 sfx2/source/sidebar/SidebarController.cxx                      |   46 ++++++++++
 sfx2/source/sidebar/SidebarController.hxx                      |    6 +
 sfx2/source/sidebar/TitleBar.cxx                               |   33 ++++++-
 sfx2/source/sidebar/TitleBar.hxx                               |    2 
 9 files changed, 127 insertions(+), 2 deletions(-)

New commits:
commit 2d14c42e77b6706208cc38ccb692237e0ff1275a
Author: Andre Fischer <af at apache.org>
Date:   Tue Apr 23 14:08:04 2013 +0000

    Resolves: #i122086# Show icons in decks and titles (optionally)
    
    (cherry picked from commit 80b53edb04ed2d4b4f27f8256b754593902f0c23)
    
    Change-Id: Ic9aafce182b96aa44956d9ddbf165f4cc736e41b

diff --git a/officecfg/registry/schema/org/openoffice/Office/UI/Sidebar.xcs b/officecfg/registry/schema/org/openoffice/Office/UI/Sidebar.xcs
index 49d6118..f7a35a3 100644
--- a/officecfg/registry/schema/org/openoffice/Office/UI/Sidebar.xcs
+++ b/officecfg/registry/schema/org/openoffice/Office/UI/Sidebar.xcs
@@ -53,6 +53,20 @@
         </info>
         <value></value>
       </prop>
+      <prop oor:name="TitleBarIconURL" oor:type="xs:string">
+        <info>
+          <desc>This icon is displayed in the title bar of the deck.
+          Any URL scheme supported by the com.sun.star.graphic.GraphicProvider service is suitable here.</desc>
+        </info>
+        <value></value>
+      </prop>
+      <prop oor:name="HighContrastTitleBarIconURL" oor:type="xs:string">
+        <info>
+          <desc>This icon is displayed in the title bar of the deck when high contrast mode is active.
+          Any URL scheme supported by the com.sun.star.graphic.GraphicProvider service is suitable here.</desc>
+        </info>
+        <value></value>
+      </prop>
       <prop oor:name="HelpURL" oor:type="xs:string">
         <info>
           <desc>Help about the sidebar deck.</desc>
@@ -142,6 +156,20 @@
         </info>
         <value></value>
       </prop>
+      <prop oor:name="TitleBarIconURL" oor:type="xs:string">
+        <info>
+          <desc>This icon is displayed in the title bar of the panel.
+          Any URL scheme supported by the com.sun.star.graphic.GraphicProvider service is suitable here.</desc>
+        </info>
+        <value></value>
+      </prop>
+      <prop oor:name="HighContrastTitleBarIconURL" oor:type="xs:string">
+        <info>
+          <desc>This icon is displayed in the title bar of the panel when high contrast mode is active.
+          Any URL scheme supported by the com.sun.star.graphic.GraphicProvider service is suitable here.</desc>
+        </info>
+        <value></value>
+      </prop>
       <prop oor:name="HelpURL" oor:type="xs:string">
         <info>
           <desc>Help about the sidebar content panel.</desc>
diff --git a/sfx2/source/sidebar/Deck.hxx b/sfx2/source/sidebar/Deck.hxx
index ae1cf19..07cdaec 100644
--- a/sfx2/source/sidebar/Deck.hxx
+++ b/sfx2/source/sidebar/Deck.hxx
@@ -93,6 +93,8 @@ private:
     ::boost::scoped_ptr<ScrollBar> mpVerticalScrollBar;
 
     DECL_LINK(HandleVerticalScrollBarChange,void*);
+
+
 };
 
 
diff --git a/sfx2/source/sidebar/DeckDescriptor.hxx b/sfx2/source/sidebar/DeckDescriptor.hxx
index 2c5a3d4..c7dc627 100644
--- a/sfx2/source/sidebar/DeckDescriptor.hxx
+++ b/sfx2/source/sidebar/DeckDescriptor.hxx
@@ -32,6 +32,8 @@ public:
     ::rtl::OUString msId;
     ::rtl::OUString msIconURL;
     ::rtl::OUString msHighContrastIconURL;
+    ::rtl::OUString msTitleBarIconURL;
+    ::rtl::OUString msHighContrastTitleBarIconURL;
     ::rtl::OUString msHelpURL;
     ::rtl::OUString msHelpText;
     ContextList maContextList;
diff --git a/sfx2/source/sidebar/PanelDescriptor.hxx b/sfx2/source/sidebar/PanelDescriptor.hxx
index a9b3445..cb39dbb 100644
--- a/sfx2/source/sidebar/PanelDescriptor.hxx
+++ b/sfx2/source/sidebar/PanelDescriptor.hxx
@@ -32,6 +32,8 @@ public:
     sal_Bool mbIsTitleBarOptional;
     ::rtl::OUString msId;
     ::rtl::OUString msDeckId;
+    ::rtl::OUString msTitleBarIconURL;
+    ::rtl::OUString msHighContrastTitleBarIconURL;
     ::rtl::OUString msHelpURL;
     ContextList maContextList;
     ::rtl::OUString msImplementationURL;
diff --git a/sfx2/source/sidebar/ResourceManager.cxx b/sfx2/source/sidebar/ResourceManager.cxx
index c29ef9a..070bb1c 100644
--- a/sfx2/source/sidebar/ResourceManager.cxx
+++ b/sfx2/source/sidebar/ResourceManager.cxx
@@ -269,6 +269,10 @@ void ResourceManager::ReadDeckList (void)
             aDeckNode.getNodeValue("IconURL"));
         rDeckDescriptor.msHighContrastIconURL = ::comphelper::getString(
             aDeckNode.getNodeValue("HighContrastIconURL"));
+        rDeckDescriptor.msTitleBarIconURL = ::comphelper::getString(
+            aDeckNode.getNodeValue("TitleBarIconURL"));
+        rDeckDescriptor.msHighContrastTitleBarIconURL = ::comphelper::getString(
+            aDeckNode.getNodeValue("HighContrastTitleBarIconURL"));
         rDeckDescriptor.msHelpURL = ::comphelper::getString(
             aDeckNode.getNodeValue("HelpURL"));
         rDeckDescriptor.msHelpText = rDeckDescriptor.msTitle;
@@ -320,6 +324,10 @@ void ResourceManager::ReadPanelList (void)
             aPanelNode.getNodeValue("Id"));
         rPanelDescriptor.msDeckId = ::comphelper::getString(
             aPanelNode.getNodeValue("DeckId"));
+        rPanelDescriptor.msTitleBarIconURL = ::comphelper::getString(
+            aPanelNode.getNodeValue("TitleBarIconURL"));
+        rPanelDescriptor.msHighContrastTitleBarIconURL = ::comphelper::getString(
+            aPanelNode.getNodeValue("HighContrastTitleBarIconURL"));
         rPanelDescriptor.msHelpURL = ::comphelper::getString(
             aPanelNode.getNodeValue("HelpURL"));
         rPanelDescriptor.msImplementationURL = ::comphelper::getString(
diff --git a/sfx2/source/sidebar/SidebarController.cxx b/sfx2/source/sidebar/SidebarController.cxx
index 969cc04..12fc4ca 100644
--- a/sfx2/source/sidebar/SidebarController.cxx
+++ b/sfx2/source/sidebar/SidebarController.cxx
@@ -487,6 +487,7 @@ void SidebarController::SwitchToDeck (
     // buttons.
     maFocusManager.SetPanels(aNewPanels);
     mpTabBar->UpdateFocusManager(maFocusManager);
+    UpdateTitleBarIcons();
 }
 
 
@@ -642,6 +643,7 @@ IMPL_LINK(SidebarController, WindowEventHandler, VclWindowEvent*, pEvent)
                 // Force an update of deck and tab bar to reflect
                 // changes in theme (high contrast mode).
                 Theme::HandleDataChange();
+                UpdateTitleBarIcons();
                 mpParentWindow->Invalidate();
                 break;
 
@@ -931,4 +933,48 @@ void SidebarController::RestrictWidth (void)
 }
 
 
+
+
+void SidebarController::UpdateTitleBarIcons (void)
+{
+    if ( ! mpCurrentDeck)
+        return;
+
+    const bool bIsHighContrastModeActive (Theme::IsHighContrastMode());
+    const ResourceManager& rResourceManager (ResourceManager::Instance());
+
+    // Update the deck icon.
+    const DeckDescriptor* pDeckDescriptor = rResourceManager.GetDeckDescriptor(mpCurrentDeck->GetId());
+    if (pDeckDescriptor != NULL && mpCurrentDeck->GetTitleBar())
+    {
+        const OUString sIconURL(
+            bIsHighContrastModeActive
+                ? pDeckDescriptor->msHighContrastTitleBarIconURL
+                : pDeckDescriptor->msTitleBarIconURL);
+        mpCurrentDeck->GetTitleBar()->SetIcon(Tools::GetImage(sIconURL, mxFrame));
+    }
+
+    // Update the panel icons.
+    const SharedPanelContainer& rPanels (mpCurrentDeck->GetPanels());
+    for (SharedPanelContainer::const_iterator
+             iPanel(rPanels.begin()), iEnd(rPanels.end());
+             iPanel!=iEnd;
+             ++iPanel)
+    {
+        if ( ! *iPanel)
+            continue;
+        if ((*iPanel)->GetTitleBar() == NULL)
+            continue;
+        const PanelDescriptor* pPanelDescriptor = rResourceManager.GetPanelDescriptor((*iPanel)->GetId());
+        if (pPanelDescriptor == NULL)
+            continue;
+        const OUString sIconURL (
+            bIsHighContrastModeActive
+               ? pPanelDescriptor->msHighContrastTitleBarIconURL
+               : pPanelDescriptor->msTitleBarIconURL);
+        (*iPanel)->GetTitleBar()->SetIcon(Tools::GetImage(sIconURL, mxFrame));
+    }
+}
+
+
 } } // end of namespace sfx2::sidebar
diff --git a/sfx2/source/sidebar/SidebarController.hxx b/sfx2/source/sidebar/SidebarController.hxx
index 4ae0f7d..9c4e2a8 100644
--- a/sfx2/source/sidebar/SidebarController.hxx
+++ b/sfx2/source/sidebar/SidebarController.hxx
@@ -161,6 +161,12 @@ private:
 
     void RestrictWidth (void);
 
+    /** Update the icons displayed in the title bars of the deck and
+        the panels.  This is called once when a deck is created and
+        every time when a data change event is processed.
+    */
+    void UpdateTitleBarIcons (void);
+
     virtual void SAL_CALL disposing (void);
 };
 
diff --git a/sfx2/source/sidebar/TitleBar.cxx b/sfx2/source/sidebar/TitleBar.cxx
index f5eac2a..6f73636 100644
--- a/sfx2/source/sidebar/TitleBar.cxx
+++ b/sfx2/source/sidebar/TitleBar.cxx
@@ -25,6 +25,11 @@
 
 ToolbarValue::~ToolbarValue (void) {}
 
+namespace
+{
+    const static sal_Int32 gnLeftIconSpace (3);
+    const static sal_Int32 gnRightIconSpace (3);
+}
 
 namespace sfx2 { namespace sidebar {
 
@@ -34,7 +39,8 @@ TitleBar::TitleBar (
     const sidebar::Paint& rInitialBackgroundPaint)
     : Window(pParentWindow),
       maToolBox(this),
-      msTitle(rsTitle)
+      msTitle(rsTitle),
+      maIcon()
 {
     SetBackground(rInitialBackgroundPaint.GetWallpaper());
 
@@ -60,6 +66,15 @@ void TitleBar::SetTitle (const ::rtl::OUString& rsTitle)
 
 
 
+void TitleBar::SetIcon (const Image& rIcon)
+{
+    maIcon = rIcon;
+    Invalidate();
+}
+
+
+
+
 void TitleBar::Paint (const Rectangle& rUpdateArea)
 {
     (void)rUpdateArea;
@@ -132,6 +147,20 @@ void TitleBar::PaintTitle (const Rectangle& rTitleBox)
 {
     Push(PUSH_FONT | PUSH_TEXTCOLOR);
 
+    Rectangle aTitleBox (rTitleBox);
+
+    // When there is an icon then paint it at the left of the given
+    // box.
+    if ( !! maIcon)
+    {
+        DrawImage(
+            Point(
+                aTitleBox.Left() + gnLeftIconSpace,
+                aTitleBox.Top() + (aTitleBox.GetHeight()-maIcon.GetSizePixel().Height())/2),
+            maIcon);
+        aTitleBox.Left() += gnLeftIconSpace + maIcon.GetSizePixel().Width() + gnRightIconSpace;
+    }
+
     Font aFont(GetFont());
     aFont.SetWeight(WEIGHT_BOLD);
     SetFont(aFont);
@@ -139,7 +168,7 @@ void TitleBar::PaintTitle (const Rectangle& rTitleBox)
     // Paint title bar text.
     SetTextColor(GetTextColor());
     DrawText(
-        rTitleBox,
+        aTitleBox,
         msTitle,
         TEXT_DRAW_LEFT | TEXT_DRAW_VCENTER);
 
diff --git a/sfx2/source/sidebar/TitleBar.hxx b/sfx2/source/sidebar/TitleBar.hxx
index 4f4f67c..e0e3772 100644
--- a/sfx2/source/sidebar/TitleBar.hxx
+++ b/sfx2/source/sidebar/TitleBar.hxx
@@ -37,6 +37,7 @@ public:
     virtual ~TitleBar (void);
 
     void SetTitle (const ::rtl::OUString& rsTitle);
+    void SetIcon (const Image& rIcon);
 
     virtual void Paint (const Rectangle& rUpdateArea);
     virtual void DataChanged (const DataChangedEvent& rEvent);
@@ -61,6 +62,7 @@ protected:
 
 private:
     ::rtl::OUString msTitle;
+    Image maIcon;
 
     void PaintTitle (const Rectangle& rTitleBox);
     DECL_LINK(SelectionHandler, ToolBox*);


More information about the Libreoffice-commits mailing list