Permalink
Browse files

PreviewDlg: Use simplified browser includes.

  • Loading branch information...
1 parent a8db989 commit e7ed600e792b85a3b4bd2b9cda5ac9a6308888b2 @adamv adamv committed with adamv Oct 23, 2009
Showing with 33 additions and 62 deletions.
  1. +24 −36 src/PreviewDlg.cpp
  2. +9 −26 src/PreviewDlg.h
View
@@ -27,12 +27,8 @@
#include "webconnect/webcontrol.h"
#include "IAppPaths.h"
-#if defined (__WXMSW__)
- #include "IEHtmlWin.h"
-#elif defined (__WXGTK__)
- #include "IHtmlWnd.h"
- #include "WebKitHtmlWnd.h"
-#endif
+#include "eBrowser.h"
+
#include "images/left_arrow.xpm"
#include "images/left_arrow_gray.xpm"
@@ -47,6 +43,8 @@
#include "images/pin2.xpm"
#include "images/pin2_over.xpm"
+using namespace std;
+
class Preview_CommandThread : public wxThread {
public:
Preview_CommandThread(const wxString& command, vector<char>& input, const wxString& outputPath, const wxString& truePath, wxEvtHandler& parent, const cxEnv& env);
@@ -65,7 +63,7 @@ class Preview_CommandThread : public wxThread {
// control id's
enum
{
- ID_MSHTML,
+ ID_BROWSER,
ID_RELOAD,
ID_BACK,
ID_FORWARD,
@@ -91,20 +89,19 @@ BEGIN_EVENT_TABLE(PreviewDlg, wxPanel)
EVT_TEXT_ENTER(ID_PIPECMD, PreviewDlg::OnPipeCmdEnter)
EVT_CHOICE(ID_WEBCHOICE, PreviewDlg::OnWebChoice)
#ifdef __WXMSW__
- EVT_ACTIVEX(ID_MSHTML, "TitleChange", PreviewDlg::OnMSHTMLTitleChange)
-// EVT_ACTIVEX(ID_MSHTML, "BeforeNavigate2", PreviewDlg::OnMSHTMLBeforeNavigate2X)
- EVT_ACTIVEX(ID_MSHTML, "CommandStateChange", PreviewDlg::OnMSHTMLStateChanged)
- EVT_ACTIVEX(ID_MSHTML, "DocumentComplete", PreviewDlg::OnMSHTMLDocumentComplete)
+ EVT_ACTIVEX(ID_BROWSER, "TitleChange", PreviewDlg::OnMSHTMLTitleChange)
+ EVT_ACTIVEX(ID_BROWSER, "CommandStateChange", PreviewDlg::OnMSHTMLStateChanged)
+ EVT_ACTIVEX(ID_BROWSER, "DocumentComplete", PreviewDlg::OnMSHTMLDocumentComplete)
#endif
EVT_WEB_TITLECHANGE(ID_WEBCONNECT, PreviewDlg::OnWebTitleChange)
EVT_WEB_DOMCONTENTLOADED(ID_WEBCONNECT, PreviewDlg::OnWebDocumentComplete)
END_EVENT_TABLE()
-PreviewDlg::PreviewDlg(EditorFrame& parent)
-: wxPanel (&parent),
- m_parent(parent), m_editorCtrl(NULL), m_thread(NULL), m_isOnPreview(true), m_isFirst(false),
- m_pinnedEditor(NULL), m_re_style(NULL), m_re_href(NULL), m_webcontrol(NULL) {
-
+PreviewDlg::PreviewDlg(EditorFrame& parent):
+ wxPanel (&parent),
+ m_parent(parent), m_editorCtrl(NULL), m_thread(NULL), m_isOnPreview(true), m_isFirst(false),
+ m_pinnedEditor(NULL), m_re_style(NULL), m_re_href(NULL), m_webcontrol(NULL)
+{
// Adressbar ctrl
m_backButton = new wxBitmapButton(this, ID_BACK, wxBitmap(left_arrow_xpm), wxDefaultPosition, wxDefaultSize, 0);
m_backButton->SetBitmapDisabled(wxBitmap(left_arrow_gray_xpm));
@@ -124,13 +121,7 @@ PreviewDlg::PreviewDlg(EditorFrame& parent)
m_browser = NULL; // know to skip events sent during construction
-#if defined (__WXMSW__)
- // IE Control
- m_browser = new wxIEHtmlWin(this, ID_MSHTML);
-#elif defined (__WXGTK__)
- // WebKit control
- m_browser = new wxBrowser(this, ID_MSHTML);
-#endif
+ m_browser = NewBrowser(this, ID_BROWSER);
// Do we have XULRunner installed?
bool xulrunner = false;
@@ -147,6 +138,7 @@ PreviewDlg::PreviewDlg(EditorFrame& parent)
wxButton* reloadButton = new wxButton(this, ID_RELOAD, _("Reload now"));
if (xulrunner) {
m_webChoice = new wxChoice(this, ID_WEBCHOICE);
+
#ifdef __WXMSW__
m_webChoice->Append(_("IE"));
#else
@@ -303,14 +295,13 @@ void PreviewDlg::RefreshBrowser(cxUpdateMode mode) {
}
else {
#ifdef __WXMSW__
- wxIEHtmlWin* ie = dynamic_cast<wxIEHtmlWin*>(m_browser);
- ie->UIDeactivate(); // otherwise ie may steal focus
+ m_browser->UIDeactivate(); // otherwise ie may steal focus
#endif
- if (mode == cxUPDATE_RELOAD || m_isFirst) {
+ if (mode == cxUPDATE_RELOAD || m_isFirst)
m_browser->LoadUrl(m_tempPath);
- }
- else m_browser->Refresh(wxHTML_REFRESH_NORMAL);
+ else
+ m_browser->Refresh(wxHTML_REFRESH_NORMAL);
}
m_isFirst = false;
@@ -341,8 +332,8 @@ void PreviewDlg::OnIdle(wxIdleEvent& WXUNUSED(event)) {
if (m_pinnedEditor) {
if (((m_pinnedEditor == m_editorCtrl || m_editorCtrl->GetName().EndsWith(wxT(".css")))
&& m_editorCtrl->GetChangeToken() != m_editorChangeToken)
- || m_editorCtrl->IsSavedForPreview() ) {
-
+ || m_editorCtrl->IsSavedForPreview() )
+ {
UpdateBrowser(cxUPDATE_REFRESH);
}
}
@@ -550,8 +541,7 @@ void PreviewDlg::SetBrowser(int sel) {
m_mainSizer->Hide(m_browser->GetWindow());
m_mainSizer->Show(m_webcontrol);
- // WebConnect does not yet offer a way to detect
- // whick nav buttons should be enabled
+ // WebConnect does not yet offer a way to detect which nav buttons should be enabled
m_backButton->Enable(true);
m_forwardButton->Enable(true);
}
@@ -602,10 +592,8 @@ void PreviewDlg::OnTitleChange(const wxString& title) {
// This is a bit of a hack, but the easiest way to see if
// it does not have a title and returns path is to compare
// filenames (very litle chance for match with other)
- if (tempFile != titleEnd)
- m_parent.SetWebPreviewTitle(wxT("Preview: ") + title);
- else
- m_parent.SetWebPreviewTitle(wxT("Preview: ") + m_truePath);
+ m_parent.SetWebPreviewTitle(wxT("Preview: ") +
+ (tempFile != titleEnd) ? title : m_truePath);
}
void PreviewDlg::OnDocumentComplete(const wxString& location) {
View
@@ -16,41 +16,29 @@
#include "wx/wxprec.h"
#ifndef WX_PRECOMP
- #include <wx/wx.h>
+#include <wx/wx.h>
#endif
-// STL can't compile with Level 4
-#ifdef __WXMSW__
- #pragma warning(disable:4786)
- #pragma warning(push, 1)
-#endif
#include <vector>
-#ifdef __WXMSW__
- #pragma warning(pop)
-#endif
-using namespace std;
-
-using namespace std;
+#include "eBrowserDef.h"
-// pre-declarations
struct real_pcre; // This double pre-definition is needed
typedef struct real_pcre pcre; // because of the way it is defined in pcre.h
+
class EditorFrame;
class EditorCtrl;
class eFrameSettings;
class wxProcessEvent;
+class Preview_CommandThread;
+
class wxWebControl;
class wxWebEvent;
#if defined (__WXMSW__)
- class wxIEHtmlWin;
- class wxActiveXEvent;
-#elif defined (__WXGTK__)
- class IHtmlWnd;
+class wxActiveXEvent;
#endif
-class Preview_CommandThread;
class PreviewDlg : public wxPanel {
public:
@@ -62,8 +50,8 @@ class PreviewDlg : public wxPanel {
void PageClosed(const EditorCtrl* ec);
// Utility functions
- bool InsertStyle(vector<char>& html);
- static void InsertBase(vector<char>& html, const wxString& path);
+ bool InsertStyle(std::vector<char>& html);
+ static void InsertBase(std::vector<char>& html, const wxString& path);
private:
enum cxUpdateMode {
@@ -119,11 +107,7 @@ class PreviewDlg : public wxPanel {
pcre* m_re_href;
// Member Ctrls
-#ifdef __WXMSW__
- wxIEHtmlWin* m_browser;
-#else
- IHtmlWnd* m_browser;
-#endif
+ eBrowser* m_browser;
wxWebControl* m_webcontrol;
wxCheckBox* m_pipeCheck;
@@ -137,7 +121,6 @@ class PreviewDlg : public wxPanel {
wxBoxSizer* m_mainSizer;
wxBoxSizer* m_optionSizer;
-
};
#endif // __PREVIEWDLG_H__

0 comments on commit e7ed600

Please sign in to comment.