Browse Source

added class element to uiml

kolja 5 years ago
parent
commit
36d9f78936
2 changed files with 73 additions and 38 deletions
  1. 65 37
      UIMLView.cpp
  2. 8 1
      UIMLView.h

+ 65 - 37
UIMLView.cpp

@@ -101,32 +101,55 @@ Zeichnung *UIMLView::parseElement( XML::Element *e )
             if( !e->hasAttribute( "margin-bottom" ) )
                 e->setAttribute( "margin-bottom", m );
         }
-        // create objects
-        if( e->getName().istGleich( "textfield" ) )
+        if( e->hasAttribute( "class" ) )
         {
-            TextFeld *t = init.createTextFeld( init.initParam );
-            t->setStyle( TextFeld::Style::TextFeld );
-            t->setText( e->getText() );
-            z = t;
-        }
-        if( e->getName().istGleich( "text" ) )
-        {
-            TextFeld *t = init.createTextFeld( init.initParam );
-            t->setStyle( TextFeld::Style::Text );
-            t->setText( e->getText() );
-            z = t;
+            Text c = e->getAttributeValue( "class" );
+            while( 1 )
+            {
+                Text *t;
+                if( c.hat( "," ) )
+                    t = c.getTeilText( 0, c.positionVon( ',' ) );
+                else
+                    t = new Text( c );
+                XML::Editor ce = dom->selectChildsByName( "class" ).whereAttributeEquals( "id", *t );
+                for( auto i = ce.getIterator(); i; i++ )
+                {
+                    for( auto j = i->getAttributeNames(), k = i->getAttributeValues(); j && k; j++, k++ )
+                    {
+                        if( !e->hasAttribute( j->getText() ) )
+                            e->setAttribute( j->getText(), i->getText() );
+                    }
+                }
+                t->release();
+                if( c.hat( "," ) )
+                    c.remove( 0, c.positionVon( ',' + 1 ) );
+                else
+                    break;
+            }
         }
-        if( e->getName().istGleich( "textarea" ) )
+        // create objects
+        if( e->getName().istGleich( "textfield" ) || 
+            e->getName().istGleich( "text" ) ||
+            e->getName().istGleich( "textarea" ) )
         {
             TextFeld *t = init.createTextFeld( init.initParam );
-            t->setStyle( TextFeld::Style::TextGebiet );
+            if( e->getName().istGleich( "textfield" ) )
+                t->setStyle( TextFeld::Style::TextFeld );
+            if( e->getName().istGleich( "text" ) )
+                t->setStyle( TextFeld::Style::Text );
+            if( e->getName().istGleich( "textarea" ) )
+                t->setStyle( TextFeld::Style::TextGebiet );
             t->setText( e->getText() );
+            if( e->hasAttribute( "font-size" ) )
+                t->setSchriftSize( (int)e->getAttributeValue( "font-size" ) );
             z = t;
         }
         if( e->getName().istGleich( "button" ) )
         {
             Knopf *k = init.createKnopf( init.initParam );
             k->setText( e->getText() );
+            if( e->hasAttribute( "font-size" ) )
+                k->setSchriftSize( (int)e->getAttributeValue( "font-size" ) );
             z = k;
         }
         if( e->getName().istGleich( "table" ) )
@@ -140,7 +163,8 @@ Zeichnung *UIMLView::parseElement( XML::Element *e )
             z->setToolTipText( e->getAttributeValue( "tooltip" ), init.initParam.bildschirm );
         if( z && e->hasAttribute( "style" ) )
             z->setStyle( (__int64)e->getAttributeValue( "style" ) );
-        members->set( id, z );
+        if( z )
+            members->set( id, z );
     }
     return z;
 }
@@ -347,12 +371,13 @@ void UIMLView::doMausEreignis( MausEreignis &me )
     bool verarbeitet = me.verarbeitet;
     ZeichnungHintergrund::doMausEreignis( me );
     me.verarbeitet = verarbeitet;
-    for( auto i = members->getIterator(); i; i++ )
+    if( dom )
     {
-        // TODO consider only first level childs
-        if( i._ )
-        {
-            i->doMausEreignis( me );
+        for( auto i = dom->getChilds(); i; i++ )
+        { // TODO render elements backwards
+            Zeichnung *z = members->z( i->getAttributeValue( "id" ) );
+            if( z )
+                z->doMausEreignis( me );
         }
     }
 }
@@ -364,12 +389,13 @@ void UIMLView::doTastaturEreignis( TastaturEreignis &te )
     bool verarbeitet = te.verarbeitet;
     ZeichnungHintergrund::doTastaturEreignis( te );
     te.verarbeitet = verarbeitet;
-    for( auto i = members->getIterator(); i; i++ )
+    if( dom )
     {
-        // TODO consider only first level childs
-        if( i._ )
-        {
-            i->doTastaturEreignis( te );
+        for( auto i = dom->getChilds(); i; i++ )
+        { // TODO render elements backwards
+            Zeichnung *z = members->z( i->getAttributeValue( "id" ) );
+            if( z )
+                z->doTastaturEreignis( te );
         }
     }
 }
@@ -379,12 +405,13 @@ void UIMLView::doTastaturEreignis( TastaturEreignis &te )
 //  return: 1, wenn das Bild neu gezeichnet werden muss. 0 sonnst
 bool UIMLView::tick( double tickVal )
 {
-    for( auto i = members->getIterator(); i; i++ )
+    if( dom )
     {
-        // TODO tick only first level childs
-        if( i._ )
-        {
-            rend |= i->tick( tickVal );
+        for( auto i = dom->getChilds(); i; i++ )
+        { // TODO render elements backwards
+            Zeichnung *z = members->z( i->getAttributeValue( "id" ) );
+            if( z )
+                rend |= z->tick( tickVal );
         }
     }
     return ZeichnungHintergrund::tick( tickVal );
@@ -394,12 +421,13 @@ bool UIMLView::tick( double tickVal )
 void UIMLView::render( Bild &rObj )
 {
     ZeichnungHintergrund::render( rObj );
-    for( auto i = members->getIterator(); i; i++ )
-    { // TODO render elements backwards
-        // TODO render only first level childs
-        if( i._ )
-        {
-            i->render( rObj );
+    if( dom )
+    {
+        for( auto i = dom->getChilds(); i; i++ )
+        { // TODO render elements backwards
+            Zeichnung *z = members->z( i->getAttributeValue( "id" ) );
+            if( z )
+                z->render( rObj );
         }
     }
 }

+ 8 - 1
UIMLView.h

@@ -8,6 +8,8 @@
 /*
   KSG UIML Standart
   possible XML elements: 
+    uimlview (the root element of uiml),
+    class (only as direct child of uimlview),
     textfield, 
     button, 
     text,
@@ -30,11 +32,16 @@
     align-bottom ((string (id values of other elements or keywords: start, end)),
     align-right (string (id values of other elements or keywords: start, end)),
     tooltip (string),
-    style (hex __int64)
+    style (hex __int64),
+    class (string (id of class element))
 
     attribute die sich gegenseitig ausschließen:
     align-left / align-right
     align-top / align-bottom
+
+  spezific attributes:
+     
+
   example:
     <view>
       <textfield id="element_at_top_left" align-left="start", align-top="start", margin-left="5", margin-top="5" width="90%" height="30"/>