bump product version to 6.3.0.0.beta1
[LibreOffice.git] / sd / source / ui / inc / smarttag.hxx
blob2130246128a8e1c68793bb556c3cd6a8840faa06
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_SD_SOURCE_UI_INC_SMARTTAG_HXX
21 #define INCLUDED_SD_SOURCE_UI_INC_SMARTTAG_HXX
23 #include <helper/simplereferencecomponent.hxx>
24 #include <rtl/ref.hxx>
25 #include <set>
26 #include <svx/svdhdl.hxx>
27 #include <svx/svdview.hxx>
29 class KeyEvent;
30 class MouseEvent;
32 namespace sd {
34 class View;
35 class SmartHdl;
37 /** a smart tag represents a visual user interface element on the documents edit view
38 that is not part of the document. It uses derivations from SmartHdl for its visuals.
39 A SmartTag adds himself to the given view if created. It removes himself if it
40 is disposed before the view is disposed.
42 Derive from this class to implement your own smart tag.
44 class SmartTag : public SimpleReferenceComponent
46 friend class SmartTagSet;
48 public:
49 explicit SmartTag( ::sd::View& rView );
50 virtual ~SmartTag() override;
52 /** returns true if the SmartTag consumes this event. */
53 virtual bool MouseButtonDown( const MouseEvent&, SmartHdl& );
55 /** returns true if the SmartTag consumes this event. */
56 virtual bool KeyInput( const KeyEvent& rKEvt );
58 /** returns true if the SmartTag consumes this event. */
59 virtual bool RequestHelp( const HelpEvent& rHEvt );
61 /** returns true if the SmartTag consumes this event. */
62 virtual bool Command( const CommandEvent& rCEvt );
64 /** returns true if this smart tag is currently selected */
65 bool isSelected() const { return mbSelected;}
67 ::sd::View& getView() const { return mrView; }
69 protected:
70 virtual sal_Int32 GetMarkablePointCount() const;
71 virtual sal_Int32 GetMarkedPointCount() const;
72 virtual bool MarkPoint(SdrHdl& rHdl, bool bUnmark);
73 virtual void CheckPossibilities();
74 virtual bool MarkPoints(const ::tools::Rectangle* pRect, bool bUnmark);
76 virtual void addCustomHandles( SdrHdlList& rHandlerList );
77 virtual void select();
78 virtual void deselect();
79 virtual bool getContext( SdrViewContext& rContext );
81 virtual void disposing() override;
83 ::sd::View& mrView;
84 bool mbSelected;
86 private:
87 SmartTag( const SmartTag& ) = delete;
88 SmartTag& operator=( const SmartTag& ) = delete;
91 typedef rtl::Reference< SmartTag > SmartTagReference;
93 /** class to administrate the available smart tags for a single view. */
94 class SmartTagSet
96 friend class SmartTag;
97 public:
98 explicit SmartTagSet( ::sd::View& rView );
99 ~SmartTagSet();
101 /** selects the given smart tag and updates all handles */
102 void select( const SmartTagReference& xTag );
104 /** deselects the current selected smart tag and updates all handles */
105 void deselect();
107 /** returns the currently selected tag or an empty reference. */
108 const SmartTagReference& getSelected() const { return mxSelectedTag; }
110 /** returns true if a SmartTag consumes this event. */
111 bool MouseButtonDown( const MouseEvent& );
113 /** returns true if a SmartTag consumes this event. */
114 bool KeyInput( const KeyEvent& rKEvt );
116 /** returns true if a SmartTag consumes this event. */
117 bool RequestHelp( const HelpEvent& rHEvt );
119 /** returns true if a SmartTag consumes this event. */
120 bool Command( const CommandEvent& rCEvt );
122 /** disposes all smart tags and clears the set */
123 void Dispose();
125 /** adds the handles from all smart tags to the given list */
126 void addCustomHandles( SdrHdlList& rHandlerList );
128 /** returns true if the currently selected smart tag has
129 a special context, returned in rContext. */
130 bool getContext( SdrViewContext& rContext ) const;
132 // support point editing
133 bool HasMarkablePoints() const;
134 sal_uLong GetMarkablePointCount() const;
135 bool HasMarkedPoints() const;
136 sal_uLong GetMarkedPointCount() const;
137 static bool IsPointMarkable(const SdrHdl& rHdl);
138 bool MarkPoint(SdrHdl& rHdl, bool bUnmark);
139 bool MarkPoints(const ::tools::Rectangle* pRect, bool bUnmark);
141 void CheckPossibilities();
143 private:
144 SmartTagSet( const SmartTagSet& ) = delete;
145 SmartTagSet& operator=( const SmartTagSet& ) = delete;
147 /** adds a new smart tag to this set */
148 void add( const SmartTagReference& xTag );
150 /** removes the given smart tag from this set */
151 void remove( const SmartTagReference& xTag );
153 std::set< SmartTagReference > maSet;
155 ::sd::View& mrView;
156 SmartTagReference mxSelectedTag;
157 SmartTagReference mxMouseOverTag;
160 /** a derivation from this handle is the visual representation for a smart tag.
161 One smart tag can have more than one handle.
163 class SmartHdl : public SdrHdl
165 public:
166 SmartHdl( const SmartTagReference& xTag, SdrObject* pObject, const Point& rPnt, SdrHdlKind eNewKind );
167 SmartHdl( const SmartTagReference& xTag, const Point& rPnt, SdrHdlKind eNewKind );
169 const SmartTagReference& getTag() const { return mxSmartTag; }
171 virtual bool isMarkable() const;
172 private:
173 SmartTagReference const mxSmartTag;
176 } // end of namespace sd
178 #endif // INCLUDED_SD_SOURCE_UI_INC_SMARTTAG_HXX
180 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */