Zeichnung.cpp 24 KB

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