Zeichnung.cpp 22 KB

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