UIMLView.cpp 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630
  1. #include "UIMLView.h"
  2. #include "XML.h"
  3. #include "TextFeld.h"
  4. #include "Knopf.h"
  5. #include "Tabelle.h"
  6. #include "Fenster.h"
  7. #include "Schrift.h"
  8. #include "Bildschirm.h"
  9. #include "Rahmen.h"
  10. #include "Scroll.h"
  11. #include "Bild.h"
  12. using namespace Framework;
  13. // Erstellt eine UIML View
  14. UIMLView::UIMLView()
  15. : ZeichnungHintergrund()
  16. {
  17. style = Style::MEIgnoreInside | Style::MEIgnoreParentInside | Style::MEIgnoreSichtbar | Style::MEIgnoreVerarbeitet;
  18. members = new Trie< Zeichnung >();
  19. dom = 0;
  20. nextId = 0;
  21. memset( &init, 0, sizeof( UIInit ) );
  22. }
  23. // Erstellt eine UIML View zu einem UIML Text
  24. // uiml: Ein xml element gemät des ksg uiml standarts
  25. UIMLView::UIMLView( XML::Element *uiml, UIInit &init )
  26. : ZeichnungHintergrund()
  27. {
  28. this->init = init;
  29. members = new Trie< Zeichnung >();
  30. dom = 0;
  31. nextId = 0;
  32. setUIML( uiml );
  33. }
  34. // Erstellt eine UIML View zu einem UIML Text
  35. // uiml: Ein xml text gemät des ksg uiml standarts
  36. UIMLView::UIMLView( Text uiml, UIInit &init )
  37. {
  38. this->init = init;
  39. members = new Trie< Zeichnung >();
  40. dom = 0;
  41. setUIML( uiml );
  42. }
  43. UIMLView::~UIMLView()
  44. {
  45. if( dom )
  46. dom->release();
  47. members->release();
  48. }
  49. // Verarbeitet ein Maus Ereignis. Wird vom Framework automatisch aufgerufen.
  50. // me: Das Ereignis
  51. void UIMLView::doMausEreignis( MausEreignis &me, bool userRet )
  52. {
  53. if( dom )
  54. {
  55. bool verarbeitet = me.verarbeitet;
  56. me.verarbeitet |= hatStyleNicht( Style::Sichtbar );
  57. bool insideParent = me.insideParent;
  58. if( !hatStyle( Style::Sichtbar ) || !me.insideParent || me.verarbeitet || me.mx < 0 || me.my < 0 || me.mx >= gr.x || me.my >= gr.y || !userRet )
  59. me.insideParent = 0;
  60. int rbr = 0;
  61. if( hatStyle( Style::Rahmen ) && rahmen )
  62. rbr = rahmen->getRBreite();
  63. me.mx -= rbr;
  64. me.my -= rbr;
  65. if( hatStyle( Style::VScroll ) && vertikalScrollBar )
  66. me.my += vertikalScrollBar->getScroll();
  67. if( hatStyle( Style::HScroll ) && horizontalScrollBar )
  68. me.mx += horizontalScrollBar->getScroll();
  69. if( dom )
  70. {
  71. for( auto i = dom->getChilds(); i; i++ )
  72. { // TODO render elements backwards
  73. Zeichnung *z = members->z( i->getAttributeValue( "id" ) );
  74. if( z )
  75. z->doPublicMausEreignis( me );
  76. }
  77. }
  78. me.mx += rbr;
  79. me.my += rbr;
  80. if( hatStyle( Style::VScroll ) && vertikalScrollBar )
  81. me.my -= vertikalScrollBar->getScroll();
  82. if( hatStyle( Style::HScroll ) && horizontalScrollBar )
  83. me.mx -= horizontalScrollBar->getScroll();
  84. if( !hatStyle( Style::Sichtbar ) || !me.insideParent || me.verarbeitet || me.mx < 0 || me.my < 0 || me.mx >= gr.x || me.my >= gr.y || !userRet )
  85. me.insideParent = insideParent;
  86. else
  87. me.verarbeitet = 1;
  88. if( hatStyleNicht( Style::Sichtbar ) )
  89. me.verarbeitet = verarbeitet;
  90. }
  91. }
  92. void UIMLView::parseTable( Iterator<XML::Element *> childs, ObjTabelle *table )
  93. {
  94. for( auto i = childs; i; i++ )
  95. {
  96. Text id;
  97. if( i->hasAttribute( "id" ) )
  98. id = i->getAttributeValue( "id" );
  99. else
  100. {
  101. id = Text( "_" ) += nextId++;
  102. i->setAttribute( "id", id );
  103. }
  104. if( i->getName().istGleich( "tr" ) )
  105. {
  106. table->addZeile( id );
  107. Text line = id;
  108. int c = 1;
  109. for( auto j = i->getChilds(); j; j++ )
  110. {
  111. Zeichnung *z = parseElement( j._ );
  112. if( table->getSpaltenAnzahl() < c )
  113. table->addSpalte( Text( c - 1 ) );
  114. if( z )
  115. table->setZeichnungZ( (char *)Text( c - 1 ), (char *)line, (Zeichnung *)z->getThis() );
  116. c++;
  117. }
  118. }
  119. }
  120. }
  121. void UIMLView::parseFrame( Iterator<XML::Element *> childs, Fenster *frame )
  122. {
  123. for( auto i = childs; i; i++ )
  124. {
  125. Zeichnung *z = parseElement( i._ );
  126. if( z )
  127. frame->addMember( (Zeichnung *)z->getThis() );
  128. }
  129. }
  130. Zeichnung *UIMLView::parseElement( XML::Element *e )
  131. {
  132. Text id;
  133. if( e->hasAttribute( "id" ) )
  134. id = e->getAttributeValue( "id" );
  135. else
  136. {
  137. id = Text( "_" ) += nextId++;
  138. e->setAttribute( "id", id );
  139. }
  140. Zeichnung *z = members->z( id );
  141. if( !z )
  142. {
  143. // precompute attributes
  144. if( e->hasAttribute( "margin" ) )
  145. {
  146. Text m = e->getAttributeValue( "margin" );
  147. if( !e->hasAttribute( "margin-left" ) )
  148. e->setAttribute( "margin-left", m );
  149. if( !e->hasAttribute( "margin-top" ) )
  150. e->setAttribute( "margin-top", m );
  151. if( !e->hasAttribute( "margin-right" ) )
  152. e->setAttribute( "margin-right", m );
  153. if( !e->hasAttribute( "margin-bottom" ) )
  154. e->setAttribute( "margin-bottom", m );
  155. }
  156. if( e->hasAttribute( "class" ) )
  157. {
  158. Text c = e->getAttributeValue( "class" );
  159. while( 1 )
  160. {
  161. Text *t;
  162. if( c.hat( "," ) )
  163. t = c.getTeilText( 0, c.positionVon( ',' ) );
  164. else
  165. t = new Text( c );
  166. XML::Editor ce = dom->selectChildsByName( "class" ).whereAttributeEquals( "id", *t );
  167. for( auto i = ce.getIterator(); i; i++ )
  168. {
  169. for( auto j = i->getAttributeNames(), k = i->getAttributeValues(); j && k; j++, k++ )
  170. {
  171. if( !e->hasAttribute( j->getText() ) )
  172. e->setAttribute( j->getText(), i->getText() );
  173. }
  174. }
  175. t->release();
  176. if( c.hat( "," ) )
  177. c.remove( 0, c.positionVon( ',' + 1 ) );
  178. else
  179. break;
  180. }
  181. }
  182. if( e->hasAttribute( "text-align" ) )
  183. {
  184. if( !e->hasAttribute( "text-align-horizontal" ) )
  185. e->setAttribute( "text-align-horizontal", e->getAttributeValue( "text-align" ) );
  186. if( !e->hasAttribute( "text-align-vertical" ) )
  187. e->setAttribute( "text-align-vertical", e->getAttributeValue( "text-align" ) );
  188. }
  189. // create objects
  190. if( e->getName().istGleich( "textfield" ) ||
  191. e->getName().istGleich( "text" ) ||
  192. e->getName().istGleich( "textarea" ) )
  193. {
  194. TextFeld *t = init.createTextFeld( init.initParam );
  195. if( e->getName().istGleich( "textfield" ) )
  196. t->addStyle( TextFeld::Style::TextFeld );
  197. if( e->getName().istGleich( "text" ) )
  198. t->addStyle( TextFeld::Style::Text );
  199. if( e->getName().istGleich( "textarea" ) )
  200. t->addStyle( TextFeld::Style::TextGebiet );
  201. t->setText( e->getText() );
  202. if( e->hasAttribute( "font-size" ) )
  203. t->setSchriftSize( (unsigned char)(int)e->getAttributeValue( "font-size" ) );
  204. if( e->hasAttribute( "text-align-horizontal" ) )
  205. {
  206. if( e->getAttributeValue( "text-align-horizontal" ).istGleich( "center" ) )
  207. t->addStyle( TextFeld::Style::HCenter );
  208. }
  209. if( e->hasAttribute( "text-align-vertical" ) )
  210. {
  211. if( e->getAttributeValue( "text-align-vertical" ).istGleich( "center" ) )
  212. t->addStyle( TextFeld::Style::VCenter );
  213. }
  214. if( e->hasAttribute( "disabled" ) )
  215. t->removeStyle( TextFeld::Style::Editierbar );
  216. z = t;
  217. }
  218. if( e->getName().istGleich( "button" ) )
  219. {
  220. Knopf *k = init.createKnopf( init.initParam );
  221. k->setText( e->getText() );
  222. if( e->hasAttribute( "font-size" ) )
  223. k->setSchriftSize( (unsigned char)(int)e->getAttributeValue( "font-size" ) );
  224. z = k;
  225. }
  226. if( e->getName().istGleich( "check" ) )
  227. {
  228. KontrollKnopf *k = init.createKontrollKnopf( init.initParam );
  229. k->setText( e->getText() );
  230. k->setSText( e->getText() );
  231. k->setStyle( KontrollKnopf::Style::Selected, e->hasAttribute( "selected" ) );
  232. if( e->hasAttribute( "font-size" ) )
  233. k->setSSize( (unsigned char)(int)e->getAttributeValue( "font-size" ) );
  234. z = k;
  235. }
  236. if( e->getName().istGleich( "table" ) )
  237. {
  238. ObjTabelle *t = init.createObjTabelle( init.initParam );
  239. parseTable( e->getChilds(), t );
  240. if( e->hasAttribute( "scroll" ) )
  241. {
  242. if( e->getAttributeValue( "scroll" ).istGleich( "horizontal" ) )
  243. t->addStyle( ObjTabelle::Style::HScroll );
  244. if( e->getAttributeValue( "scroll" ).istGleich( "vertical" ) )
  245. t->addStyle( ObjTabelle::Style::VScroll );
  246. if( e->getAttributeValue( "scroll" ).istGleich( "both" ) )
  247. t->addStyle( ObjTabelle::Style::scroll );
  248. }
  249. z = t;
  250. }
  251. if( e->getName().istGleich( "frame" ) )
  252. {
  253. Fenster *f = init.createFenster( init.initParam );
  254. parseFrame( e->getChilds(), f );
  255. if( e->hasAttribute( "title" ) )
  256. f->setTitel( e->getAttributeValue( "title" ) );
  257. if( e->hasAttribute( "title-height" ) )
  258. f->zTTextFeld()->setSize( f->zTTextFeld()->getBreite(), e->getAttributeValue( "title-height" ) );
  259. z = f;
  260. }
  261. // add general attributes
  262. if( z && e->hasAttribute( "tooltip" ) )
  263. z->setToolTipText( e->getAttributeValue( "tooltip" ), init.initParam.bildschirm, init.initParam.schrift );
  264. if( z && e->hasAttribute( "style" ) )
  265. z->setStyle( (__int64)e->getAttributeValue( "style" ) );
  266. if( z && e->hasAttribute( "hidden" ) )
  267. z->removeStyle( Zeichnung::Style::Sichtbar );
  268. if( z && e->hasAttribute( "disabled" ) )
  269. z->removeStyle( Zeichnung::Style::Erlaubt );
  270. if( z )
  271. members->set( id, z );
  272. }
  273. return z;
  274. }
  275. void UIMLView::layout( XML::Element *e, int pWidth, int pHeight )
  276. {
  277. Text id = e->getAttributeValue( "id" );
  278. Zeichnung *z = members->z( id );
  279. if( z )
  280. {
  281. int width = z->getBreite();
  282. int height = z->getHeight();
  283. if( e->hasAttribute( "width" ) )
  284. {
  285. Text w = e->getAttributeValue( "width" );
  286. width = w;
  287. if( w.getText()[ w.getLength() - 1 ] == '%' )
  288. width = (int)( ( pWidth / 100.0 ) * width );
  289. }
  290. if( e->hasAttribute( "height" ) )
  291. {
  292. Text h = e->getAttributeValue( "height" );
  293. height = h;
  294. if( h.getText()[ h.getLength() - 1 ] == '%' )
  295. height = (int)( ( pHeight / 100.0 ) * height );
  296. }
  297. z->setSize( width, height );
  298. if( e->hasAttribute( "align-left" ) )
  299. {
  300. Text la = e->getAttributeValue( "align-left" );
  301. int x = 0;
  302. if( la.istGleich( "start" ) )
  303. x = 0;
  304. else if( la.istGleich( "end" ) )
  305. x = pWidth;
  306. else
  307. {
  308. XML::Editor ed = e->zParent()->selectChildsByAttribute( "id", la );
  309. for( auto i = ed.getIterator(); i; i++ )
  310. layout( i, pWidth, pHeight );
  311. Zeichnung *laz = members->z( la );
  312. if( laz )
  313. x = laz->getX() + laz->getBreite();
  314. }
  315. if( e->hasAttribute( "margin-left" ) )
  316. {
  317. Text mt = e->getAttributeValue( "margin-left" );
  318. int m = mt;
  319. if( mt.getText()[ mt.getLength() - 1 ] == '%' )
  320. m = (int)( ( pWidth / 100.0 ) * m );
  321. x += m;
  322. }
  323. z->setX( x );
  324. }
  325. else if( e->hasAttribute( "align-right" ) )
  326. {
  327. Text ra = e->getAttributeValue( "align-right" );
  328. int x = 0;
  329. if( ra.istGleich( "start" ) )
  330. x = -z->getBreite();
  331. else if( ra.istGleich( "end" ) )
  332. x = pWidth - z->getBreite();
  333. else
  334. {
  335. XML::Editor ed = e->zParent()->selectChildsByAttribute( "id", ra );
  336. for( auto i = ed.getIterator(); i; i++ )
  337. layout( i, pWidth, pHeight );
  338. Zeichnung *raz = members->z( ra );
  339. if( raz )
  340. x = raz->getX() - z->getBreite();
  341. }
  342. if( e->hasAttribute( "margin-right" ) )
  343. {
  344. Text mt = e->getAttributeValue( "margin-right" );
  345. int m = mt;
  346. if( mt.getText()[ mt.getLength() - 1 ] == '%' )
  347. m = (int)( ( pWidth / 100.0 ) * m );
  348. x -= m;
  349. }
  350. z->setX( x );
  351. }
  352. if( e->hasAttribute( "align-top" ) )
  353. {
  354. Text ta = e->getAttributeValue( "align-top" );
  355. int y = 0;
  356. if( ta.istGleich( "start" ) )
  357. y = 0;
  358. else if( ta.istGleich( "end" ) )
  359. y = pHeight;
  360. else
  361. {
  362. XML::Editor ed = e->zParent()->selectChildsByAttribute( "id", ta );
  363. for( auto i = ed.getIterator(); i; i++ )
  364. layout( i, pWidth, pHeight );
  365. Zeichnung *taz = members->z( ta );
  366. if( taz )
  367. y = taz->getY() + taz->getHeight();
  368. }
  369. if( e->hasAttribute( "margin-top" ) )
  370. {
  371. Text mt = e->getAttributeValue( "margin-top" );
  372. int m = mt;
  373. if( mt.getText()[ mt.getLength() - 1 ] == '%' )
  374. m = (int)( ( pHeight / 100.0 ) * m );
  375. y += m;
  376. }
  377. z->setY( y );
  378. }
  379. else if( e->hasAttribute( "align-bottom" ) )
  380. {
  381. Text ba = e->getAttributeValue( "align-bottom" );
  382. int y = 0;
  383. if( ba.istGleich( "start" ) )
  384. y = -z->getHeight();
  385. else if( ba.istGleich( "end" ) )
  386. y = pHeight - z->getHeight();
  387. else
  388. {
  389. XML::Editor ed = e->zParent()->selectChildsByAttribute( "id", ba );
  390. for( auto i = ed.getIterator(); i; i++ )
  391. layout( i, pWidth, pHeight );
  392. Zeichnung *baz = members->z( ba );
  393. if( baz )
  394. y = baz->getY() - z->getHeight();
  395. }
  396. if( e->hasAttribute( "margin-bottom" ) )
  397. {
  398. Text mt = e->getAttributeValue( "margin-bottom" );
  399. int m = mt;
  400. if( mt.getText()[ mt.getLength() - 1 ] == '%' )
  401. m = (int)( ( pHeight / 100.0 ) * m );
  402. y -= m;
  403. }
  404. z->setY( y );
  405. }
  406. int x = z->getX();
  407. int y = z->getY();
  408. if( e->hasAttribute( "x" ) )
  409. {
  410. Text xt = e->getAttributeValue( "x" );
  411. x = xt;
  412. if( xt.getText()[ xt.getLength() - 1 ] == '%' )
  413. x = (int)( ( pWidth / 100.0 ) * x );
  414. }
  415. if( e->hasAttribute( "y" ) )
  416. {
  417. Text yt = e->getAttributeValue( "y" );
  418. y = yt;
  419. if( yt.getText()[ yt.getLength() - 1 ] == '%' )
  420. y = (int)( ( pHeight / 100.0 ) * y );
  421. }
  422. z->setPosition( x, y );
  423. if( e->getName().istGleich( "textarea" ) )
  424. {
  425. ( (TextFeld *)z )->zTextRenderer()->textFormatieren( ( (TextFeld *)z )->zText(), z->getInnenBreite() );
  426. }
  427. }
  428. if( z )
  429. {
  430. pWidth = z->getInnenBreite();
  431. pHeight = z->getInnenHeight();
  432. }
  433. // recursive layout
  434. for( auto i = e->getChilds(); i; i++ )
  435. layout( i, pWidth, pHeight );
  436. if( z )
  437. {
  438. if( e->getName().istGleich( "table" ) )
  439. {
  440. ObjTabelle *objT = (ObjTabelle *)z;
  441. if( objT->getZeilenAnzahl() > 0 )
  442. {
  443. if( e->hasAttribute( "line-height" ) )
  444. {
  445. int height = e->getAttributeValue( "line-height" );
  446. for( int i = 0; i < objT->getZeilenAnzahl(); i++ )
  447. objT->setZeilenHeight( i, height );
  448. }
  449. for( int i = 0; i < objT->getSpaltenAnzahl(); i++ )
  450. {
  451. if( objT->zZeichnung( i, 0 ) )
  452. objT->setSpaltenBreite( i, objT->zZeichnung( i, 0 )->getBreite() );
  453. }
  454. }
  455. }
  456. }
  457. }
  458. // setzt den inhalt der view
  459. // uiml: Ein xml element gemät des ksg uiml standarts
  460. void UIMLView::setUIML( XML::Element *uiml )
  461. {
  462. if( dom )
  463. dom->release();
  464. dom = uiml;
  465. members->leeren();
  466. nextId = 0;
  467. if( dom )
  468. {
  469. for( auto i = dom->getChilds(); i; i++ )
  470. {
  471. parseElement( i._ );
  472. }
  473. }
  474. }
  475. // setzt den inhalt der view
  476. // uiml: Ein xml text gemät des ksg uiml standarts
  477. void UIMLView::setUIML( Text uiml )
  478. {
  479. setUIML( new XML::Element( uiml ) );
  480. }
  481. // Gibt eine zeichnung zurück, welche in uiml eine bestimmte id hat
  482. // id: die id der Zeichnung
  483. Zeichnung *UIMLView::zZeichnung( Text id )
  484. {
  485. return members->z( id );
  486. }
  487. // aktualisiert größe und position aller Zeichnungen gemäß den spezifikationen in UIML
  488. void UIMLView::layout()
  489. {
  490. if( dom )
  491. {
  492. for( auto i = dom->getChilds(); i; i++ )
  493. {
  494. layout( i._, this->getInnenBreite(), this->getInnenHeight() );
  495. }
  496. }
  497. }
  498. // fügt ein element hinzu
  499. // uiml: Ein xml text gemät des KSG UIML standarts, welcher das neue Objekt darstellt
  500. Text UIMLView::addMember( Text uiml )
  501. {
  502. XML::Element *e = new XML::Element( uiml );
  503. if( parseElement( e ) )
  504. dom->addChildAtFront( e );
  505. return e->getAttributeValue( "id" );
  506. }
  507. // fügt ein element zu einem Elternelement hinzu (funktioniert momentan nur mit frame Objekten)
  508. // uiml: Ein xml text gemät des KSG UIML standarts, welcher das neue Objekt darstellt
  509. Text UIMLView::addMember( Text uiml, Text parentId )
  510. {
  511. XML::Element *e = new XML::Element( uiml );
  512. XML::Editor ed = dom->selectChildren();
  513. while( ed.getIterator() )
  514. {
  515. XML::Editor ed2 = ed.whereAttributeEquals( "id", parentId );
  516. if( ed2.getIterator() )
  517. {
  518. if( ed2.getIterator()->getName().istGleich( "frame" ) )
  519. {
  520. Zeichnung *z = parseElement( e );
  521. if( z )
  522. {
  523. ( (Fenster *)members->z( parentId ) )->addMember( (Zeichnung *)z->getThis() );
  524. ed2.getIterator()->addChild( e );
  525. }
  526. return e->getAttributeValue( "id" );
  527. }
  528. }
  529. ed = ed.selectChildren();
  530. }
  531. e->release();
  532. return "";
  533. }
  534. // entfernt ein element
  535. // id: id des Elements
  536. void UIMLView::removeMember( Text id )
  537. {
  538. XML::Editor e = dom->selectChildsByAttribute( "id", id );
  539. e.remove();
  540. members->remove( id );
  541. }
  542. // Verarbeitet ein Tastatur Ereignis. Wird vom Framework automatisch aufgerufen
  543. // te: Das Ereignis
  544. void UIMLView::doTastaturEreignis( TastaturEreignis &te )
  545. {
  546. bool verarbeitet = te.verarbeitet;
  547. ZeichnungHintergrund::doTastaturEreignis( te );
  548. te.verarbeitet = verarbeitet;
  549. if( dom )
  550. {
  551. for( auto i = dom->getChilds(); i; i++ )
  552. { // TODO render elements backwards
  553. Zeichnung *z = members->z( i->getAttributeValue( "id" ) );
  554. if( z )
  555. z->doTastaturEreignis( te );
  556. }
  557. }
  558. }
  559. // Updated den Zeichenhintergrund
  560. // tickVal: Die vergangene Zeit in Sekunden, die seit dem Letzten Aufruf dieser Funktion verstrichen ist
  561. // return: 1, wenn das Bild neu gezeichnet werden muss. 0 sonnst
  562. bool UIMLView::tick( double tickVal )
  563. {
  564. if( dom )
  565. {
  566. for( auto i = dom->getChilds(); i; i++ )
  567. { // TODO render elements backwards
  568. Zeichnung *z = members->z( i->getAttributeValue( "id" ) );
  569. if( z )
  570. rend |= z->tick( tickVal );
  571. }
  572. }
  573. return ZeichnungHintergrund::tick( tickVal );
  574. }
  575. // Zeichnet den Hintergrund eines Zeichnunges nach rObj
  576. void UIMLView::render( Bild &rObj )
  577. {
  578. ZeichnungHintergrund::render( rObj );
  579. if( dom )
  580. {
  581. if( !rObj.setDrawOptions( pos.x + getRahmenBreite(), pos.y + getRahmenBreite(), gr.x + getRahmenBreite() * 2, gr.y + getRahmenBreite() * 2 ) )
  582. return;
  583. bool vSc = hatStyle( Style::VScroll ) && vertikalScrollBar;
  584. bool hSc = hatStyle( Style::HScroll ) && horizontalScrollBar;
  585. rObj.addScrollOffset( hSc ? horizontalScrollBar->getScroll() : 0, vSc ? vertikalScrollBar->getScroll() : 0 );
  586. for( int i = dom->getChildCount() - 1; i >= 0; i-- )
  587. { // TODO render elements backwards
  588. XML::Element *e = dom->zChild( i );
  589. Zeichnung *z = members->z( e->getAttributeValue( "id" ) );
  590. if( z )
  591. z->render( rObj );
  592. }
  593. rObj.releaseDrawOptions();
  594. }
  595. }
  596. // Gibt den Dom Tree ohne erhöhten reference counter zurück
  597. // Änderungen am Dom Tree sollten vermieden werden (nur änderungen von attributen einzelner elemente sind erlaubt)
  598. XML::Element *UIMLView::zDom() const
  599. {
  600. return dom;
  601. }
  602. // Gibt den Dom Tree zurück
  603. // Änderungen am Dom Tree sollten vermieden werden (nur änderungen von attributen einzelner elemente sind erlaubt)
  604. XML::Element *UIMLView::getDom() const
  605. {
  606. return dom ? (XML::Element *)dom->getThis() : 0;
  607. }