bump product version to 4.1.6.2
[LibreOffice.git] / sd / source / ui / inc / smarttag.hxx
blob1e9bc9c4c0cf656b647f11bc1001ca981e5ea7a3
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 _SD_SMARTTAG_HXX_
21 #define _SD_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;
31 class SdrHdlList;
33 namespace sd {
35 class View;
36 class SmartHdl;
38 /** a smart tag represents a visual user interface element on the documents edit view
39 that is not part of the document. It uses derivations from SmartHdl for its visuals.
40 A SmartTag adds himself to the given view if created. It removes himself if it
41 is disposed before the view is disposed.
43 Derive from this class to implement your own smart tag.
45 class SmartTag : public SimpleReferenceComponent
47 friend class SmartTagSet;
49 public:
50 explicit SmartTag( ::sd::View& rView );
51 virtual ~SmartTag();
53 /** returns true if the SmartTag consumes this event. */
54 virtual bool MouseButtonDown( const MouseEvent&, SmartHdl& );
56 /** returns true if the SmartTag consumes this event. */
57 virtual bool KeyInput( const KeyEvent& rKEvt );
59 /** returns true if the SmartTag consumes this event. */
60 virtual bool RequestHelp( const HelpEvent& rHEvt );
62 /** returns true if the SmartTag consumes this event. */
63 virtual bool Command( const CommandEvent& rCEvt );
65 /** returns true if this smart tag is currently selected */
66 bool isSelected() const;
68 ::sd::View& getView() const { return mrView; }
70 protected:
71 virtual sal_uLong GetMarkablePointCount() const;
72 virtual sal_uLong GetMarkedPointCount() const;
73 virtual sal_Bool MarkPoint(SdrHdl& rHdl, sal_Bool bUnmark=sal_False);
74 virtual void CheckPossibilities();
75 virtual sal_Bool MarkPoints(const Rectangle* pRect, sal_Bool bUnmark);
77 virtual void addCustomHandles( SdrHdlList& rHandlerList );
78 virtual void select();
79 virtual void deselect();
80 virtual bool getContext( SdrViewContext& rContext );
82 virtual void disposing();
84 ::sd::View& mrView;
85 bool mbSelected;
87 private:
88 SmartTag( const SmartTag& ); // not implemented
89 SmartTag& operator=( const SmartTag& ); // not implemented
92 typedef rtl::Reference< SmartTag > SmartTagReference;
94 /** class to administrate the available smart tags for a single view. */
95 class SmartTagSet
97 friend class SmartTag;
98 public:
99 explicit SmartTagSet( ::sd::View& rView );
100 ~SmartTagSet();
102 /** selects the given smart tag and updates all handles */
103 void select( const SmartTagReference& xTag );
105 /** deselects the current selected smart tag and updates all handles */
106 void deselect();
108 /** returns the currently selected tag or an empty reference. */
109 const SmartTagReference& getSelected() const { return mxSelectedTag; }
111 /** returns true if a SmartTag consumes this event. */
112 bool MouseButtonDown( const MouseEvent& );
114 /** returns true if a SmartTag consumes this event. */
115 bool KeyInput( const KeyEvent& rKEvt );
117 /** returns true if a SmartTag consumes this event. */
118 bool RequestHelp( const HelpEvent& rHEvt );
120 /** returns true if a SmartTag consumes this event. */
121 bool Command( const CommandEvent& rCEvt );
123 /** disposes all smart tags and clears the set */
124 void Dispose();
126 /** addes the handles from all smart tags to the given list */
127 void addCustomHandles( SdrHdlList& rHandlerList );
129 /** returns true if the currently selected smart tag has
130 a special context, returned in rContext. */
131 bool getContext( SdrViewContext& rContext ) const;
133 // support point editing
134 sal_Bool HasMarkablePoints() const;
135 sal_uLong GetMarkablePointCount() const;
136 sal_Bool HasMarkedPoints() const;
137 sal_uLong GetMarkedPointCount() const;
138 sal_Bool IsPointMarkable(const SdrHdl& rHdl) const;
139 sal_Bool MarkPoint(SdrHdl& rHdl, sal_Bool bUnmark=sal_False);
140 sal_Bool MarkPoints(const Rectangle* pRect, sal_Bool bUnmark);
142 void CheckPossibilities();
144 private:
145 SmartTagSet( const SmartTagSet& ); // not implemented
146 SmartTagSet& operator=( const SmartTagSet& ); // not implemented
148 /** adds a new smart tag to this set */
149 void add( const SmartTagReference& xTag );
151 /** removes the given smart tag from this set */
152 void remove( const SmartTagReference& xTag );
154 std::set< SmartTagReference > maSet;
156 ::sd::View& mrView;
157 SmartTagReference mxSelectedTag;
158 SmartTagReference mxMouseOverTag;
161 /** a derivation from this handle is the visual representation for a smart tag.
162 One smart tag can have more than one handle.
164 class SmartHdl : public SdrHdl
166 public:
167 SmartHdl( const SmartTagReference& xTag, SdrObject* pObject, const Point& rPnt, SdrHdlKind eNewKind=HDL_SMARTTAG );
168 SmartHdl( const SmartTagReference& xTag, const Point& rPnt, SdrHdlKind eNewKind=HDL_SMARTTAG );
170 const SmartTagReference& getTag() const { return mxTag; }
172 virtual bool isMarkable() const;
173 protected:
174 SmartTagReference mxTag;
177 } // end of namespace sd
179 #endif // _SD_SMARTTAG_HXX_
181 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */