Zeichnung.cpp 22 KB

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