diff options
Diffstat (limited to 'chrome/views/custom_frame_window.cc')
-rw-r--r-- | chrome/views/custom_frame_window.cc | 74 |
1 files changed, 18 insertions, 56 deletions
diff --git a/chrome/views/custom_frame_window.cc b/chrome/views/custom_frame_window.cc index a7434aa..8c6bf98 100644 --- a/chrome/views/custom_frame_window.cc +++ b/chrome/views/custom_frame_window.cc @@ -41,6 +41,7 @@ #include "chrome/views/button.h" #include "chrome/views/client_view.h" #include "chrome/views/native_button.h" +#include "chrome/views/non_client_view.h" #include "chrome/views/window_delegate.h" #include "generated_resources.h" @@ -229,7 +230,7 @@ ChromeFont InactiveWindowResources::title_font_; // rendering the non-standard window caption, border, and controls. // //////////////////////////////////////////////////////////////////////////////// -class DefaultNonClientView : public CustomFrameWindow::NonClientView, +class DefaultNonClientView : public NonClientView, public BaseButton::ButtonListener { public: explicit DefaultNonClientView(CustomFrameWindow* container); @@ -241,7 +242,7 @@ class DefaultNonClientView : public CustomFrameWindow::NonClientView, virtual gfx::Size CalculateWindowSizeForClientSize(int width, int height) const; virtual CPoint GetSystemMenuPoint() const; - virtual int HitTest(const gfx::Point& point); + virtual int NonClientHitTest(const gfx::Point& point); virtual void GetWindowMask(const gfx::Size& size, gfx::Path* window_mask); virtual void EnableClose(bool enable); @@ -433,7 +434,7 @@ CPoint DefaultNonClientView::GetSystemMenuPoint() const { // that bound are mirrored if the View uses right-to-left UI layout. This is // why this function passes APPLY_MIRRORING_TRANSFORMATION as the |settings| // whenever it calls GetBounds(). -int DefaultNonClientView::HitTest(const gfx::Point& point) { +int DefaultNonClientView::NonClientHitTest(const gfx::Point& point) { CRect bounds; CPoint test_point = point.ToPOINT(); @@ -466,59 +467,20 @@ int DefaultNonClientView::HitTest(const gfx::Point& point) { if (bounds.PtInRect(test_point)) return HTSYSMENU; - // Then see if the point is within the resize boundaries. - int width = GetWidth(); - int height = GetHeight(); - int component = HTNOWHERE; - if (point.x() < kResizeAreaSize) { - if (point.y() < kResizeAreaCornerSize) { - component = HTTOPLEFT; - } else if (point.y() >= (height - kResizeAreaCornerSize)) { - component = HTBOTTOMLEFT; - } else { - component = HTLEFT; - } - } else if (point.x() < kResizeAreaCornerSize) { - if (point.y() < kResizeAreaNorthSize) { - component = HTTOPLEFT; - } else if (point.y() >= (height - kResizeAreaSize)) { - component = HTBOTTOMLEFT; - } - } else if (point.x() >= (width - kResizeAreaSize)) { - if (point.y() < kResizeAreaCornerSize) { - component = HTTOPRIGHT; - } else if (point.y() >= (height - kResizeAreaCornerSize)) { - component = HTBOTTOMRIGHT; - } else if (point.x() >= (width - kResizeAreaSize)) { - component = HTRIGHT; - } - } else if (point.x() >= (width - kResizeAreaCornerSize)) { - if (point.y() < kResizeAreaNorthSize) { - component = HTTOPRIGHT; - } else if (point.y() >= (height - kResizeAreaSize)) { - component = HTBOTTOMRIGHT; - } - } else if (point.y() < kResizeAreaNorthSize) { - component = HTTOP; - } else if (point.y() >= (height - kResizeAreaSize)) { - component = HTBOTTOM; - } - - // If the window can't be resized, there are no resize boundaries, just - // window borders. - if (component != HTNOWHERE) { - if (!container_->window_delegate()->CanResize()) { - return HTBORDER; - } - return component; + int component = GetHTComponentForFrame( + point, + kResizeAreaSize, + kResizeAreaCornerSize, + kResizeAreaNorthSize, + container_->window_delegate()->CanResize()); + if (component == HTNOWHERE) { + // Finally fall back to the caption. + GetBounds(&bounds, APPLY_MIRRORING_TRANSFORMATION); + if (bounds.PtInRect(test_point)) + component = HTCAPTION; + // Otherwise, the point is outside the window's bounds. } - - // Finally fall back to the caption. - GetBounds(&bounds, APPLY_MIRRORING_TRANSFORMATION); - if (bounds.PtInRect(test_point)) - return HTCAPTION; - // The point is outside the window's bounds. - return HTNOWHERE; + return component; } void DefaultNonClientView::GetWindowMask(const gfx::Size& size, @@ -1016,7 +978,7 @@ LRESULT CustomFrameWindow::OnNCHitTest(const CPoint& point) { // NC points are in screen coordinates. CPoint temp = point; MapWindowPoints(HWND_DESKTOP, GetHWND(), &temp, 1); - return non_client_view_->HitTest(gfx::Point(temp.x, temp.y)); + return non_client_view_->NonClientHitTest(gfx::Point(temp.x, temp.y)); } LRESULT CustomFrameWindow::OnNCMouseMove(UINT flags, const CPoint& point) { |