/* This file is part of the KDE project
   Copyright (C) 1998, 1999 Reginald Stadlbauer <reggie@kde.org>
   Copyright (C) 2005 Thomas Zander <zander@kde.org>

   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Library General Public
   License as published by the Free Software Foundation; either
   version 2 of the License, or (at your option) any later version.

   This library is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   Library General Public License for more details.

   You should have received a copy of the GNU Library General Public License
   along with this library; see the file COPYING.LIB.  If not, write to
   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
   Boston, MA 02110-1301, USA.
*/

#ifndef kwview_h
#define kwview_h

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include <kprinter.h>

#include <KoBorder.h>
#include "defs.h"
#include "KWTextParag.h"

#include <KoPageLayoutDia.h>
#include <KoView.h>
#include <KoPoint.h>
#include <tdeshortcut.h>
#include <KoZoomMode.h>

#include <tqbrush.h>
#include <tqhbox.h>

class KWPage;
class KWViewMode;
class KWDocStruct;
class KWCanvas;
class KWDocument;
class KWGUI;
class KWFrame;
class KWFrameView;
class KWFrameViewManager;
class KWTextFrameSetEdit;
class KMacroCommand;
class KWFrameSet;
class KWFindReplace;
class KWFrameStyle;
class KWTableStyle;
class KWTableFrameSet;

class KoPicture;
class KoSearchContext;
class KoTextFormatInterface;
class KoRuler;
class TTDESelectColorAction;
class KoPartSelectAction;
class KoCharSelectDia;
class KoTextFormat;
class KoFontDia;
class KoParagDia;
class KoTextIterator;

class DCOPObject;
class KStatusBarLabel;
class KoSpell;
class KURL;
class TDEAction;
class TDEActionMenu;
class TDESelectAction;
class TDEToggleAction;
class TDEFontSizeAction;
class TDEFontAction;
class TQResizeEvent;
class TQSplitter;

#include <tdespell2/broker.h>
namespace KSpell2 {
    class Dialog;
}


/******************************************************************/
/* Class: KWView                                                  */
/******************************************************************/

class KWView : public KoView
{
    Q_OBJECT
  

public:
    KWView( const TQString& viewMode, TQWidget *parent, const char *name, KWDocument *doc );
    virtual ~KWView();

    virtual DCOPObject* dcopObject();

    // Those methods update the UI (from the given formatting info)
    // They do NOT do anything to the text
    void showFormat( const KoTextFormat &currentFormat );
    void showAlign( int align );
    void showCounter( KoParagCounter &c );
    void showSpacing( int spacing );
    /**
     * Updates the checked state of the border buttons based on the parameters.
     * @param left represents the left border being currently visible
     * @param right represents the right border being currently visible
     * @param top represents the top border being currently visible
     * @param bottom represents the bottom border being currently visible
     */
    void updateBorderButtons( const KoBorder& left, const KoBorder& right,
                          const KoBorder& top, const KoBorder& bottom );

    void showStyle( const TQString & styleName );
    void showRulerIndent( double leftMargin, double firstLine, double rightMargin, bool rtl );
    void showZoom( int zoom ); // show a zoom value in the combo
    void showZoom( const TQString& zoom ); // show a zoom value in the combo
    void setZoom( int zoom, bool updateViews ); // change the zoom value

    bool viewFrameBorders() const { return m_viewFrameBorders; }
    void setViewFrameBorders(bool b);

    /**
     * Returns the KWord global KSpell2 Broker object.
     */
    KSpell2::Broker *broker() const;

    void setNoteType(NoteType nt, bool change=true);

    KWDocument *kWordDocument()const { return m_doc; }
    KWGUI *getGUI()const { return m_gui; }
    KWViewMode* viewMode() const;

    void updateStyleList();
    void updateFrameStyleList();
    void updateTableStyleList();

    void initGui();

    /// returns the current page number this view is looking at
    int currentPage() const;

    /**
     * Overloaded from View
     */
    bool doubleClickActivation() const;
    /**
     * Overloaded from View
     */
    TQWidget* canvas() const;
    /**
     * Overloaded from View
     */
    int canvasXOffset() const;
    /**
     * Overloaded from View
     */
    int canvasYOffset() const;
    /**
     * Overloaded vrom View
     */
    void canvasAddChild( KoViewChild *child );

    virtual void setupPrinter( KPrinter &printer );
    virtual void print( KPrinter &printer );

    virtual TQPoint applyViewTransformations( const TQPoint& ) const;
    virtual TQPoint reverseViewTransformations( const TQPoint& ) const;

    void changeNbOfRecentFiles(int nb);

    void changeZoomMenu( int zoom=-1);

    void refreshMenuExpression();

    void updateGridButton();

    void deleteFrame(bool warning=true);

    TQPopupMenu * popupMenu( const TQString& name );

    TQPtrList<TDEAction> &dataToolActionList() { return m_actionList; }
    TQPtrList<TDEAction> &variableActionList() { return m_variableActionList; }
    TQPtrList<TDEAction> &tableActions() { return m_tableActionList; }

    enum { // bitfield
        ProvidesImage = 1,
        ProvidesPlainText = 2,
        ProvidesOasis = 4,
        ProvidesFormula = 8
    };
    static int checkClipboard( TQMimeSource *data );

    bool insertInlinePicture();

    void displayFrameInlineInfo();

    void initGUIButton();

    void updateHeaderFooterButton();
    void updateFooter();
    void updateHeader();
    void switchModeView();
    void changeFootNoteMenuItem( bool b);
    void insertFile(const KURL& url);
    void testAndCloseAllFrameSetProtectedContent();
    void updateBgSpellCheckingState();
    void updateRulerInProtectContentMode();
    void deselectAllFrames();
    void autoSpellCheck(bool b);
    void insertDirectCursor(bool b);
    void updateDirectCursorButton();

    void deleteFrameSet( KWFrameSet *);

    TQPtrList<TDEAction> listOfResultOfCheckWord( const TQString &word );

    int  tableSelectCell(const TQString &tableName, uint row, uint col);
    void tableInsertRow(uint row, KWTableFrameSet *table = 0);
    void tableInsertCol(uint col, KWTableFrameSet *table = 0);
    int tableDeleteRow(const TQValueList<uint>& rows, KWTableFrameSet *table = 0);
    int tableDeleteCol(const TQValueList<uint>& cols, KWTableFrameSet *table = 0);

    void pasteData( TQMimeSource* data, bool drop );

    KWFrameViewManager* frameViewManager() const;

public slots:
    void fileStatistics();
    void editCut();
    void editCopy();
    void editPaste();
    void editSelectAll();
    void editSelectAllFrames();
    void editSelectCurrentFrame();
    void editFind();
    void editFindNext();
    void editFindPrevious();
    void editReplace();
    void editDeleteFrame();
    void editCustomVariable();
    void editCustomVars();
    void editMailMergeDataBase();
    void createLinkedFrame();

    void viewTextMode();
    void viewPageMode();
    void viewPreviewMode();
    void slotViewFormattingChars();
    void slotViewFrameBorders();
    void viewHeader();
    void viewFooter();
    void viewZoom( const TQString &s );
    void updateZoom();

    void insertTable();
    void insertPicture();
    void insertSpecialChar();
    void insertFrameBreak();
    void insertVariable();
    void insertFootNote();
    void insertContents();
    void insertLink();
    void insertComment();
    void removeComment();
    void copyTextOfComment();

    void insertPage();
    void deletePage();

    void formatFont();
    void formatParagraph();
    void formatPage();
    void formatFrameSet();

    void slotSpellCheck();
    void extraAutoFormat();
    void extraFrameStylist();
    void extraStylist();
    void extraCreateTemplate();

    void toolsCreateText();
    void insertFormula( TQMimeSource* source=0 );
    void toolsPart();

    void tableProperties();
    void tableInsertRow();
    void tableInsertCol();
    void tableResizeCol();
    void tableDeleteRow();
    void tableDeleteCol();
    void tableJoinCells();
    void tableSplitCells();
    void tableSplitCells(int col, int row);
    void tableProtectCells(bool);
    void tableUngroupTable();
    void tableDelete();
    void tableStylist();
    void convertTableToText();
    void sortText();
    void addPersonalExpression();

    void slotStyleSelected();
    void slotFrameStyleSelected();
    void slotTableStyleSelected();
    void textStyleSelected( int );
    void frameStyleSelected( int );
    void tableStyleSelected( int );
    void textSizeSelected( int );
    void increaseFontSize();
    void decreaseFontSize();
    void textFontSelected( const TQString & );
    void textBold();
    void textItalic();
    void textUnderline();
    void textStrikeOut();
    void textColor();
    void textAlignLeft();
    void textAlignCenter();
    void textAlignRight();
    void textAlignBlock();
    void textSpacingSingle();
    void textSpacingOneAndHalf();
    void textSpacingDouble();
    void textSuperScript();
    void textSubScript();
    void textIncreaseIndent();
    void textDecreaseIndent();
    void textDefaultFormat();
    void slotCounterStyleSelected();

    // Text and Frame borders.
    void borderOutline();
    void borderLeft();
    void borderRight();
    void borderTop();
    void borderBottom();
    void backgroundColor();

    void showFormulaToolbar( bool show );

    void configure();
    void configureCompletion();

    void newPageLayout( const KoPageLayout &layout );
    void newLeftIndent( double leftIndent);
    void newFirstIndent( double firstIndent);
    void newRightIndent( double rightIndent);

    void clipboardDataChanged();
    void tabListChanged( const KoTabulatorList & tabList );

    void updatePageInfo();
    void updateFrameStatusBarItem();
    void setTemporaryStatusBarText(const TQString &text);

    void slotSpecialChar(TQChar , const TQString &);
    void slotFrameSetEditChanged();
    void showMouseMode( int /*KWCanvas::MouseMode*/ mouseMode );
    void frameSelectedChanged();
    void docStructChanged(int type);
    void documentModified( bool );
    void changeOverwriteMode( bool );
    void slotHRulerDoubleClicked();
    void slotHRulerDoubleClicked( double );
    void slotUnitChanged(KoUnit::Unit);

    void numPagesChanged();

    void insertExpression();

    void updateTocActionText(bool hasToc);

    void changeCaseOfText();

    void editPersonalExpr();

    void slotUpdateRuler();
    void slotEmbedImage( const TQString &filename );

    void insertCustomVariable();
    void insertNewCustomVariable();
    void slotSpecialCharDlgClosed();

    void refreshCustomMenu();

    void changePicture();

    void configureHeaderFooter();

    void inlineFrame();

    /** Move the selected frame above maximum 1 frame that is in front of it. */
    void raiseFrame() { adjustZOrderOfSelectedFrames(RaiseFrame); };
    /** Move the selected frame behind maximum 1 frame that is behind it */
    void lowerFrame() { adjustZOrderOfSelectedFrames(LowerFrame); };
    /** Move the selected frame(s) to be in the front most position. */
    void bringToFront() { adjustZOrderOfSelectedFrames(BringToFront); };
    /** Move the selected frame(s) to be behind all other frames */
    void sendToBack() { adjustZOrderOfSelectedFrames(SendToBack); };

    void openLink();
    void changeLink();
    void copyLink();
    void removeLink();
    void addToBookmark();
    void editComment();
    void showDocStructure();
    void showRuler();
    void viewGrid();
    void viewSnapToGrid();

    void slotSoftHyphen();
    void slotLineBreak();
    void slotNonbreakingSpace();
    void slotNonbreakingHyphen();

    void slotIncreaseNumberingLevel();
    void slotDecreaseNumberingLevel();

    void refreshAllVariable();

    void slotAllowAutoFormat();

    void slotCompletion();

    void applyAutoFormat();
    void createStyleFromSelection();

    void configureFootEndNote();
    void editFootEndNote();
    void changeFootNoteType();
    void savePicture();

    void autoSpellCheck();
    void goToFootEndNote();

    // Document Structure Area popup menu.
    void docStructEdit();
    void docStructSpeak();
    void docStructSelect();
    void docStructDelete();
    void docStructProperties();
    void openDocStructurePopupMenu( const TQPoint &p, KWFrameSet *frameset, KWTextParag *parag);

    void insertFile();

    void addBookmark();
    void selectBookmark();
    void importStyle();

    void createFrameStyle();

    void insertDirectCursor();

    void convertToTextBox();

    void slotAddIgnoreAllWord();

    void embeddedStoreInternal();

    void goToDocumentStructure();
    void goToDocument();

    void addWordToDictionary();

    void insertPicture( const KoPicture& picture, const bool makeInline, const bool keepRatio, int suggestedWidth, int suggestedHeight );

    // end of public methods
protected slots:
    virtual void slotChildActivated( bool a ); ///< from KoView
    void slotSetInitialPosition();

    void spellCheckerMisspelling( const TQString &, int );
    void spellCheckerCorrected( const TQString &, int, const TQString & );
    void spellCheckerDone( const TQString & );
    void spellCheckerCancel();

    void spellAddAutoCorrect (const TQString & originalword, const TQString & newword);
    void slotApplyFont();
    void slotApplyParag();
    void slotPageLayoutChanged( const KoPageLayout& layout );
    void slotChangeCaseState(bool b);
    void slotChangeCutState(bool b);
    void slotCorrectWord();

    /// This slot is called when the document has finished loading.
    void slotDocumentLoadingCompleted();

protected:
    void addVariableActions( int type, const TQStringList & texts,
                             TDEActionMenu * parentMenu, const TQString & menuText );

    void loadexpressionActions( TDEActionMenu * parentMenu);

    void createExpressionActions( TDEActionMenu * parentMenu,const TQString& filename,int &i , bool insertSepar, const TQMap<TQString, TDEShortcut>& personalShortCut );

    void showParagraphDialog( int initialPage = -1, double initialTabPos = 0.0 );

    KWTextFrameSetEdit *currentTextEdit() const;
    /** The current text-edit if there is one, otherwise the selected text objects
     * This is what the "bold", "italic" etc. buttons apply to. */
    TQPtrList<KoTextFormatInterface> applicableTextInterfaces() const;

    void setupActions();

    virtual void resizeEvent( TQResizeEvent *e );
    virtual void guiActivateEvent( KParts::GUIActivateEvent *ev );

    virtual void updateReadWrite( bool readwrite );
    /**
     * Make sure the actions related to tables have the right texts and enabled options.
     * @param selectFrames a list of selected frames
     * @see KWFrameViewManager::selectedFrames()
     */
    void updateTableActions( TQValueList<KWFrameView*> selectFrames);


    void startKSpell();
    void clearSpellChecker(bool cancelSpellCheck = false );

    TQValueList<TQString> getInlineFramesets( const TQDomNode &framesetElem );

    // Helper stuff for the frame adjustment;
    enum MoveFrameType  { RaiseFrame, LowerFrame, BringToFront, SendToBack };
    void adjustZOrderOfSelectedFrames(MoveFrameType moveType);
    void increaseAllZOrdersAbove(int refZOrder, int pageNum, const TQPtrList<KWFrame>& frameSelection);
    void decreaseAllZOrdersUnder(int refZOrder, int pageNum, const TQPtrList<KWFrame>& frameSelection);
    int raiseFrame(const TQPtrList<KWFrame>& frameSelection, const KWFrame *frame);
    int lowerFrame(const TQPtrList<KWFrame>& frameSelection, const KWFrame *frame);
    int bringToFront(const TQPtrList<KWFrame>& frameSelection, const KWFrame *frame);
    int sendToBack(const TQPtrList<KWFrame>& frameSelection, const KWFrame *frame);
    void textStyleSelected( KoParagStyle *sty );
    void frameStyleSelected( KWFrameStyle *sty );
    void tableStyleSelected( KWTableStyle *sty );
    void changeFootEndNoteState();
    void refreshDeletePageAction();

    void spellCheckerRemoveHighlight();

    void setSpacing( KoParagLayout::SpacingType spacing, const TQString &commandName );

private:  // methods
    void deleteSelectedFrames();
    void borderChanged(KoBorder::BorderType type);
    void updateZoomControls();

private: // variables
    KWDocument *m_doc;

    TDEAction *m_actionFileStatistics;
    TDEAction *m_actionEditCut;
    TDEAction *m_actionEditCopy;
    TDEAction *m_actionEditPaste;
    TDEAction *m_actionEditSelectAll;
    TDEAction *m_actionEditSelectCurrentFrame;
    TDEAction *m_actionEditDelFrame;
    TDEAction *m_actionCreateLinkedFrame;
    TDEAction *m_actionRaiseFrame;
    TDEAction *m_actionLowerFrame;
    TDEAction *m_actionSendBackward;
    TDEAction *m_actionBringToFront;

    TDEAction *m_actionEditCustomVars;
    TDEAction *m_actionEditCustomVarsEdit;
    TDEAction *m_actionEditFind;
    TDEAction *m_actionEditFindNext;
    TDEAction *m_actionEditFindPrevious;
    TDEAction *m_actionEditReplace;
    TDEAction *m_actionApplyAutoFormat;

    TDEToggleAction *m_actionViewTextMode;
    TDEToggleAction *m_actionViewPageMode;
    TDEToggleAction *m_actionViewPreviewMode;

    TDEToggleAction *m_actionViewFormattingChars;
    TDEToggleAction *m_actionViewFrameBorders;
    TDEToggleAction *m_actionViewHeader;
    TDEToggleAction *m_actionViewFooter;
    TDEToggleAction *m_actionViewFootNotes;
    TDEToggleAction *m_actionViewEndNotes;
    TDEToggleAction *m_actionShowDocStruct;
    TDEToggleAction *m_actionShowRuler;
    TDEToggleAction *m_actionViewShowGrid;
    TDEToggleAction *m_actionViewSnapToGrid;
    TDEToggleAction *m_actionAllowAutoFormat;

    TDEToggleAction *m_actionAllowBgSpellCheck;

    TDESelectAction *m_actionViewZoom;

    TDEAction *m_actionInsertFrameBreak;
    TDEAction *m_actionInsertFootEndNote;
    TDEAction *m_actionInsertContents;
    TDEAction *m_actionInsertLink;
    TDEAction *m_actionInsertComment;
    TDEAction *m_actionEditComment;
    TDEAction *m_actionRemoveComment;
    TDEAction *m_actionCopyTextOfComment;
    //TDEAction *actionInsertPage;
    TDEAction *m_actionDeletePage;

    TDEActionMenu *actionInsertVariable;
    struct VariableDef {
        int type;
        int subtype;
    };
    typedef TQMap<TDEAction *, VariableDef> VariableDefMap;
    TDEActionMenu *m_actionInsertExpression;

    TDEActionMenu *m_actionInsertCustom;

    VariableDefMap m_variableDefMap;
    TDEAction *m_actionInsertFormula;
    TDEAction *m_actionInsertTable;
    TDEAction *m_actionAutoFormat;

    TDEToggleAction *m_actionToolsCreateText;
    TDEToggleAction *m_actionToolsCreatePix;
    KoPartSelectAction *m_actionToolsCreatePart;

    TDEAction *m_actionFormatFont;
    TDEAction *m_actionFormatDefault;
    TDEAction *m_actionFormatFrameStylist;
    TDEAction *m_actionFormatStylist;
    TDEAction *m_actionFormatPage;

    TDEAction *m_actionFontSizeIncrease;
    TDEAction *m_actionFontSizeDecrease;

    TDEFontSizeAction *m_actionFormatFontSize;
    TDEFontAction *m_actionFormatFontFamily;
    TDESelectAction *m_actionFormatStyle;
    TDEActionMenu *m_actionFormatStyleMenu;
    TDEToggleAction *m_actionFormatBold;
    TDEToggleAction *m_actionFormatItalic;
    TDEToggleAction *m_actionFormatUnderline;
    TDEToggleAction *m_actionFormatStrikeOut;
    TTDESelectColorAction *m_actionFormatColor;
    TDEToggleAction *m_actionFormatAlignLeft;
    TDEToggleAction *m_actionFormatAlignCenter;
    TDEToggleAction *m_actionFormatAlignRight;
    TDEToggleAction *m_actionFormatAlignBlock;
    TDEToggleAction *m_actionFormatSpacingSingle;
    TDEToggleAction *m_actionFormatSpacingOneAndHalf;
    TDEToggleAction *m_actionFormatSpacingDouble;
    TDEAction *m_actionFormatParag;
    TDEAction *m_actionFormatFrameSet;
    TDEAction *m_actionFormatIncreaseIndent;
    TDEAction *m_actionFormatDecreaseIndent;
    TDEActionMenu *m_actionFormatBullet;
    TDEActionMenu *m_actionFormatNumber;
    TDEToggleAction *m_actionFormatSuper;
    TDEToggleAction *m_actionFormatSub;
    TDEAction* m_actionInsertSpecialChar;

    // Text and Frame borders.
    TDESelectAction *m_actionFrameStyle;
    TDEActionMenu *m_actionFrameStyleMenu;
    TDESelectAction *m_actionTableStyle;
    TDEActionMenu *m_actionTableStyleMenu;
    TDEToggleAction *m_actionBorderLeft;
    TDEToggleAction *m_actionBorderRight;
    TDEToggleAction *m_actionBorderTop;
    TDEToggleAction *m_actionBorderBottom;
    TDEToggleAction *m_actionBorderOutline;
    TTDESelectColorAction *m_actionBorderColor;
    TDESelectAction *m_actionBorderWidth;
    TDESelectAction *m_actionBorderStyle;
    TTDESelectColorAction *m_actionBackgroundColor;

    TDEAction *m_actionTableDelRow;
    TDEAction *m_actionTableDelCol;
    TDEAction *m_actionTableInsertRow;
    TDEAction *m_actionTableInsertCol;
    TDEAction *m_actionTableResizeCol;
    TDEAction *m_actionTableJoinCells;
    TDEAction *m_actionTableSplitCells;
    TDEAction *m_actionConvertTableToText;
    TDEAction *m_actionSortText;
    TDEAction *m_actionAddPersonalExpression;
    TDEToggleAction *m_actionTableProtectCells;

    TDEAction *m_actionTableUngroup;
    TDEAction *m_actionTableDelete;

    TDEAction *m_actionTableStylist;
    TDEAction *m_actionTablePropertiesMenu;
    TDEAction *m_actionTableProperties;

    TDEAction *m_actionExtraCreateTemplate;

    TDEAction *m_actionChangeCase;

    TDEAction *m_actionEditPersonnalExpr;

    TDEAction *m_actionConfigure;

    TDEAction *m_actionConfigureCompletion;

    TDEAction *m_actionSavePicture;

    TDEAction *m_actionConfigureHeaderFooter;
    TDEToggleAction *m_actionInlineFrame;

    TDEAction *m_actionOpenLink;
    TDEAction *m_actionChangeLink;
    TDEAction *m_actionCopyLink;
    TDEAction *m_actionAddLinkToBookmak;
    TDEAction *m_actionRemoveLink;

    TDEAction *m_actionRefreshAllVariable;
    TDEAction *m_actionCreateStyleFromSelection;

    TDEAction *m_actionConfigureFootEndNote;

    TDEAction *m_actionEditFootEndNote;

    TDEAction *m_actionChangeFootNoteType;

    TDEAction *m_actionGoToFootEndNote;

    // Document Structure Area popup menu.
    TDEAction *m_actionDocStructEdit;
    TDEAction *m_actionDocStructSpeak;
    TDEAction *m_actionDocStructSelect;
    TDEAction *m_actionDocStructDelete;
    TDEAction *m_actionDocStructProperties;

    TDEAction *m_actionInsertFile;

    TDEAction *m_actionAddBookmark;
    TDEAction *m_actionSelectBookmark;

    TDEAction *m_actionImportStyle;

    TDEAction *m_actionCreateFrameStyle;

    TDEAction *m_actionConvertToTextBox;

    TDEAction *m_actionSpellIgnoreAll;
    TDEAction *m_actionSpellCheck;

    TDEToggleAction *m_actionEmbeddedStoreInternal;

    TDEAction *m_actionAddWordToPersonalDictionary;

    TDEToggleAction *m_actionInsertDirectCursor;

    TDEAction *m_actionGoToDocumentStructure;
    TDEAction *m_actionGoToDocument;


    KoCharSelectDia *m_specialCharDlg;
    KoFontDia *m_fontDlg;
    KoParagDia *m_paragDlg;

    KWGUI *m_gui;

    DCOPObject *m_dcop;

    KoSearchContext *m_searchEntry, *m_replaceEntry;
    KWFindReplace *m_findReplace;

    TQPtrList<TDEAction> m_actionList; // for the kodatatools
    TQPtrList<TDEAction> m_variableActionList;
    TQPtrList<TDEAction> m_tableActionList;

    KWPage *m_currentPage; ///< current page number

    // Statusbar items
    KStatusBarLabel* m_sbPageLabel; ///< 'Current page number and page count' label
    KStatusBarLabel* m_sbModifiedLabel;
    KStatusBarLabel* m_sbFramesLabel; ///< Info about selected frames
    KStatusBarLabel* m_sbOverwriteLabel;
    KStatusBarLabel* m_sbUnitLabel;
    KStatusBarLabel* m_sbZoomLabel;

    // Zoom values for each viewmode ( todo a viewmode enum and a qmap or so )
    struct KWZoomValueStore {
        int m_zoom;
        KoZoomMode::Mode m_zoomMode;
    };
    KWZoomValueStore m_zoomViewModeNormal;
    KWZoomValueStore m_zoomViewModePreview;

    bool m_viewFrameBorders /*, m_viewTableGrid*/;

    /// Spell-checking
    struct {
        KoSpell *kospell;
        KMacroCommand * macroCmdSpellCheck;
        TQStringList replaceAll;
        KoTextIterator * textIterator;
        KSpell2::Dialog *dlg;
     } m_spell;
    KSpell2::Broker::Ptr m_broker;


    KWFrameSet *m_fsInline;

    // Split cell in table
    struct {
        unsigned int columns, rows;
    } m_tableSplit;
};

/******************************************************************/
/* Class: KWViewWidget                                            */
/******************************************************************/
class KWViewWidget : public TQWidget
{
    Q_OBJECT
  

public:
    KWViewWidget( TQWidget *parent, KWView *view );

protected:
    void resizeEvent( TQResizeEvent *e );

    // A pointer to the view.
    KWView          *m_view;
};

/******************************************************************/
/* Class: KWGUI                                                   */
/******************************************************************/

class KWGUI : public TQHBox
{
    Q_OBJECT
  

public:
    KWGUI( const TQString& viewMode, TQWidget *parent, KWView *view );

    void showGUI();

    KWView *getView()const { return m_view; }
    KWCanvas *canvasWidget()const { return m_canvas; }
    KoRuler *getVertRuler()const { return m_vertRuler; }
    KoRuler *getHorzRuler()const { return m_horRuler; }
    KoTabChooser *getTabChooser()const { return m_tabChooser; }
    KWDocStruct *getDocStruct()const { return m_docStruct; }

public slots:
    void reorganize();

protected slots:
    void unitChanged( KoUnit::Unit );

protected:
    void resizeEvent( TQResizeEvent *e );

    // A pointer to the view.
    KWView          *m_view;

    // The left side
    KWDocStruct     *m_docStruct;

    // The right side
    TQWidget         *m_right;	// The layout widget.

    KoTabChooser    *m_tabChooser;
    KoRuler         *m_vertRuler;
    KoRuler         *m_horRuler;
    KWCanvas        *m_canvas;

    TQSplitter       *m_panner;

};

#endif
