Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(157)

Side by Side Diff: ui/views/window/dialog_client_view.cc

Issue 8597015: Add a new GetSystemColor method to native theme. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix win build Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« ui/gfx/native_theme_win.cc ('K') | « ui/gfx/native_theme_win.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/views/window/dialog_client_view.h" 5 #include "ui/views/window/dialog_client_view.h"
6 6
7 #include "build/build_config.h" 7 #include "build/build_config.h"
8 8
9 #if defined(OS_WIN) 9 #if defined(OS_WIN)
10 #include <windows.h> 10 #include <windows.h>
11 #include <uxtheme.h> 11 #include <uxtheme.h>
12 #include <vsstyle.h> 12 #include <vsstyle.h>
13 #elif defined(TOOLKIT_USES_GTK)
14 #include <gtk/gtk.h>
15 #endif 13 #endif
16 14
17 #include <algorithm> 15 #include <algorithm>
18 16
19 #include "base/utf_string_conversions.h" 17 #include "base/utf_string_conversions.h"
20 #include "grit/ui_strings.h" 18 #include "grit/ui_strings.h"
21 #include "ui/base/hit_test.h" 19 #include "ui/base/hit_test.h"
22 #include "ui/base/keycodes/keyboard_codes.h" 20 #include "ui/base/keycodes/keyboard_codes.h"
23 #include "ui/base/l10n/l10n_util.h" 21 #include "ui/base/l10n/l10n_util.h"
24 #include "ui/base/resource/resource_bundle.h" 22 #include "ui/base/resource/resource_bundle.h"
(...skipping 18 matching lines...) Expand all
43 void UpdateButtonHelper(NativeTextButton* button_view, 41 void UpdateButtonHelper(NativeTextButton* button_view,
44 DialogDelegate* delegate, 42 DialogDelegate* delegate,
45 ui::DialogButton button) { 43 ui::DialogButton button) {
46 string16 label = delegate->GetDialogButtonLabel(button); 44 string16 label = delegate->GetDialogButtonLabel(button);
47 if (!label.empty()) 45 if (!label.empty())
48 button_view->SetText(label); 46 button_view->SetText(label);
49 button_view->SetEnabled(delegate->IsDialogButtonEnabled(button)); 47 button_view->SetEnabled(delegate->IsDialogButtonEnabled(button));
50 button_view->SetVisible(delegate->IsDialogButtonVisible(button)); 48 button_view->SetVisible(delegate->IsDialogButtonVisible(button));
51 } 49 }
52 50
53 #if defined(OS_WIN)
54 void FillViewWithSysColor(gfx::Canvas* canvas, View* view, COLORREF color) {
55 SkColor sk_color =
56 SkColorSetRGB(GetRValue(color), GetGValue(color), GetBValue(color));
57 canvas->FillRect(sk_color, view->GetLocalBounds());
58 }
59 #endif
60
61 // DialogButton ---------------------------------------------------------------- 51 // DialogButton ----------------------------------------------------------------
62 52
63 // DialogButtons is used for the ok/cancel buttons of the window. DialogButton 53 // DialogButtons is used for the ok/cancel buttons of the window. DialogButton
64 // forwards AcceleratorPressed to the delegate. 54 // forwards AcceleratorPressed to the delegate.
65 55
66 class DialogButton : public NativeTextButton { 56 class DialogButton : public NativeTextButton {
67 public: 57 public:
68 DialogButton(ButtonListener* listener, 58 DialogButton(ButtonListener* listener,
69 Widget* owner, 59 Widget* owner,
70 ui::DialogButton type, 60 ui::DialogButton type,
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 } 297 }
308 298
309 const DialogClientView* DialogClientView::AsDialogClientView() const { 299 const DialogClientView* DialogClientView::AsDialogClientView() const {
310 return this; 300 return this;
311 } 301 }
312 302
313 //////////////////////////////////////////////////////////////////////////////// 303 ////////////////////////////////////////////////////////////////////////////////
314 // DialogClientView, View overrides: 304 // DialogClientView, View overrides:
315 305
316 void DialogClientView::OnPaint(gfx::Canvas* canvas) { 306 void DialogClientView::OnPaint(gfx::Canvas* canvas) {
317 #if defined(OS_WIN) 307 SkColor bg_color = gfx::NativeTheme::instance()->
318 FillViewWithSysColor(canvas, this, GetSysColor(COLOR_3DFACE)); 308 GetSystemColor(gfx::NativeTheme::kDialogBackgroundColorId);
Ben Goodger (Google) 2011/11/21 18:59:59 reformat as: gfx::NativeTheme::instance()->GetSys
benrg 2011/11/21 19:54:20 Done.
319 #elif defined(USE_WAYLAND) || defined(USE_AURA) 309 canvas->FillRect(bg_color, GetLocalBounds());
320 SkColor sk_color = SkColorSetARGB(200, 255, 255, 255);
321 canvas->FillRect(sk_color, GetLocalBounds());
322 #else
323 GtkWidget* widget = GetWidget()->GetNativeView();
324 if (GTK_IS_WINDOW(widget)) {
325 GtkStyle* window_style = gtk_widget_get_style(widget);
326 canvas->FillRect(gfx::GdkColorToSkColor(window_style->bg[GTK_STATE_NORMAL]),
327 GetLocalBounds());
328 }
329 #endif
330 } 310 }
331 311
332 void DialogClientView::PaintChildren(gfx::Canvas* canvas) { 312 void DialogClientView::PaintChildren(gfx::Canvas* canvas) {
333 View::PaintChildren(canvas); 313 View::PaintChildren(canvas);
334 if (!GetWidget()->IsMaximized() && !GetWidget()->IsMinimized()) 314 if (!GetWidget()->IsMaximized() && !GetWidget()->IsMinimized())
335 PaintSizeBox(canvas); 315 PaintSizeBox(canvas);
336 } 316 }
337 317
338 void DialogClientView::Layout() { 318 void DialogClientView::Layout() {
339 if (has_dialog_buttons()) 319 if (has_dialog_buttons())
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
582 void DialogClientView::InitClass() { 562 void DialogClientView::InitClass() {
583 static bool initialized = false; 563 static bool initialized = false;
584 if (!initialized) { 564 if (!initialized) {
585 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); 565 ResourceBundle& rb = ResourceBundle::GetSharedInstance();
586 dialog_button_font_ = new gfx::Font(rb.GetFont(ResourceBundle::BaseFont)); 566 dialog_button_font_ = new gfx::Font(rb.GetFont(ResourceBundle::BaseFont));
587 initialized = true; 567 initialized = true;
588 } 568 }
589 } 569 }
590 570
591 } // namespace views 571 } // namespace views
OLDNEW
« ui/gfx/native_theme_win.cc ('K') | « ui/gfx/native_theme_win.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698