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 #ifndef INCLUDED_SVX_SVDHLPLN_HXX 21 #define INCLUDED_SVX_SVDHLPLN_HXX 22 23 #include <sal/types.h> 24 #include <tools/gen.hxx> 25 26 #include <svx/svxdllapi.h> 27 28 #include <vector> 29 #include <memory> 30 31 class OutputDevice; 32 enum class PointerStyle; 33 34 enum class SdrHelpLineKind { Point, Vertical, Horizontal }; 35 36 #define SDRHELPLINE_POINT_PIXELSIZE 15 /* actual size = PIXELSIZE*2+1 */ 37 38 class SdrHelpLine { 39 Point aPos; // X or Y may be unimportant, depending on the value of eKind 40 SdrHelpLineKind eKind; 41 42 public: SdrHelpLine(SdrHelpLineKind eNewKind=SdrHelpLineKind::Point)43 explicit SdrHelpLine(SdrHelpLineKind eNewKind=SdrHelpLineKind::Point): eKind(eNewKind) {} SdrHelpLine(SdrHelpLineKind eNewKind,const Point & rNewPos)44 SdrHelpLine(SdrHelpLineKind eNewKind, const Point& rNewPos): aPos(rNewPos), eKind(eNewKind) {} operator ==(const SdrHelpLine & rCmp) const45 bool operator==(const SdrHelpLine& rCmp) const { return aPos==rCmp.aPos && eKind==rCmp.eKind; } operator !=(const SdrHelpLine & rCmp) const46 bool operator!=(const SdrHelpLine& rCmp) const { return !operator==(rCmp); } 47 SetKind(SdrHelpLineKind eNewKind)48 void SetKind(SdrHelpLineKind eNewKind) { eKind=eNewKind; } GetKind() const49 SdrHelpLineKind GetKind() const { return eKind; } SetPos(const Point & rPnt)50 void SetPos(const Point& rPnt) { aPos=rPnt; } GetPos() const51 const Point& GetPos() const { return aPos; } 52 53 PointerStyle GetPointer() const; 54 bool IsHit(const Point& rPnt, sal_uInt16 nTolLog, const OutputDevice& rOut) const; 55 // OutputDevice is required because capture points have a fixed pixel size 56 tools::Rectangle GetBoundRect(const OutputDevice& rOut) const; 57 }; 58 59 #define SDRHELPLINE_NOTFOUND 0xFFFF 60 61 class SVX_DLLPUBLIC SdrHelpLineList { 62 std::vector<std::unique_ptr<SdrHelpLine>> aList; 63 64 public: SdrHelpLineList()65 SdrHelpLineList() {} SdrHelpLineList(const SdrHelpLineList & rSrcList)66 SdrHelpLineList(const SdrHelpLineList& rSrcList) { *this=rSrcList; } 67 void Clear(); 68 SdrHelpLineList& operator=(const SdrHelpLineList& rSrcList); 69 bool operator==(const SdrHelpLineList& rCmp) const; operator !=(const SdrHelpLineList & rCmp) const70 bool operator!=(const SdrHelpLineList& rCmp) const { return !operator==(rCmp); } GetCount() const71 sal_uInt16 GetCount() const { return sal_uInt16(aList.size()); } Insert(const SdrHelpLine & rHL)72 void Insert(const SdrHelpLine& rHL) { aList.emplace_back(new SdrHelpLine(rHL)); } Insert(const SdrHelpLine & rHL,sal_uInt16 nPos)73 void Insert(const SdrHelpLine& rHL, sal_uInt16 nPos) 74 { 75 if(nPos==0xFFFF) 76 aList.emplace_back(new SdrHelpLine(rHL)); 77 else 78 aList.emplace(aList.begin() + nPos, new SdrHelpLine(rHL)); 79 } Delete(sal_uInt16 nPos)80 void Delete(sal_uInt16 nPos) 81 { 82 aList.erase(aList.begin() + nPos); 83 } operator [](sal_uInt16 nPos)84 SdrHelpLine& operator[](sal_uInt16 nPos) { return *aList[nPos]; } operator [](sal_uInt16 nPos) const85 const SdrHelpLine& operator[](sal_uInt16 nPos) const { return *aList[nPos]; } 86 sal_uInt16 HitTest(const Point& rPnt, sal_uInt16 nTolLog, const OutputDevice& rOut) const; 87 }; 88 89 90 #endif // INCLUDED_SVX_SVDHLPLN_HXX 91 92 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ 93