summaryrefslogtreecommitdiffstats
path: root/views
diff options
context:
space:
mode:
authorkuan@chromium.org <kuan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-27 19:04:55 +0000
committerkuan@chromium.org <kuan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-27 19:04:55 +0000
commitfb53e5d2dad6356043a2e202578eea074995f72a (patch)
treefcb3c2b4243c3fb8364e077ea650a23847214eef /views
parent82011cee978aad75254211c2b6ed187350f14dcb (diff)
downloadchromium_src-fb53e5d2dad6356043a2e202578eea074995f72a.zip
chromium_src-fb53e5d2dad6356043a2e202578eea074995f72a.tar.gz
chromium_src-fb53e5d2dad6356043a2e202578eea074995f72a.tar.bz2
implement infobars and delegates placeholders for translate feature.
Review URL: http://codereview.chromium.org/546132 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@37281 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views')
-rw-r--r--views/controls/button/text_button.cc138
-rw-r--r--views/controls/button/text_button.h10
2 files changed, 84 insertions, 64 deletions
diff --git a/views/controls/button/text_button.cc b/views/controls/button/text_button.cc
index 0df9578c..042f9d2 100644
--- a/views/controls/button/text_button.cc
+++ b/views/controls/button/text_button.cc
@@ -68,9 +68,10 @@ TextButtonBorder::TextButtonBorder() {
TextButtonBorder::~TextButtonBorder() {
}
+
////////////////////////////////////////////////////////////////////////////////
//
-// TextButtonBackground - painting
+// TextButtonBorder - painting
//
////////////////////////////////////////////////////////////////////////////////
@@ -84,71 +85,76 @@ void TextButtonBorder::Paint(const View& view, gfx::Canvas* canvas) const {
set = &pushed_set_;
if (set) {
- gfx::Rect bounds = view.bounds();
-
- // Draw the top left image
- canvas->DrawBitmapInt(*set->top_left, 0, 0);
-
- // Tile the top image
- canvas->TileImageInt(
- *set->top,
- set->top_left->width(),
- 0,
- bounds.width() - set->top_right->width() - set->top_left->width(),
- set->top->height());
-
- // Draw the top right image
- canvas->DrawBitmapInt(*set->top_right,
- bounds.width() - set->top_right->width(), 0);
-
- // Tile the left image
- canvas->TileImageInt(
- *set->left,
- 0,
- set->top_left->height(),
- set->top_left->width(),
- bounds.height() - set->top->height() - set->bottom_left->height());
-
- // Tile the center image
- canvas->TileImageInt(
- *set->center,
- set->left->width(),
- set->top->height(),
- bounds.width() - set->right->width() - set->left->width(),
- bounds.height() - set->bottom->height() - set->top->height());
-
- // Tile the right image
- canvas->TileImageInt(
- *set->right,
- bounds.width() - set->right->width(),
- set->top_right->height(),
- bounds.width(),
- bounds.height() - set->bottom_right->height() -
- set->top_right->height());
-
- // Draw the bottom left image
- canvas->DrawBitmapInt(*set->bottom_left,
- 0,
- bounds.height() - set->bottom_left->height());
-
- // Tile the bottom image
- canvas->TileImageInt(
- *set->bottom,
- set->bottom_left->width(),
- bounds.height() - set->bottom->height(),
- bounds.width() - set->bottom_right->width() -
- set->bottom_left->width(),
- set->bottom->height());
-
- // Draw the bottom right image
- canvas->DrawBitmapInt(*set->bottom_right,
- bounds.width() - set->bottom_right->width(),
- bounds.height() - set->bottom_right->height());
+ Paint(view, canvas, *set);
} else {
// Do nothing
}
}
+void TextButtonBorder::Paint(const View& view, gfx::Canvas* canvas,
+ const MBBImageSet& set) const {
+ gfx::Rect bounds = view.bounds();
+
+ // Draw the top left image
+ canvas->DrawBitmapInt(*set.top_left, 0, 0);
+
+ // Tile the top image
+ canvas->TileImageInt(
+ *set.top,
+ set.top_left->width(),
+ 0,
+ bounds.width() - set.top_right->width() - set.top_left->width(),
+ set.top->height());
+
+ // Draw the top right image
+ canvas->DrawBitmapInt(*set.top_right,
+ bounds.width() - set.top_right->width(), 0);
+
+ // Tile the left image
+ canvas->TileImageInt(
+ *set.left,
+ 0,
+ set.top_left->height(),
+ set.top_left->width(),
+ bounds.height() - set.top->height() - set.bottom_left->height());
+
+ // Tile the center image
+ canvas->TileImageInt(
+ *set.center,
+ set.left->width(),
+ set.top->height(),
+ bounds.width() - set.right->width() - set.left->width(),
+ bounds.height() - set.bottom->height() - set.top->height());
+
+ // Tile the right image
+ canvas->TileImageInt(
+ *set.right,
+ bounds.width() - set.right->width(),
+ set.top_right->height(),
+ bounds.width(),
+ bounds.height() - set.bottom_right->height() -
+ set.top_right->height());
+
+ // Draw the bottom left image
+ canvas->DrawBitmapInt(*set.bottom_left,
+ 0,
+ bounds.height() - set.bottom_left->height());
+
+ // Tile the bottom image
+ canvas->TileImageInt(
+ *set.bottom,
+ set.bottom_left->width(),
+ bounds.height() - set.bottom->height(),
+ bounds.width() - set.bottom_right->width() -
+ set.bottom_left->width(),
+ set.bottom->height());
+
+ // Draw the bottom right image
+ canvas->DrawBitmapInt(*set.bottom_right,
+ bounds.width() - set.bottom_right->width(),
+ bounds.height() - set.bottom_right->height());
+}
+
void TextButtonBorder::GetInsets(gfx::Insets* insets) const {
insets->Set(kPreferredPaddingVertical, kPreferredPaddingHorizontal,
kPreferredPaddingVertical, kPreferredPaddingHorizontal);
@@ -169,7 +175,8 @@ TextButton::TextButton(ButtonListener* listener, const std::wstring& text)
color_highlight_(kHighlightColor),
color_hover_(kHoverColor),
has_hover_icon_(false),
- max_width_(0) {
+ max_width_(0),
+ normal_has_border_(false) {
SetText(text);
set_border(new TextButtonBorder);
SetAnimationDuration(kHoverAnimationDurationMs);
@@ -222,6 +229,10 @@ void TextButton::ClearMaxTextSize() {
max_text_size_ = text_size_;
}
+void TextButton::SetNormalHasBorder(bool normal_has_border) {
+ normal_has_border_ = normal_has_border;
+}
+
void TextButton::Paint(gfx::Canvas* canvas, bool for_drag) {
if (!for_drag) {
PaintBackground(canvas);
@@ -235,7 +246,8 @@ void TextButton::Paint(gfx::Canvas* canvas, bool for_drag) {
canvas->drawARGB(0, 255, 255, 255, SkXfermode::kClear_Mode);
PaintBorder(canvas);
canvas->restore();
- } else if (state_ == BS_HOT || state_ == BS_PUSHED) {
+ } else if (state_ == BS_HOT || state_ == BS_PUSHED ||
+ (state_ == BS_NORMAL && normal_has_border_)) {
PaintBorder(canvas);
}
diff --git a/views/controls/button/text_button.h b/views/controls/button/text_button.h
index d895a6e..b6bd739 100644
--- a/views/controls/button/text_button.h
+++ b/views/controls/button/text_button.h
@@ -36,7 +36,7 @@ class TextButtonBorder : public Border {
// Returns the insets for the border.
virtual void GetInsets(gfx::Insets* insets) const;
- private:
+ protected:
// Images
struct MBBImageSet {
SkBitmap* top_left;
@@ -52,6 +52,10 @@ class TextButtonBorder : public Border {
MBBImageSet hot_set_;
MBBImageSet pushed_set_;
+ virtual void Paint(const View& view, gfx::Canvas* canvas,
+ const MBBImageSet& set) const;
+
+ private:
DISALLOW_COPY_AND_ASSIGN(TextButtonBorder);
};
@@ -112,6 +116,7 @@ class TextButton : public CustomButton {
void SetDisabledColor(SkColor color);
void SetHighlightColor(SkColor color);
void SetHoverColor(SkColor color);
+ void SetNormalHasBorder(bool normal_has_border);
// Paint the button into the specified canvas. If |for_drag| is true, the
// function paints a drag image representation into the canvas.
@@ -176,6 +181,9 @@ class TextButton : public CustomButton {
// indicates the width is not constrained.
int max_width_;
+ // This is true if normal state has a border frame; default is false.
+ bool normal_has_border_;
+
DISALLOW_COPY_AND_ASSIGN(TextButton);
};