NOT PART OF BUILD. Implement view-source: and hook up status bar on edit app

This commit is contained in:
locka%iol.ie 2004-01-13 22:19:52 +00:00
Родитель eb5f101ca9
Коммит 94a9a0f0bf
6 изменённых файлов: 93 добавлений и 13 удалений

Просмотреть файл

@ -38,6 +38,14 @@
#include "nsIURI.h" #include "nsIURI.h"
BEGIN_EVENT_TABLE(BrowserFrame, GeckoFrame) BEGIN_EVENT_TABLE(BrowserFrame, GeckoFrame)
// View menu
EVT_MENU(XRCID("view_pagesource"), BrowserFrame::OnViewPageSource)
EVT_UPDATE_UI(XRCID("view_pagesource"),
BrowserFrame::OnUpdateViewPageSource)
// Browser operations, back / forward etc.
// TODO some of these can go in GeckoFrame
EVT_MENU(XRCID("browse_back"), BrowserFrame::OnBrowserBack) EVT_MENU(XRCID("browse_back"), BrowserFrame::OnBrowserBack)
EVT_UPDATE_UI(XRCID("browse_back"), BrowserFrame::OnUpdateBrowserBack) EVT_UPDATE_UI(XRCID("browse_back"), BrowserFrame::OnUpdateBrowserBack)
EVT_MENU(XRCID("browse_fwd"), BrowserFrame::OnBrowserForward) EVT_MENU(XRCID("browse_fwd"), BrowserFrame::OnBrowserForward)
@ -103,6 +111,42 @@ void BrowserFrame::OnFilePrint(wxCommandEvent & WXUNUSED(event))
{ {
} }
void BrowserFrame::OnViewPageSource(wxCommandEvent &event)
{
nsCOMPtr<nsIWebNavigation> webNav = do_QueryInterface(mWebBrowser);
if(!webNav)
return;
// Get the URI object whose source we want to view.
nsresult rv = NS_OK;
nsCOMPtr<nsIURI> currentURI;
rv = webNav->GetCurrentURI(getter_AddRefs(currentURI));
if(NS_FAILED(rv) || !currentURI)
return;
// Get the uri string associated with the nsIURI object
nsCAutoString uriString;
rv = currentURI->GetSpec(uriString);
if(NS_FAILED(rv))
return;
// Build the view-source: url
nsAutoString viewSrcUrl(L"view-source:");
viewSrcUrl.AppendWithConversion(uriString.get());
BrowserFrame *frame = new BrowserFrame(NULL);
if (frame)
{
frame->Show(TRUE);
frame->LoadURI(viewSrcUrl.get());
}
}
void BrowserFrame::OnUpdateViewPageSource(wxUpdateUIEvent &event)
{
}
void BrowserFrame::OnBrowserGo(wxCommandEvent & WXUNUSED(event)) void BrowserFrame::OnBrowserGo(wxCommandEvent & WXUNUSED(event))
{ {
wxTextCtrl *txtCtrl = (wxTextCtrl *) FindWindowById(XRCID("url"), this); wxTextCtrl *txtCtrl = (wxTextCtrl *) FindWindowById(XRCID("url"), this);

Просмотреть файл

@ -44,18 +44,26 @@ protected:
void OnBrowserUrl(wxCommandEvent &event); void OnBrowserUrl(wxCommandEvent &event);
void OnBrowserGo(wxCommandEvent &event); void OnBrowserGo(wxCommandEvent &event);
void OnBrowserBack(wxCommandEvent &event);
void OnBrowserForward(wxCommandEvent &event);
void OnBrowserReload(wxCommandEvent &event);
void OnBrowserStop(wxCommandEvent &event);
void OnBrowserHome(wxCommandEvent &event); void OnBrowserHome(wxCommandEvent &event);
void OnBrowserOpenLinkInNewWindow(wxCommandEvent & event); void OnBrowserOpenLinkInNewWindow(wxCommandEvent & event);
void OnBrowserBack(wxCommandEvent &event);
void OnUpdateBrowserBack(wxUpdateUIEvent &event); void OnUpdateBrowserBack(wxUpdateUIEvent &event);
void OnBrowserForward(wxCommandEvent &event);
void OnUpdateBrowserForward(wxUpdateUIEvent &event); void OnUpdateBrowserForward(wxUpdateUIEvent &event);
void OnBrowserReload(wxCommandEvent &event);
void OnBrowserStop(wxCommandEvent &event);
void OnUpdateBrowserStop(wxUpdateUIEvent &event); void OnUpdateBrowserStop(wxUpdateUIEvent &event);
void OnFileSave(wxCommandEvent &event); void OnFileSave(wxCommandEvent &event);
void OnFilePrint(wxCommandEvent &event); void OnFilePrint(wxCommandEvent &event);
void OnViewPageSource(wxCommandEvent &event);
void OnUpdateViewPageSource(wxUpdateUIEvent &event);
public : public :
BrowserFrame(wxWindow* aParent); BrowserFrame(wxWindow* aParent);

Просмотреть файл

@ -64,8 +64,9 @@ EditorFrame::EditorFrame(wxWindow* aParent)
SetupDefaultGeckoWindow(); SetupDefaultGeckoWindow();
SendSizeEvent(); // SendSizeEvent(); //
CreateStatusBar();
MakeEditable(); MakeEditable();
mCommandManager = do_GetInterface(mWebBrowser); mCommandManager = do_GetInterface(mWebBrowser);
@ -73,6 +74,7 @@ EditorFrame::EditorFrame(wxWindow* aParent)
nsCOMPtr<nsIWebNavigation> webNav = do_QueryInterface(mWebBrowser); nsCOMPtr<nsIWebNavigation> webNav = do_QueryInterface(mWebBrowser);
webNav->LoadURI(NS_ConvertASCIItoUCS2("www.mozilla.org").get(), webNav->LoadURI(NS_ConvertASCIItoUCS2("www.mozilla.org").get(),
nsIWebNavigation::LOAD_FLAGS_NONE, nsnull, nsnull, nsnull); nsIWebNavigation::LOAD_FLAGS_NONE, nsnull, nsnull, nsnull);
} }
void EditorFrame::MakeEditable() void EditorFrame::MakeEditable()
@ -107,7 +109,6 @@ void EditorFrame::IsCommandEnabled(const char *aCommand, PRBool *retval)
} }
} }
void EditorFrame::GetCommandState(const char *aCommand, nsICommandParams *aCommandParams) void EditorFrame::GetCommandState(const char *aCommand, nsICommandParams *aCommandParams)
{ {
if (mCommandManager) if (mCommandManager)
@ -118,6 +119,10 @@ void EditorFrame::GetCommandState(const char *aCommand, nsICommandParams *aComma
} }
} }
void EditorFrame::UpdateStatusBarText(const PRUnichar* aStatusText)
{
SetStatusText(aStatusText);
}
static static
nsresult MakeCommandParams(nsICommandParams **aParams) nsresult MakeCommandParams(nsICommandParams **aParams)
@ -133,12 +138,12 @@ nsresult MakeCommandParams(nsICommandParams **aParams)
return rv; return rv;
} }
const char kCmdBold[] = "cmd_bold"; static const char kCmdBold[] = "cmd_bold";
const char kCmdItalic[] = "cmd_italic"; static const char kCmdItalic[] = "cmd_italic";
const char kCmdUnderline[] = "cmd_underline"; static const char kCmdUnderline[] = "cmd_underline";
const char kCmdIndent[] = "cmd_indent"; static const char kCmdIndent[] = "cmd_indent";
const char kCmdOutdent[] = "cmd_outdent"; static const char kCmdOutdent[] = "cmd_outdent";
const char kCmdAlign[] = "cmd_align"; static const char kCmdAlign[] = "cmd_align";
void EditorFrame::OnEditBold(wxCommandEvent &event) void EditorFrame::OnEditBold(wxCommandEvent &event)
{ {

Просмотреть файл

@ -56,6 +56,9 @@ public :
nsCOMPtr<nsICommandManager> mCommandManager; nsCOMPtr<nsICommandManager> mCommandManager;
// GeckoContainerUI overrides
virtual void UpdateStatusBarText(const PRUnichar* aStatusText);
void MakeEditable(); void MakeEditable();
nsresult DoCommand(const char *aCommand, nsICommandParams *aCommandParams); nsresult DoCommand(const char *aCommand, nsICommandParams *aCommandParams);
void IsCommandEnabled(const char *aCommand, PRBool *retval); void IsCommandEnabled(const char *aCommand, PRBool *retval);

Просмотреть файл

@ -55,6 +55,9 @@
<!-- Browser menu --> <!-- Browser menu -->
<object class="wxMenuBar" name="mainmenu"> <object class="wxMenuBar" name="mainmenu">
<style>wxMB_DOCKABLE</style> <style>wxMB_DOCKABLE</style>
<!-- File menu -->
<object class="wxMenu" name="menu_file"> <object class="wxMenu" name="menu_file">
<label>_File</label> <label>_File</label>
<object class="wxMenuItem" name="menu_about"> <object class="wxMenuItem" name="menu_about">
@ -72,6 +75,9 @@
<label>E_xit\tAlt-Q</label> <label>E_xit\tAlt-Q</label>
</object> </object>
</object> </object>
<!-- Edit menu -->
<object class="wxMenu" name="menu_edit"> <object class="wxMenu" name="menu_edit">
<label>_Edit</label> <label>_Edit</label>
<object class="wxMenuItem" name="edit_cut"> <object class="wxMenuItem" name="edit_cut">
@ -87,6 +93,18 @@
<label>Select _All</label> <label>Select _All</label>
</object> </object>
</object> </object>
<!-- View menu -->
<object class="wxMenu" name="menu_view">
<label>_View</label>
<object class="wxMenuItem" name="view_pagesource">
<label>_View Page Source</label>
</object>
</object>
<!-- Go menu -->
<object class="wxMenu" name="menu_go"> <object class="wxMenu" name="menu_go">
<label>_Go</label> <label>_Go</label>
<object class="wxMenuItem" name="browse_back"> <object class="wxMenuItem" name="browse_back">
@ -102,6 +120,9 @@
<label>Stop</label> <label>Stop</label>
</object> </object>
</object> </object>
<!-- Other apps menu -->
<object class="wxMenu" name="menu_other_apps"> <object class="wxMenu" name="menu_other_apps">
<label>_Other Apps</label> <label>_Other Apps</label>
<object class="wxMenuItem" name="menu_mail"> <object class="wxMenuItem" name="menu_mail">

Просмотреть файл

@ -69,7 +69,6 @@
</object> </object>
</object> </object>
<object class="wxFlexGridSizer"> <object class="wxFlexGridSizer">
<cols>1</cols> <cols>1</cols>
<rows>1</rows> <rows>1</rows>