List.cpp 40 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322
  1. #include "List.h"
  2. #include "AlphaField.h"
  3. #include "Array.h"
  4. #include "Image.h"
  5. #include "Globals.h"
  6. #include "MouseEvent.h"
  7. #include "Border.h"
  8. #include "Font.h"
  9. #include "Scroll.h"
  10. #include "KeyboardEvent.h"
  11. #include "Text.h"
  12. #include "TextField.h"
  13. using namespace Framework;
  14. // Contents of the AuswahlListe class from List.h
  15. // Constructor
  16. AuswahlListe::AuswahlListe()
  17. : DrawableBackground(),
  18. tfListe(0),
  19. auswahl(-1),
  20. ahFarbe(0xFF000000),
  21. ahImage(0),
  22. aBuffer(0),
  23. aBorder(0),
  24. styles(0),
  25. ahFarbeListe(0),
  26. ahImageListe(0),
  27. aBufferListe(0),
  28. aBorderList(0),
  29. schrift(0)
  30. {
  31. style = 0;
  32. this->setMausEreignis(_ret1ME);
  33. this->setTastaturEreignis(_ret1TE);
  34. }
  35. // Destructor
  36. AuswahlListe::~AuswahlListe()
  37. {
  38. if (tfListe) tfListe->release();
  39. if (ahImage) ahImage->release();
  40. if (aBuffer) aBuffer->release();
  41. if (aBorder) aBorder->release();
  42. if (styles) styles->release();
  43. if (ahFarbeListe) ahFarbeListe->release();
  44. if (ahImageListe) ahImageListe->release();
  45. if (aBufferListe) aBufferListe->release();
  46. if (aBorderList) aBorderList->release();
  47. if (schrift) schrift->release();
  48. }
  49. void AuswahlListe::doMausEreignis(MausEreignis& me, bool userRet)
  50. {
  51. if (!userRet || hatStyleNicht(Style::Erlaubt)) return;
  52. if (DrawableBackground::hatStyle(Style::VScroll) && vertikalScrollBar)
  53. {
  54. int rbr = 0;
  55. if (rahmen && DrawableBackground::hatStyle(Style::Border))
  56. rbr = rahmen->getRBreite();
  57. if (((me.mx > gr.x - 15 - rbr) || me.id == ME_UScroll
  58. || me.id == ME_DScroll)
  59. && me.id != ME_Betritt && me.id != ME_Leaves)
  60. {
  61. vertikalScrollBar->doMausMessage(
  62. gr.x - rbr - 15, rbr, 15, gr.y - rbr * 2, me);
  63. me.verarbeitet = 1;
  64. }
  65. }
  66. if (!me.verarbeitet && me.id == ME_RLinks)
  67. {
  68. int eintr = getKlickEintrag(me.my);
  69. if (eintr >= 0)
  70. {
  71. if (hatStyleNicht(Style::MultiSelect))
  72. {
  73. auswahl = eintr;
  74. rend = 1;
  75. }
  76. else
  77. {
  78. bool shift = getTastenStand(T_Shift);
  79. bool strg = getTastenStand(T_Strg);
  80. if (strg)
  81. {
  82. setMsStyle(eintr,
  83. Style::Selected,
  84. hatMsStyleNicht(eintr, Style::Selected));
  85. auswahl = eintr;
  86. }
  87. else if (shift && auswahl != -1)
  88. {
  89. deSelect();
  90. int beg = auswahl, end = eintr;
  91. if (beg > end)
  92. {
  93. int tmp = end;
  94. end = beg;
  95. beg = tmp;
  96. }
  97. for (int i = beg; i <= end; ++i)
  98. {
  99. addMsStyle(i, Style::Selected);
  100. }
  101. }
  102. else
  103. {
  104. deSelect();
  105. addMsStyle(eintr, Style::Selected);
  106. auswahl = eintr;
  107. }
  108. }
  109. }
  110. else
  111. deSelect();
  112. }
  113. me.verarbeitet = 1;
  114. }
  115. bool AuswahlListe::hatStyle(int styleSet, int styleCheck) const
  116. {
  117. return (styleSet | styleCheck) == styleSet;
  118. }
  119. // non-constant
  120. void AuswahlListe::update() // updates the selection list
  121. {
  122. int rbr = 0;
  123. if (rahmen)
  124. {
  125. rbr = rahmen->getRBreite();
  126. rahmen->setPosition(0, 0);
  127. rahmen->setSize(gr.x, gr.y);
  128. }
  129. if (hintergrundFeld)
  130. {
  131. hintergrundFeld->setPosition(rbr, rbr);
  132. hintergrundFeld->setSize(gr.x - rbr * 2, gr.y - rbr * 2);
  133. }
  134. if (hatStyleNicht(Style::MultiStyled) && tfListe)
  135. {
  136. bool FieldBorder = DrawableBackground::hatStyle(Style::FieldBorder);
  137. bool FeldHintergrund
  138. = DrawableBackground::hatStyle(Style::FeldHintergrund);
  139. bool FeldHImage = DrawableBackground::hatStyle(Style::FeldHImage);
  140. bool FeldHAlpha = DrawableBackground::hatStyle(Style::FeldHAlpha);
  141. bool FeldBuffer = DrawableBackground::hatStyle(Style::FeldBuffer);
  142. for (TextField* tf : *tfListe)
  143. {
  144. tf->setStyle(TextField::Style::Border, FieldBorder);
  145. tf->setStyle(TextField::Style::Hintergrund, FeldHintergrund);
  146. tf->setStyle(TextField::Style::HImage, FeldHImage);
  147. tf->setStyle(TextField::Style::HAlpha, FeldHAlpha);
  148. tf->setStyle(TextField::Style::Buffered, FeldBuffer);
  149. if (schrift)
  150. tf->setFontZ(dynamic_cast<Font*>(schrift->getThis()));
  151. }
  152. }
  153. if (DrawableBackground::hatStyle(Style::MultiStyled) && tfListe && styles)
  154. {
  155. auto style = styles->begin();
  156. for (auto tf = tfListe->begin(); tf; tf++, style++)
  157. {
  158. tf->setStyle(
  159. TextField::Style::Border, hatStyle(style, Style::FieldBorder));
  160. tf->setStyle(TextField::Style::Hintergrund,
  161. hatStyle(style, Style::FeldHintergrund));
  162. tf->setStyle(
  163. TextField::Style::HImage, hatStyle(style, Style::FeldHImage));
  164. tf->setStyle(
  165. TextField::Style::HAlpha, hatStyle(style, Style::FeldHAlpha));
  166. tf->setStyle(
  167. TextField::Style::Buffered, hatStyle(style, Style::FeldBuffer));
  168. }
  169. }
  170. rend = 1;
  171. }
  172. void AuswahlListe::addEintrag(Text* txt) // adds an entry
  173. {
  174. TextField* tf = new TextField();
  175. tf->setStyle(TextField::Style::Center | TextField::Style::Sichtbar
  176. | TextField::Style::Border);
  177. tf->setSchriftFarbe(0xFFFFFFFF);
  178. tf->setBorderWidth(1);
  179. tf->setBorderColor(0xFFFFFFFF);
  180. tf->setTextZ(txt);
  181. tf->setSize(0, 20);
  182. addEintragZ(tf);
  183. rend = 1;
  184. }
  185. void AuswahlListe::addEintrag(const char* txt)
  186. {
  187. Text* tx = new Text(txt);
  188. addEintrag(tx);
  189. rend = 1;
  190. }
  191. void AuswahlListe::addEintragZ(TextField* tf)
  192. {
  193. if (!tfListe) tfListe = new RCArray<TextField>();
  194. if (schrift && (!tf->zFont() || hatStyleNicht(Style::MultiStyled)))
  195. tf->setFontZ(dynamic_cast<Font*>(schrift->getThis()));
  196. tfListe->add(tf);
  197. rend = 1;
  198. }
  199. void AuswahlListe::addEintrag(
  200. int pos, Text* txt) // inserts an entry at position pos
  201. {
  202. TextField* tf = new TextField();
  203. tf->setStyle(TextField::Style::Center | TextField::Style::Sichtbar
  204. | TextField::Style::Border);
  205. tf->setSchriftFarbe(0xFFFFFFFF);
  206. tf->setBorderWidth(1);
  207. tf->setBorderColor(0xFFFFFFFF);
  208. tf->setTextZ(txt);
  209. tf->setSize(0, 20);
  210. addEintragZ(pos, tf);
  211. rend = 1;
  212. }
  213. void AuswahlListe::addEintrag(int pos, const char* txt)
  214. {
  215. Text* tx = new Text(txt);
  216. addEintrag(pos, tx);
  217. rend = 1;
  218. }
  219. void AuswahlListe::addEintragZ(int pos, TextField* tf)
  220. {
  221. if (!tfListe) tfListe = new RCArray<TextField>();
  222. if (schrift && (!tf->zFont() || hatStyleNicht(Style::MultiStyled)))
  223. tf->setFontZ(dynamic_cast<Font*>(schrift->getThis()));
  224. tfListe->add(tf, pos);
  225. rend = 1;
  226. }
  227. void AuswahlListe::setEintrag(
  228. int pos, Text* txt) // changes the entry at pos
  229. {
  230. TextField* tf = 0;
  231. if (tfListe) tf = tfListe->z(pos);
  232. if (!tf)
  233. {
  234. tf = new TextField();
  235. tf->setStyle(TextField::Style::Center | TextField::Style::Sichtbar
  236. | TextField::Style::Border);
  237. tf->setSchriftFarbe(0xFFFFFFFF);
  238. tf->setBorderColor(0xFFFFFFFF);
  239. tf->setBorderWidth(1);
  240. tf->setTextZ(txt);
  241. tf->setSize(0, 20);
  242. setEintragZ(pos, tf);
  243. rend = 1;
  244. return;
  245. }
  246. tf->setTextZ(txt);
  247. rend = 1;
  248. }
  249. void AuswahlListe::setEintrag(int pos, const char* txt)
  250. {
  251. Text* tx = new Text(txt);
  252. setEintrag(pos, tx);
  253. rend = 1;
  254. }
  255. void AuswahlListe::setEintragZ(int pos, TextField* tf)
  256. {
  257. if (!tfListe) tfListe = new RCArray<TextField>();
  258. if (schrift && (!tf->zFont() || hatStyleNicht(Style::MultiStyled)))
  259. tf->setFontZ(dynamic_cast<Font*>(schrift->getThis()));
  260. tfListe->set(tf, pos);
  261. rend = 1;
  262. }
  263. void AuswahlListe::tauschEintragPos(
  264. int vpos, int npos) // swaps entry vpos with entry npos
  265. {
  266. if (tfListe)
  267. {
  268. tfListe->tausch(vpos, npos);
  269. if (styles) styles->tausch(vpos, npos);
  270. if (ahFarbeListe) ahFarbeListe->tausch(vpos, npos);
  271. if (ahImageListe) ahImageListe->tausch(vpos, npos);
  272. if (aBufferListe) aBufferListe->tausch(vpos, npos);
  273. if (aBorderList) aBorderList->tausch(vpos, npos);
  274. rend = 1;
  275. }
  276. }
  277. void Framework::AuswahlListe::setEintragPos(int vpos, int npos) {
  278. if (tfListe)
  279. {
  280. tfListe->setPosition(vpos, npos);
  281. if (styles) styles->setPosition(vpos, npos);
  282. if (ahFarbeListe) ahFarbeListe->setPosition(vpos, npos);
  283. if (ahImageListe) ahImageListe->setPosition(vpos, npos);
  284. if (aBufferListe) aBufferListe->setPosition(vpos, npos);
  285. if (aBorderList) aBorderList->setPosition(vpos, npos);
  286. rend = 1;
  287. }
  288. }
  289. void AuswahlListe::removeEintrag(int pos) // deletes entry at pos
  290. {
  291. tfListe->remove(pos);
  292. rend = 1;
  293. }
  294. void AuswahlListe::setFontZ(
  295. Font* schrift) // sets the font for the entries
  296. {
  297. if (this->schrift) this->schrift->release();
  298. this->schrift = schrift;
  299. rend = 1;
  300. }
  301. void AuswahlListe::setVScrollZuEintrag(int eintrag) // scrolls to entry
  302. {
  303. if (vertikalScrollBar)
  304. {
  305. if (eintrag > tfListe->getLastIndex())
  306. eintrag = tfListe->getLastIndex();
  307. int y = 0;
  308. for (int i = 0; i < eintrag; i++)
  309. y += tfListe->z(i) ? tfListe->z(i)->getHeight() : 0;
  310. vertikalScrollBar->scroll(y);
  311. }
  312. }
  313. void AuswahlListe::updateVScroll() // scrolls to cursor position or
  314. // down
  315. {
  316. if (vertikalScrollBar)
  317. {
  318. int y = 0;
  319. for (TextField* tf : *tfListe)
  320. y += (TextField*)tf ? tf->getHeight() : 0;
  321. vertikalScrollBar->update(y,
  322. gr.y
  323. - ((rahmen
  324. && DrawableBackground::hatStyle(
  325. TextField::Style::Border))
  326. ? rahmen->getRBreite()
  327. : 0));
  328. }
  329. }
  330. void AuswahlListe::setALRZ(Border*
  331. rahmen) // sets a pointer to the selection border (only without MultiStyled)
  332. {
  333. if (aBorder) aBorder->release();
  334. aBorder = rahmen;
  335. rend = 1;
  336. }
  337. void AuswahlListe::setALRBreite(
  338. int br) // sets the width of the selection border (only without MultiStyled)
  339. {
  340. if (!aBorder) aBorder = new LBorder();
  341. aBorder->setRamenBreite(br);
  342. rend = 1;
  343. }
  344. void AuswahlListe::setALRFarbe(
  345. int fc) // sets the color of the selection border (only without MultiStyled)
  346. {
  347. if (!aBorder) aBorder = new LBorder();
  348. aBorder->setFarbe(fc);
  349. rend = 1;
  350. }
  351. void AuswahlListe::setAAFZ(AlphaFeld* buffer) // sets a pointer to the selection
  352. // AlphaFeld (only without MultiStyled)
  353. {
  354. if (aBuffer) aBuffer->release();
  355. aBuffer = buffer;
  356. rend = 1;
  357. }
  358. void AuswahlListe::setAAFStrength(
  359. int st) // sets the strength of the selection background buffer (only without
  360. // MultiStyled)
  361. {
  362. if (!aBuffer) aBuffer = new AlphaFeld();
  363. aBuffer->setStrength(st);
  364. rend = 1;
  365. }
  366. void AuswahlListe::setAAFFarbe(
  367. int fc) // sets the color of the selection background buffer (only without
  368. // MultiStyled)
  369. {
  370. if (!aBuffer) aBuffer = new AlphaFeld();
  371. aBuffer->setFarbe(fc);
  372. rend = 1;
  373. }
  374. void AuswahlListe::setAHImage(
  375. Image* bild) // sets the selection background image (only without MultiStyled)
  376. {
  377. if (!ahImage) ahImage = new Image();
  378. ahImage->neuImage(bild->getBreite(), bild->getHeight(), 0);
  379. int* buff1 = ahImage->getBuffer();
  380. int* buff2 = bild->getBuffer();
  381. for (int i = 0; i < bild->getBreite() * bild->getHeight(); ++i)
  382. buff1[i] = buff2[i];
  383. bild->release();
  384. rend = 1;
  385. }
  386. void AuswahlListe::setAHFarbe(int f) // sets the selection
  387. // background color (only without MultiStyled)
  388. {
  389. ahFarbe = f;
  390. rend = 1;
  391. }
  392. void AuswahlListe::setAHImageZ(
  393. Image* b) // sets a pointer to the background image (only without MultiStyled)
  394. {
  395. if (ahImage) ahImage->release();
  396. ahImage = b;
  397. rend = 1;
  398. }
  399. void AuswahlListe::setALRZ(int pos,
  400. Border*
  401. rahmen) // sets a pointer to the selection border (only with MultiStyled)
  402. {
  403. if (!aBorderList) aBorderList = new RCArray<Border>();
  404. aBorderList->set(rahmen, pos);
  405. rend = 1;
  406. }
  407. void AuswahlListe::setALRBreite(int pos,
  408. int br) // sets the width of the selection border (only with MultiStyled)
  409. {
  410. if (!aBorderList) aBorderList = new RCArray<Border>();
  411. if (!aBorderList->z(pos)) aBorderList->set(new LBorder(), pos);
  412. aBorderList->z(pos)->setRamenBreite(br);
  413. rend = 1;
  414. }
  415. void AuswahlListe::setALRFarbe(int pos,
  416. int fc) // sets the color of the selection border (only with MultiStyled)
  417. {
  418. if (!aBorderList) aBorderList = new RCArray<Border>();
  419. if (!aBorderList->z(pos)) aBorderList->set(new LBorder(), pos);
  420. aBorderList->z(pos)->setFarbe(fc);
  421. rend = 1;
  422. }
  423. void AuswahlListe::setAAFZ(int pos,
  424. AlphaFeld*
  425. buffer) // sets a pointer to the selection AlphaFeld (only with MultiStyled)
  426. {
  427. if (!aBufferListe) aBufferListe = new RCArray<AlphaFeld>();
  428. aBufferListe->set(buffer, pos);
  429. rend = 1;
  430. }
  431. void AuswahlListe::setAAFStrength(
  432. int pos, int st) // sets the strength of the selection background buffer
  433. // (only with MultiStyled)
  434. {
  435. if (!aBufferListe) aBufferListe = new RCArray<AlphaFeld>();
  436. if (!aBufferListe->z(pos)) aBufferListe->set(new AlphaFeld(), pos);
  437. aBufferListe->z(pos)->setStrength(st);
  438. rend = 1;
  439. }
  440. void AuswahlListe::setAAFFarbe(
  441. int pos, int fc) // sets the color of the selection background buffer
  442. // (only with MultiStyled)
  443. {
  444. if (!aBufferListe) aBufferListe = new RCArray<AlphaFeld>();
  445. if (!aBufferListe->z(pos)) aBufferListe->set(new AlphaFeld(), pos);
  446. aBufferListe->z(pos)->setFarbe(fc);
  447. rend = 1;
  448. }
  449. void AuswahlListe::setAHImage(int pos,
  450. Image* bild) // sets the selection background image (only with MultiStyled)
  451. {
  452. if (ahImageListe) ahImageListe = new RCArray<Image>();
  453. if (!ahImageListe->z(pos)) ahImageListe->set(new Image(), pos);
  454. ahImageListe->z(pos)->neuImage(bild->getBreite(), bild->getHeight(), 0);
  455. int* buff1 = ahImageListe->z(pos)->getBuffer();
  456. int* buff2 = bild->getBuffer();
  457. for (int i = 0; i < bild->getBreite() * bild->getHeight(); ++i)
  458. buff1[i] = buff2[i];
  459. bild->release();
  460. rend = 1;
  461. }
  462. void AuswahlListe::setAHFarbe(
  463. int pos, int f) // sets the selection background color
  464. // (only with MultiStyled)
  465. {
  466. if (ahFarbeListe) ahFarbeListe = new Array<int>();
  467. ahFarbeListe->set(f, pos);
  468. rend = 1;
  469. }
  470. void AuswahlListe::setAHImageZ(int pos,
  471. Image* b) // sets a pointer to the background image (only with MultiStyled)
  472. {
  473. if (ahImageListe) ahImageListe = new RCArray<Image>();
  474. ahImageListe->set(b, pos);
  475. rend = 1;
  476. }
  477. void AuswahlListe::setMsStyle(int pos,
  478. __int64 style) // sets the style of the entry (only with MultiStyled)
  479. {
  480. if (!styles) styles = new Array<__int64>();
  481. styles->set(style, pos);
  482. rend = 1;
  483. }
  484. void AuswahlListe::setMsStyle(int pos, __int64 style, bool add_remove)
  485. {
  486. if (!styles) styles = new Array<__int64>();
  487. if (add_remove)
  488. styles->set(styles->get(pos) | style, pos);
  489. else
  490. styles->set(styles->get(pos) & ~style, pos);
  491. rend = 1;
  492. }
  493. void AuswahlListe::addMsStyle(int pos, __int64 style)
  494. {
  495. if (!styles) styles = new Array<__int64>();
  496. styles->set(styles->get(pos) | style, pos);
  497. rend = 1;
  498. }
  499. void AuswahlListe::removeMsStyle(int pos, __int64 style)
  500. {
  501. if (!styles) styles = new Array<__int64>();
  502. styles->set(styles->get(pos) & ~style, pos);
  503. rend = 1;
  504. }
  505. void AuswahlListe::doTastaturEreignis(TastaturEreignis& te)
  506. {
  507. bool ntakc = !te.verarbeitet;
  508. if (hatStyleNicht(Style::Fokus) || !tak || te.verarbeitet) return;
  509. getThis();
  510. if (tak(takParam, this, te))
  511. {
  512. if (te.id == TE_Press)
  513. {
  514. if (hatStyleNicht(Style::MultiSelect))
  515. {
  516. switch (te.virtualKey)
  517. {
  518. case T_Unten:
  519. ++auswahl;
  520. if (auswahl > tfListe->getEintragAnzahl())
  521. auswahl = tfListe->getEintragAnzahl();
  522. rend = 1;
  523. break;
  524. case T_Oben:
  525. --auswahl;
  526. if (auswahl < -1) auswahl = -1;
  527. rend = 1;
  528. break;
  529. }
  530. }
  531. else
  532. {
  533. switch (te.virtualKey)
  534. {
  535. case T_Unten:
  536. deSelect();
  537. ++auswahl;
  538. if (auswahl > tfListe->getEintragAnzahl())
  539. auswahl = tfListe->getEintragAnzahl();
  540. if (auswahl >= 0) addMsStyle(auswahl, Style::Selected);
  541. rend = 1;
  542. break;
  543. case T_Oben:
  544. deSelect();
  545. --auswahl;
  546. if (auswahl < -1) auswahl = -1;
  547. if (auswahl >= 0) addMsStyle(auswahl, Style::Selected);
  548. rend = 1;
  549. break;
  550. }
  551. }
  552. }
  553. te.verarbeitet = 1;
  554. }
  555. if (ntakc && te.verarbeitet && nTak)
  556. te.verarbeitet = nTak(ntakParam, this, te);
  557. release();
  558. }
  559. void AuswahlListe::render(Image& zRObj) // draws to zRObj
  560. {
  561. if (!DrawableBackground::hatStyle(Style::Sichtbar)) return;
  562. removeStyle(Style::HScroll);
  563. DrawableBackground::render(zRObj);
  564. lockDrawable();
  565. if (!zRObj.setDrawOptions(innenPosition, innenSize))
  566. {
  567. unlockDrawable();
  568. return;
  569. }
  570. int rbr = 0;
  571. if (rahmen && DrawableBackground::hatStyle(Style::Border))
  572. rbr = rahmen->getRBreite();
  573. if (tfListe)
  574. {
  575. int maxHeight = 0;
  576. int dx = 0, dy = 0;
  577. if (vertikalScrollBar && DrawableBackground::hatStyle(Style::VScroll))
  578. dy -= vertikalScrollBar->getScroll();
  579. int mdy = innenSize.y + rbr;
  580. auto style = styles ? styles->begin() : Array<__int64>().begin();
  581. int i = 0;
  582. for (auto tf = tfListe->begin(); tf; tf++, style++, i++)
  583. {
  584. if (dy + tf->getHeight() > mdy
  585. && !(vertikalScrollBar
  586. && DrawableBackground::hatStyle(Style::VScroll)))
  587. break;
  588. tf->setPosition(dx, dy);
  589. tf->setSize(innenSize.x, tf->getHeight());
  590. maxHeight += tf->getHeight();
  591. bool selected = 0;
  592. if (DrawableBackground::hatStyle(Style::MultiSelect) && styles)
  593. selected = hatStyle(style, Style::Selected);
  594. else
  595. selected = auswahl == i;
  596. AlphaFeld* tmpBuffer = 0;
  597. bool tmpB = 0;
  598. int tmpHFarbe = 0;
  599. bool tmpH = 0;
  600. Image* tmpHImage = 0;
  601. bool tmpHB = 0;
  602. bool tmpHAlpha = 0;
  603. Border* tmpBorder = 0;
  604. bool tmpR = 0;
  605. if (selected)
  606. {
  607. if (hatStyleNicht(Style::MultiStyled) || !styles)
  608. {
  609. if (DrawableBackground::hatStyle(Style::AuswahlBuffer)
  610. && aBuffer)
  611. {
  612. tmpBuffer = tf->getAlphaFeld();
  613. tf->setAlphaFeldZ(
  614. dynamic_cast<AlphaFeld*>(aBuffer->getThis()));
  615. tmpB = tf->hatStyle(TextField::Style::Buffered);
  616. tf->setStyle(TextField::Style::Buffered,
  617. DrawableBackground::hatStyle(
  618. Style::AuswahlBuffer));
  619. }
  620. if (DrawableBackground::hatStyle(
  621. Style::AuswahlHintergrund))
  622. {
  623. tmpH = tf->hatStyle(TextField::Style::Hintergrund);
  624. tmpHFarbe = tf->getHintergrundFarbe();
  625. tf->setHintergrundFarbe(ahFarbe);
  626. tf->setStyle(TextField::Style::Hintergrund,
  627. DrawableBackground::hatStyle(Style::Hintergrund));
  628. if (DrawableBackground::hatStyle(Style::AuswahlHImage)
  629. && ahImage)
  630. {
  631. tmpHImage = tf->getHintergrundImage();
  632. tf->setHintergrundImageZ(
  633. dynamic_cast<Image*>(ahImage->getThis()));
  634. tmpHB = tf->hatStyle(TextField::Style::HImage);
  635. tf->setStyle(TextField::Style::HImage,
  636. DrawableBackground::hatStyle(Style::HImage));
  637. }
  638. if (DrawableBackground::hatStyle(
  639. Style::AuswahlHAlpha))
  640. {
  641. tmpHAlpha = tf->hatStyle(TextField::Style::HAlpha);
  642. tf->setStyle(TextField::Style::HAlpha,
  643. DrawableBackground::hatStyle(
  644. Style::AuswahlHAlpha));
  645. }
  646. }
  647. if (DrawableBackground::hatStyle(Style::SelectionBorder)
  648. && aBorder)
  649. {
  650. tmpBorder = tf->getBorder();
  651. tf->setBorderZ(
  652. dynamic_cast<Border*>(aBorder->getThis()));
  653. tmpR = tf->hatStyle(TextField::Style::Border);
  654. tf->setStyle(TextField::Style::Border,
  655. DrawableBackground::hatStyle(
  656. Style::SelectionBorder));
  657. }
  658. }
  659. else
  660. {
  661. if (hatStyle(style, Style::AuswahlBuffer) && aBufferListe)
  662. {
  663. tmpBuffer = tf->getAlphaFeld();
  664. tf->setAlphaFeldZ(aBufferListe->get(i));
  665. tmpB = tf->hatStyle(TextField::Style::Buffered);
  666. tf->setStyle(TextField::Style::Buffered,
  667. hatStyle(style, Style::AuswahlBuffer));
  668. }
  669. if (hatStyle(style, Style::AuswahlHintergrund))
  670. {
  671. tmpH = tf->hatStyle(Style::Hintergrund);
  672. tf->setStyle(TextField::Style::Hintergrund,
  673. hatStyle(style, Style::AuswahlHintergrund));
  674. if (ahFarbeListe && ahFarbeListe->hat(i))
  675. {
  676. tmpHFarbe = tf->getHintergrundFarbe();
  677. tf->setHintergrundFarbe(ahFarbeListe->get(i));
  678. }
  679. if (hatStyle(style, Style::AuswahlHImage) && ahImageListe)
  680. {
  681. tmpHImage = tf->getHintergrundImage();
  682. tf->setHintergrundImageZ(ahImageListe->get(i));
  683. tmpHB = tf->hatStyle(TextField::Style::HImage);
  684. tf->setStyle(TextField::Style::HImage,
  685. hatStyle(style, Style::HImage));
  686. }
  687. if (hatStyle(style, Style::AuswahlHAlpha))
  688. {
  689. tmpHAlpha = tf->hatStyle(TextField::Style::HAlpha);
  690. tf->setStyle(TextField::Style::HAlpha,
  691. hatStyle(style, Style::AuswahlHAlpha));
  692. }
  693. }
  694. if (hatStyle(style, Style::SelectionBorder) && aBorderList)
  695. {
  696. tmpBorder = tf->getBorder();
  697. tf->setBorderZ(aBorderList->get(i));
  698. tmpR = tf->hatStyle(TextField::Style::Border);
  699. tf->setStyle(TextField::Style::Border,
  700. hatStyle(style, Style::SelectionBorder));
  701. }
  702. }
  703. }
  704. tf->render(zRObj);
  705. if (selected)
  706. {
  707. if (hatStyleNicht(Style::MultiStyled) || !styles)
  708. {
  709. if (DrawableBackground::hatStyle(Style::AuswahlBuffer))
  710. {
  711. tf->setAlphaFeldZ(tmpBuffer);
  712. tf->setStyle(TextField::Style::Buffered, tmpB);
  713. }
  714. if (DrawableBackground::hatStyle(
  715. Style::AuswahlHintergrund))
  716. {
  717. tf->setHintergrundFarbe(tmpHFarbe);
  718. tf->setStyle(TextField::Style::Hintergrund, tmpH);
  719. if (DrawableBackground::hatStyle(Style::AuswahlHImage))
  720. {
  721. tf->setHintergrundImageZ(tmpHImage);
  722. tf->setStyle(TextField::Style::HImage, tmpHB);
  723. }
  724. if (DrawableBackground::hatStyle(
  725. Style::AuswahlHAlpha))
  726. tf->setStyle(TextField::Style::HAlpha, tmpHAlpha);
  727. }
  728. if (DrawableBackground::hatStyle(Style::SelectionBorder))
  729. {
  730. tf->setBorderZ(tmpBorder);
  731. tf->setStyle(TextField::Style::Border, tmpR);
  732. }
  733. }
  734. else
  735. {
  736. if (hatMsStyle(i, Style::AuswahlBuffer) && aBufferListe)
  737. {
  738. tf->setAlphaFeldZ(tmpBuffer);
  739. tf->setStyle(TextField::Style::Buffered, tmpB);
  740. }
  741. if (hatMsStyle(i, Style::AuswahlHintergrund))
  742. {
  743. tf->setStyle(TextField::Style::Hintergrund, tmpH);
  744. if (ahFarbeListe && ahFarbeListe->hat(i))
  745. tf->setHintergrundFarbe(tmpHFarbe);
  746. if (hatMsStyle(i, Style::AuswahlHImage) && ahImageListe)
  747. {
  748. tf->setHintergrundImageZ(tmpHImage);
  749. tf->setStyle(TextField::Style::HImage, tmpHB);
  750. }
  751. if (hatMsStyle(i, Style::AuswahlHAlpha))
  752. tf->setStyle(TextField::Style::HAlpha, tmpHAlpha);
  753. }
  754. if (hatMsStyle(i, Style::SelectionBorder) && aBorderList)
  755. {
  756. tf->setBorderZ(tmpBorder);
  757. tf->setStyle(TextField::Style::Border, tmpR);
  758. }
  759. }
  760. }
  761. dy += tf->getHeight();
  762. }
  763. if (vertikalScrollBar)
  764. vertikalScrollBar->getScrollData()->max = maxHeight;
  765. }
  766. zRObj.releaseDrawOptions();
  767. unlockDrawable();
  768. }
  769. int AuswahlListe::getKlickEintrag(int my)
  770. {
  771. if (!tfListe) return -1;
  772. int y = 0;
  773. if (DrawableBackground::hatStyle(Style::VScroll) && vertikalScrollBar)
  774. y -= vertikalScrollBar->getScroll();
  775. int i = 0;
  776. for (auto tf = tfListe->begin(); tf; tf++, i++)
  777. {
  778. y += tf->getHeight();
  779. if (y > my) return i;
  780. }
  781. return -1;
  782. }
  783. void AuswahlListe::setAuswahl(int ausw) // sets the selection
  784. {
  785. if (hatStyleNicht(Style::MultiSelect))
  786. auswahl = ausw;
  787. else if (styles)
  788. {
  789. for (int i = 0; i < styles->getEintragAnzahl(); ++i)
  790. removeMsStyle(i, Style::Selected);
  791. addMsStyle(ausw, Style::Selected);
  792. }
  793. }
  794. void AuswahlListe::deSelect()
  795. {
  796. if (hatStyleNicht(Style::MultiSelect))
  797. auswahl = -1;
  798. else if (styles)
  799. {
  800. for (int i = 0; i < styles->getEintragAnzahl(); ++i)
  801. removeMsStyle(i, Style::Selected);
  802. }
  803. }
  804. // constant
  805. int AuswahlListe::getEintragAnzahl()
  806. const // returns the number of entries
  807. {
  808. return tfListe ? tfListe->getEintragAnzahl() : 0;
  809. }
  810. int AuswahlListe::getAuswahl()
  811. const // returns the first selected entry
  812. {
  813. return auswahl;
  814. }
  815. int AuswahlListe::getEintragPos(
  816. Text* eintragText) // returns the position of the entry with the
  817. // corresponding text
  818. {
  819. int i = 0;
  820. for (auto tf = tfListe->begin(); tf; tf++, i++)
  821. {
  822. if (tf->zText()->istGleich(eintragText->getText()))
  823. {
  824. eintragText->release();
  825. return i;
  826. }
  827. }
  828. return -1;
  829. }
  830. TextField* AuswahlListe::getEintrag(
  831. int pos) const // returns the entry at position pos
  832. {
  833. if (!tfListe) return 0;
  834. TextField* ret = (TextField*)tfListe->get(pos);
  835. if (ret) return dynamic_cast<TextField*>(ret->getThis());
  836. return 0;
  837. }
  838. TextField* AuswahlListe::zEintrag(int pos) const
  839. {
  840. if (!tfListe) return 0;
  841. return (TextField*)tfListe->z(pos);
  842. }
  843. Border* AuswahlListe::getABorder()
  844. const // returns the selection border (without MultiStyled)
  845. {
  846. if (aBorder) return dynamic_cast<Border*>(aBorder->getThis());
  847. return 0;
  848. }
  849. Border* AuswahlListe::zABorder() const
  850. {
  851. return aBorder;
  852. }
  853. int AuswahlListe::getAHFarbe()
  854. const // returns the selection background color (without MultiStyled)
  855. {
  856. return ahFarbe;
  857. }
  858. Image* AuswahlListe::getAHImage()
  859. const // returns the selection background image (without MultiStyled)
  860. {
  861. if (ahImage) return dynamic_cast<Image*>(ahImage->getThis());
  862. return 0;
  863. }
  864. Image* AuswahlListe::zAHImage() const
  865. {
  866. return ahImage;
  867. }
  868. AlphaFeld* AuswahlListe::getABuffer()
  869. const // returns the selection buffer (without MultiStyled)
  870. {
  871. if (aBuffer) return dynamic_cast<AlphaFeld*>(aBuffer->getThis());
  872. return 0;
  873. }
  874. AlphaFeld* AuswahlListe::zABuffer() const
  875. {
  876. return aBuffer;
  877. }
  878. Border* AuswahlListe::getABorder(
  879. int pos) const // returns the selection border (with MultiStyled)
  880. {
  881. Border* ret = 0;
  882. if (aBorderList) ret = (Border*)aBorderList->get(pos);
  883. if (ret) return dynamic_cast<Border*>(ret->getThis());
  884. return 0;
  885. }
  886. Border* AuswahlListe::zABorder(int pos) const
  887. {
  888. Border* ret = 0;
  889. if (aBorderList) ret = (Border*)aBorderList->z(pos);
  890. return ret;
  891. }
  892. int AuswahlListe::getAHFarbe(int pos)
  893. const // returns the selection background color (with MultiStyled)
  894. {
  895. if (ahFarbeListe && ahFarbeListe->hat(pos)) return ahFarbeListe->get(pos);
  896. return 0;
  897. }
  898. Image* AuswahlListe::getAHImage(
  899. int pos) const // returns the selection background image (with MultiStyled)
  900. {
  901. Image* ret = 0;
  902. if (ahImageListe) ret = (Image*)ahImageListe->get(pos);
  903. if (ret) return dynamic_cast<Image*>(ret->getThis());
  904. return 0;
  905. }
  906. Image* AuswahlListe::zAHImage(int pos) const
  907. {
  908. Image* ret = 0;
  909. if (ahImageListe) ret = (Image*)ahImageListe->z(pos);
  910. return ret;
  911. }
  912. AlphaFeld* AuswahlListe::getABuffer(
  913. int pos) const // returns the selection buffer (with MultiStyled)
  914. {
  915. AlphaFeld* ret = 0;
  916. if (aBufferListe) ret = (AlphaFeld*)aBufferListe->get(pos);
  917. if (ret) return dynamic_cast<AlphaFeld*>(ret->getThis());
  918. return 0;
  919. }
  920. AlphaFeld* AuswahlListe::zABuffer(int pos) const
  921. {
  922. AlphaFeld* ret = 0;
  923. if (aBufferListe) ret = (AlphaFeld*)aBufferListe->z(pos);
  924. return ret;
  925. }
  926. bool AuswahlListe::hatMsStyle(
  927. int pos, __int64 style) const // checks if style is present (with MultiStyled)
  928. {
  929. __int64 st = 0;
  930. if (styles) st = styles->get(pos);
  931. return (st | style) == st;
  932. }
  933. bool AuswahlListe::hatMsStyleNicht(int pos,
  934. __int64 style) const // checks if style is not present (with MultiStyled)
  935. {
  936. __int64 st = 0;
  937. if (styles) st = styles->get(pos);
  938. return (st | style) != st;
  939. }
  940. //! Constructor
  941. ZListe::ZListe()
  942. : DrawableBackground()
  943. {
  944. entrySeperatorSize = 1;
  945. entrySeperatorColor = 0xFFFFFFFF;
  946. setBorderWidth(1);
  947. setBorderColor(0xFFFFFFFF);
  948. setHintergrundFarbe(0xFF000000);
  949. }
  950. //! Destructor
  951. ZListe::~ZListe() {}
  952. //! Processes mouse messages
  953. //! \param me The event triggered by the mouse input
  954. void ZListe::doMausEreignis(MausEreignis& me, bool userRet)
  955. {
  956. if (DrawableBackground::hatStyle(Style::VScroll) && vertikalScrollBar)
  957. {
  958. int rbr = 0;
  959. if (rahmen && DrawableBackground::hatStyle(Style::Border))
  960. rbr = rahmen->getRBreite();
  961. if (((me.mx > gr.x - 15 - rbr) || me.id == ME_UScroll
  962. || me.id == ME_DScroll)
  963. && me.id != ME_Betritt && me.id != ME_Leaves)
  964. {
  965. vertikalScrollBar->doMausMessage(
  966. gr.x - rbr - 15, rbr, 15, gr.y - rbr * 2, me);
  967. me.verarbeitet = 1;
  968. }
  969. me.my += vertikalScrollBar->getScroll();
  970. }
  971. me.my -= (rahmen && DrawableBackground::hatStyle(TextField::Style::Border))
  972. ? rahmen->getRBreite() * 2
  973. : 0;
  974. me.mx -= (rahmen && DrawableBackground::hatStyle(TextField::Style::Border))
  975. ? rahmen->getRBreite() * 2
  976. : 0;
  977. int ySum = 0;
  978. int index = 0;
  979. for (Drawable* entry : list)
  980. {
  981. entry->doPublicMausEreignis(me);
  982. ySum += entry->getHeight();
  983. me.my -= entry->getHeight();
  984. if (index < list.getLastIndex())
  985. {
  986. ySum
  987. += DrawableBackground::hatStyle(ZListe::Style::EntrySeperator)
  988. ? entrySeperatorSize
  989. : 0;
  990. me.my
  991. -= DrawableBackground::hatStyle(ZListe::Style::EntrySeperator)
  992. ? entrySeperatorSize
  993. : 0;
  994. }
  995. index++;
  996. }
  997. me.my
  998. += ySum
  999. + (rahmen
  1000. && DrawableBackground::hatStyle(TextField::Style::Border))
  1001. ? rahmen->getRBreite() * 2
  1002. : 0;
  1003. me.mx += (rahmen && DrawableBackground::hatStyle(TextField::Style::Border))
  1004. ? rahmen->getRBreite() * 2
  1005. : 0;
  1006. if (DrawableBackground::hatStyle(Style::VScroll) && vertikalScrollBar)
  1007. me.my -= vertikalScrollBar->getScroll();
  1008. }
  1009. //! Adds an entry
  1010. //! \param entry The drawing to add
  1011. void ZListe::addEintrag(Drawable* entry)
  1012. {
  1013. rend = 1;
  1014. list.add(entry);
  1015. }
  1016. //! Changes an entry
  1017. //! \param pos The index of the entry
  1018. //! \param entry The new drawing
  1019. void ZListe::setEintrag(int pos, Drawable* entry)
  1020. {
  1021. rend = 1;
  1022. list.set(entry, pos);
  1023. }
  1024. //! Swaps the positions of two entries
  1025. //! \param vpos The index of the first entry
  1026. //! \param npos The index of the second entry
  1027. void ZListe::tauschEintragPos(int vPos, int nPos)
  1028. {
  1029. rend = 1;
  1030. list.tausch(vPos, nPos);
  1031. }
  1032. void Framework::ZListe::setEintragPos(int vpos, int npos)
  1033. {
  1034. list.setPosition(vpos, npos);
  1035. }
  1036. //! Deletes an entry
  1037. //! pos: The index of the entry
  1038. void ZListe::removeEintrag(int pos)
  1039. {
  1040. rend = 1;
  1041. list.remove(pos);
  1042. }
  1043. //! Scrolls to a specific entry
  1044. //! \param eintrag The index of the entry
  1045. void ZListe::setVScrollZuEintrag(int eintrag)
  1046. {
  1047. if (vertikalScrollBar)
  1048. {
  1049. if (eintrag > list.getLastIndex()) eintrag = list.getLastIndex();
  1050. int y = 0;
  1051. int index = 0;
  1052. for (Drawable* entry : list)
  1053. {
  1054. y += entry->getHeight();
  1055. if (index < list.getLastIndex())
  1056. y += DrawableBackground::hatStyle(
  1057. ZListe::Style::EntrySeperator)
  1058. ? entrySeperatorSize
  1059. : 0;
  1060. index++;
  1061. }
  1062. vertikalScrollBar->scroll(y);
  1063. }
  1064. }
  1065. //! Updates the maximum scroll height by adding the heights of all entries
  1066. void ZListe::updateVScroll()
  1067. {
  1068. if (vertikalScrollBar)
  1069. {
  1070. int y = 0;
  1071. int index = 0;
  1072. for (Drawable* entry : list)
  1073. {
  1074. y += entry->getHeight();
  1075. if (index < list.getLastIndex())
  1076. y += DrawableBackground::hatStyle(
  1077. ZListe::Style::EntrySeperator)
  1078. ? entrySeperatorSize
  1079. : 0;
  1080. index++;
  1081. }
  1082. vertikalScrollBar->update(y,
  1083. gr.y
  1084. - ((rahmen
  1085. && DrawableBackground::hatStyle(
  1086. TextField::Style::Border))
  1087. ? rahmen->getRBreite() * 2
  1088. : 0));
  1089. }
  1090. }
  1091. //! sets the size of the entry seperator
  1092. void ZListe::setEntrySeperatorSize(int size)
  1093. {
  1094. entrySeperatorSize = size;
  1095. }
  1096. //! sets the color of the entry seperator
  1097. void ZListe::setEntrySeperatorColor(int color)
  1098. {
  1099. entrySeperatorColor = color;
  1100. }
  1101. //! Processes a keyboard event. Called automatically by the framework
  1102. //! \param te The event
  1103. void ZListe::doTastaturEreignis(TastaturEreignis& te)
  1104. {
  1105. for (Drawable* entry : list)
  1106. entry->doTastaturEreignis(te);
  1107. }
  1108. //! Updates the drawing
  1109. //! \param tickVal The elapsed time in seconds since the last call of this
  1110. //! function \return 1 if the drawing has changed since the last call
  1111. bool ZListe::tick(double tickVal)
  1112. {
  1113. bool ret = DrawableBackground::tick(tickVal);
  1114. for (Drawable* entry : list)
  1115. ret |= entry->tick(tickVal);
  1116. return ret;
  1117. }
  1118. //! Draws the object to zRObj if it is visible
  1119. //! \param zRObj The image to draw into
  1120. void ZListe::render(Image& rObj)
  1121. {
  1122. DrawableBackground::render(rObj);
  1123. int index = 0;
  1124. int rbr = rahmen && DrawableBackground::hatStyle(TextField::Style::Border)
  1125. ? rahmen->getRBreite()
  1126. : 0;
  1127. bool vs = vertikalScrollBar && hatStyle(Style::VScroll);
  1128. if (rObj.setDrawOptions(pos + Punkt(rbr, rbr),
  1129. gr - Punkt(rbr, rbr) * 2 - Punkt(vs ? 15 : 0, 0)))
  1130. {
  1131. if (vs) rObj.addScrollOffset(0, vertikalScrollBar->getScroll());
  1132. for (Drawable* entry : list)
  1133. {
  1134. entry->setWidth(gr.x - rbr * 2 - (vs ? 15 : 0));
  1135. entry->render(rObj);
  1136. rObj.addScrollOffset(0, -entry->getHeight());
  1137. if (index < list.getLastIndex()
  1138. && DrawableBackground::hatStyle(
  1139. ZListe::Style::EntrySeperator))
  1140. {
  1141. for (int i = 0; i < entrySeperatorSize; i++)
  1142. {
  1143. rObj.drawLinieHAlpha(
  1144. 0, 0, gr.x - rbr - (vs ? 15 : 0), entrySeperatorColor);
  1145. rObj.addScrollOffset(0, -1);
  1146. }
  1147. }
  1148. index++;
  1149. }
  1150. rObj.releaseDrawOptions();
  1151. }
  1152. }
  1153. //! Returns the index of an entry the mouse points to
  1154. //! \param my The position of the mouse on the Y axis relative to the top
  1155. //! edge of the list
  1156. int ZListe::getKlickEintrag(int my)
  1157. {
  1158. if (my < 0) return -1;
  1159. int index = 0;
  1160. int y = 0;
  1161. for (Drawable* entry : list)
  1162. {
  1163. if (my < y) return index;
  1164. y += entry->getHeight();
  1165. if (index < list.getLastIndex())
  1166. y += DrawableBackground::hatStyle(ZListe::Style::EntrySeperator)
  1167. ? entrySeperatorSize
  1168. : 0;
  1169. index++;
  1170. }
  1171. return -1;
  1172. }
  1173. //! Returns the number of entries
  1174. int ZListe::getEintragAnzahl() const
  1175. {
  1176. return list.getEintragAnzahl();
  1177. }
  1178. //! Returns the index of an entry
  1179. //! \param zEntry The drawing
  1180. int ZListe::getEintragPos(Drawable* zEntry)
  1181. {
  1182. int index = 0;
  1183. for (Drawable* entry : list)
  1184. {
  1185. if (zEntry == entry) return index;
  1186. index++;
  1187. }
  1188. return -1;
  1189. }
  1190. //! Returns an entry
  1191. //! \param pos The index of the entry
  1192. Drawable* ZListe::getEintrag(int pos) const
  1193. {
  1194. return list.get(pos);
  1195. }
  1196. //! Returns an entry without increased reference counter
  1197. //! \param pos The index of the entry
  1198. Drawable* ZListe::zEintrag(int pos) const
  1199. {
  1200. return list.get(pos);
  1201. }
  1202. //! Returns the needed height
  1203. int ZListe::getNeededHeight() const
  1204. {
  1205. int y = (rahmen && DrawableBackground::hatStyle(TextField::Style::Border))
  1206. ? rahmen->getRBreite() * 2
  1207. : 0;
  1208. int index = 0;
  1209. for (Drawable* entry : list)
  1210. {
  1211. y += entry->getHeight();
  1212. if (index < list.getLastIndex())
  1213. y += DrawableBackground::hatStyle(ZListe::Style::EntrySeperator)
  1214. ? entrySeperatorSize
  1215. : 0;
  1216. index++;
  1217. }
  1218. return y;
  1219. }
  1220. //! returns the size of the entry seperator
  1221. int ZListe::getEntrySeperatorSize() const
  1222. {
  1223. return entrySeperatorSize;
  1224. }
  1225. //! returns the color of the entry seperator
  1226. int ZListe::getEntrySeperatorColor() const
  1227. {
  1228. return entrySeperatorColor;
  1229. }