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"
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_UPDATE_UI(XRCID("browse_back"), BrowserFrame::OnUpdateBrowserBack)
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))
{
wxTextCtrl *txtCtrl = (wxTextCtrl *) FindWindowById(XRCID("url"), this);

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

@ -44,18 +44,26 @@ protected:
void OnBrowserUrl(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 OnBrowserOpenLinkInNewWindow(wxCommandEvent & event);
void OnBrowserBack(wxCommandEvent &event);
void OnUpdateBrowserBack(wxUpdateUIEvent &event);
void OnBrowserForward(wxCommandEvent &event);
void OnUpdateBrowserForward(wxUpdateUIEvent &event);
void OnBrowserReload(wxCommandEvent &event);
void OnBrowserStop(wxCommandEvent &event);
void OnUpdateBrowserStop(wxUpdateUIEvent &event);
void OnFileSave(wxCommandEvent &event);
void OnFilePrint(wxCommandEvent &event);
void OnViewPageSource(wxCommandEvent &event);
void OnUpdateViewPageSource(wxUpdateUIEvent &event);
public :
BrowserFrame(wxWindow* aParent);

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

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

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

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

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

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

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

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