kword

KWFrameViewManager.h

00001 /* This file is part of the KOffice project
00002  * Copyright (C) 2005 Thomas Zander <zander@kde.org>
00003  *
00004  * This library is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU Library General Public
00006  * License as published by the Free Software Foundation; version 2.
00007 
00008  * This library is distributed in the hope that it will be useful,
00009  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00010  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011  * Library General Public License for more details.
00012  *
00013  * You should have received a copy of the GNU Library General Public License
00014  * along with this library; see the file COPYING.LIB.  If not, write to
00015  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00016  * Boston, MA 02110-1301, USA.
00017  */
00018 #ifndef kwframeviewmanager_h
00019 #define kwframeviewmanager_h
00020 #include <qobject.h>
00021 #include <qptrlist.h>
00022 #include <qvaluelist.h>
00023 #include <qvaluevector.h>
00024 #include <defs.h>
00025 
00026 class KWDocument;
00027 class KWFrame;
00028 class KWFrameSet;
00029 class KWView;
00030 class KWViewMode;
00031 class KWFramesListener;
00032 class KWFrameSetEdit;
00033 class KWFrameView;
00034 
00035 class KoPoint;
00036 class KoRect;
00037 
00038 class QPointer;
00039 class QRegion;
00040 
00051 class KWFrameViewManager : public QObject {
00052     Q_OBJECT
00053 
00054 public:
00055     KWFrameViewManager();
00060     KWFrameViewManager(KWDocument *doc);
00061     virtual ~KWFrameViewManager();
00062 
00076     enum SelectionType { selected, unselected, nextUnselected, frameOnTop };
00085     KWFrameView *view(const KoPoint &point, SelectionType select, bool borderOnly = false) const;
00087     KWFrameView *view(const KWFrame *frame) const;
00088 
00092     QValueList<KWFrameView*> selectedFrames() const;
00097     KWFrameView* selectedFrame() const;
00098 
00099     // this should be changed to a real iterator when Qt4 is used.
00100     const QValueList<KWFrameView*> frameViewsIterator() const { return m_frames; }
00101 
00109     MouseMeaning mouseMeaning( const KoPoint &point, int keyState) const;
00116     QCursor mouseCursor( const KoPoint &point, int keyState ) const;
00117 
00127     void showPopup( const KoPoint &point, KWView *view, int keyState, const QPoint &popupPoint) const;
00128 
00129     // listeners; see the fireEvents method signature for more info.
00130     void addKWFramesListener(KWFramesListener *listener);
00131     void removeKWFramesListener(KWFramesListener *listener);
00132 
00141     void selectFrames(const KoPoint &point, int keyState, bool leftClick);
00142 
00143 public slots:
00145     void slotFrameSetAdded(KWFrameSet *fs);
00147     void slotFrameSetRemoved(KWFrameSet *fs);
00149     void slotFrameAdded(KWFrame *f);
00151     void slotFrameRemoved(KWFrame *f);
00158     void slotFrameMoved(KWFrame *f, double previousYPosition);
00160     void slotFrameResized(KWFrame *f);
00162     void slotFrameSelectionChanged();
00164     void slotFrameSetRenamed(KWFrameSet *fs);
00165 
00166 signals:
00168     void sigFrameSelectionChanged();
00170     void sigFrameSetRenamed();
00172     void sigFrameResized(const QValueList<KWFrame*>&);
00174     void sigFrameMoved(const QValueList<KWFrame*>&);
00175 
00176 protected slots:
00182     void fireEvents();
00183 
00184 protected:
00186 #ifndef NDEBUG
00187     virtual
00188 #endif
00189     void requestFireEvents();
00190 
00191 private:
00193     class FrameEvent {
00194         public:
00195             enum ActionType { FrameRemoved, FrameAdded, FrameSetRemoved, FrameSetAdded, FrameMoved,
00196                 FrameResized, FrameSelectionChanged, FrameSetRenamed };
00197             FrameEvent (ActionType action);
00198             FrameEvent (ActionType action, KWFrame *frame);
00199             FrameEvent (ActionType action, KWFrameSet *frameSet);
00200         private:
00201             ActionType m_action;
00202             KWFrame *m_frame;
00203             KWFrameSet *m_frameSet;
00204         friend class KWFrameViewManager;
00205     };
00206 
00208     void recalculateFrameCache();
00209 
00215     QValueVector<KWFrameView*> framesAt(const KoPoint &point, bool borderOnly = false) const;
00221     static bool compareFrameViewZOrder(KWFrameView *f1, KWFrameView *f2);
00222 
00223 private:
00224     QValueList<KWFrameView*> m_frames; // TODO QHash<KWFrame*,KWFrameView*>
00225     QValueList<KWFramesListener*> m_framesListener;
00226     QValueList<FrameEvent*> m_frameEvents;
00227     bool m_queueRequested, m_blockEvents;
00228 };
00229 
00230 class KWFramesListener {
00231 public:
00232     virtual void frameSetAdded(KWFrameSet *fs) = 0;
00233     virtual void frameSetRemoved(KWFrameSet *fs) = 0;
00234     virtual void frameAdded(KWFrame *f) = 0;
00235     virtual void frameRemoved(KWFrame *f) = 0;
00236 };
00237 
00238 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys