LibreOffice Module svx (master)  1
StylesPreviewWindow.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
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 .
18  */
19 
20 #ifndef INCLUDED_SVX_SOURCE_INC_STYLES_PREVIEW_WINDOW_HXX
21 #define INCLUDED_SVX_SOURCE_INC_STYLES_PREVIEW_WINDOW_HXX
22 
24 #include <vcl/customweld.hxx>
25 #include <svl/style.hxx>
26 #include <com/sun/star/frame/XDispatchProvider.hpp>
28 
30 
31 class StyleStatusListener : public SfxStatusListener
32 {
34 
35 public:
37  StylesPreviewWindow_Base* pPreviewControl,
38  const css::uno::Reference<css::frame::XDispatchProvider>& xDispatchProvider);
39 
40  void StateChanged(SfxItemState eState, const SfxPoolItem* pState) override;
41 };
42 
44 {
45  static constexpr unsigned LEFT_MARGIN = 8;
46 
48  std::pair<OUString, OUString> m_aStyleName;
50  css::uno::Reference<css::frame::XDispatchProvider> m_xDispatchProvider;
51 
52 public:
54  const std::pair<OUString, OUString>& aStyleName,
55  const css::uno::Reference<css::frame::XDispatchProvider>& xDispatchProvider);
56 
57  void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) override;
58 
59  bool MouseButtonDown(const MouseEvent&) override;
60 
61  void SetStyle(const std::pair<OUString, OUString>& sStyleName);
62 
63  void Select(bool bSelect);
64 
65 private:
66  void DrawEntry(vcl::RenderContext& rRenderContext);
67  void DrawText(vcl::RenderContext& rRenderContext);
68  void DrawHighlight(vcl::RenderContext& rRenderContext, Color aFontBack);
69  static void DrawSelection(vcl::RenderContext& rRenderContext);
70  static void DrawContentBackground(vcl::RenderContext& rRenderContext,
71  const tools::Rectangle& aContentRect, const Color& aColor);
72 };
73 
75 {
76 protected:
77  static constexpr unsigned STYLES_COUNT = 6;
78 
79  std::unique_ptr<StyleItemController> m_xStyleControllers[STYLES_COUNT];
80  std::unique_ptr<weld::CustomWeld> m_xStyleControllersWeld[STYLES_COUNT];
81 
83  css::uno::Reference<css::lang::XComponent> m_xStatusListener;
84 
85  std::unique_ptr<weld::Toolbar> m_xUp;
86  std::unique_ptr<weld::Toolbar> m_xDown;
87 
88  std::vector<std::pair<OUString, OUString>> m_aDefaultStyles;
89  std::vector<std::pair<OUString, OUString>> m_aAllStyles;
90 
91  unsigned m_nStyleIterator;
92  OUString m_sSelectedStyle;
93 
94  DECL_LINK(GoUp, const OString&, void);
95  DECL_LINK(GoDown, const OString&, void);
96 
97 public:
99  weld::Builder& xBuilder, std::vector<std::pair<OUString, OUString>>& aDefaultStyles,
100  const css::uno::Reference<css::frame::XDispatchProvider>& xDispatchProvider);
102 
103  void Select(const OUString& rStyleName);
104 
105 private:
106  void Update();
107  void UpdateStylesList();
109  std::pair<OUString, OUString> GetVisibleStyle(unsigned nPosition);
110 };
111 
113 {
114 public:
116  vcl::Window* pParent, std::vector<std::pair<OUString, OUString>>& aDefaultStyles,
117  const css::uno::Reference<css::frame::XDispatchProvider>& xDispatchProvider);
119 
120  void dispose();
121 
122  void SetOptimalSize();
123 };
124 
125 #endif
126 
127 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
StyleStatusListener(StylesPreviewWindow_Base *pPreviewControl, const css::uno::Reference< css::frame::XDispatchProvider > &xDispatchProvider)
void DrawEntry(vcl::RenderContext &rRenderContext)
std::vector< std::pair< OUString, OUString > > m_aDefaultStyles
static void DrawSelection(vcl::RenderContext &rRenderContext)
StylesPreviewWindow_Impl(vcl::Window *pParent, std::vector< std::pair< OUString, OUString >> &aDefaultStyles, const css::uno::Reference< css::frame::XDispatchProvider > &xDispatchProvider)
bool MouseButtonDown(const MouseEvent &) override
void SetStyle(const std::pair< OUString, OUString > &sStyleName)
static void DrawContentBackground(vcl::RenderContext &rRenderContext, const tools::Rectangle &aContentRect, const Color &aColor)
css::uno::Reference< css::lang::XComponent > m_xStatusListener
SfxStyleFamily
static constexpr unsigned STYLES_COUNT
void Select(bool bSelect)
std::vector< std::pair< OUString, OUString > > m_aAllStyles
std::unique_ptr< StyleItemController > m_xStyleControllers[STYLES_COUNT]
StyleItemController(const std::pair< OUString, OUString > &aStyleName, const css::uno::Reference< css::frame::XDispatchProvider > &xDispatchProvider)
std::pair< OUString, OUString > GetVisibleStyle(unsigned nPosition)
SfxStyleFamily m_eStyleFamily
std::unique_ptr< weld::Toolbar > m_xDown
DECL_LINK(GoUp, const OString &, void)
std::pair< OUString, OUString > m_aStyleName
void Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &rRect) override
StylesPreviewWindow_Base * m_pPreviewControl
static constexpr unsigned LEFT_MARGIN
void Select(const OUString &rStyleName)
void DrawHighlight(vcl::RenderContext &rRenderContext, Color aFontBack)
SfxItemState
void DrawText(vcl::RenderContext &rRenderContext)
std::unique_ptr< weld::CustomWeld > m_xStyleControllersWeld[STYLES_COUNT]
void StateChanged(SfxItemState eState, const SfxPoolItem *pState) override
StyleStatusListener * m_pStatusListener
css::uno::Reference< css::frame::XDispatchProvider > m_xDispatchProvider
StylesPreviewWindow_Base(weld::Builder &xBuilder, std::vector< std::pair< OUString, OUString >> &aDefaultStyles, const css::uno::Reference< css::frame::XDispatchProvider > &xDispatchProvider)
std::unique_ptr< weld::Toolbar > m_xUp