Skip to content

Commit

Permalink
Use gfx::Point instead of GET_X/Y_LPARAM to reduce a dependency on ATL.
Browse files Browse the repository at this point in the history
BUG=5027
TEST=none
Review URL: http://codereview.chromium.org/195035

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@25788 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
jhawkins@chromium.org committed Sep 9, 2009
1 parent 9343914 commit 938d54a
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 20 deletions.
6 changes: 6 additions & 0 deletions base/gfx/point.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ Point::Point(int x, int y) : x_(x), y_(y) {
}

#if defined(OS_WIN)
Point::Point(DWORD point) {
POINTS points = MAKEPOINTS(point);
x_ = points.x;
y_ = points.y;
}

Point::Point(const POINT& point) : x_(point.x), y_(point.y) {
}

Expand Down
7 changes: 6 additions & 1 deletion base/gfx/point.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <iosfwd>

#if defined(OS_WIN)
typedef unsigned long DWORD;
typedef struct tagPOINT POINT;
#elif defined(OS_MACOSX)
#include <ApplicationServices/ApplicationServices.h>
Expand All @@ -25,6 +26,10 @@ class Point {
Point();
Point(int x, int y);
#if defined(OS_WIN)
// |point| is a DWORD value that contains a coordinate. The x-coordinate is
// the low-order short and the y-coordinate is the high-order short. This
// value is commonly acquired from GetMessagePos/GetCursorPos.
explicit Point(DWORD point);
explicit Point(const POINT& point);
Point& operator=(const POINT& point);
#elif defined(OS_MACOSX)
Expand Down Expand Up @@ -72,4 +77,4 @@ class Point {

std::ostream& operator<<(std::ostream& out, const gfx::Point& p);

#endif // BASE_GFX_POINT_H__
#endif // BASE_GFX_POINT_H__
9 changes: 4 additions & 5 deletions chrome/browser/views/keyword_editor_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@

#include "chrome/browser/views/keyword_editor_view.h"

#include <atlbase.h>
#include <atlapp.h>
#include <vector>

#include "app/l10n_util.h"
#include "base/gfx/point.h"
#include "base/stl_util-inl.h"
#include "base/string_util.h"
#include "chrome/browser/profile.h"
Expand Down Expand Up @@ -219,9 +218,9 @@ void KeywordEditorView::OnSelectionChanged() {
void KeywordEditorView::OnDoubleClick() {
if (edit_button_->IsEnabled()) {
DWORD pos = GetMessagePos();
POINT cursor_point = { GET_X_LPARAM(pos), GET_Y_LPARAM(pos) };
gfx::Point cursor_point(pos);
views::MouseEvent event(views::Event::ET_MOUSE_RELEASED,
cursor_point.x, cursor_point.y,
cursor_point.x(), cursor_point.y(),
views::Event::EF_LEFT_BUTTON_DOWN);
ButtonPressed(edit_button_, event);
}
Expand All @@ -233,7 +232,7 @@ void KeywordEditorView::ButtonPressed(
browser::EditSearchEngine(GetWindow()->GetNativeWindow(), NULL, this,
profile_);
} else if (sender == remove_button_) {
DCHECK(table_view_->SelectedRowCount() == 1);
DCHECK_EQ(1, table_view_->SelectedRowCount());
int last_view_row = -1;
for (views::TableView::iterator i = table_view_->SelectionBegin();
i != table_view_->SelectionEnd(); ++i) {
Expand Down
10 changes: 4 additions & 6 deletions views/controls/tree/tree_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@

#include "views/controls/tree/tree_view.h"

#include <atlbase.h>
#include <atlapp.h>
#include <atlmisc.h>
#include <vector>

#include "app/gfx/canvas_paint.h"
#include "app/gfx/icon_util.h"
#include "app/l10n_util.h"
#include "app/l10n_util_win.h"
#include "app/resource_bundle.h"
#include "base/gfx/point.h"
#include "base/stl_util-inl.h"
#include "base/win_util.h"
#include "grit/app_resources.h"
Expand Down Expand Up @@ -53,7 +52,7 @@ TreeView::~TreeView() {
void TreeView::SetModel(TreeModel* model) {
if (model == model_)
return;
if(model_ && tree_view_)
if (model_ && tree_view_)
DeleteRootItems();
if (model_)
model_->SetObserver(NULL);
Expand Down Expand Up @@ -727,8 +726,7 @@ LRESULT CALLBACK TreeView::TreeWndProc(HWND window,
case WM_RBUTTONDOWN:
if (tree->select_on_right_mouse_down_) {
TVHITTESTINFO hit_info;
hit_info.pt.x = GET_X_LPARAM(l_param);
hit_info.pt.y = GET_Y_LPARAM(l_param);
hit_info.pt = gfx::Point(l_param).ToPOINT();
HTREEITEM hit_item = TreeView_HitTest(window, &hit_info);
if (hit_item && (hit_info.flags & (TVHT_ONITEM | TVHT_ONITEMRIGHT |
TVHT_ONITEMINDENT)) != 0)
Expand Down
14 changes: 6 additions & 8 deletions views/widget/aero_tooltip_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@
#include "views/widget/aero_tooltip_manager.h"

#include <windows.h>
#include <atlbase.h>
#include <atlapp.h> // for GET_X/Y_LPARAM
#include <commctrl.h>
#include <shlobj.h>

#include "app/l10n_util_win.h"
#include "base/gfx/point.h"
#include "base/message_loop.h"

namespace views {
Expand All @@ -33,13 +32,12 @@ void AeroTooltipManager::OnMouse(UINT u_msg, WPARAM w_param, LPARAM l_param) {
initial_timer_->Disown();

if (u_msg == WM_MOUSEMOVE || u_msg == WM_NCMOUSEMOVE) {
int x = GET_X_LPARAM(l_param);
int y = GET_Y_LPARAM(l_param);
if (last_mouse_x_ != x || last_mouse_y_ != y) {
last_mouse_x_ = x;
last_mouse_y_ = y;
gfx::Point mouse_pos(l_param);
if (last_mouse_x_ != mouse_pos.x() || last_mouse_y_ != mouse_pos.y()) {
last_mouse_x_ = mouse_pos.x();
last_mouse_y_ = mouse_pos.y();
HideKeyboardTooltip();
UpdateTooltip(x, y);
UpdateTooltip(mouse_pos.x(), mouse_pos.y());
}

// Delay opening of the tooltip just in case the user moves their
Expand Down

0 comments on commit 938d54a

Please sign in to comment.