kword

KWFrameView.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 kwframeview_h
00019 #define kwframeview_h
00020 
00021 #include "defs.h"
00022 class KWFrameView;
00023 class KWFrameViewManager;
00024 class KWFrame;
00025 class KWView;
00026 class KWViewMode;
00027 class KoZoomHandler;
00028 class KoPoint;
00029 class KActionSeparator;
00030 class KAction;
00031 class QPopupMenu;
00032 
00036 class FramePolicy {
00037 public:
00039     FramePolicy(KWFrameView *view);
00045     virtual MouseMeaning mouseMeaning( const KoPoint &point, int keyState ) = 0;
00051     virtual QPopupMenu* createPopup( const KoPoint &point, KWView *view ) = 0;
00055     virtual void setSelected(MouseMeaning) { }
00056 
00057 protected:
00063     virtual MouseMeaning mouseMeaningOnBorder(const KoPoint &point, int keyState);
00069     void addFloatingAction(KWView *view, QPtrList<KAction> &actionList);
00070 
00071     KWFrameView *m_view;
00072     KActionSeparator *m_separator;
00073 
00074     friend class KWFrameView; // so it can call mouseMeaningOnBorder which assumes some stuff
00075 };
00076 
00082 class KWFrameView {
00083 public:
00089     KWFrameView(KWFrameViewManager *parent, KWFrame *frame);
00090     virtual ~KWFrameView();
00091 
00093     bool selected() const { return m_selected; }
00100     void setSelected(bool selected, MouseMeaning selectPolicy = MEANING_MOUSE_SELECT);
00101 
00103     KWFrame *frame() const { return m_frame; }
00104 
00106     bool isBorderHit(const KoPoint &point) const;
00108     bool contains(const KoPoint &point, bool fuzzy = true) const;
00109 
00115     MouseMeaning mouseMeaning( const KoPoint &point, int keyState );
00116 
00118     KWFrameViewManager *parent() const { return m_manager; }
00119 
00128     void showPopup( const KoPoint &point, KWView *view, const QPoint &popupPoint) const;
00129 
00137     void paintFrameAttributes(QPainter *painter, const QRect &crect, KWViewMode *vm, KoZoomHandler *zh);
00138 
00139 private:
00146     bool hit(const KoPoint &point, bool fuzzy, bool borderOnly) const;
00147 
00148 private:
00149     KWFrame *m_frame;
00150     bool m_selected;
00151     FramePolicy *m_policy;
00152     KWFrameViewManager *m_manager;
00153 };
00154 
00156 class TableFramePolicy : public FramePolicy {
00157 public:
00158     TableFramePolicy(KWFrameView *view);
00159     MouseMeaning mouseMeaning( const KoPoint &point, int keyState );
00160     QPopupMenu* createPopup( const KoPoint &point, KWView *view );
00161     void setSelected(MouseMeaning selectPolicy);
00162 
00163 protected:
00164     MouseMeaning mouseMeaningOnBorder( const KoPoint &point, int keyState);
00165 };
00166 
00168 class PartFramePolicy : public FramePolicy {
00169 public:
00170     PartFramePolicy(KWFrameView *view);
00171     MouseMeaning mouseMeaning( const KoPoint &point, int keyState );
00172     QPopupMenu* createPopup( const KoPoint &point, KWView *view );
00173 };
00174 
00176 class TextFramePolicy : public FramePolicy {
00177 public:
00178     TextFramePolicy(KWFrameView *view);
00179     MouseMeaning mouseMeaning( const KoPoint &point, int keyState );
00180     QPopupMenu* createPopup( const KoPoint &point, KWView *view );
00181 };
00182 
00184 class ImageFramePolicy : public FramePolicy {
00185 public:
00186     ImageFramePolicy(KWFrameView *view);
00187     MouseMeaning mouseMeaning( const KoPoint &point, int keyState );
00188     QPopupMenu* createPopup( const KoPoint &point, KWView *view );
00189 };
00190 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys