File indexing completed on 2024-05-12 04:21:15
0001 0002 /* 0003 Copyright (c) 2003-2007 Clarence Dang <dang@kde.org> 0004 All rights reserved. 0005 0006 Redistribution and use in source and binary forms, with or without 0007 modification, are permitted provided that the following conditions 0008 are met: 0009 0010 1. Redistributions of source code must retain the above copyright 0011 notice, this list of conditions and the following disclaimer. 0012 2. Redistributions in binary form must reproduce the above copyright 0013 notice, this list of conditions and the following disclaimer in the 0014 documentation and/or other materials provided with the distribution. 0015 0016 THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 0017 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 0018 OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 0019 IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 0020 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 0021 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 0022 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 0023 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 0024 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 0025 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 0026 */ 0027 0028 0029 #include "kpToolEnvironment.h" 0030 0031 #include "imagelib/kpColor.h" 0032 #include "widgets/toolbars/kpColorToolBar.h" 0033 #include "mainWindow/kpMainWindow.h" 0034 #include "widgets/toolbars/kpToolToolBar.h" 0035 0036 #include <KActionCollection> 0037 0038 #include <QActionGroup> 0039 #include <QPoint> 0040 #include <QString> 0041 0042 //-------------------------------------------------------------------------------- 0043 0044 bool kpToolEnvironment::drawAntiAliased = true; 0045 0046 //-------------------------------------------------------------------------------- 0047 0048 struct kpToolEnvironmentPrivate 0049 { 0050 }; 0051 0052 kpToolEnvironment::kpToolEnvironment (kpMainWindow *mainWindow) 0053 : kpEnvironmentBase (mainWindow), 0054 d (new kpToolEnvironmentPrivate ()) 0055 { 0056 } 0057 0058 kpToolEnvironment::~kpToolEnvironment () 0059 { 0060 delete d; 0061 } 0062 0063 0064 // public 0065 KActionCollection *kpToolEnvironment::actionCollection () const 0066 { 0067 return mainWindow ()->actionCollection (); 0068 } 0069 0070 // public 0071 kpCommandHistory *kpToolEnvironment::commandHistory () const 0072 { 0073 return mainWindow ()->commandHistory (); 0074 } 0075 0076 0077 // public 0078 QActionGroup *kpToolEnvironment::toolsActionGroup () const 0079 { 0080 return mainWindow ()->toolsActionGroup (); 0081 } 0082 0083 // public 0084 kpToolToolBar *kpToolEnvironment::toolToolBar () const 0085 { 0086 return mainWindow ()->toolToolBar (); 0087 } 0088 0089 // public 0090 void kpToolEnvironment::hideAllToolWidgets () const 0091 { 0092 toolToolBar ()->hideAllToolWidgets (); 0093 } 0094 0095 // public 0096 bool kpToolEnvironment::selectPreviousTool () const 0097 { 0098 kpToolToolBar *tb = toolToolBar (); 0099 0100 // (don't end up with no tool selected) 0101 if (!tb->previousTool ()) { 0102 return false; 0103 } 0104 0105 // endInternal() will be called by kpMainWindow (thanks to this line) 0106 // so we won't have the view anymore 0107 // TODO: Update comment. 0108 tb->selectPreviousTool (); 0109 return true; 0110 } 0111 0112 0113 static kpColorToolBar *ColorToolBar (kpMainWindow *mw) 0114 { 0115 return mw->colorToolBar (); 0116 } 0117 0118 // public 0119 kpColor kpToolEnvironment::color (int which) const 0120 { 0121 return ::ColorToolBar (mainWindow ())->color (which); 0122 } 0123 0124 // public 0125 double kpToolEnvironment::colorSimilarity () const 0126 { 0127 return ::ColorToolBar (mainWindow ())->colorSimilarity (); 0128 } 0129 0130 // public 0131 int kpToolEnvironment::processedColorSimilarity () const 0132 { 0133 return ::ColorToolBar (mainWindow ())->processedColorSimilarity (); 0134 } 0135 0136 // public 0137 kpColor kpToolEnvironment::oldForegroundColor () const 0138 { 0139 return ::ColorToolBar (mainWindow ())->oldForegroundColor (); 0140 } 0141 0142 // public 0143 kpColor kpToolEnvironment::oldBackgroundColor () const 0144 { 0145 return ::ColorToolBar (mainWindow ())->oldBackgroundColor (); 0146 } 0147 0148 // public 0149 double kpToolEnvironment::oldColorSimilarity () const 0150 { 0151 return ::ColorToolBar (mainWindow ())->oldColorSimilarity (); 0152 } 0153 0154 0155 // public 0156 void kpToolEnvironment::flashColorSimilarityToolBarItem () const 0157 { 0158 ::ColorToolBar (mainWindow ())->flashColorSimilarityToolBarItem (); 0159 } 0160 0161 0162 // public 0163 void kpToolEnvironment::setColor (int which, const kpColor &color) const 0164 { 0165 kpColorToolBar *toolBar = mainWindow ()->colorToolBar (); 0166 Q_ASSERT (toolBar); 0167 0168 toolBar->setColor (which, color); 0169 } 0170 0171 0172 // public 0173 void kpToolEnvironment::deleteSelection () const 0174 { 0175 mainWindow ()->slotDelete (); 0176 } 0177 0178 // public 0179 void kpToolEnvironment::pasteTextAt (const QString &text, const QPoint &point, 0180 bool allowNewTextSelectionPointShift) const 0181 { 0182 mainWindow ()->pasteTextAt (text, point, allowNewTextSelectionPointShift); 0183 } 0184 0185 0186 // public 0187 void kpToolEnvironment::zoomIn (bool centerUnderCursor) const 0188 { 0189 mainWindow ()->zoomIn (centerUnderCursor); 0190 } 0191 0192 // public 0193 void kpToolEnvironment::zoomOut (bool centerUnderCursor) const 0194 { 0195 mainWindow ()->zoomOut (centerUnderCursor); 0196 } 0197 0198 0199 // public 0200 void kpToolEnvironment::zoomToRect ( 0201 const QRect &normalizedDocRect, 0202 bool accountForGrips, 0203 bool careAboutWidth, bool careAboutHeight) const 0204 { 0205 mainWindow ()->zoomToRect ( 0206 normalizedDocRect, 0207 accountForGrips, 0208 careAboutWidth, careAboutHeight); 0209 } 0210 0211 // public 0212 void kpToolEnvironment::fitToPage () const 0213 { 0214 mainWindow ()->slotFitToPage (); 0215 } 0216 0217 #include "moc_kpToolEnvironment.cpp"