LibreOffice Module sw (master) 1
conarc.cxx
Go to the documentation of this file.
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/svxids.hrc>
21#include <vcl/event.hxx>
22
23#include <view.hxx>
24#include <edtwin.hxx>
25#include <wrtsh.hxx>
26#include <drawbase.hxx>
27#include <conarc.hxx>
28
29ConstArc::ConstArc(SwWrtShell* pWrtShell, SwEditWin* pEditWin, SwView* pSwView)
30 : SwDrawBase(pWrtShell, pEditWin, pSwView)
31 , m_nButtonUpCount(0)
32{
33}
34
36{
37 bool bReturn = SwDrawBase::MouseButtonDown(rMEvt);
38 if (bReturn && !m_nButtonUpCount)
39 m_aStartPoint = m_pWin->PixelToLogic(rMEvt.GetPosPixel());
40 return bReturn;
41}
42
44{
45 bool bReturn = false;
46
47 if ((m_pSh->IsDrawCreate() || m_pWin->IsDrawAction()) && rMEvt.IsLeft())
48 {
49 Point aPnt(m_pWin->PixelToLogic(rMEvt.GetPosPixel()));
50 if (!m_nButtonUpCount && aPnt == m_aStartPoint)
51 {
53 bReturn = true;
54 }
55 else
56 {
58
59 if (m_nButtonUpCount == 3) // Generating of circular arc finished
60 {
63 bReturn = true;
64 }
65 else
66 m_pSh->EndCreate(SdrCreateCmd::NextPoint);
67 }
68 }
69
70 return bReturn;
71}
72
73void ConstArc::Activate(const sal_uInt16 nSlotId)
74{
75 switch (nSlotId)
76 {
77 case SID_DRAW_ARC:
78 m_pWin->SetSdrDrawMode(SdrObjKind::CircleArc);
79 break;
80 case SID_DRAW_PIE:
81 m_pWin->SetSdrDrawMode(SdrObjKind::CircleSection);
82 break;
83 case SID_DRAW_CIRCLECUT:
84 m_pWin->SetSdrDrawMode(SdrObjKind::CircleCut);
85 break;
86 default:
87 m_pWin->SetSdrDrawMode(SdrObjKind::NONE);
88 break;
89 }
90
91 SwDrawBase::Activate(nSlotId);
92}
93
95{
97
99}
100
101/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
sal_uInt16 m_nButtonUpCount
Definition: conarc.hxx:28
virtual bool MouseButtonUp(const MouseEvent &rMEvt) override
Definition: conarc.cxx:43
virtual void Activate(const sal_uInt16 nSlotId) override
Definition: conarc.cxx:73
ConstArc(SwWrtShell *pSh, SwEditWin *pWin, SwView *pView)
Definition: conarc.cxx:29
virtual bool MouseButtonDown(const MouseEvent &rMEvt) override
Definition: conarc.cxx:35
Point m_aStartPoint
Definition: conarc.hxx:27
virtual void Deactivate() override
Definition: conarc.cxx:94
const Point & GetPosPixel() const
bool IsLeft() const
virtual void Activate(const sal_uInt16 nSlotId)
Definition: drawbase.cxx:432
SwWrtShell * m_pSh
Definition: drawbase.hxx:36
VclPtr< SwEditWin > m_pWin
Definition: drawbase.hxx:37
virtual void Deactivate()
Definition: drawbase.cxx:444
virtual bool MouseButtonDown(const MouseEvent &rMEvt)
Definition: drawbase.cxx:62
virtual bool MouseButtonUp(const MouseEvent &rMEvt)
Definition: drawbase.cxx:239
Window class for the Writer edit area, this is the one handling mouse and keyboard events and doing t...
Definition: edtwin.hxx:61
bool EndCreate(SdrCreateCmd eSdrCreateCmd)
Definition: feshview.cxx:1840
bool IsDrawCreate() const
Definition: feshview.cxx:2230
Definition: view.hxx:145
Used by the UI to modify the document model.
Definition: wrtsh.hxx:97