From 3aff27fdb550b4079c822272c2cc66d3d7ea8dc8 Mon Sep 17 00:00:00 2001 From: "locka%iol.ie" Date: Thu, 26 Jun 2003 21:31:10 +0000 Subject: [PATCH] NOT PART OF BUILD. Add prototypes of editor & chat windows. Create GeckoFrame subclass that does the common functionality for all frames. Cleanup mail window. git-svn-id: svn://10.0.0.236/trunk@144200 18797224-902f-48f8-a5cc-f745e15eee43 --- .../embedding/tests/wxEmbed/BrowserFrame.cpp | 67 +++---- .../embedding/tests/wxEmbed/BrowserFrame.h | 9 +- mozilla/embedding/tests/wxEmbed/ChatFrame.cpp | 44 ++++- mozilla/embedding/tests/wxEmbed/ChatFrame.h | 9 +- .../embedding/tests/wxEmbed/EditorFrame.cpp | 68 +++++++ mozilla/embedding/tests/wxEmbed/EditorFrame.h | 46 +++++ mozilla/embedding/tests/wxEmbed/EmbedApp.cpp | 36 +++- .../embedding/tests/wxEmbed/GeckoFrame.cpp | 74 ++++++++ mozilla/embedding/tests/wxEmbed/GeckoFrame.h | 59 ++++++ mozilla/embedding/tests/wxEmbed/MailFrame.cpp | 170 ++++++++++-------- mozilla/embedding/tests/wxEmbed/MailFrame.h | 8 +- mozilla/embedding/tests/wxEmbed/makefile.vc | 4 + .../embedding/tests/wxEmbed/rc/browser.xrc | 3 + mozilla/embedding/tests/wxEmbed/rc/chat.xrc | 2 +- mozilla/embedding/tests/wxEmbed/rc/editor.xrc | 70 ++++++++ mozilla/embedding/tests/wxEmbed/wxEmbed.dsp | 32 ++++ 16 files changed, 543 insertions(+), 158 deletions(-) create mode 100644 mozilla/embedding/tests/wxEmbed/EditorFrame.cpp create mode 100644 mozilla/embedding/tests/wxEmbed/EditorFrame.h create mode 100644 mozilla/embedding/tests/wxEmbed/GeckoFrame.cpp create mode 100644 mozilla/embedding/tests/wxEmbed/GeckoFrame.h create mode 100644 mozilla/embedding/tests/wxEmbed/rc/editor.xrc diff --git a/mozilla/embedding/tests/wxEmbed/BrowserFrame.cpp b/mozilla/embedding/tests/wxEmbed/BrowserFrame.cpp index 0ec4440954b..43ebb5d6928 100644 --- a/mozilla/embedding/tests/wxEmbed/BrowserFrame.cpp +++ b/mozilla/embedding/tests/wxEmbed/BrowserFrame.cpp @@ -35,7 +35,7 @@ #include "nsIURI.h" -BEGIN_EVENT_TABLE(BrowserFrame, wxFrame) +BEGIN_EVENT_TABLE(BrowserFrame, GeckoFrame) EVT_MENU(XRCID("browse_back"), BrowserFrame::OnBrowserBack) EVT_UPDATE_UI(XRCID("browse_back"), BrowserFrame::OnUpdateBrowserBack) EVT_MENU(XRCID("browse_fwd"), BrowserFrame::OnBrowserForward) @@ -48,38 +48,13 @@ BEGIN_EVENT_TABLE(BrowserFrame, wxFrame) EVT_TEXT_ENTER(XRCID("url"), BrowserFrame::OnBrowserUrl) END_EVENT_TABLE() -BrowserFrame::BrowserFrame(wxWindow* aParent) : - mGeckoWnd(NULL) +BrowserFrame::BrowserFrame(wxWindow* aParent) { wxXmlResource::Get()->LoadFrame(this, aParent, wxT("browser_frame")); SetIcon(wxICON(appicon)); - mGeckoWnd = (GeckoWindow *) FindWindowById(XRCID("gecko"), this); - if (mGeckoWnd) - { - // Note we pass in 'browser' as the role so that when the content - // wants to open a popup the window creator can say okay but deny it - // for other roles such as 'mail' or whatever. - GeckoContainer *geckoContainer = new GeckoContainer(this, "browser"); - if (geckoContainer) - { - mGeckoWnd->SetGeckoContainer(geckoContainer); - - PRUint32 aChromeFlags = nsIWebBrowserChrome::CHROME_ALL; - geckoContainer->SetChromeFlags(aChromeFlags); - geckoContainer->SetParent(nsnull); - - wxSize size = mGeckoWnd->GetClientSize(); - - // Insert the browser - geckoContainer->CreateBrowser(0, 0, size.GetWidth(), size.GetHeight(), - (nativeWindow) mGeckoWnd->GetHWND(), getter_AddRefs(mWebbrowser)); - - GeckoContainerUI::ShowWindow(PR_TRUE); - - } - } + SetupDefaultGeckoWindow(); CreateStatusBar(); } @@ -91,13 +66,13 @@ BrowserFrame::BrowserFrame(wxWindow* aParent) : void BrowserFrame::OnBrowserGo(wxCommandEvent & WXUNUSED(event)) { - if (mWebbrowser) + if (mWebBrowser) { wxTextCtrl *txtCtrl = (wxTextCtrl *) FindWindowById(XRCID("url"), this); wxString url = txtCtrl->GetValue(); if (!url.IsEmpty()) { - nsCOMPtr webNav = do_QueryInterface(mWebbrowser); + nsCOMPtr webNav = do_QueryInterface(mWebBrowser); webNav->LoadURI(NS_ConvertASCIItoUCS2(url.c_str()).get(), nsIWebNavigation::LOAD_FLAGS_NONE, nsnull, @@ -114,9 +89,9 @@ void BrowserFrame::OnBrowserUrl(wxCommandEvent & event) void BrowserFrame::OnBrowserBack(wxCommandEvent & WXUNUSED(event)) { - if (mWebbrowser) + if (mWebBrowser) { - nsCOMPtr webNav = do_QueryInterface(mWebbrowser); + nsCOMPtr webNav = do_QueryInterface(mWebBrowser); webNav->GoBack(); } } @@ -124,9 +99,9 @@ void BrowserFrame::OnBrowserBack(wxCommandEvent & WXUNUSED(event)) void BrowserFrame::OnUpdateBrowserBack(wxUpdateUIEvent &event) { PRBool canGoBack = PR_FALSE; - if (mWebbrowser) + if (mWebBrowser) { - nsCOMPtr webNav = do_QueryInterface(mWebbrowser); + nsCOMPtr webNav = do_QueryInterface(mWebBrowser); webNav->GetCanGoBack(&canGoBack); } event.Enable(canGoBack); @@ -134,9 +109,9 @@ void BrowserFrame::OnUpdateBrowserBack(wxUpdateUIEvent &event) void BrowserFrame::OnBrowserForward(wxCommandEvent & WXUNUSED(event)) { - if (mWebbrowser) + if (mWebBrowser) { - nsCOMPtr webNav = do_QueryInterface(mWebbrowser); + nsCOMPtr webNav = do_QueryInterface(mWebBrowser); webNav->GoForward(); } } @@ -144,9 +119,9 @@ void BrowserFrame::OnBrowserForward(wxCommandEvent & WXUNUSED(event)) void BrowserFrame::OnUpdateBrowserForward(wxUpdateUIEvent &event) { PRBool canGoForward = PR_FALSE; - if (mWebbrowser) + if (mWebBrowser) { - nsCOMPtr webNav = do_QueryInterface(mWebbrowser); + nsCOMPtr webNav = do_QueryInterface(mWebBrowser); webNav->GetCanGoForward(&canGoForward); } event.Enable(canGoForward); @@ -154,18 +129,18 @@ void BrowserFrame::OnUpdateBrowserForward(wxUpdateUIEvent &event) void BrowserFrame::OnBrowserReload(wxCommandEvent & WXUNUSED(event)) { - if (mWebbrowser) + if (mWebBrowser) { - nsCOMPtr webNav = do_QueryInterface(mWebbrowser); + nsCOMPtr webNav = do_QueryInterface(mWebBrowser); webNav->Reload(nsIWebNavigation::LOAD_FLAGS_NONE); } } void BrowserFrame::OnBrowserStop(wxCommandEvent & WXUNUSED(event)) { - if (mWebbrowser) + if (mWebBrowser) { - nsCOMPtr webNav = do_QueryInterface(mWebbrowser); + nsCOMPtr webNav = do_QueryInterface(mWebBrowser); webNav->Stop(nsIWebNavigation::STOP_ALL); } } @@ -177,9 +152,9 @@ void BrowserFrame::OnUpdateBrowserStop(wxUpdateUIEvent &event) void BrowserFrame::OnBrowserHome(wxCommandEvent & WXUNUSED(event)) { - if (mWebbrowser) + if (mWebBrowser) { - nsCOMPtr webNav = do_QueryInterface(mWebbrowser); + nsCOMPtr webNav = do_QueryInterface(mWebBrowser); webNav->LoadURI(NS_ConvertASCIItoUCS2("http://www.mozilla.org/projects/embedding/").get(), nsIWebNavigation::LOAD_FLAGS_NONE, nsnull, @@ -211,9 +186,9 @@ void BrowserFrame::UpdateStatusBarText(const PRUnichar* aStatusText) void BrowserFrame::UpdateCurrentURI() { - if (mWebbrowser) + if (mWebBrowser) { - nsCOMPtr webNav = do_QueryInterface(mWebbrowser); + nsCOMPtr webNav = do_QueryInterface(mWebBrowser); nsCOMPtr currentURI; webNav->GetCurrentURI(getter_AddRefs(currentURI)); nsCAutoString spec; diff --git a/mozilla/embedding/tests/wxEmbed/BrowserFrame.h b/mozilla/embedding/tests/wxEmbed/BrowserFrame.h index e9dd2115acf..99aba74108d 100644 --- a/mozilla/embedding/tests/wxEmbed/BrowserFrame.h +++ b/mozilla/embedding/tests/wxEmbed/BrowserFrame.h @@ -32,12 +32,10 @@ #ifndef BROWSERFRAME_H #define BROWSERFRAME_H -#include "GeckoContainer.h" -#include "GeckoWindow.h" +#include "GeckoFrame.h" class BrowserFrame : - public wxFrame, - public GeckoContainerUI + public GeckoFrame { public : BrowserFrame(wxWindow* aParent); @@ -55,9 +53,6 @@ public : void OnUpdateBrowserForward(wxUpdateUIEvent &event); void OnUpdateBrowserStop(wxUpdateUIEvent &event); - GeckoWindow *mGeckoWnd; - nsCOMPtr mWebbrowser; - // GeckoContainerUI overrides virtual nsresult CreateBrowserWindow(PRUint32 aChromeFlags, nsIWebBrowserChrome *aParent, nsIWebBrowserChrome **aNewWindow); diff --git a/mozilla/embedding/tests/wxEmbed/ChatFrame.cpp b/mozilla/embedding/tests/wxEmbed/ChatFrame.cpp index eb767d46bde..f64cabecf8b 100644 --- a/mozilla/embedding/tests/wxEmbed/ChatFrame.cpp +++ b/mozilla/embedding/tests/wxEmbed/ChatFrame.cpp @@ -29,17 +29,47 @@ * * ***** END LICENSE BLOCK ***** */ - #include "global.h" +#include "global.h" - #include "ChatFrame.h" +#include "nsIWebNavigation.h" +#include "nsIDOMDocument.h" +#include "nsIDOMHTMLDocument.h" +#include "ChatFrame.h" -BEGIN_EVENT_TABLE(ChatFrame, wxFrame) -// EVT_LIST_ITEM_SELECTED(XRCID("articles"), ChatFrame::OnArticleClick) +BEGIN_EVENT_TABLE(ChatFrame, GeckoFrame) + EVT_TEXT_ENTER(XRCID("chat"), ChatFrame::OnChat) END_EVENT_TABLE() -ChatFrame::ChatFrame(wxWindow* aParent) : - mGeckoWnd(NULL) +ChatFrame::ChatFrame(wxWindow* aParent) { wxXmlResource::Get()->LoadFrame(this, aParent, wxT("chat_frame")); -} \ No newline at end of file + + SetIcon(wxICON(appicon)); + + SetupDefaultGeckoWindow(); + + nsCOMPtr webNav = do_QueryInterface(mWebBrowser); + webNav->LoadURI(NS_ConvertASCIItoUCS2("about:blank").get(), + nsIWebNavigation::LOAD_FLAGS_NONE, nsnull, nsnull, nsnull); + +} + +void ChatFrame::OnChat(wxCommandEvent &event) +{ + nsCOMPtr webNav = do_QueryInterface(mWebBrowser); + nsCOMPtr doc; + webNav->GetDocument(getter_AddRefs(doc)); + nsCOMPtr htmlDoc = do_QueryInterface(doc); + // doc->CreateElement(getter_AddRefs(element)); + + wxTextCtrl *chatCtrl = (wxTextCtrl *) FindWindowById(XRCID("chat"), this); + if (chatCtrl) + { + wxString txt = chatCtrl->GetValue(); + nsAutoString htmlFragment(NS_LITERAL_STRING("

Foo: ")); + htmlFragment.AppendWithConversion(txt.c_str()); + htmlDoc->Writeln(htmlFragment); + chatCtrl->SetValue(""); + } +} diff --git a/mozilla/embedding/tests/wxEmbed/ChatFrame.h b/mozilla/embedding/tests/wxEmbed/ChatFrame.h index db04fbb0d6b..56eccea66c9 100644 --- a/mozilla/embedding/tests/wxEmbed/ChatFrame.h +++ b/mozilla/embedding/tests/wxEmbed/ChatFrame.h @@ -31,20 +31,17 @@ #ifndef CHATFRAME_H -#include "GeckoContainer.h" -#include "GeckoWindow.h" +#include "GeckoFrame.h" class ChatFrame : - public wxFrame, - public GeckoContainerUI + public GeckoFrame { public : ChatFrame(wxWindow* aParent); DECLARE_EVENT_TABLE() - GeckoWindow *mGeckoWnd; - nsCOMPtr mWebbrowser; + void OnChat(wxCommandEvent &event); }; #endif \ No newline at end of file diff --git a/mozilla/embedding/tests/wxEmbed/EditorFrame.cpp b/mozilla/embedding/tests/wxEmbed/EditorFrame.cpp new file mode 100644 index 00000000000..6c2e9559eeb --- /dev/null +++ b/mozilla/embedding/tests/wxEmbed/EditorFrame.cpp @@ -0,0 +1,68 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: Mozilla-sample-code 1.0 + * + * Copyright (c) 2002 Netscape Communications Corporation and + * other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this Mozilla sample software and associated documentation files + * (the "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to permit + * persons to whom the Software is furnished to do so, subject to the + * following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + * Contributor(s): + * + * Adam Lock + * + * ***** END LICENSE BLOCK ***** */ + +#include "global.h" + +#include "nsIWebNavigation.h" +#include "nsIDOMDocument.h" +#include "nsIDOMHTMLDocument.h" +#include "nsIDOMWindow.h" +#include "nsIEditingSession.h" + +#include "EditorFrame.h" + +BEGIN_EVENT_TABLE(EditorFrame, GeckoFrame) + //EVT_TEXT_ENTER(XRCID("chat"), ChatFrame::OnChat) +END_EVENT_TABLE() + +EditorFrame::EditorFrame(wxWindow* aParent) +{ + wxXmlResource::Get()->LoadFrame(this, aParent, wxT("editor_frame")); + + SetIcon(wxICON(appicon)); + + SetupDefaultGeckoWindow(); + + nsCOMPtr webNav = do_QueryInterface(mWebBrowser); + webNav->LoadURI(NS_ConvertASCIItoUCS2("www.mozilla.org").get(), + nsIWebNavigation::LOAD_FLAGS_NONE, nsnull, nsnull, nsnull); + + + nsCOMPtr domWindow; + mWebBrowser->GetContentDOMWindow(getter_AddRefs(domWindow)); + + nsCOMPtr editingSession = do_GetInterface(mWebBrowser); + if (!editingSession) + return;// NS_ERROR_FAILURE; + + editingSession->MakeWindowEditable(domWindow, NULL, PR_TRUE); +} + diff --git a/mozilla/embedding/tests/wxEmbed/EditorFrame.h b/mozilla/embedding/tests/wxEmbed/EditorFrame.h new file mode 100644 index 00000000000..8709106a941 --- /dev/null +++ b/mozilla/embedding/tests/wxEmbed/EditorFrame.h @@ -0,0 +1,46 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: Mozilla-sample-code 1.0 + * + * Copyright (c) 2002 Netscape Communications Corporation and + * other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this Mozilla sample software and associated documentation files + * (the "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to permit + * persons to whom the Software is furnished to do so, subject to the + * following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + * Contributor(s): + * + * Adam Lock + * + * ***** END LICENSE BLOCK ***** */ + +#ifndef EDITORFRAME_H +#define EDITORFRAME_H + +#include "GeckoFrame.h" + +class EditorFrame : + public GeckoFrame +{ +public : + EditorFrame(wxWindow* aParent); + + DECLARE_EVENT_TABLE() +}; + +#endif \ No newline at end of file diff --git a/mozilla/embedding/tests/wxEmbed/EmbedApp.cpp b/mozilla/embedding/tests/wxEmbed/EmbedApp.cpp index 20a78ba844e..3c09d9cd9cf 100644 --- a/mozilla/embedding/tests/wxEmbed/EmbedApp.cpp +++ b/mozilla/embedding/tests/wxEmbed/EmbedApp.cpp @@ -38,6 +38,7 @@ #include "BrowserFrame.h" #include "MailFrame.h" #include "ChatFrame.h" +#include "EditorFrame.h" #include "GeckoProtocolHandler.h" #include "GeckoWindowCreator.h" @@ -80,13 +81,15 @@ class EmbedApp : public wxApp void OnAbout(wxCommandEvent &event); void OnMail(wxCommandEvent &event); void OnChat(wxCommandEvent &event); + void OnEditor(wxCommandEvent &event); }; BEGIN_EVENT_TABLE(EmbedApp, wxApp) - EVT_MENU(XRCID("menu_quit"), EmbedApp::OnQuit) - EVT_MENU(XRCID("menu_about"), EmbedApp::OnAbout) - EVT_MENU(XRCID("menu_mail"), EmbedApp::OnMail) - EVT_MENU(XRCID("menu_chat"), EmbedApp::OnChat) + EVT_MENU(XRCID("menu_quit"), EmbedApp::OnQuit) + EVT_MENU(XRCID("menu_about"), EmbedApp::OnAbout) + EVT_MENU(XRCID("menu_mail"), EmbedApp::OnMail) + EVT_MENU(XRCID("menu_chat"), EmbedApp::OnChat) + EVT_MENU(XRCID("menu_editor"), EmbedApp::OnEditor) END_EVENT_TABLE() /////////////////////////////////////////////////////////////////////////////// @@ -166,12 +169,27 @@ void EmbedApp::OnAbout(wxCommandEvent & WXUNUSED(event)) void EmbedApp::OnMail(wxCommandEvent & WXUNUSED(event)) { // Create the mail frame window - MailFrame * frame = new MailFrame(NULL); - frame->Show(TRUE); + static MailFrame * frame = NULL; + if (!frame) + frame = new MailFrame(NULL); + if (frame) + frame->Show(TRUE); } void EmbedApp::OnChat(wxCommandEvent & WXUNUSED(event)) { - ChatFrame * frame = new ChatFrame(NULL); - frame->Show(TRUE); -} \ No newline at end of file + static ChatFrame * frame = NULL; + if (!frame) + frame = new ChatFrame(NULL); + if (frame) + frame->Show(TRUE); +} + +void EmbedApp::OnEditor(wxCommandEvent & WXUNUSED(event)) +{ + static EditorFrame * frame = NULL; + if (!frame) + frame = new EditorFrame(NULL); + if (frame) + frame->Show(TRUE); +} diff --git a/mozilla/embedding/tests/wxEmbed/GeckoFrame.cpp b/mozilla/embedding/tests/wxEmbed/GeckoFrame.cpp new file mode 100644 index 00000000000..b59f3276208 --- /dev/null +++ b/mozilla/embedding/tests/wxEmbed/GeckoFrame.cpp @@ -0,0 +1,74 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: Mozilla-sample-code 1.0 + * + * Copyright (c) 2002 Netscape Communications Corporation and + * other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this Mozilla sample software and associated documentation files + * (the "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to permit + * persons to whom the Software is furnished to do so, subject to the + * following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + * Contributor(s): + * + * Adam Lock + * + * ***** END LICENSE BLOCK ***** */ + +#include "global.h" + +#include "GeckoFrame.h" +#include "GeckoContainer.h" + +GeckoFrame::GeckoFrame() : + mGeckoWnd(NULL) +{ +} + +bool GeckoFrame::SetupDefaultGeckoWindow() +{ + mGeckoWnd = (GeckoWindow *) FindWindowById(XRCID("gecko"), this); + if (!mGeckoWnd) + return FALSE; + return SetupGeckoWindow(mGeckoWnd, this, getter_AddRefs(mWebBrowser)); +} + +bool GeckoFrame::SetupGeckoWindow(GeckoWindow *aGeckoWindow, GeckoContainerUI *aUI, nsIWebBrowser **aWebBrowser) const +{ + if (!aGeckoWindow || !aUI) + return FALSE; + + GeckoContainer *geckoContainer = new GeckoContainer(aUI); + if (!geckoContainer) + return FALSE; + + mGeckoWnd->SetGeckoContainer(geckoContainer); + + PRUint32 aChromeFlags = nsIWebBrowserChrome::CHROME_ALL; + geckoContainer->SetChromeFlags(aChromeFlags); + geckoContainer->SetParent(nsnull); + + wxSize size = mGeckoWnd->GetClientSize(); + + // Insert the browser + geckoContainer->CreateBrowser(0, 0, size.GetWidth(), size.GetHeight(), + (nativeWindow) aGeckoWindow->GetHWND(), aWebBrowser); + + aUI->ShowWindow(PR_TRUE); + + return TRUE; +} \ No newline at end of file diff --git a/mozilla/embedding/tests/wxEmbed/GeckoFrame.h b/mozilla/embedding/tests/wxEmbed/GeckoFrame.h new file mode 100644 index 00000000000..ac15d378cb8 --- /dev/null +++ b/mozilla/embedding/tests/wxEmbed/GeckoFrame.h @@ -0,0 +1,59 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: Mozilla-sample-code 1.0 + * + * Copyright (c) 2002 Netscape Communications Corporation and + * other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this Mozilla sample software and associated documentation files + * (the "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to permit + * persons to whom the Software is furnished to do so, subject to the + * following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + * Contributor(s): + * + * Adam Lock + * + * ***** END LICENSE BLOCK ***** */ + +#ifndef GECKOFRAME_H +#define GECKOFRAME_H + +#include "nsIWebBrowser.h" + +#include "GeckoWindow.h" +#include "GeckoContainer.h" + +class GeckoFrame : + public wxFrame, + public GeckoContainerUI +{ +protected: + GeckoWindow *mGeckoWnd; + nsCOMPtr mWebBrowser; +public: + GeckoFrame(); + + // This method searches for a "gecko" wxWindow and sets it up with the frame + // as the container UI. The results are stored in the mGeckoWnd and mWebBrowser + // member variables. + bool SetupDefaultGeckoWindow(); + // This method sets up the specified window with the specified container UI + // and returns the nsIWebBrowser interface to it. + bool SetupGeckoWindow(GeckoWindow *aGeckoWindow, GeckoContainerUI *aUI, nsIWebBrowser **aWebBrowser) const; +}; + +#endif \ No newline at end of file diff --git a/mozilla/embedding/tests/wxEmbed/MailFrame.cpp b/mozilla/embedding/tests/wxEmbed/MailFrame.cpp index d63b766ecab..03efc7aee15 100644 --- a/mozilla/embedding/tests/wxEmbed/MailFrame.cpp +++ b/mozilla/embedding/tests/wxEmbed/MailFrame.cpp @@ -36,40 +36,70 @@ #include "nsIURI.h" -const char msg1[] = -"" -"Attention: Sir,
\n" -"Good day. I am ALEXANDER NENE, Solicitor and Notary Public, The Personal Attorney
" -"to MR HENRI CARLTON, The president of DIAMOND SAFARIESCO.LTD.ACCRA-GHANA who is a
" -"National of your country. On the 21st of April 2000, my client, his wife and their
" -"only son were Involved in a car accident along ACCRA/KUMASI Express Road.
\n" -"Unfortunately, they all lost their lives in the event of the accident, since then
" -"I have made several enquiries to locate any of my clients extended relatives and
" -"this has also proved unsuccessful.After these several unsuccessful attempts, I decided
" -"to trace his Relatives over the Internet, to locate any member of his family but of
" -"no avail, hence I contacted youI contacted you to assist in repatriating the money and
" -"property left Behind before they get confiscated or declare unserviceable by the bank
" -"where my client lodged this huge deposits. Particularly, the Bank where the deceased had
" -"an account valued at about 28.3 million dollars.Conseqently, the bank issued me a notice
" -"to provide the next of kin or Have the account confiscated within a short time. Since
" -"I have been Unsuccessful in locating the relatives for over some years now, I seek your
" -"consent to present you as the next of kin of the deceased since you share the same surname
" -" so that the proceeds of this account valued at 48.3 million dollars can be paid to you
" -"for both of us to share the money; 70% to me and 25% to you, while 5% should be for
" -"expenses or tax as your government may require. I have all necessary legal documents that
" -"can be used to backup the claim.All I require is your honest cooperation to enable us see
" -"this deal Through. I guarantee that this will be executed under a legitimate arrangement
" -"that will protect you from any breach of the law. Please get in touch with me through my
" -"email to enable us discuss further.

\n" -"Thanks for you kind co-operation

\n" -"ALEXANDER NENE


"; +struct MailMsg +{ + char *mSubject; + char *mSender; + char *mDate; + char *mBody; +}; - -const char msg2[] = -"The network will be going down tonight so please log off your computers before going home."; - -const char msg3[] = -"Please submit expense reports ASAP if you want to see payment in your accounts this month!"; +MailMsg gSampleMessages[] = +{ + { + "URGENT ASSITANCE PLS", + "alexander nene", + "09/06/2003 14:38", + "" + "

Attention: Sir,
\n" + "

Good day. I am ALEXANDER NENE, Solicitor and Notary Public, The Personal Attorney" + "to MR HENRI CARLTON, The president of DIAMOND SAFARIESCO.LTD.ACCRA-GHANA who is a" + "National of your country. On the 21st of April 2000, my client, his wife and their " + "only son were Involved in a car accident along ACCRA/KUMASI Express Road." + "

Unfortunately, they all lost their lives in the event of the accident, since then " + "I have made several enquiries to locate any of my clients extended relatives and" + "this has also proved unsuccessful.After these several unsuccessful attempts, I decided" + "to trace his Relatives over the Internet, to locate any member of his family but of" + "no avail, hence I contacted youI contacted you to assist in repatriating the money and" + "property left Behind before they get confiscated or declare unserviceable by the bank" + "where my client lodged this huge deposits. Particularly, the Bank where the deceased had" + "an account valued at about 28.3 million dollars.Conseqently, the bank issued me a notice " + "to provide the next of kin or Have the account confiscated within a short time. Since " + "I have been Unsuccessful in locating the relatives for over some years now, I seek your " + "consent to present you as the next of kin of the deceased since you share the same surname " + "so that the proceeds of this account valued at 48.3 million dollars can be paid to you " + "for both of us to share the money; 70% to me and 25% to you, while 5% should be for " + "expenses or tax as your government may require. I have all necessary legal documents that" + "can be used to backup the claim.All I require is your honest cooperation to enable us see" + "this deal Through. " + "

I guarantee that this will be executed under a legitimate arrangement" + "that will protect you from any breach of the law. Please get in touch with me through my" + "email to enable us discuss further.

\n" + "

Thanks for you kind co-operation

\n" + "

ALEXANDER NENE


" + }, + { + "Reminder: Network Outage Tonight", + "IT Dept", + "09/06/2003 15:22", + "The network will be going down tonight so please log off " + "your computers before going home." + }, + { + "Expense Reports Due", + "Finance Dept", + "09/06/2003 15:40", + "Please submit expense reports ASAP if you want to see payment " + "in your accounts this month!" + }, + { + "Flight confirmation", + "Expediocity", + "12/06/2003 12:31", + "Thank you for booking with Expediocity, Your flight reservation has been " + "confirmed and details may be found online here." + } +}; static bool gMailChannelCallbackRegistered = FALSE; @@ -88,12 +118,16 @@ public: nsCAutoString path; aURI->GetPath(path); - if (path.Equals("//0")) - txt = msg1; - else if (path.Equals("//1")) - txt = msg2; + + long i; + if (sscanf(path.get(), "//%ld", &i) == 1) + { + txt = gSampleMessages[i].mBody; + } else - txt = msg3; + { + return NS_ERROR_FAILURE; + } size_t size = txt.Length(); *aData = (void *) nsMemory::Alloc(size + 1); @@ -106,12 +140,11 @@ public: } }; -BEGIN_EVENT_TABLE(MailFrame, wxFrame) +BEGIN_EVENT_TABLE(MailFrame, GeckoFrame) EVT_LIST_ITEM_SELECTED(XRCID("articles"), MailFrame::OnArticleClick) END_EVENT_TABLE() -MailFrame::MailFrame(wxWindow* aParent) : - mGeckoWnd(NULL) +MailFrame::MailFrame(wxWindow* aParent) { wxXmlResource::Get()->LoadFrame(this, aParent, wxT("mail_frame")); @@ -130,41 +163,17 @@ MailFrame::MailFrame(wxWindow* aParent) : articleListCtrl->InsertColumn(0, "Subject", wxLIST_FORMAT_LEFT, 200); articleListCtrl->InsertColumn(1, "Sender", wxLIST_FORMAT_LEFT, 100); articleListCtrl->InsertColumn(2, "Date", wxLIST_FORMAT_LEFT, 100); - long idx; - idx = articleListCtrl->InsertItem(0, "URGENT ASSITANCE PLS"); - articleListCtrl->SetItem(idx, 1, "alexander nene"); - articleListCtrl->SetItem(idx, 2, "09/06/2003 14:38"); - idx = articleListCtrl->InsertItem(1, "Reminder: Network Outage Tonight"); - articleListCtrl->SetItem(idx, 1, "IT Dept"); - articleListCtrl->SetItem(idx, 2, "09/06/2003 15:22"); - idx = articleListCtrl->InsertItem(2, "Expense Reports Due"); - articleListCtrl->SetItem(idx, 1, "Finance Dept"); - articleListCtrl->SetItem(idx, 2, "09/06/2003 15:40"); - } - mGeckoWnd = (GeckoWindow *) FindWindowById(XRCID("gecko"), this); - if (mGeckoWnd) - { - GeckoContainer *geckoContainer = new GeckoContainer(this); - if (geckoContainer) + for (long i = 0; i < sizeof(gSampleMessages) / sizeof(gSampleMessages[0]); i++) { - mGeckoWnd->SetGeckoContainer(geckoContainer); - - PRUint32 aChromeFlags = nsIWebBrowserChrome::CHROME_ALL; - geckoContainer->SetChromeFlags(aChromeFlags); - geckoContainer->SetParent(nsnull); - - wxSize size = mGeckoWnd->GetClientSize(); - - // Insert the browser - geckoContainer->CreateBrowser(0, 0, size.GetWidth(), size.GetHeight(), - (nativeWindow) mGeckoWnd->GetHWND(), getter_AddRefs(mWebbrowser)); - - GeckoContainerUI::ShowWindow(PR_TRUE); - + articleListCtrl->InsertItem(i, gSampleMessages[i].mSubject); + articleListCtrl->SetItem(i, 1, gSampleMessages[i].mSender); + articleListCtrl->SetItem(i, 2, gSampleMessages[i].mDate); } } + SetupDefaultGeckoWindow(); + wxWindow *hdrPanel = FindWindowById(XRCID("mail_header_panel"), this); if (hdrPanel) { @@ -177,18 +186,27 @@ MailFrame::MailFrame(wxWindow* aParent) : void MailFrame::OnArticleClick(wxListEvent &event) { - if (mWebbrowser) + if (mWebBrowser) { - wxString url = wxString::Format("wxmail://%ld", event.GetIndex()); + long idx = event.GetIndex(); + wxString url = wxString::Format("wxmail://%ld", idx); if (!url.IsEmpty()) { + wxStaticText *txtFrom = (wxStaticText *) FindWindowById(XRCID("mail_from"), this); + if (txtFrom) + txtFrom->SetLabel(gSampleMessages[idx].mSender); + wxStaticText *txtDate = (wxStaticText *) FindWindowById(XRCID("mail_date"), this); + if (txtDate) + txtDate->SetLabel(gSampleMessages[idx].mDate); + wxStaticText *txtSubject = (wxStaticText *) FindWindowById(XRCID("mail_subject"), this); + if (txtSubject) + txtSubject->SetLabel(gSampleMessages[idx].mSubject); + wxWindow *hdrPanel = FindWindowById(XRCID("mail_header_panel"), this); if (hdrPanel) - { hdrPanel->Show(TRUE); - } - nsCOMPtr webNav = do_QueryInterface(mWebbrowser); + nsCOMPtr webNav = do_QueryInterface(mWebBrowser); webNav->LoadURI(NS_ConvertASCIItoUCS2(url.c_str()).get(), nsIWebNavigation::LOAD_FLAGS_NONE, nsnull, diff --git a/mozilla/embedding/tests/wxEmbed/MailFrame.h b/mozilla/embedding/tests/wxEmbed/MailFrame.h index 92a63a0d1b7..8c5b8cc061b 100644 --- a/mozilla/embedding/tests/wxEmbed/MailFrame.h +++ b/mozilla/embedding/tests/wxEmbed/MailFrame.h @@ -32,12 +32,10 @@ #ifndef MAILFRAME_H #define MAILFRAME_H -#include "GeckoContainer.h" -#include "GeckoWindow.h" +#include "GeckoFrame.h" class MailFrame : - public wxFrame, - public GeckoContainerUI + public GeckoFrame { public : MailFrame(wxWindow* aParent); @@ -46,8 +44,6 @@ public : void OnArticleClick(wxListEvent &event); - GeckoWindow *mGeckoWnd; - nsCOMPtr mWebbrowser; }; #endif \ No newline at end of file diff --git a/mozilla/embedding/tests/wxEmbed/makefile.vc b/mozilla/embedding/tests/wxEmbed/makefile.vc index 8faaa785708..56ce4ac4b7d 100644 --- a/mozilla/embedding/tests/wxEmbed/makefile.vc +++ b/mozilla/embedding/tests/wxEmbed/makefile.vc @@ -10,8 +10,10 @@ OBJECTS = \ BrowserFrame.obj \ MailFrame.obj \ ChatFrame.obj \ + EditorFrame.obj \ GeckoContainer.obj \ GeckoContainerUI.obj \ + GeckoFrame.obj \ GeckoWindow.obj \ GeckoWindowCreator.obj \ GeckoProtocolHandler.obj \ @@ -22,6 +24,7 @@ XRC = \ rc\browser.xrc \ rc\mail.xrc \ rc\chat.xrc \ + rc\editor.xrc \ $(NULL) # Needing to include this big long list of includes STINKS!!! @@ -41,6 +44,7 @@ MOZINC = \ -I$(MOZSDK)\include\webbrwsr \ -I$(MOZSDK)\include\embed_base \ -I$(MOZSDK)\include\windowwatcher \ + -I$(MOZSDK)\include\composer \ $(NULL) # This isn't much better either! diff --git a/mozilla/embedding/tests/wxEmbed/rc/browser.xrc b/mozilla/embedding/tests/wxEmbed/rc/browser.xrc index d0712391e6f..e11c4b7a62d 100644 --- a/mozilla/embedding/tests/wxEmbed/rc/browser.xrc +++ b/mozilla/embedding/tests/wxEmbed/rc/browser.xrc @@ -72,6 +72,9 @@ + + + diff --git a/mozilla/embedding/tests/wxEmbed/rc/chat.xrc b/mozilla/embedding/tests/wxEmbed/rc/chat.xrc index b010d96587f..e5996bb7dca 100644 --- a/mozilla/embedding/tests/wxEmbed/rc/chat.xrc +++ b/mozilla/embedding/tests/wxEmbed/rc/chat.xrc @@ -33,7 +33,7 @@ wxGROW|wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL - + diff --git a/mozilla/embedding/tests/wxEmbed/rc/editor.xrc b/mozilla/embedding/tests/wxEmbed/rc/editor.xrc new file mode 100644 index 00000000000..50877acee77 --- /dev/null +++ b/mozilla/embedding/tests/wxEmbed/rc/editor.xrc @@ -0,0 +1,70 @@ + + + + + + wxEmbed Mail + 300,300 + + -1,-1 + + + + + + + + + + + 2,2 + 20,18 + + + home.gif + Bold + + + home.gif + Italic + + + + home.gif + Underline + + + + home.gif + Indent paragraph + + + home.gif + Outdent paragraph + + + + + + 1 + 1 + 0 + 0 + 0 + 0 + + + + + wxGROW|wxALL + + + 500,280 + + + + + + + + \ No newline at end of file diff --git a/mozilla/embedding/tests/wxEmbed/wxEmbed.dsp b/mozilla/embedding/tests/wxEmbed/wxEmbed.dsp index 0d7b962feef..fc9fd56308c 100644 --- a/mozilla/embedding/tests/wxEmbed/wxEmbed.dsp +++ b/mozilla/embedding/tests/wxEmbed/wxEmbed.dsp @@ -90,6 +90,14 @@ SOURCE=.\BrowserFrame.cpp # End Source File # Begin Source File +SOURCE=.\ChatFrame.cpp +# End Source File +# Begin Source File + +SOURCE=.\EditorFrame.cpp +# End Source File +# Begin Source File + SOURCE=.\EmbedApp.cpp # End Source File # Begin Source File @@ -102,6 +110,10 @@ SOURCE=.\GeckoContainerUI.cpp # End Source File # Begin Source File +SOURCE=.\GeckoFrame.cpp +# End Source File +# Begin Source File + SOURCE=.\GeckoProtocolHandler.cpp # End Source File # Begin Source File @@ -126,10 +138,22 @@ SOURCE=.\BrowserFrame.h # End Source File # Begin Source File +SOURCE=.\ChatFrame.h +# End Source File +# Begin Source File + +SOURCE=.\EditorFrame.h +# End Source File +# Begin Source File + SOURCE=.\GeckoContainer.h # End Source File # Begin Source File +SOURCE=.\GeckoFrame.h +# End Source File +# Begin Source File + SOURCE=.\GeckoProtocolHandler.h # End Source File # Begin Source File @@ -162,6 +186,14 @@ SOURCE=.\rc\browser.xrc # End Source File # Begin Source File +SOURCE=.\rc\chat.xrc +# End Source File +# Begin Source File + +SOURCE=.\rc\editor.xrc +# End Source File +# Begin Source File + SOURCE=.\rc\forward.gif # End Source File # Begin Source File