3 Copyright (c) 2003-2007 Clarence Dang <dang@kde.org>
6 Redistribution and use in source and binary forms, with or without
7 modification, are permitted provided that the following conditions
10 1. Redistributions of source code must retain the above copyright
11 notice, this list of conditions and the following disclaimer.
12 2. Redistributions in binary form must reproduce the above copyright
13 notice, this list of conditions and the following disclaimer in the
14 documentation and/or other materials provided with the distribution.
16 THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18 OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 // Tools' statusbar updates.
33 #define DEBUG_KP_TOOL 0
36 // LOREFACTOR: reduce number of includes
38 #include <kpToolPrivate.h>
42 #include <qapplication.h>
43 #include <qclipboard.h>
50 #include <kapplication.h>
52 #include <kiconloader.h>
54 #include <kmessagebox.h>
58 #include <kpColorToolBar.h>
60 #include <kpPixmapFX.h>
61 #include <kpToolAction.h>
62 #include <kpToolToolBar.h>
64 #include <kpViewManager.h>
65 #include <kactioncollection.h>
69 QString
kpTool::cancelUserMessage (int mouseButton
)
72 return i18n ("Right click to cancel.");
74 return i18n ("Left click to cancel.");
78 QString
kpTool::cancelUserMessage () const
80 return cancelUserMessage (d
->mouseButton
);
85 QString
kpTool::userMessage () const
87 return d
->userMessage
;
91 void kpTool::setUserMessage (const QString
&userMessage
)
93 d
->userMessage
= userMessage
;
95 if (d
->userMessage
.isEmpty ())
96 d
->userMessage
= text ();
98 d
->userMessage
.prepend (i18n ("%1: ", text ()));
100 emit
userMessageChanged (d
->userMessage
);
105 QPoint
kpTool::userShapeStartPoint () const
107 return d
->userShapeStartPoint
;
111 QPoint
kpTool::userShapeEndPoint () const
113 return d
->userShapeEndPoint
;
117 void kpTool::setUserShapePoints (const QPoint
&startPoint
,
118 const QPoint
&endPoint
,
121 d
->userShapeStartPoint
= startPoint
;
122 d
->userShapeEndPoint
= endPoint
;
123 emit
userShapePointsChanged (d
->userShapeStartPoint
, d
->userShapeEndPoint
);
127 if (startPoint
!= KP_INVALID_POINT
&&
128 endPoint
!= KP_INVALID_POINT
)
130 setUserShapeSize (calculateLength (startPoint
.x (), endPoint
.x ()),
131 calculateLength (startPoint
.y (), endPoint
.y ()));
141 QSize
kpTool::userShapeSize () const
143 return d
->userShapeSize
;
147 int kpTool::userShapeWidth () const
149 return d
->userShapeSize
.width ();
153 int kpTool::userShapeHeight () const
155 return d
->userShapeSize
.height ();
159 void kpTool::setUserShapeSize (const QSize
&size
)
161 d
->userShapeSize
= size
;
163 emit
userShapeSizeChanged (d
->userShapeSize
);
164 emit
userShapeSizeChanged (d
->userShapeSize
.width (),
165 d
->userShapeSize
.height ());
169 void kpTool::setUserShapeSize (int width
, int height
)
171 setUserShapeSize (QSize (width
, height
));