Action.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (c) 2004 Werner Mayer <wmayer[at]users.sourceforge.net>     *
00003  *                                                                         *
00004  *   This file is part of the FreeCAD CAx development system.              *
00005  *                                                                         *
00006  *   This library is free software; you can redistribute it and/or         *
00007  *   modify it under the terms of the GNU Library General Public           *
00008  *   License as published by the Free Software Foundation; either          *
00009  *   version 2 of the License, or (at your option) any later version.      *
00010  *                                                                         *
00011  *   This library  is distributed in the hope that it will be useful,      *
00012  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00013  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00014  *   GNU Library General Public License for more details.                  *
00015  *                                                                         *
00016  *   You should have received a copy of the GNU Library General Public     *
00017  *   License along with this library; see the file COPYING.LIB. If not,    *
00018  *   write to the Free Software Foundation, Inc., 59 Temple Place,         *
00019  *   Suite 330, Boston, MA  02111-1307, USA                                *
00020  *                                                                         *
00021  ***************************************************************************/
00022 
00023 
00024 #ifndef GUI_ACTION_H
00025 #define GUI_ACTION_H
00026 
00027 #include <QAction>
00028 #include <QComboBox>
00029 #include <QKeySequence>
00030 
00031 namespace Gui 
00032 {
00033 class Command;
00034 
00042 class GuiExport Action : public QObject
00043 {
00044     Q_OBJECT
00045 
00046 public:
00047     Action (Command* pcCmd, QObject * parent = 0);
00048     virtual ~Action();
00049 
00050     virtual void addTo (QWidget * w);
00051     virtual void setEnabled(bool);
00052     virtual void setVisible(bool);
00053 
00054     void setCheckable(bool);
00055     void setChecked (bool);
00056     bool isChecked() const;
00057 
00058     void setShortcut (const QString &);
00059     QKeySequence shortcut() const;
00060     void setIcon (const QIcon &);
00061     void setStatusTip (const QString &);
00062     QString statusTip() const;
00063     void setText (const QString &);
00064     QString text() const;
00065     void setToolTip (const QString &);
00066     QString toolTip() const;
00067     void setWhatsThis (const QString &);
00068     QString whatsThis() const;
00069 
00070 public Q_SLOTS:
00071     virtual void onActivated ();
00072     virtual void onToggled   (bool); 
00073 
00074 protected:
00075     QAction* _action;
00076     Command *_pcCmd;
00077 };
00078 
00079 // --------------------------------------------------------------------
00080 
00088 class GuiExport ActionGroup : public Action
00089 {
00090     Q_OBJECT
00091 
00092 public:
00093     ActionGroup (Command* pcCmd, QObject * parent = 0);
00094     virtual ~ActionGroup();
00095 
00096     void addTo (QWidget * w);
00097     void setEnabled (bool);
00098     void setDisabled (bool);
00099     void setExclusive (bool);
00100     void setVisible (bool);
00101 
00102     void setDropDownMenu(bool b) { _dropDown = b; }
00103     QAction* addAction(const QString&);
00104     QList<QAction*> actions() const;
00105     int checkedAction() const;
00106     void setCheckedAction(int);
00107 
00108 public Q_SLOTS:
00109     void onActivated ();
00110     void onActivated (QAction*);
00111 
00112 protected:
00113     QActionGroup* _group;
00114     bool _dropDown;
00115 };
00116 
00117 // --------------------------------------------------------------------
00118 
00119 class WorkbenchGroup;
00120 class GuiExport WorkbenchComboBox : public QComboBox
00121 {
00122     Q_OBJECT
00123 
00124 public:
00125     WorkbenchComboBox(WorkbenchGroup* wb, QWidget* parent=0);
00126     virtual ~WorkbenchComboBox();
00127 
00128 public Q_SLOTS:
00129     void onActivated(int);
00130     void onActivated(QAction*);
00131 
00132 protected Q_SLOTS:
00133     void onWorkbenchActivated(const QString&);
00134 
00135 protected:
00136     void actionEvent (QActionEvent*);
00137 
00138 private:
00139     WorkbenchGroup* group;
00140 };
00141 
00147 class GuiExport WorkbenchGroup : public ActionGroup
00148 {
00149     Q_OBJECT
00150 
00151 public:
00156     WorkbenchGroup (Command* pcCmd, QObject * parent);
00157     virtual ~WorkbenchGroup();
00158     void addTo (QWidget * w);
00159     void refreshWorkbenchList();
00160 
00161     void slotActivateWorkbench(const char*);
00162     void slotAddWorkbench(const char*);
00163     void slotRemoveWorkbench(const char*);
00164 
00165 protected:
00166     void customEvent(QEvent* e);
00167 };
00168 
00169 // --------------------------------------------------------------------
00170 
00175 class GuiExport RecentFilesAction : public ActionGroup
00176 {
00177     Q_OBJECT
00178 
00179 public:
00180     RecentFilesAction (Command* pcCmd, QObject * parent = 0);
00181     virtual ~RecentFilesAction();
00182 
00183     void appendFile(const QString&);
00184     void activateFile(int);
00185     void resizeList(int);
00186 
00187 private:
00188     void setFiles(const QStringList&);
00189     QStringList files() const;
00190     void restore();
00191     void save();
00192 
00193 private:
00194     int visibleItems; 
00195     int maximumItems; 
00196 };
00197 
00198 // --------------------------------------------------------------------
00199 
00205 class GuiExport UndoAction : public Action
00206 {
00207     Q_OBJECT
00208 
00209 public:
00210     UndoAction (Command* pcCmd,QObject * parent = 0);
00211     ~UndoAction();
00212     void addTo (QWidget * w);
00213     void setEnabled(bool);
00214     void setVisible(bool);
00215 
00216 private:
00217     QAction* _toolAction;
00218 };
00219 
00220 // --------------------------------------------------------------------
00221 
00227 class GuiExport RedoAction : public Action
00228 {
00229     Q_OBJECT
00230 
00231 public:
00232     RedoAction (Command* pcCmd,QObject * parent = 0);
00233     ~RedoAction();
00234     void addTo ( QWidget * w );
00235     void setEnabled(bool);
00236     void setVisible(bool);
00237 
00238 private:
00239     QAction* _toolAction;
00240 };
00241 
00242 // --------------------------------------------------------------------
00243 
00248 class GuiExport DockWidgetAction : public Action
00249 {
00250     Q_OBJECT
00251 
00252 public:
00253     DockWidgetAction (Command* pcCmd, QObject * parent = 0);
00254     virtual ~DockWidgetAction();
00255     void addTo (QWidget * w);
00256 
00257 private:
00258     QMenu* _menu;
00259 };
00260 
00261 // --------------------------------------------------------------------
00262 
00267 class GuiExport ToolBarAction : public Action
00268 {
00269     Q_OBJECT
00270 
00271 public:
00272     ToolBarAction (Command* pcCmd, QObject * parent = 0);
00273     virtual ~ToolBarAction();
00274     void addTo (QWidget * w);
00275 
00276 private:
00277     QMenu* _menu;
00278 };
00279 
00280 // --------------------------------------------------------------------
00281 
00285 class GuiExport WindowAction : public ActionGroup
00286 {
00287     Q_OBJECT
00288 
00289 public:
00290     WindowAction (Command* pcCmd, QObject * parent = 0);
00291     virtual ~WindowAction();
00292     void addTo (QWidget * w);
00293 
00294 private:
00295     QMenu* _menu;
00296 };
00297 
00298 } // namespace Gui
00299 
00300 #endif // GUI_ACTION_H

Generated on Wed Nov 23 18:59:54 2011 for FreeCAD by  doxygen 1.6.1