diff options
author | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-24 00:05:06 +0000 |
---|---|---|
committer | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-24 00:05:06 +0000 |
commit | bbcd29efb5a1ed6bf27334454b2e641a306dad0d (patch) | |
tree | 652703ab73a55f9bf55d4cf976a3c1b8d2fec75f /views | |
parent | 8569eafc863900c15ba3df7da5b05ac8ec145ec5 (diff) | |
download | chromium_src-bbcd29efb5a1ed6bf27334454b2e641a306dad0d.zip chromium_src-bbcd29efb5a1ed6bf27334454b2e641a306dad0d.tar.gz chromium_src-bbcd29efb5a1ed6bf27334454b2e641a306dad0d.tar.bz2 |
Make the Clear Browsing Data dialog box look a little nicer.
- Now use GtkCheckButton's own label instead of the hack one used only by windows.
- Render a background for DialogClientView.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/160066
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@21484 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views')
-rw-r--r-- | views/controls/button/checkbox.cc | 31 | ||||
-rw-r--r-- | views/controls/button/checkbox.h | 4 | ||||
-rw-r--r-- | views/controls/button/native_button_gtk.cc | 4 | ||||
-rw-r--r-- | views/controls/button/native_button_gtk.h | 1 | ||||
-rw-r--r-- | views/controls/button/native_button_win.cc | 8 | ||||
-rw-r--r-- | views/controls/button/native_button_win.h | 2 | ||||
-rw-r--r-- | views/controls/button/native_button_wrapper.h | 4 | ||||
-rw-r--r-- | views/window/dialog_client_view.cc | 33 |
8 files changed, 62 insertions, 25 deletions
diff --git a/views/controls/button/checkbox.cc b/views/controls/button/checkbox.cc index 0097251..c3ea2ff 100644 --- a/views/controls/button/checkbox.cc +++ b/views/controls/button/checkbox.cc @@ -57,6 +57,9 @@ gfx::Size Checkbox::GetPreferredSize() { return gfx::Size(); gfx::Size prefsize = native_wrapper_->GetView()->GetPreferredSize(); + if (native_wrapper_->UsesNativeLabel()) + return prefsize; + prefsize.set_width( prefsize.width() + kCheckboxLabelSpacing + kLabelFocusPaddingHorizontal * 2); @@ -72,16 +75,24 @@ void Checkbox::Layout() { if (!native_wrapper_) return; - gfx::Size checkmark_prefsize = native_wrapper_->GetView()->GetPreferredSize(); - int label_x = checkmark_prefsize.width() + kCheckboxLabelSpacing + - kLabelFocusPaddingHorizontal; - label_->SetBounds( - label_x, 0, std::max(0, width() - label_x - kLabelFocusPaddingHorizontal), - height()); - int first_line_height = label_->GetFont().height(); - native_wrapper_->GetView()->SetBounds( - 0, ((first_line_height - checkmark_prefsize.height()) / 2), - checkmark_prefsize.width(), checkmark_prefsize.height()); + if (native_wrapper_->UsesNativeLabel()) { + label_->SetBounds(0, 0, 0, 0); + label_->SetVisible(false); + native_wrapper_->GetView()->SetBounds(0, 0, width(), height()); + } else { + gfx::Size checkmark_prefsize = + native_wrapper_->GetView()->GetPreferredSize(); + int label_x = checkmark_prefsize.width() + kCheckboxLabelSpacing + + kLabelFocusPaddingHorizontal; + label_->SetBounds( + label_x, 0, std::max(0, width() - label_x - + kLabelFocusPaddingHorizontal), + height()); + int first_line_height = label_->GetFont().height(); + native_wrapper_->GetView()->SetBounds( + 0, ((first_line_height - checkmark_prefsize.height()) / 2), + checkmark_prefsize.width(), checkmark_prefsize.height()); + } native_wrapper_->GetView()->Layout(); } diff --git a/views/controls/button/checkbox.h b/views/controls/button/checkbox.h index 86111d1..e515b4f 100644 --- a/views/controls/button/checkbox.h +++ b/views/controls/button/checkbox.h @@ -69,8 +69,8 @@ class Checkbox : public NativeButton { // Called from the constructor to create and configure the checkbox label. void Init(const std::wstring& label_text); - // The checkbox's label. We don't use the OS version because of transparency - // and sizing issues. + // The checkbox's label. We may not be able to use the OS version on some + // platforms because of transparency and sizing issues. Label* label_; // True if the checkbox is checked. diff --git a/views/controls/button/native_button_gtk.cc b/views/controls/button/native_button_gtk.cc index 7bd4da6..4ed3138 100644 --- a/views/controls/button/native_button_gtk.cc +++ b/views/controls/button/native_button_gtk.cc @@ -70,6 +70,10 @@ void NativeButtonGtk::SetFocus() { Focus(); } +bool NativeButtonGtk::UsesNativeLabel() const { + return true; +} + gfx::NativeView NativeButtonGtk::GetTestingHandle() const { return native_view(); } diff --git a/views/controls/button/native_button_gtk.h b/views/controls/button/native_button_gtk.h index 1d0dfc1..4b609d9 100644 --- a/views/controls/button/native_button_gtk.h +++ b/views/controls/button/native_button_gtk.h @@ -23,6 +23,7 @@ class NativeButtonGtk : public NativeControlGtk, public NativeButtonWrapper { virtual void UpdateDefault(); virtual View* GetView(); virtual void SetFocus(); + virtual bool UsesNativeLabel() const; virtual gfx::NativeView GetTestingHandle() const; // Overridden from View: diff --git a/views/controls/button/native_button_win.cc b/views/controls/button/native_button_win.cc index 86dd91f..f134b51 100644 --- a/views/controls/button/native_button_win.cc +++ b/views/controls/button/native_button_win.cc @@ -63,6 +63,10 @@ void NativeButtonWin::SetFocus() { Focus(); } +bool NativeButtonWin::UsesNativeLabel() const { + return true; +} + gfx::NativeView NativeButtonWin::GetTestingHandle() const { return native_view(); } @@ -156,6 +160,10 @@ bool NativeCheckboxWin::OnKeyDown(int vkey) { return false; } +bool NativeCheckboxWin::UsesNativeLabel() const { + return false; +} + //////////////////////////////////////////////////////////////////////////////// // NativeCheckboxWin, NativeButtonWin overrides: diff --git a/views/controls/button/native_button_win.h b/views/controls/button/native_button_win.h index ea7e7cb..2ac0817 100644 --- a/views/controls/button/native_button_win.h +++ b/views/controls/button/native_button_win.h @@ -24,6 +24,7 @@ class NativeButtonWin : public NativeControlWin, virtual void UpdateDefault(); virtual View* GetView(); virtual void SetFocus(); + virtual bool UsesNativeLabel() const; virtual gfx::NativeView GetTestingHandle() const; // Overridden from View: @@ -63,6 +64,7 @@ class NativeCheckboxWin : public NativeButtonWin { virtual void UpdateChecked(); virtual void SetPushed(bool pushed); virtual bool OnKeyDown(int vkey); + virtual bool UsesNativeLabel() const; // Overridden from NativeControlWin: virtual bool ProcessMessage(UINT message, diff --git a/views/controls/button/native_button_wrapper.h b/views/controls/button/native_button_wrapper.h index 39aa2c3..bd974bd 100644 --- a/views/controls/button/native_button_wrapper.h +++ b/views/controls/button/native_button_wrapper.h @@ -46,6 +46,10 @@ class NativeButtonWrapper { // Sets the focus to the button. virtual void SetFocus() = 0; + // Returns true if the wrapped NativeButton supplies its own label, false if + // the caller needs to provide one. + virtual bool UsesNativeLabel() const = 0; + // Returns a handle to the underlying native view for testing. virtual gfx::NativeView GetTestingHandle() const = 0; diff --git a/views/window/dialog_client_view.cc b/views/window/dialog_client_view.cc index c114bc9..612b1c5 100644 --- a/views/window/dialog_client_view.cc +++ b/views/window/dialog_client_view.cc @@ -4,27 +4,28 @@ #include "views/window/dialog_client_view.h" -#if defined(OS_WIN) -#include <windows.h> -#include <uxtheme.h> -#include <vsstyle.h> -#endif - #include "app/gfx/canvas.h" #include "app/gfx/font.h" #include "app/l10n_util.h" #include "app/resource_bundle.h" -#if defined(OS_WIN) -#include "base/gfx/native_theme.h" -#endif #include "grit/app_strings.h" #include "views/controls/button/native_button.h" #include "views/standard_layout.h" #include "views/window/dialog_delegate.h" -#if !defined(OS_WIN) +#include "views/window/window.h" + +#if defined(OS_WIN) +#include <windows.h> +#include <uxtheme.h> +#include <vsstyle.h> + +#include "base/gfx/native_theme.h" +#else +#include <gtk/gtk.h> + #include "views/window/hit_test.h" +#include "views/widget/widget.h" #endif -#include "views/window/window.h" namespace views { @@ -282,8 +283,14 @@ void DialogClientView::Paint(gfx::Canvas* canvas) { #if defined(OS_WIN) FillViewWithSysColor(canvas, this, GetSysColor(COLOR_3DFACE)); #else - NOTIMPLEMENTED(); - // TODO(port): paint dialog background color + GtkWidget* widget = GetWidget()->GetNativeView(); + if (GTK_IS_WINDOW(widget)) { + GtkStyle* window_style = gtk_widget_get_style(widget); + canvas->FillRectInt(SkColorSetRGB(window_style->bg[GTK_STATE_NORMAL].red, + window_style->bg[GTK_STATE_NORMAL].green, + window_style->bg[GTK_STATE_NORMAL].blue), + 0, 0, width(), height()); + } #endif } |