Zeichnung.cpp 24 KB

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