summaryrefslogtreecommitdiffstats
path: root/views
diff options
context:
space:
mode:
authorrogerta@chromium.org <rogerta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-04-27 20:39:35 +0000
committerrogerta@chromium.org <rogerta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-04-27 20:39:35 +0000
commitf9e77d7d6dd6ffe2a686ae98d8bba47abd92ad9a (patch)
treecba32fc4a32415221c1a5ea30944a27cbf075761 /views
parent311cb806c0d6eb603d4e29606bf33d83bdea3d22 (diff)
downloadchromium_src-f9e77d7d6dd6ffe2a686ae98d8bba47abd92ad9a.zip
chromium_src-f9e77d7d6dd6ffe2a686ae98d8bba47abd92ad9a.tar.gz
chromium_src-f9e77d7d6dd6ffe2a686ae98d8bba47abd92ad9a.tar.bz2
Step 5 in native theme refactoring
Moved all calls to new API. Kept PaintTextField() still available from the old API since there is one user of the method that is not in views::View specific code, and does not have access to gfx::Canvas and such. Also moved callers of GetThemePartSize() to the new GetPartSize() API. BUG=None TEST=Use the following URL to test all possible controls on web pages: http://www.corp.google.com/~rogerta/no_crawl/widgets_test.html All controls should look and before the same with and without my changes. Also, make sure the chrome UI has not been changed, for example the wrench menu. Review URL: http://codereview.chromium.org/6880107 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@83204 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views')
-rw-r--r--views/controls/menu/menu_config_win.cc61
-rw-r--r--views/controls/tabbed_pane/native_tabbed_pane_win.cc9
-rw-r--r--views/native_theme_painter.cc4
-rw-r--r--views/window/dialog_client_view.cc25
4 files changed, 49 insertions, 50 deletions
diff --git a/views/controls/menu/menu_config_win.cc b/views/controls/menu/menu_config_win.cc
index 0b4334c..f272dc2 100644
--- a/views/controls/menu/menu_config_win.cc
+++ b/views/controls/menu/menu_config_win.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -13,6 +13,7 @@
#include "ui/base/l10n/l10n_util_win.h"
#include "ui/gfx/native_theme_win.h"
+using gfx::NativeTheme;
using gfx::NativeThemeWin;
namespace views {
@@ -32,65 +33,59 @@ MenuConfig* MenuConfig::Create() {
DLOG_ASSERT(font);
config->font = gfx::Font(font);
- HDC dc = GetDC(NULL);
- RECT bounds = { 0, 0, 200, 200 };
- SIZE check_size;
- if (NativeThemeWin::instance()->GetThemePartSize(
- NativeThemeWin::MENU, dc, MENU_POPUPCHECK, MC_CHECKMARKNORMAL,
- &bounds, TS_TRUE, &check_size) == S_OK) {
- config->check_width = check_size.cx;
- config->check_height = check_size.cy;
+ NativeTheme::ExtraParams extra;
+ extra.menu_check.is_radio = false;
+ gfx::Size check_size = NativeTheme::instance()->GetPartSize(
+ NativeTheme::kMenuCheck, NativeTheme::kNormal, extra);
+ if (!check_size.IsEmpty()) {
+ config->check_width = check_size.width();
+ config->check_height = check_size.height();
} else {
config->check_width = GetSystemMetrics(SM_CXMENUCHECK);
config->check_height = GetSystemMetrics(SM_CYMENUCHECK);
}
- SIZE radio_size;
- if (NativeThemeWin::instance()->GetThemePartSize(
- NativeThemeWin::MENU, dc, MENU_POPUPCHECK, MC_BULLETNORMAL, &bounds,
- TS_TRUE, &radio_size) == S_OK) {
- config->radio_width = radio_size.cx;
- config->radio_height = radio_size.cy;
+ extra.menu_check.is_radio = true;
+ gfx::Size radio_size = NativeTheme::instance()->GetPartSize(
+ NativeTheme::kMenuCheck, NativeTheme::kNormal, extra);
+ if (!radio_size.IsEmpty()) {
+ config->radio_width = radio_size.width();
+ config->radio_height = radio_size.height();
} else {
config->radio_width = GetSystemMetrics(SM_CXMENUCHECK);
config->radio_height = GetSystemMetrics(SM_CYMENUCHECK);
}
- SIZE arrow_size;
- if (NativeThemeWin::instance()->GetThemePartSize(
- NativeThemeWin::MENU, dc, MENU_POPUPSUBMENU, MSM_NORMAL, &bounds,
- TS_TRUE, &arrow_size) == S_OK) {
- config->arrow_width = arrow_size.cx;
- config->arrow_height = arrow_size.cy;
+ gfx::Size arrow_size = NativeTheme::instance()->GetPartSize(
+ NativeTheme::kMenuPopupArrow, NativeTheme::kNormal, extra);
+ if (!arrow_size.IsEmpty()) {
+ config->arrow_width = arrow_size.width();
+ config->arrow_height = arrow_size.height();
} else {
// Sadly I didn't see a specify metrics for this.
config->arrow_width = GetSystemMetrics(SM_CXMENUCHECK);
config->arrow_height = GetSystemMetrics(SM_CYMENUCHECK);
}
- SIZE gutter_size;
- if (NativeThemeWin::instance()->GetThemePartSize(
- NativeThemeWin::MENU, dc, MENU_POPUPGUTTER, MSM_NORMAL, &bounds,
- TS_TRUE, &gutter_size) == S_OK) {
- config->gutter_width = gutter_size.cx;
+ gfx::Size gutter_size = NativeTheme::instance()->GetPartSize(
+ NativeTheme::kMenuPopupGutter, NativeTheme::kNormal, extra);
+ if (!gutter_size.IsEmpty()) {
+ config->gutter_width = gutter_size.width();
config->render_gutter = true;
} else {
config->gutter_width = 0;
config->render_gutter = false;
}
- SIZE separator_size;
- if (NativeThemeWin::instance()->GetThemePartSize(
- NativeThemeWin::MENU, dc, MENU_POPUPSEPARATOR, MSM_NORMAL, &bounds,
- TS_TRUE, &separator_size) == S_OK) {
- config->separator_height = separator_size.cy;
+ gfx::Size separator_size = NativeTheme::instance()->GetPartSize(
+ NativeTheme::kMenuPopupSeparator, NativeTheme::kNormal, extra);
+ if (!separator_size.IsEmpty()) {
+ config->separator_height = separator_size.height();
} else {
// -1 makes separator centered.
config->separator_height = GetSystemMetrics(SM_CYMENU) / 2 - 1;
}
- ReleaseDC(NULL, dc);
-
BOOL show_cues;
config->show_mnemonics =
(SystemParametersInfo(SPI_GETKEYBOARDCUES, 0, &show_cues, 0) &&
diff --git a/views/controls/tabbed_pane/native_tabbed_pane_win.cc b/views/controls/tabbed_pane/native_tabbed_pane_win.cc
index 313716f..0054de0 100644
--- a/views/controls/tabbed_pane/native_tabbed_pane_win.cc
+++ b/views/controls/tabbed_pane/native_tabbed_pane_win.cc
@@ -38,10 +38,11 @@ class TabBackground : public Background {
virtual ~TabBackground() {}
virtual void Paint(gfx::Canvas* canvas, View* view) const {
- HDC dc = canvas->BeginPlatformPaint();
- RECT r = {0, 0, view->width(), view->height()};
- gfx::NativeThemeWin::instance()->PaintTabPanelBackground(dc, &r);
- canvas->EndPlatformPaint();
+ gfx::Rect r(0, 0, view->width(), view->height());
+ gfx::NativeTheme::ExtraParams extra;
+ gfx::NativeTheme::instance()->Paint(
+ canvas->AsCanvasSkia(), gfx::NativeTheme::kTabPanelBackground,
+ gfx::NativeTheme::kNormal, r, extra);
}
private:
diff --git a/views/native_theme_painter.cc b/views/native_theme_painter.cc
index 7806f33..a99edea 100644
--- a/views/native_theme_painter.cc
+++ b/views/native_theme_painter.cc
@@ -19,7 +19,9 @@ NativeThemePainter::NativeThemePainter(Delegate* delegate)
gfx::Size NativeThemePainter::GetPreferredSize() {
const gfx::NativeTheme* theme = gfx::NativeTheme::instance();
- return theme->GetPartSize(delegate_->GetThemePart());
+ gfx::NativeTheme::ExtraParams extra;
+ gfx::NativeTheme::State state = delegate_->GetThemeState(&extra);
+ return theme->GetPartSize(delegate_->GetThemePart(), state, extra);
}
void NativeThemePainter::Paint(int w, int h, gfx::Canvas* canvas) {
diff --git a/views/window/dialog_client_view.cc b/views/window/dialog_client_view.cc
index 2f08f96..e2cc5ef 100644
--- a/views/window/dialog_client_view.cc
+++ b/views/window/dialog_client_view.cc
@@ -27,7 +27,7 @@
#include "views/window/window.h"
#if defined(OS_WIN)
-#include "ui/gfx/native_theme_win.h"
+#include "ui/gfx/native_theme.h"
#else
#include "ui/gfx/skia_utils_gtk.h"
#include "views/window/hit_test.h"
@@ -427,23 +427,24 @@ void DialogClientView::PaintSizeBox(gfx::Canvas* canvas) {
if (window()->window_delegate()->CanResize() ||
window()->window_delegate()->CanMaximize()) {
#if defined(OS_WIN)
- HDC dc = canvas->BeginPlatformPaint();
- SIZE gripper_size = { 0, 0 };
- gfx::NativeThemeWin::instance()->GetThemePartSize(
- gfx::NativeThemeWin::STATUS, dc, SP_GRIPPER, 1, NULL, TS_TRUE,
- &gripper_size);
+ gfx::NativeTheme::ExtraParams extra;
+ gfx::Size gripper_size = gfx::NativeTheme::instance()->GetPartSize(
+ gfx::NativeTheme::kWindowResizeGripper, gfx::NativeTheme::kNormal,
+ extra);
// TODO(beng): (http://b/1085509) In "classic" rendering mode, there isn't
// a theme-supplied gripper. We should probably improvise
// something, which would also require changing |gripper_size|
// to have different default values, too...
size_box_bounds_ = GetContentsBounds();
- size_box_bounds_.set_x(size_box_bounds_.right() - gripper_size.cx);
- size_box_bounds_.set_y(size_box_bounds_.bottom() - gripper_size.cy);
- RECT native_bounds = size_box_bounds_.ToRECT();
- gfx::NativeThemeWin::instance()->PaintStatusGripper(
- dc, SP_PANE, 1, 0, &native_bounds);
- canvas->EndPlatformPaint();
+ size_box_bounds_.set_x(size_box_bounds_.right() - gripper_size.width());
+ size_box_bounds_.set_y(size_box_bounds_.bottom() - gripper_size.height());
+
+ gfx::NativeTheme::instance()->Paint(canvas->AsCanvasSkia(),
+ gfx::NativeTheme::kWindowResizeGripper,
+ gfx::NativeTheme::kNormal,
+ size_box_bounds_,
+ extra);
#else
NOTIMPLEMENTED();
// TODO(port): paint size box