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 :
20 : #include "fudspord.hxx"
21 :
22 : #include <svx/svxids.hrc>
23 : #include <vcl/pointr.hxx>
24 :
25 : #include "app.hrc"
26 : #include "fupoor.hxx"
27 : #include "ViewShell.hxx"
28 : #include "View.hxx"
29 : #include "Window.hxx"
30 : #include "drawdoc.hxx"
31 :
32 : namespace sd {
33 :
34 0 : TYPEINIT1( FuDisplayOrder, FuPoor );
35 :
36 : /*************************************************************************
37 : |*
38 : |* Konstruktor
39 : |*
40 : \************************************************************************/
41 :
42 0 : FuDisplayOrder::FuDisplayOrder( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq)
43 : : FuPoor(pViewSh, pWin, pView, pDoc, rReq)
44 : , mpRefObj(NULL)
45 0 : , mpOverlay(0L)
46 : {
47 0 : }
48 :
49 : /*************************************************************************
50 : |*
51 : |* Destruktor
52 : |*
53 : \************************************************************************/
54 :
55 0 : FuDisplayOrder::~FuDisplayOrder()
56 : {
57 0 : implClearOverlay();
58 0 : }
59 :
60 0 : void FuDisplayOrder::implClearOverlay()
61 : {
62 0 : if(mpOverlay)
63 : {
64 0 : delete mpOverlay;
65 0 : mpOverlay = 0L;
66 : }
67 0 : }
68 :
69 0 : FunctionReference FuDisplayOrder::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
70 : {
71 0 : FunctionReference xFunc( new FuDisplayOrder( pViewSh, pWin, pView, pDoc, rReq ) );
72 0 : return xFunc;
73 : }
74 :
75 : /*************************************************************************
76 : |*
77 : |* MouseButtonDown-event
78 : |*
79 : \************************************************************************/
80 :
81 0 : sal_Bool FuDisplayOrder::MouseButtonDown(const MouseEvent& rMEvt)
82 : {
83 : // remember button state for creation of own MouseEvents
84 0 : SetMouseButtonCode(rMEvt.GetButtons());
85 :
86 0 : return sal_True;
87 : }
88 :
89 : /*************************************************************************
90 : |*
91 : |* MouseMove-event
92 : |*
93 : \************************************************************************/
94 :
95 0 : sal_Bool FuDisplayOrder::MouseMove(const MouseEvent& rMEvt)
96 : {
97 : SdrObject* pPickObj;
98 : SdrPageView* pPV;
99 0 : Point aPnt( mpWindow->PixelToLogic( rMEvt.GetPosPixel() ) );
100 :
101 0 : if ( mpView->PickObj(aPnt, mpView->getHitTolLog(), pPickObj, pPV) )
102 : {
103 0 : if (mpRefObj != pPickObj)
104 : {
105 : // delete current overlay
106 0 : implClearOverlay();
107 :
108 : // create new one
109 0 : mpOverlay = new SdrDropMarkerOverlay(*mpView, *pPickObj);
110 :
111 : // remember referenced object
112 0 : mpRefObj = pPickObj;
113 : }
114 : }
115 : else
116 : {
117 0 : mpRefObj = NULL;
118 0 : implClearOverlay();
119 : }
120 :
121 0 : return sal_True;
122 : }
123 :
124 : /*************************************************************************
125 : |*
126 : |* MouseButtonUp-event
127 : |*
128 : \************************************************************************/
129 :
130 0 : sal_Bool FuDisplayOrder::MouseButtonUp(const MouseEvent& rMEvt)
131 : {
132 : // remember button state for creation of own MouseEvents
133 0 : SetMouseButtonCode(rMEvt.GetButtons());
134 :
135 0 : SdrPageView* pPV = NULL;
136 0 : Point aPnt( mpWindow->PixelToLogic( rMEvt.GetPosPixel() ) );
137 :
138 0 : if ( mpView->PickObj(aPnt, mpView->getHitTolLog(), mpRefObj, pPV) )
139 : {
140 0 : if (nSlotId == SID_BEFORE_OBJ)
141 : {
142 0 : mpView->PutMarkedInFrontOfObj(mpRefObj);
143 : }
144 : else
145 : {
146 0 : mpView->PutMarkedBehindObj(mpRefObj);
147 : }
148 : }
149 :
150 0 : mpViewShell->Cancel();
151 :
152 0 : return sal_True;
153 : }
154 :
155 : /*************************************************************************
156 : |*
157 : |* Function aktivieren
158 : |*
159 : \************************************************************************/
160 :
161 0 : void FuDisplayOrder::Activate()
162 : {
163 0 : maPtr = mpWindow->GetPointer();
164 0 : mpWindow->SetPointer( Pointer( POINTER_REFHAND ) );
165 0 : }
166 :
167 : /*************************************************************************
168 : |*
169 : |* Function deaktivieren
170 : |*
171 : \************************************************************************/
172 :
173 0 : void FuDisplayOrder::Deactivate()
174 : {
175 0 : mpWindow->SetPointer( maPtr );
176 0 : }
177 :
178 :
179 : } // end of namespace sd
180 :
181 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|