diff options
author | beng@google.com <beng@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-07-31 00:42:17 +0000 |
---|---|---|
committer | beng@google.com <beng@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-07-31 00:42:17 +0000 |
commit | b2a4b9f96997dc3b929b5b9930325a030a8294e3 (patch) | |
tree | 3b18dd4002b9f6b681dd8256783f9d308591568f /chrome/browser/views | |
parent | cd5241ff75071da8e4345e81ebc220e17505a306 (diff) | |
download | chromium_src-b2a4b9f96997dc3b929b5b9930325a030a8294e3.zip chromium_src-b2a4b9f96997dc3b929b5b9930325a030a8294e3.tar.gz chromium_src-b2a4b9f96997dc3b929b5b9930325a030a8294e3.tar.bz2 |
Move dialog-specific aspects of ClientView into a new subclass DialogClientView.
ClientView becomes a generic representation of the View that occupies the "client area" of a window. All Windows now require a Client View (though they can use the default).
Adjust WindowDelegate to provide a method for constructing the ClientView for a Window. The DialogDelegate overrides this to construct the DialogClientView. In the future, other specialized delegates will construct ClientViews specific to them, e.g. WizardDelegate would construct WizardClientView.
Adjust the Window Init method to set up this new required Client View, and make some tweaks to CustomFrameWindow to make all this work.
Remove all traces of dialog specific handling in Window into DialogClientView.
B=1280060
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@153 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/views')
-rw-r--r-- | chrome/browser/views/about_chrome_view.cc | 2 | ||||
-rw-r--r-- | chrome/browser/views/bookmark_editor_view.cc | 2 | ||||
-rw-r--r-- | chrome/browser/views/bug_report_view.cc | 2 | ||||
-rw-r--r-- | chrome/browser/views/clear_browsing_data.cc | 4 | ||||
-rw-r--r-- | chrome/browser/views/constrained_window_impl.cc | 56 | ||||
-rw-r--r-- | chrome/browser/views/constrained_window_impl.h | 9 | ||||
-rw-r--r-- | chrome/browser/views/edit_keyword_controller.cc | 4 | ||||
-rw-r--r-- | chrome/browser/views/first_run_view_base.cc | 9 | ||||
-rw-r--r-- | chrome/browser/views/input_window.cc | 4 | ||||
-rw-r--r-- | chrome/browser/views/shelf_item_dialog.cc | 4 |
10 files changed, 40 insertions, 56 deletions
diff --git a/chrome/browser/views/about_chrome_view.cc b/chrome/browser/views/about_chrome_view.cc index 4ad5908..bc632cd 100644 --- a/chrome/browser/views/about_chrome_view.cc +++ b/chrome/browser/views/about_chrome_view.cc @@ -489,5 +489,5 @@ void AboutChromeView::UpdateStatus(GoogleUpdateUpgradeResult result, // Check button may have appeared/disappeared. We cannot call this during // ViewHierarchyChanged because the |window()| pointer hasn't been set yet. if (window()) - window()->UpdateDialogButtons(); + GetDialogClientView()->UpdateDialogButtons(); } diff --git a/chrome/browser/views/bookmark_editor_view.cc b/chrome/browser/views/bookmark_editor_view.cc index da5a92d..8f6ae2c 100644 --- a/chrome/browser/views/bookmark_editor_view.cc +++ b/chrome/browser/views/bookmark_editor_view.cc @@ -391,7 +391,7 @@ void BookmarkEditorView::UserInputChanged() { url_tf_.SetBackgroundColor(kErrorColor); else url_tf_.SetDefaultBackgroundColor(); - window()->UpdateDialogButtons(); + GetDialogClientView()->UpdateDialogButtons(); } void BookmarkEditorView::NewGroup() { diff --git a/chrome/browser/views/bug_report_view.cc b/chrome/browser/views/bug_report_view.cc index 45023e5..b46235f 100644 --- a/chrome/browser/views/bug_report_view.cc +++ b/chrome/browser/views/bug_report_view.cc @@ -278,7 +278,7 @@ void BugReportView::ItemChanged(ChromeViews::ComboBox* combo_box, include_page_image_checkbox_->SetEnabled(!is_phishing_report); include_page_image_checkbox_->SetIsSelected(!is_phishing_report); - window()->UpdateDialogButtons(); + GetDialogClientView()->UpdateDialogButtons(); } void BugReportView::ContentsChanged(ChromeViews::TextField* sender, diff --git a/chrome/browser/views/clear_browsing_data.cc b/chrome/browser/views/clear_browsing_data.cc index b3721ab..2526182 100644 --- a/chrome/browser/views/clear_browsing_data.cc +++ b/chrome/browser/views/clear_browsing_data.cc @@ -322,7 +322,7 @@ std::wstring ClearBrowsingDataView::GetItemAt(ChromeViews::ComboBox* source, void ClearBrowsingDataView::ButtonPressed(ChromeViews::NativeButton* sender) { // When no checkbox is checked we should not have the action button enabled. // This forces the button to evaluate what state they should be in. - window()->UpdateDialogButtons(); + GetDialogClientView()->UpdateDialogButtons(); } //////////////////////////////////////////////////////////////////////////////// @@ -355,7 +355,7 @@ void ClearBrowsingDataView::UpdateControlEnabledState() { throbber_->Stop(); // Make sure to update the state for OK and Cancel buttons. - window()->UpdateDialogButtons(); + GetDialogClientView()->UpdateDialogButtons(); } // Convenience method that returns true if the supplied checkbox is selected diff --git a/chrome/browser/views/constrained_window_impl.cc b/chrome/browser/views/constrained_window_impl.cc index f666b50..96a63588 100644 --- a/chrome/browser/views/constrained_window_impl.cc +++ b/chrome/browser/views/constrained_window_impl.cc @@ -256,7 +256,6 @@ class ConstrainedWindowNonClientView void SetShowThrobber(bool show_throbber); // Overridden from ChromeViews::NonClientView: - virtual void Init(ChromeViews::ClientView* client_view); virtual gfx::Rect CalculateClientAreaBounds(int width, int height) const; virtual gfx::Size CalculateWindowSizeForClientSize(int width, int height) const; @@ -300,11 +299,6 @@ class ConstrainedWindowNonClientView void UpdateLocationBar(); bool ShouldDisplayURLField() const; - // The View that provides the background for the window, and optionally - // dialog buttons. Note: the non-client view does _not_ own this view, the - // container does. - ChromeViews::ClientView* client_view_; - ConstrainedWindowImpl* container_; ChromeViews::WindowDelegate* window_delegate_; @@ -540,12 +534,6 @@ void ConstrainedWindowNonClientView::Run() { //////////////////////////////////////////////////////////////////////////////// // ConstrainedWindowNonClientView, ChromeViews::NonClientView implementation: -void ConstrainedWindowNonClientView::Init( - ChromeViews::ClientView* client_view) { - client_view_ = client_view; - AddChildView(client_view_); -} - gfx::Rect ConstrainedWindowNonClientView::CalculateClientAreaBounds( int width, int height) const { @@ -578,15 +566,9 @@ int ConstrainedWindowNonClientView::NonClientHitTest(const gfx::Point& point) { // First see if it's within the grow box area, since that overlaps the client // bounds. - if (client_view_->PointIsInSizeBox(point)) - return HTBOTTOMRIGHT; - - // Then see if it's within the client area. - if (client_view_) { - client_view_->GetBounds(&bounds); - if (bounds.PtInRect(test_point)) - return HTCLIENT; - } + int component = container_->client_view()->NonClientHitTest(point); + if (component != HTNOWHERE) + return component; // Then see if the point is within any of the window controls. close_button_->GetBounds(&bounds); @@ -596,10 +578,10 @@ int ConstrainedWindowNonClientView::NonClientHitTest(const gfx::Point& point) { if (bounds.PtInRect(test_point)) return HTSYSMENU; - int component = GetHTComponentForFrame(point, kResizeAreaSize, - kResizeAreaCornerSize, - kResizeAreaNorthSize, - window_delegate_->CanResize()); + component = GetHTComponentForFrame(point, kResizeAreaSize, + kResizeAreaCornerSize, + kResizeAreaNorthSize, + window_delegate_->CanResize()); if (component == HTNOWHERE) { // Finally fall back to the caption. GetBounds(&bounds, APPLY_MIRRORING_TRANSFORMATION); @@ -692,26 +674,28 @@ void ConstrainedWindowNonClientView::Layout() { location_bar_height); location_bar_->Layout(); } - if (client_view_) - client_view_->SetBounds(client_bounds_.ToRECT()); + container_->client_view()->SetBounds(client_bounds_.ToRECT()); } void ConstrainedWindowNonClientView::GetPreferredSize(CSize* out) { DCHECK(out); - if (client_view_) { - client_view_->GetPreferredSize(out); - out->cx += 2 * kWindowHorizontalBorderSize; - out->cy += CalculateNonClientHeight(ShouldDisplayURLField()) + - kWindowVerticalBorderSize; - } + container_->client_view()->GetPreferredSize(out); + out->cx += 2 * kWindowHorizontalBorderSize; + out->cy += CalculateNonClientHeight(ShouldDisplayURLField()) + + kWindowVerticalBorderSize; } void ConstrainedWindowNonClientView::ViewHierarchyChanged(bool is_add, View *parent, View *child) { - if (is_add && location_bar_ && GetViewContainer() && - !(location_bar_->IsInitialized())) { - location_bar_->Init(); + if (is_add && GetViewContainer()) { + // Add our Client View as we are added to the ViewContainer so that if we + // are subsequently resized all the parent-child relationships are + // established. + if (is_add && GetViewContainer() && child == this) + AddChildView(container_->client_view()); + if (location_bar_ && !location_bar_->IsInitialized()) + location_bar_->Init(); } } diff --git a/chrome/browser/views/constrained_window_impl.h b/chrome/browser/views/constrained_window_impl.h index 9e8c0b3..31a6d04 100644 --- a/chrome/browser/views/constrained_window_impl.h +++ b/chrome/browser/views/constrained_window_impl.h @@ -32,12 +32,15 @@ #include "chrome/browser/constrained_window.h" #include "chrome/browser/tab_contents_delegate.h" -#include "chrome/views/client_view.h" #include "chrome/views/custom_frame_window.h" class ConstrainedTabContentsWindowDelegate; class ConstrainedWindowAnimation; class ConstrainedWindowNonClientView; +namespace ChromeViews { +class HWNDView; +class WindowDelegate; +} /////////////////////////////////////////////////////////////////////////////// // ConstrainedWindowImpl @@ -123,6 +126,8 @@ class ConstrainedWindowImpl : public ConstrainedWindow, virtual void OnWindowPosChanged(WINDOWPOS* window_pos); private: + friend class ConstrainedWindow; + // Use the static factory methods on ConstrainedWindow to construct a // ConstrainedWindow. ConstrainedWindowImpl(TabContents* owner, @@ -132,8 +137,6 @@ class ConstrainedWindowImpl : public ConstrainedWindow, ChromeViews::WindowDelegate* window_delegate); void Init(TabContents* owner); - friend class ConstrainedWindow; - // Called after changing either the anchor point or titlebar // visibility of a suppressed popup. This does the actual resizing. // diff --git a/chrome/browser/views/edit_keyword_controller.cc b/chrome/browser/views/edit_keyword_controller.cc index 8fe9b00..982b6d2 100644 --- a/chrome/browser/views/edit_keyword_controller.cc +++ b/chrome/browser/views/edit_keyword_controller.cc @@ -81,7 +81,7 @@ void EditKeywordController::Show() { ChromeViews::Window::CreateChromeWindow(::IsWindow(parent_) ? parent_ : NULL, gfx::Rect(), this); window()->Show(); - window()->UpdateDialogButtons(); + GetDialogClientView()->UpdateDialogButtons(); title_tf_->SelectAll(); title_tf_->RequestFocus(); } @@ -183,7 +183,7 @@ ChromeViews::View* EditKeywordController::GetContentsView() { void EditKeywordController::ContentsChanged(TextField* sender, const std::wstring& new_contents) { - window()->UpdateDialogButtons(); + GetDialogClientView()->UpdateDialogButtons(); UpdateImageViews(); } diff --git a/chrome/browser/views/first_run_view_base.cc b/chrome/browser/views/first_run_view_base.cc index 4ee8aceb..9f8044c 100644 --- a/chrome/browser/views/first_run_view_base.cc +++ b/chrome/browser/views/first_run_view_base.cc @@ -180,12 +180,9 @@ int FirstRunViewBase::GetDefaultImportItems() const { void FirstRunViewBase::DisableButtons() { window()->EnableClose(false); - ChromeViews::ClientView* cv = - reinterpret_cast<ChromeViews::ClientView*>(GetParent()); - if (cv) { - cv->ok_button()->SetEnabled(false); - cv->cancel_button()->SetEnabled(false); - } + ChromeViews::DialogClientView* dcv = GetDialogClientView(); + dcv->ok_button()->SetEnabled(false); + dcv->cancel_button()->SetEnabled(false); } bool FirstRunViewBase::CreateDesktopShortcut() { diff --git a/chrome/browser/views/input_window.cc b/chrome/browser/views/input_window.cc index f4c560e..2576139 100644 --- a/chrome/browser/views/input_window.cc +++ b/chrome/browser/views/input_window.cc @@ -131,7 +131,7 @@ ChromeViews::View* ContentView::GetContentsView() { void ContentView::ContentsChanged(ChromeViews::TextField* sender, const std::wstring& new_contents) { - window()->UpdateDialogButtons(); + GetDialogClientView()->UpdateDialogButtons(); } /////////////////////////////////////////////////////////////////////////////// @@ -187,6 +187,6 @@ ChromeViews::Window* CreateInputWindow(HWND parent_hwnd, ChromeViews::Window* window = ChromeViews::Window::CreateChromeWindow(parent_hwnd, gfx::Rect(), new ContentView(delegate)); - window->UpdateDialogButtons(); + window->client_view()->AsDialogClientView()->UpdateDialogButtons(); return window; } diff --git a/chrome/browser/views/shelf_item_dialog.cc b/chrome/browser/views/shelf_item_dialog.cc index 670453a..2c3de48 100644 --- a/chrome/browser/views/shelf_item_dialog.cc +++ b/chrome/browser/views/shelf_item_dialog.cc @@ -413,7 +413,7 @@ void ShelfItemDialog::ContentsChanged(ChromeViews::TextField* sender, // so we reset the expected handle to an impossible value. if (sender == title_field_) expected_title_handle_ = 0; - window()->UpdateDialogButtons(); + GetDialogClientView()->UpdateDialogButtons(); } bool ShelfItemDialog::Accept() { @@ -493,7 +493,7 @@ void ShelfItemDialog::OnSelectionChanged() { UTF8ToWide(url_table_model_->GetURL(selection).spec())); if (title_field_) title_field_->SetText(url_table_model_->GetTitle(selection)); - window()->UpdateDialogButtons(); + GetDialogClientView()->UpdateDialogButtons(); } } |