Browse Source

Fenster zur UIML View hinzugefügt

kolja 5 years ago
parent
commit
64bcd6ab10
2 changed files with 62 additions and 1 deletions
  1. 53 0
      UIMLView.cpp
  2. 9 1
      UIMLView.h

+ 53 - 0
UIMLView.cpp

@@ -3,6 +3,7 @@
 #include "TextFeld.h"
 #include "Knopf.h"
 #include "Tabelle.h"
+#include "Fenster.h"
 #include "Schrift.h"
 #include "Bildschirm.h"
 
@@ -75,6 +76,16 @@ void UIMLView::parseTable( Iterator<XML::Element*> childs, ObjTabelle *table )
     }
 }
 
+void UIMLView::parseFrame( Iterator<XML::Element*> childs, Fenster *frame )
+{
+    for( auto i = childs; i; i++ )
+    {
+        Zeichnung *z = parseElement( i._ );
+        if( z )
+            frame->addMember( z->getThis() );
+    }
+}
+
 Zeichnung *UIMLView::parseElement( XML::Element *e )
 {
     Text id;
@@ -175,6 +186,12 @@ Zeichnung *UIMLView::parseElement( XML::Element *e )
             parseTable( e->getChilds(), t );
             z = t;
         }
+        if( e->getName().istGleich( "frame" ) )
+        {
+            Fenster *f = init.createFenster( init.initParam );
+            parseFrame( e->getChilds(), f );
+            z = f;
+        }
         // add general attributes
         if( z && e->hasAttribute( "tooltip" ) )
             z->setToolTipText( e->getAttributeValue( "tooltip" ), init.initParam.bildschirm );
@@ -399,6 +416,42 @@ void UIMLView::layout()
     }
 }
 
+// fügt ein element hinzu
+//  uiml: Ein xml text gemät des KSG UIML standarts, welcher das neue Objekt darstellt
+void UIMLView::addMember( Text uiml )
+{
+    XML::Element *e = new XML::Element( uiml );
+    if( parseElement( e ) )
+        dom->addChild( e );
+}
+
+// fügt ein element zu einem Elternelement hinzu (funktioniert momentan nur mit frame Objekten)
+//  uiml: Ein xml text gemät des KSG UIML standarts, welcher das neue Objekt darstellt
+void UIMLView::addMember( Text uiml, Text parentId )
+{
+    XML::Element *e = new XML::Element( uiml );
+    XML::Editor ed = dom->selectChildren();
+    while( ed.getIterator() )
+    {
+        XML::Editor ed2 = ed.whereAttributeEquals( "id", parentId );
+        if( ed2.getIterator() )
+        {
+            if( ed2.getIterator()->getName().istGleich( "frame" ) )
+            {
+                Zeichnung *z = parseElement( e );
+                if( z )
+                {
+                    ( (Fenster*)members->z( parentId ) )->addMember( z->getThis() );
+                    ed2.getIterator()->addChild( e );
+                }
+                return;
+            }
+        }
+        ed = ed.selectChildren();
+    }
+    e->release();
+}
+
 // Verarbeitet ein Maus Ereignis. Wird vom Framework automatisch aufgerufen.
 //  me: Das Ereignis
 void UIMLView::doMausEreignis( MausEreignis &me )

+ 9 - 1
UIMLView.h

@@ -15,7 +15,8 @@
     text,
     textarea,
     table (allowed child elements: tr), 
-    tr (allowed child elements: textfield, button, table, text, textarea).
+    tr (allowed child elements: textfield, button, table, text, textarea, frame),
+    frame (allowed child elements: textfield, button, table, text, textarea, frame).
   possible global XML attributes: 
     id (string should be unique), 
     x (integer, optional % char at end), 
@@ -77,6 +78,7 @@ namespace Framework
         XML::Element *dom;
         int nextId;
         void parseTable( Iterator<XML::Element*> childs, ObjTabelle *table );
+        void parseFrame( Iterator<XML::Element*> childs, Fenster *frame );
         Zeichnung *parseElement( XML::Element *e );
         void layout( XML::Element *e, Zeichnung *parent );
 
@@ -102,6 +104,12 @@ namespace Framework
         __declspec( dllexport ) void setUIML( Text uiml );
         // aktualisiert größe und position aller Zeichnungen gemäß den spezifikationen in UIML
         __declspec( dllexport ) void layout();
+        // fügt ein element hinzu
+        //  uiml: Ein xml text gemät des KSG UIML standarts, welcher das neue Objekt darstellt
+        __declspec( dllexport ) void addMember( Text uiml );
+        // fügt ein element zu einem Elternelement hinzu (funktioniert momentan nur mit frame Objekten)
+        //  uiml: Ein xml text gemät des KSG UIML standarts, welcher das neue Objekt darstellt
+        __declspec( dllexport ) void addMember( Text uiml, Text parentId );
         // Gibt eine zeichnung zurück, welche in uiml eine bestimmte id hat
         //  id: die id der Zeichnung
         __declspec( dllexport ) Zeichnung *zZeichnung( Text id );