summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
authorsky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-18 21:14:02 +0000
committersky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-18 21:14:02 +0000
commit2237ce6abe23d4e4610af5a492eb60016fb85171 (patch)
tree3844320cb95b1e9009f5d0a38b107066a2404bf2 /chrome/browser
parent61c2bae0cd2458f8d055bccab1edb738fa82a20d (diff)
downloadchromium_src-2237ce6abe23d4e4610af5a492eb60016fb85171.zip
chromium_src-2237ce6abe23d4e4610af5a492eb60016fb85171.tar.gz
chromium_src-2237ce6abe23d4e4610af5a492eb60016fb85171.tar.bz2
Makes it so tab_strip can compile on linux. Most differences are due
to compiler differences between gcc and MSVC. BUG=none TEST=none Review URL: http://codereview.chromium.org/113537 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@16319 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/views/tabs/tab_strip.cc56
-rw-r--r--chrome/browser/views/tabs/tab_strip.h27
2 files changed, 64 insertions, 19 deletions
diff --git a/chrome/browser/views/tabs/tab_strip.cc b/chrome/browser/views/tabs/tab_strip.cc
index 2ffcfd6..bb340d8 100644
--- a/chrome/browser/views/tabs/tab_strip.cc
+++ b/chrome/browser/views/tabs/tab_strip.cc
@@ -11,7 +11,9 @@
#include "app/os_exchange_data.h"
#include "app/resource_bundle.h"
#include "app/slide_animation.h"
+#if defined(OS_WIN)
#include "app/win_util.h"
+#endif
#include "base/gfx/size.h"
#include "base/stl_util-inl.h"
#include "chrome/browser/metrics/user_metrics.h"
@@ -75,7 +77,6 @@ class NewTabButton : public views::ImageButton {
virtual void GetHitTestMask(gfx::Path* path) const {
DCHECK(path);
- SkScalar h = SkIntToScalar(height());
SkScalar w = SkIntToScalar(width());
// These values are defined by the shape of the new tab bitmap. Should that
@@ -231,7 +232,7 @@ class TabStrip::TabAnimation : public AnimationDelegate {
///////////////////////////////////////////////////////////////////////////////
// Handles insertion of a Tab at |index|.
-class InsertTabAnimation : public TabStrip::TabAnimation {
+class TabStrip::InsertTabAnimation : public TabStrip::TabAnimation {
public:
explicit InsertTabAnimation(TabStrip* tabstrip, int index)
: TabAnimation(tabstrip, INSERT),
@@ -272,7 +273,7 @@ class InsertTabAnimation : public TabStrip::TabAnimation {
///////////////////////////////////////////////////////////////////////////////
// Handles removal of a Tab from |index|
-class RemoveTabAnimation : public TabStrip::TabAnimation {
+class TabStrip::RemoveTabAnimation : public TabStrip::TabAnimation {
public:
RemoveTabAnimation(TabStrip* tabstrip, int index, TabContents* contents)
: TabAnimation(tabstrip, REMOVE),
@@ -336,6 +337,7 @@ class RemoveTabAnimation : public TabStrip::TabAnimation {
return;
}
+#if defined(OS_WIN)
POINT pt;
GetCursorPos(&pt);
views::Widget* widget = tabstrip_->GetWidget();
@@ -348,6 +350,9 @@ class RemoveTabAnimation : public TabStrip::TabAnimation {
// in progress.
PostMessage(widget->GetNativeView(), WM_MOUSEMOVE, 0,
MAKELPARAM(pt.x, pt.y));
+#else
+ NOTIMPLEMENTED();
+#endif
}
int index_;
@@ -358,7 +363,7 @@ class RemoveTabAnimation : public TabStrip::TabAnimation {
///////////////////////////////////////////////////////////////////////////////
// Handles the movement of a Tab from one position to another.
-class MoveTabAnimation : public TabStrip::TabAnimation {
+class TabStrip::MoveTabAnimation : public TabStrip::TabAnimation {
public:
MoveTabAnimation(TabStrip* tabstrip, int tab_a_index, int tab_b_index)
: TabAnimation(tabstrip, MOVE),
@@ -413,7 +418,7 @@ class MoveTabAnimation : public TabStrip::TabAnimation {
// Handles the animated resize layout of the entire TabStrip from one width
// to another.
-class ResizeLayoutAnimation : public TabStrip::TabAnimation {
+class TabStrip::ResizeLayoutAnimation : public TabStrip::TabAnimation {
public:
explicit ResizeLayoutAnimation(TabStrip* tabstrip)
: TabAnimation(tabstrip, RESIZE) {
@@ -496,7 +501,7 @@ int TabStrip::GetPreferredHeight() {
}
bool TabStrip::CanProcessInputEvents() const {
- return IsAnimating() == NULL;
+ return !IsAnimating();
}
bool TabStrip::PointIsWithinWindowCaption(const gfx::Point& point) {
@@ -815,8 +820,7 @@ void TabStrip::TabInsertedAt(TabContents* contents,
// Don't animate the first tab, it looks weird, and don't animate anything
// if the containing window isn't visible yet.
- if (GetTabCount() > 1 && GetWidget() &&
- IsWindowVisible(GetWidget()->GetNativeView())) {
+ if (GetTabCount() > 1 && GetWindow() && GetWindow()->IsVisible()) {
StartInsertTabAnimation(index);
} else {
Layout();
@@ -853,7 +857,6 @@ void TabStrip::TabSelectedAt(TabContents* old_contents,
void TabStrip::TabMoved(TabContents* contents, int from_index, int to_index) {
Tab* tab = GetTabAt(from_index);
- Tab* other_tab = GetTabAt(to_index);
tab_data_.erase(tab_data_.begin() + from_index);
TabData data = {tab, gfx::Rect()};
tab_data_.insert(tab_data_.begin() + to_index, data);
@@ -1006,6 +1009,7 @@ void TabStrip::ButtonPressed(views::Button* sender) {
///////////////////////////////////////////////////////////////////////////////
// TabStrip, MessageLoop::Observer implementation:
+#if defined(OS_WIN)
void TabStrip::WillProcessMessage(const MSG& msg) {
}
@@ -1056,6 +1060,11 @@ void TabStrip::DidProcessMessage(const MSG& msg) {
break;
}
}
+#else
+void TabStrip::WillProcessEvent(GdkEvent* event) {
+ NOTIMPLEMENTED();
+}
+#endif
///////////////////////////////////////////////////////////////////////////////
// TabStrip, private:
@@ -1203,10 +1212,18 @@ bool TabStrip::IsCursorInTabStripZone() {
bounds.set_origin(tabstrip_topleft);
bounds.set_height(bounds.height() + kTabStripAnimationVSlop);
- CPoint cursor_point;
- GetCursorPos(&cursor_point);
+#if defined(OS_WIN)
+ CPoint cursor_point_c;
+ GetCursorPos(&cursor_point_c);
+ gfx::Point cursor_point(cursor_point_c);
+#else
+ // TODO: make sure this is right with multiple monitors.
+ gint x, y;
+ gdk_display_get_pointer(NULL, NULL, &x, &y, NULL);
+ gfx::Point cursor_point(x, y);
+#endif
- return bounds.Contains(cursor_point.x, cursor_point.y);
+ return bounds.Contains(cursor_point.x(), cursor_point.y());
}
void TabStrip::AddMessageLoopObserver() {
@@ -1250,9 +1267,14 @@ gfx::Rect TabStrip::GetDropBounds(int drop_index,
drop_indicator_height);
// If the rect doesn't fit on the monitor, push the arrow to the bottom.
+#if defined(OS_WIN)
gfx::Rect monitor_bounds = win_util::GetMonitorBoundsForRect(drop_bounds);
*is_beneath = (monitor_bounds.IsEmpty() ||
!monitor_bounds.Contains(drop_bounds));
+#else
+ *is_beneath = false;
+ NOTIMPLEMENTED();
+#endif
if (*is_beneath)
drop_bounds.Offset(0, drop_bounds.height() + height());
@@ -1313,9 +1335,13 @@ void TabStrip::SetDropIndex(int index, bool drop_before) {
// Reposition the window. Need to show it too as the window is initially
// hidden.
+#if defined(OS_WIN)
drop_info_->arrow_window->SetWindowPos(
HWND_TOPMOST, drop_bounds.x(), drop_bounds.y(), drop_bounds.width(),
drop_bounds.height(), SWP_NOACTIVATE | SWP_SHOWWINDOW);
+#else
+ NOTIMPLEMENTED();
+#endif
}
int TabStrip::GetDropEffect(const views::DropTargetEvent& event) {
@@ -1339,6 +1365,7 @@ TabStrip::DropInfo::DropInfo(int drop_index, bool drop_before, bool point_down)
: drop_index(drop_index),
drop_before(drop_before),
point_down(point_down) {
+#if defined(OS_WIN)
arrow_window = new views::WidgetWin;
arrow_window->set_window_style(WS_POPUP);
arrow_window->set_window_ex_style(WS_EX_TOPMOST | WS_EX_NOACTIVATE |
@@ -1352,11 +1379,16 @@ TabStrip::DropInfo::DropInfo(int drop_index, bool drop_before, bool point_down)
gfx::Rect(0, 0, drop_indicator_width, drop_indicator_height),
true);
arrow_window->SetContentsView(arrow_view);
+#else
+ NOTIMPLEMENTED();
+#endif
}
TabStrip::DropInfo::~DropInfo() {
// Close eventually deletes the window, which deletes arrow_view too.
+#if defined(OS_WIN)
arrow_window->Close();
+#endif
}
///////////////////////////////////////////////////////////////////////////////
diff --git a/chrome/browser/views/tabs/tab_strip.h b/chrome/browser/views/tabs/tab_strip.h
index 2c1cc23..51a839f 100644
--- a/chrome/browser/views/tabs/tab_strip.h
+++ b/chrome/browser/views/tabs/tab_strip.h
@@ -2,16 +2,19 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROME_BROWSER_VIEWS_TABS_TAB_STRIP_H__
-#define CHROME_BROWSER_VIEWS_TABS_TAB_STRIP_H__
+#ifndef CHROME_BROWSER_VIEWS_TABS_TAB_STRIP_H_
+#define CHROME_BROWSER_VIEWS_TABS_TAB_STRIP_H_
#include "base/gfx/point.h"
+#include "base/message_loop.h"
#include "chrome/browser/tabs/tab_strip_model.h"
#include "chrome/browser/views/tabs/tab.h"
#include "views/controls/button/image_button.h"
#include "views/controls/menu/menu.h"
#include "views/view.h"
+#if defined(OS_WIN)
#include "views/widget/widget_win.h"
+#endif
class DraggedTabController;
class ScopedMouseCloseWidthCalculator;
@@ -141,16 +144,25 @@ class TabStrip : public views::View,
virtual void ButtonPressed(views::Button* sender);
// MessageLoop::Observer implementation:
+#if defined(OS_WIN)
virtual void WillProcessMessage(const MSG& msg);
virtual void DidProcessMessage(const MSG& msg);
+#else
+ virtual void WillProcessEvent(GdkEvent* event);
+#endif
private:
+ class InsertTabAnimation;
+ class MoveTabAnimation;
+ class RemoveTabAnimation;
+ class ResizeLayoutAnimation;
+ class TabAnimation;
+
friend class DraggedTabController;
friend class InsertTabAnimation;
friend class MoveTabAnimation;
friend class RemoveTabAnimation;
friend class ResizeLayoutAnimation;
- friend class SuspendAnimationsTask;
friend class TabAnimation;
TabStrip();
@@ -251,7 +263,6 @@ class TabStrip : public views::View,
// Notifies the TabStrip that the specified TabAnimation has completed.
// Optionally a full Layout will be performed, specified by |layout|.
- class TabAnimation;
void FinishAnimation(TabAnimation* animation, bool layout);
// Finds the index of the TabContents corresponding to |tab| in our
@@ -331,11 +342,13 @@ class TabStrip : public views::View,
// Renders the drop indicator.
// TODO(beng): should be views::Widget.
+#if defined(OS_WIN)
views::WidgetWin* arrow_window;
+#endif
views::ImageView* arrow_view;
private:
- DISALLOW_EVIL_CONSTRUCTORS(DropInfo);
+ DISALLOW_COPY_AND_ASSIGN(DropInfo);
};
// Valid for the lifetime of a drag over us.
@@ -355,7 +368,7 @@ class TabStrip : public views::View,
// The currently running animation.
scoped_ptr<TabAnimation> active_animation_;
- DISALLOW_EVIL_CONSTRUCTORS(TabStrip);
+ DISALLOW_COPY_AND_ASSIGN(TabStrip);
};
-#endif // CHROME_BROWSER_VIEWS_TABS_TAB_STRIP_H__
+#endif // CHROME_BROWSER_VIEWS_TABS_TAB_STRIP_H_