Gui/Application.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (c) 2004 Jürgen Riegel <juergen.riegel@web.de>              *
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 APPLICATION_H
00025 #define APPLICATION_H
00026 
00027 #include <QPixmap>
00028 #include <string>
00029 #include <vector>
00030 
00031 #define  putpix()
00032 
00033 #include <App/Application.h>
00034 
00035 class QCloseEvent;
00036 
00037 namespace Gui{
00038 class BaseView;
00039 class CommandManager;
00040 class Document;
00041 class MacroManager;
00042 class MDIView;
00043 class MainWindow;
00044 class MenuItem;
00045 class ViewProvider;
00046 
00051 class GuiExport Application 
00052 {
00053 public:
00055     Application(bool GUIenabled);
00057     ~Application();
00058 
00061 
00062     void open(const char* FileName, const char* Module);
00064     void importFrom(const char* FileName, const char* DocName, const char* Module);
00066     void exportTo(const char* FileName, const char* DocName, const char* Module);
00068 
00069 
00072 
00073     bool sendMsgToActiveView(const char* pMsg, const char** ppReturn=0);
00075     bool sendHasMsgToActiveView(const char* pMsg);
00077     void attachView(Gui::BaseView* pcView);
00079     void detachView(Gui::BaseView* pcView);
00081     void viewActivated(Gui::MDIView* pcView);
00083     void onUpdate(void);
00085     void updateActive(void);
00087 
00090 
00091     boost::signal<void (const Gui::Document&)> signalNewDocument;
00093     boost::signal<void (const Gui::Document&)> signalDeleteDocument;
00095     boost::signal<void (const Gui::Document&)> signalRelabelDocument;
00097     boost::signal<void (const Gui::Document&)> signalRenameDocument;
00099     boost::signal<void (const Gui::Document&)> signalActiveDocument;
00101     boost::signal<void (const Gui::ViewProvider&)> signalNewObject;
00103     boost::signal<void (const Gui::ViewProvider&)> signalDeletedObject;
00105     boost::signal<void (const Gui::ViewProvider&, const App::Property&)> signalChangedObject;
00107     boost::signal<void (const Gui::ViewProvider&)> signalRenamedObject;
00109     boost::signal<void (const Gui::ViewProvider&)> signalActivatedObject;
00111     boost::signal<void (const char*)> signalActivateWorkbench;
00113     boost::signal<void (const char*)> signalAddWorkbench;
00115     boost::signal<void (const char*)> signalRemoveWorkbench;
00117     boost::signal<void (const Gui::MDIView*)> signalActivateView;
00119 
00122 protected:
00124     void slotNewDocument(const App::Document&);
00125     void slotDeleteDocument(const App::Document&);
00126     void slotRelabelDocument(const App::Document&);
00127     void slotRenameDocument(const App::Document&);
00128     void slotActiveDocument(const App::Document&);
00129     void slotNewObject(const ViewProvider&);
00130     void slotDeletedObject(const ViewProvider&);
00131     void slotChangedObject(const ViewProvider&, const App::Property& Prop);
00132     void slotRenamedObject(const ViewProvider&);
00133     void slotActivatedObject(const ViewProvider&);
00134 
00135 public:
00137     void onLastWindowClosed(Gui::Document* pcDoc);
00139     Gui::Document* activeDocument(void) const;
00141     void setActiveDocument(Gui::Document* pcDocument);
00145     Gui::Document* getDocument(const char* name) const;
00149     Gui::Document* getDocument(const App::Document* pDoc) const;
00151     void showViewProvider(App::DocumentObject*);
00153     void hideViewProvider(App::DocumentObject*);
00155     Gui::ViewProvider* getViewProvider(App::DocumentObject*) const;
00157 
00159     bool isClosing(void);
00160 
00163 
00164     bool activateWorkbench(const char* name);
00165     QPixmap workbenchIcon(const QString&) const;
00166     QString workbenchToolTip(const QString&) const;
00167     QString workbenchMenuText(const QString&) const;
00168     QStringList workbenches(void) const;
00169     void setupContextMenu(const char* recipient, MenuItem*) const;
00171 
00174 
00175     Gui::MacroManager *macroManager(void);
00177     Gui::CommandManager &commandManager(void);
00179     void runCommand(bool bForce, const char* sCmd,...);
00180     bool runPythonCode(const char* cmd, bool gui=false, bool pyexc=true);
00182     void createStandardOperations();
00184 
00187 
00188     static Application* Instance;
00189     static void initApplication(void);
00190     static void initTypes(void);
00191     static void runApplication(void);
00192     void tryClose( QCloseEvent * e );
00194 
00195 public:
00196     //---------------------------------------------------------------------
00197     // python exports goes here +++++++++++++++++++++++++++++++++++++++++++     
00198     //---------------------------------------------------------------------
00199     // static python wrapper of the exported functions
00200     PYFUNCDEF_S(sActivateWorkbenchHandler); // activates a workbench object
00201     PYFUNCDEF_S(sAddWorkbenchHandler);      // adds a new workbench handler to a list
00202     PYFUNCDEF_S(sRemoveWorkbenchHandler);   // removes a workbench handler from the list
00203     PYFUNCDEF_S(sGetWorkbenchHandler);      // retrieves the workbench handler
00204     PYFUNCDEF_S(sListWorkbenchHandlers);    // retrieves a list of all workbench handlers
00205     PYFUNCDEF_S(sActiveWorkbenchHandler);   // retrieves the active workbench object
00206     PYFUNCDEF_S(sAddResPath);               // adds a path where to find resources
00207     PYFUNCDEF_S(sAddLangPath);              // adds a path to a qm file
00208     PYFUNCDEF_S(sAddIconPath);              // adds a path to an icon file
00209     PYFUNCDEF_S(sAddIcon);                  // adds an icon to the cache
00210 
00211     PYFUNCDEF_S(sSendActiveView);
00212 
00213     PYFUNCDEF_S(sUpdateGui);
00214     PYFUNCDEF_S(sUpdateLocale);
00215     PYFUNCDEF_S(sGetLocale);
00216     PYFUNCDEF_S(sCreateDialog);
00217     PYFUNCDEF_S(sAddPreferencePage);
00218 
00219     PYFUNCDEF_S(sRunCommand);
00220     PYFUNCDEF_S(sAddCommand);
00221 
00222     PYFUNCDEF_S(sHide);                     // deprecated
00223     PYFUNCDEF_S(sShow);                     // deprecated
00224     PYFUNCDEF_S(sHideObject);               // hide view provider object
00225     PYFUNCDEF_S(sShowObject);               // show view provider object
00226 
00227     PYFUNCDEF_S(sOpen);                     // open Python scripts
00228     PYFUNCDEF_S(sInsert);                   // open Python scripts
00229     PYFUNCDEF_S(sExport);
00230 
00231     PYFUNCDEF_S(sActiveDocument);
00232     PYFUNCDEF_S(sGetDocument);
00233 
00234     static PyMethodDef    Methods[]; 
00235 
00236 private:
00237     struct ApplicationP* d;
00239     PyObject*             _pcWorkbenchDictionary;
00240 };
00241 
00242 } //namespace Gui
00243 
00244 #endif

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