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

Side by Side Diff: chrome/browser/views/options/content_page_view.cc

Issue 20038: Review request: fix 7324 and 7326: missing icon and wrong path in "download location" (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 10 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/options/advanced_contents_view.cc ('k') | chrome/common/l10n_util.h » ('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 <windows.h> 5 #include <windows.h>
6 #include <shlobj.h> 6 #include <shlobj.h>
7 #include <vsstyle.h> 7 #include <vsstyle.h>
8 #include <vssym32.h> 8 #include <vssym32.h>
9 9
10 #include "chrome/browser/views/options/content_page_view.h" 10 #include "chrome/browser/views/options/content_page_view.h"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 } // namespace 45 } // namespace
46 46
47 //////////////////////////////////////////////////////////////////////////////// 47 ////////////////////////////////////////////////////////////////////////////////
48 // FileDisplayArea 48 // FileDisplayArea
49 49
50 class FileDisplayArea : public views::View { 50 class FileDisplayArea : public views::View {
51 public: 51 public:
52 FileDisplayArea(); 52 FileDisplayArea();
53 virtual ~FileDisplayArea(); 53 virtual ~FileDisplayArea();
54 54
55 void SetFile(const std::wstring& file_path); 55 void SetFile(const FilePath& file_path);
56 56
57 // views::View overrides: 57 // views::View overrides:
58 virtual void Paint(ChromeCanvas* canvas); 58 virtual void Paint(ChromeCanvas* canvas);
59 virtual void Layout(); 59 virtual void Layout();
60 virtual gfx::Size GetPreferredSize(); 60 virtual gfx::Size GetPreferredSize();
61 61
62 protected: 62 protected:
63 // views::View overrides: 63 // views::View overrides:
64 virtual void ViewHierarchyChanged(bool is_add, 64 virtual void ViewHierarchyChanged(bool is_add,
65 views::View* parent, 65 views::View* parent,
(...skipping 21 matching lines...) Expand all
87 FileDisplayArea::FileDisplayArea() 87 FileDisplayArea::FileDisplayArea()
88 : text_field_(new views::TextField), 88 : text_field_(new views::TextField),
89 text_field_background_color_(0), 89 text_field_background_color_(0),
90 initialized_(false) { 90 initialized_(false) {
91 InitClass(); 91 InitClass();
92 } 92 }
93 93
94 FileDisplayArea::~FileDisplayArea() { 94 FileDisplayArea::~FileDisplayArea() {
95 } 95 }
96 96
97 void FileDisplayArea::SetFile(const std::wstring& file_path) { 97 void FileDisplayArea::SetFile(const FilePath& file_path) {
98 text_field_->SetText(file_path); 98 // Force file path to have LTR directionality.
99 if (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) {
100 string16 localized_file_path;
101 l10n_util::WrapPathWithLTRFormatting(file_path, &localized_file_path);
102 text_field_->SetText(UTF16ToWide(localized_file_path));
103 } else {
104 text_field_->SetText(file_path.ToWStringHack());
105 }
99 } 106 }
100 107
101 void FileDisplayArea::Paint(ChromeCanvas* canvas) { 108 void FileDisplayArea::Paint(ChromeCanvas* canvas) {
102 HDC dc = canvas->beginPlatformPaint(); 109 HDC dc = canvas->beginPlatformPaint();
103 RECT rect = { 0, 0, width(), height() }; 110 RECT rect = { 0, 0, width(), height() };
104 gfx::NativeTheme::instance()->PaintTextField( 111 gfx::NativeTheme::instance()->PaintTextField(
105 dc, EP_EDITTEXT, ETS_READONLY, 0, &rect, 112 dc, EP_EDITTEXT, ETS_READONLY, 0, &rect,
106 skia::SkColorToCOLORREF(text_field_background_color_), true, true); 113 skia::SkColorToCOLORREF(text_field_background_color_), true, true);
107 canvas->endPlatformPaint(); 114 canvas->endPlatformPaint();
108 canvas->DrawBitmapInt(default_folder_icon_, icon_bounds_.x(), 115 // Mirror left point for icon_bounds_ to draw icon in RTL locales correctly.
116 canvas->DrawBitmapInt(default_folder_icon_,
117 MirroredLeftPointForRect(icon_bounds_),
109 icon_bounds_.y()); 118 icon_bounds_.y());
110 } 119 }
111 120
112 void FileDisplayArea::Layout() { 121 void FileDisplayArea::Layout() {
113 icon_bounds_.SetRect(kFileIconHorizontalSpacing, kFileIconVerticalSpacing, 122 icon_bounds_.SetRect(kFileIconHorizontalSpacing, kFileIconVerticalSpacing,
114 kFileIconSize, kFileIconSize); 123 kFileIconSize, kFileIconSize);
115 gfx::Size ps = text_field_->GetPreferredSize(); 124 gfx::Size ps = text_field_->GetPreferredSize();
116 text_field_->SetBounds(icon_bounds_.right() + kFileIconTextFieldSpacing, 125 text_field_->SetBounds(icon_bounds_.right() + kFileIconTextFieldSpacing,
117 (height() - ps.height()) / 2, 126 (height() - ps.height()) / 2,
118 width() - icon_bounds_.right() - 127 width() - icon_bounds_.right() -
(...skipping 18 matching lines...) Expand all
137 AddChildView(text_field_); 146 AddChildView(text_field_);
138 text_field_background_color_ = 147 text_field_background_color_ =
139 gfx::NativeTheme::instance()->GetThemeColorWithDefault( 148 gfx::NativeTheme::instance()->GetThemeColorWithDefault(
140 gfx::NativeTheme::TEXTFIELD, EP_EDITTEXT, ETS_READONLY, 149 gfx::NativeTheme::TEXTFIELD, EP_EDITTEXT, ETS_READONLY,
141 TMT_FILLCOLOR, COLOR_3DFACE); 150 TMT_FILLCOLOR, COLOR_3DFACE);
142 text_field_->SetReadOnly(true); 151 text_field_->SetReadOnly(true);
143 text_field_->RemoveBorder(); 152 text_field_->RemoveBorder();
144 text_field_->SetBackgroundColor(text_field_background_color_); 153 text_field_->SetBackgroundColor(text_field_background_color_);
145 } 154 }
146 155
156 // static
147 void FileDisplayArea::InitClass() { 157 void FileDisplayArea::InitClass() {
148 static bool initialized = false; 158 static bool initialized = false;
149 if (!initialized) { 159 if (!initialized) {
160 // We'd prefer to use UILayoutIsRightToLeft() to perform the RTL
161 // environment check, but it's nonstatic, so, instead, we check whether the
162 // locale is RTL.
163 bool ui_is_rtl = l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT;
150 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); 164 ResourceBundle& rb = ResourceBundle::GetSharedInstance();
151 default_folder_icon_ = *rb.GetBitmapNamed(IDR_FOLDER_CLOSED); 165 default_folder_icon_ = *rb.GetBitmapNamed(ui_is_rtl ?
166 IDR_FOLDER_CLOSED_RTL :
167 IDR_FOLDER_CLOSED);
152 initialized = true; 168 initialized = true;
153 } 169 }
154 } 170 }
155 171
156 //////////////////////////////////////////////////////////////////////////////// 172 ////////////////////////////////////////////////////////////////////////////////
157 // ContentPageView, public: 173 // ContentPageView, public:
158 174
159 ContentPageView::ContentPageView(Profile* profile) 175 ContentPageView::ContentPageView(Profile* profile)
160 : download_location_group_(NULL), 176 : download_location_group_(NULL),
161 download_default_download_location_display_(NULL), 177 download_default_download_location_display_(NULL),
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after
494 layout->AddView(change_content_fonts_button_); 510 layout->AddView(change_content_fonts_button_);
495 511
496 fonts_lang_group_ = new OptionsGroupView( 512 fonts_lang_group_ = new OptionsGroupView(
497 contents, 513 contents,
498 l10n_util::GetString(IDS_OPTIONS_FONTSANDLANGUAGES_GROUP_NAME), 514 l10n_util::GetString(IDS_OPTIONS_FONTSANDLANGUAGES_GROUP_NAME),
499 L"", true); 515 L"", true);
500 } 516 }
501 517
502 void ContentPageView::UpdateDownloadDirectoryDisplay() { 518 void ContentPageView::UpdateDownloadDirectoryDisplay() {
503 download_default_download_location_display_->SetFile( 519 download_default_download_location_display_->SetFile(
504 default_download_location_.GetValue()); 520 FilePath::FromWStringHack(default_download_location_.GetValue()));
505 } 521 }
506 522
OLDNEW
« no previous file with comments | « chrome/browser/views/options/advanced_contents_view.cc ('k') | chrome/common/l10n_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698