diff options
author | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-07-15 17:13:33 +0000 |
---|---|---|
committer | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-07-15 17:13:33 +0000 |
commit | fe84b910e02f66451d9b746d03f761aedfa39032 (patch) | |
tree | ba31d5ff4ae9229366bb0675d6dc476fd55645f8 /views/controls | |
parent | ce2d72c6918e9707ef3dc9987369241108ed239f (diff) | |
download | chromium_src-fe84b910e02f66451d9b746d03f761aedfa39032.zip chromium_src-fe84b910e02f66451d9b746d03f761aedfa39032.tar.gz chromium_src-fe84b910e02f66451d9b746d03f761aedfa39032.tar.bz2 |
Convert some more view methods to the ui/views style.
BUG=72040
TEST=none
Review URL: http://codereview.chromium.org/7349021
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@92705 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views/controls')
-rw-r--r-- | views/controls/menu/menu_controller.cc | 8 | ||||
-rw-r--r-- | views/controls/menu/menu_item_view.cc | 14 | ||||
-rw-r--r-- | views/controls/menu/menu_scroll_view_container.cc | 2 | ||||
-rw-r--r-- | views/controls/menu/submenu_view.cc | 10 | ||||
-rw-r--r-- | views/controls/scroll_view.cc | 2 | ||||
-rw-r--r-- | views/controls/single_split_view.cc | 23 | ||||
-rw-r--r-- | views/controls/single_split_view_unittest.cc | 14 | ||||
-rw-r--r-- | views/controls/tabbed_pane/native_tabbed_pane_gtk.cc | 2 | ||||
-rw-r--r-- | views/controls/tabbed_pane/native_tabbed_pane_win.cc | 8 | ||||
-rw-r--r-- | views/controls/textfield/native_textfield_win.cc | 2 |
10 files changed, 41 insertions, 44 deletions
diff --git a/views/controls/menu/menu_controller.cc b/views/controls/menu/menu_controller.cc index d5e3305..b2038da 100644 --- a/views/controls/menu/menu_controller.cc +++ b/views/controls/menu/menu_controller.cc @@ -82,7 +82,7 @@ static View* GetFirstHotTrackedView(View* view) { return view; for (int i = 0; i < view->child_count(); ++i) { - View* hot_view = GetFirstHotTrackedView(view->GetChildViewAt(i)); + View* hot_view = GetFirstHotTrackedView(view->child_at(i)); if (hot_view) return hot_view; } @@ -97,15 +97,13 @@ static View* GetFirstHotTrackedView(View* view) { static View* GetFirstFocusableView(View* view, int start, bool forward) { if (forward) { for (int i = start == -1 ? 0 : start; i < view->child_count(); ++i) { - View* deepest = GetFirstFocusableView(view->GetChildViewAt(i), -1, - forward); + View* deepest = GetFirstFocusableView(view->child_at(i), -1, forward); if (deepest) return deepest; } } else { for (int i = start == -1 ? view->child_count() - 1 : start; i >= 0; --i) { - View* deepest = GetFirstFocusableView(view->GetChildViewAt(i), -1, - forward); + View* deepest = GetFirstFocusableView(view->child_at(i), -1, forward); if (deepest) return deepest; } diff --git a/views/controls/menu/menu_item_view.cc b/views/controls/menu/menu_item_view.cc index a20e725..6c70190 100644 --- a/views/controls/menu/menu_item_view.cc +++ b/views/controls/menu/menu_item_view.cc @@ -289,7 +289,7 @@ void MenuItemView::RemoveMenuItemAt(int index) { DCHECK_LE(0, index); DCHECK_GT(submenu_->child_count(), index); - View* item = submenu_->GetChildViewAt(index); + View* item = submenu_->child_at(index); DCHECK(item); submenu_->RemoveChildView(item); @@ -446,7 +446,7 @@ MenuItemView* MenuItemView::GetMenuItemByID(int id) { if (!HasSubmenu()) return NULL; for (int i = 0; i < GetSubmenu()->child_count(); ++i) { - View* child = GetSubmenu()->GetChildViewAt(i); + View* child = GetSubmenu()->child_at(i); if (child->id() == MenuItemView::kMenuItemViewID) { MenuItemView* result = static_cast<MenuItemView*>(child)-> GetMenuItemByID(id); @@ -487,7 +487,7 @@ void MenuItemView::Layout() { if (child_count() == 1 && GetTitle().size() == 0) { // We only have one child and no title so let the view take over all the // space. - View* child = GetChildViewAt(0); + View* child = child_at(0); gfx::Size size = child->GetPreferredSize(); child->SetBounds(label_start_, GetTopMargin(), size.width(), size.height()); } else { @@ -495,7 +495,7 @@ void MenuItemView::Layout() { // right align start with the last view and progress to the first. for (int i = child_count() - 1, x = width() - item_right_margin_; i >= 0; --i) { - View* child = GetChildViewAt(i); + View* child = child_at(i); int width = child->GetPreferredSize().width(); child->SetBounds(x - width, 0, width, height()); x -= width - kChildXPadding; @@ -667,7 +667,7 @@ void MenuItemView::RemoveEmptyMenus() { // Iterate backwards as we may end up removing views, which alters the child // view count. for (int i = submenu_->child_count() - 1; i >= 0; --i) { - View* child = submenu_->GetChildViewAt(i); + View* child = submenu_->child_at(i); if (child->id() == MenuItemView::kMenuItemViewID) { MenuItemView* menu_item = static_cast<MenuItemView*>(child); if (menu_item->HasSubmenu()) @@ -745,7 +745,7 @@ gfx::Size MenuItemView::GetChildPreferredSize() { return gfx::Size(); if (GetTitle().size() == 0 && child_count() == 1) { - View* child = GetChildViewAt(0); + View* child = child_at(0); return child->GetPreferredSize(); } @@ -753,7 +753,7 @@ gfx::Size MenuItemView::GetChildPreferredSize() { for (int i = 0; i < child_count(); ++i) { if (i) width += kChildXPadding; - width += GetChildViewAt(i)->GetPreferredSize().width(); + width += child_at(i)->GetPreferredSize().width(); } // Return a height of 0 to indicate that we should use the title height // instead. diff --git a/views/controls/menu/menu_scroll_view_container.cc b/views/controls/menu/menu_scroll_view_container.cc index 6aed7cf..5f1b94e 100644 --- a/views/controls/menu/menu_scroll_view_container.cc +++ b/views/controls/menu/menu_scroll_view_container.cc @@ -150,7 +150,7 @@ class MenuScrollViewContainer::MenuScrollView : public View { // Returns the contents, which is the SubmenuView. View* GetContents() { - return GetChildViewAt(0); + return child_at(0); } private: diff --git a/views/controls/menu/submenu_view.cc b/views/controls/menu/submenu_view.cc index 84e4cd1..987cf15 100644 --- a/views/controls/menu/submenu_view.cc +++ b/views/controls/menu/submenu_view.cc @@ -55,7 +55,7 @@ SubmenuView::~SubmenuView() { int SubmenuView::GetMenuItemCount() { int count = 0; for (int i = 0; i < child_count(); ++i) { - if (GetChildViewAt(i)->id() == MenuItemView::kMenuItemViewID) + if (child_at(i)->id() == MenuItemView::kMenuItemViewID) count++; } return count; @@ -63,9 +63,9 @@ int SubmenuView::GetMenuItemCount() { MenuItemView* SubmenuView::GetMenuItemAt(int index) { for (int i = 0, count = 0; i < child_count(); ++i) { - if (GetChildViewAt(i)->id() == MenuItemView::kMenuItemViewID && + if (child_at(i)->id() == MenuItemView::kMenuItemViewID && count++ == index) { - return static_cast<MenuItemView*>(GetChildViewAt(i)); + return static_cast<MenuItemView*>(child_at(i)); } } NOTREACHED(); @@ -91,7 +91,7 @@ void SubmenuView::Layout() { int y = insets.top(); int menu_item_width = width() - insets.width(); for (int i = 0; i < child_count(); ++i) { - View* child = GetChildViewAt(i); + View* child = child_at(i); if (child->IsVisible()) { gfx::Size child_pref_size = child->GetPreferredSize(); child->SetBounds(x, y, menu_item_width, child_pref_size.height()); @@ -108,7 +108,7 @@ gfx::Size SubmenuView::GetPreferredSize() { int max_width = 0; int height = 0; for (int i = 0; i < child_count(); ++i) { - View* child = GetChildViewAt(i); + View* child = child_at(i); gfx::Size child_pref_size = child->IsVisible() ? child->GetPreferredSize() : gfx::Size(); max_width = std::max(max_width, child_pref_size.width()); diff --git a/views/controls/scroll_view.cc b/views/controls/scroll_view.cc index 6a2b912..dd2c650 100644 --- a/views/controls/scroll_view.cc +++ b/views/controls/scroll_view.cc @@ -22,7 +22,7 @@ class Viewport : public View { if (!has_children() || !parent()) return; - View* contents = GetChildViewAt(0); + View* contents = child_at(0); gfx::Rect scroll_rect(rect); scroll_rect.Offset(-contents->x(), -contents->y()); static_cast<ScrollView*>(parent())->ScrollContentsRegionToBeVisible( diff --git a/views/controls/single_split_view.cc b/views/controls/single_split_view.cc index 0397810..5addbb9 100644 --- a/views/controls/single_split_view.cc +++ b/views/controls/single_split_view.cc @@ -49,11 +49,11 @@ void SingleSplitView::Layout() { CalculateChildrenBounds(bounds(), &leading_bounds, &trailing_bounds); if (has_children()) { - if (GetChildViewAt(0)->IsVisible()) - GetChildViewAt(0)->SetBoundsRect(leading_bounds); + if (child_at(0)->IsVisible()) + child_at(0)->SetBoundsRect(leading_bounds); if (child_count() > 1) { - if (GetChildViewAt(1)->IsVisible()) - GetChildViewAt(1)->SetBoundsRect(trailing_bounds); + if (child_at(1)->IsVisible()) + child_at(1)->SetBoundsRect(trailing_bounds); } } @@ -76,7 +76,7 @@ gfx::Size SingleSplitView::GetPreferredSize() { int width = 0; int height = 0; for (int i = 0; i < 2 && i < child_count(); ++i) { - View* view = GetChildViewAt(i); + View* view = child_at(i); gfx::Size pref = view->GetPreferredSize(); if (is_horizontal_) { width += pref.width(); @@ -110,9 +110,8 @@ void SingleSplitView::CalculateChildrenBounds( const gfx::Rect& bounds, gfx::Rect* leading_bounds, gfx::Rect* trailing_bounds) const { - bool is_leading_visible = has_children() && GetChildViewAt(0)->IsVisible(); - bool is_trailing_visible = - child_count() > 1 && GetChildViewAt(1)->IsVisible(); + bool is_leading_visible = has_children() && child_at(0)->IsVisible(); + bool is_trailing_visible = child_count() > 1 && child_at(1)->IsVisible(); if (!is_leading_visible && !is_trailing_visible) { *leading_bounds = gfx::Rect(); @@ -171,7 +170,7 @@ bool SingleSplitView::OnMouseDragged(const MouseEvent& event) { if (is_horizontal_ && base::i18n::IsRTL()) delta_offset *= -1; // Honor the minimum size when resizing. - gfx::Size min = GetChildViewAt(0)->GetMinimumSize(); + gfx::Size min = child_at(0)->GetMinimumSize(); int new_size = std::max(GetPrimaryAxisSize(min.width(), min.height()), drag_info_.initial_divider_offset + delta_offset); @@ -206,15 +205,15 @@ bool SingleSplitView::IsPointInDivider(const gfx::Point& p) { if (child_count() < 2) return false; - if (!GetChildViewAt(0)->IsVisible() || !GetChildViewAt(1)->IsVisible()) + if (!child_at(0)->IsVisible() || !child_at(1)->IsVisible()) return false; int divider_relative_offset; if (is_horizontal_) { divider_relative_offset = - p.x() - GetChildViewAt(base::i18n::IsRTL() ? 1 : 0)->width(); + p.x() - child_at(base::i18n::IsRTL() ? 1 : 0)->width(); } else { - divider_relative_offset = p.y() - GetChildViewAt(0)->height(); + divider_relative_offset = p.y() - child_at(0)->height(); } return (divider_relative_offset >= 0 && divider_relative_offset < kDividerSize); diff --git a/views/controls/single_split_view_unittest.cc b/views/controls/single_split_view_unittest.cc index f880528..c3375d8 100644 --- a/views/controls/single_split_view_unittest.cc +++ b/views/controls/single_split_view_unittest.cc @@ -15,8 +15,8 @@ namespace { static void VerifySplitViewLayout(const views::SingleSplitView& split) { ASSERT_EQ(2, split.child_count()); - const views::View* leading = split.GetChildViewAt(0); - const views::View* trailing = split.GetChildViewAt(1); + const views::View* leading = split.child_at(0); + const views::View* trailing = split.child_at(1); if (split.bounds().IsEmpty()) { EXPECT_TRUE(leading->bounds().IsEmpty()); @@ -113,16 +113,16 @@ TEST(SingleSplitViewTest, Resize) { } // Special cases, one of the child views is hidden. - split.GetChildViewAt(0)->SetVisible(false); + split.child_at(0)->SetVisible(false); split.Layout(); - EXPECT_EQ(split.size(), split.GetChildViewAt(1)->size()); + EXPECT_EQ(split.size(), split.child_at(1)->size()); - split.GetChildViewAt(0)->SetVisible(true); - split.GetChildViewAt(1)->SetVisible(false); + split.child_at(0)->SetVisible(true); + split.child_at(1)->SetVisible(false); split.Layout(); - EXPECT_EQ(split.size(), split.GetChildViewAt(0)->size()); + EXPECT_EQ(split.size(), split.child_at(0)->size()); } } diff --git a/views/controls/tabbed_pane/native_tabbed_pane_gtk.cc b/views/controls/tabbed_pane/native_tabbed_pane_gtk.cc index ac3ff19..37b24d1 100644 --- a/views/controls/tabbed_pane/native_tabbed_pane_gtk.cc +++ b/views/controls/tabbed_pane/native_tabbed_pane_gtk.cc @@ -205,7 +205,7 @@ View* NativeTabbedPaneGtk::GetTabViewAt(int index) { Widget* widget = GetWidgetAt(index); DCHECK(widget); DCHECK_EQ(1, widget->GetRootView()->child_count()); - return widget->GetRootView()->GetChildViewAt(0); + return widget->GetRootView()->child_at(0); } void NativeTabbedPaneGtk::OnSwitchPage(int selected_tab_index) { diff --git a/views/controls/tabbed_pane/native_tabbed_pane_win.cc b/views/controls/tabbed_pane/native_tabbed_pane_win.cc index 829d5a3..5499051 100644 --- a/views/controls/tabbed_pane/native_tabbed_pane_win.cc +++ b/views/controls/tabbed_pane/native_tabbed_pane_win.cc @@ -57,7 +57,7 @@ class TabLayout : public LayoutManager { // Switches to the tab page identified by the given index. void SwitchToPage(View* host, View* page) { for (int i = 0; i < host->child_count(); ++i) { - View* child = host->GetChildViewAt(i); + View* child = host->child_at(i); // The child might not have been laid out yet. if (child == page) child->SetBoundsRect(host->GetContentsBounds()); @@ -77,7 +77,7 @@ class TabLayout : public LayoutManager { virtual void Layout(View* host) { gfx::Rect bounds(host->GetContentsBounds()); for (int i = 0; i < host->child_count(); ++i) { - View* child = host->GetChildViewAt(i); + View* child = host->child_at(i); // We only layout visible children, since it may be expensive. if (child->IsVisible() && child->bounds() != bounds) child->SetBoundsRect(bounds); @@ -88,7 +88,7 @@ class TabLayout : public LayoutManager { // First, query the preferred sizes to determine a good width. int width = 0; for (int i = 0; i < host->child_count(); ++i) { - View* page = host->GetChildViewAt(i); + View* page = host->child_at(i); width = std::max(width, page->GetPreferredSize().width()); } // After we know the width, decide on the height. @@ -98,7 +98,7 @@ class TabLayout : public LayoutManager { virtual int GetPreferredHeightForWidth(View* host, int width) { int height = 0; for (int i = 0; i < host->child_count(); ++i) { - View* page = host->GetChildViewAt(i); + View* page = host->child_at(i); height = std::max(height, page->GetHeightForWidth(width)); } return height; diff --git a/views/controls/textfield/native_textfield_win.cc b/views/controls/textfield/native_textfield_win.cc index c14fb4d..f53e67b 100644 --- a/views/controls/textfield/native_textfield_win.cc +++ b/views/controls/textfield/native_textfield_win.cc @@ -462,7 +462,7 @@ void NativeTextfieldWin::InitializeAccessibilityInfo() { // Try to find the name of this text field. // We expect it to be a Label preceeding this view (if it exists). string16 name; - View* label_view = parent->GetChildViewAt(label_index); + View* label_view = parent->child_at(label_index); if (label_view->GetClassName() == Label::kViewClassName) { ui::AccessibleViewState state; label_view->GetAccessibleState(&state); |