xref: /trunk/main/sw/inc/SidebarWin.hxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef _SIDEBARWIN_HXX
29 #define _SIDEBARWIN_HXX
30 
31 #include <postithelper.hxx>
32 #include <SidebarWindowsTypes.hxx>
33 
34 #include <vcl/window.hxx>
35 #include <swrect.hxx>
36 
37 #include <tools/datetime.hxx>
38 #include <tools/date.hxx>
39 
40 #include <vcl/lineinfo.hxx>
41 #include <basegfx/polygon/b2dpolygon.hxx>
42 #include <editeng/editstat.hxx>
43 
44 class SwPostItMgr;
45 class SwPostItField;
46 class OutlinerView;
47 class Outliner;
48 class ScrollBar;
49 class SwEditWin;
50 class SwView;
51 class Edit;
52 class MenuButton;
53 //class SwRedline;
54 class SwFrm;
55 
56 
57 namespace sw { namespace sidebarwindows {
58 
59 class SidebarTxtControl;
60 class AnchorOverlayObject;
61 class ShadowOverlayObject;
62 
63 typedef sal_Int64 SwPostItBits;
64 
65 #define PB_Preview ((SwPostItBits)0x00000001)
66 
67 
68 class SwSidebarWin : public Window
69 {
70 	public:
71         SwSidebarWin( SwEditWin& rEditWin,
72                       WinBits nBits,
73                       SwPostItMgr& aMgr,
74                       SwPostItBits aBits,
75                       SwSidebarItem& rSidebarItem );
76         virtual ~SwSidebarWin();
77 
78         void SetSize( const Size& rNewSize );
79         void SetPosSizePixelRect( long nX,
80                                   long nY,
81                                   long nWidth,
82                                   long nHeight,
83                                   const SwRect &aRect,
84                                   const long PageBorder);
85         void SetPosAndSize();
86         void TranslateTopPosition(const long aAmount);
87         virtual void CheckMetaText();
88 
89         inline Point GetAnchorPos() { return mAnchorRect.Pos(); }
90         SwEditWin* EditWin();
91 
92         inline OutlinerView* GetOutlinerView() { return mpOutlinerView;}
93         bool HasScrollbar() const;
94         bool IsScrollbarVisible() const;
95         inline ScrollBar* Scrollbar() { return mpVScrollbar; }
96         inline ::sw::sidebarwindows::AnchorOverlayObject* Anchor() { return mpAnchor;}
97         inline ::sw::sidebarwindows::ShadowOverlayObject* Shadow() { return mpShadow;}
98 
99         long            GetPostItTextHeight();
100 
101 		void			SwitchToPostIt(sal_uInt16 aDirection);
102 		virtual void	SwitchToFieldPos();
103 
104         virtual sal_uInt32 MoveCaret() = 0;
105 
106 		virtual void	UpdateData() = 0;
107 		virtual void	SetPostItText() = 0;
108 		virtual void	Delete();
109 		virtual void	GotoPos() = 0;
110 
111         virtual String  GetAuthor() = 0;
112         virtual Date    GetDate() = 0;
113         virtual Time    GetTime() = 0;
114 
115 		void			ExecuteCommand(sal_uInt16 nSlot);
116 		void			InitControls();
117         void            HidePostIt();
118         void            DoResize();
119 		void			ResizeIfNeccessary(long aOldHeight, long aNewHeight);
120 		void			SetScrollbar();
121 
122 		void			SetVirtualPosSize( const Point& aPoint, const Size& aSize);
123 		const Point		VirtualPos()	{ return mPosSize.TopLeft(); }
124 		const Size		VirtualSize()	{ return mPosSize.GetSize(); }
125 
126         void            ShowAnchorOnly(const Point &aPoint);
127         void            ShowNote();
128         void            HideNote();
129 
130 		void			ResetAttributes();
131 
132         void            SetSidebarPosition(sw::sidebarwindows::SidebarPosition eSidebarPosition);
133 		void			SetReadonly(sal_Bool bSet);
134 		sal_Bool			IsReadOnly()		{ return mbReadonly;}
135 		bool			IsPreview()			{ return nFlags & PB_Preview;}
136 
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();
142 
143         void            SetViewState(::sw::sidebarwindows::ViewState bViewState);
144 
145         bool            IsFollow() { return mbIsFollow; }
146         void            SetFollow( bool bIsFollow) { mbIsFollow = bIsFollow; };
147         virtual bool    CalcFollow() = 0;
148 
149 #if 0
150 #endif
151 
152 		sal_Int32		GetMetaHeight();
153 		sal_Int32		GetMinimumSizeWithMeta();
154 		sal_Int32		GetMinimumSizeWithoutMeta();
155 		sal_Int32		GetMetaButtonAreaWidth();
156 		sal_Int32		GetScrollbarWidth();
157 
158 		void			SetSpellChecking();
159 
160 		void			ToggleInsMode();
161 
162 		virtual	void	ActivatePostIt();
163 		virtual void	DeactivatePostIt();
164 
165         void SetChangeTracking( const SwPostItHelper::SwLayoutStatus aStatus,
166                                 const Color& aColor);
167         SwPostItHelper::SwLayoutStatus GetLayoutStatus() { return mLayoutStatus; }
168         Color GetChangeColor() { return mChangeColor; }
169 
170 		virtual bool	IsProtected() {return mbReadonly;};
171 
172         DECL_LINK( WindowEventListener, VclSimpleEvent* );
173         inline bool IsMouseOverSidebarWin() const { return mbMouseOver; }
174 
175         void SetLanguage(const SvxLanguageItem aNewItem);
176 
177         void ChangeSidebarItem( SwSidebarItem& rSidebarItem );
178         virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > CreateAccessible();
179 
180     protected:
181         virtual void    DataChanged( const DataChangedEvent& aEvent);
182         virtual void    LoseFocus();
183         virtual void    Paint( const Rectangle& rRect);
184         virtual void    GetFocus();
185         virtual MenuButton* CreateMenuButton() = 0;
186 
187         void        SetSizePixel( const Size& rNewSize );
188         SfxItemSet  DefaultItem();
189 
190         DECL_LINK(ModifyHdl, void*);
191         DECL_LINK(ScrollHdl, ScrollBar*);
192         DECL_LINK(DeleteHdl, void*);
193 
194         inline SwView& DocView() { return mrView;}
195         inline SwPostItMgr& Mgr() { return mrMgr; }
196         inline Outliner* Engine() { return mpOutliner;}
197 
198     private:
199         SwSidebarWin*   GetTopReplyNote();
200 
201         virtual SvxLanguageItem GetLanguage(void);
202 
203         SwPostItMgr&    mrMgr;
204         SwView&         mrView;
205         const SwPostItBits nFlags;
206 
207         sal_uLong           mnEventId;
208 
209         OutlinerView*   mpOutlinerView;
210         Outliner*       mpOutliner;
211 
212         sw::sidebarwindows::SidebarTxtControl* mpSidebarTxtControl;
213         ScrollBar*      mpVScrollbar;
214         Edit*           mpMetadataAuthor;
215         Edit*           mpMetadataDate;
216         MenuButton*     mpMenuButton;
217 
218         sw::sidebarwindows::AnchorOverlayObject* mpAnchor;
219         sw::sidebarwindows::ShadowOverlayObject* mpShadow;
220 
221         Color           mColorAnchor;
222         Color           mColorDark;
223         Color           mColorLight;
224         Color           mChangeColor;
225 
226         sw::sidebarwindows::SidebarPosition meSidebarPosition;
227 
228         Rectangle       mPosSize;
229         SwRect          mAnchorRect;
230         long            mPageBorder;
231 
232         bool            mbMouseOver;
233         SwPostItHelper::SwLayoutStatus mLayoutStatus;
234 
235         bool            mbReadonly;
236         bool            mbIsFollow;
237 
238         SwSidebarItem& mrSidebarItem;
239         const SwFrm* mpAnchorFrm;
240 };
241 
242 } } // eof namespace sw::sidebarwindows
243 
244 
245 // implementation for change tracking comments, fully functional, but not yet used
246 /*
247 class SwRedComment : public SwSidebarWin
248 {
249 	private:
250 		SwRedline*		pRedline;
251 
252 	protected:
253 		virtual void	MouseButtonDown( const MouseEvent& rMEvt );
254 	public:
255 		SwRedComment( Window* pParent, WinBits nBits,SwPostItMgr* aMgr,SwPostItBits aBits,SwRedline* pRed);
256 		virtual ~SwRedComment() {};
257 
258 		virtual void	UpdateData();
259 		virtual void	SetPostItText();
260 		virtual void	Delete();
261 		virtual void	GotoPos();
262 		virtual void	SetPopup();
263 		virtual void	ActivatePostIt();
264 		virtual void	DeactivatePostIt();
265 
266 		virtual String	GetAuthor();
267 		virtual Date	GetDate();
268 		virtual Time	GetTime();
269 
270 		virtual bool	IsProtected();
271 };
272 */
273 
274 #endif
275