1
2 /*
3 Copyright (c) 2003-2007 Clarence Dang <dang@kde.org>
4 All rights reserved.
5
6 Redistribution and use in source and binary forms, with or without
7 modification, are permitted provided that the following conditions
8 are met:
9
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.
15
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.
26 */
27
28
29 #include "environments/kpEnvironmentBase.h"
30
31 #include "widgets/toolbars/kpColorToolBar.h"
32 #include "document/kpDocument.h"
33 #include "mainWindow/kpMainWindow.h"
34 #include "layers/selections/text/kpTextStyle.h"
35 #include "tools/kpTool.h"
36
37
38 struct kpEnvironmentBasePrivate
39 {
40 kpMainWindow *mainWindow;
41 };
42
kpEnvironmentBase(kpMainWindow * mainWindow)43 kpEnvironmentBase::kpEnvironmentBase (kpMainWindow *mainWindow)
44 : QObject (mainWindow),
45 d (new kpEnvironmentBasePrivate ())
46 {
47 Q_ASSERT (mainWindow);
48
49 d->mainWindow = mainWindow;
50 }
51
~kpEnvironmentBase()52 kpEnvironmentBase::~kpEnvironmentBase ()
53 {
54 delete d;
55 }
56
57
58 // public
document() const59 kpDocument *kpEnvironmentBase::document () const
60 {
61 return d->mainWindow->document ();
62 }
63
64
65 // public
selection() const66 kpAbstractSelection *kpEnvironmentBase::selection () const
67 {
68 kpDocument *doc = document ();
69 Q_ASSERT (doc);
70
71 return doc->selection ();
72 }
73
74 // public
imageSelection() const75 kpAbstractImageSelection *kpEnvironmentBase::imageSelection () const
76 {
77 kpDocument *doc = document ();
78 Q_ASSERT (doc);
79
80 return doc->imageSelection ();
81 }
82
83 // public
textSelection() const84 kpTextSelection *kpEnvironmentBase::textSelection () const
85 {
86 kpDocument *doc = document ();
87 Q_ASSERT (doc);
88
89 return doc->textSelection ();
90 }
91
92
93 // public
viewManager() const94 kpViewManager *kpEnvironmentBase::viewManager () const
95 {
96 return mainWindow ()->viewManager ();
97 }
98
99
100 // public
commandEnvironment() const101 kpCommandEnvironment *kpEnvironmentBase::commandEnvironment () const
102 {
103 return mainWindow ()->commandEnvironment ();
104 }
105
106
107 // public
backgroundColor(bool ofSelection) const108 kpColor kpEnvironmentBase::backgroundColor (bool ofSelection) const
109 {
110 return d->mainWindow->backgroundColor (ofSelection);
111 }
112
113
114 // protected
mainWindow() const115 kpMainWindow *kpEnvironmentBase::mainWindow () const
116 {
117 return d->mainWindow;
118 }
119
120
121