Author: fejj
Date: 2007-10-03 16:23:41 -0400 (Wed, 03 Oct 2007)
New Revision: 86830
Modified:
trunk/moon/src/ChangeLog
trunk/moon/src/text.cpp
trunk/moon/src/text.h
Log:
2007-10-03 Jeffrey Stedfast <[EMAIL PROTECTED]>
* text.cpp (TextBlock::SetFontSource): Implemented.
Modified: trunk/moon/src/ChangeLog
===================================================================
--- trunk/moon/src/ChangeLog 2007-10-03 19:40:47 UTC (rev 86829)
+++ trunk/moon/src/ChangeLog 2007-10-03 20:23:41 UTC (rev 86830)
@@ -1,3 +1,7 @@
+2007-10-03 Jeffrey Stedfast <[EMAIL PROTECTED]>
+
+ * text.cpp (TextBlock::SetFontSource): Implemented.
+
2007-10-03 Sebastien Pouliot <[EMAIL PROTECTED]>
* brush.cpp|h: SL and Cairo defaults to different values (end
Modified: trunk/moon/src/text.cpp
===================================================================
--- trunk/moon/src/text.cpp 2007-10-03 19:40:47 UTC (rev 86829)
+++ trunk/moon/src/text.cpp 2007-10-03 20:23:41 UTC (rev 86830)
@@ -355,6 +355,7 @@
double size = text_block_get_font_size (this);
foreground = NULL;
+ downloader = NULL;
dirty = true;
actual_height = 0.0;
@@ -409,6 +410,11 @@
delete font.custom;
}
+ if (downloader != NULL) {
+ downloader_abort (downloader);
+ downloader->unref ();
+ }
+
if (foreground != NULL) {
foreground->Detach (NULL, this);
foreground->unref ();
@@ -416,9 +422,37 @@
}
void
-TextBlock::SetFontSource (DependencyObject *downloader)
+TextBlock::SetFontSource (DependencyObject *dl)
{
- ;
+ if (RENDER_USING_PANGO) {
+ fprintf (stderr, "TextBlock::SetFontSource() not supported
using the Pango text layout/rendering engine.\n");
+ return;
+ }
+
+ if (downloader == (Downloader *) dl)
+ return;
+
+ if (downloader) {
+ downloader_abort (downloader);
+ downloader->unref ();
+ downloader = NULL;
+ }
+
+ if (dl) {
+ downloader = (Downloader *) dl;
+ downloader->ref ();
+
+ downloader->AddHandler (downloader->CompletedEvent,
downloader_complete, this);
+ if (downloader->Started () || downloader->Completed ()) {
+ if (downloader->Completed ())
+ DownloaderComplete ();
+ } else {
+ downloader->SetWriteFunc (data_write, size_notify,
this);
+
+ // This is what actually triggers the download
+ downloader->Send ();
+ }
+ }
}
void
@@ -979,7 +1013,41 @@
SetValue (property, &value);
}
+void
+TextBlock::data_write (guchar *buf, gsize offset, gsize count, gpointer data)
+{
+ ;
+}
+void
+TextBlock::size_notify (int64_t size, gpointer data)
+{
+ ;
+}
+
+void
+TextBlock::downloader_complete (EventObject *sender, gpointer calldata,
gpointer closure)
+{
+ ((TextBlock *) closure)->DownloaderComplete ();
+}
+
+void
+TextBlock::DownloaderComplete ()
+{
+ char *filename = downloader_get_response_file (downloader, "");
+
+ /* the download was aborted */
+ if (!filename)
+ return;
+
+ font.custom->SetFilename (filename);
+ g_free (filename);
+ dirty = true;
+
+ UpdateBounds (true);
+ Invalidate ();
+}
+
TextBlock *
text_block_new (void)
{
@@ -1379,10 +1447,9 @@
gunichar *c = text;
while (*c != 0) {
- if (attr && (attr->set & Index)) {
- printf ("glyph index %lu was specified to use
in place of char %c\n", attr->index, (char) *c);
+ if (attr && (attr->set & Index))
glyph = font->GetGlyphInfoByIndex (attr->index);
- } else
+ else
glyph = font->GetGlyphInfo (*c);
if (!glyph)
Modified: trunk/moon/src/text.h
===================================================================
--- trunk/moon/src/text.h 2007-10-03 19:40:47 UTC (rev 86829)
+++ trunk/moon/src/text.h 2007-10-03 20:23:41 UTC (rev 86830)
@@ -106,6 +106,7 @@
TextLayout *custom;
} layout;
MangoRenderer *renderer;
+ Downloader *downloader;
Brush *foreground;
double actual_height;
@@ -135,6 +136,12 @@
void LayoutPango (cairo_t *cr);
void LayoutSilverlight (cairo_t *cr);
+ void DownloaderComplete ();
+
+ static void data_write (guchar *data, gsize n, gsize nn, void *closure);
+ static void downloader_complete (EventObject *sender, gpointer
calldata, gpointer closure);
+ static void size_notify (int64_t size, gpointer data);
+
public:
static DependencyProperty *ActualHeightProperty;
static DependencyProperty *ActualWidthProperty;
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches