Renamed WebViewWindow to BWebWindow and converted the API to Haiku coding guide

lines.


git-svn-id: http://svn.haiku-os.org/webpositive/webkit/trunk@195 94f232f2-1747-11df-bad5-a5bfde151594
This commit is contained in:
stippi
2010-02-24 18:33:22 +00:00
parent feba54b70c
commit 054c42b1b9
3 changed files with 71 additions and 70 deletions
+2 -2
View File
@@ -151,7 +151,7 @@ void LauncherApp::MessageReceived(BMessage* message)
newWindow(url); newWindow(url);
} else { } else {
// load the URL in the first window // load the URL in the first window
webWindow->currentWebView()->LoadURL(url.String()); webWindow->CurrentWebView()->LoadURL(url.String());
} }
} }
break; break;
@@ -279,7 +279,7 @@ void LauncherApp::newWindow(const BString& url)
BMessenger(m_downloadWindow)); BMessenger(m_downloadWindow));
window->Show(); window->Show();
if (url.Length()) if (url.Length())
window->currentWebView()->LoadURL(url.String()); window->CurrentWebView()->LoadURL(url.String());
} }
void LauncherApp::newTab(LauncherWindow* window, const BString& url, bool select) void LauncherApp::newTab(LauncherWindow* window, const BString& url, bool select)
+49 -49
View File
@@ -91,7 +91,7 @@ static BLayoutItem* layoutItemFor(BView* view)
LauncherWindow::LauncherWindow(BRect frame, const BMessenger& downloadListener, LauncherWindow::LauncherWindow(BRect frame, const BMessenger& downloadListener,
ToolbarPolicy toolbarPolicy) ToolbarPolicy toolbarPolicy)
: WebViewWindow(frame, "HaikuLauncher", : BWebWindow(frame, "HaikuLauncher",
B_TITLED_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL, B_TITLED_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL,
B_AUTO_UPDATE_SIZE_LIMITS | B_ASYNCHRONOUS_CONTROLS) B_AUTO_UPDATE_SIZE_LIMITS | B_ASYNCHRONOUS_CONTROLS)
, m_downloadListener(downloadListener) , m_downloadListener(downloadListener)
@@ -221,10 +221,10 @@ LauncherWindow::LauncherWindow(BRect frame, const BMessenger& downloadListener,
m_loadingProgressBar = 0; m_loadingProgressBar = 0;
BWebView* webView = new BWebView("web_view"); BWebView* webView = new BWebView("web_view");
setCurrentWebView(webView); SetCurrentWebView(webView);
AddChild(BGroupLayoutBuilder(B_VERTICAL, 7) AddChild(BGroupLayoutBuilder(B_VERTICAL, 7)
.Add(currentWebView()) .Add(CurrentWebView())
); );
} }
@@ -248,20 +248,20 @@ void LauncherWindow::MessageReceived(BMessage* message)
{ {
switch (message->what) { switch (message->what) {
case RELOAD: case RELOAD:
currentWebView()->LoadURL(m_url->Text()); CurrentWebView()->LoadURL(m_url->Text());
break; break;
case GOTO_URL: { case GOTO_URL: {
BString url = m_url->Text(); BString url = m_url->Text();
message->FindString("url", &url); message->FindString("url", &url);
if (m_loadedURL != url) if (m_loadedURL != url)
currentWebView()->LoadURL(url.String()); CurrentWebView()->LoadURL(url.String());
break; break;
} }
case GO_BACK: case GO_BACK:
currentWebView()->GoBack(); CurrentWebView()->GoBack();
break; break;
case GO_FORWARD: case GO_FORWARD:
currentWebView()->GoForward(); CurrentWebView()->GoForward();
break; break;
case CLEAR_HISTORY: { case CLEAR_HISTORY: {
@@ -297,26 +297,26 @@ void LauncherWindow::MessageReceived(BMessage* message)
BPath path; BPath path;
if (!entry.Exists() || entry.GetPath(&path) != B_OK) if (!entry.Exists() || entry.GetPath(&path) != B_OK)
break; break;
currentWebView()->LoadURL(path.Path()); CurrentWebView()->LoadURL(path.Path());
break; break;
} }
case TEXT_SIZE_INCREASE: case TEXT_SIZE_INCREASE:
currentWebView()->IncreaseTextSize(); CurrentWebView()->IncreaseTextSize();
break; break;
case TEXT_SIZE_DECREASE: case TEXT_SIZE_DECREASE:
currentWebView()->DecreaseTextSize(); CurrentWebView()->DecreaseTextSize();
break; break;
case TEXT_SIZE_RESET: case TEXT_SIZE_RESET:
currentWebView()->ResetTextSize(); CurrentWebView()->ResetTextSize();
break; break;
case TEXT_FIND_NEXT: case TEXT_FIND_NEXT:
currentWebView()->FindString(m_findTextControl->Text(), true, CurrentWebView()->FindString(m_findTextControl->Text(), true,
m_findCaseSensitiveCheckBox->Value()); m_findCaseSensitiveCheckBox->Value());
break; break;
case TEXT_FIND_PREVIOUS: case TEXT_FIND_PREVIOUS:
currentWebView()->FindString(m_findTextControl->Text(), false, CurrentWebView()->FindString(m_findTextControl->Text(), false,
m_findCaseSensitiveCheckBox->Value()); m_findCaseSensitiveCheckBox->Value());
break; break;
case TEXT_SHOW_FIND_GROUP: case TEXT_SHOW_FIND_GROUP:
@@ -344,17 +344,17 @@ void LauncherWindow::MessageReceived(BMessage* message)
case TAB_CHANGED: { case TAB_CHANGED: {
int32 index = message->FindInt32("index"); int32 index = message->FindInt32("index");
setCurrentWebView(dynamic_cast<BWebView*>(m_tabView->ViewForTab(index))); SetCurrentWebView(dynamic_cast<BWebView*>(m_tabView->ViewForTab(index)));
updateTitle(m_tabView->TabAt(index)->Label()); updateTitle(m_tabView->TabAt(index)->Label());
m_url->SetText(currentWebView()->MainFrameURL()); m_url->SetText(CurrentWebView()->MainFrameURL());
// Trigger update of the interface to the new page, by requesting // Trigger update of the interface to the new page, by requesting
// to resend all notifications. // to resend all notifications.
currentWebView()->WebPage()->ResendNotifications(); CurrentWebView()->WebPage()->ResendNotifications();
break; break;
} }
default: default:
WebViewWindow::MessageReceived(message); BWebWindow::MessageReceived(message);
break; break;
} }
} }
@@ -367,7 +367,7 @@ bool LauncherWindow::QuitRequested()
// TODO: Iterator over all WebViews, if there are more then one... // TODO: Iterator over all WebViews, if there are more then one...
while (m_tabView->CountTabs() > 0) while (m_tabView->CountTabs() > 0)
delete m_tabView->RemoveTab(0L); delete m_tabView->RemoveTab(0L);
setCurrentWebView(0); SetCurrentWebView(0);
BMessage message(WINDOW_CLOSED); BMessage message(WINDOW_CLOSED);
message.AddRect("window frame", Frame()); message.AddRect("window frame", Frame());
@@ -422,8 +422,8 @@ void LauncherWindow::newTab(const BString& url, bool select)
if (select) { if (select) {
m_tabView->Select(m_tabView->CountTabs() - 1); m_tabView->Select(m_tabView->CountTabs() - 1);
setCurrentWebView(webView); SetCurrentWebView(webView);
navigationCapabilitiesChanged(false, false, false, webView); NavigationCapabilitiesChanged(false, false, false, webView);
if (m_url) if (m_url)
m_url->MakeFocus(true); m_url->MakeFocus(true);
} }
@@ -431,11 +431,11 @@ void LauncherWindow::newTab(const BString& url, bool select)
// #pragma mark - Notification API // #pragma mark - Notification API
void LauncherWindow::navigationRequested(const BString& url, BWebView* view) void LauncherWindow::NavigationRequested(const BString& url, BWebView* view)
{ {
} }
void LauncherWindow::newWindowRequested(const BString& url) void LauncherWindow::NewWindowRequested(const BString& url)
{ {
// Always open new windows in the application thread, since // Always open new windows in the application thread, since
// creating a BWebView will try to grab the application lock. // creating a BWebView will try to grab the application lock.
@@ -449,16 +449,16 @@ void LauncherWindow::newWindowRequested(const BString& url)
be_app->PostMessage(&message); be_app->PostMessage(&message);
} }
void LauncherWindow::loadNegotiating(const BString& url, BWebView* view) void LauncherWindow::LoadNegotiating(const BString& url, BWebView* view)
{ {
BString status("Requesting: "); BString status("Requesting: ");
status << url; status << url;
statusChanged(status, view); StatusChanged(status, view);
} }
void LauncherWindow::loadCommited(const BString& url, BWebView* view) void LauncherWindow::LoadCommited(const BString& url, BWebView* view)
{ {
if (view != currentWebView()) if (view != CurrentWebView())
return; return;
m_loadedURL = url; m_loadedURL = url;
@@ -469,12 +469,12 @@ void LauncherWindow::loadCommited(const BString& url, BWebView* view)
BString status("Loading: "); BString status("Loading: ");
status << url; status << url;
statusChanged(status, view); StatusChanged(status, view);
} }
void LauncherWindow::loadProgress(float progress, BWebView* view) void LauncherWindow::LoadProgress(float progress, BWebView* view)
{ {
if (view != currentWebView()) if (view != CurrentWebView())
return; return;
if (m_loadingProgressBar) { if (m_loadingProgressBar) {
@@ -484,34 +484,34 @@ void LauncherWindow::loadProgress(float progress, BWebView* view)
} }
} }
void LauncherWindow::loadFailed(const BString& url, BWebView* view) void LauncherWindow::LoadFailed(const BString& url, BWebView* view)
{ {
if (view != currentWebView()) if (view != CurrentWebView())
return; return;
BString status(url); BString status(url);
status << " failed."; status << " failed.";
statusChanged(status, view); StatusChanged(status, view);
if (m_loadingProgressBar && !m_loadingProgressBar->IsHidden()) if (m_loadingProgressBar && !m_loadingProgressBar->IsHidden())
m_loadingProgressBar->Hide(); m_loadingProgressBar->Hide();
} }
void LauncherWindow::loadFinished(const BString& url, BWebView* view) void LauncherWindow::LoadFinished(const BString& url, BWebView* view)
{ {
if (view != currentWebView()) if (view != CurrentWebView())
return; return;
m_loadedURL = url; m_loadedURL = url;
BString status(url); BString status(url);
status << " finished."; status << " finished.";
statusChanged(status, view); StatusChanged(status, view);
if (m_loadingProgressBar && !m_loadingProgressBar->IsHidden()) if (m_loadingProgressBar && !m_loadingProgressBar->IsHidden())
m_loadingProgressBar->Hide(); m_loadingProgressBar->Hide();
} }
void LauncherWindow::resizeRequested(float width, float height, BWebView* view) void LauncherWindow::ResizeRequested(float width, float height, BWebView* view)
{ {
if (view != currentWebView()) if (view != CurrentWebView())
return; return;
// TODO: Ignore request when there is more than one BWebView embedded! // TODO: Ignore request when there is more than one BWebView embedded!
@@ -519,25 +519,25 @@ void LauncherWindow::resizeRequested(float width, float height, BWebView* view)
ResizeTo(width, height); ResizeTo(width, height);
} }
void LauncherWindow::setToolBarsVisible(bool flag, BWebView* view) void LauncherWindow::SetToolBarsVisible(bool flag, BWebView* view)
{ {
// TODO // TODO
// TODO: Ignore request when there is more than one BWebView embedded! // TODO: Ignore request when there is more than one BWebView embedded!
} }
void LauncherWindow::setStatusBarVisible(bool flag, BWebView* view) void LauncherWindow::SetStatusBarVisible(bool flag, BWebView* view)
{ {
// TODO // TODO
// TODO: Ignore request when there is more than one BWebView embedded! // TODO: Ignore request when there is more than one BWebView embedded!
} }
void LauncherWindow::setMenuBarVisible(bool flag, BWebView* view) void LauncherWindow::SetMenuBarVisible(bool flag, BWebView* view)
{ {
// TODO // TODO
// TODO: Ignore request when there is more than one BWebView embedded! // TODO: Ignore request when there is more than one BWebView embedded!
} }
void LauncherWindow::setResizable(bool flag, BWebView* view) void LauncherWindow::SetResizable(bool flag, BWebView* view)
{ {
// TODO: Ignore request when there is more than one BWebView embedded! // TODO: Ignore request when there is more than one BWebView embedded!
@@ -547,7 +547,7 @@ void LauncherWindow::setResizable(bool flag, BWebView* view)
SetFlags(Flags() | B_NOT_RESIZABLE); SetFlags(Flags() | B_NOT_RESIZABLE);
} }
void LauncherWindow::titleChanged(const BString& title, BWebView* view) void LauncherWindow::TitleChanged(const BString& title, BWebView* view)
{ {
for (int32 i = 0; i < m_tabView->CountTabs(); i++) { for (int32 i = 0; i < m_tabView->CountTabs(); i++) {
if (m_tabView->ViewForTab(i) == view) { if (m_tabView->ViewForTab(i) == view) {
@@ -556,25 +556,25 @@ void LauncherWindow::titleChanged(const BString& title, BWebView* view)
break; break;
} }
} }
if (view != currentWebView()) if (view != CurrentWebView())
return; return;
updateTitle(title); updateTitle(title);
} }
void LauncherWindow::statusChanged(const BString& statusText, BWebView* view) void LauncherWindow::StatusChanged(const BString& statusText, BWebView* view)
{ {
if (view != currentWebView()) if (view != CurrentWebView())
return; return;
if (m_statusText) if (m_statusText)
m_statusText->SetText(statusText.String()); m_statusText->SetText(statusText.String());
} }
void LauncherWindow::navigationCapabilitiesChanged(bool canGoBackward, void LauncherWindow::NavigationCapabilitiesChanged(bool canGoBackward,
bool canGoForward, bool canStop, BWebView* view) bool canGoForward, bool canStop, BWebView* view)
{ {
if (view != currentWebView()) if (view != CurrentWebView())
return; return;
if (m_BackButton) if (m_BackButton)
@@ -583,12 +583,12 @@ void LauncherWindow::navigationCapabilitiesChanged(bool canGoBackward,
m_ForwardButton->SetEnabled(canGoForward); m_ForwardButton->SetEnabled(canGoForward);
} }
void LauncherWindow::updateGlobalHistory(const BString& url) void LauncherWindow::UpdateGlobalHistory(const BString& url)
{ {
BrowsingHistory::defaultInstance()->addItem(BrowsingHistoryItem(url)); BrowsingHistory::defaultInstance()->addItem(BrowsingHistoryItem(url));
} }
void LauncherWindow::authenticationChallenge(BMessage* message) void LauncherWindow::AuthenticationChallenge(BMessage* message)
{ {
BString text; BString text;
bool rememberCredentials = false; bool rememberCredentials = false;
+20 -19
View File
@@ -30,7 +30,7 @@
#ifndef LauncherWindow_h #ifndef LauncherWindow_h
#define LauncherWindow_h #define LauncherWindow_h
#include "WebViewWindow.h" #include "WebWindow.h"
#include <Messenger.h> #include <Messenger.h>
#include <String.h> #include <String.h>
@@ -58,7 +58,7 @@ enum {
SHOW_DOWNLOAD_WINDOW = 'sdwd' SHOW_DOWNLOAD_WINDOW = 'sdwd'
}; };
class LauncherWindow : public WebViewWindow { class LauncherWindow : public BWebWindow {
public: public:
LauncherWindow(BRect frame, const BMessenger& downloadListener, LauncherWindow(BRect frame, const BMessenger& downloadListener,
ToolbarPolicy = HaveToolbar); ToolbarPolicy = HaveToolbar);
@@ -72,24 +72,25 @@ public:
private: private:
// WebPage notification API implementations // WebPage notification API implementations
virtual void navigationRequested(const BString& url, BWebView* view); virtual void NavigationRequested(const BString& url, BWebView* view);
virtual void newWindowRequested(const BString& url); virtual void NewWindowRequested(const BString& url);
virtual void loadNegotiating(const BString& url, BWebView* view); virtual void LoadNegotiating(const BString& url, BWebView* view);
virtual void loadCommited(const BString& url, BWebView* view); virtual void LoadCommited(const BString& url, BWebView* view);
virtual void loadProgress(float progress, BWebView* view); virtual void LoadProgress(float progress, BWebView* view);
virtual void loadFailed(const BString& url, BWebView* view); virtual void LoadFailed(const BString& url, BWebView* view);
virtual void loadFinished(const BString& url, BWebView* view); virtual void LoadFinished(const BString& url, BWebView* view);
virtual void titleChanged(const BString& title, BWebView* view); virtual void TitleChanged(const BString& title, BWebView* view);
virtual void resizeRequested(float width, float height, BWebView* view); virtual void ResizeRequested(float width, float height, BWebView* view);
virtual void setToolBarsVisible(bool flag, BWebView* view); virtual void SetToolBarsVisible(bool flag, BWebView* view);
virtual void setStatusBarVisible(bool flag, BWebView* view); virtual void SetStatusBarVisible(bool flag, BWebView* view);
virtual void setMenuBarVisible(bool flag, BWebView* view); virtual void SetMenuBarVisible(bool flag, BWebView* view);
virtual void setResizable(bool flag, BWebView* view); virtual void SetResizable(bool flag, BWebView* view);
virtual void statusChanged(const BString& status, BWebView* view); virtual void StatusChanged(const BString& status, BWebView* view);
virtual void navigationCapabilitiesChanged(bool canGoBackward, virtual void NavigationCapabilitiesChanged(bool canGoBackward,
bool canGoForward, bool canStop, BWebView* view); bool canGoForward, bool canStop, BWebView* view);
virtual void updateGlobalHistory(const BString& url); virtual void UpdateGlobalHistory(const BString& url);
virtual void authenticationChallenge(BMessage* challenge); virtual void AuthenticationChallenge(BMessage* challenge);
void updateTitle(const BString &title); void updateTitle(const BString &title);
private: private: