aboutsummaryrefslogtreecommitdiff
path: root/dw
diff options
context:
space:
mode:
authorcorvid <corvid@lavabit.com>2011-07-28 01:53:34 +0000
committercorvid <corvid@lavabit.com>2011-07-28 01:53:34 +0000
commitfba96a118b4c18076b5d2126524af477809b37b2 (patch)
treef8e26ed1d4550f38d270a1cbaf9fa765ff09d017 /dw
parent088c9f87456944790625e772e3d7f1c406f8ed7c (diff)
wrap image alt text
Diffstat (limited to 'dw')
-rw-r--r--dw/fltkpreview.cc8
-rw-r--r--dw/fltkpreview.hh5
-rw-r--r--dw/fltkviewbase.cc18
-rw-r--r--dw/fltkviewbase.hh5
-rw-r--r--dw/image.cc6
-rw-r--r--dw/view.hh5
6 files changed, 43 insertions, 4 deletions
diff --git a/dw/fltkpreview.cc b/dw/fltkpreview.cc
index fbf139c9..907e129c 100644
--- a/dw/fltkpreview.cc
+++ b/dw/fltkpreview.cc
@@ -146,6 +146,14 @@ void FltkPreview::drawText (core::style::Font *font,
fl_draw(text, len, translateCanvasXToViewX (x), translateCanvasYToViewY(y));
}
+void FltkPreview::drawSimpleWrappedText (core::style::Font *font,
+ core::style::Color *color,
+ core::style::Color::Shading shading,
+ int x, int y, int w, int h,
+ const char *text, int len)
+{
+}
+
void FltkPreview::drawImage (core::Imgbuf *imgbuf, int xRoot, int yRoot,
int x, int y, int width, int height)
{
diff --git a/dw/fltkpreview.hh b/dw/fltkpreview.hh
index 06d5a537..9e0f4eb1 100644
--- a/dw/fltkpreview.hh
+++ b/dw/fltkpreview.hh
@@ -42,6 +42,11 @@ public:
core::style::Color *color,
core::style::Color::Shading shading,
int x, int y, const char *text, int len);
+ void drawSimpleWrappedText (core::style::Font *font,
+ core::style::Color *color,
+ core::style::Color::Shading shading,
+ int x, int y, int w, int h,
+ const char *text, int len);
void drawImage (core::Imgbuf *imgbuf, int xRoot, int yRoot,
int x, int y, int width, int height);
diff --git a/dw/fltkviewbase.cc b/dw/fltkviewbase.cc
index a01adf1a..ce8dc475 100644
--- a/dw/fltkviewbase.cc
+++ b/dw/fltkviewbase.cc
@@ -582,6 +582,24 @@ void FltkWidgetView::drawText (core::style::Font *font,
}
}
+/*
+ * "simple" in that it ignores letter-spacing, etc. This was added for image
+ * alt text where none of that matters.
+ */
+void FltkWidgetView::drawSimpleWrappedText (core::style::Font *font,
+ core::style::Color *color,
+ core::style::Color::Shading shading,
+ int X, int Y, int W, int H,
+ const char *text, int len)
+{
+ FltkFont *ff = (FltkFont*)font;
+ fl_font(ff->font, ff->size);
+ fl_color(((FltkColor*)color)->colors[shading]);
+ fl_draw(text,
+ translateCanvasXToViewX (X), translateCanvasYToViewY (Y),
+ W, H, FL_ALIGN_TOP|FL_ALIGN_LEFT|FL_ALIGN_WRAP, NULL, 0);
+}
+
void FltkWidgetView::drawImage (core::Imgbuf *imgbuf, int xRoot, int yRoot,
int X, int Y, int width, int height)
{
diff --git a/dw/fltkviewbase.hh b/dw/fltkviewbase.hh
index 03cf26d8..e6e85694 100644
--- a/dw/fltkviewbase.hh
+++ b/dw/fltkviewbase.hh
@@ -116,6 +116,11 @@ public:
core::style::Color *color,
core::style::Color::Shading shading,
int x, int y, const char *text, int len);
+ void drawSimpleWrappedText (core::style::Font *font,
+ core::style::Color *color,
+ core::style::Color::Shading shading,
+ int x, int y, int w, int h,
+ const char *text, int len);
void drawImage (core::Imgbuf *imgbuf, int xRoot, int yRoot,
int x, int y, int width, int height);
diff --git a/dw/image.cc b/dw/image.cc
index 827cd753..50083151 100644
--- a/dw/image.cc
+++ b/dw/image.cc
@@ -384,11 +384,11 @@ void Image::draw (core::View *view, core::Rectangle *area)
getContentHeight());
}
- usedView->drawText (getStyle()->font, getStyle()->color,
+ usedView->drawSimpleWrappedText (getStyle()->font, getStyle()->color,
core::style::Color::SHADING_NORMAL,
allocation.x + getStyle()->boxOffsetX (),
- allocation.y + getStyle()->boxOffsetY ()
- + getStyle()->font->ascent,
+ allocation.y + getStyle()->boxOffsetY (),
+ getContentWidth(), getContentHeight(),
altText, strlen(altText));
if (clippingView)
diff --git a/dw/view.hh b/dw/view.hh
index f2504091..0c8011c7 100644
--- a/dw/view.hh
+++ b/dw/view.hh
@@ -179,7 +179,10 @@ public:
style::Color *color,
style::Color::Shading shading,
int x, int y, const char *text, int len) = 0;
-
+ virtual void drawSimpleWrappedText (style::Font *font, style::Color *color,
+ style::Color::Shading shading,
+ int x, int y, int w, int h,
+ const char *text, int len) = 0;
virtual void drawImage (Imgbuf *imgbuf, int xRoot, int yRoot,
int x, int y, int width, int height) = 0;