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 <svx/svdobj.hxx>
21 :
22 :
23 : #include "view.hxx"
24 : #include "edtwin.hxx"
25 : #include "wrtsh.hxx"
26 : #include "drawbase.hxx"
27 : #include "conarc.hxx"
28 :
29 :
30 :
31 : /*************************************************************************
32 : |*
33 : |* Konstruktor
34 : |*
35 : \************************************************************************/
36 :
37 :
38 :
39 0 : ConstArc::ConstArc(SwWrtShell* pWrtShell, SwEditWin* pEditWin, SwView* pSwView)
40 0 : : SwDrawBase(pWrtShell, pEditWin, pSwView), nAnzButUp(0)
41 : {
42 0 : }
43 :
44 : /*************************************************************************
45 : |*
46 : |* MouseButtonDown-event
47 : |*
48 : \************************************************************************/
49 :
50 :
51 :
52 0 : sal_Bool ConstArc::MouseButtonDown( const MouseEvent& rMEvt )
53 : {
54 : sal_Bool bReturn;
55 :
56 0 : if ((bReturn = SwDrawBase::MouseButtonDown(rMEvt)) == sal_True)
57 : {
58 0 : if (!nAnzButUp)
59 0 : aStartPnt = m_pWin->PixelToLogic(rMEvt.GetPosPixel());
60 : }
61 0 : return (bReturn);
62 : }
63 :
64 : /*************************************************************************
65 : |*
66 : |* MouseButtonUp-event
67 : |*
68 : \************************************************************************/
69 :
70 :
71 :
72 0 : sal_Bool ConstArc::MouseButtonUp( const MouseEvent& rMEvt )
73 : {
74 0 : sal_Bool bReturn = sal_False;
75 :
76 0 : if ((m_pSh->IsDrawCreate() || m_pWin->IsDrawAction()) && rMEvt.IsLeft())
77 : {
78 0 : Point aPnt(m_pWin->PixelToLogic(rMEvt.GetPosPixel()));
79 0 : if (!nAnzButUp && aPnt == aStartPnt)
80 : {
81 0 : SwDrawBase::MouseButtonUp(rMEvt);
82 0 : bReturn = sal_True;
83 : }
84 : else
85 0 : { nAnzButUp++;
86 :
87 0 : if (nAnzButUp == 3) // Kreisbogenerzeugung beendet
88 : {
89 0 : SwDrawBase::MouseButtonUp(rMEvt);
90 0 : nAnzButUp = 0;
91 0 : bReturn = sal_True;
92 : }
93 : else
94 0 : m_pSh->EndCreate(SDRCREATE_NEXTPOINT);
95 : }
96 : }
97 :
98 0 : return (bReturn);
99 : }
100 :
101 : /*************************************************************************
102 : |*
103 : |* Function aktivieren
104 : |*
105 : \************************************************************************/
106 :
107 :
108 :
109 0 : void ConstArc::Activate(const sal_uInt16 nSlotId)
110 : {
111 0 : switch (nSlotId)
112 : {
113 : case SID_DRAW_ARC:
114 0 : m_pWin->SetSdrDrawMode(OBJ_CARC);
115 0 : break;
116 : case SID_DRAW_PIE:
117 0 : m_pWin->SetSdrDrawMode(OBJ_SECT);
118 0 : break;
119 : case SID_DRAW_CIRCLECUT:
120 0 : m_pWin->SetSdrDrawMode(OBJ_CCUT);
121 0 : break;
122 : default:
123 0 : m_pWin->SetSdrDrawMode(OBJ_NONE);
124 0 : break;
125 : }
126 :
127 0 : SwDrawBase::Activate(nSlotId);
128 0 : }
129 :
130 : /*************************************************************************
131 : |*
132 : |* Funktion deaktivieren
133 : |*
134 : \************************************************************************/
135 :
136 0 : void ConstArc::Deactivate()
137 : {
138 0 : nAnzButUp = 0;
139 :
140 0 : SwDrawBase::Deactivate();
141 0 : }
142 :
143 :
144 :
145 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|