Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 : #include "ColorListener.hxx"
20 : #include <svl/smplhint.hxx>
21 : #include <vcl/settings.hxx>
22 :
23 : #include "uistrings.hrc"
24 :
25 :
26 : namespace rptui
27 : {
28 :
29 0 : OColorListener::OColorListener(vcl::Window* _pParent ,const OUString& _sColorEntry)
30 : : Window(_pParent)
31 : ,m_sColorEntry(_sColorEntry)
32 : ,m_nColor(COL_LIGHTBLUE)
33 : ,m_bCollapsed(false)
34 0 : ,m_bMarked(false)
35 : {
36 0 : StartListening(m_aExtendedColorConfig);
37 0 : m_nColor = m_aExtendedColorConfig.GetColorValue(CFG_REPORTDESIGNER,m_sColorEntry).getColor();
38 0 : m_nTextBoundaries = m_aColorConfig.GetColorValue(::svtools::DOCBOUNDARIES).nColor;
39 0 : }
40 :
41 0 : OColorListener::~OColorListener()
42 : {
43 0 : disposeOnce();
44 0 : }
45 :
46 0 : void OColorListener::dispose()
47 : {
48 0 : EndListening(m_aExtendedColorConfig);
49 0 : vcl::Window::dispose();
50 0 : }
51 :
52 0 : void OColorListener::Notify(SfxBroadcaster & /*rBc*/, SfxHint const & rHint)
53 : {
54 0 : const SfxSimpleHint* pSimpleHint = dynamic_cast<const SfxSimpleHint*>(&rHint);
55 0 : if (pSimpleHint && pSimpleHint->GetId() == SFX_HINT_COLORS_CHANGED)
56 : {
57 0 : m_nColor = m_aExtendedColorConfig.GetColorValue(CFG_REPORTDESIGNER,m_sColorEntry).getColor();
58 0 : m_nTextBoundaries = m_aColorConfig.GetColorValue(::svtools::DOCBOUNDARIES).nColor;
59 0 : Invalidate(InvalidateFlags::NoChildren|InvalidateFlags::NoErase);
60 : }
61 0 : }
62 :
63 0 : void OColorListener::DataChanged( const DataChangedEvent& rDCEvt )
64 : {
65 0 : Window::DataChanged( rDCEvt );
66 :
67 0 : if ( (rDCEvt.GetType() == DataChangedEventType::SETTINGS) &&
68 0 : (rDCEvt.GetFlags() & AllSettingsFlags::STYLE) )
69 : {
70 0 : ImplInitSettings();
71 0 : Invalidate();
72 : }
73 0 : }
74 :
75 0 : void OColorListener::setCollapsed(bool _bCollapsed)
76 : {
77 0 : if ( m_bCollapsed != _bCollapsed )
78 : {
79 0 : m_bCollapsed = _bCollapsed;
80 0 : if ( m_aCollapsedLink.IsSet() )
81 0 : m_aCollapsedLink.Call(this);
82 : }
83 0 : }
84 :
85 0 : void OColorListener::setMarked(bool _bMark)
86 : {
87 0 : if ( m_bMarked != _bMark)
88 : {
89 0 : m_bMarked = _bMark;
90 0 : Invalidate(InvalidateFlags::NoChildren|InvalidateFlags::NoErase);
91 : }
92 0 : }
93 :
94 : }
95 :
96 :
97 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|