summaryrefslogtreecommitdiffstats
path: root/chrome/browser/views
diff options
context:
space:
mode:
authormaruel@google.com <maruel@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-09-04 03:36:44 +0000
committermaruel@google.com <maruel@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-09-04 03:36:44 +0000
commitee9653f9a6db545c361da48b856aa601a04005b3 (patch)
tree792aba47d663cb39d07c14c30f1b7ee90a51f742 /chrome/browser/views
parentc919469b3dfc6ea110fdc2218c014599babfd6e9 (diff)
downloadchromium_src-ee9653f9a6db545c361da48b856aa601a04005b3.zip
chromium_src-ee9653f9a6db545c361da48b856aa601a04005b3.tar.gz
chromium_src-ee9653f9a6db545c361da48b856aa601a04005b3.tar.bz2
Fix the polymorphic WindowResources class and FramePartBitmap enum.
TBR=ben Review URL: http://codereview.chromium.org/224 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@1710 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/views')
-rw-r--r--chrome/browser/views/browser_views.vcproj8
-rw-r--r--chrome/browser/views/constrained_window_impl.cc14
-rw-r--r--chrome/browser/views/frame/aero_glass_non_client_view.cc8
-rw-r--r--chrome/browser/views/frame/opaque_non_client_view.cc47
-rw-r--r--chrome/browser/views/window_resources.cc27
-rw-r--r--chrome/browser/views/window_resources.h35
6 files changed, 80 insertions, 59 deletions
diff --git a/chrome/browser/views/browser_views.vcproj b/chrome/browser/views/browser_views.vcproj
index 1ff0c1d2..1b4f0d0 100644
--- a/chrome/browser/views/browser_views.vcproj
+++ b/chrome/browser/views/browser_views.vcproj
@@ -669,6 +669,14 @@
RelativePath=".\toolbar_view.h"
>
</File>
+ <File
+ RelativePath=".\window_resources.cc"
+ >
+ </File>
+ <File
+ RelativePath=".\window_resources.h"
+ >
+ </File>
</Files>
<Globals>
</Globals>
diff --git a/chrome/browser/views/constrained_window_impl.cc b/chrome/browser/views/constrained_window_impl.cc
index 3d0b0c3..85d9e58 100644
--- a/chrome/browser/views/constrained_window_impl.cc
+++ b/chrome/browser/views/constrained_window_impl.cc
@@ -10,6 +10,7 @@
#include "chrome/browser/tab_contents.h"
#include "chrome/browser/views/constrained_window_animation.h"
#include "chrome/browser/views/location_bar_view.h"
+#include "chrome/browser/views/window_resources.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/profile.h"
#include "chrome/browser/toolbar_model.h"
@@ -40,11 +41,8 @@ namespace ChromeViews {
class ClientView;
}
-////////////////////////////////////////////////////////////////////////////////
-// WindowResources
-
// An enumeration of bitmap resources used by this window.
-enum FramePartBitmap {
+enum {
FRAME_PART_BITMAP_FIRST = 0, // Must be first.
FRAME_BOTTOM_CENTER,
@@ -82,14 +80,6 @@ static const int kOTRFramePartIDs[] = {
IDR_WINDOW_TOP_LEFT_CORNER_OTR, IDR_WINDOW_TOP_RIGHT_CORNER_OTR,
IDR_CLOSE_SA, IDR_CLOSE_SA_H, IDR_CLOSE_SA_P, 0 };
-class WindowResources {
- public:
- virtual ~WindowResources() {}
- virtual SkBitmap* GetPartBitmap(FramePartBitmap part_id) const = 0;
- virtual const ChromeFont& GetTitleFont() const = 0;
- virtual SkColor GetTitleColor() const = 0;
-};
-
class XPWindowResources : public WindowResources {
public:
XPWindowResources() {
diff --git a/chrome/browser/views/frame/aero_glass_non_client_view.cc b/chrome/browser/views/frame/aero_glass_non_client_view.cc
index a13f6ed..4648484 100644
--- a/chrome/browser/views/frame/aero_glass_non_client_view.cc
+++ b/chrome/browser/views/frame/aero_glass_non_client_view.cc
@@ -7,6 +7,7 @@
#include "chrome/app/theme/theme_resources.h"
#include "chrome/browser/tabs/tab_strip.h"
#include "chrome/browser/views/frame/browser_view2.h"
+#include "chrome/browser/views/window_resources.h"
#include "chrome/common/gfx/chrome_canvas.h"
#include "chrome/common/gfx/chrome_font.h"
#include "chrome/common/gfx/path.h"
@@ -14,12 +15,9 @@
#include "chrome/views/client_view.h"
#include "chrome/views/window_delegate.h"
-///////////////////////////////////////////////////////////////////////////////
-// WindowResources
-//
// An enumeration of bitmap resources used by this window.
-enum FramePartBitmap {
- FRAME_PART_BITMAP_FIRST = 0, // must be first.
+enum {
+ FRAME_PART_BITMAP_FIRST = 0, // must be first.
// Client Edge Border.
FRAME_CLIENT_EDGE_TOP_LEFT,
diff --git a/chrome/browser/views/frame/opaque_non_client_view.cc b/chrome/browser/views/frame/opaque_non_client_view.cc
index 86691d2..be7b36a 100644
--- a/chrome/browser/views/frame/opaque_non_client_view.cc
+++ b/chrome/browser/views/frame/opaque_non_client_view.cc
@@ -7,18 +7,15 @@
#include "chrome/app/theme/theme_resources.h"
#include "chrome/browser/tabs/tab_strip.h"
#include "chrome/browser/views/frame/browser_view2.h"
-#include "chrome/common/gfx/chrome_canvas.h"
+#include "chrome/browser/views/window_resources.h"
#include "chrome/common/gfx/chrome_font.h"
#include "chrome/common/gfx/path.h"
#include "chrome/common/resource_bundle.h"
-#include "chrome/views/client_view.h"
-///////////////////////////////////////////////////////////////////////////////
-// WindowResources
-//
+
// An enumeration of bitmap resources used by this window.
-enum FramePartBitmap {
- FRAME_PART_BITMAP_FIRST = 0, // must be first.
+enum {
+ FRAME_PART_BITMAP_FIRST = 0, // Must be first.
// Window Controls.
FRAME_CLOSE_BUTTON_ICON,
@@ -64,40 +61,6 @@ enum FramePartBitmap {
FRAME_PART_BITMAP_COUNT // Must be last.
};
-class WindowResources {
- public:
- virtual SkBitmap* GetPartBitmap(FramePartBitmap part) const = 0;
- virtual const ChromeFont& GetTitleFont() const = 0;
- SkColor title_color() const { return SK_ColorWHITE; }
-
- SkBitmap app_top_left() const { return app_top_left_; }
- SkBitmap app_top_center() const { return app_top_center_; }
- SkBitmap app_top_right() const { return app_top_right_; }
-
- protected:
- static void InitClass() {
- static bool initialized = false;
- if (!initialized) {
- ResourceBundle& rb = ResourceBundle::GetSharedInstance();
- app_top_left_ = *rb.GetBitmapNamed(IDR_APP_TOP_LEFT);
- app_top_center_ = *rb.GetBitmapNamed(IDR_APP_TOP_CENTER);
- app_top_right_ = *rb.GetBitmapNamed(IDR_APP_TOP_RIGHT);
- initialized = true;
- }
- }
-
- private:
- // Bitmaps shared between all frame types.
- static SkBitmap app_top_left_;
- static SkBitmap app_top_center_;
- static SkBitmap app_top_right_;
-};
-
-// static
-SkBitmap WindowResources::app_top_left_;
-SkBitmap WindowResources::app_top_center_;
-SkBitmap WindowResources::app_top_right_;
-
class ActiveWindowResources : public WindowResources {
public:
ActiveWindowResources() {
@@ -802,7 +765,7 @@ void OpaqueNonClientView::PaintTitleBar(ChromeCanvas* canvas) {
if (d->ShouldShowWindowTitle()) {
canvas->DrawStringInt(d->GetWindowTitle(),
resources()->GetTitleFont(),
- resources()->title_color(), title_bounds_.x(),
+ resources()->GetTitleColor(), title_bounds_.x(),
title_bounds_.y(), title_bounds_.width(),
title_bounds_.height());
}
diff --git a/chrome/browser/views/window_resources.cc b/chrome/browser/views/window_resources.cc
new file mode 100644
index 0000000..42b1bc4
--- /dev/null
+++ b/chrome/browser/views/window_resources.cc
@@ -0,0 +1,27 @@
+// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/views/window_resources.h"
+
+#include "chrome/app/theme/theme_resources.h"
+#include "chrome/common/resource_bundle.h"
+
+#include "SkBitmap.h"
+
+// static
+SkBitmap WindowResources::app_top_left_;
+SkBitmap WindowResources::app_top_center_;
+SkBitmap WindowResources::app_top_right_;
+
+// static
+void WindowResources::InitClass() {
+ static bool initialized = false;
+ if (!initialized) {
+ ResourceBundle& rb = ResourceBundle::GetSharedInstance();
+ app_top_left_ = *rb.GetBitmapNamed(IDR_APP_TOP_LEFT);
+ app_top_center_ = *rb.GetBitmapNamed(IDR_APP_TOP_CENTER);
+ app_top_right_ = *rb.GetBitmapNamed(IDR_APP_TOP_RIGHT);
+ initialized = true;
+ }
+}
diff --git a/chrome/browser/views/window_resources.h b/chrome/browser/views/window_resources.h
new file mode 100644
index 0000000..eeea313
--- /dev/null
+++ b/chrome/browser/views/window_resources.h
@@ -0,0 +1,35 @@
+// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_VIEWS_WINDOW_RESOURCES_H_
+#define CHROME_BROWSER_VIEWS_WINDOW_RESOURCES_H_
+
+#include "SkBitmap.h"
+
+class ChromeFont;
+
+typedef int FramePartBitmap;
+
+class WindowResources {
+ public:
+ virtual ~WindowResources() { }
+ virtual SkBitmap* GetPartBitmap(FramePartBitmap part) const = 0;
+ virtual const ChromeFont& GetTitleFont() const = 0;
+ virtual SkColor GetTitleColor() const { return SK_ColorWHITE; }
+
+ SkBitmap app_top_left() const { return app_top_left_; }
+ SkBitmap app_top_center() const { return app_top_center_; }
+ SkBitmap app_top_right() const { return app_top_right_; }
+
+ protected:
+ static void InitClass();
+
+ private:
+ // Bitmaps shared between all frame types.
+ static SkBitmap app_top_left_;
+ static SkBitmap app_top_center_;
+ static SkBitmap app_top_right_;
+};
+
+#endif // CHROME_BROWSER_VIEWS_WINDOW_RESOURCES_H_