OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #ifndef UI_GFX_PANGO_UTIL_H_ | 5 #ifndef UI_GFX_PANGO_UTIL_H_ |
6 #define UI_GFX_PANGO_UTIL_H_ | 6 #define UI_GFX_PANGO_UTIL_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <cairo/cairo.h> | |
9 #include <pango/pango.h> | 10 #include <pango/pango.h> |
11 | |
10 #include "base/i18n/rtl.h" | 12 #include "base/i18n/rtl.h" |
11 #include "base/string16.h" | 13 #include "base/string16.h" |
14 #include "ui/base/ui_export.h" | |
15 #include "third_party/skia/include/core/SkColor.h" | |
12 | 16 |
13 // TODO(xji): move other pango related functions from gtk_util to here. | 17 // TODO(xji): move other pango related functions from gtk_util to here. |
14 | 18 |
15 namespace gfx { | 19 namespace gfx { |
16 | 20 |
17 class Font; | 21 class Font; |
22 class Rect; | |
18 | 23 |
19 // Setup pango layout |layout|, including set layout text as |text|, font | 24 // Setup pango layout |layout|, including set layout text as |text|, font |
20 // description based on |font|, width as |width| in PANGO_SCALE for RTL lcoale, | 25 // description based on |font|, width as |width| in PANGO_SCALE for RTL lcoale, |
21 // and set up whether auto-detect directionality, alignment, ellipsis, word | 26 // and set up whether auto-detect directionality, alignment, ellipsis, word |
22 // wrapping, resolution etc. | 27 // wrapping, resolution etc. |
23 void SetupPangoLayout(PangoLayout* layout, | 28 void SetupPangoLayout(PangoLayout* layout, |
24 const string16& text, | 29 const string16& text, |
25 const gfx::Font& font, | 30 const gfx::Font& font, |
26 int width, | 31 int width, |
27 base::i18n::TextDirection text_direction, | 32 base::i18n::TextDirection text_direction, |
28 int flags); | 33 int flags); |
34 | |
35 // A simple class to quickly do raw pango drawing. | |
36 class UI_EXPORT PangoDrawString { | |
Evan Stade
2011/10/25 23:33:30
seems weird to do
PangoDrawString draw(...);
draw
Elliot Glaysher
2011/10/26 21:06:57
First, I agree this is weird.
The class is split
| |
37 public: | |
38 PangoDrawString(cairo_t* cr, | |
39 const string16& text, | |
40 const gfx::Font& font, | |
41 const gfx::Rect& bounds, | |
42 const gfx::Rect& clip, | |
43 int flags); | |
44 ~PangoDrawString(); | |
45 | |
46 void Draw(const SkColor& text_color); | |
47 | |
48 protected: | |
49 // Draw an underline under the text using |cr|, which must already be | |
50 // initialized with the correct source. |extra_edge_width| is added to the | |
51 // outer edge of the line. Helper method for Draw() and DrawWithHalo(). | |
52 void DrawUnderline(cairo_t* cr, double extra_edge_width); | |
53 | |
54 const gfx::Rect& bounds_; | |
55 int flags_; | |
56 const gfx::Font& font_; | |
57 | |
58 cairo_t* cr_; | |
59 PangoLayout* layout_; | |
60 | |
61 int text_x_; | |
62 int text_y_; | |
63 int text_width_; | |
64 int text_height_; | |
65 | |
66 base::i18n::TextDirection text_direction_; | |
67 }; | |
68 | |
29 } // namespace gfx | 69 } // namespace gfx |
30 | 70 |
31 #endif // UI_GFX_PANGO_UTIL_H_ | 71 #endif // UI_GFX_PANGO_UTIL_H_ |
OLD | NEW |