Skip to content

Commit

Permalink
get rid of buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
yong z committed Jan 13, 2012
1 parent 512e1db commit 66fb61f
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 109 deletions.
44 changes: 0 additions & 44 deletions cefclient/cefclient_win.cpp
Expand Up @@ -287,52 +287,8 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)

// Create the child windows used for navigation
RECT rect;
int x = 0;

GetClientRect(hWnd, &rect);

backWnd = CreateWindow(L"BUTTON", L"Back",
WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON
| WS_DISABLED, x, 0, BUTTON_WIDTH, URLBAR_HEIGHT,
hWnd, (HMENU) IDC_NAV_BACK, hInst, 0);
x += BUTTON_WIDTH;

forwardWnd = CreateWindow(L"BUTTON", L"Forward",
WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON
| WS_DISABLED, x, 0, BUTTON_WIDTH,
URLBAR_HEIGHT, hWnd, (HMENU) IDC_NAV_FORWARD,
hInst, 0);
x += BUTTON_WIDTH;

reloadWnd = CreateWindow(L"BUTTON", L"Reload",
WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON
| WS_DISABLED, x, 0, BUTTON_WIDTH,
URLBAR_HEIGHT, hWnd, (HMENU) IDC_NAV_RELOAD,
hInst, 0);
x += BUTTON_WIDTH;

stopWnd = CreateWindow(L"BUTTON", L"Stop",
WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON
| WS_DISABLED, x, 0, BUTTON_WIDTH, URLBAR_HEIGHT,
hWnd, (HMENU) IDC_NAV_STOP, hInst, 0);
x += BUTTON_WIDTH;

editWnd = CreateWindow(L"EDIT", 0,
WS_CHILD | WS_VISIBLE | WS_BORDER | ES_LEFT |
ES_AUTOVSCROLL | ES_AUTOHSCROLL| WS_DISABLED,
x, 0, rect.right - BUTTON_WIDTH * 4,
URLBAR_HEIGHT, hWnd, 0, hInst, 0);

// Assign the edit window's WNDPROC to this function so that we can
// capture the enter key
editWndOldProc =
reinterpret_cast<WNDPROC>(GetWindowLongPtr(editWnd, GWLP_WNDPROC));
SetWindowLongPtr(editWnd, GWLP_WNDPROC,
reinterpret_cast<LONG_PTR>(WndProc));
g_handler->SetEditHwnd(editWnd);
g_handler->SetButtonHwnds(backWnd, forwardWnd, reloadWnd, stopWnd);

rect.top += URLBAR_HEIGHT;

CefWindowInfo info;
CefBrowserSettings settings;
Expand Down
33 changes: 1 addition & 32 deletions cefclient/client_handler.cpp
Expand Up @@ -15,11 +15,6 @@
ClientHandler::ClientHandler()
: m_MainHwnd(NULL),
m_BrowserHwnd(NULL),
m_EditHwnd(NULL),
m_BackHwnd(NULL),
m_ForwardHwnd(NULL),
m_StopHwnd(NULL),
m_ReloadHwnd(NULL),
m_bFormElementHasFocus(false)
{
}
Expand Down Expand Up @@ -76,11 +71,6 @@ void ClientHandler::OnLoadStart(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame)
{
REQUIRE_UI_THREAD();

if(m_BrowserHwnd == browser->GetWindowHandle() && frame->IsMain()) {
// We've just started loading a page
SetLoading(true);
}
}

void ClientHandler::OnLoadEnd(CefRefPtr<CefBrowser> browser,
Expand All @@ -91,8 +81,7 @@ void ClientHandler::OnLoadEnd(CefRefPtr<CefBrowser> browser,

if(m_BrowserHwnd == browser->GetWindowHandle() && frame->IsMain()) {
// We've just finished loading a page
SetLoading(false);


CefRefPtr<CefDOMVisitor> visitor = GetDOMVisitor(frame->GetURL());
if(visitor.get())
frame->VisitDOM(visitor);
Expand Down Expand Up @@ -153,8 +142,6 @@ void ClientHandler::OnNavStateChange(CefRefPtr<CefBrowser> browser,
bool canGoForward)
{
REQUIRE_UI_THREAD();

SetNavState(canGoBack, canGoForward);
}

bool ClientHandler::OnConsoleMessage(CefRefPtr<CefBrowser> browser,
Expand Down Expand Up @@ -316,24 +303,6 @@ void ClientHandler::SetMainHwnd(CefWindowHandle hwnd)
m_MainHwnd = hwnd;
}

void ClientHandler::SetEditHwnd(CefWindowHandle hwnd)
{
AutoLock lock_scope(this);
m_EditHwnd = hwnd;
}

void ClientHandler::SetButtonHwnds(CefWindowHandle backHwnd,
CefWindowHandle forwardHwnd,
CefWindowHandle reloadHwnd,
CefWindowHandle stopHwnd)
{
AutoLock lock_scope(this);
m_BackHwnd = backHwnd;
m_ForwardHwnd = forwardHwnd;
m_ReloadHwnd = reloadHwnd;
m_StopHwnd = stopHwnd;
}

std::string ClientHandler::GetLogFile()
{
AutoLock lock_scope(this);
Expand Down
12 changes: 0 additions & 12 deletions cefclient/client_handler.h
Expand Up @@ -180,9 +180,6 @@ class ClientHandler : public CefClient,
void CloseMainWindow();

protected:
void SetLoading(bool isLoading);
void SetNavState(bool canGoBack, bool canGoForward);

// The child browser window
CefRefPtr<CefBrowser> m_Browser;

Expand All @@ -192,15 +189,6 @@ class ClientHandler : public CefClient,
// The child browser window handle
CefWindowHandle m_BrowserHwnd;

// The edit window handle
CefWindowHandle m_EditHwnd;

// The button window handles
CefWindowHandle m_BackHwnd;
CefWindowHandle m_ForwardHwnd;
CefWindowHandle m_StopHwnd;
CefWindowHandle m_ReloadHwnd;

// Support for logging.
std::string m_LogFile;

Expand Down
21 changes: 0 additions & 21 deletions cefclient/client_handler_win.cpp
Expand Up @@ -51,12 +51,6 @@ void ClientHandler::OnAddressChange(CefRefPtr<CefBrowser> browser,
const CefString& url)
{
REQUIRE_UI_THREAD();

if(m_BrowserHwnd == browser->GetWindowHandle() && frame->IsMain())
{
// Set the edit window text
SetWindowText(m_EditHwnd, std::wstring(url).c_str());
}
}

void ClientHandler::OnTitleChange(CefRefPtr<CefBrowser> browser,
Expand Down Expand Up @@ -94,21 +88,6 @@ void ClientHandler::SendNotification(NotificationType type)
PostMessage(m_MainHwnd, WM_COMMAND, id, 0);
}

void ClientHandler::SetLoading(bool isLoading)
{
ASSERT(m_EditHwnd != NULL && m_ReloadHwnd != NULL && m_StopHwnd != NULL);
EnableWindow(m_EditHwnd, TRUE);
EnableWindow(m_ReloadHwnd, !isLoading);
EnableWindow(m_StopHwnd, isLoading);
}

void ClientHandler::SetNavState(bool canGoBack, bool canGoForward)
{
ASSERT(m_BackHwnd != NULL && m_ForwardHwnd != NULL);
EnableWindow(m_BackHwnd, canGoBack);
EnableWindow(m_ForwardHwnd, canGoForward);
}

void ClientHandler::CloseMainWindow()
{
::PostMessage(m_MainHwnd, WM_CLOSE, 0, 0);
Expand Down

0 comments on commit 66fb61f

Please sign in to comment.