bump product version to 4.1.6.2
[LibreOffice.git] / sw / inc / viscrs.hxx
blob70345935dede256d89f45d180cc871be613cdd7b
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 .
19 #ifndef _VISCRS_HXX
20 #define _VISCRS_HXX
22 #include <vcl/cursor.hxx>
23 #include "swcrsr.hxx"
24 #include "swrect.hxx"
25 #include "swregion.hxx"
27 class SwCrsrShell;
28 class SwShellCrsr;
30 // From here classes/methods for non-text cursor.
32 class SwVisCrsr
34 friend void _InitCore();
35 friend void _FinitCore();
37 bool bIsVisible : 1;
38 bool bIsDragCrsr : 1;
40 Cursor aTxtCrsr;
41 const SwCrsrShell* pCrsrShell;
43 void _SetPosAndShow();
45 public:
46 SwVisCrsr( const SwCrsrShell * pCShell );
47 ~SwVisCrsr();
49 void Show();
50 void Hide();
52 bool IsVisible() const { return bIsVisible; }
53 void SetDragCrsr( bool bFlag = true ) { bIsDragCrsr = bFlag; }
57 // From here classes/methods for selections.
59 namespace sdr { namespace overlay { class OverlayObject; }}
61 class SwSelPaintRects : public SwRects
63 friend void _InitCore();
64 friend void _FinitCore();
66 static long nPixPtX, nPixPtY;
67 static MapMode *pMapMode;
69 const SwCrsrShell* pCShell;
71 virtual void Paint( const Rectangle& rRect );
72 virtual void FillRects() = 0;
74 sdr::overlay::OverlayObject* mpCursorOverlay;
76 // access to mpCursorOverlay for swapContent
77 sdr::overlay::OverlayObject* getCursorOverlay() const { return mpCursorOverlay; }
78 void setCursorOverlay(sdr::overlay::OverlayObject* pNew) { mpCursorOverlay = pNew; }
80 public:
81 SwSelPaintRects( const SwCrsrShell& rCSh );
82 virtual ~SwSelPaintRects();
84 // in SwCrsrShell::CreateCrsr() the content of SwSelPaintRects is exchanged. To
85 // make a complete swap access to mpCursorOverlay is needed there
86 void swapContent(SwSelPaintRects& rSwap);
88 void Show();
89 void Hide();
90 void Invalidate( const SwRect& rRect );
92 const SwCrsrShell* GetShell() const { return pCShell; }
93 // check current MapMode of the shell and set possibly the static members.
94 // Optional set the parameters pX, pY
95 static void Get1PixelInLogic( const ViewShell& rSh,
96 long* pX = 0, long* pY = 0 );
100 class SwShellCrsr : public virtual SwCursor, public SwSelPaintRects
102 // Document positions of start/end characters of a SSelection.
103 Point aMkPt, aPtPt;
104 const SwPosition* pPt; // For assignment of GetPoint() to aPtPt.
106 virtual void FillRects(); // For Table- und normal cursors.
108 using SwCursor::UpDown;
110 public:
111 SwShellCrsr( const SwCrsrShell& rCrsrSh, const SwPosition &rPos );
112 SwShellCrsr( const SwCrsrShell& rCrsrSh, const SwPosition &rPos,
113 const Point& rPtPos, SwPaM* pRing = 0 );
114 SwShellCrsr( SwShellCrsr& );
115 virtual ~SwShellCrsr();
117 void Show(); // Update and display all selections.
118 void Hide(); // Hide all selections.
119 void Invalidate( const SwRect& rRect );
121 const Point& GetPtPos() const { return( SwPaM::GetPoint() == pPt ? aPtPt : aMkPt ); }
122 Point& GetPtPos() { return( SwPaM::GetPoint() == pPt ? aPtPt : aMkPt ); }
123 const Point& GetMkPos() const { return( SwPaM::GetMark() == pPt ? aPtPt : aMkPt ); }
124 Point& GetMkPos() { return( SwPaM::GetMark() == pPt ? aPtPt : aMkPt ); }
125 const Point& GetSttPos() const { return( SwPaM::Start() == pPt ? aPtPt : aMkPt ); }
126 Point& GetSttPos() { return( SwPaM::Start() == pPt ? aPtPt : aMkPt ); }
127 const Point& GetEndPos() const { return( SwPaM::End() == pPt ? aPtPt : aMkPt ); }
128 Point& GetEndPos() { return( SwPaM::End() == pPt ? aPtPt : aMkPt ); }
130 virtual void SetMark();
132 virtual SwCursor* Create( SwPaM* pRing = 0 ) const;
134 virtual short MaxReplaceArived(); //returns RET_YES/RET_CANCEL/RET_NO
135 virtual void SaveTblBoxCntnt( const SwPosition* pPos = 0 );
137 sal_Bool UpDown( sal_Bool bUp, sal_uInt16 nCnt = 1 );
139 // sal_True: Cursor can be set to this position.
140 virtual sal_Bool IsAtValidPos( sal_Bool bPoint = sal_True ) const;
142 virtual bool IsReadOnlyAvailable() const;
144 DECL_FIXEDMEMPOOL_NEWDEL( SwShellCrsr )
149 class SwShellTableCrsr : public virtual SwShellCrsr, public virtual SwTableCursor
151 // The Selection has the same order as the table boxes, i.e.
152 // if something is deleted from the one array at a certain position
153 // it has to be deleted from the other one as well!!
155 public:
156 SwShellTableCrsr( const SwCrsrShell& rCrsrSh, const SwPosition& rPos );
157 SwShellTableCrsr( const SwCrsrShell& rCrsrSh,
158 const SwPosition &rMkPos, const Point& rMkPt,
159 const SwPosition &rPtPos, const Point& rPtPt );
160 virtual ~SwShellTableCrsr();
162 virtual void FillRects(); // For table and normal cursor.
164 // Check if SPoint is within table SSelection.
165 sal_Bool IsInside( const Point& rPt ) const;
167 virtual void SetMark();
168 virtual SwCursor* Create( SwPaM* pRing = 0 ) const;
170 virtual short MaxReplaceArived(); //returns RET_YES/RET_CANCEL/RET_NO
171 virtual void SaveTblBoxCntnt( const SwPosition* pPos = 0 );
173 // sal_True: Cursor can be set to this position.
174 virtual sal_Bool IsAtValidPos( sal_Bool bPoint = sal_True ) const;
178 #endif // _VISCRS_HXX
180 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */