Back to index

scribus-ng  1.3.4.dfsg+svn20071115
undogui.h
Go to the documentation of this file.
00001 /*
00002 For general Scribus (>=1.3.2) copyright and licensing information please refer
00003 to the COPYING file provided with the program. Following this notice may exist
00004 a copyright and/or license notice that predates the release of Scribus 1.3.2
00005 for which a new license (GPL+exception) is in place.
00006 */
00007 /***************************************************************************
00008  *   Copyright (C) 2005 by Riku Leino                                      *
00009  *   tsoots@gmail.com                                                      *
00010  *                                                                         *
00011  *   This program is free software; you can redistribute it and/or modify  *
00012  *   it under the terms of the GNU General Public License as published by  *
00013  *   the Free Software Foundation; either version 2 of the License, or     *
00014  *   (at your option) any later version.                                   *
00015  *                                                                         *
00016  *   This program is distributed in the hope that it will be useful,       *
00017  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00018  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00019  *   GNU General Public License for more details.                          *
00020  *                                                                         *
00021  *   You should have received a copy of the GNU General Public License     *
00022  *   along with this program; if not, write to the                         *
00023  *   Free Software Foundation, Inc.,                                       *
00024  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00025  ***************************************************************************/
00026 
00027 #ifndef UNDOGUI_H
00028 #define UNDOGUI_H
00029 
00030 #include "scribusapi.h"
00031 #include "undoobject.h"
00032 #include "undostate.h"
00033 #include "scrpalettebase.h"
00034 #include <vector>
00035 #include <qwidget.h>
00036 #include <qdialog.h>
00037 #include <qstring.h>
00038 #include <qlistbox.h>
00039 #include <qtoolbutton.h>
00040 #include <qpainter.h>
00041 #include <qpixmap.h>
00042 #include <qpopupmenu.h>
00043 
00044 class QCheckBox;
00045 class PrefsContext;
00046 
00062 class SCRIBUS_API UndoGui : public ScrPaletteBase
00063 {
00064        Q_OBJECT
00065 
00066 public:
00073        UndoGui(QWidget* parent = 0, const char* name = "UndoGui", WFlags f = 0);
00074 
00076        virtual ~UndoGui() {};
00077 
00079        virtual void clear() = 0;
00080 
00081 public slots:
00091        virtual void insertUndoItem(UndoObject* target, UndoState* state) = 0;
00092 
00098        virtual void insertRedoItem(UndoObject* target, UndoState* state) = 0;
00099 
00108        virtual void updateUndo(int steps) = 0;
00109 
00118        virtual void updateRedo(int steps) = 0;
00119        
00123        virtual void updateUndoActions() = 0;
00124        
00126        virtual void clearRedo() = 0;
00127 
00129        virtual void popBack() = 0;
00130 /* signals: do not implement these but emit when action happens
00131        virtual void undo(int steps) = 0;
00132        virtual void redo(int steps) = 0;
00133 */
00134 };
00135 
00136 /*** UndoGui implementations **************************************************/
00137 /*** UndoWidget ***************************************************************/
00138 
00148 class SCRIBUS_API UndoWidget : public UndoGui
00149 {
00150        Q_OBJECT
00151 
00152 private:
00154        static const uint MENU_HEIGHT = 5;
00155        std::vector<QString> undoItems;
00156        std::vector<QString> redoItems;
00157        /* BnF buttons
00158        QToolButton* undoButton;
00159        QToolButton* redoButton;
00160        */
00161        QPopupMenu* undoMenu;
00162        QPopupMenu* redoMenu;
00163        void updateUndoMenu();
00164        void updateRedoMenu();
00165 public:
00167        UndoWidget(QWidget* parent = 0, const char* name = 0);
00168 
00170        virtual ~UndoWidget();
00171 
00173        void clear();
00177        virtual void updateUndoActions();
00178               
00179 private slots:
00180        void undoClicked();
00181        void redoClicked();
00182        void undoMenuClicked(int id);
00183        void redoMenuClicked(int id);
00184 public slots:
00194        void insertUndoItem(UndoObject* target, UndoState* state);
00195 
00201        void insertRedoItem(UndoObject* target, UndoState* state);
00202 
00211        void updateUndo(int steps);
00212 
00221        void updateRedo(int steps);
00222        
00224        void clearRedo();
00225        
00227        void popBack();
00228 signals:
00235        void undo(int steps);
00236 
00243        void redo(int steps);
00244 };
00245 
00246 /*** UndoPalette **************************************************************/
00247 
00259 class SCRIBUS_API UndoPalette : public UndoGui
00260 {
00261        Q_OBJECT
00262 
00263 private:
00264        int currentSelection;
00265        int redoItems;
00266        QListBox* undoList;
00267        QCheckBox* objectBox;
00268        QPushButton* undoButton;
00269        QPushButton* redoButton;
00270        QKeySequence initialUndoKS;
00271        QKeySequence initialRedoKS;
00272        void updateList();
00273        void removeRedoItems();
00274        
00275 /*** UndoPalette::UndoItem ****************************************************/
00276        
00278        class UndoItem : public QListBoxItem
00279        {
00280        private:
00282               QPixmap *targetpixmap;
00284               QPixmap *actionpixmap;
00286               QString target;
00288               QString action;
00290               QString description;
00292               bool isUndoAction_;
00293        public:
00295               UndoItem();
00300               UndoItem(const UndoItem &another);
00313               UndoItem(const QString &targetName,
00314                  const QString &actionName,
00315                  const QString &actionDescription,
00316                  QPixmap *targetPixmap,
00317                  QPixmap *actionPixmap,
00318                        bool isUndoAction);
00319               ~UndoItem();
00320               void paint(QPainter *painter);
00321               int height(const QListBox*) const;
00322               int width(const QListBox*) const;
00323               QString getDescription();
00324               bool isUndoAction();
00325               void setUndoAction(bool isUndo);
00326        };
00327        
00328 /******************************************************************************/
00329 
00330 private slots:
00331        void undoClicked();
00332        void redoClicked();
00333        void undoListClicked(int i);
00334        void showToolTip(QListBoxItem *i);
00335        void removeToolTip();
00336        void objectCheckBoxClicked(bool on);
00337 
00338 public:
00345        UndoPalette(QWidget* parent = 0, const char* name = 0);
00346 
00348        ~UndoPalette();
00349 
00351        void clear();
00355        virtual void updateUndoActions();
00356        
00357 public slots:
00359        void languageChange();
00360        
00370        void insertUndoItem(UndoObject* target, UndoState* state);
00371 
00377        void insertRedoItem(UndoObject* target, UndoState* state);
00378 
00387        void updateUndo(int steps);
00388 
00397        void updateRedo(int steps);
00398 
00400        void clearRedo();
00401        
00403        void popBack();
00404 
00406        void updateFromPrefs();
00407 
00408 signals:
00409 
00415        void objectMode(bool isEnabled);
00422        void undo(int steps);
00423 
00430        void redo(int steps);
00431 
00432 };
00433 
00434 #endif // UNDOGUI_H