compile
[kdegraphics.git] / kolourpaint / environments / tools / kpToolEnvironment.cpp
blob92b7bccff1b84d52390e7125ec9ff0d5e37abd04
2 /*
3 Copyright (c) 2003-2007 Clarence Dang <dang@kde.org>
4 All rights reserved.
6 Redistribution and use in source and binary forms, with or without
7 modification, are permitted provided that the following conditions
8 are met:
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 #include <kpToolEnvironment.h>
31 #include <QActionGroup>
32 #include <QPoint>
33 #include <QString>
35 #include <KActionCollection>
37 #include <kpColor.h>
38 #include <kpColorToolBar.h>
39 #include <kpMainWindow.h>
40 #include <kpToolToolBar.h>
43 struct kpToolEnvironmentPrivate
47 kpToolEnvironment::kpToolEnvironment (kpMainWindow *mainWindow)
48 : kpEnvironmentBase (mainWindow),
49 d (new kpToolEnvironmentPrivate ())
53 kpToolEnvironment::~kpToolEnvironment ()
55 delete d;
59 // public
60 KActionCollection *kpToolEnvironment::actionCollection () const
62 return mainWindow ()->actionCollection ();
65 // public
66 kpCommandHistory *kpToolEnvironment::commandHistory () const
68 return mainWindow ()->commandHistory ();
72 // public
73 QActionGroup *kpToolEnvironment::toolsActionGroup () const
75 return mainWindow ()->toolsActionGroup ();
78 // public
79 kpToolToolBar *kpToolEnvironment::toolToolBar () const
81 return mainWindow ()->toolToolBar ();
84 // public
85 void kpToolEnvironment::hideAllToolWidgets () const
87 toolToolBar ()->hideAllToolWidgets ();
90 // public
91 bool kpToolEnvironment::selectPreviousTool () const
93 kpToolToolBar *tb = toolToolBar ();
95 // (don't end up with no tool selected)
96 if (!tb->previousTool ())
97 return false;
99 // endInternal() will be called by kpMainWindow (thanks to this line)
100 // so we won't have the view anymore
101 // TODO: Update comment.
102 tb->selectPreviousTool ();
103 return true;
107 static kpColorToolBar *ColorToolBar (kpMainWindow *mw)
109 return mw->colorToolBar ();
112 // public
113 kpColor kpToolEnvironment::color (int which) const
115 return ::ColorToolBar (mainWindow ())->color (which);
118 // public
119 double kpToolEnvironment::colorSimilarity () const
121 return ::ColorToolBar (mainWindow ())->colorSimilarity ();
124 // public
125 int kpToolEnvironment::processedColorSimilarity () const
127 return ::ColorToolBar (mainWindow ())->processedColorSimilarity ();
130 // public
131 kpColor kpToolEnvironment::oldForegroundColor () const
133 return ::ColorToolBar (mainWindow ())->oldForegroundColor ();
136 // public
137 kpColor kpToolEnvironment::oldBackgroundColor () const
139 return ::ColorToolBar (mainWindow ())->oldBackgroundColor ();
142 // public
143 double kpToolEnvironment::oldColorSimilarity () const
145 return ::ColorToolBar (mainWindow ())->oldColorSimilarity ();
149 // public
150 void kpToolEnvironment::flashColorSimilarityToolBarItem () const
152 ::ColorToolBar (mainWindow ())->flashColorSimilarityToolBarItem ();
156 // public
157 void kpToolEnvironment::setColor (int which, const kpColor &color) const
159 kpColorToolBar *toolBar = mainWindow ()->colorToolBar ();
160 Q_ASSERT (toolBar);
162 toolBar->setColor (which, color);
166 // public
167 void kpToolEnvironment::deleteSelection () const
169 mainWindow ()->slotDelete ();
172 // public
173 void kpToolEnvironment::pasteTextAt (const QString &text, const QPoint &point,
174 bool allowNewTextSelectionPointShift) const
176 mainWindow ()->pasteTextAt (text, point, allowNewTextSelectionPointShift);
180 // public
181 void kpToolEnvironment::zoomIn (bool centerUnderCursor) const
183 mainWindow ()->zoomIn (centerUnderCursor);
186 // public
187 void kpToolEnvironment::zoomOut (bool centerUnderCursor) const
189 mainWindow ()->zoomOut (centerUnderCursor);
193 // public
194 void kpToolEnvironment::zoomToRect (
195 const QRect &normalizedDocRect,
196 bool accountForGrips,
197 bool careAboutWidth, bool careAboutHeight) const
199 mainWindow ()->zoomToRect (
200 normalizedDocRect,
201 accountForGrips,
202 careAboutWidth, careAboutHeight);
205 // public
206 void kpToolEnvironment::fitToPage () const
208 mainWindow ()->slotFitToPage ();
212 #include <kpToolEnvironment.moc>