NachrichtenListe.cpp 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874
  1. #include "NachrichtenListe.h"
  2. #include <Punkt.h>
  3. #include <MausEreignis.h>
  4. #include <Bild.h>
  5. #include "../../Global/Initialisierung.h"
  6. #include <Scroll.h>
  7. #include "../../Global/Variablen.h"
  8. #include <Rahmen.h>
  9. #include <DateiSystem.h>
  10. #include <KSGTDatei.h>
  11. #include <ToolTip.h>
  12. #include <GSLDateiV.h>
  13. #include <Globals.h>
  14. typedef GSL::GSLDateiV *( *GetGSLDatei )( );
  15. NLNachricht::NLNachricht( Schrift *zSchrift, Text *titel )
  16. {
  17. rahmen = new LRahmen();
  18. rahmen->setRamenBreite( 1 );
  19. rahmen->setFarbe( 0xFFFFFFFF );
  20. this->titel = initTextFeld( 1, 1, 208, 20, zSchrift, TextFeld::Style::Text | TextFeld::Style::Center, titel->getText() );
  21. titel = titel->release();
  22. close = initKnopf( 208, 1, 20, 20, 0, 0, "" );
  23. close->setStyle( Knopf::Style::Sichtbar | Knopf::Style::Erlaubt | Knopf::Style::Hintergrund | Knopf::Style::HBild | Knopf::Style::HAlpha | Knopf::Style::KlickBuffer );
  24. Bild * closeBild = bilder->get( "data/client/bilder/chat.ltdb/entfernen.png" );
  25. close->setHintergrundBildZ( closeBild );
  26. initToolTip( close, "Nachricht ignorieren.", zSchrift, hauptScreen );
  27. maxHöhe = 20;
  28. ref = 1;
  29. animation = 1;
  30. ausgewählt = 0;
  31. tickVal = 0;
  32. rend = 0;
  33. höhe = 0;
  34. }
  35. NLNachricht::~NLNachricht()
  36. {
  37. titel = (TextFeld *)titel->release();
  38. close = (Knopf *)close->release();
  39. rahmen->release();
  40. }
  41. void NLNachricht::entfernen()
  42. {
  43. animation = 3;
  44. }
  45. void NLNachricht::setAusgewählt( bool ausgewählt )
  46. {
  47. if( animation != 3 )
  48. {
  49. this->ausgewählt = ausgewählt;
  50. if( ausgewählt )
  51. animation = 2;
  52. else
  53. animation = 1;
  54. }
  55. }
  56. void NLNachricht::doMausEreignis( MausEreignis & me )
  57. {
  58. if( animation != 3 )
  59. {
  60. bool tmp = 0;
  61. if( me.my > höhe || !ausgewählt )
  62. {
  63. tmp = me.verarbeitet;
  64. me.verarbeitet = 1;
  65. }
  66. char aktion = me.verarbeitet ? 2 : 0;
  67. close->doMausEreignis( me );
  68. if( !aktion )
  69. aktion = me.verarbeitet ? 1 : 0;
  70. if( me.my > höhe || !ausgewählt )
  71. {
  72. me.verarbeitet = tmp;
  73. return;
  74. }
  75. if( me.id != ME_RLinks )
  76. return;
  77. if( aktion == 1 )
  78. entfernen();
  79. }
  80. }
  81. bool NLNachricht::tick( double tickVal )
  82. {
  83. rend |= close->tick( tickVal );
  84. if( !animation )
  85. {
  86. bool ret = rend;
  87. rend = 0;
  88. return ret;
  89. }
  90. this->tickVal += tickVal * 100;
  91. int val = (int)this->tickVal;
  92. if( val < 1 )
  93. {
  94. bool ret = rend;
  95. rend = 0;
  96. return ret;
  97. }
  98. if( val > 4 )
  99. val = 4;
  100. this->tickVal -= val;
  101. switch( animation )
  102. {
  103. case 1:
  104. if( höhe != 20 )
  105. {
  106. if( höhe > 20 )
  107. {
  108. höhe -= val;
  109. if( höhe < 20 )
  110. höhe = 20;
  111. }
  112. else
  113. {
  114. höhe += val;
  115. if( höhe > 20 )
  116. höhe = 20;
  117. }
  118. rend = 1;
  119. }
  120. else
  121. animation = 0;
  122. break;
  123. case 2:
  124. if( höhe != maxHöhe )
  125. {
  126. höhe += val;
  127. if( höhe > maxHöhe )
  128. höhe = maxHöhe;
  129. rend = 1;
  130. }
  131. else
  132. animation = 0;
  133. break;
  134. case 3:
  135. höhe -= val;
  136. if( höhe <= 0 )
  137. {
  138. nachLogin->zNachrichtenListe()->removeNachricht( this ); // delete this
  139. return 1;
  140. }
  141. rend = 1;
  142. break;
  143. }
  144. bool ret = rend;
  145. rend = 0;
  146. return ret;
  147. }
  148. void NLNachricht::render( int y, Bild & zRObj )
  149. {
  150. int br = 228;
  151. int hö = höhe;
  152. if( !zRObj.setDrawOptions( 0, y, br, hö ) )
  153. return;
  154. rahmen->setSize( br, hö );
  155. rahmen->render( zRObj );
  156. int rbr = rahmen->getRBreite();
  157. if( !zRObj.setDrawOptions( rbr, rbr, br - rbr * 2, hö - rbr * 2 ) )
  158. {
  159. zRObj.releaseDrawOptions();
  160. return;
  161. }
  162. titel->render( zRObj );
  163. close->render( zRObj );
  164. zRObj.releaseDrawOptions();
  165. zRObj.releaseDrawOptions();
  166. }
  167. // contant
  168. bool NLNachricht::istAusgewählt() const
  169. {
  170. return ausgewählt;
  171. }
  172. int NLNachricht::getHeight() const
  173. {
  174. return höhe;
  175. }
  176. Text *NLNachricht::zTitel() const
  177. {
  178. return titel->zText();
  179. }
  180. // Reference Counting
  181. NLNachricht *NLNachricht::getThis()
  182. {
  183. ref++;
  184. return this;
  185. }
  186. NLNachricht *NLNachricht::release()
  187. {
  188. ref--;
  189. if( !ref )
  190. delete this;
  191. return 0;
  192. }
  193. SpielUpdateNachricht::SpielUpdateNachricht( Schrift * zSchrift, Text * titel, Text * nachricht, int dgID, std::function<void()> posAk, std::function<void()> negAk )
  194. : NLNachricht( zSchrift, titel )
  195. {
  196. Text *result = new Text( nachricht->getText() );
  197. int län = nachricht->getLength();
  198. char *txt = nachricht->getText();
  199. int x = 0;
  200. int y = 0;
  201. Alphabet *tmp = zSchrift->getAlphabet( 12 );
  202. TextRenderer rd( zSchrift->getThis() );
  203. rd.setSchriftSize( 12 );
  204. int zeilenHöhe = rd.getZeilenHeight() + rd.getZeilenAbstand();
  205. int lastPos = -1;
  206. for( int i = 0; i < län; i++ )
  207. {
  208. char c = txt[ i ];
  209. if( c == ' ' )
  210. {
  211. lastPos = i;
  212. x += 6;
  213. continue;
  214. }
  215. if( c == '\n' )
  216. {
  217. x = 0;
  218. y += zeilenHöhe;
  219. lastPos = -1;
  220. continue;
  221. }
  222. Buchstabe *b = tmp->getBuchstabe( (unsigned)c );
  223. if( b )
  224. {
  225. x += b->getBreite();
  226. if( x > 228 && lastPos > -1 )
  227. {
  228. result->ersetzen( lastPos, lastPos + 1, "\n" );
  229. x = 0;
  230. y += zeilenHöhe;
  231. i = lastPos;
  232. lastPos = -1;
  233. }
  234. b = b->release();
  235. }
  236. }
  237. y += zeilenHöhe;
  238. tmp = tmp->release();
  239. nachricht = nachricht->release();
  240. text = initTextFeld( 1, 22, 228, y, zSchrift, TextFeld::Style::Text, result->getText() );
  241. result = result->release();
  242. fortschritt = initFBalken( 5, y + 20, 215, 20, zSchrift, FBalken::Style::normal );
  243. herunterladen = initKnopf( 10, 45 + y, 120, 20, zSchrift, Knopf::Style::Sichtbar, "herunterladen" );
  244. abbrechen = initKnopf( 140, 45 + y, 80, 20, zSchrift, Knopf::Style::Sichtbar, "abbrechen" );
  245. this->posAk = posAk;
  246. this->negAk = negAk;
  247. maxHöhe = 75 + y;
  248. update = new Update( zSchrift, (FBalken *)fortschritt->getThis(), dgID, [ this ]( bool ok )
  249. {
  250. this->animation = 3;
  251. if( ok )
  252. this->posAk();
  253. else
  254. this->negAk();
  255. } );
  256. if( !updateH->add( (Update *)update->getThis() ) )
  257. entfernen();
  258. }
  259. SpielUpdateNachricht::~SpielUpdateNachricht()
  260. {
  261. text->release();
  262. herunterladen->release();
  263. abbrechen->release();
  264. fortschritt->release();
  265. updateH->remove( update->getDateiGruppe() );
  266. update->release();
  267. }
  268. // nicht constant
  269. void SpielUpdateNachricht::entfernen()
  270. {
  271. __super::entfernen();
  272. negAk();
  273. }
  274. void SpielUpdateNachricht::doMausEreignis( MausEreignis & me )
  275. {
  276. __super::doMausEreignis( me );
  277. if( animation != 3 )
  278. {
  279. bool tmp = 0;
  280. if( me.my > höhe || !ausgewählt )
  281. {
  282. tmp = me.verarbeitet;
  283. me.verarbeitet = 1;
  284. }
  285. char aktion = me.verarbeitet ? 3 : 0;
  286. herunterladen->doMausEreignis( me );
  287. if( !aktion )
  288. aktion = me.verarbeitet ? 1 : 0;
  289. abbrechen->doMausEreignis( me );
  290. if( !aktion )
  291. aktion = me.verarbeitet ? 2 : 0;
  292. if( me.my > höhe || !ausgewählt )
  293. {
  294. me.verarbeitet = tmp;
  295. return;
  296. }
  297. if( me.id != ME_RLinks )
  298. return;
  299. switch( aktion )
  300. {
  301. case 1:
  302. // positiv
  303. update->herunterladen();
  304. herunterladen->removeStyle( Knopf::Style::Erlaubt | Knopf::Style::Sichtbar );
  305. break;
  306. case 2:
  307. // negativ
  308. update->abbrechen();
  309. abbrechen->removeStyle( Knopf::Style::Erlaubt | Knopf::Style::Sichtbar );
  310. break;
  311. }
  312. }
  313. }
  314. bool SpielUpdateNachricht::tick( double tickVal )
  315. {
  316. rend |= herunterladen->tick( tickVal );
  317. rend |= fortschritt->tick( tickVal );
  318. rend |= abbrechen->tick( tickVal );
  319. rend |= text->tick( tickVal );
  320. return __super::tick( tickVal );
  321. }
  322. void SpielUpdateNachricht::render( int y, Bild & zRObj )
  323. {
  324. __super::render( y, zRObj );
  325. int rbr = rahmen->getRBreite();
  326. if( !zRObj.setDrawOptions( rbr, y + rbr, rahmen->getBreite() - rbr * 2, rahmen->getHeight() - rbr * 2 ) )
  327. return;
  328. text->render( zRObj );
  329. fortschritt->render( zRObj );
  330. herunterladen->render( zRObj );
  331. abbrechen->render( zRObj );
  332. zRObj.releaseDrawOptions();
  333. }
  334. // Inhalt der Nachricht Klasse aus NachrichtListe.h
  335. // Konstruktor
  336. Nachricht::Nachricht( Schrift * zSchrift, Text * titel, Text * nachricht, Text * positiv, Text * negativ, std::function<void()> posAk, std::function<void()> negAk )
  337. : NLNachricht( zSchrift, titel )
  338. {
  339. Text *result = new Text( nachricht->getText() );
  340. int län = nachricht->getLength();
  341. char *txt = nachricht->getText();
  342. int x = 0;
  343. int y = 0;
  344. Alphabet *tmp = zSchrift->getAlphabet( 12 );
  345. TextRenderer rd( zSchrift->getThis() );
  346. rd.setSchriftSize( 12 );
  347. int zeilenHöhe = rd.getZeilenHeight() + rd.getZeilenAbstand();
  348. int lastPos = -1;
  349. for( int i = 0; i < län; i++ )
  350. {
  351. char c = txt[ i ];
  352. if( c == ' ' )
  353. {
  354. lastPos = i;
  355. x += 6;
  356. continue;
  357. }
  358. if( c == '\n' )
  359. {
  360. x = 0;
  361. y += zeilenHöhe;
  362. lastPos = -1;
  363. continue;
  364. }
  365. Buchstabe *b = tmp->getBuchstabe( (unsigned)c );
  366. if( b )
  367. {
  368. x += b->getBreite();
  369. if( x > 228 && lastPos > -1 )
  370. {
  371. result->ersetzen( lastPos, lastPos + 1, "\n" );
  372. x = 0;
  373. y += zeilenHöhe;
  374. i = lastPos;
  375. lastPos = -1;
  376. }
  377. b = b->release();
  378. }
  379. }
  380. y += zeilenHöhe;
  381. tmp = tmp->release();
  382. nachricht = nachricht->release();
  383. text = initTextFeld( 1, 22, 228, y, zSchrift, TextFeld::Style::Text, result->getText() );
  384. result = result->release();
  385. if( positiv )
  386. {
  387. this->positiv = initKnopf( 10, 20 + y, 100, 20, zSchrift, Knopf::Style::Sichtbar, positiv->getText() );
  388. positiv = positiv->release();
  389. }
  390. else
  391. this->positiv = 0;
  392. if( negativ )
  393. {
  394. this->negativ = initKnopf( 120, 20 + y, 100, 20, zSchrift, Knopf::Style::Sichtbar, negativ->getText() );
  395. negativ = negativ->release();
  396. }
  397. else
  398. this->negativ = 0;
  399. this->posAk = posAk;
  400. this->negAk = negAk;
  401. maxHöhe = 50 + y;
  402. }
  403. // Destruktor
  404. Nachricht::~Nachricht()
  405. {
  406. text = (TextFeld *)text->release();
  407. if( positiv )
  408. positiv = (Knopf *)positiv->release();
  409. if( negativ )
  410. negativ = (Knopf *)negativ->release();
  411. }
  412. void Nachricht::entfernen()
  413. {
  414. __super::entfernen();
  415. negAk();
  416. }
  417. void Nachricht::doMausEreignis( MausEreignis & me )
  418. {
  419. __super::doMausEreignis( me );
  420. if( animation != 3 )
  421. {
  422. bool tmp = 0;
  423. if( me.my > höhe || !ausgewählt )
  424. {
  425. tmp = me.verarbeitet;
  426. me.verarbeitet = 1;
  427. }
  428. char aktion = me.verarbeitet ? 3 : 0;
  429. if( positiv )
  430. positiv->doMausEreignis( me );
  431. if( !aktion )
  432. aktion = me.verarbeitet ? 1 : 0;
  433. if( negativ )
  434. negativ->doMausEreignis( me );
  435. if( !aktion )
  436. aktion = me.verarbeitet ? 2 : 0;
  437. if( me.my > höhe || !ausgewählt )
  438. {
  439. me.verarbeitet = tmp;
  440. return;
  441. }
  442. if( me.id != ME_RLinks )
  443. return;
  444. switch( aktion )
  445. {
  446. case 1:
  447. // positiv
  448. __super::entfernen();
  449. posAk();
  450. break;
  451. case 2:
  452. // negativ
  453. __super::entfernen();
  454. negAk();
  455. break;
  456. }
  457. }
  458. }
  459. bool Nachricht::tick( double tickVal )
  460. {
  461. rend |= positiv ? positiv->tick( tickVal ) : 0;
  462. rend |= negativ ? negativ->tick( tickVal ) : 0;
  463. rend |= text->tick( tickVal );
  464. return __super::tick( tickVal );
  465. }
  466. void Nachricht::render( int yPos, Bild & zRObj )
  467. {
  468. __super::render( yPos, zRObj );
  469. int rbr = rahmen->getRBreite();
  470. if( !zRObj.setDrawOptions( rbr, yPos + rbr, rahmen->getBreite() - rbr * 2, rahmen->getHeight() - rbr * 2 ) )
  471. return;
  472. text->render( zRObj );
  473. if( positiv )
  474. positiv->render( zRObj );
  475. if( negativ )
  476. negativ->render( zRObj );
  477. zRObj.releaseDrawOptions();
  478. }
  479. // Inhalt der NachrichtenListeObj Klasse aus NachrichtListe.h
  480. // Konstruktor
  481. NachrichtenListeObj::NachrichtenListeObj( Schrift * zSchrift )
  482. : Zeichnung()
  483. {
  484. members = new RCArray< NLNachricht >();
  485. schrift = zSchrift->getThis();
  486. vsb = new VScrollBar();
  487. vsb->setKlickScroll( 10 );
  488. bildschirmGröße = BildschirmGröße();
  489. vsb->update( 0, bildschirmGröße.y - 122 );
  490. anzahl = 0;
  491. gr = Punkt( 250, bildschirmGröße.y - 122 );
  492. }
  493. // Destruktor
  494. NachrichtenListeObj::~NachrichtenListeObj()
  495. {
  496. schrift = schrift->release();
  497. vsb = (VScrollBar *)vsb->release();
  498. members = members->release();
  499. }
  500. // nicht constant
  501. void NachrichtenListeObj::addNachricht( NLNachricht * nachricht )
  502. {
  503. members->add( nachricht, anzahl );
  504. anzahl++;
  505. rend = 1;
  506. }
  507. void NachrichtenListeObj::removeNachricht( NLNachricht * zNachricht )
  508. {
  509. for( int i = 0; i < anzahl; i++ )
  510. {
  511. if( members->z( i ) == zNachricht )
  512. {
  513. members->remove( i );
  514. anzahl--;
  515. rend = 1;
  516. break;
  517. }
  518. }
  519. }
  520. void NachrichtenListeObj::removeAll()
  521. {
  522. lockZeichnung();
  523. members->leeren();
  524. anzahl = 0;
  525. rend = 1;
  526. unlockZeichnung();
  527. }
  528. bool NachrichtenListeObj::tick( double tickVal )
  529. {
  530. lockZeichnung();
  531. rend |= vsb->getRend();
  532. rend |= nachLogin->zNachrichtenListe()->tick( tickVal );
  533. for( int i = 0; i < anzahl; i++ )
  534. {
  535. NLNachricht *tmp = members->z( i );
  536. if( tmp )
  537. rend |= tmp->tick( tickVal );
  538. }
  539. unlockZeichnung();
  540. bool ret = rend;
  541. rend = 0;
  542. return ret;
  543. }
  544. void NachrichtenListeObj::doMausEreignis( MausEreignis & me )
  545. {
  546. lockZeichnung();
  547. int my = me.my;
  548. me.my -= 20;
  549. if( me.mx <= 229 && me.mx > 0 && me.my >= 0 )
  550. {
  551. me.my += vsb->getScroll();
  552. for( int i = 0; i < anzahl; i++ )
  553. {
  554. NLNachricht *tmp = members->z( i );
  555. if( tmp )
  556. {
  557. if( me.my > 0 && me.my < tmp->getHeight() )
  558. tmp->setAusgewählt( 1 );
  559. else
  560. tmp->setAusgewählt( 0 );
  561. tmp->doMausEreignis( me );
  562. me.my -= tmp->getHeight();
  563. }
  564. }
  565. me.my -= vsb->getScroll();
  566. }
  567. else
  568. {
  569. me.my += vsb->getScroll();
  570. for( int i = 0; i < anzahl; i++ )
  571. {
  572. NLNachricht *tmp = members->z( i );
  573. if( tmp )
  574. {
  575. tmp->setAusgewählt( 0 );
  576. tmp->doMausEreignis( me );
  577. me.my -= tmp->getHeight();
  578. }
  579. }
  580. me.my -= vsb->getScroll();
  581. }
  582. me.my = my;
  583. vsb->doMausMessage( 229, 20, 20, bildschirmGröße.y - 122, me );
  584. unlockZeichnung();
  585. }
  586. void NachrichtenListeObj::render( Bild & zrObj )
  587. {
  588. lockZeichnung();
  589. int x = pos.x;
  590. int y = pos.y;
  591. int br = gr.x;
  592. int hö = gr.y;
  593. if( !zrObj.setDrawOptions( x, y, br, hö ) )
  594. {
  595. unlockZeichnung();
  596. return;
  597. }
  598. int höhe = 0;
  599. for( int i = 0; i < anzahl; i++ )
  600. {
  601. NLNachricht *tmp = members->z( i );
  602. tmp->render( höhe - ( vsb ? vsb->getScroll() : 0 ), zrObj );
  603. höhe += tmp->getHeight();
  604. }
  605. if( vsb )
  606. {
  607. vsb->update( höhe, bildschirmGröße.y - 122 );
  608. vsb->render( 229, 0, 20, bildschirmGröße.y - 122, zrObj );
  609. }
  610. zrObj.releaseDrawOptions();
  611. unlockZeichnung();
  612. }
  613. // Inhalt der NachrichtenListe Klasse aus NachrichtListe.h
  614. // Konstruktor
  615. NachrichtenListe::NachrichtenListe( Schrift * zSchrift, Fenster * zNachLoginFenster )
  616. {
  617. schrift = zSchrift->getThis();
  618. minimierenBild = bilder->get( "data/client/bilder/chat.ltdb/minimieren.png" );
  619. maximierenBild = bilder->get( "data/client/bilder/chat.ltdb/maximieren.png" );
  620. bildschirmGröße = BildschirmGröße();
  621. fenster = initFenster( bildschirmGröße.x - 21, 100, 250, 22, zSchrift, Fenster::Style::Sichtbar | Fenster::Style::Erlaubt | Fenster::Style::Rahmen | Fenster::Style::BodyHintergrund, "" );
  622. fenster->setKBgFarbe( 0xFF000000 );
  623. überschrift = initTextFeld( 1, 1, 248, 20, zSchrift, TextFeld::Style::Text | TextFeld::Style::Center | TextFeld::Style::Sichtbar, "Nachrichten" );
  624. überschrift->setSchriftSize( 15 );
  625. fenster->addMember( überschrift->getThis() );
  626. minMax = initKnopf( 1, 1, 20, 20, 0, 0, "" );
  627. minMax->setStyle( Knopf::Style::Sichtbar | Knopf::Style::Erlaubt | Knopf::Style::Hintergrund | Knopf::Style::HBild | Knopf::Style::HAlpha | Knopf::Style::KlickBuffer );
  628. minMax->setMausEreignisParameter( this );
  629. minMax->setMausEreignis( NachrichtenListeMinMaxME );
  630. minMax->setHintergrundBildZ( minimierenBild->getThis() );
  631. initToolTip( minMax, "Nachrichten Leiste minimieren.", zSchrift, hauptScreen );
  632. fenster->addMember( minMax->getThis() );
  633. nachrichtenListe = new NachrichtenListeObj( zSchrift );
  634. nachrichtenListe->setPosition( 1, 21 );
  635. nachrichtenListe->setSize( 248, bildschirmGröße.y - 122 );
  636. fenster->addMember( nachrichtenListe->getThis() );
  637. zNachLoginFenster->addMember( fenster->getThis() );
  638. tickVal = 0;
  639. animation = 1;
  640. rend = 0;
  641. msgSound = 0;
  642. errSound = 0;
  643. HMODULE dll = Framework::getDLLRegister()->ladeDLL( "GSL.dll", "data/bin/GSL.dll" );
  644. if( dll )
  645. {
  646. GetGSLDatei getGSLDatei = (GetGSLDatei)GetProcAddress( dll, "getGSLDatei" );
  647. if( getGSLDatei )
  648. {
  649. GSL::GSLDateiV *sDat = getGSLDatei();
  650. sDat->setDatei( "data/sounds/popup.gsl" );
  651. sDat->leseDaten();
  652. msgSound = sDat->getSound( "info.wav" );
  653. errSound = sDat->getSound( "error.wav" );
  654. sDat->release();
  655. if( msgSound )
  656. msgSound->setVolume( 0xFFFF, 0xFFFF );
  657. if( errSound )
  658. errSound->setVolume( 0xFFFF, 0xFFFF );
  659. }
  660. if( !msgSound && !errSound )
  661. Framework::getDLLRegister()->releaseDLL( "GSL.dll" );
  662. }
  663. ref = 1;
  664. }
  665. // Destruktor
  666. NachrichtenListe::~NachrichtenListe()
  667. {
  668. if( msgSound || errSound )
  669. {
  670. if( msgSound )
  671. {
  672. msgSound->stopSound();
  673. msgSound->release();
  674. }
  675. if( errSound )
  676. {
  677. errSound->stopSound();
  678. errSound->release();
  679. }
  680. Framework::getDLLRegister()->releaseDLL( "GSL.dll" );
  681. }
  682. überschrift = (TextFeld *)überschrift->release();
  683. fenster = (Fenster *)fenster->release();
  684. minMax = (Knopf *)minMax->release();
  685. nachrichtenListe = (NachrichtenListeObj *)nachrichtenListe->release();
  686. minimierenBild = minimierenBild->release();
  687. maximierenBild = maximierenBild->release();
  688. schrift->release();
  689. }
  690. // nicht constant
  691. void NachrichtenListe::addNachricht( Text * titel, Text * nachricht, Text * positiv, Text * negativ, std::function<void()> posAk, std::function<void()> negAk )
  692. {
  693. if( titel &&titel->hat( "Fehler" ) && errSound )
  694. errSound->playSound();
  695. else if( msgSound )
  696. msgSound->playSound();
  697. nachrichtenListe->addNachricht( new Nachricht( schrift, titel, nachricht, positiv, negativ, posAk, negAk ) );
  698. }
  699. void NachrichtenListe::addNachricht( NLNachricht * nachricht )
  700. {
  701. if( nachricht->zTitel() && nachricht->zTitel()->hat( "Fehler" ) && errSound )
  702. errSound->playSound();
  703. else if( msgSound )
  704. msgSound->playSound();
  705. nachrichtenListe->addNachricht( nachricht );
  706. }
  707. void NachrichtenListe::removeNachricht( NLNachricht * zNachricht )
  708. {
  709. nachrichtenListe->removeNachricht( zNachricht );
  710. }
  711. void NachrichtenListe::removeAll()
  712. {
  713. nachrichtenListe->removeAll();
  714. }
  715. bool NachrichtenListe::druckMinMax( MausEreignis & me )
  716. {
  717. if( me.id == ME_RLinks )
  718. {
  719. if( minMax->zHintergrundBild() == minimierenBild )
  720. {
  721. animation = 2;
  722. minMax->setHintergrundBildZ( maximierenBild->getThis() );
  723. // TODO minMax->zToolTip()->setText( "Nachrichten Leiste maximieren." );
  724. }
  725. else
  726. {
  727. animation = 1;
  728. minMax->setHintergrundBildZ( minimierenBild->getThis() );
  729. // TODO minMax->zToolTip()->setText( "Nachrichten Leiste minimieren." );
  730. }
  731. }
  732. return 1;
  733. }
  734. bool NachrichtenListe::tick( double tickVal )
  735. {
  736. if( !animation )
  737. {
  738. bool ret = rend;
  739. rend = 0;
  740. return ret;
  741. }
  742. this->tickVal += tickVal * 400;
  743. int val = (int)this->tickVal;
  744. if( val < 1 )
  745. {
  746. bool ret = rend;
  747. rend = 0;
  748. return ret;
  749. }
  750. if( val > 14 )
  751. val = 14;
  752. this->tickVal -= val;
  753. switch( animation )
  754. {
  755. case 1: // maximieren
  756. if( fenster->getX() > bildschirmGröße.x - 250 )
  757. {
  758. fenster->setPosition( fenster->getX() - val, fenster->getY() );
  759. minMax->setPosition( minMax->getX() + val, minMax->getY() );
  760. if( fenster->getX() < bildschirmGröße.x - 250 )
  761. {
  762. fenster->setPosition( bildschirmGröße.x - 250, fenster->getY() );
  763. minMax->setPosition( 229, minMax->getY() );
  764. }
  765. rend = 1;
  766. }
  767. else if( fenster->getHeight() < bildschirmGröße.y - 100 )
  768. {
  769. fenster->setSize( fenster->getBreite(), fenster->getHeight() + val );
  770. if( fenster->getHeight() >= bildschirmGröße.y - 100 )
  771. {
  772. fenster->setSize( fenster->getBreite(), bildschirmGröße.y - 100 );
  773. animation = 0;
  774. }
  775. rend = 1;
  776. }
  777. break;
  778. case 2: // minimieren
  779. if( fenster->getHeight() > 22 )
  780. {
  781. fenster->setSize( fenster->getBreite(), fenster->getHeight() - val );
  782. if( fenster->getHeight() < 22 )
  783. fenster->setSize( fenster->getBreite(), 22 );
  784. rend = 1;
  785. }
  786. else if( fenster->getX() < bildschirmGröße.x - 21 )
  787. {
  788. minMax->setPosition( minMax->getX() - val, minMax->getY() );
  789. fenster->setPosition( fenster->getX() + val, fenster->getY() );
  790. if( fenster->getX() >= bildschirmGröße.x - 21 )
  791. {
  792. minMax->setPosition( 1, minMax->getY() );
  793. fenster->setPosition( bildschirmGröße.x - 21, fenster->getY() );
  794. animation = 0;
  795. }
  796. rend = 1;
  797. }
  798. break;
  799. }
  800. bool ret = rend;
  801. rend = 0;
  802. return ret;
  803. }
  804. // contant
  805. Schrift *NachrichtenListe::zSchrift() const
  806. {
  807. return schrift;
  808. }
  809. // Reference Counting
  810. NachrichtenListe *NachrichtenListe::getThis()
  811. {
  812. ref++;
  813. return this;
  814. }
  815. NachrichtenListe *NachrichtenListe::release()
  816. {
  817. ref--;
  818. if( !ref )
  819. delete this;
  820. return 0;
  821. }
  822. // Nachrichten
  823. bool NachrichtenListeMinMaxME( void *p, void *obj, MausEreignis me )
  824. {
  825. return ( (NachrichtenListe *)p )->druckMinMax( me );
  826. }