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 : #include "view.hxx"
23 : #include "edtwin.hxx"
24 : #include "wrtsh.hxx"
25 : #include "drawbase.hxx"
26 : #include "conarc.hxx"
27 :
28 0 : ConstArc::ConstArc(SwWrtShell* pWrtShell, SwEditWin* pEditWin, SwView* pSwView)
29 0 : : SwDrawBase(pWrtShell, pEditWin, pSwView), nAnzButUp(0)
30 : {
31 0 : }
32 :
33 0 : bool ConstArc::MouseButtonDown( const MouseEvent& rMEvt )
34 : {
35 : bool bReturn;
36 :
37 0 : if ((bReturn = SwDrawBase::MouseButtonDown(rMEvt)))
38 : {
39 0 : if (!nAnzButUp)
40 0 : aStartPnt = m_pWin->PixelToLogic(rMEvt.GetPosPixel());
41 : }
42 0 : return (bReturn);
43 : }
44 :
45 0 : bool ConstArc::MouseButtonUp( const MouseEvent& rMEvt )
46 : {
47 0 : bool bReturn = false;
48 :
49 0 : if ((m_pSh->IsDrawCreate() || m_pWin->IsDrawAction()) && rMEvt.IsLeft())
50 : {
51 0 : Point aPnt(m_pWin->PixelToLogic(rMEvt.GetPosPixel()));
52 0 : if (!nAnzButUp && aPnt == aStartPnt)
53 : {
54 0 : SwDrawBase::MouseButtonUp(rMEvt);
55 0 : bReturn = true;
56 : }
57 : else
58 0 : { nAnzButUp++;
59 :
60 0 : if (nAnzButUp == 3) // Generating of circular arc finished
61 : {
62 0 : SwDrawBase::MouseButtonUp(rMEvt);
63 0 : nAnzButUp = 0;
64 0 : bReturn = true;
65 : }
66 : else
67 0 : m_pSh->EndCreate(SDRCREATE_NEXTPOINT);
68 : }
69 : }
70 :
71 0 : return (bReturn);
72 : }
73 :
74 0 : void ConstArc::Activate(const sal_uInt16 nSlotId)
75 : {
76 0 : switch (nSlotId)
77 : {
78 : case SID_DRAW_ARC:
79 0 : m_pWin->SetSdrDrawMode(OBJ_CARC);
80 0 : break;
81 : case SID_DRAW_PIE:
82 0 : m_pWin->SetSdrDrawMode(OBJ_SECT);
83 0 : break;
84 : case SID_DRAW_CIRCLECUT:
85 0 : m_pWin->SetSdrDrawMode(OBJ_CCUT);
86 0 : break;
87 : default:
88 0 : m_pWin->SetSdrDrawMode(OBJ_NONE);
89 0 : break;
90 : }
91 :
92 0 : SwDrawBase::Activate(nSlotId);
93 0 : }
94 :
95 0 : void ConstArc::Deactivate()
96 : {
97 0 : nAnzButUp = 0;
98 :
99 0 : SwDrawBase::Deactivate();
100 270 : }
101 :
102 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|