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

Side by Side Diff: chrome/views/menu_button.cc

Issue 7317: Change all ConvertPointTo* methods to use gfx::Point instead of CPoint.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 12 years, 2 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/views/hwnd_view_container.cc ('k') | chrome/views/root_view.h » ('j') | 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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 <atlbase.h> 5 #include <atlbase.h>
6 #include <atlapp.h> 6 #include <atlapp.h>
7 7
8 #include "chrome/views/menu_button.h" 8 #include "chrome/views/menu_button.h"
9 9
10 #include "chrome/app/theme/theme_resources.h" 10 #include "chrome/app/theme/theme_resources.h"
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 // menu modal loop which will stop this window from updating and 122 // menu modal loop which will stop this window from updating and
123 // receiving the paint message that should be spawned by SetState until 123 // receiving the paint message that should be spawned by SetState until
124 // after the menu closes. 124 // after the menu closes.
125 PaintNow(); 125 PaintNow();
126 if (menu_delegate_) { 126 if (menu_delegate_) {
127 CRect lb; 127 CRect lb;
128 GetLocalBounds(&lb, true); 128 GetLocalBounds(&lb, true);
129 129
130 // The position of the menu depends on whether or not the locale is 130 // The position of the menu depends on whether or not the locale is
131 // right-to-left. 131 // right-to-left.
132 CPoint menu_position = lb.BottomRight(); 132 gfx::Point menu_position(lb.BottomRight());
133 if (UILayoutIsRightToLeft()) 133 if (UILayoutIsRightToLeft())
134 menu_position.x = lb.left; 134 menu_position.set_x(lb.left);
135 135
136 View::ConvertPointToScreen(this, &menu_position); 136 View::ConvertPointToScreen(this, &menu_position);
137 if (UILayoutIsRightToLeft()) 137 if (UILayoutIsRightToLeft())
138 menu_position.Offset(2, -4); 138 menu_position.Offset(2, -4);
139 else 139 else
140 menu_position.Offset(-2, -4); 140 menu_position.Offset(-2, -4);
141 141
142 int max_x_coordinate = GetMaximumScreenXCoordinate(); 142 int max_x_coordinate = GetMaximumScreenXCoordinate();
143 if (max_x_coordinate && max_x_coordinate <= menu_position.x) 143 if (max_x_coordinate && max_x_coordinate <= menu_position.x())
144 menu_position.x = max_x_coordinate - 1; 144 menu_position.set_x(max_x_coordinate - 1);
145 145
146 // We're about to show the menu from a mouse press. By showing from the 146 // We're about to show the menu from a mouse press. By showing from the
147 // mouse press event we block RootView in mouse dispatching. This also 147 // mouse press event we block RootView in mouse dispatching. This also
148 // appears to cause RootView to get a mouse pressed BEFORE the mouse 148 // appears to cause RootView to get a mouse pressed BEFORE the mouse
149 // release is seen, which means RootView sends us another mouse press no 149 // release is seen, which means RootView sends us another mouse press no
150 // matter where the user pressed. To force RootView to recalculate the 150 // matter where the user pressed. To force RootView to recalculate the
151 // mouse target during the mouse press we explicitly set the mouse handler 151 // mouse target during the mouse press we explicitly set the mouse handler
152 // to NULL. 152 // to NULL.
153 GetRootView()->SetMouseHandler(NULL); 153 GetRootView()->SetMouseHandler(NULL);
154 154
155 menu_visible_ = true; 155 menu_visible_ = true;
156 menu_delegate_->RunMenu(this, menu_position, GetViewContainer()->GetHWND()); 156 menu_delegate_->RunMenu(this, menu_position.ToPOINT(),
157 GetViewContainer()->GetHWND());
157 menu_visible_ = false; 158 menu_visible_ = false;
158 menu_closed_time_ = Time::Now(); 159 menu_closed_time_ = Time::Now();
159 160
160 // Now that the menu has closed, we need to manually reset state to 161 // Now that the menu has closed, we need to manually reset state to
161 // "normal" since the menu modal loop will have prevented normal 162 // "normal" since the menu modal loop will have prevented normal
162 // mouse move messages from getting to this View. We set "normal" 163 // mouse move messages from getting to this View. We set "normal"
163 // and not "hot" because the likelihood is that the mouse is now 164 // and not "hot" because the likelihood is that the mouse is now
164 // somewhere else (user clicked elsewhere on screen to close the menu 165 // somewhere else (user clicked elsewhere on screen to close the menu
165 // or selected an item) and we will inevitably refresh the hot state 166 // or selected an item) and we will inevitably refresh the hot state
166 // in the event the mouse _is_ over the view. 167 // in the event the mouse _is_ over the view.
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 // cause the button to appear depressed while the menu is displayed. 249 // cause the button to appear depressed while the menu is displayed.
249 void MenuButton::OnMouseExited(const MouseEvent& event) { 250 void MenuButton::OnMouseExited(const MouseEvent& event) {
250 using namespace ChromeViews; 251 using namespace ChromeViews;
251 if ((state_ != BS_DISABLED) && (!menu_visible_) && (!InDrag())) { 252 if ((state_ != BS_DISABLED) && (!menu_visible_) && (!InDrag())) {
252 SetState(BS_NORMAL); 253 SetState(BS_NORMAL);
253 } 254 }
254 } 255 }
255 256
256 } // namespace ChromeViews 257 } // namespace ChromeViews
257 258
OLDNEW
« no previous file with comments | « chrome/views/hwnd_view_container.cc ('k') | chrome/views/root_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698