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

Unified Diff: views/controls/button/native_button_win.cc

Issue 2812026: Auto-size the views version of the options dialog. (Closed)
Patch Set: Fix autosizing issue with gtk pref pages in chromeos options dialog. Created 10 years, 6 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « views/controls/button/native_button_win.h ('k') | views/controls/menu/menu_scroll_view_container.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: views/controls/button/native_button_win.cc
diff --git a/views/controls/button/native_button_win.cc b/views/controls/button/native_button_win.cc
index c485c71d7d49d87fc9606b1a295e6cde783461a5..9e24fc3decb9c3304f9fec6a6c820f0a77acafdb 100644
--- a/views/controls/button/native_button_win.cc
+++ b/views/controls/button/native_button_win.cc
@@ -19,7 +19,8 @@ namespace views {
// NativeButtonWin, public:
NativeButtonWin::NativeButtonWin(NativeButton* native_button)
- : native_button_(native_button) {
+ : native_button_(native_button),
+ button_size_valid_(false) {
// Associates the actual HWND with the native_button so the native_button is
// the one considered as having the focus (not the wrapper) when the HWND is
// focused directly (with a click for example).
@@ -43,12 +44,14 @@ void NativeButtonWin::UpdateLabel() {
}
SetWindowText(native_view(), native_button_->label().c_str());
+ button_size_valid_ = false;
}
void NativeButtonWin::UpdateFont() {
SendMessage(native_view(), WM_SETFONT,
reinterpret_cast<WPARAM>(native_button_->font().hfont()),
FALSE);
+ button_size_valid_ = false;
}
void NativeButtonWin::UpdateEnabled() {
@@ -60,6 +63,7 @@ void NativeButtonWin::UpdateDefault() {
SendMessage(native_view(), BM_SETSTYLE,
native_button_->is_default() ? BS_DEFPUSHBUTTON : BS_PUSHBUTTON,
true);
+ button_size_valid_ = false;
}
}
@@ -88,10 +92,13 @@ gfx::NativeView NativeButtonWin::GetTestingHandle() const {
// NativeButtonWin, View overrides:
gfx::Size NativeButtonWin::GetPreferredSize() {
- SIZE sz = {0};
- SendMessage(native_view(), BCM_GETIDEALSIZE, 0, reinterpret_cast<LPARAM>(&sz));
-
- return gfx::Size(sz.cx, sz.cy);
+ if (!button_size_valid_) {
+ SIZE sz = {0};
+ Button_GetIdealSize(native_view(), reinterpret_cast<LPARAM>(&sz));
+ button_size_.SetSize(sz.cx, sz.cy);
+ button_size_valid_ = true;
+ }
+ return button_size_;
}
////////////////////////////////////////////////////////////////////////////////
« no previous file with comments | « views/controls/button/native_button_win.h ('k') | views/controls/menu/menu_scroll_view_container.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698