1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
10 #ifndef INCLUDED_SW_SOURCE_UIBASE_INC_SWRULER_HXX
11 #define INCLUDED_SW_SOURCE_UIBASE_INC_SWRULER_HXX
13 #include <svx/ruler.hxx>
14 #include <vcl/timer.hxx>
15 #include <vcl/virdev.hxx>
19 namespace vcl
{ class Window
; }
21 namespace tools
{ class JsonWriter
; }
24 * An horizontal ruler with a control for comment panel visibility for Writer.
26 * The comment control only appears when the document has comments already.
28 class SwCommentRuler final
: public SvxRuler
35 SvxRulerSupportFlags nRulerFlags
,
36 SfxBindings
& rBindings
,
38 virtual ~SwCommentRuler () override
;
39 virtual void dispose() override
;
43 * \param rRect ignored
45 virtual void Paint( vcl::RenderContext
& rRenderContext
, const tools::Rectangle
& rRect
) override
;
46 void CreateJsonNotification(tools::JsonWriter
& rJsonWriter
);
49 SwViewShell
* mpViewShell
; //< Shell to check if there is any comments on doc and their visibility
50 VclPtr
<SwEditWin
> mpSwWin
; //< Used to get SwView to change the SideBar visibility
51 bool mbIsHighlighted
; //< If comment control is highlighted (mouse is over it)
52 Timer maFadeTimer
; //< Timer for high/'low'light fading
53 int mnFadeRate
; //< From 0 to 100. 0 means not highlighted.
54 ScopedVclPtr
<VirtualDevice
> maVirDev
; //< VirtualDevice of this window. Just for convenience.
58 * Callback function to handle a mouse button down event.
60 * When on comment control, it toggles the comment panel visibility.
62 virtual void MouseButtonDown( const MouseEvent
& rMEvt
) override
;
64 * Callback function to handle a mouse move event.
66 * When on comment control, it let the control responsive by highlighting.
68 virtual void MouseMove(const MouseEvent
& rMEvt
) override
;
70 * Callback function to handle a context menu call (mouse right button click).
72 * When on comment control, it does not do anything.
74 virtual void Command( const CommandEvent
& rCEvt
) override
;
78 * Update the ruler appearance according to the document view and
79 * current cursor position.
81 virtual void Update() override
;
84 * Get the rectangle area that should be used to draw the comment control.
86 * It is horizontally aligned to the SideBar panel.
87 * \return The area where the comment control is.
89 tools::Rectangle
GetCommentControlRegion();
92 * Paint the comment control on VirtualDevice.
94 void DrawCommentControl(vcl::RenderContext
& rRenderContext
);
97 * Update the tooltip text.
99 void UpdateCommentHelpText();
102 * Get the proper color between two options, according to current status.
104 * The return color can be one of the given colors, or a merged one.
105 * It depends on highlight fading status.
107 * \param rHighColor color used to highlight status
108 * \param rLowColor color used to normal status
109 * \return The proper color to used in moment
111 Color
GetFadedColor(const Color
&rHighColor
, const Color
&rLowColor
);
113 /// Fade timer callback.
114 DECL_LINK(FadeHandler
, Timer
*, void);
119 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */