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  css::uno::Reference<css::frame::XDispatchProvider>& xDispatchProvider);
38 
39  void StateChanged(SfxItemState eState, const SfxPoolItem* pState) override;
40 };
41 
43 {
44  static constexpr unsigned LEFT_MARGIN = 8;
45 
47  OUString m_aStyleName;
49  css::uno::Reference<css::frame::XDispatchProvider> m_xDispatchProvider;
50 
51 public:
52  StyleItemController(const OUString& aStyleName,
53  css::uno::Reference<css::frame::XDispatchProvider>& xDispatchProvider);
54 
55  void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) override;
56 
57  bool MouseButtonDown(const MouseEvent&) override;
58 
59  void SetStyle(const OUString& sStyleName);
60 
61  void Select(bool bSelect);
62 
63 private:
64  void DrawEntry(vcl::RenderContext& rRenderContext);
65  void DrawText(vcl::RenderContext& rRenderContext);
66  void DrawHighlight(vcl::RenderContext& rRenderContext, Color aFontBack);
67  static void DrawSelection(vcl::RenderContext& rRenderContext);
68  static void DrawContentBackground(vcl::RenderContext& rRenderContext,
69  tools::Rectangle& aContentRect, Color& aColor);
70 };
71 
73 {
74 protected:
75  static constexpr unsigned STYLES_COUNT = 4;
76 
77  std::unique_ptr<StyleItemController> m_xStyleControllers[STYLES_COUNT];
78  std::unique_ptr<weld::CustomWeld> m_xStyleControllersWeld[STYLES_COUNT];
79 
81  css::uno::Reference<css::lang::XComponent> m_xStatusListener;
82 
83  std::unique_ptr<weld::Toolbar> m_xUp;
84  std::unique_ptr<weld::Toolbar> m_xDown;
85 
86  std::vector<OUString> m_aDefaultStyles;
87  std::vector<OUString> m_aAllStyles;
88 
89  unsigned m_nStyleIterator;
90  OUString m_sSelectedStyle;
91 
92  DECL_LINK(GoUp, const OString&, void);
93  DECL_LINK(GoDown, const OString&, void);
94 
95 public:
96  StylesPreviewWindow_Base(weld::Builder& xBuilder, std::vector<OUString>& aDefaultStyles,
97  css::uno::Reference<css::frame::XDispatchProvider>& xDispatchProvider);
99 
100  void Select(const OUString& rStyleName);
101 
102 private:
103  void Update();
104  void UpdateStylesList();
106  OUString GetVisibleStyle(unsigned nPosition);
107 };
108 
110 {
111 public:
112  StylesPreviewWindow_Impl(vcl::Window* pParent, std::vector<OUString>& aDefaultStyles,
113  css::uno::Reference<css::frame::XDispatchProvider>& xDispatchProvider);
115 
116  void dispose();
117 
118  void SetOptimalSize();
119 };
120 
121 #endif
122 
123 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
std::vector< OUString > m_aAllStyles
StyleItemController(const OUString &aStyleName, css::uno::Reference< css::frame::XDispatchProvider > &xDispatchProvider)
void DrawEntry(vcl::RenderContext &rRenderContext)
StylesPreviewWindow_Impl(vcl::Window *pParent, std::vector< OUString > &aDefaultStyles, css::uno::Reference< css::frame::XDispatchProvider > &xDispatchProvider)
static void DrawSelection(vcl::RenderContext &rRenderContext)
StylesPreviewWindow_Base(weld::Builder &xBuilder, std::vector< OUString > &aDefaultStyles, css::uno::Reference< css::frame::XDispatchProvider > &xDispatchProvider)
bool MouseButtonDown(const MouseEvent &) override
std::vector< OUString > m_aDefaultStyles
void SetStyle(const OUString &sStyleName)
static void DrawContentBackground(vcl::RenderContext &rRenderContext, tools::Rectangle &aContentRect, Color &aColor)
css::uno::Reference< css::lang::XComponent > m_xStatusListener
SfxStyleFamily
static constexpr unsigned STYLES_COUNT
void Select(bool bSelect)
std::unique_ptr< StyleItemController > m_xStyleControllers[STYLES_COUNT]
SfxStyleFamily m_eStyleFamily
std::unique_ptr< weld::Toolbar > m_xDown
DECL_LINK(GoUp, const OString &, void)
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
OUString GetVisibleStyle(unsigned nPosition)
StyleStatusListener * m_pStatusListener
css::uno::Reference< css::frame::XDispatchProvider > m_xDispatchProvider
StyleStatusListener(StylesPreviewWindow_Base *pPreviewControl, css::uno::Reference< css::frame::XDispatchProvider > &xDispatchProvider)
std::unique_ptr< weld::Toolbar > m_xUp