Zeichnung.cpp 22 KB

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