diff options
author | beng@google.com <beng@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-07-30 22:30:22 +0000 |
---|---|---|
committer | beng@google.com <beng@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-07-30 22:30:22 +0000 |
commit | cb5d17f2f5c9d4a9777439f58e4a7f6eb049e26f (patch) | |
tree | 8124412fcae98e1e465668bc66a2f97d9fe7b3a4 /chrome/views/custom_frame_window.cc | |
parent | e3dad87db7cab48a8a1109a49fd1119fd98ff6da (diff) | |
download | chromium_src-cb5d17f2f5c9d4a9777439f58e4a7f6eb049e26f.zip chromium_src-cb5d17f2f5c9d4a9777439f58e4a7f6eb049e26f.tar.gz chromium_src-cb5d17f2f5c9d4a9777439f58e4a7f6eb049e26f.tar.bz2 |
Make NonClientView an interface independent of CustomFrameWindow (i.e. move it into its own file).
Rename NonClientView's HitTest method to NonClientHitTest, so it doesn't collide with View's HitTest method.
Also, consolidate some duplicated code between CustomFrameWindow and ConstrainedWindow's non-client view impl.
B=1300864
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@141 0039d316-1c4b-4281-b951-d872f2087c98
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) { |