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

Side by Side Diff: chrome/browser/views/star_toggle.cc

Issue 113443: ChromeCanvas->gfx::Canvas (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years, 7 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/browser/views/star_toggle.h ('k') | chrome/browser/views/status_bubble_views.cc » ('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 "chrome/browser/views/star_toggle.h" 5 #include "chrome/browser/views/star_toggle.h"
6 6
7 #include "app/gfx/chrome_canvas.h" 7 #include "app/gfx/canvas.h"
8 #include "app/resource_bundle.h" 8 #include "app/resource_bundle.h"
9 #include "chrome/app/chrome_dll_resource.h" 9 #include "chrome/app/chrome_dll_resource.h"
10 #include "grit/theme_resources.h" 10 #include "grit/theme_resources.h"
11 11
12 StarToggle::StarToggle(Delegate* delegate) 12 StarToggle::StarToggle(Delegate* delegate)
13 : delegate_(delegate), 13 : delegate_(delegate),
14 state_(false), 14 state_(false),
15 change_state_immediately_(false) { 15 change_state_immediately_(false) {
16 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); 16 ResourceBundle& rb = ResourceBundle::GetSharedInstance();
17 state_off_ = rb.GetBitmapNamed(IDR_CONTENT_STAR_OFF); 17 state_off_ = rb.GetBitmapNamed(IDR_CONTENT_STAR_OFF);
18 state_on_ = rb.GetBitmapNamed(IDR_CONTENT_STAR_ON); 18 state_on_ = rb.GetBitmapNamed(IDR_CONTENT_STAR_ON);
19 SetFocusable(true); 19 SetFocusable(true);
20 } 20 }
21 21
22 StarToggle::~StarToggle() { 22 StarToggle::~StarToggle() {
23 } 23 }
24 24
25 void StarToggle::SetState(bool s) { 25 void StarToggle::SetState(bool s) {
26 if (s != state_) { 26 if (s != state_) {
27 state_ = s; 27 state_ = s;
28 SchedulePaint(); 28 SchedulePaint();
29 } 29 }
30 } 30 }
31 31
32 bool StarToggle::GetState() const { 32 bool StarToggle::GetState() const {
33 return state_; 33 return state_;
34 } 34 }
35 35
36 void StarToggle::Paint(ChromeCanvas* canvas) { 36 void StarToggle::Paint(gfx::Canvas* canvas) {
37 PaintFocusBorder(canvas); 37 PaintFocusBorder(canvas);
38 canvas->DrawBitmapInt(state_ ? *state_on_ : *state_off_, 38 canvas->DrawBitmapInt(state_ ? *state_on_ : *state_off_,
39 (width() - state_off_->width()) / 2, 39 (width() - state_off_->width()) / 2,
40 (height() - state_off_->height()) / 2); 40 (height() - state_off_->height()) / 2);
41 } 41 }
42 42
43 gfx::Size StarToggle::GetPreferredSize() { 43 gfx::Size StarToggle::GetPreferredSize() {
44 return gfx::Size(state_off_->width(), state_off_->height()); 44 return gfx::Size(state_off_->width(), state_off_->height());
45 } 45 }
46 46
(...skipping 23 matching lines...) Expand all
70 return false; 70 return false;
71 } 71 }
72 72
73 void StarToggle::SwitchState() { 73 void StarToggle::SwitchState() {
74 const bool new_state = !state_; 74 const bool new_state = !state_;
75 if (change_state_immediately_) 75 if (change_state_immediately_)
76 state_ = new_state; 76 state_ = new_state;
77 SchedulePaint(); 77 SchedulePaint();
78 delegate_->StarStateChanged(new_state); 78 delegate_->StarStateChanged(new_state);
79 } 79 }
OLDNEW
« no previous file with comments | « chrome/browser/views/star_toggle.h ('k') | chrome/browser/views/status_bubble_views.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698