Liste.cpp 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977
  1. #include "Liste.h"
  2. #include "Array.h"
  3. #include "Rahmen.h"
  4. #include "Bild.h"
  5. #include "AlphaFeld.h"
  6. #include "TextFeld.h"
  7. #include "Text.h"
  8. #include "MausEreignis.h"
  9. #include "TastaturEreignis.h"
  10. #include "Scroll.h"
  11. #include "Globals.h"
  12. #include "Schrift.h"
  13. using namespace Framework;
  14. // Inhalt der AuswahlListe Klasse aus Liste.h
  15. // Konstruktor
  16. AuswahlListe::AuswahlListe()
  17. : ZeichnungHintergrund(),
  18. tfListe(0),
  19. auswahl(-1),
  20. ahFarbe(0xFF000000),
  21. ahBild(0),
  22. aBuffer(0),
  23. aRahmen(0),
  24. styles(0),
  25. ahFarbeListe(0),
  26. ahBildListe(0),
  27. aBufferListe(0),
  28. aRahmenListe(0),
  29. schrift(0)
  30. {
  31. style = 0;
  32. this->setMausEreignis(_ret1ME);
  33. this->setTastaturEreignis(_ret1TE);
  34. }
  35. // Destruktor
  36. AuswahlListe::~AuswahlListe()
  37. {
  38. if (tfListe)
  39. tfListe->release();
  40. if (ahBild)
  41. ahBild->release();
  42. if (aBuffer)
  43. aBuffer->release();
  44. if (aRahmen)
  45. aRahmen->release();
  46. if (styles)
  47. styles->release();
  48. if (ahFarbeListe)
  49. ahFarbeListe->release();
  50. if (ahBildListe)
  51. ahBildListe->release();
  52. if (aBufferListe)
  53. aBufferListe->release();
  54. if (aRahmenListe)
  55. aRahmenListe->release();
  56. if (schrift)
  57. schrift->release();
  58. }
  59. void AuswahlListe::doMausEreignis(MausEreignis& me, bool userRet)
  60. {
  61. if (!userRet || hatStyleNicht(Style::Erlaubt))
  62. return;
  63. if (ZeichnungHintergrund::hatStyle(Style::VScroll) && vertikalScrollBar)
  64. {
  65. int rbr = 0;
  66. if (rahmen && ZeichnungHintergrund::hatStyle(Style::Rahmen))
  67. rbr = rahmen->getRBreite();
  68. if (((me.mx > gr.x - 15 - rbr) || me.id == ME_UScroll || me.id == ME_DScroll) && me.id != ME_Betritt && me.id != ME_Leaves)
  69. {
  70. vertikalScrollBar->doMausMessage(gr.x - rbr - 15, rbr, 15, gr.y - rbr * 2, me);
  71. me.verarbeitet = 1;
  72. }
  73. }
  74. if (!me.verarbeitet && me.id == ME_RLinks)
  75. {
  76. int eintr = getKlickEintrag(me.my);
  77. if (eintr >= 0)
  78. {
  79. if (hatStyleNicht(Style::MultiSelect))
  80. {
  81. auswahl = eintr;
  82. rend = 1;
  83. }
  84. else
  85. {
  86. bool shift = TastenStand[T_Shift];
  87. bool strg = TastenStand[T_Strg];
  88. if (strg)
  89. {
  90. setMsStyle(eintr, Style::Selected, hatMsStyleNicht(eintr, Style::Selected));
  91. auswahl = eintr;
  92. }
  93. else if (shift && auswahl != -1)
  94. {
  95. deSelect();
  96. int beg = auswahl, end = eintr;
  97. if (beg > end)
  98. {
  99. int tmp = end;
  100. end = beg;
  101. beg = tmp;
  102. }
  103. for (int i = beg; i <= end; ++i)
  104. {
  105. addMsStyle(i, Style::Selected);
  106. }
  107. }
  108. else
  109. {
  110. deSelect();
  111. addMsStyle(eintr, Style::Selected);
  112. auswahl = eintr;
  113. }
  114. }
  115. }
  116. else
  117. deSelect();
  118. }
  119. me.verarbeitet = 1;
  120. }
  121. bool AuswahlListe::hatStyle(int styleSet, int styleCheck) const
  122. {
  123. return (styleSet | styleCheck) == styleSet;
  124. }
  125. // nicht constant
  126. void AuswahlListe::update() // aktualisiert die Auswahl Liste
  127. {
  128. int rbr = 0;
  129. if (rahmen)
  130. {
  131. rbr = rahmen->getRBreite();
  132. rahmen->setPosition(0, 0);
  133. rahmen->setSize(gr.x, gr.y);
  134. }
  135. if (hintergrundFeld)
  136. {
  137. hintergrundFeld->setPosition(rbr, rbr);
  138. hintergrundFeld->setSize(gr.x - rbr * 2, gr.y - rbr * 2);
  139. }
  140. if (hatStyleNicht(Style::MultiStyled) && tfListe)
  141. {
  142. bool FeldRahmen = ZeichnungHintergrund::hatStyle(Style::FeldRahmen);
  143. bool FeldHintergrund = ZeichnungHintergrund::hatStyle(Style::FeldHintergrund);
  144. bool FeldHBild = ZeichnungHintergrund::hatStyle(Style::FeldHBild);
  145. bool FeldHAlpha = ZeichnungHintergrund::hatStyle(Style::FeldHAlpha);
  146. bool FeldBuffer = ZeichnungHintergrund::hatStyle(Style::FeldBuffer);
  147. for (TextFeld* tf : *tfListe)
  148. {
  149. tf->setStyle(TextFeld::Style::Rahmen, FeldRahmen);
  150. tf->setStyle(TextFeld::Style::Hintergrund, FeldHintergrund);
  151. tf->setStyle(TextFeld::Style::HBild, FeldHBild);
  152. tf->setStyle(TextFeld::Style::HAlpha, FeldHAlpha);
  153. tf->setStyle(TextFeld::Style::Buffered, FeldBuffer);
  154. if (schrift)
  155. tf->setSchriftZ(dynamic_cast<Schrift*>(schrift->getThis()));
  156. }
  157. }
  158. if (ZeichnungHintergrund::hatStyle(Style::MultiStyled) && tfListe && styles)
  159. {
  160. auto style = styles->begin();
  161. for (auto tf = tfListe->begin(); tf; tf++, style++)
  162. {
  163. tf->setStyle(TextFeld::Style::Rahmen, hatStyle(style, Style::FeldRahmen));
  164. tf->setStyle(TextFeld::Style::Hintergrund, hatStyle(style, Style::FeldHintergrund));
  165. tf->setStyle(TextFeld::Style::HBild, hatStyle(style, Style::FeldHBild));
  166. tf->setStyle(TextFeld::Style::HAlpha, hatStyle(style, Style::FeldHAlpha));
  167. tf->setStyle(TextFeld::Style::Buffered, hatStyle(style, Style::FeldBuffer));
  168. }
  169. }
  170. rend = 1;
  171. }
  172. void AuswahlListe::addEintrag(Text* txt) // fügt einen Eintrag hinzu
  173. {
  174. TextFeld* tf = new TextFeld();
  175. tf->setStyle(TextFeld::Style::Center | TextFeld::Style::Sichtbar | TextFeld::Style::Rahmen);
  176. tf->setSchriftFarbe(0xFFFFFFFF);
  177. tf->setRahmenBreite(1);
  178. tf->setRahmenFarbe(0xFFFFFFFF);
  179. tf->setTextZ(txt);
  180. tf->setSize(0, 20);
  181. addEintragZ(tf);
  182. rend = 1;
  183. }
  184. void AuswahlListe::addEintrag(const char* txt)
  185. {
  186. Text* tx = new Text(txt);
  187. addEintrag(tx);
  188. rend = 1;
  189. }
  190. void AuswahlListe::addEintragZ(TextFeld* tf)
  191. {
  192. if (!tfListe)
  193. tfListe = new RCArray< TextFeld >();
  194. if (schrift && (!tf->zSchrift() || hatStyleNicht(Style::MultiStyled)))
  195. tf->setSchriftZ(dynamic_cast<Schrift*>(schrift->getThis()));
  196. tfListe->add(tf);
  197. rend = 1;
  198. }
  199. void AuswahlListe::addEintrag(int pos, Text* txt) // fügt einen Eintrag bei position pos ein
  200. {
  201. TextFeld* tf = new TextFeld();
  202. tf->setStyle(TextFeld::Style::Center | TextFeld::Style::Sichtbar | TextFeld::Style::Rahmen);
  203. tf->setSchriftFarbe(0xFFFFFFFF);
  204. tf->setRahmenBreite(1);
  205. tf->setRahmenFarbe(0xFFFFFFFF);
  206. tf->setTextZ(txt);
  207. tf->setSize(0, 20);
  208. addEintragZ(pos, tf);
  209. rend = 1;
  210. }
  211. void AuswahlListe::addEintrag(int pos, const char* txt)
  212. {
  213. Text* tx = new Text(txt);
  214. addEintrag(pos, tx);
  215. rend = 1;
  216. }
  217. void AuswahlListe::addEintragZ(int pos, TextFeld* tf)
  218. {
  219. if (!tfListe)
  220. tfListe = new RCArray< TextFeld >();
  221. if (schrift && (!tf->zSchrift() || hatStyleNicht(Style::MultiStyled)))
  222. tf->setSchriftZ(dynamic_cast<Schrift*>(schrift->getThis()));
  223. tfListe->add(tf, pos);
  224. rend = 1;
  225. }
  226. void AuswahlListe::setEintrag(int pos, Text* txt) // ändert den pos - ten Eintrag
  227. {
  228. TextFeld* tf = 0;
  229. if (tfListe)
  230. tf = tfListe->z(pos);
  231. if (!tf)
  232. {
  233. tf = new TextFeld();
  234. tf->setStyle(TextFeld::Style::Center | TextFeld::Style::Sichtbar | TextFeld::Style::Rahmen);
  235. tf->setSchriftFarbe(0xFFFFFFFF);
  236. tf->setRahmenFarbe(0xFFFFFFFF);
  237. tf->setRahmenBreite(1);
  238. tf->setTextZ(txt);
  239. tf->setSize(0, 20);
  240. setEintragZ(pos, tf);
  241. rend = 1;
  242. return;
  243. }
  244. tf->setTextZ(txt);
  245. rend = 1;
  246. }
  247. void AuswahlListe::setEintrag(int pos, const char* txt)
  248. {
  249. Text* tx = new Text(txt);
  250. setEintrag(pos, tx);
  251. rend = 1;
  252. }
  253. void AuswahlListe::setEintragZ(int pos, TextFeld* tf)
  254. {
  255. if (!tfListe)
  256. tfListe = new RCArray< TextFeld >();
  257. if (schrift && (!tf->zSchrift() || hatStyleNicht(Style::MultiStyled)))
  258. tf->setSchriftZ(dynamic_cast<Schrift*>(schrift->getThis()));
  259. tfListe->set(tf, pos);
  260. rend = 1;
  261. }
  262. void AuswahlListe::tauschEintragPos(int vpos, int npos) // taucht den Eintrag vpos mit dem Eintrag npos
  263. {
  264. if (tfListe)
  265. {
  266. tfListe->tausch(vpos, npos);
  267. if (styles)
  268. styles->tausch(vpos, npos);
  269. if (ahFarbeListe)
  270. ahFarbeListe->tausch(vpos, npos);
  271. if (ahBildListe)
  272. ahBildListe->tausch(vpos, npos);
  273. if (aBufferListe)
  274. aBufferListe->tausch(vpos, npos);
  275. if (aRahmenListe)
  276. aRahmenListe->tausch(vpos, npos);
  277. rend = 1;
  278. }
  279. }
  280. void AuswahlListe::removeEintrag(int pos) // löscht den Eintrag pos
  281. {
  282. tfListe->remove(pos);
  283. rend = 1;
  284. }
  285. void AuswahlListe::setSchriftZ(Schrift* schrift) // legt die Schrift der Einträge fest
  286. {
  287. if (this->schrift)
  288. this->schrift->release();
  289. this->schrift = schrift;
  290. rend = 1;
  291. }
  292. void AuswahlListe::setVScrollZuEintrag(int eintrag) // scrollt zum Eintrag
  293. {
  294. if (vertikalScrollBar)
  295. {
  296. if (eintrag > tfListe->getLastIndex())
  297. eintrag = tfListe->getLastIndex();
  298. int y = 0;
  299. for (int i = 0; i < eintrag; i++)
  300. y += tfListe->z(i) ? tfListe->z(i)->getHeight() : 0;
  301. vertikalScrollBar->scroll(y);
  302. }
  303. }
  304. void AuswahlListe::updateVScroll() // scrollt zur Curser Position oder nach Unten
  305. {
  306. if (vertikalScrollBar)
  307. {
  308. int y = 0;
  309. for (TextFeld* tf : *tfListe)
  310. y += (TextFeld*)tf ? tf->getHeight() : 0;
  311. vertikalScrollBar->update(y, gr.y - ((rahmen && ZeichnungHintergrund::hatStyle(TextFeld::Style::Rahmen)) ? rahmen->getRBreite() : 0));
  312. }
  313. }
  314. void AuswahlListe::setALRZ(Rahmen* rahmen) // setzt einen Zeiger zum Auswahl Rahmen (nur ohne MulitStyled)
  315. {
  316. if (aRahmen)
  317. aRahmen->release();
  318. aRahmen = rahmen;
  319. rend = 1;
  320. }
  321. void AuswahlListe::setALRBreite(int br) // setzt die Breite des Auswahl Rahmens (nur ohne MultiStyled)
  322. {
  323. if (!aRahmen)
  324. aRahmen = new LRahmen();
  325. aRahmen->setRamenBreite(br);
  326. rend = 1;
  327. }
  328. void AuswahlListe::setALRFarbe(int fc) // setzt die Farbe des Auswahl Rahmens (nur ohne MultiStyled)
  329. {
  330. if (!aRahmen)
  331. aRahmen = new LRahmen();
  332. aRahmen->setFarbe(fc);
  333. rend = 1;
  334. }
  335. void AuswahlListe::setAAFZ(AlphaFeld* buffer) // setzt einen Zeiger zum Auswahl AlpaFeld (nur ohne MultiStyled)
  336. {
  337. if (aBuffer)
  338. aBuffer->release();
  339. aBuffer = buffer;
  340. rend = 1;
  341. }
  342. void AuswahlListe::setAAFStrength(int st) // setzt die Stärke des Auswahl Hintergrund Buffers (nur ohne MultiStyled)
  343. {
  344. if (!aBuffer)
  345. aBuffer = new AlphaFeld();
  346. aBuffer->setStrength(st);
  347. rend = 1;
  348. }
  349. void AuswahlListe::setAAFFarbe(int fc) // setzt die Farbe des Auswahl Hintergrund Buffers (nur ohne MultiStyled)
  350. {
  351. if (!aBuffer)
  352. aBuffer = new AlphaFeld();
  353. aBuffer->setFarbe(fc);
  354. rend = 1;
  355. }
  356. void AuswahlListe::setAHBild(Bild* bild) // setzt das Auswahl Hintergrund Bild (nur ohne MultiStyled)
  357. {
  358. if (!ahBild)
  359. ahBild = new Bild();
  360. ahBild->neuBild(bild->getBreite(), bild->getHeight(), 0);
  361. int* buff1 = ahBild->getBuffer();
  362. int* buff2 = bild->getBuffer();
  363. for (int i = 0; i < bild->getBreite() * bild->getHeight(); ++i)
  364. buff1[i] = buff2[i];
  365. bild->release();
  366. rend = 1;
  367. }
  368. void AuswahlListe::setAHFarbe(int f) // setzt einen Zeiger zur Auswahl Hintergrund Farbe (nur ohne MultiStyled)
  369. {
  370. ahFarbe = f;
  371. rend = 1;
  372. }
  373. void AuswahlListe::setAHBildZ(Bild* b) // setzt einen Zeiger zum Hintergrund Bild (nur ohne MultiStyled)
  374. {
  375. if (ahBild)
  376. ahBild->release();
  377. ahBild = b;
  378. rend = 1;
  379. }
  380. void AuswahlListe::setALRZ(int pos, Rahmen* rahmen) // setzt einen Zeiger zum Auswahl Rahmen (nur mit MulitStyled)
  381. {
  382. if (!aRahmenListe)
  383. aRahmenListe = new RCArray< Rahmen >();
  384. aRahmenListe->set(rahmen, pos);
  385. rend = 1;
  386. }
  387. void AuswahlListe::setALRBreite(int pos, int br) // setzt die Breite des Auswahl Rahmens (nur mit MultiStyled)
  388. {
  389. if (!aRahmenListe)
  390. aRahmenListe = new RCArray< Rahmen >();
  391. if (!aRahmenListe->z(pos))
  392. aRahmenListe->set(new LRahmen(), pos);
  393. aRahmenListe->z(pos)->setRamenBreite(br);
  394. rend = 1;
  395. }
  396. void AuswahlListe::setALRFarbe(int pos, int fc) // setzt die Farbe des Auswahl Rahmens (nur mit MultiStyled)
  397. {
  398. if (!aRahmenListe)
  399. aRahmenListe = new RCArray< Rahmen >();
  400. if (!aRahmenListe->z(pos))
  401. aRahmenListe->set(new LRahmen(), pos);
  402. aRahmenListe->z(pos)->setFarbe(fc);
  403. rend = 1;
  404. }
  405. void AuswahlListe::setAAFZ(int pos, AlphaFeld* buffer) // setzt einen Zeiger zum Auswahl AlpaFeld (nur mit MultiStyled)
  406. {
  407. if (!aBufferListe)
  408. aBufferListe = new RCArray< AlphaFeld >();
  409. aBufferListe->set(buffer, pos);
  410. rend = 1;
  411. }
  412. void AuswahlListe::setAAFStrength(int pos, int st) // setzt die Stärke des Auswahl Hintergrund Buffers (nur mit MultiStyled)
  413. {
  414. if (!aBufferListe)
  415. aBufferListe = new RCArray< AlphaFeld >();
  416. if (!aBufferListe->z(pos))
  417. aBufferListe->set(new AlphaFeld(), pos);
  418. aBufferListe->z(pos)->setStrength(st);
  419. rend = 1;
  420. }
  421. void AuswahlListe::setAAFFarbe(int pos, int fc) // setzt die Farbe des Auswahl Hintergrund Buffers (nur mit MultiStyled)
  422. {
  423. if (!aBufferListe)
  424. aBufferListe = new RCArray< AlphaFeld >();
  425. if (!aBufferListe->z(pos))
  426. aBufferListe->set(new AlphaFeld(), pos);
  427. aBufferListe->z(pos)->setFarbe(fc);
  428. rend = 1;
  429. }
  430. void AuswahlListe::setAHBild(int pos, Bild* bild) // setzt das Auswahl Hintergrund Bild (nur mit MultiStyled)
  431. {
  432. if (ahBildListe)
  433. ahBildListe = new RCArray< Bild >();
  434. if (!ahBildListe->z(pos))
  435. ahBildListe->set(new Bild(), pos);
  436. ahBildListe->z(pos)->neuBild(bild->getBreite(), bild->getHeight(), 0);
  437. int* buff1 = ahBildListe->z(pos)->getBuffer();
  438. int* buff2 = bild->getBuffer();
  439. for (int i = 0; i < bild->getBreite() * bild->getHeight(); ++i)
  440. buff1[i] = buff2[i];
  441. bild->release();
  442. rend = 1;
  443. }
  444. void AuswahlListe::setAHFarbe(int pos, int f) // setzt einen Zeiger zur Auswahl Hintergrund Farbe (nur miz MultiStyled)
  445. {
  446. if (ahFarbeListe)
  447. ahFarbeListe = new Array< int >();
  448. ahFarbeListe->set(f, pos);
  449. rend = 1;
  450. }
  451. void AuswahlListe::setAHBildZ(int pos, Bild* b) // setzt einen Zeiger zum Hintergrund Bild (nur mit MultiStyled)
  452. {
  453. if (ahBildListe)
  454. ahBildListe = new RCArray< Bild >();
  455. ahBildListe->set(b, pos);
  456. rend = 1;
  457. }
  458. void AuswahlListe::setMsStyle(int pos, __int64 style) // setzt den Style des Eintrags (nur mit MultiStyled)
  459. {
  460. if (!styles)
  461. styles = new Array< __int64 >();
  462. styles->set(style, pos);
  463. rend = 1;
  464. }
  465. void AuswahlListe::setMsStyle(int pos, __int64 style, bool add_remove)
  466. {
  467. if (!styles)
  468. styles = new Array< __int64 >();
  469. if (add_remove)
  470. styles->set(styles->get(pos) | style, pos);
  471. else
  472. styles->set(styles->get(pos) & ~style, pos);
  473. rend = 1;
  474. }
  475. void AuswahlListe::addMsStyle(int pos, __int64 style)
  476. {
  477. if (!styles)
  478. styles = new Array< __int64 >();
  479. styles->set(styles->get(pos) | style, pos);
  480. rend = 1;
  481. }
  482. void AuswahlListe::removeMsStyle(int pos, __int64 style)
  483. {
  484. if (!styles)
  485. styles = new Array< __int64 >();
  486. styles->set(styles->get(pos) & ~style, pos);
  487. rend = 1;
  488. }
  489. void AuswahlListe::doTastaturEreignis(TastaturEreignis& te)
  490. {
  491. bool ntakc = !te.verarbeitet;
  492. if (hatStyleNicht(Style::Fokus) || !tak || te.verarbeitet)
  493. return;
  494. getThis();
  495. if (tak(takParam, this, te))
  496. {
  497. if (te.id == TE_Press)
  498. {
  499. if (hatStyleNicht(Style::MultiSelect))
  500. {
  501. switch (te.taste)
  502. {
  503. case T_Unten:
  504. ++auswahl;
  505. if (auswahl > tfListe->getEintragAnzahl())
  506. auswahl = tfListe->getEintragAnzahl();
  507. rend = 1;
  508. break;
  509. case T_Oben:
  510. --auswahl;
  511. if (auswahl < -1)
  512. auswahl = -1;
  513. rend = 1;
  514. break;
  515. }
  516. }
  517. else
  518. {
  519. switch (te.taste)
  520. {
  521. case T_Unten:
  522. deSelect();
  523. ++auswahl;
  524. if (auswahl > tfListe->getEintragAnzahl())
  525. auswahl = tfListe->getEintragAnzahl();
  526. if (auswahl >= 0)
  527. addMsStyle(auswahl, Style::Selected);
  528. rend = 1;
  529. break;
  530. case T_Oben:
  531. deSelect();
  532. --auswahl;
  533. if (auswahl < -1)
  534. auswahl = -1;
  535. if (auswahl >= 0)
  536. addMsStyle(auswahl, Style::Selected);
  537. rend = 1;
  538. break;
  539. }
  540. }
  541. }
  542. te.verarbeitet = 1;
  543. }
  544. if (ntakc && te.verarbeitet && nTak)
  545. te.verarbeitet = nTak(ntakParam, this, te);
  546. release();
  547. }
  548. void AuswahlListe::render(Bild& zRObj) // zeichnet nach zRObj
  549. {
  550. if (!ZeichnungHintergrund::hatStyle(Style::Sichtbar))
  551. return;
  552. removeStyle(Style::HScroll);
  553. ZeichnungHintergrund::render(zRObj);
  554. lockZeichnung();
  555. if (!zRObj.setDrawOptions(innenPosition, innenSize))
  556. {
  557. unlockZeichnung();
  558. return;
  559. }
  560. int rbr = 0;
  561. if (rahmen && ZeichnungHintergrund::hatStyle(Style::Rahmen))
  562. rbr = rahmen->getRBreite();
  563. if (tfListe)
  564. {
  565. int maxHeight = 0;
  566. int dx = 0, dy = 0;
  567. if (vertikalScrollBar && ZeichnungHintergrund::hatStyle(Style::VScroll))
  568. dy -= vertikalScrollBar->getScroll();
  569. int mdy = innenSize.y + rbr;
  570. auto style = styles->begin();
  571. int i = 0;
  572. for (auto tf = tfListe->begin(); tf; tf++, style++, i++)
  573. {
  574. if (dy + tf->getHeight() > mdy && !(vertikalScrollBar && ZeichnungHintergrund::hatStyle(Style::VScroll)))
  575. break;
  576. tf->setPosition(dx, dy);
  577. tf->setSize(innenSize.x, tf->getHeight());
  578. maxHeight += tf->getHeight();
  579. bool selected = 0;
  580. if (ZeichnungHintergrund::hatStyle(Style::MultiSelect) && styles)
  581. selected = hatStyle(style, Style::Selected);
  582. else
  583. selected = auswahl == i;
  584. AlphaFeld* tmpBuffer = 0;
  585. bool tmpB = 0;
  586. int tmpHFarbe = 0;
  587. bool tmpH = 0;
  588. Bild* tmpHBild = 0;
  589. bool tmpHB = 0;
  590. bool tmpHAlpha = 0;
  591. Rahmen* tmpRahmen = 0;
  592. bool tmpR = 0;
  593. if (selected)
  594. {
  595. if (hatStyleNicht(Style::MultiStyled) || !styles)
  596. {
  597. if (ZeichnungHintergrund::hatStyle(Style::AuswahlBuffer) && aBuffer)
  598. {
  599. tmpBuffer = tf->getAlphaFeld();
  600. tf->setAlphaFeldZ(dynamic_cast<AlphaFeld*>(aBuffer->getThis()));
  601. tmpB = tf->hatStyle(TextFeld::Style::Buffered);
  602. tf->setStyle(TextFeld::Style::Buffered, ZeichnungHintergrund::hatStyle(Style::AuswahlBuffer));
  603. }
  604. if (ZeichnungHintergrund::hatStyle(Style::AuswahlHintergrund))
  605. {
  606. tmpH = tf->hatStyle(TextFeld::Style::Hintergrund);
  607. tmpHFarbe = tf->getHintergrundFarbe();
  608. tf->setHintergrundFarbe(ahFarbe);
  609. tf->setStyle(TextFeld::Style::Hintergrund, ZeichnungHintergrund::hatStyle(Style::Hintergrund));
  610. if (ZeichnungHintergrund::hatStyle(Style::AuswahlHBild) && ahBild)
  611. {
  612. tmpHBild = tf->getHintergrundBild();
  613. tf->setHintergrundBildZ(dynamic_cast<Bild*>(ahBild->getThis()));
  614. tmpHB = tf->hatStyle(TextFeld::Style::HBild);
  615. tf->setStyle(TextFeld::Style::HBild, ZeichnungHintergrund::hatStyle(Style::HBild));
  616. }
  617. if (ZeichnungHintergrund::hatStyle(Style::AuswahlHAlpha))
  618. {
  619. tmpHAlpha = tf->hatStyle(TextFeld::Style::HAlpha);
  620. tf->setStyle(TextFeld::Style::HAlpha, ZeichnungHintergrund::hatStyle(Style::AuswahlHAlpha));
  621. }
  622. }
  623. if (ZeichnungHintergrund::hatStyle(Style::AuswahlRahmen) && aRahmen)
  624. {
  625. tmpRahmen = tf->getRahmen();
  626. tf->setRahmenZ(dynamic_cast<Rahmen*>(aRahmen->getThis()));
  627. tmpR = tf->hatStyle(TextFeld::Style::Rahmen);
  628. tf->setStyle(TextFeld::Style::Rahmen, ZeichnungHintergrund::hatStyle(Style::AuswahlRahmen));
  629. }
  630. }
  631. else
  632. {
  633. if (hatStyle(style, Style::AuswahlBuffer) && aBufferListe)
  634. {
  635. tmpBuffer = tf->getAlphaFeld();
  636. tf->setAlphaFeldZ(aBufferListe->get(i));
  637. tmpB = tf->hatStyle(TextFeld::Style::Buffered);
  638. tf->setStyle(TextFeld::Style::Buffered, hatStyle(style, Style::AuswahlBuffer));
  639. }
  640. if (hatStyle(style, Style::AuswahlHintergrund))
  641. {
  642. tmpH = tf->hatStyle(Style::Hintergrund);
  643. tf->setStyle(TextFeld::Style::Hintergrund, hatStyle(style, Style::AuswahlHintergrund));
  644. if (ahFarbeListe && ahFarbeListe->hat(i))
  645. {
  646. tmpHFarbe = tf->getHintergrundFarbe();
  647. tf->setHintergrundFarbe(ahFarbeListe->get(i));
  648. }
  649. if (hatStyle(style, Style::AuswahlHBild) && ahBildListe)
  650. {
  651. tmpHBild = tf->getHintergrundBild();
  652. tf->setHintergrundBildZ(ahBildListe->get(i));
  653. tmpHB = tf->hatStyle(TextFeld::Style::HBild);
  654. tf->setStyle(TextFeld::Style::HBild, hatStyle(style, Style::HBild));
  655. }
  656. if (hatStyle(style, Style::AuswahlHAlpha))
  657. {
  658. tmpHAlpha = tf->hatStyle(TextFeld::Style::HAlpha);
  659. tf->setStyle(TextFeld::Style::HAlpha, hatStyle(style, Style::AuswahlHAlpha));
  660. }
  661. }
  662. if (hatStyle(style, Style::AuswahlRahmen) && aRahmenListe)
  663. {
  664. tmpRahmen = tf->getRahmen();
  665. tf->setRahmenZ(aRahmenListe->get(i));
  666. tmpR = tf->hatStyle(TextFeld::Style::Rahmen);
  667. tf->setStyle(TextFeld::Style::Rahmen, hatStyle(style, Style::AuswahlRahmen));
  668. }
  669. }
  670. }
  671. tf->render(zRObj);
  672. if (selected)
  673. {
  674. if (hatStyleNicht(Style::MultiStyled) || !styles)
  675. {
  676. if (ZeichnungHintergrund::hatStyle(Style::AuswahlBuffer))
  677. {
  678. tf->setAlphaFeldZ(tmpBuffer);
  679. tf->setStyle(TextFeld::Style::Buffered, tmpB);
  680. }
  681. if (ZeichnungHintergrund::hatStyle(Style::AuswahlHintergrund))
  682. {
  683. tf->setHintergrundFarbe(tmpHFarbe);
  684. tf->setStyle(TextFeld::Style::Hintergrund, tmpH);
  685. if (ZeichnungHintergrund::hatStyle(Style::AuswahlHBild))
  686. {
  687. tf->setHintergrundBildZ(tmpHBild);
  688. tf->setStyle(TextFeld::Style::HBild, tmpHB);
  689. }
  690. if (ZeichnungHintergrund::hatStyle(Style::AuswahlHAlpha))
  691. tf->setStyle(TextFeld::Style::HAlpha, tmpHAlpha);
  692. }
  693. if (ZeichnungHintergrund::hatStyle(Style::AuswahlRahmen))
  694. {
  695. tf->setRahmenZ(tmpRahmen);
  696. tf->setStyle(TextFeld::Style::Rahmen, tmpR);
  697. }
  698. }
  699. else
  700. {
  701. if (hatMsStyle(i, Style::AuswahlBuffer) && aBufferListe)
  702. {
  703. tf->setAlphaFeldZ(tmpBuffer);
  704. tf->setStyle(TextFeld::Style::Buffered, tmpB);
  705. }
  706. if (hatMsStyle(i, Style::AuswahlHintergrund))
  707. {
  708. tf->setStyle(TextFeld::Style::Hintergrund, tmpH);
  709. if (ahFarbeListe && ahFarbeListe->hat(i))
  710. tf->setHintergrundFarbe(tmpHFarbe);
  711. if (hatMsStyle(i, Style::AuswahlHBild) && ahBildListe)
  712. {
  713. tf->setHintergrundBildZ(tmpHBild);
  714. tf->setStyle(TextFeld::Style::HBild, tmpHB);
  715. }
  716. if (hatMsStyle(i, Style::AuswahlHAlpha))
  717. tf->setStyle(TextFeld::Style::HAlpha, tmpHAlpha);
  718. }
  719. if (hatMsStyle(i, Style::AuswahlRahmen) && aRahmenListe)
  720. {
  721. tf->setRahmenZ(tmpRahmen);
  722. tf->setStyle(TextFeld::Style::Rahmen, tmpR);
  723. }
  724. }
  725. }
  726. dy += tf->getHeight();
  727. }
  728. if (vertikalScrollBar)
  729. vertikalScrollBar->getScrollData()->max = maxHeight;
  730. }
  731. zRObj.releaseDrawOptions();
  732. unlockZeichnung();
  733. }
  734. int AuswahlListe::getKlickEintrag(int my)
  735. {
  736. if (!tfListe)
  737. return -1;
  738. int y = 0;
  739. if (ZeichnungHintergrund::hatStyle(Style::VScroll) && vertikalScrollBar)
  740. y -= vertikalScrollBar->getScroll();
  741. int i = 0;
  742. for (auto tf = tfListe->begin(); tf; tf++, i++)
  743. {
  744. y += tf->getHeight();
  745. if (y > my)
  746. return i;
  747. }
  748. return -1;
  749. }
  750. void AuswahlListe::setAuswahl(int ausw) // setzt die Auswahl
  751. {
  752. if (hatStyleNicht(Style::MultiSelect))
  753. auswahl = ausw;
  754. else if (styles)
  755. {
  756. for (int i = 0; i < styles->getEintragAnzahl(); ++i)
  757. removeMsStyle(i, Style::Selected);
  758. addMsStyle(ausw, Style::Selected);
  759. }
  760. }
  761. void AuswahlListe::deSelect()
  762. {
  763. if (hatStyleNicht(Style::MultiSelect))
  764. auswahl = -1;
  765. else if (styles)
  766. {
  767. for (int i = 0; i < styles->getEintragAnzahl(); ++i)
  768. removeMsStyle(i, Style::Selected);
  769. }
  770. }
  771. // constant
  772. int AuswahlListe::getEintragAnzahl() const // gibt die Anzahl der Einträge zurück
  773. {
  774. return tfListe ? tfListe->getEintragAnzahl() : 0;
  775. }
  776. int AuswahlListe::getAuswahl() const // gibt den ersten ausgewählten Eintrag zurück
  777. {
  778. return auswahl;
  779. }
  780. int AuswahlListe::getEintragPos(Text* eintragText) // gibt die Position des eintrages mit dem entsprechenden Textes zurück
  781. {
  782. int i = 0;
  783. for (auto tf = tfListe->begin(); tf; tf++, i++)
  784. {
  785. if (tf->zText()->istGleich(eintragText->getText()))
  786. {
  787. eintragText->release();
  788. return i;
  789. }
  790. }
  791. return -1;
  792. }
  793. TextFeld* AuswahlListe::getEintrag(int pos) const // gibt den pos- ten Eintrag zurück
  794. {
  795. if (!tfListe)
  796. return 0;
  797. TextFeld* ret = (TextFeld*)tfListe->get(pos);
  798. if (ret)
  799. return dynamic_cast<TextFeld*>(ret->getThis());
  800. return 0;
  801. }
  802. TextFeld* AuswahlListe::zEintrag(int pos) const
  803. {
  804. if (!tfListe)
  805. return 0;
  806. return (TextFeld*)tfListe->z(pos);
  807. }
  808. Rahmen* AuswahlListe::getARahmen() const // gibt den Auswahl Rahmen zurück (ohne MultiStyled)
  809. {
  810. if (aRahmen)
  811. return dynamic_cast<Rahmen*>(aRahmen->getThis());
  812. return 0;
  813. }
  814. Rahmen* AuswahlListe::zARahmen() const
  815. {
  816. return aRahmen;
  817. }
  818. int AuswahlListe::getAHFarbe() const // gibt die Auswahl Hintergrund Farbe zurück (ohne MultiStyled)
  819. {
  820. return ahFarbe;
  821. }
  822. Bild* AuswahlListe::getAHBild() const // gibt das Auswahl Hintergrund Bild zurück (ohne MultiStyled)
  823. {
  824. if (ahBild)
  825. return dynamic_cast<Bild*>(ahBild->getThis());
  826. return 0;
  827. }
  828. Bild* AuswahlListe::zAHBild() const
  829. {
  830. return ahBild;
  831. }
  832. AlphaFeld* AuswahlListe::getABuffer() const // gibt den Auswahl Buffer zurück (ohne MultiStyled)
  833. {
  834. if (aBuffer)
  835. return dynamic_cast<AlphaFeld*>(aBuffer->getThis());
  836. return 0;
  837. }
  838. AlphaFeld* AuswahlListe::zABuffer() const
  839. {
  840. return aBuffer;
  841. }
  842. Rahmen* AuswahlListe::getARahmen(int pos) const // gibt den Auswahl Rahmen zurück (mit MultiStyled)
  843. {
  844. Rahmen* ret = 0;
  845. if (aRahmenListe)
  846. ret = (Rahmen*)aRahmenListe->get(pos);
  847. if (ret)
  848. return dynamic_cast<Rahmen*>(ret->getThis());
  849. return 0;
  850. }
  851. Rahmen* AuswahlListe::zARahmen(int pos) const
  852. {
  853. Rahmen* ret = 0;
  854. if (aRahmenListe)
  855. ret = (Rahmen*)aRahmenListe->z(pos);
  856. return ret;
  857. }
  858. int AuswahlListe::getAHFarbe(int pos) const // gibt die Auswahl Hintergrund Farbe zurück (mit MultiStyled)
  859. {
  860. if (ahFarbeListe && ahFarbeListe->hat(pos))
  861. return ahFarbeListe->get(pos);
  862. return 0;
  863. }
  864. Bild* AuswahlListe::getAHBild(int pos) const // gibt das Auswahl Hintergrund Bild zurück (mit MultiStyled)
  865. {
  866. Bild* ret = 0;
  867. if (ahBildListe)
  868. ret = (Bild*)ahBildListe->get(pos);
  869. if (ret)
  870. return dynamic_cast<Bild*>(ret->getThis());
  871. return 0;
  872. }
  873. Bild* AuswahlListe::zAHBild(int pos) const
  874. {
  875. Bild* ret = 0;
  876. if (ahBildListe)
  877. ret = (Bild*)ahBildListe->z(pos);
  878. return ret;
  879. }
  880. AlphaFeld* AuswahlListe::getABuffer(int pos) const // gibt den Auswahl Buffer zurück (mit MultiStyled)
  881. {
  882. AlphaFeld* ret = 0;
  883. if (aBufferListe)
  884. ret = (AlphaFeld*)aBufferListe->get(pos);
  885. if (ret)
  886. return dynamic_cast<AlphaFeld*>(ret->getThis());
  887. return 0;
  888. }
  889. AlphaFeld* AuswahlListe::zABuffer(int pos) const
  890. {
  891. AlphaFeld* ret = 0;
  892. if (aBufferListe)
  893. ret = (AlphaFeld*)aBufferListe->z(pos);
  894. return ret;
  895. }
  896. bool AuswahlListe::hatMsStyle(int pos, __int64 style) const // prüft ob style vorhanden (mit MultiStyled)
  897. {
  898. __int64 st = 0;
  899. if (styles)
  900. st = styles->get(pos);
  901. return (st | style) == st;
  902. }
  903. bool AuswahlListe::hatMsStyleNicht(int pos, __int64 style) const // prüft obt style nicht vorhanden (mit MultiStyled)
  904. {
  905. __int64 st = 0;
  906. if (styles)
  907. st = styles->get(pos);
  908. return (st | style) != st;
  909. }