Branch libreoffice-5-0-4
[LibreOffice.git] / sw / inc / SidebarWin.hxx
blob9514ac0eca900ac68aff072d1bcb502b421aaac6
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_SW_INC_SIDEBARWIN_HXX
21 #define INCLUDED_SW_INC_SIDEBARWIN_HXX
23 #include <postithelper.hxx>
24 #include <SidebarWindowsTypes.hxx>
26 #include <vcl/window.hxx>
27 #include <swrect.hxx>
29 #include <tools/date.hxx>
31 #include <vcl/lineinfo.hxx>
32 #include <basegfx/polygon/b2dpolygon.hxx>
33 #include <editeng/editstat.hxx>
35 class SwPostItMgr;
36 class SwPostItField;
37 class OutlinerView;
38 class Outliner;
39 class ScrollBar;
40 class SwEditWin;
41 class SwView;
42 class Edit;
43 class MenuButton;
44 class SwFrm;
46 namespace sw { namespace overlay {
47 class OverlayRanges;
50 namespace sw { namespace sidebarwindows {
52 class SidebarTextControl;
53 class AnchorOverlayObject;
54 class ShadowOverlayObject;
56 typedef sal_Int64 SwPostItBits;
58 #define PB_Preview ((SwPostItBits)0x00000001)
60 class SwSidebarWin : public vcl::Window
62 public:
63 SwSidebarWin( SwEditWin& rEditWin,
64 WinBits nBits,
65 SwPostItMgr& aMgr,
66 SwPostItBits aBits,
67 SwSidebarItem& rSidebarItem );
68 virtual ~SwSidebarWin();
69 virtual void dispose() SAL_OVERRIDE;
71 void SetSize( const Size& rNewSize );
72 void SetPosSizePixelRect( long nX,
73 long nY,
74 long nWidth,
75 long nHeight,
76 const SwRect& aAnchorRect,
77 const long PageBorder);
78 void SetPosAndSize();
79 void TranslateTopPosition(const long aAmount);
80 void CheckMetaText();
82 inline Point GetAnchorPos() { return mAnchorRect.Pos(); }
83 SwEditWin* EditWin();
85 inline OutlinerView* GetOutlinerView() { return mpOutlinerView;}
86 bool HasScrollbar() const;
87 bool IsScrollbarVisible() const;
88 inline ScrollBar* Scrollbar() { return mpVScrollbar; }
89 inline ::sw::sidebarwindows::AnchorOverlayObject* Anchor() { return mpAnchor;}
90 inline ::sw::sidebarwindows::ShadowOverlayObject* Shadow() { return mpShadow;}
91 inline ::sw::overlay::OverlayRanges* TextRange() { return mpTextRangeOverlay;}
93 long GetPostItTextHeight();
95 void SwitchToPostIt(sal_uInt16 aDirection);
96 void SwitchToFieldPos();
98 virtual sal_uInt32 MoveCaret() = 0;
100 virtual void UpdateData() = 0;
101 virtual void SetPostItText() = 0;
102 virtual void Delete();
103 virtual void GotoPos() = 0;
105 virtual OUString GetAuthor() = 0;
106 virtual Date GetDate() = 0;
107 virtual tools::Time GetTime() = 0;
109 void ExecuteCommand(sal_uInt16 nSlot);
110 void InitControls();
111 void HidePostIt();
112 void DoResize();
113 void ResizeIfNecessary(long aOldHeight, long aNewHeight);
114 void SetScrollbar();
116 void SetVirtualPosSize( const Point& aPoint, const Size& aSize);
117 const Point VirtualPos() { return mPosSize.TopLeft(); }
118 const Size VirtualSize() { return mPosSize.GetSize(); }
120 void ShowAnchorOnly(const Point &aPoint);
121 void ShowNote();
122 void HideNote();
124 void ResetAttributes();
126 void SetSidebarPosition(sw::sidebarwindows::SidebarPosition eSidebarPosition);
127 void SetReadonly(bool bSet);
128 bool IsReadOnly()
130 return mbReadonly;
132 bool IsPreview()
134 return nFlags & PB_Preview;
137 void SetColor(Color aColorDark,Color aColorLight, Color aColorAnchor);
138 const Color& ColorAnchor() { return mColorAnchor; }
139 const Color& ColorDark() { return mColorDark; }
140 const Color& ColorLight() { return mColorLight; }
141 void Rescale();
143 void SetViewState(::sw::sidebarwindows::ViewState bViewState);
145 bool IsFollow() { return mbIsFollow; }
146 void SetFollow( bool bIsFollow) { mbIsFollow = bIsFollow; };
147 virtual bool CalcFollow() = 0;
149 sal_Int32 GetMetaHeight();
150 sal_Int32 GetMinimumSizeWithMeta();
151 sal_Int32 GetMinimumSizeWithoutMeta();
152 sal_Int32 GetMetaButtonAreaWidth();
153 sal_Int32 GetScrollbarWidth();
155 void SetSpellChecking();
157 void ToggleInsMode();
159 void ActivatePostIt();
160 void DeactivatePostIt();
162 void SetChangeTracking( const SwPostItHelper::SwLayoutStatus aStatus,
163 const Color& aColor);
164 SwPostItHelper::SwLayoutStatus GetLayoutStatus() { return mLayoutStatus; }
165 Color GetChangeColor() { return mChangeColor; }
167 virtual bool IsProtected()
169 return mbReadonly;
172 DECL_LINK( WindowEventListener, VclSimpleEvent* );
173 inline bool IsMouseOverSidebarWin() const { return mbMouseOver; }
175 void SetLanguage(const SvxLanguageItem& rNewItem);
177 void ChangeSidebarItem( SwSidebarItem& rSidebarItem );
178 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > CreateAccessible() SAL_OVERRIDE;
180 virtual void Draw(OutputDevice* pDev, const Point&, const Size&, sal_uLong) SAL_OVERRIDE;
182 protected:
183 virtual void DataChanged( const DataChangedEvent& aEvent) SAL_OVERRIDE;
184 virtual void LoseFocus() SAL_OVERRIDE;
185 virtual void Paint(vcl::RenderContext& rRenderContext, const Rectangle& rRect) SAL_OVERRIDE;
186 virtual void GetFocus() SAL_OVERRIDE;
187 virtual VclPtr<MenuButton> CreateMenuButton() = 0;
189 void SetSizePixel( const Size& rNewSize ) SAL_OVERRIDE;
190 SfxItemSet DefaultItem();
192 DECL_LINK(ModifyHdl, void*);
193 DECL_LINK(ScrollHdl, ScrollBar*);
194 DECL_LINK(DeleteHdl, void*);
196 inline SwView& DocView() { return mrView;}
197 inline SwPostItMgr& Mgr() { return mrMgr; }
198 inline Outliner* Engine() { return mpOutliner;}
200 private:
201 SwSidebarWin* GetTopReplyNote();
203 virtual SvxLanguageItem GetLanguage();
205 SwPostItMgr& mrMgr;
206 SwView& mrView;
207 const SwPostItBits nFlags;
209 ImplSVEvent * mnEventId;
211 OutlinerView* mpOutlinerView;
212 Outliner* mpOutliner;
214 VclPtr<sw::sidebarwindows::SidebarTextControl> mpSidebarTextControl;
215 VclPtr<ScrollBar> mpVScrollbar;
216 VclPtr<Edit> mpMetadataAuthor;
217 VclPtr<Edit> mpMetadataDate;
218 VclPtr<MenuButton> mpMenuButton;
220 sw::sidebarwindows::AnchorOverlayObject* mpAnchor;
221 sw::sidebarwindows::ShadowOverlayObject* mpShadow;
222 sw::overlay::OverlayRanges* mpTextRangeOverlay;
224 Color mColorAnchor;
225 Color mColorDark;
226 Color mColorLight;
227 Color mChangeColor;
229 sw::sidebarwindows::SidebarPosition meSidebarPosition;
231 Rectangle mPosSize;
232 SwRect mAnchorRect;
233 long mPageBorder;
235 bool mbMouseOver;
236 SwPostItHelper::SwLayoutStatus mLayoutStatus;
238 bool mbReadonly;
239 bool mbIsFollow;
241 SwSidebarItem& mrSidebarItem;
242 const SwFrm* mpAnchorFrm;
245 } } // eof namespace sw::sidebarwindows
247 #endif
249 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */