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 #include <kpToolEnvironment.h>
31 #include <QActionGroup>
35 #include <KActionCollection>
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 ()
60 KActionCollection
*kpToolEnvironment::actionCollection () const
62 return mainWindow ()->actionCollection ();
66 kpCommandHistory
*kpToolEnvironment::commandHistory () const
68 return mainWindow ()->commandHistory ();
73 QActionGroup
*kpToolEnvironment::toolsActionGroup () const
75 return mainWindow ()->toolsActionGroup ();
79 kpToolToolBar
*kpToolEnvironment::toolToolBar () const
81 return mainWindow ()->toolToolBar ();
85 void kpToolEnvironment::hideAllToolWidgets () const
87 toolToolBar ()->hideAllToolWidgets ();
91 bool kpToolEnvironment::selectPreviousTool () const
93 kpToolToolBar
*tb
= toolToolBar ();
95 // (don't end up with no tool selected)
96 if (!tb
->previousTool ())
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 ();
107 static kpColorToolBar
*ColorToolBar (kpMainWindow
*mw
)
109 return mw
->colorToolBar ();
113 kpColor
kpToolEnvironment::color (int which
) const
115 return ::ColorToolBar (mainWindow ())->color (which
);
119 double kpToolEnvironment::colorSimilarity () const
121 return ::ColorToolBar (mainWindow ())->colorSimilarity ();
125 int kpToolEnvironment::processedColorSimilarity () const
127 return ::ColorToolBar (mainWindow ())->processedColorSimilarity ();
131 kpColor
kpToolEnvironment::oldForegroundColor () const
133 return ::ColorToolBar (mainWindow ())->oldForegroundColor ();
137 kpColor
kpToolEnvironment::oldBackgroundColor () const
139 return ::ColorToolBar (mainWindow ())->oldBackgroundColor ();
143 double kpToolEnvironment::oldColorSimilarity () const
145 return ::ColorToolBar (mainWindow ())->oldColorSimilarity ();
150 void kpToolEnvironment::flashColorSimilarityToolBarItem () const
152 ::ColorToolBar (mainWindow ())->flashColorSimilarityToolBarItem ();
157 void kpToolEnvironment::setColor (int which
, const kpColor
&color
) const
159 kpColorToolBar
*toolBar
= mainWindow ()->colorToolBar ();
162 toolBar
->setColor (which
, color
);
167 void kpToolEnvironment::deleteSelection () const
169 mainWindow ()->slotDelete ();
173 void kpToolEnvironment::pasteTextAt (const QString
&text
, const QPoint
&point
,
174 bool allowNewTextSelectionPointShift
) const
176 mainWindow ()->pasteTextAt (text
, point
, allowNewTextSelectionPointShift
);
181 void kpToolEnvironment::zoomIn (bool centerUnderCursor
) const
183 mainWindow ()->zoomIn (centerUnderCursor
);
187 void kpToolEnvironment::zoomOut (bool centerUnderCursor
) const
189 mainWindow ()->zoomOut (centerUnderCursor
);
194 void kpToolEnvironment::zoomToRect (
195 const QRect
&normalizedDocRect
,
196 bool accountForGrips
,
197 bool careAboutWidth
, bool careAboutHeight
) const
199 mainWindow ()->zoomToRect (
202 careAboutWidth
, careAboutHeight
);
206 void kpToolEnvironment::fitToPage () const
208 mainWindow ()->slotFitToPage ();
212 #include <kpToolEnvironment.moc>