Zeichnung.cpp 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982
  1. #include "Zeichnung.h"
  2. #include "MausEreignis.h"
  3. #include "TastaturEreignis.h"
  4. #include "Globals.h"
  5. #include "ToolTip.h"
  6. #include "Scroll.h"
  7. #include "Text.h"
  8. #include "Rahmen.h"
  9. #include "AlphaFeld.h"
  10. #include "Bild.h"
  11. #ifdef WIN32
  12. #include <Windows.h>
  13. #endif
  14. using namespace Framework;
  15. // Inhalt der Zeichnung Klasse aus Zeichnung.h
  16. // Konstruktor
  17. Zeichnung::Zeichnung()
  18. : pos( 0, 0 ),
  19. gr( 0, 0 ),
  20. makParam( 0 ),
  21. takParam( 0 ),
  22. mak( 0 ),
  23. tak( 0 ),
  24. nmakParam( 0 ),
  25. ntakParam( 0 ),
  26. nMak( 0 ),
  27. nTak( 0 ),
  28. mausIn( 0 ),
  29. toolTip( 0 ),
  30. rend( 0 )
  31. {}
  32. // Destruktor
  33. Zeichnung::~Zeichnung()
  34. {
  35. if( toolTip )
  36. toolTip->release();
  37. }
  38. // Übergibt einen Void Funktionspointer auf eine Aktion die einmalig vom Hauptthread ausgeführt werden soll. (Passiert nach dem Tick)
  39. void Zeichnung::postAction( std::function< void() > action )
  40. {
  41. actions.push( action );
  42. }
  43. // nicht constant
  44. void Zeichnung::setRender()
  45. {
  46. rend = 1;
  47. }
  48. void Zeichnung::setToolTipText( const char *txt, Bildschirm *zScreen )
  49. {
  50. if( !txt )
  51. toolTip = (ToolTip*)toolTip->release();
  52. else
  53. {
  54. if( !toolTip )
  55. toolTip = new ToolTip( zScreen );
  56. toolTip->setText( txt );
  57. }
  58. }
  59. void Zeichnung::lockZeichnung()
  60. {
  61. cs.lock();
  62. }
  63. void Zeichnung::unlockZeichnung()
  64. {
  65. cs.unlock();
  66. }
  67. void Zeichnung::setMausEreignisParameter( void *p ) // setzt den Parameter vom Maus Ereignis
  68. {
  69. makParam = p;
  70. }
  71. void Zeichnung::setTastaturEreignisParameter( void *p ) // setzt den Parameter vom Tastatur Ereignis
  72. {
  73. takParam = p;
  74. }
  75. void Zeichnung::setMausEreignis( std::function< bool( void*, void*, MausEreignis ) > ak ) // setzt das Maus Ereignis
  76. {
  77. mak = ak;
  78. }
  79. void Zeichnung::setTastaturEreignis( std::function< bool( void*, void*, TastaturEreignis ) > ak ) // setzt das TastaturEreignis
  80. {
  81. tak = ak;
  82. }
  83. void Zeichnung::setNMausEreignisParameter( void *p ) // setzt den Parameter vom Maus Ereignis
  84. {
  85. nmakParam = p;
  86. }
  87. void Zeichnung::setNTastaturEreignisParameter( void *p ) // setzt den Parameter vom Tastatur Ereignis
  88. {
  89. ntakParam = p;
  90. }
  91. void Zeichnung::setNMausEreignis( std::function< bool( void*, void*, MausEreignis ) > ak ) // setzt das Maus Ereignis
  92. {
  93. nMak = ak;
  94. }
  95. void Zeichnung::setNTastaturEreignis( std::function< bool( void*, void*, TastaturEreignis ) > ak ) // setzt das TastaturEreignis
  96. {
  97. nTak = ak;
  98. }
  99. void Zeichnung::doMausEreignis( MausEreignis &me ) // ruft Mak auf
  100. {
  101. if( me.verarbeitet || ( !( me.mx >= pos.x && me.mx <= pos.x + gr.x && me.my >= pos.y && me.my <= pos.y + gr.y ) && me.id != ME_Leaves ) )
  102. {
  103. if( mausIn )
  104. {
  105. mausIn = 0;
  106. if( toolTip )
  107. toolTip->setMausIn( 0 );
  108. MausEreignis me2;
  109. me2.id = ME_Leaves;
  110. me2.mx = me.mx;
  111. me2.my = me.my;
  112. me2.verarbeitet = 0;
  113. doMausEreignis( me2 );
  114. }
  115. return;
  116. }
  117. if( !mausIn && me.id != ME_Leaves )
  118. {
  119. mausIn = 1;
  120. if( toolTip )
  121. toolTip->setMausIn( 1 );
  122. MausEreignis me2;
  123. me2.id = ME_Betritt;
  124. me2.mx = me.mx;
  125. me2.my = me.my;
  126. me2.verarbeitet = 0;
  127. doMausEreignis( me2 );
  128. }
  129. me.mx -= pos.x, me.my -= pos.y;
  130. if( mak )
  131. me.verarbeitet |= mak( makParam, this, me );
  132. if( nMak && me.verarbeitet )
  133. me.verarbeitet = nMak( nmakParam, this, me );
  134. me.mx += pos.x, me.my += pos.y;
  135. }
  136. void Zeichnung::doTastaturEreignis( TastaturEreignis &te ) // ruft Tak auf
  137. {
  138. if( te.verarbeitet )
  139. return;
  140. if( tak )
  141. te.verarbeitet |= tak( takParam, this, te );
  142. if( nTak && te.verarbeitet )
  143. te.verarbeitet = nTak( ntakParam, this, te );
  144. }
  145. void Zeichnung::setPosition( const Punkt &pos ) // setzt die position
  146. {
  147. lockZeichnung();
  148. if( this->pos != pos )
  149. rend = 1;
  150. this->pos = pos;
  151. unlockZeichnung();
  152. }
  153. void Zeichnung::setX( int xPos )
  154. {
  155. lockZeichnung();
  156. if( pos.x != xPos )
  157. {
  158. rend = 1;
  159. pos.x = xPos;
  160. }
  161. unlockZeichnung();
  162. }
  163. void Zeichnung::setY( int yPos )
  164. {
  165. lockZeichnung();
  166. if( pos.y != yPos )
  167. {
  168. rend = 1;
  169. pos.y = yPos;
  170. }
  171. unlockZeichnung();
  172. }
  173. void Zeichnung::setSize( const Punkt &gr ) // setzt die Größe
  174. {
  175. lockZeichnung();
  176. if( this->gr != gr )
  177. rend = 1;
  178. this->gr = gr;
  179. unlockZeichnung();
  180. }
  181. void Zeichnung::setPosition( int x, int y ) // setzt die position
  182. {
  183. setPosition( Punkt( x, y ) );
  184. }
  185. void Zeichnung::setSize( int x, int y ) // setzt die Größe
  186. {
  187. setSize( Punkt( x, y ) );
  188. }
  189. bool Zeichnung::tick( double tickval )
  190. {
  191. while( !actions.empty() )
  192. {
  193. actions.front()();
  194. actions.pop();
  195. }
  196. bool r = rend;
  197. rend = 0;
  198. return r;
  199. }
  200. void Zeichnung::setStyle( __int64 style ) // setzt den Style des Text Feldes
  201. {
  202. if( this->style != style )
  203. {
  204. this->style = style;
  205. rend = 1;
  206. }
  207. }
  208. void Zeichnung::setStyle( __int64 style, bool add_remove )
  209. {
  210. if( add_remove && ( this->style | style ) != this->style )
  211. {
  212. this->style |= style;
  213. rend = 1;
  214. }
  215. else if( !add_remove && ( this->style & ~style ) != this->style )
  216. {
  217. if( toolTip && ( style | Style::Sichtbar ) == style )
  218. toolTip->setMausIn( 0 );
  219. this->style &= ~style;
  220. rend = 1;
  221. }
  222. }
  223. void Zeichnung::addStyle( __int64 style )
  224. {
  225. if( ( this->style | style ) != this->style )
  226. {
  227. this->style |= style;
  228. rend = 1;
  229. }
  230. }
  231. void Zeichnung::removeStyle( __int64 style )
  232. {
  233. if( ( this->style & ~style ) != this->style )
  234. {
  235. if( toolTip && ( style | Style::Sichtbar ) == style )
  236. toolTip->setMausIn( 0 );
  237. this->style &= ~style;
  238. rend = 1;
  239. }
  240. }
  241. void Zeichnung::render( Bild &zRObj )
  242. {
  243. if( toolTip && ( style | Style::Sichtbar ) == style )
  244. toolTip->setZeichnen();
  245. }
  246. // constant
  247. bool Zeichnung::hatMausEreignis() const // prüft, ob Mak gesetzt ist
  248. {
  249. return mak != 0;
  250. }
  251. bool Zeichnung::hatTastaturEreignis() const // prüft, ob Tak gesetzt ist
  252. {
  253. return tak != 0;
  254. }
  255. const Punkt &Zeichnung::getPosition() const // gibt die Position zurück
  256. {
  257. return pos;
  258. }
  259. const Punkt &Zeichnung::getSize() const // gibt die Größe zurück
  260. {
  261. return gr;
  262. }
  263. int Zeichnung::getBreite() const // gibt die Breite zurück
  264. {
  265. return gr.x;
  266. }
  267. int Zeichnung::getHeight() const // gibt die Höhe zurück
  268. {
  269. return gr.y;
  270. }
  271. int Zeichnung::getX() const // gibt X zurück
  272. {
  273. return pos.x;
  274. }
  275. int Zeichnung::getY() const // gibt Y zurück
  276. {
  277. return pos.y;
  278. }
  279. ToolTip *Zeichnung::getToolTip() const // gibt den ToolTip Text
  280. {
  281. return (ToolTip*)toolTip->getThis();
  282. }
  283. ToolTip *Zeichnung::zToolTip() const
  284. {
  285. return toolTip;
  286. }
  287. bool Zeichnung::hatStyle( __int64 style ) const // prüft, ob style vorhanden
  288. {
  289. return ( this->style | style ) == this->style;
  290. }
  291. bool Zeichnung::hatStyleNicht( __int64 style ) const // prüft, ob style nicht vorhanden
  292. {
  293. return ( this->style | style ) != this->style;
  294. }
  295. Zeichnung *Zeichnung::dublizieren() const // Erzeugt eine Kopie des Zeichnungs
  296. {
  297. Zeichnung *obj = new Zeichnung();
  298. obj->setPosition( pos );
  299. obj->setSize( gr );
  300. obj->setMausEreignisParameter( makParam );
  301. obj->setTastaturEreignisParameter( takParam );
  302. obj->setMausEreignis( mak );
  303. obj->setTastaturEreignis( tak );
  304. if( toolTip )
  305. obj->setToolTipText( toolTip->zText()->getText(), toolTip->zBildschirm() );
  306. return obj;
  307. }
  308. // Inhalt der ZeichnungArray Klasse aus Zeichnung.h
  309. // Konstruktor
  310. ZeichnungArray::ZeichnungArray()
  311. : This( 0 ),
  312. next( 0 )
  313. {}
  314. // Destruktor
  315. ZeichnungArray::~ZeichnungArray()
  316. {
  317. delete next;
  318. }
  319. // nicht const
  320. bool ZeichnungArray::addZeichnung( Zeichnung *obj ) // Fügt ein Zeichnung hinzu
  321. {
  322. if( obj == This )
  323. return 0;
  324. if( !This )
  325. {
  326. This = obj;
  327. return 1;
  328. }
  329. if( !next )
  330. next = new ZeichnungArray();
  331. return next->addZeichnung( obj );
  332. }
  333. bool ZeichnungArray::removeZeichnung( Zeichnung *obj ) // Entfernt ein Zeichnung
  334. {
  335. if( obj == This )
  336. {
  337. if( index == 0 )
  338. {
  339. if( next )
  340. {
  341. This = next->getZeichnung();
  342. ZeichnungArray *tmp = next->getNext();
  343. next->setNext0();
  344. delete next;
  345. next = tmp;
  346. }
  347. else
  348. This = 0;
  349. return 0;
  350. }
  351. return 1;
  352. }
  353. if( !next )
  354. return 0;
  355. if( next->removeZeichnung( obj ) )
  356. {
  357. ZeichnungArray *tmp = next->getNext();
  358. next->setNext0();
  359. delete next;
  360. next = tmp;
  361. }
  362. return 0;
  363. }
  364. bool ZeichnungArray::removeZeichnung( int i ) // Entfernt das von diesem aus i-te Zeichnung
  365. {
  366. if( i == index )
  367. {
  368. if( index == 0 )
  369. {
  370. This = next->getZeichnung();
  371. ZeichnungArray *tmp = next->getNext();
  372. next->setNext0();
  373. delete next;
  374. next = tmp;
  375. return 0;
  376. }
  377. return 1;
  378. }
  379. if( !next )
  380. return 0;
  381. if( next->removeZeichnung( i ) )
  382. {
  383. ZeichnungArray *tmp = next->getNext();
  384. next->setNext0();
  385. delete next;
  386. next = tmp;
  387. }
  388. return 0;
  389. }
  390. void ZeichnungArray::setNext0() // Setzt das nächste Zeichnung zu 0
  391. {
  392. next = 0;
  393. }
  394. void ZeichnungArray::updateIndex( int i ) // aktualisiert die Index variable
  395. {
  396. index = i;
  397. if( next )
  398. next->updateIndex( i + 1 );
  399. }
  400. // constant
  401. ZeichnungArray *ZeichnungArray::getNext() const // gibt das nächste Zeichnung zurück
  402. {
  403. return next;
  404. }
  405. Zeichnung *ZeichnungArray::getZeichnung( int i ) const // gibt das von diesem aus i-te Zeichnung zurück
  406. {
  407. if( i == index )
  408. return This;
  409. if( !next )
  410. return 0;
  411. return next->getZeichnung( i );
  412. }
  413. Zeichnung *ZeichnungArray::getZeichnung() const // gibt das von diesem aus i-te Zeichnung zurück
  414. {
  415. return This;
  416. }
  417. int ZeichnungArray::getIndex() const // Gibt den Index zurück
  418. {
  419. return index;
  420. }
  421. void ZeichnungArray::sendMausAll( MausEreignis &me ) const // sendet me an alle volgenden Zeichnunge
  422. {
  423. if( next )
  424. next->sendMausAll( me );
  425. if( This )
  426. This->doMausEreignis( me );
  427. }
  428. void ZeichnungArray::sendTastaturAll( TastaturEreignis &te ) const // sendet te an alle volgenden Zeichnunge
  429. {
  430. if( next )
  431. next->sendTastaturAll( te );
  432. if( This )
  433. This->doTastaturEreignis( te );
  434. }
  435. void ZeichnungArray::render( Bild &zRObj )
  436. {
  437. if( This )
  438. This->render( zRObj );
  439. if( next )
  440. next->render( zRObj );
  441. }
  442. bool ZeichnungArray::tick( double tickval )
  443. {
  444. return ( This && This->tick( tickval ) ) | ( next && next->tick( tickval ) );
  445. }
  446. // Inhalt der ZeichnungHintergrund Klasse aus Zeichnung.h
  447. // Konstruktor
  448. ZeichnungHintergrund::ZeichnungHintergrund()
  449. : Zeichnung()
  450. {
  451. hintergrundFarbe = 0xFF000000;
  452. rahmen = 0;
  453. hintergrundBild = 0;
  454. hintergrundFeld = 0;
  455. horizontalScrollBar = 0;
  456. vertikalScrollBar = 0;
  457. innenPosition.x = 0;
  458. innenPosition.y = 0;
  459. innenSize.x = 0;
  460. innenSize.y = 0;
  461. }
  462. // Destruktor
  463. ZeichnungHintergrund::~ZeichnungHintergrund()
  464. {
  465. if( rahmen )
  466. rahmen->release();
  467. if( hintergrundBild )
  468. hintergrundBild->release();
  469. if( hintergrundFeld )
  470. hintergrundFeld->release();
  471. if( horizontalScrollBar )
  472. horizontalScrollBar->release();
  473. if( vertikalScrollBar )
  474. vertikalScrollBar->release();
  475. }
  476. void ZeichnungHintergrund::setHintergrundBild( Bild *bild ) // setzt das Hintergrund Bild
  477. {
  478. if( !hintergrundBild )
  479. hintergrundBild = new Bild();
  480. hintergrundBild->neuBild( bild->getBreite(), bild->getHeight(), 0 );
  481. int *buff1 = hintergrundBild->getBuffer();
  482. int *buff2 = bild->getBuffer();
  483. for( int i = 0; i < bild->getBreite() * bild->getHeight(); ++i )
  484. buff1[ i ] = buff2[ i ];
  485. bild->release();
  486. rend = 1;
  487. }
  488. void ZeichnungHintergrund::setHintergrundBildZ( Bild *bild ) // setzt einen Zeiger zum Hintergrund Bild
  489. {
  490. if( hintergrundBild != bild )
  491. {
  492. if( hintergrundBild )
  493. hintergrundBild->release();
  494. hintergrundBild = bild;
  495. rend = 1;
  496. }
  497. }
  498. void ZeichnungHintergrund::setHintergrundFarbe( int fc ) // setzt die Hintergrundfarbe
  499. {
  500. if( hintergrundFarbe != fc )
  501. {
  502. hintergrundFarbe = fc;
  503. rend = 1;
  504. }
  505. }
  506. void ZeichnungHintergrund::setAlphaFeldZ( AlphaFeld *buff ) // setzt einen Zeiger zum Hintergrund Buffer
  507. {
  508. if( hintergrundFeld != buff )
  509. {
  510. if( hintergrundFeld )
  511. hintergrundFeld->release();
  512. hintergrundFeld = buff;
  513. rend = 1;
  514. }
  515. }
  516. void ZeichnungHintergrund::setAlphaFeldStrength( int st ) // setzt die Stärke des Hintergrund Buffers
  517. {
  518. if( !hintergrundFeld )
  519. {
  520. hintergrundFeld = new AlphaFeld();
  521. rend = 1;
  522. }
  523. if( hintergrundFeld->getStrength() != st )
  524. {
  525. hintergrundFeld->setStrength( st );
  526. rend = 1;
  527. }
  528. }
  529. void ZeichnungHintergrund::setAlphaFeldFarbe( int fc ) // setzt die Farbe des Hintergrund Buffers
  530. {
  531. if( !hintergrundFeld )
  532. {
  533. hintergrundFeld = new AlphaFeld();
  534. rend = 1;
  535. }
  536. if( hintergrundFeld->getFarbe() != fc )
  537. {
  538. hintergrundFeld->setFarbe( fc );
  539. rend = 1;
  540. }
  541. }
  542. void ZeichnungHintergrund::setLinienRahmenZ( LRahmen *ram ) // setzt einen Zeiger zum Rahmen
  543. {
  544. if( rahmen != ram )
  545. {
  546. if( rahmen )
  547. rahmen->release();
  548. rahmen = ram;
  549. rend = 1;
  550. }
  551. }
  552. void ZeichnungHintergrund::setLinienRahmenBreite( int br ) // setzt die Breite des Rahmens
  553. {
  554. if( !rahmen )
  555. {
  556. rahmen = new LRahmen();
  557. rend = 1;
  558. }
  559. if( rahmen->getRBreite() != br )
  560. {
  561. rahmen->setRamenBreite( br );
  562. rend = 1;
  563. }
  564. }
  565. void ZeichnungHintergrund::setLinienRahmenFarbe( int fc ) // setzt die Farbe des Rahmens
  566. {
  567. if( !rahmen )
  568. {
  569. rahmen = new LRahmen();
  570. rend = 1;
  571. }
  572. if( rahmen->getFarbe() != fc )
  573. {
  574. rahmen->setFarbe( fc );
  575. rend = 1;
  576. }
  577. }
  578. void ZeichnungHintergrund::setVertikalKlickScroll( int ks ) // setzt die vertikale Scroll geschwindigkeit
  579. {
  580. if( !vertikalScrollBar )
  581. {
  582. vertikalScrollBar = new VScrollBar();
  583. rend = 1;
  584. }
  585. if( vertikalScrollBar->getKlickScroll() != ks )
  586. {
  587. vertikalScrollBar->setKlickScroll( ks );
  588. rend = 1;
  589. }
  590. }
  591. void ZeichnungHintergrund::setVertikalScrollPos( int pos ) // setzt die vertikale Scroll Position
  592. {
  593. if( !vertikalScrollBar )
  594. {
  595. vertikalScrollBar = new VScrollBar();
  596. rend = 1;
  597. }
  598. if( vertikalScrollBar && vertikalScrollBar->getScroll() != pos )
  599. {
  600. vertikalScrollBar->scroll( pos );
  601. rend = 1;
  602. }
  603. }
  604. void ZeichnungHintergrund::setVertikalScrollFarbe( int f, int bgF ) // setzt die scroll Farbe
  605. {
  606. if( !vertikalScrollBar )
  607. {
  608. vertikalScrollBar = new VScrollBar();
  609. rend = 1;
  610. }
  611. if( vertikalScrollBar && ( vertikalScrollBar->getFarbe() != f || vertikalScrollBar->getBgFarbe() != bgF ) )
  612. {
  613. vertikalScrollBar->setFarbe( f );
  614. vertikalScrollBar->setBgFarbe( bgF, bgF != 0 );
  615. rend = 1;
  616. }
  617. }
  618. void ZeichnungHintergrund::setHorizontalKlickScroll( int ks ) // setzt die horizontale Scroll geschwindigkeit
  619. {
  620. if( !horizontalScrollBar )
  621. {
  622. horizontalScrollBar = new HScrollBar();
  623. rend = 1;
  624. }
  625. if( horizontalScrollBar && horizontalScrollBar->getKlickScroll() != ks )
  626. {
  627. horizontalScrollBar->setKlickScroll( ks );
  628. rend = 1;
  629. }
  630. }
  631. void ZeichnungHintergrund::setHorizontalScrollPos( int pos ) // setzt die horizontale Scroll Position
  632. {
  633. if( !horizontalScrollBar )
  634. {
  635. horizontalScrollBar = new HScrollBar();
  636. rend = 1;
  637. }
  638. if( horizontalScrollBar && horizontalScrollBar->getScroll() != pos )
  639. {
  640. horizontalScrollBar->scroll( pos );
  641. rend = 1;
  642. }
  643. }
  644. void ZeichnungHintergrund::setHorizontalScrollFarbe( int f, int bgF ) // setzt die scroll Farbe
  645. {
  646. if( !horizontalScrollBar )
  647. {
  648. horizontalScrollBar = new HScrollBar();
  649. rend = 1;
  650. }
  651. if( horizontalScrollBar && ( horizontalScrollBar->getFarbe() != f || horizontalScrollBar->getBgFarbe() != bgF ) )
  652. {
  653. horizontalScrollBar->setFarbe( f );
  654. horizontalScrollBar->setBgFarbe( bgF, bgF != 0 );
  655. rend = 1;
  656. }
  657. }
  658. bool ZeichnungHintergrund::tick( double tickVal )
  659. {
  660. if( vertikalScrollBar && hatStyle( Style::VScroll ) )
  661. rend |= vertikalScrollBar->getRend();
  662. if( horizontalScrollBar && hatStyle( Style::HScroll ) )
  663. rend |= horizontalScrollBar->getRend();
  664. return Zeichnung::tick( tickVal );
  665. }
  666. void ZeichnungHintergrund::render( Bild &rObj )
  667. {
  668. innenPosition.x = pos.x;
  669. innenPosition.y = pos.y;
  670. innenSize.x = gr.x;
  671. innenSize.y = gr.y;
  672. if( hatStyleNicht( Style::Sichtbar ) )
  673. return;
  674. lockZeichnung();
  675. if( !rObj.setDrawOptions( pos.x, pos.y, gr.x, gr.y ) )
  676. {
  677. unlockZeichnung();
  678. return;
  679. }
  680. Zeichnung::render( rObj );
  681. int rbr = 0;
  682. if( hatStyle( Style::Rahmen ) && rahmen )
  683. {
  684. rahmen->setSize( gr );
  685. rahmen->render( rObj );
  686. rbr = rahmen->getRBreite();
  687. }
  688. innenPosition.x += rbr;
  689. innenPosition.y += rbr;
  690. innenSize.x -= rbr * 2;
  691. innenSize.y -= rbr * 2;
  692. if( !rObj.setDrawOptions( rbr, rbr, gr.x - rbr * 2, gr.y - rbr * 2 ) )
  693. {
  694. rObj.releaseDrawOptions();
  695. unlockZeichnung();
  696. return;
  697. }
  698. bool vs = vertikalScrollBar && hatStyle( Style::VScroll );
  699. bool hs = horizontalScrollBar && hatStyle( Style::HScroll );
  700. if( vs )
  701. {
  702. vertikalScrollBar->render( gr.x - rbr * 2 - 15, 0, 15, gr.y - rbr * 2, rObj );
  703. innenSize.x -= 15;
  704. if( hs )
  705. {
  706. horizontalScrollBar->render( 0, gr.y - rbr * 2 - 15, gr.x - rbr * 2 - 15, 15, rObj );
  707. innenSize.y -= 15;
  708. if( !rObj.setDrawOptions( 0, 0, gr.x - rbr * 2 - 15, gr.y - rbr * 2 - 15 ) )
  709. {
  710. rObj.releaseDrawOptions();
  711. rObj.releaseDrawOptions();
  712. unlockZeichnung();
  713. return;
  714. }
  715. horizontalScrollBar->update( horizontalScrollBar->getScrollData()->max, innenSize.x );
  716. }
  717. else
  718. {
  719. if( !rObj.setDrawOptions( 0, 0, gr.x - rbr * 2 - 15, gr.y - rbr * 2 ) )
  720. {
  721. rObj.releaseDrawOptions();
  722. rObj.releaseDrawOptions();
  723. unlockZeichnung();
  724. return;
  725. }
  726. }
  727. vertikalScrollBar->update( vertikalScrollBar->getScrollData()->max, innenSize.y );
  728. }
  729. else if( hs )
  730. {
  731. horizontalScrollBar->render( rbr, gr.y - rbr * 2 - 15, gr.x - rbr * 2, 15, rObj );
  732. innenSize.y -= 15;
  733. if( !rObj.setDrawOptions( 0, 0, gr.x - rbr * 2, gr.y - rbr * 2 - 15 ) )
  734. {
  735. rObj.releaseDrawOptions();
  736. rObj.releaseDrawOptions();
  737. unlockZeichnung();
  738. return;
  739. }
  740. }
  741. if( hatStyle( Style::Hintergrund ) )
  742. {
  743. if( hatStyle( Style::HAlpha ) )
  744. rObj.alphaRegion( 0, 0, gr.x - rbr * 2, gr.y - rbr * 2, hintergrundFarbe );
  745. else
  746. rObj.fillRegion( 0, 0, gr.x - rbr * 2, gr.y - rbr * 2, hintergrundFarbe );
  747. if( hatStyle( Style::HBild ) && hintergrundBild )
  748. {
  749. if( hatStyle( Style::HAlpha ) )
  750. rObj.alphaBildSkall( 0, 0, gr.x - rbr * 2, gr.y - rbr * 2, *hintergrundBild );
  751. else
  752. rObj.drawBildSkall( 0, 0, gr.x - rbr * 2, gr.y - rbr * 2, *hintergrundBild );
  753. }
  754. }
  755. if( hatStyle( Style::Buffered ) && hintergrundFeld )
  756. {
  757. hintergrundFeld->setSize( gr.x - rbr * 2, gr.y - rbr * 2 );
  758. hintergrundFeld->render( rObj );
  759. }
  760. if( vs || hs )
  761. rObj.releaseDrawOptions();
  762. rObj.releaseDrawOptions();
  763. rObj.releaseDrawOptions();
  764. unlockZeichnung();
  765. }
  766. Bild *ZeichnungHintergrund::getHintergrundBild() const // gibt getThis vom Hintergrund Bild zurück
  767. {
  768. if( !hintergrundBild )
  769. return 0;
  770. return hintergrundBild->getThis();
  771. }
  772. Bild *ZeichnungHintergrund::zHintergrundBild() const // gibt das Hintergrund Bild zurück
  773. {
  774. return hintergrundBild;
  775. }
  776. int ZeichnungHintergrund::getHintergrundFarbe() const // giebt getThis der Hintergrundfarbe zurück
  777. {
  778. return hintergrundFarbe;
  779. }
  780. AlphaFeld *ZeichnungHintergrund::getAlphaFeld() const // gibt getThir vom Hintergrund Buffer zurück
  781. {
  782. if( !hintergrundFeld )
  783. return 0;
  784. return hintergrundFeld->getThis();
  785. }
  786. AlphaFeld *ZeichnungHintergrund::zAlphaFeld() const // gibt den Hintergrund Buffer zurück
  787. {
  788. return hintergrundFeld;
  789. }
  790. int ZeichnungHintergrund::getAlphaFeldStrength() const // gibt die Stärke des Hintergrund Buffers zurück
  791. {
  792. if( !hintergrundFeld )
  793. return 0;
  794. return hintergrundFeld->getStrength();
  795. }
  796. int ZeichnungHintergrund::getAlphaFeldFarbe() const // gibt getThis von der Farbe des Hintergrund Buffers zurück
  797. {
  798. return hintergrundFeld->getFarbe();
  799. }
  800. LRahmen *ZeichnungHintergrund::getLinienRahmen() const // gibt getThis des Rahmens zurück
  801. {
  802. if( !rahmen )
  803. return 0;
  804. return rahmen->getThis();
  805. }
  806. LRahmen *ZeichnungHintergrund::zLinienRahmen() const // gibt den Rahmen zurück
  807. {
  808. return rahmen;
  809. }
  810. int ZeichnungHintergrund::getLinienRahmenBreite() const // gibt die Breite des Rahmens zurück
  811. {
  812. if( !rahmen || hatStyleNicht( Style::Rahmen ) )
  813. return 0;
  814. return rahmen->getRBreite();
  815. }
  816. int ZeichnungHintergrund::getLinienRahmenFarbe() const // gibt getThis der Farbe des Rahmens zurück
  817. {
  818. return rahmen->getFarbe();
  819. }
  820. int ZeichnungHintergrund::getVertikalKlickScroll() const
  821. {
  822. return vertikalScrollBar ? vertikalScrollBar->getKlickScroll() : 0;
  823. }
  824. int ZeichnungHintergrund::getVertikalScrollPos() const
  825. {
  826. return vertikalScrollBar ? vertikalScrollBar->getScroll() : 0;
  827. }
  828. int ZeichnungHintergrund::getVertikalScrollFarbe() const
  829. {
  830. return vertikalScrollBar ? vertikalScrollBar->getFarbe() : 0;
  831. }
  832. int ZeichnungHintergrund::getVertikalScrollHintergrund() const
  833. {
  834. return vertikalScrollBar ? vertikalScrollBar->getBgFarbe() : 0;
  835. }
  836. int ZeichnungHintergrund::getHorizontalKlickScroll() const
  837. {
  838. return horizontalScrollBar ? horizontalScrollBar->getKlickScroll() : 0;
  839. }
  840. int ZeichnungHintergrund::getHorizontalScrollPos() const
  841. {
  842. return horizontalScrollBar ? horizontalScrollBar->getScroll() : 0;
  843. }
  844. int ZeichnungHintergrund::getHorizontalScrollFarbe() const
  845. {
  846. return horizontalScrollBar ? horizontalScrollBar->getFarbe() : 0;
  847. }
  848. int ZeichnungHintergrund::getHorizontalScrollHintergrund() const
  849. {
  850. return horizontalScrollBar ? horizontalScrollBar->getBgFarbe() : 0;
  851. }
  852. Zeichnung *ZeichnungHintergrund::dublizieren() const // Erzeugt eine Kopie des Zeichnungs
  853. {
  854. ZeichnungHintergrund *obj = new ZeichnungHintergrund();
  855. obj->setPosition( pos );
  856. obj->setSize( gr );
  857. obj->setMausEreignisParameter( makParam );
  858. obj->setTastaturEreignisParameter( takParam );
  859. obj->setMausEreignis( mak );
  860. obj->setTastaturEreignis( tak );
  861. if( toolTip )
  862. obj->setToolTipText( toolTip->zText()->getText(), toolTip->zBildschirm() );
  863. obj->setStyle( style );
  864. obj->setHintergrundFarbe( hintergrundFarbe );
  865. if( hintergrundFeld )
  866. obj->setAlphaFeldZ( (AlphaFeld*)hintergrundFeld->dublizieren() );
  867. if( rahmen )
  868. obj->setLinienRahmenZ( (LRahmen*)rahmen->dublizieren() );
  869. if( hintergrundBild )
  870. obj->setHintergrundBild( hintergrundBild->getThis() );
  871. if( vertikalScrollBar )
  872. {
  873. obj->setVertikalKlickScroll( vertikalScrollBar->getKlickScroll() );
  874. obj->setVertikalScrollPos( vertikalScrollBar->getScroll() );
  875. obj->setVertikalScrollFarbe( vertikalScrollBar->getFarbe(), vertikalScrollBar->getBgFarbe() );
  876. }
  877. if( horizontalScrollBar )
  878. {
  879. obj->setHorizontalKlickScroll( horizontalScrollBar->getKlickScroll() );
  880. obj->setHorizontalScrollPos( horizontalScrollBar->getScroll() );
  881. obj->setHorizontalScrollFarbe( horizontalScrollBar->getFarbe(), horizontalScrollBar->getBgFarbe() );
  882. }
  883. return obj;
  884. }