00001 /*************************************************************************** 00002 * Copyright (c) 2008 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 #include "PreCompiled.h" 00025 #ifndef _PreComp_ 00026 #endif 00027 00028 #include <Gui/Application.h> 00029 #include <Gui/Command.h> 00030 #include <Gui/MainWindow.h> 00031 #include <Gui/FileDialog.h> 00032 00033 #include "BrowserView.h" 00034 00035 using namespace std; 00036 using namespace Gui; 00037 using namespace WebGui; 00038 00039 00040 //=========================================================================== 00041 // CmdWebOpenWebsite 00042 //=========================================================================== 00043 00044 DEF_STD_CMD(CmdWebOpenWebsite); 00045 00046 CmdWebOpenWebsite::CmdWebOpenWebsite() 00047 : Command("Web_OpenWebsite") 00048 { 00049 sAppModule = "Web"; 00050 sGroup = QT_TR_NOOP("Web"); 00051 sMenuText = QT_TR_NOOP("Open website..."); 00052 sToolTipText = QT_TR_NOOP("Opens a website in FreeCAD"); 00053 sWhatsThis = sToolTipText; 00054 sStatusTip = sToolTipText; 00055 sPixmap = "actions/web-browser"; 00056 } 00057 00058 00059 void CmdWebOpenWebsite::activated(int iMsg) 00060 { 00061 doCommand(Doc,"import WebGui"); 00062 doCommand(Command::Gui,"WebGui.openBrowser('http://free-cad.sf.net/')"); 00063 } 00064 00065 //=========================================================================== 00066 // CmdWebBrowserBack 00067 //=========================================================================== 00068 00069 DEF_STD_CMD_A(CmdWebBrowserBack); 00070 00071 CmdWebBrowserBack::CmdWebBrowserBack() 00072 : Command("Web_BrowserBack") 00073 { 00074 sAppModule = "Web"; 00075 sGroup = QT_TR_NOOP("Web"); 00076 sMenuText = QT_TR_NOOP("Previous page"); 00077 sToolTipText = QT_TR_NOOP("Go back to the previous page"); 00078 sWhatsThis = sToolTipText; 00079 sStatusTip = sToolTipText; 00080 sPixmap = "actions/web-previous"; 00081 } 00082 00083 void CmdWebBrowserBack::activated(int iMsg) 00084 { 00085 doCommand(Command::Gui,"Gui.SendMsgToActiveView('Back')"); 00086 } 00087 00088 bool CmdWebBrowserBack::isActive(void) 00089 { 00090 return getGuiApplication()->sendHasMsgToActiveView("Back"); 00091 } 00092 00093 //=========================================================================== 00094 // CmdWebBrowserNext 00095 //=========================================================================== 00096 00097 DEF_STD_CMD_A(CmdWebBrowserNext); 00098 00099 CmdWebBrowserNext::CmdWebBrowserNext() 00100 : Command("Web_BrowserNext") 00101 { 00102 sAppModule = "Web"; 00103 sGroup = QT_TR_NOOP("Web"); 00104 sMenuText = QT_TR_NOOP("Next page"); 00105 sToolTipText = QT_TR_NOOP("Go to the next page"); 00106 sWhatsThis = sToolTipText; 00107 sStatusTip = sToolTipText; 00108 sPixmap = "actions/web-next"; 00109 } 00110 00111 void CmdWebBrowserNext::activated(int iMsg) 00112 { 00113 doCommand(Command::Gui,"Gui.SendMsgToActiveView('Next')"); 00114 } 00115 00116 bool CmdWebBrowserNext::isActive(void) 00117 { 00118 return getGuiApplication()->sendHasMsgToActiveView("Next"); 00119 } 00120 00121 //=========================================================================== 00122 // CmdWebBrowserRefresh 00123 //=========================================================================== 00124 00125 DEF_STD_CMD_A(CmdWebBrowserRefresh); 00126 00127 CmdWebBrowserRefresh::CmdWebBrowserRefresh() 00128 : Command("Web_BrowserRefresh") 00129 { 00130 sAppModule = "Web"; 00131 sGroup = QT_TR_NOOP("Web"); 00132 sMenuText = QT_TR_NOOP("Refresh web page"); 00133 sToolTipText = QT_TR_NOOP("Refresh web page"); 00134 sWhatsThis = sToolTipText; 00135 sStatusTip = sToolTipText; 00136 sPixmap = "actions/web-refresh"; 00137 } 00138 00139 void CmdWebBrowserRefresh::activated(int iMsg) 00140 { 00141 doCommand(Command::Gui,"Gui.SendMsgToActiveView('Refresh')"); 00142 } 00143 00144 bool CmdWebBrowserRefresh::isActive(void) 00145 { 00146 return getGuiApplication()->sendHasMsgToActiveView("Refresh"); 00147 } 00148 //=========================================================================== 00149 // CmdWebBrowserStop 00150 //=========================================================================== 00151 00152 DEF_STD_CMD_A(CmdWebBrowserStop); 00153 00154 CmdWebBrowserStop::CmdWebBrowserStop() 00155 :Command("Web_BrowserStop") 00156 { 00157 sAppModule = "Web"; 00158 sGroup = QT_TR_NOOP("Web"); 00159 sMenuText = QT_TR_NOOP("Stop loading"); 00160 sToolTipText = QT_TR_NOOP("Stop the actuall loading"); 00161 sWhatsThis = sToolTipText; 00162 sStatusTip = sToolTipText; 00163 sPixmap = "actions/web-stop"; 00164 } 00165 00166 00167 void CmdWebBrowserStop::activated(int iMsg) 00168 { 00169 doCommand(Command::Gui,"Gui.SendMsgToActiveView('Stop')"); 00170 } 00171 00172 bool CmdWebBrowserStop::isActive(void) 00173 { 00174 return getGuiApplication()->sendHasMsgToActiveView("Stop"); 00175 } 00176 00177 //=========================================================================== 00178 // CmdWebBrowserZoomIn 00179 //=========================================================================== 00180 00181 DEF_STD_CMD_A(CmdWebBrowserZoomIn); 00182 00183 CmdWebBrowserZoomIn::CmdWebBrowserZoomIn() 00184 : Command("Web_BrowserZoomIn") 00185 { 00186 sAppModule = "Web"; 00187 sGroup = QT_TR_NOOP("Web"); 00188 sMenuText = QT_TR_NOOP("Zoom in"); 00189 sToolTipText = QT_TR_NOOP("Zoom into the page"); 00190 sWhatsThis = sToolTipText; 00191 sStatusTip = sToolTipText; 00192 sPixmap = "actions/web-zoom-in"; 00193 } 00194 00195 void CmdWebBrowserZoomIn::activated(int iMsg) 00196 { 00197 doCommand(Command::Gui,"Gui.SendMsgToActiveView('ZoomIn')"); 00198 } 00199 00200 bool CmdWebBrowserZoomIn::isActive(void) 00201 { 00202 return getGuiApplication()->sendHasMsgToActiveView("ZoomIn"); 00203 } 00204 00205 //=========================================================================== 00206 // CmdWebBrowserZoomOut 00207 //=========================================================================== 00208 00209 DEF_STD_CMD_A(CmdWebBrowserZoomOut); 00210 00211 CmdWebBrowserZoomOut::CmdWebBrowserZoomOut() 00212 : Command("Web_BrowserZoomOut") 00213 { 00214 sAppModule = "Web"; 00215 sGroup = QT_TR_NOOP("Web"); 00216 sMenuText = QT_TR_NOOP("Zoom out"); 00217 sToolTipText = QT_TR_NOOP("Zoom out of the page"); 00218 sWhatsThis = sToolTipText; 00219 sStatusTip = sToolTipText; 00220 sPixmap = "actions/web-zoom-out"; 00221 } 00222 00223 void CmdWebBrowserZoomOut::activated(int iMsg) 00224 { 00225 doCommand(Command::Gui,"Gui.SendMsgToActiveView('ZoomOut')"); 00226 } 00227 00228 bool CmdWebBrowserZoomOut::isActive(void) 00229 { 00230 return getGuiApplication()->sendHasMsgToActiveView("ZoomOut"); 00231 } 00232 00233 00234 void CreateWebCommands(void) 00235 { 00236 Gui::CommandManager &rcCmdMgr = Gui::Application::Instance->commandManager(); 00237 00238 rcCmdMgr.addCommand(new CmdWebOpenWebsite()); 00239 rcCmdMgr.addCommand(new CmdWebBrowserBack()); 00240 rcCmdMgr.addCommand(new CmdWebBrowserNext()); 00241 rcCmdMgr.addCommand(new CmdWebBrowserRefresh()); 00242 rcCmdMgr.addCommand(new CmdWebBrowserStop()); 00243 rcCmdMgr.addCommand(new CmdWebBrowserZoomIn()); 00244 rcCmdMgr.addCommand(new CmdWebBrowserZoomOut()); 00245 }