Zeichnung.cpp 24 KB

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