diff options
author | beng@google.com <beng@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-15 02:16:10 +0000 |
---|---|---|
committer | beng@google.com <beng@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-15 02:16:10 +0000 |
commit | 7322c44018c4e7b8bd58c67f52986660fb365d76 (patch) | |
tree | 4bb67ec23689e83682a5aa228e3b8c402880baa8 /views | |
parent | 0c875075a6c45e9979b8345e5f5f9d4b747e05c3 (diff) | |
download | chromium_src-7322c44018c4e7b8bd58c67f52986660fb365d76.zip chromium_src-7322c44018c4e7b8bd58c67f52986660fb365d76.tar.gz chromium_src-7322c44018c4e7b8bd58c67f52986660fb365d76.tar.bz2 |
ChromeFont->gfx::Font
Does not rename the files yet.
http://crbug.com/11387
Review URL: http://codereview.chromium.org/113441
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@16141 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views')
-rw-r--r-- | views/controls/button/native_button.h | 10 | ||||
-rw-r--r-- | views/controls/button/native_button_wrapper.h | 2 | ||||
-rw-r--r-- | views/controls/button/text_button.h | 2 | ||||
-rw-r--r-- | views/controls/combo_box.cc | 2 | ||||
-rw-r--r-- | views/controls/label.cc | 10 | ||||
-rw-r--r-- | views/controls/label.h | 12 | ||||
-rw-r--r-- | views/controls/label_unittest.cc | 4 | ||||
-rw-r--r-- | views/controls/link.cc | 12 | ||||
-rw-r--r-- | views/controls/link.h | 2 | ||||
-rw-r--r-- | views/controls/menu/chrome_menu.cc | 8 | ||||
-rw-r--r-- | views/controls/menu/chrome_menu.h | 4 | ||||
-rw-r--r-- | views/controls/menu/menu_win.cc | 4 | ||||
-rw-r--r-- | views/controls/text_field.cc | 4 | ||||
-rw-r--r-- | views/controls/text_field.h | 6 | ||||
-rw-r--r-- | views/drag_utils.cc | 2 | ||||
-rw-r--r-- | views/widget/tooltip_manager.cc | 16 | ||||
-rw-r--r-- | views/widget/tooltip_manager.h | 6 | ||||
-rw-r--r-- | views/window/custom_frame_view.cc | 6 | ||||
-rw-r--r-- | views/window/custom_frame_view.h | 4 | ||||
-rw-r--r-- | views/window/dialog_client_view.cc | 4 | ||||
-rw-r--r-- | views/window/dialog_client_view.h | 2 | ||||
-rw-r--r-- | views/window/window_win.cc | 4 |
22 files changed, 64 insertions, 62 deletions
diff --git a/views/controls/button/native_button.h b/views/controls/button/native_button.h index 52946d7..8b3fbcf 100644 --- a/views/controls/button/native_button.h +++ b/views/controls/button/native_button.h @@ -9,7 +9,9 @@ #include "views/controls/button/button.h" #include "views/controls/button/native_button_wrapper.h" -class ChromeFont; +namespace gfx { +class Font; +} namespace views { @@ -27,8 +29,8 @@ class NativeButton : public Button { std::wstring label() const { return label_; } // Sets the font to be used when displaying the button's label. - void set_font(const ChromeFont& font) { font_ = font; } - const ChromeFont& font() const { return font_; } + void set_font(const gfx::Font& font) { font_ = font; } + const gfx::Font& font() const { return font_; } // Sets/Gets whether or not the button appears and behaves as the default // button in its current context. @@ -80,7 +82,7 @@ class NativeButton : public Button { bool is_default_; // The font used to render the button label. - ChromeFont font_; + gfx::Font font_; // True if the button should ignore the minimum size for the platform. Default // is false. Set to true to create narrower buttons. diff --git a/views/controls/button/native_button_wrapper.h b/views/controls/button/native_button_wrapper.h index a4cbbc8..4ae939c 100644 --- a/views/controls/button/native_button_wrapper.h +++ b/views/controls/button/native_button_wrapper.h @@ -5,8 +5,6 @@ #ifndef VIEWS_CONTROLS_BUTTON_NATIVE_BUTTON_WRAPPER_H_ #define VIEWS_CONTROLS_BUTTON_NATIVE_BUTTON_WRAPPER_H_ -class ChromeFont; - namespace views { class Checkbox; diff --git a/views/controls/button/text_button.h b/views/controls/button/text_button.h index aeb2b72..e0e547c 100644 --- a/views/controls/button/text_button.h +++ b/views/controls/button/text_button.h @@ -118,7 +118,7 @@ class TextButton : public CustomButton { TextAlignment alignment_; // The font used to paint the text. - ChromeFont font_; + gfx::Font font_; // Text color. SkColor color_; diff --git a/views/controls/combo_box.cc b/views/controls/combo_box.cc index eb079f7..1469c32 100644 --- a/views/controls/combo_box.cc +++ b/views/controls/combo_box.cc @@ -115,7 +115,7 @@ LRESULT ComboBox::OnNotify(int w_param, LPNMHDR l_param) { void ComboBox::UpdateComboBoxFromModel(HWND hwnd) { ::SendMessage(hwnd, CB_RESETCONTENT, 0, 0); - ChromeFont font = ResourceBundle::GetSharedInstance().GetFont( + gfx::Font font = ResourceBundle::GetSharedInstance().GetFont( ResourceBundle::BaseFont); int max_width = 0; int num_items = model_->GetItemCount(this); diff --git a/views/controls/label.cc b/views/controls/label.cc index fde9a9e..aed16b9 100644 --- a/views/controls/label.cc +++ b/views/controls/label.cc @@ -32,11 +32,11 @@ Label::Label(const std::wstring& text) { Init(text, GetDefaultFont()); } -Label::Label(const std::wstring& text, const ChromeFont& font) { +Label::Label(const std::wstring& text, const gfx::Font& font) { Init(text, font); } -void Label::Init(const std::wstring& text, const ChromeFont& font) { +void Label::Init(const std::wstring& text, const gfx::Font& font) { contains_mouse_ = false; font_ = font; text_size_valid_ = false; @@ -184,13 +184,13 @@ void Label::PaintBackground(ChromeCanvas* canvas) { bg->Paint(canvas, this); } -void Label::SetFont(const ChromeFont& font) { +void Label::SetFont(const gfx::Font& font) { font_ = font; text_size_valid_ = false; SchedulePaint(); } -ChromeFont Label::GetFont() const { +gfx::Font Label::GetFont() const { return font_; } @@ -363,7 +363,7 @@ gfx::Insets Label::GetInsets() const { } // static -ChromeFont Label::GetDefaultFont() { +gfx::Font Label::GetDefaultFont() { return ResourceBundle::GetSharedInstance().GetFont(ResourceBundle::BaseFont); } diff --git a/views/controls/label.h b/views/controls/label.h index d5f246e..e9ace3f 100644 --- a/views/controls/label.h +++ b/views/controls/label.h @@ -51,7 +51,7 @@ class Label : public View { // Create a new label with a default font explicit Label(const std::wstring& text); - Label(const std::wstring& text, const ChromeFont& font); + Label(const std::wstring& text, const gfx::Font& font); virtual ~Label(); @@ -74,10 +74,10 @@ class Label : public View { virtual void PaintBackground(ChromeCanvas* canvas); // Set the font. - void SetFont(const ChromeFont& font); + void SetFont(const gfx::Font& font); // Return the font used by this label - ChromeFont GetFont() const; + gfx::Font GetFont() const; // Set the label text. void SetText(const std::wstring& text); @@ -192,7 +192,7 @@ class Label : public View { FRIEND_TEST(LabelTest, DrawSingleLineString); FRIEND_TEST(LabelTest, DrawMultiLineString); - static ChromeFont GetDefaultFont(); + static gfx::Font GetDefaultFont(); // Returns parameters to be used for the DrawString call. void CalculateDrawStringParams(std::wstring* paint_text, @@ -213,10 +213,10 @@ class Label : public View { int ComputeMultiLineFlags(); gfx::Size GetTextSize(); - void Init(const std::wstring& text, const ChromeFont& font); + void Init(const std::wstring& text, const gfx::Font& font); std::wstring text_; GURL url_; - ChromeFont font_; + gfx::Font font_; SkColor color_; gfx::Size text_size_; bool text_size_valid_; diff --git a/views/controls/label_unittest.cc b/views/controls/label_unittest.cc index 1ac74b1..54ee5ca 100644 --- a/views/controls/label_unittest.cc +++ b/views/controls/label_unittest.cc @@ -17,9 +17,9 @@ const int kMinTextDimension = 4; TEST(LabelTest, FontProperty) { Label label; std::wstring font_name(L"courier"); - ChromeFont font = ChromeFont::CreateFont(font_name, 30); + gfx::Font font = gfx::Font::CreateFont(font_name, 30); label.SetFont(font); - ChromeFont font_used = label.GetFont(); + gfx::Font font_used = label.GetFont(); EXPECT_STREQ(font_name.c_str(), font_used.FontName().c_str()); EXPECT_EQ(30, font_used.FontSize()); } diff --git a/views/controls/link.cc b/views/controls/link.cc index aae254503..d89ce4d 100644 --- a/views/controls/link.cc +++ b/views/controls/link.cc @@ -131,17 +131,17 @@ void Link::SetHighlighted(bool f) { } void Link::ValidateStyle() { - ChromeFont font = GetFont(); + gfx::Font font = GetFont(); if (enabled_) { - if ((font.style() & ChromeFont::UNDERLINED) == 0) { + if ((font.style() & gfx::Font::UNDERLINED) == 0) { Label::SetFont(font.DeriveFont(0, font.style() | - ChromeFont::UNDERLINED)); + gfx::Font::UNDERLINED)); } } else { - if ((font.style() & ChromeFont::UNDERLINED) != 0) { + if ((font.style() & gfx::Font::UNDERLINED) != 0) { Label::SetFont(font.DeriveFont(0, font.style() & - ~ChromeFont::UNDERLINED)); + ~gfx::Font::UNDERLINED)); } } @@ -156,7 +156,7 @@ void Link::ValidateStyle() { } } -void Link::SetFont(const ChromeFont& font) { +void Link::SetFont(const gfx::Font& font) { Label::SetFont(font); ValidateStyle(); } diff --git a/views/controls/link.h b/views/controls/link.h index 6da6aa3..4464f28 100644 --- a/views/controls/link.h +++ b/views/controls/link.h @@ -49,7 +49,7 @@ class Link : public Label { virtual bool OnKeyPressed(const KeyEvent& e); virtual bool OverrideAccelerator(const Accelerator& accelerator); - virtual void SetFont(const ChromeFont& font); + virtual void SetFont(const gfx::Font& font); // Set whether the link is enabled. virtual void SetEnabled(bool f); diff --git a/views/controls/menu/chrome_menu.cc b/views/controls/menu/chrome_menu.cc index a1a6809..f0cf28b 100644 --- a/views/controls/menu/chrome_menu.cc +++ b/views/controls/menu/chrome_menu.cc @@ -126,14 +126,14 @@ namespace views { namespace { // Returns the font menus are to use. -ChromeFont GetMenuFont() { +gfx::Font GetMenuFont() { NONCLIENTMETRICS metrics; win_util::GetNonClientMetrics(&metrics); l10n_util::AdjustUIFont(&(metrics.lfMenuFont)); HFONT font = CreateFontIndirect(&metrics.lfMenuFont); DLOG_ASSERT(font); - return ChromeFont::CreateFont(font); + return gfx::Font::CreateFont(font); } // Calculates all sizes that we can from the OS. @@ -1215,7 +1215,7 @@ void MenuItemView::Paint(ChromeCanvas* canvas) { } gfx::Size MenuItemView::GetPreferredSize() { - ChromeFont& font = GetRootMenuItem()->font_; + gfx::Font& font = GetRootMenuItem()->font_; return gfx::Size( font.GetStringWidth(title_) + label_start + item_right_margin, font.height() + GetBottomMargin() + GetTopMargin()); @@ -1487,7 +1487,7 @@ void MenuItemView::Paint(ChromeCanvas* canvas, bool for_drag) { NativeTheme::MENU, MENU_POPUPITEM, state, TMT_TEXTCOLOR, default_sys_color); int width = this->width() - item_right_margin - label_start; - ChromeFont& font = GetRootMenuItem()->font_; + gfx::Font& font = GetRootMenuItem()->font_; gfx::Rect text_bounds(label_start, top_margin, width, font.height()); text_bounds.set_x(MirroredLeftPointForRect(text_bounds)); if (for_drag) { diff --git a/views/controls/menu/chrome_menu.h b/views/controls/menu/chrome_menu.h index 6bb25c7..6622cbd 100644 --- a/views/controls/menu/chrome_menu.h +++ b/views/controls/menu/chrome_menu.h @@ -319,7 +319,7 @@ class MenuItemView : public View { MenuItemView* GetParentMenuItem() const { return parent_menu_item_; } // Sets the font. - void SetFont(const ChromeFont& font) { font_ = font; } + void SetFont(const gfx::Font& font) { font_ = font; } // Sets the title void SetTitle(const std::wstring& title) { @@ -460,7 +460,7 @@ class MenuItemView : public View { SubmenuView* submenu_; // Font. - ChromeFont font_; + gfx::Font font_; // Title. std::wstring title_; diff --git a/views/controls/menu/menu_win.cc b/views/controls/menu/menu_win.cc index 9c85b54..b10d8dc 100644 --- a/views/controls/menu/menu_win.cc +++ b/views/controls/menu/menu_win.cc @@ -107,7 +107,7 @@ class MenuHostWindow : public CWindowImpl<MenuHostWindow, CWindow, MenuWin::ItemData* data = reinterpret_cast<MenuWin::ItemData*>(lpmis->itemData); if (data != NULL) { - ChromeFont font; + gfx::Font font; lpmis->itemWidth = font.GetStringWidth(data->label) + kIconWidth + kItemLeftMargin + kItemRightMargin - GetSystemMetrics(SM_CXMENUCHECK); @@ -161,7 +161,7 @@ class MenuHostWindow : public CWindowImpl<MenuHostWindow, CWindow, SystemParametersInfo(SPI_GETKEYBOARDCUES, 0, &underline_mnemonics, 0); if (!underline_mnemonics) format |= DT_HIDEPREFIX; - ChromeFont font; + gfx::Font font; HGDIOBJ old_font = static_cast<HFONT>(SelectObject(hDC, font.hfont())); int fontsize = font.FontSize(); diff --git a/views/controls/text_field.cc b/views/controls/text_field.cc index 62762f4..76732a1 100644 --- a/views/controls/text_field.cc +++ b/views/controls/text_field.cc @@ -1117,13 +1117,13 @@ void TextField::SetDefaultBackgroundColor() { UpdateEditBackgroundColor(); } -void TextField::SetFont(const ChromeFont& font) { +void TextField::SetFont(const gfx::Font& font) { font_ = font; if (edit_) edit_->SetFont(font.hfont()); } -ChromeFont TextField::GetFont() const { +gfx::Font TextField::GetFont() const { return font_; } diff --git a/views/controls/text_field.h b/views/controls/text_field.h index 6dda5db..c49c7d7 100644 --- a/views/controls/text_field.h +++ b/views/controls/text_field.h @@ -121,10 +121,10 @@ class TextField : public View { void SetDefaultBackgroundColor(); // Set the font. - void SetFont(const ChromeFont& font); + void SetFont(const gfx::Font& font); // Return the font used by this TextField. - ChromeFont GetFont() const; + gfx::Font GetFont() const; // Sets the left and right margin (in pixels) within the text box. On Windows // this is accomplished by packing the left and right margin into a single @@ -173,7 +173,7 @@ class TextField : public View { StyleFlags style_; - ChromeFont font_; + gfx::Font font_; // NOTE: this is temporary until we rewrite TextField to always work whether // there is an HWND or not. diff --git a/views/drag_utils.cc b/views/drag_utils.cc index f312b14..85498b7 100644 --- a/views/drag_utils.cc +++ b/views/drag_utils.cc @@ -118,7 +118,7 @@ void CreateDragImageForFile(const std::wstring& file_name, // Set up our text portion const std::wstring& name = file_util::GetFilenameFromPath(file_name); ResourceBundle& rb = ResourceBundle::GetSharedInstance(); - ChromeFont font = rb.GetFont(ResourceBundle::BaseFont); + gfx::Font font = rb.GetFont(ResourceBundle::BaseFont); const int width = kFileDragImageMaxWidth; // Add +2 here to allow room for the halo. diff --git a/views/widget/tooltip_manager.cc b/views/widget/tooltip_manager.cc index c082040..9ef9ff9 100644 --- a/views/widget/tooltip_manager.cc +++ b/views/widget/tooltip_manager.cc @@ -52,21 +52,21 @@ int TooltipManager::GetTooltipHeight() { return tooltip_height_; } -static ChromeFont DetermineDefaultFont() { +static gfx::Font DetermineDefaultFont() { HWND window = CreateWindowEx( WS_EX_TRANSPARENT | l10n_util::GetExtendedTooltipStyles(), TOOLTIPS_CLASS, NULL, 0 , 0, 0, 0, 0, NULL, NULL, NULL, NULL); HFONT hfont = reinterpret_cast<HFONT>(SendMessage(window, WM_GETFONT, 0, 0)); - ChromeFont font = hfont ? ChromeFont::CreateFont(hfont) : ChromeFont(); + gfx::Font font = hfont ? gfx::Font::CreateFont(hfont) : gfx::Font(); DestroyWindow(window); return font; } // static -ChromeFont TooltipManager::GetDefaultFont() { - static ChromeFont* font = NULL; +gfx::Font TooltipManager::GetDefaultFont() { + static gfx::Font* font = NULL; if (!font) - font = new ChromeFont(DetermineDefaultFont()); + font = new gfx::Font(DetermineDefaultFont()); return *font; } @@ -264,9 +264,9 @@ int TooltipManager::CalcTooltipHeight() { SetMapMode(dc, last_map_mode); ReleaseDC(NULL, dc); } else { - // Tooltip is using the system font. Use ChromeFont, which should pick + // Tooltip is using the system font. Use gfx::Font, which should pick // up the system font. - height = ChromeFont().height(); + height = gfx::Font().height(); } // Get the margins from the tooltip RECT tooltip_margin; @@ -309,7 +309,7 @@ void TooltipManager::TrimTooltipToFit(std::wstring* text, *line_count = static_cast<int>(lines.size()); // Format each line to fit. - ChromeFont font = GetDefaultFont(); + gfx::Font font = GetDefaultFont(); std::wstring result; for (std::vector<std::wstring>::iterator i = lines.begin(); i != lines.end(); ++i) { diff --git a/views/widget/tooltip_manager.h b/views/widget/tooltip_manager.h index 3d5620d..5cfe2bf 100644 --- a/views/widget/tooltip_manager.h +++ b/views/widget/tooltip_manager.h @@ -12,7 +12,9 @@ #include "base/basictypes.h" #include "base/task.h" -class ChromeFont; +namespace gfx { +class Font; +} namespace views { @@ -55,7 +57,7 @@ class TooltipManager { static int GetTooltipHeight(); // Returns the default font used by tooltips. - static ChromeFont GetDefaultFont(); + static gfx::Font GetDefaultFont(); // Returns the separator for lines of text in a tooltip. static const std::wstring& GetLineSeparator(); diff --git a/views/window/custom_frame_view.cc b/views/window/custom_frame_view.cc index 19ce2fb..f7f9ab3 100644 --- a/views/window/custom_frame_view.cc +++ b/views/window/custom_frame_view.cc @@ -23,7 +23,7 @@ namespace views { // static -ChromeFont* CustomFrameView::title_font_ = NULL; +gfx::Font* CustomFrameView::title_font_ = NULL; namespace { // The frame border is only visible in restored mode and is hardcoded to 4 px on @@ -585,10 +585,10 @@ void CustomFrameView::InitClass() { static bool initialized = false; if (!initialized) { #if defined(OS_WIN) - title_font_ = new ChromeFont(win_util::GetWindowTitleFont()); + title_font_ = new gfx::Font(win_util::GetWindowTitleFont()); #elif defined(OS_LINUX) // TODO: need to resolve what font this is. - title_font_ = new ChromeFont(); + title_font_ = new gfx::Font(); #endif initialized = true; } diff --git a/views/window/custom_frame_view.h b/views/window/custom_frame_view.h index ac0b114..0c41009 100644 --- a/views/window/custom_frame_view.h +++ b/views/window/custom_frame_view.h @@ -11,12 +11,12 @@ #include "views/window/window_resources.h" namespace gfx{ +class Font; class Size; class Path; class Point; } class ChromeCanvas; -class ChromeFont; namespace views { @@ -104,7 +104,7 @@ class CustomFrameView : public NonClientFrameView, // Initialize various static resources. static void InitClass(); - static ChromeFont* title_font_; + static gfx::Font* title_font_; DISALLOW_EVIL_CONSTRUCTORS(CustomFrameView); }; diff --git a/views/window/dialog_client_view.cc b/views/window/dialog_client_view.cc index 28c721c..9e25462 100644 --- a/views/window/dialog_client_view.cc +++ b/views/window/dialog_client_view.cc @@ -77,7 +77,7 @@ class DialogButton : public NativeButton { } // namespace // static -ChromeFont* DialogClientView::dialog_button_font_ = NULL; +gfx::Font* DialogClientView::dialog_button_font_ = NULL; static const int kDialogMinButtonWidth = 75; static const int kDialogButtonLabelSpacing = 16; static const int kDialogButtonContentSpacing = 5; @@ -454,7 +454,7 @@ void DialogClientView::InitClass() { static bool initialized = false; if (!initialized) { ResourceBundle& rb = ResourceBundle::GetSharedInstance(); - dialog_button_font_ = new ChromeFont(rb.GetFont(ResourceBundle::BaseFont)); + dialog_button_font_ = new gfx::Font(rb.GetFont(ResourceBundle::BaseFont)); initialized = true; } } diff --git a/views/window/dialog_client_view.h b/views/window/dialog_client_view.h index 347b61c..c1e6ed8 100644 --- a/views/window/dialog_client_view.h +++ b/views/window/dialog_client_view.h @@ -113,7 +113,7 @@ class DialogClientView : public ClientView, // Static resource initialization static void InitClass(); - static ChromeFont* dialog_button_font_; + static gfx::Font* dialog_button_font_; DISALLOW_COPY_AND_ASSIGN(DialogClientView); }; diff --git a/views/window/window_win.cc b/views/window/window_win.cc index c5c92c7..9c06e21 100644 --- a/views/window/window_win.cc +++ b/views/window/window_win.cc @@ -186,7 +186,7 @@ void WindowWin::PopForceHidden() { int Window::GetLocalizedContentsWidth(int col_resource_id) { double chars = _wtof(l10n_util::GetString(col_resource_id).c_str()); ResourceBundle& rb = ResourceBundle::GetSharedInstance(); - ChromeFont font = rb.GetFont(ResourceBundle::BaseFont); + gfx::Font font = rb.GetFont(ResourceBundle::BaseFont); int width = font.GetExpectedTextWidth(static_cast<int>(chars)); DCHECK(width > 0); return width; @@ -196,7 +196,7 @@ int Window::GetLocalizedContentsWidth(int col_resource_id) { int Window::GetLocalizedContentsHeight(int row_resource_id) { double lines = _wtof(l10n_util::GetString(row_resource_id).c_str()); ResourceBundle& rb = ResourceBundle::GetSharedInstance(); - ChromeFont font = rb.GetFont(ResourceBundle::BaseFont); + gfx::Font font = rb.GetFont(ResourceBundle::BaseFont); int height = static_cast<int>(font.height() * lines); DCHECK(height > 0); return height; |