File indexing completed on 2024-04-28 04:20:14
0001 0002 // LOREFACTOR: The files in this folder duplicate too much code. 0003 // Use mixin multiple inheritance to get around this. 0004 // 0005 // LOREFACTOR: Move as much kpMainWindow code as possible into these classes 0006 // to reduce the size of kpMainWindow. But do not split concerns / 0007 // "aspects" in kpMainWindow, with half the code there and half here, 0008 // as that would be confusing. 0009 0010 /* 0011 Copyright (c) 2003-2007 Clarence Dang <dang@kde.org> 0012 All rights reserved. 0013 0014 Redistribution and use in source and binary forms, with or without 0015 modification, are permitted provided that the following conditions 0016 are met: 0017 0018 1. Redistributions of source code must retain the above copyright 0019 notice, this list of conditions and the following disclaimer. 0020 2. Redistributions in binary form must reproduce the above copyright 0021 notice, this list of conditions and the following disclaimer in the 0022 documentation and/or other materials provided with the distribution. 0023 0024 THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 0025 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 0026 OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 0027 IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 0028 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 0029 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 0030 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 0031 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 0032 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 0033 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 0034 */ 0035 0036 0037 #ifndef kpEnvironmentBase_H 0038 #define kpEnvironmentBase_H 0039 0040 0041 #include <QObject> 0042 0043 0044 class kpAbstractImageSelection; 0045 class kpAbstractSelection; 0046 class kpColor; 0047 class kpCommandEnvironment; 0048 class kpDocument; 0049 class kpMainWindow; 0050 class kpTextSelection; 0051 class kpViewManager; 0052 0053 0054 // Abstract facade bridging kpMainWindow and other suppliers (e.g. kpTool, 0055 // kpToolToolBar, kpColorToolBar) to clients. 0056 // 0057 // This decouples as many classes as possible from clients, for maintainability. 0058 // If adding new methods to this class, it is preferable to expose additional 0059 // functionality, rather than expose additional classes. 0060 // 0061 // This class also avoids cramming excessive functionality into kpMainWindow. 0062 // 0063 // If this interface gets too bloated, push down the specialized methods into 0064 // a new class. 0065 class kpEnvironmentBase : public QObject 0066 { 0067 Q_OBJECT 0068 0069 // (must derive from) 0070 protected: 0071 // Note: Our interface must never publicly leak <mainWindow> or any other 0072 // classes we are trying to hide as that would defeat the point of 0073 // the facade. 0074 kpEnvironmentBase (kpMainWindow *mainWindow); 0075 ~kpEnvironmentBase () override; 0076 0077 public: 0078 kpDocument *document () const; 0079 0080 kpAbstractSelection *selection () const; 0081 kpAbstractImageSelection *imageSelection () const; 0082 kpTextSelection *textSelection () const; 0083 0084 kpViewManager *viewManager () const; 0085 0086 kpCommandEnvironment *commandEnvironment () const; 0087 0088 kpColor backgroundColor (bool ofSelection = false) const; 0089 0090 protected: 0091 kpMainWindow *mainWindow () const; 0092 0093 private: 0094 struct kpEnvironmentBasePrivate * const d; 0095 }; 0096 0097 0098 #endif // kpEnvironmentBase_H 0099