Index: ui/gfx/pango_util.h |
diff --git a/ui/gfx/pango_util.h b/ui/gfx/pango_util.h |
index a49ffaab379769a2741be63ab0fd12dd8d625b6b..2bfecd202068f44e4e0dcc88e1372da912455f6d 100644 |
--- a/ui/gfx/pango_util.h |
+++ b/ui/gfx/pango_util.h |
@@ -6,15 +6,20 @@ |
#define UI_GFX_PANGO_UTIL_H_ |
#pragma once |
+#include <cairo/cairo.h> |
#include <pango/pango.h> |
+ |
#include "base/i18n/rtl.h" |
#include "base/string16.h" |
+#include "ui/base/ui_export.h" |
+#include "third_party/skia/include/core/SkColor.h" |
// TODO(xji): move other pango related functions from gtk_util to here. |
namespace gfx { |
class Font; |
+class Rect; |
// Setup pango layout |layout|, including set layout text as |text|, font |
// description based on |font|, width as |width| in PANGO_SCALE for RTL lcoale, |
@@ -26,6 +31,41 @@ void SetupPangoLayout(PangoLayout* layout, |
int width, |
base::i18n::TextDirection text_direction, |
int flags); |
+ |
+// A simple class to quickly do raw pango drawing. |
+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
|
+ public: |
+ PangoDrawString(cairo_t* cr, |
+ const string16& text, |
+ const gfx::Font& font, |
+ const gfx::Rect& bounds, |
+ const gfx::Rect& clip, |
+ int flags); |
+ ~PangoDrawString(); |
+ |
+ void Draw(const SkColor& text_color); |
+ |
+ protected: |
+ // Draw an underline under the text using |cr|, which must already be |
+ // initialized with the correct source. |extra_edge_width| is added to the |
+ // outer edge of the line. Helper method for Draw() and DrawWithHalo(). |
+ void DrawUnderline(cairo_t* cr, double extra_edge_width); |
+ |
+ const gfx::Rect& bounds_; |
+ int flags_; |
+ const gfx::Font& font_; |
+ |
+ cairo_t* cr_; |
+ PangoLayout* layout_; |
+ |
+ int text_x_; |
+ int text_y_; |
+ int text_width_; |
+ int text_height_; |
+ |
+ base::i18n::TextDirection text_direction_; |
+}; |
+ |
} // namespace gfx |
#endif // UI_GFX_PANGO_UTIL_H_ |