MainWindow.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (c) 2005 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_MAINWINDOW_H
00025 #define GUI_MAINWINDOW_H
00026 
00027 //#define NO_USE_QT_MDI_AREA
00028 
00029 #include "Window.h"
00030 #include <Base/Console.h>
00031 #include <string>
00032 #include <vector>
00033 
00034 #include <QMainWindow>
00035 #ifndef NO_USE_QT_MDI_AREA
00036 #include <QMdiArea>
00037 #else
00038 #include <QWorkspace>
00039 #endif
00040 
00041 class QMimeData;
00042 class QUrl;
00043 #if !defined (NO_USE_QT_MDI_AREA)
00044 class QMdiSubWindow;
00045 #endif
00046 
00047 namespace App {
00048 class Document;
00049 }
00050 
00051 namespace Gui {
00052 
00053 class BaseView;
00054 class CommandManager;
00055 class Document;
00056 class MacroManager;
00057 class MDIView;
00058 
00059 namespace DockWnd {
00060     class HelpView;
00061 } //namespace DockWnd
00062 
00063 
00069 class GuiExport MainWindow : public QMainWindow
00070 {
00071     Q_OBJECT
00072  
00073 public:
00078     MainWindow(QWidget * parent = 0, Qt::WFlags f = Qt::Window);
00080     ~MainWindow();
00084     bool eventFilter(QObject* o, QEvent* e);
00089     void addWindow(MDIView* view);
00094     void removeWindow(MDIView* view);
00098 #if !defined(NO_USE_QT_MDI_AREA) 
00099     QList<QWidget*> windows(QMdiArea::WindowOrder order = QMdiArea::CreationOrder) const;
00100 #else
00101     QList<QWidget*> windows(QWorkspace::WindowOrder order = QWorkspace::CreationOrder) const;
00102 #endif
00103 
00106     void tabChanged(MDIView* view);
00110     MDIView* activeWindow() const;
00114     void setActiveWindow(MDIView* view);
00118     void appendRecentFile(const QString& filename);
00122     QMenu * createPopupMenu();
00123 
00127     static MainWindow* getInstance();
00129     void startSplasher(void);
00131     void stopSplasher(void);
00132     /* The image of the splash screen of the application. */
00133     QPixmap splashImage() const;
00135     void showTipOfTheDay(bool force=false);
00137     void showDocumentation(const char* Article=0);
00139 
00143 
00144     void loadWindowSettings();
00146     void saveWindowSettings();
00148 
00153     QMimeData * createMimeDataFromSelection () const;
00155     bool canInsertFromMimeData (const QMimeData * source) const;
00159     void insertFromMimeData (const QMimeData * source);
00164     void loadUrls(App::Document*, const QList<QUrl>&);
00166 
00167 public Q_SLOTS:
00171     void setPaneText(int i, QString text);
00175     void arrangeIcons();
00179     void tile();
00183     void cascade();
00187     void closeActiveWindow ();
00193     void closeAllWindows ();
00197     void activateNextWindow ();
00201     void activatePreviousWindow ();
00205     void activateWorkbench(const QString&);
00209     void whatsThis();
00210     void switchToTopLevelMode();
00211     void switchToDockedMode();
00212     void showMessage (const QString & message, int timeout = 0);
00213 
00214 protected:
00218     void closeEvent (QCloseEvent * e);
00219     void showEvent  (QShowEvent  * e);
00220     void hideEvent  (QHideEvent  * e);
00221     void timerEvent (QTimerEvent *  ){ timeEvent();}
00222     void customEvent(QEvent      * e);
00223     bool event      (QEvent      * e);
00227     void dropEvent  (QDropEvent  * e);
00231     void dragEnterEvent(QDragEnterEvent * e);
00237     void changeEvent(QEvent *e);
00238 
00239 private Q_SLOTS:
00240 #if !defined (NO_USE_QT_MDI_AREA)
00241 
00244     void onSetActiveSubWindow(QWidget *window);
00248     void onWindowActivated(QMdiSubWindow*);
00252     void tabCloseRequested(int index);
00253 #else
00254 
00257     void onWindowActivated(QWidget*);
00261     void onTabSelected(int i);
00265     void onWindowDestroyed();
00266 #endif
00267 
00270     void onWindowsMenuAboutToShow();
00274     void onToolBarMenuAboutToShow();
00278     void onDockWindowMenuAboutToShow();
00282     void updateActions();
00286     void showMainWindow();
00290     void delayedStartup();
00291 
00292 Q_SIGNALS:
00293     void timeEvent();
00294     void windowStateChanged(MDIView*);
00295     void workbenchActivated(const QString&);
00296     void mainWindowClosed();
00297 
00298 private:
00300     static MainWindow* instance;
00301     struct MainWindowP* d;
00302 };
00303 
00304 inline MainWindow* getMainWindow()
00305 {
00306     return MainWindow::getInstance();
00307 }
00308 
00309 // -------------------------------------------------------------
00310 
00319 class StatusBarObserver: public WindowParameter, public Base::ConsoleObserver
00320 {
00321 public:
00322     StatusBarObserver();
00323     virtual ~StatusBarObserver();
00324 
00326     void OnChange(Base::Subject<const char*> &rCaller, const char * sReason);
00327 
00329     void Warning(const char *m);
00331     void Message(const char * m);
00333     void Error  (const char *m);
00335     void Log    (const char *);
00337     const char *Name(void){return "StatusBar";}
00338 
00339 private:
00340     QString msg, wrn, err;
00341 };
00342 
00343 } // namespace Gui
00344 
00345 #endif // GUI_MAINWINDOW_H

Generated on Wed Nov 23 19:00:21 2011 for FreeCAD by  doxygen 1.6.1