[hyena] [Hyena.Gui.Canvas] Ensure TextBlock's layout text is current
- From: Gabriel Burt <gburt src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [hyena] [Hyena.Gui.Canvas] Ensure TextBlock's layout text is current
- Date: Wed, 17 Nov 2010 22:29:15 +0000 (UTC)
commit 2ddc00021f803db2145ded975b75c29392960b24
Author: Gabriel Burt <gabriel burt gmail com>
Date: Wed Nov 17 16:28:45 2010 -0600
[Hyena.Gui.Canvas] Ensure TextBlock's layout text is current
Hyena.Gui/Hyena.Data.Gui/DataViewLayoutGrid.cs | 1 +
Hyena.Gui/Hyena.Gui.Canvas/TextBlock.cs | 38 ++++++++++++++---------
2 files changed, 24 insertions(+), 15 deletions(-)
---
diff --git a/Hyena.Gui/Hyena.Data.Gui/DataViewLayoutGrid.cs b/Hyena.Gui/Hyena.Data.Gui/DataViewLayoutGrid.cs
index 7870b8d..ef4b14d 100644
--- a/Hyena.Gui/Hyena.Data.Gui/DataViewLayoutGrid.cs
+++ b/Hyena.Gui/Hyena.Data.Gui/DataViewLayoutGrid.cs
@@ -144,6 +144,7 @@ namespace Hyena.Data.Gui
var child = ChildAllocator ();
child.Manager = CanvasManager;
+ child.Measure (Size.Empty);
//child.ParentLayout = this;
return child;
}
diff --git a/Hyena.Gui/Hyena.Gui.Canvas/TextBlock.cs b/Hyena.Gui/Hyena.Gui.Canvas/TextBlock.cs
index e6f01e9..d9f81f7 100644
--- a/Hyena.Gui/Hyena.Gui.Canvas/TextBlock.cs
+++ b/Hyena.Gui/Hyena.Gui.Canvas/TextBlock.cs
@@ -82,21 +82,8 @@ namespace Hyena.Gui.Canvas
layout.SingleParagraphMode = wrap == TextWrap.None;
layout.Ellipsize = EllipsizeMode;
- var text = GetText ();
- if (text != last_text) {
- last_formatted_text = GetFormattedText (text) ?? "";
- last_text = text;
- }
-
- if (TextWrap == TextWrap.None && last_formatted_text.IndexOfAny (lfcr) >= 0) {
- last_formatted_text = last_formatted_text.Replace ("\r\n", "\x20").Replace ('\n', '\x20').Replace ('\r', '\x20');
- }
-
- if (UseMarkup) {
- layout.SetMarkup (last_formatted_text);
- } else {
- layout.SetText (last_formatted_text);
- }
+ // Update layout
+ UpdateLayoutText (GetText ());
layout.GetPixelSize (out text_w, out text_h);
@@ -119,6 +106,26 @@ namespace Hyena.Gui.Canvas
return size;
}
+ private void UpdateLayoutText (string text)
+ {
+ if (text == last_text) {
+ return;
+ }
+
+ last_formatted_text = GetFormattedText (text) ?? "";
+ last_text = text;
+
+ if (TextWrap == TextWrap.None && last_formatted_text.IndexOfAny (lfcr) >= 0) {
+ last_formatted_text = last_formatted_text.Replace ("\r\n", "\x20").Replace ('\n', '\x20').Replace ('\r', '\x20');
+ }
+
+ if (UseMarkup) {
+ layout.SetMarkup (last_formatted_text);
+ } else {
+ layout.SetText (last_formatted_text);
+ }
+ }
+
private string GetText ()
{
if (TextGenerator != null) {
@@ -208,6 +215,7 @@ namespace Hyena.Gui.Canvas
cr.MoveTo (text_alloc.X, text_alloc.Y);
Foreground.Apply (cr);
+ UpdateLayoutText (GetText ());
Pango.CairoHelper.ShowLayout (cr, layout);
cr.Fill ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]