Author: fejj
Date: 2007-06-23 12:44:46 -0400 (Sat, 23 Jun 2007)
New Revision: 80600

Modified:
   trunk/moon/src/ChangeLog
   trunk/moon/src/runtime.cpp
   trunk/moon/src/runtime.h
   trunk/moon/src/text.cpp
   trunk/moon/src/text.h
   trunk/moon/src/value.cpp
   trunk/moon/src/xaml.cpp
Log:
2007-06-23  Jeffrey Stedfast  <[EMAIL PROTECTED]>

        * text.cpp (SetValue): Overridden to enforce Text strings not
        preserving any leading nor trailing whitespace (as defined in the
        Silverlight docs).



Modified: trunk/moon/src/ChangeLog
===================================================================
--- trunk/moon/src/ChangeLog    2007-06-23 15:35:08 UTC (rev 80599)
+++ trunk/moon/src/ChangeLog    2007-06-23 16:44:46 UTC (rev 80600)
@@ -1,3 +1,9 @@
+2007-06-23  Jeffrey Stedfast  <[EMAIL PROTECTED]>
+
+       * text.cpp (SetValue): Overridden to enforce Text strings not
+       preserving any leading nor trailing whitespace (as defined in the
+       Silverlight docs).
+
 2007-06-22  Jeffrey Stedfast  <[EMAIL PROTECTED]>
 
        * xaml.cpp (matrix_value_from_str): use delete[] to free the array

Modified: trunk/moon/src/runtime.cpp
===================================================================
--- trunk/moon/src/runtime.cpp  2007-06-23 15:35:08 UTC (rev 80599)
+++ trunk/moon/src/runtime.cpp  2007-06-23 16:44:46 UTC (rev 80600)
@@ -1825,6 +1825,7 @@
                if (current_as_dep)
                        current_as_dep->SetParent (NULL);
        }
+       
        if (value != NULL && value->GetKind () >= Type::DEPENDENCY_OBJECT) {
                DependencyObject *new_as_dep = value->AsDependencyObject ();
                
@@ -1834,7 +1835,6 @@
        if ((current_value == NULL && value != NULL) ||
            (current_value != NULL && value == NULL) ||
            (current_value != NULL && value != NULL && *current_value != 
*value)) {
-
                if (current_value != NULL && current_value->GetKind () >= 
Type::DEPENDENCY_OBJECT){
                        DependencyObject *dob = 
current_value->AsDependencyObject();
 
@@ -1851,16 +1851,11 @@
 
                g_hash_table_insert (current_values, property->name, store);
 
-               if (value) {
-                       if (value->GetKind () >= Type::DEPENDENCY_OBJECT){
-                               DependencyObject *dob = 
value->AsDependencyObject();
-                               
-                               if (dob != NULL)
-                                       dob->Attach (property, this);
-                       }
-
-                       // 
-                       //NotifyAttacheesOfPropertyChange (property);
+               if (value && value->GetKind () >= Type::DEPENDENCY_OBJECT){
+                       DependencyObject *dob = value->AsDependencyObject();
+                       
+                       if (dob != NULL)
+                               dob->Attach (property, this);
                }
 
                OnPropertyChanged (property);

Modified: trunk/moon/src/runtime.h
===================================================================
--- trunk/moon/src/runtime.h    2007-06-23 15:35:08 UTC (rev 80599)
+++ trunk/moon/src/runtime.h    2007-06-23 16:44:46 UTC (rev 80600)
@@ -255,8 +255,8 @@
        static DependencyProperty *GetDependencyProperty (Type::Kind type, 
const char *name);
        static DependencyProperty *GetDependencyProperty (Type::Kind type, 
const char *name, bool inherits);
        static DependencyProperty *NameProperty;
-       void SetValue (DependencyProperty *property, Value value);
-       void SetValue (DependencyProperty *property, Value *value);
+       virtual void SetValue (DependencyProperty *property, Value value);
+       virtual void SetValue (DependencyProperty *property, Value *value);
        void SetValue (const char *name, Value *value);
        void SetValue (const char *name, Value value);
        virtual Value *GetValue (DependencyProperty *property);

Modified: trunk/moon/src/text.cpp
===================================================================
--- trunk/moon/src/text.cpp     2007-06-23 15:35:08 UTC (rev 80599)
+++ trunk/moon/src/text.cpp     2007-06-23 16:44:46 UTC (rev 80600)
@@ -294,6 +294,24 @@
        Inline::OnPropertyChanged (prop);
 }
 
+void
+Run::SetValue (DependencyProperty *prop, Value *value)
+{
+       if (prop == Run::TextProperty && value != NULL) {
+               // Note: Any leading or trailing whitespace is not
+               // preserved when setting the Text property.
+               g_strstrip (value->AsString ());
+       }
+       
+       Inline::SetValue (prop, value);
+}
+
+void
+Run::SetValue (DependencyProperty *prop, Value value)
+{
+       Inline::SetValue (prop, value);
+}
+
 Run *
 run_new (void)
 {
@@ -527,7 +545,7 @@
        if ((prop == TextBlock::ActualWidthProperty ||
             prop == TextBlock::ActualHeightProperty) && block_width < 0.0) {
                Surface *s = item_get_surface (this);
-               printf ("GetValue for actual width/height value requested 
before calculated\n");
+               printf ("GetValue for actual width/height requested before 
calculated\n");
                CalcActualWidthHeight (s ? s->cairo : NULL);
        }
        
@@ -535,6 +553,24 @@
 }
 
 void
+TextBlock::SetValue (DependencyProperty *prop, Value *value)
+{
+       if (prop == TextBlock::TextProperty && value != NULL) {
+               // Note: Any leading or trailing whitespace is not
+               // preserved when setting the Text property.
+               g_strstrip (value->AsString ());
+       }
+       
+       FrameworkElement::SetValue (prop, value);
+}
+
+void
+TextBlock::SetValue (DependencyProperty *prop, Value value)
+{
+       FrameworkElement::SetValue (prop, value);
+}
+
+void
 TextBlock::Layout (cairo_t *cr)
 {
        double width, height, x = 0, y = 0;
@@ -575,6 +611,10 @@
        // element and the overall width/height of each line (for
        // calculating block width/height).
        
+       // FIXME: we need to take the TextWrapping property into
+       // consideration... and possibly embedded \n's? Ugh, this will
+       // be a bitch.
+       
        if (inlines != NULL) {
                Collection::Node *node = (Collection::Node *) 
inlines->list->First ();
                PangoFontMask run_mask, inherited_mask;

Modified: trunk/moon/src/text.h
===================================================================
--- trunk/moon/src/text.h       2007-06-23 15:35:08 UTC (rev 80599)
+++ trunk/moon/src/text.h       2007-06-23 16:44:46 UTC (rev 80600)
@@ -134,6 +134,8 @@
        ~Run ();
        virtual Type::Kind GetObjectType () { return Type::RUN; };
        virtual void OnPropertyChanged (DependencyProperty *prop);
+       virtual void SetValue (DependencyProperty *prop, Value *value);
+       virtual void SetValue (DependencyProperty *prop, Value value);
 };
 
 Run *run_new (void);
@@ -172,6 +174,8 @@
        virtual Point getxformorigin ();
        virtual bool inside_object (Surface *s, double x, double y);
        virtual Value *GetValue (DependencyProperty *prop);
+       virtual void SetValue (DependencyProperty *prop, Value *value);
+       virtual void SetValue (DependencyProperty *prop, Value value);
        virtual void OnPropertyChanged (DependencyProperty *prop);
        virtual void OnSubPropertyChanged (DependencyProperty *prop, 
DependencyProperty *subprop);
        

Modified: trunk/moon/src/value.cpp
===================================================================
--- trunk/moon/src/value.cpp    2007-06-23 15:35:08 UTC (rev 80599)
+++ trunk/moon/src/value.cpp    2007-06-23 16:44:46 UTC (rev 80600)
@@ -200,11 +200,11 @@
        u.keytime = new KeyTime (keytime);
 }
 
-Value::Value (const char* s)
+Value::Value (const char *s)
 {
        Init ();
        k = Type::STRING;
-       u.s= g_strdup (s);
+       u.s = g_strdup (s);
 }
 
 Value::Value (Point *points, int count)

Modified: trunk/moon/src/xaml.cpp
===================================================================
--- trunk/moon/src/xaml.cpp     2007-06-23 15:35:08 UTC (rev 80599)
+++ trunk/moon/src/xaml.cpp     2007-06-23 16:44:46 UTC (rev 80600)
@@ -559,7 +559,8 @@
                lwsp = g_ascii_isspace (p->char_data_buffer->str[len - 1]);
        }
        
-       // Condense multi-lwsp blocks into a single space (and make all lwsp 
chars a literal space, not '\n', etc)
+       // Condense multi-lwsp blocks into a single space (and make
+       // all lwsp chars a literal space, not '\n', etc)
        s = d = p->char_data_buffer->str + len;
        while (*s != '\0') {
                if (g_ascii_isspace (*s)) {

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to