List.cpp 40 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324
  1. #include "List.h"
  2. #include "AlphaField.h"
  3. #include "Array.h"
  4. #include "Border.h"
  5. #include "Font.h"
  6. #include "Globals.h"
  7. #include "Image.h"
  8. #include "KeyboardEvent.h"
  9. #include "MouseEvent.h"
  10. #include "Scroll.h"
  11. #include "Text.h"
  12. #include "TextField.h"
  13. using namespace Framework;
  14. // Contents of the SelectionList class from List.h
  15. // Constructor
  16. SelectionList::SelectionList()
  17. : DrawableBackground(),
  18. tfListe(0),
  19. selection(-1),
  20. ahColor(0xFF000000),
  21. ahImage(0),
  22. aBuffer(0),
  23. aBorder(0),
  24. styles(0),
  25. ahColorListe(0),
  26. ahImageListe(0),
  27. aBufferListe(0),
  28. aBorderList(0),
  29. font(0)
  30. {
  31. style = 0;
  32. this->setMouseEvent(_ret1ME);
  33. this->setKeyboardEvent(_ret1TE);
  34. }
  35. // Destructor
  36. SelectionList::~SelectionList()
  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 (ahColorListe) ahColorListe->release();
  44. if (ahImageListe) ahImageListe->release();
  45. if (aBufferListe) aBufferListe->release();
  46. if (aBorderList) aBorderList->release();
  47. if (font) font->release();
  48. }
  49. void SelectionList::doMouseEvent(MouseEvent& me, bool userRet)
  50. {
  51. if (!userRet || hasStyleNot(Style::Allowed)) return;
  52. if (DrawableBackground::hasStyle(Style::VScroll) && vertikalScrollBar)
  53. {
  54. int rbr = 0;
  55. if (border && DrawableBackground::hasStyle(Style::Border))
  56. rbr = border->getRWidth();
  57. if (((me.mx > gr.x - 15 - rbr) || me.id == ME_UScroll
  58. || me.id == ME_DScroll)
  59. && me.id != ME_Enter && me.id != ME_Leaves)
  60. {
  61. vertikalScrollBar->doMouseMessage(
  62. gr.x - rbr - 15, rbr, 15, gr.y - rbr * 2, me);
  63. me.processed = 1;
  64. }
  65. }
  66. if (!me.processed && me.id == ME_RLeft)
  67. {
  68. int eintr = getClickEntry(me.my);
  69. if (eintr >= 0)
  70. {
  71. if (hasStyleNot(Style::MultiSelect))
  72. {
  73. selection = eintr;
  74. rend = 1;
  75. }
  76. else
  77. {
  78. bool shift = getKeyState(T_Shift);
  79. bool strg = getKeyState(T_Strg);
  80. if (strg)
  81. {
  82. setMsStyle(eintr,
  83. Style::Selected,
  84. hasMsStyleNot(eintr, Style::Selected));
  85. selection = eintr;
  86. }
  87. else if (shift && selection != -1)
  88. {
  89. deselect();
  90. int beg = selection, 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. selection = eintr;
  107. }
  108. }
  109. }
  110. else
  111. deselect();
  112. }
  113. me.processed = 1;
  114. }
  115. bool SelectionList::hasStyle(int styleSet, int styleCheck) const
  116. {
  117. return (styleSet | styleCheck) == styleSet;
  118. }
  119. // non-constant
  120. void SelectionList::update() // updates the selection list
  121. {
  122. int rbr = 0;
  123. if (border)
  124. {
  125. rbr = border->getRWidth();
  126. border->setPosition(0, 0);
  127. border->setSize(gr.x, gr.y);
  128. }
  129. if (backgroundFeld)
  130. {
  131. backgroundFeld->setPosition(rbr, rbr);
  132. backgroundFeld->setSize(gr.x - rbr * 2, gr.y - rbr * 2);
  133. }
  134. if (hasStyleNot(Style::MultiStyled) && tfListe)
  135. {
  136. bool FieldBorder = DrawableBackground::hasStyle(Style::FieldBorder);
  137. bool FieldBackground
  138. = DrawableBackground::hasStyle(Style::FieldBackground);
  139. bool FieldHImage = DrawableBackground::hasStyle(Style::FieldBImage);
  140. bool FieldHAlpha = DrawableBackground::hasStyle(Style::FieldBAlpha);
  141. bool FieldBuffer = DrawableBackground::hasStyle(Style::FieldBuffer);
  142. for (TextField* tf : *tfListe)
  143. {
  144. tf->setStyle(TextField::Style::Border, FieldBorder);
  145. tf->setStyle(TextField::Style::Background, FieldBackground);
  146. tf->setStyle(TextField::Style::BImage, FieldHImage);
  147. tf->setStyle(TextField::Style::BAlpha, FieldHAlpha);
  148. tf->setStyle(TextField::Style::Buffered, FieldBuffer);
  149. if (font) tf->setFontZ(dynamic_cast<Font*>(font->getThis()));
  150. }
  151. }
  152. if (DrawableBackground::hasStyle(Style::MultiStyled) && tfListe && styles)
  153. {
  154. auto style = styles->begin();
  155. for (auto tf = tfListe->begin(); tf; tf++, style++)
  156. {
  157. tf->setStyle(
  158. TextField::Style::Border, hasStyle(style, Style::FieldBorder));
  159. tf->setStyle(TextField::Style::Background,
  160. hasStyle(style, Style::FieldBackground));
  161. tf->setStyle(
  162. TextField::Style::BImage, hasStyle(style, Style::FieldBImage));
  163. tf->setStyle(
  164. TextField::Style::BAlpha, hasStyle(style, Style::FieldBAlpha));
  165. tf->setStyle(TextField::Style::Buffered,
  166. hasStyle(style, Style::FieldBuffer));
  167. }
  168. }
  169. rend = 1;
  170. }
  171. void SelectionList::addEntry(Text* txt) // adds an entry
  172. {
  173. TextField* tf = new TextField();
  174. tf->setStyle(TextField::Style::Center | TextField::Style::Visible
  175. | TextField::Style::Border);
  176. tf->setFontColor(0xFFFFFFFF);
  177. tf->setBorderWidth(1);
  178. tf->setBorderColor(0xFFFFFFFF);
  179. tf->setTextZ(txt);
  180. tf->setSize(0, 20);
  181. addEntryZ(tf);
  182. rend = 1;
  183. }
  184. void SelectionList::addEntry(const char* txt)
  185. {
  186. Text* tx = new Text(txt);
  187. addEntry(tx);
  188. rend = 1;
  189. }
  190. void SelectionList::addEntryZ(TextField* tf)
  191. {
  192. if (!tfListe) tfListe = new RCArray<TextField>();
  193. if (font && (!tf->zFont() || hasStyleNot(Style::MultiStyled)))
  194. tf->setFontZ(dynamic_cast<Font*>(font->getThis()));
  195. tfListe->add(tf);
  196. rend = 1;
  197. }
  198. void SelectionList::addEntry(
  199. int pos, Text* txt) // inserts an entry at position pos
  200. {
  201. TextField* tf = new TextField();
  202. tf->setStyle(TextField::Style::Center | TextField::Style::Visible
  203. | TextField::Style::Border);
  204. tf->setFontColor(0xFFFFFFFF);
  205. tf->setBorderWidth(1);
  206. tf->setBorderColor(0xFFFFFFFF);
  207. tf->setTextZ(txt);
  208. tf->setSize(0, 20);
  209. addEntryZ(pos, tf);
  210. rend = 1;
  211. }
  212. void SelectionList::addEntry(int pos, const char* txt)
  213. {
  214. Text* tx = new Text(txt);
  215. addEntry(pos, tx);
  216. rend = 1;
  217. }
  218. void SelectionList::addEntryZ(int pos, TextField* tf)
  219. {
  220. if (!tfListe) tfListe = new RCArray<TextField>();
  221. if (font && (!tf->zFont() || hasStyleNot(Style::MultiStyled)))
  222. tf->setFontZ(dynamic_cast<Font*>(font->getThis()));
  223. tfListe->add(tf, pos);
  224. rend = 1;
  225. }
  226. void SelectionList::setEntry(int pos, Text* txt) // changes the entry at pos
  227. {
  228. TextField* tf = 0;
  229. if (tfListe) tf = tfListe->z(pos);
  230. if (!tf)
  231. {
  232. tf = new TextField();
  233. tf->setStyle(TextField::Style::Center | TextField::Style::Visible
  234. | TextField::Style::Border);
  235. tf->setFontColor(0xFFFFFFFF);
  236. tf->setBorderColor(0xFFFFFFFF);
  237. tf->setBorderWidth(1);
  238. tf->setTextZ(txt);
  239. tf->setSize(0, 20);
  240. setEntryZ(pos, tf);
  241. rend = 1;
  242. return;
  243. }
  244. tf->setTextZ(txt);
  245. rend = 1;
  246. }
  247. void SelectionList::setEntry(int pos, const char* txt)
  248. {
  249. Text* tx = new Text(txt);
  250. setEntry(pos, tx);
  251. rend = 1;
  252. }
  253. void SelectionList::setEntryZ(int pos, TextField* tf)
  254. {
  255. if (!tfListe) tfListe = new RCArray<TextField>();
  256. if (font && (!tf->zFont() || hasStyleNot(Style::MultiStyled)))
  257. tf->setFontZ(dynamic_cast<Font*>(font->getThis()));
  258. tfListe->set(tf, pos);
  259. rend = 1;
  260. }
  261. void SelectionList::swapEntryPos(
  262. int vpos, int npos) // swaps entry vpos with entry npos
  263. {
  264. if (tfListe)
  265. {
  266. tfListe->swap(vpos, npos);
  267. if (styles) styles->swap(vpos, npos);
  268. if (ahColorListe) ahColorListe->swap(vpos, npos);
  269. if (ahImageListe) ahImageListe->swap(vpos, npos);
  270. if (aBufferListe) aBufferListe->swap(vpos, npos);
  271. if (aBorderList) aBorderList->swap(vpos, npos);
  272. rend = 1;
  273. }
  274. }
  275. void Framework::SelectionList::setEntryPos(int vpos, int npos)
  276. {
  277. if (tfListe)
  278. {
  279. tfListe->setPosition(vpos, npos);
  280. if (styles) styles->setPosition(vpos, npos);
  281. if (ahColorListe) ahColorListe->setPosition(vpos, npos);
  282. if (ahImageListe) ahImageListe->setPosition(vpos, npos);
  283. if (aBufferListe) aBufferListe->setPosition(vpos, npos);
  284. if (aBorderList) aBorderList->setPosition(vpos, npos);
  285. rend = 1;
  286. }
  287. }
  288. void SelectionList::removeEntry(int pos) // deletes entry at pos
  289. {
  290. tfListe->remove(pos);
  291. rend = 1;
  292. }
  293. void SelectionList::setFontZ(Font* font) // sets the font for the entries
  294. {
  295. if (this->font) this->font->release();
  296. this->font = font;
  297. rend = 1;
  298. }
  299. void SelectionList::setVScrollToEntry(int entry) // scrolls to entry
  300. {
  301. if (vertikalScrollBar)
  302. {
  303. if (entry > tfListe->getLastIndex()) entry = tfListe->getLastIndex();
  304. int y = 0;
  305. for (int i = 0; i < entry; i++)
  306. y += tfListe->z(i) ? tfListe->z(i)->getHeight() : 0;
  307. vertikalScrollBar->scroll(y);
  308. }
  309. }
  310. void SelectionList::updateVScroll() // scrolls to cursor position or
  311. // down
  312. {
  313. if (vertikalScrollBar)
  314. {
  315. int y = 0;
  316. for (TextField* tf : *tfListe)
  317. y += (TextField*)tf ? tf->getHeight() : 0;
  318. vertikalScrollBar->update(y,
  319. gr.y
  320. - ((border
  321. && DrawableBackground::hasStyle(
  322. TextField::Style::Border))
  323. ? border->getRWidth()
  324. : 0));
  325. }
  326. }
  327. void SelectionList::setSelectionBorderZ(
  328. Border* border) // sets a pointer to the selection border (only without
  329. // MultiStyled)
  330. {
  331. if (aBorder) aBorder->release();
  332. aBorder = border;
  333. rend = 1;
  334. }
  335. void SelectionList::setSelectionBorderWidth(
  336. int br) // sets the width of the selection border (only without MultiStyled)
  337. {
  338. if (!aBorder) aBorder = new LBorder();
  339. aBorder->setBorderWidth(br);
  340. rend = 1;
  341. }
  342. void SelectionList::setSelectionBorderColor(
  343. int fc) // sets the color of the selection border (only without MultiStyled)
  344. {
  345. if (!aBorder) aBorder = new LBorder();
  346. aBorder->setColor(fc);
  347. rend = 1;
  348. }
  349. void SelectionList::setSelectionAFZ(
  350. AlphaField* buffer) // sets a pointer to the selection
  351. // AlphaField (only without MultiStyled)
  352. {
  353. if (aBuffer) aBuffer->release();
  354. aBuffer = buffer;
  355. rend = 1;
  356. }
  357. void SelectionList::setSelectionAFStrength(
  358. int st) // sets the strength of the selection background buffer (only
  359. // without MultiStyled)
  360. {
  361. if (!aBuffer) aBuffer = new AlphaField();
  362. aBuffer->setStrength(st);
  363. rend = 1;
  364. }
  365. void SelectionList::setSelectionAFColor(
  366. int fc) // sets the color of the selection background buffer (only without
  367. // MultiStyled)
  368. {
  369. if (!aBuffer) aBuffer = new AlphaField();
  370. aBuffer->setColor(fc);
  371. rend = 1;
  372. }
  373. void SelectionList::setSelectionBImage(Image*
  374. bild) // sets the selection background image (only without MultiStyled)
  375. {
  376. if (!ahImage) ahImage = new Image();
  377. ahImage->newImage(bild->getWidth(), bild->getHeight(), 0);
  378. int* buff1 = ahImage->getBuffer();
  379. int* buff2 = bild->getBuffer();
  380. for (int i = 0; i < bild->getWidth() * bild->getHeight(); ++i)
  381. buff1[i] = buff2[i];
  382. bild->release();
  383. rend = 1;
  384. }
  385. void SelectionList::setSelectionBColor(
  386. int f) // sets the selection
  387. // background color (only without MultiStyled)
  388. {
  389. ahColor = f;
  390. rend = 1;
  391. }
  392. void SelectionList::setSelectionBImageZ(Image*
  393. 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 SelectionList::setSelectionBorderZ(int pos,
  400. Border* border) // sets a pointer to the selection border (only with
  401. // MultiStyled)
  402. {
  403. if (!aBorderList) aBorderList = new RCArray<Border>();
  404. aBorderList->set(border, pos);
  405. rend = 1;
  406. }
  407. void SelectionList::setSelectionBorderWidth(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)->setBorderWidth(br);
  413. rend = 1;
  414. }
  415. void SelectionList::setSelectionBorderColor(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)->setColor(fc);
  421. rend = 1;
  422. }
  423. void SelectionList::setSelectionAFZ(int pos,
  424. AlphaField* buffer) // sets a pointer to the selection AlphaField (only with
  425. // MultiStyled)
  426. {
  427. if (!aBufferListe) aBufferListe = new RCArray<AlphaField>();
  428. aBufferListe->set(buffer, pos);
  429. rend = 1;
  430. }
  431. void SelectionList::setSelectionAFStrength(
  432. int pos, int st) // sets the strength of the selection background buffer
  433. // (only with MultiStyled)
  434. {
  435. if (!aBufferListe) aBufferListe = new RCArray<AlphaField>();
  436. if (!aBufferListe->z(pos)) aBufferListe->set(new AlphaField(), pos);
  437. aBufferListe->z(pos)->setStrength(st);
  438. rend = 1;
  439. }
  440. void SelectionList::setSelectionAFColor(
  441. int pos, int fc) // sets the color of the selection background buffer
  442. // (only with MultiStyled)
  443. {
  444. if (!aBufferListe) aBufferListe = new RCArray<AlphaField>();
  445. if (!aBufferListe->z(pos)) aBufferListe->set(new AlphaField(), pos);
  446. aBufferListe->z(pos)->setColor(fc);
  447. rend = 1;
  448. }
  449. void SelectionList::setSelectionBImage(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)->newImage(bild->getWidth(), bild->getHeight(), 0);
  455. int* buff1 = ahImageListe->z(pos)->getBuffer();
  456. int* buff2 = bild->getBuffer();
  457. for (int i = 0; i < bild->getWidth() * bild->getHeight(); ++i)
  458. buff1[i] = buff2[i];
  459. bild->release();
  460. rend = 1;
  461. }
  462. void SelectionList::setSelectionBColor(
  463. int pos, int f) // sets the selection background color
  464. // (only with MultiStyled)
  465. {
  466. if (ahColorListe) ahColorListe = new Array<int>();
  467. ahColorListe->set(f, pos);
  468. rend = 1;
  469. }
  470. void SelectionList::setSelectionBImageZ(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 SelectionList::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 SelectionList::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 SelectionList::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 SelectionList::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 SelectionList::doKeyboardEvent(KeyboardEvent& te)
  506. {
  507. bool ntakc = !te.processed;
  508. if (hasStyleNot(Style::Focus) || !tak || te.processed) return;
  509. getThis();
  510. if (tak(takParam, this, te))
  511. {
  512. if (te.id == TE_Press)
  513. {
  514. if (hasStyleNot(Style::MultiSelect))
  515. {
  516. switch (te.virtualKey)
  517. {
  518. case T_Unten:
  519. ++selection;
  520. if (selection > tfListe->getEntryCount())
  521. selection = tfListe->getEntryCount();
  522. rend = 1;
  523. break;
  524. case T_Oben:
  525. --selection;
  526. if (selection < -1) selection = -1;
  527. rend = 1;
  528. break;
  529. }
  530. }
  531. else
  532. {
  533. switch (te.virtualKey)
  534. {
  535. case T_Unten:
  536. deselect();
  537. ++selection;
  538. if (selection > tfListe->getEntryCount())
  539. selection = tfListe->getEntryCount();
  540. if (selection >= 0) addMsStyle(selection, Style::Selected);
  541. rend = 1;
  542. break;
  543. case T_Oben:
  544. deselect();
  545. --selection;
  546. if (selection < -1) selection = -1;
  547. if (selection >= 0) addMsStyle(selection, Style::Selected);
  548. rend = 1;
  549. break;
  550. }
  551. }
  552. }
  553. te.processed = 1;
  554. }
  555. if (ntakc && te.processed && nTak) te.processed = nTak(ntakParam, this, te);
  556. release();
  557. }
  558. void SelectionList::render(Image& zRObj) // draws to zRObj
  559. {
  560. if (!DrawableBackground::hasStyle(Style::Visible)) return;
  561. removeStyle(Style::HScroll);
  562. DrawableBackground::render(zRObj);
  563. lockDrawable();
  564. if (!zRObj.setDrawOptions(innenPosition, innenSize))
  565. {
  566. unlockDrawable();
  567. return;
  568. }
  569. int rbr = 0;
  570. if (border && DrawableBackground::hasStyle(Style::Border))
  571. rbr = border->getRWidth();
  572. if (tfListe)
  573. {
  574. int maxHeight = 0;
  575. int dx = 0, dy = 0;
  576. if (vertikalScrollBar && DrawableBackground::hasStyle(Style::VScroll))
  577. dy -= vertikalScrollBar->getScroll();
  578. int mdy = innenSize.y + rbr;
  579. auto style = styles ? styles->begin() : Array<__int64>().begin();
  580. int i = 0;
  581. for (auto tf = tfListe->begin(); tf; tf++, style++, i++)
  582. {
  583. if (dy + tf->getHeight() > mdy
  584. && !(vertikalScrollBar
  585. && DrawableBackground::hasStyle(Style::VScroll)))
  586. break;
  587. tf->setPosition(dx, dy);
  588. tf->setSize(innenSize.x, tf->getHeight());
  589. maxHeight += tf->getHeight();
  590. bool selected = 0;
  591. if (DrawableBackground::hasStyle(Style::MultiSelect) && styles)
  592. selected = hasStyle(style, Style::Selected);
  593. else
  594. selected = selection == i;
  595. AlphaField* tmpBuffer = 0;
  596. bool tmpB = 0;
  597. int tmpHColor = 0;
  598. bool tmpH = 0;
  599. Image* tmpHImage = 0;
  600. bool tmpHB = 0;
  601. bool tmpHAlpha = 0;
  602. Border* tmpBorder = 0;
  603. bool tmpR = 0;
  604. if (selected)
  605. {
  606. if (hasStyleNot(Style::MultiStyled) || !styles)
  607. {
  608. if (DrawableBackground::hasStyle(Style::SelectionBuffer)
  609. && aBuffer)
  610. {
  611. tmpBuffer = tf->getAlphaField();
  612. tf->setAlphaFieldZ(
  613. dynamic_cast<AlphaField*>(aBuffer->getThis()));
  614. tmpB = tf->hasStyle(TextField::Style::Buffered);
  615. tf->setStyle(TextField::Style::Buffered,
  616. DrawableBackground::hasStyle(
  617. Style::SelectionBuffer));
  618. }
  619. if (DrawableBackground::hasStyle(
  620. Style::SelectionBackground))
  621. {
  622. tmpH = tf->hasStyle(TextField::Style::Background);
  623. tmpHColor = tf->getBackgroundColor();
  624. tf->setBackgroundColor(ahColor);
  625. tf->setStyle(TextField::Style::Background,
  626. DrawableBackground::hasStyle(Style::Background));
  627. if (DrawableBackground::hasStyle(Style::SelectionBImage)
  628. && ahImage)
  629. {
  630. tmpHImage = tf->getBackgroundImage();
  631. tf->setBackgroundImageZ(
  632. dynamic_cast<Image*>(ahImage->getThis()));
  633. tmpHB = tf->hasStyle(TextField::Style::BImage);
  634. tf->setStyle(TextField::Style::BImage,
  635. DrawableBackground::hasStyle(Style::BImage));
  636. }
  637. if (DrawableBackground::hasStyle(
  638. Style::SelectionBAlpha))
  639. {
  640. tmpHAlpha = tf->hasStyle(TextField::Style::BAlpha);
  641. tf->setStyle(TextField::Style::BAlpha,
  642. DrawableBackground::hasStyle(
  643. Style::SelectionBAlpha));
  644. }
  645. }
  646. if (DrawableBackground::hasStyle(Style::SelectionBorder)
  647. && aBorder)
  648. {
  649. tmpBorder = tf->getBorder();
  650. tf->setBorderZ(
  651. dynamic_cast<Border*>(aBorder->getThis()));
  652. tmpR = tf->hasStyle(TextField::Style::Border);
  653. tf->setStyle(TextField::Style::Border,
  654. DrawableBackground::hasStyle(
  655. Style::SelectionBorder));
  656. }
  657. }
  658. else
  659. {
  660. if (hasStyle(style, Style::SelectionBuffer) && aBufferListe)
  661. {
  662. tmpBuffer = tf->getAlphaField();
  663. tf->setAlphaFieldZ(aBufferListe->get(i));
  664. tmpB = tf->hasStyle(TextField::Style::Buffered);
  665. tf->setStyle(TextField::Style::Buffered,
  666. hasStyle(style, Style::SelectionBuffer));
  667. }
  668. if (hasStyle(style, Style::SelectionBackground))
  669. {
  670. tmpH = tf->hasStyle(Style::Background);
  671. tf->setStyle(TextField::Style::Background,
  672. hasStyle(style, Style::SelectionBackground));
  673. if (ahColorListe && ahColorListe->has(i))
  674. {
  675. tmpHColor = tf->getBackgroundColor();
  676. tf->setBackgroundColor(ahColorListe->get(i));
  677. }
  678. if (hasStyle(style, Style::SelectionBImage)
  679. && ahImageListe)
  680. {
  681. tmpHImage = tf->getBackgroundImage();
  682. tf->setBackgroundImageZ(ahImageListe->get(i));
  683. tmpHB = tf->hasStyle(TextField::Style::BImage);
  684. tf->setStyle(TextField::Style::BImage,
  685. hasStyle(style, Style::BImage));
  686. }
  687. if (hasStyle(style, Style::SelectionBAlpha))
  688. {
  689. tmpHAlpha = tf->hasStyle(TextField::Style::BAlpha);
  690. tf->setStyle(TextField::Style::BAlpha,
  691. hasStyle(style, Style::SelectionBAlpha));
  692. }
  693. }
  694. if (hasStyle(style, Style::SelectionBorder) && aBorderList)
  695. {
  696. tmpBorder = tf->getBorder();
  697. tf->setBorderZ(aBorderList->get(i));
  698. tmpR = tf->hasStyle(TextField::Style::Border);
  699. tf->setStyle(TextField::Style::Border,
  700. hasStyle(style, Style::SelectionBorder));
  701. }
  702. }
  703. }
  704. tf->render(zRObj);
  705. if (selected)
  706. {
  707. if (hasStyleNot(Style::MultiStyled) || !styles)
  708. {
  709. if (DrawableBackground::hasStyle(Style::SelectionBuffer))
  710. {
  711. tf->setAlphaFieldZ(tmpBuffer);
  712. tf->setStyle(TextField::Style::Buffered, tmpB);
  713. }
  714. if (DrawableBackground::hasStyle(
  715. Style::SelectionBackground))
  716. {
  717. tf->setBackgroundColor(tmpHColor);
  718. tf->setStyle(TextField::Style::Background, tmpH);
  719. if (DrawableBackground::hasStyle(
  720. Style::SelectionBImage))
  721. {
  722. tf->setBackgroundImageZ(tmpHImage);
  723. tf->setStyle(TextField::Style::BImage, tmpHB);
  724. }
  725. if (DrawableBackground::hasStyle(
  726. Style::SelectionBAlpha))
  727. tf->setStyle(TextField::Style::BAlpha, tmpHAlpha);
  728. }
  729. if (DrawableBackground::hasStyle(Style::SelectionBorder))
  730. {
  731. tf->setBorderZ(tmpBorder);
  732. tf->setStyle(TextField::Style::Border, tmpR);
  733. }
  734. }
  735. else
  736. {
  737. if (hasMsStyle(i, Style::SelectionBuffer) && aBufferListe)
  738. {
  739. tf->setAlphaFieldZ(tmpBuffer);
  740. tf->setStyle(TextField::Style::Buffered, tmpB);
  741. }
  742. if (hasMsStyle(i, Style::SelectionBackground))
  743. {
  744. tf->setStyle(TextField::Style::Background, tmpH);
  745. if (ahColorListe && ahColorListe->has(i))
  746. tf->setBackgroundColor(tmpHColor);
  747. if (hasMsStyle(i, Style::SelectionBImage)
  748. && ahImageListe)
  749. {
  750. tf->setBackgroundImageZ(tmpHImage);
  751. tf->setStyle(TextField::Style::BImage, tmpHB);
  752. }
  753. if (hasMsStyle(i, Style::SelectionBAlpha))
  754. tf->setStyle(TextField::Style::BAlpha, tmpHAlpha);
  755. }
  756. if (hasMsStyle(i, Style::SelectionBorder) && aBorderList)
  757. {
  758. tf->setBorderZ(tmpBorder);
  759. tf->setStyle(TextField::Style::Border, tmpR);
  760. }
  761. }
  762. }
  763. dy += tf->getHeight();
  764. }
  765. if (vertikalScrollBar)
  766. vertikalScrollBar->getScrollData()->max = maxHeight;
  767. }
  768. zRObj.releaseDrawOptions();
  769. unlockDrawable();
  770. }
  771. int SelectionList::getClickEntry(int my)
  772. {
  773. if (!tfListe) return -1;
  774. int y = 0;
  775. if (DrawableBackground::hasStyle(Style::VScroll) && vertikalScrollBar)
  776. y -= vertikalScrollBar->getScroll();
  777. int i = 0;
  778. for (auto tf = tfListe->begin(); tf; tf++, i++)
  779. {
  780. y += tf->getHeight();
  781. if (y > my) return i;
  782. }
  783. return -1;
  784. }
  785. void SelectionList::setSelection(int sel) // sets the selection
  786. {
  787. if (hasStyleNot(Style::MultiSelect))
  788. selection = sel;
  789. else if (styles)
  790. {
  791. for (int i = 0; i < styles->getEntryCount(); ++i)
  792. removeMsStyle(i, Style::Selected);
  793. addMsStyle(sel, Style::Selected);
  794. }
  795. }
  796. void SelectionList::deselect()
  797. {
  798. if (hasStyleNot(Style::MultiSelect))
  799. selection = -1;
  800. else if (styles)
  801. {
  802. for (int i = 0; i < styles->getEntryCount(); ++i)
  803. removeMsStyle(i, Style::Selected);
  804. }
  805. }
  806. // constant
  807. int SelectionList::getEntryCount() const // returns the number of entries
  808. {
  809. return tfListe ? tfListe->getEntryCount() : 0;
  810. }
  811. int SelectionList::getSelection() const // returns the first selected entry
  812. {
  813. return selection;
  814. }
  815. int SelectionList::getEntryPos(
  816. Text* entryText) // 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()->isEqual(entryText->getText()))
  823. {
  824. entryText->release();
  825. return i;
  826. }
  827. }
  828. return -1;
  829. }
  830. TextField* SelectionList::getEntry(
  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* SelectionList::zEntry(int pos) const
  839. {
  840. if (!tfListe) return 0;
  841. return (TextField*)tfListe->z(pos);
  842. }
  843. Border* SelectionList::getSelectionBorder()
  844. const // returns the selection border (without MultiStyled)
  845. {
  846. if (aBorder) return dynamic_cast<Border*>(aBorder->getThis());
  847. return 0;
  848. }
  849. Border* SelectionList::zSelectionBorder() const
  850. {
  851. return aBorder;
  852. }
  853. int SelectionList::getSelectionBColor()
  854. const // returns the selection background color (without MultiStyled)
  855. {
  856. return ahColor;
  857. }
  858. Image* SelectionList::getSelectionBImage()
  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* SelectionList::zSelectionBImage() const
  865. {
  866. return ahImage;
  867. }
  868. AlphaField* SelectionList::getSelectionBuffer()
  869. const // returns the selection buffer (without MultiStyled)
  870. {
  871. if (aBuffer) return dynamic_cast<AlphaField*>(aBuffer->getThis());
  872. return 0;
  873. }
  874. AlphaField* SelectionList::zSelectionBuffer() const
  875. {
  876. return aBuffer;
  877. }
  878. Border* SelectionList::getSelectionBorder(
  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* SelectionList::zSelectionBorder(int pos) const
  887. {
  888. Border* ret = 0;
  889. if (aBorderList) ret = (Border*)aBorderList->z(pos);
  890. return ret;
  891. }
  892. int SelectionList::getSelectionBColor(
  893. int pos) const // returns the selection background color (with MultiStyled)
  894. {
  895. if (ahColorListe && ahColorListe->has(pos)) return ahColorListe->get(pos);
  896. return 0;
  897. }
  898. Image* SelectionList::getSelectionBImage(
  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* SelectionList::zSelectionBImage(int pos) const
  907. {
  908. Image* ret = 0;
  909. if (ahImageListe) ret = (Image*)ahImageListe->z(pos);
  910. return ret;
  911. }
  912. AlphaField* SelectionList::getSelectionBuffer(
  913. int pos) const // returns the selection buffer (with MultiStyled)
  914. {
  915. AlphaField* ret = 0;
  916. if (aBufferListe) ret = (AlphaField*)aBufferListe->get(pos);
  917. if (ret) return dynamic_cast<AlphaField*>(ret->getThis());
  918. return 0;
  919. }
  920. AlphaField* SelectionList::zSelectionBuffer(int pos) const
  921. {
  922. AlphaField* ret = 0;
  923. if (aBufferListe) ret = (AlphaField*)aBufferListe->z(pos);
  924. return ret;
  925. }
  926. bool SelectionList::hasMsStyle(int pos,
  927. __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 SelectionList::hasMsStyleNot(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. DrawableList::DrawableList()
  942. : DrawableBackground()
  943. {
  944. entrySeperatorSize = 1;
  945. entrySeperatorColor = 0xFFFFFFFF;
  946. setBorderWidth(1);
  947. setBorderColor(0xFFFFFFFF);
  948. setBackgroundColor(0xFF000000);
  949. }
  950. //! Destructor
  951. DrawableList::~DrawableList() {}
  952. //! Processes mouse messages
  953. //! \param me The event triggered by the mouse input
  954. void DrawableList::doMouseEvent(MouseEvent& me, bool userRet)
  955. {
  956. if (DrawableBackground::hasStyle(Style::VScroll) && vertikalScrollBar)
  957. {
  958. int rbr = 0;
  959. if (border && DrawableBackground::hasStyle(Style::Border))
  960. rbr = border->getRWidth();
  961. if (((me.mx > gr.x - 15 - rbr) || me.id == ME_UScroll
  962. || me.id == ME_DScroll)
  963. && me.id != ME_Enter && me.id != ME_Leaves)
  964. {
  965. vertikalScrollBar->doMouseMessage(
  966. gr.x - rbr - 15, rbr, 15, gr.y - rbr * 2, me);
  967. me.processed = 1;
  968. }
  969. me.my += vertikalScrollBar->getScroll();
  970. }
  971. me.my -= (border && DrawableBackground::hasStyle(TextField::Style::Border))
  972. ? border->getRWidth() * 2
  973. : 0;
  974. me.mx -= (border && DrawableBackground::hasStyle(TextField::Style::Border))
  975. ? border->getRWidth() * 2
  976. : 0;
  977. int ySum = 0;
  978. int index = 0;
  979. for (Drawable* entry : list)
  980. {
  981. entry->doPublicMouseEvent(me);
  982. ySum += entry->getHeight();
  983. me.my -= entry->getHeight();
  984. if (index < list.getLastIndex())
  985. {
  986. ySum += DrawableBackground::hasStyle(
  987. DrawableList::Style::EntrySeperator)
  988. ? entrySeperatorSize
  989. : 0;
  990. me.my -= DrawableBackground::hasStyle(
  991. DrawableList::Style::EntrySeperator)
  992. ? entrySeperatorSize
  993. : 0;
  994. }
  995. index++;
  996. }
  997. me.my
  998. += ySum
  999. + (border
  1000. && DrawableBackground::hasStyle(TextField::Style::Border))
  1001. ? border->getRWidth() * 2
  1002. : 0;
  1003. me.mx += (border && DrawableBackground::hasStyle(TextField::Style::Border))
  1004. ? border->getRWidth() * 2
  1005. : 0;
  1006. if (DrawableBackground::hasStyle(Style::VScroll) && vertikalScrollBar)
  1007. me.my -= vertikalScrollBar->getScroll();
  1008. }
  1009. //! Adds an entry
  1010. //! \param entry The drawing to add
  1011. void DrawableList::addEntry(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 DrawableList::setEntry(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 DrawableList::swapEntryPos(int vPos, int nPos)
  1028. {
  1029. rend = 1;
  1030. list.swap(vPos, nPos);
  1031. }
  1032. void Framework::DrawableList::setEntryPos(int vpos, int npos)
  1033. {
  1034. list.setPosition(vpos, npos);
  1035. }
  1036. //! Deletes an entry
  1037. //! pos: The index of the entry
  1038. void DrawableList::removeEntry(int pos)
  1039. {
  1040. rend = 1;
  1041. list.remove(pos);
  1042. }
  1043. //! Scrolls to a specific entry
  1044. //! \param entry The index of the entry
  1045. void DrawableList::setVScrollToEntry(int entry)
  1046. {
  1047. if (vertikalScrollBar)
  1048. {
  1049. if (entry > list.getLastIndex()) entry = 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::hasStyle(
  1057. DrawableList::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 DrawableList::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::hasStyle(
  1077. DrawableList::Style::EntrySeperator)
  1078. ? entrySeperatorSize
  1079. : 0;
  1080. index++;
  1081. }
  1082. vertikalScrollBar->update(y,
  1083. gr.y
  1084. - ((border
  1085. && DrawableBackground::hasStyle(
  1086. TextField::Style::Border))
  1087. ? border->getRWidth() * 2
  1088. : 0));
  1089. }
  1090. }
  1091. //! sets the size of the entry seperator
  1092. void DrawableList::setEntrySeperatorSize(int size)
  1093. {
  1094. entrySeperatorSize = size;
  1095. }
  1096. //! sets the color of the entry seperator
  1097. void DrawableList::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 DrawableList::doKeyboardEvent(KeyboardEvent& te)
  1104. {
  1105. for (Drawable* entry : list)
  1106. entry->doKeyboardEvent(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 DrawableList::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 DrawableList::render(Image& rObj)
  1121. {
  1122. DrawableBackground::render(rObj);
  1123. int index = 0;
  1124. int rbr = border && DrawableBackground::hasStyle(TextField::Style::Border)
  1125. ? border->getRWidth()
  1126. : 0;
  1127. bool vs = vertikalScrollBar && hasStyle(Style::VScroll);
  1128. if (rObj.setDrawOptions(pos + Point(rbr, rbr),
  1129. gr - Point(rbr, rbr) * 2 - Point(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::hasStyle(
  1139. DrawableList::Style::EntrySeperator))
  1140. {
  1141. for (int i = 0; i < entrySeperatorSize; i++)
  1142. {
  1143. rObj.drawLineHAlpha(
  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 DrawableList::getClickEntry(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::hasStyle(
  1167. DrawableList::Style::EntrySeperator)
  1168. ? entrySeperatorSize
  1169. : 0;
  1170. index++;
  1171. }
  1172. return -1;
  1173. }
  1174. //! Returns the number of entries
  1175. int DrawableList::getEntryCount() const
  1176. {
  1177. return list.getEntryCount();
  1178. }
  1179. //! Returns the index of an entry
  1180. //! \param zEntry The drawing
  1181. int DrawableList::getEntryPos(Drawable* zEntry)
  1182. {
  1183. int index = 0;
  1184. for (Drawable* entry : list)
  1185. {
  1186. if (zEntry == entry) return index;
  1187. index++;
  1188. }
  1189. return -1;
  1190. }
  1191. //! Returns an entry
  1192. //! \param pos The index of the entry
  1193. Drawable* DrawableList::getEntry(int pos) const
  1194. {
  1195. return list.get(pos);
  1196. }
  1197. //! Returns an entry without increased reference counter
  1198. //! \param pos The index of the entry
  1199. Drawable* DrawableList::zEntry(int pos) const
  1200. {
  1201. return list.get(pos);
  1202. }
  1203. //! Returns the needed height
  1204. int DrawableList::getNeededHeight() const
  1205. {
  1206. int y = (border && DrawableBackground::hasStyle(TextField::Style::Border))
  1207. ? border->getRWidth() * 2
  1208. : 0;
  1209. int index = 0;
  1210. for (Drawable* entry : list)
  1211. {
  1212. y += entry->getHeight();
  1213. if (index < list.getLastIndex())
  1214. y += DrawableBackground::hasStyle(
  1215. DrawableList::Style::EntrySeperator)
  1216. ? entrySeperatorSize
  1217. : 0;
  1218. index++;
  1219. }
  1220. return y;
  1221. }
  1222. //! returns the size of the entry seperator
  1223. int DrawableList::getEntrySeperatorSize() const
  1224. {
  1225. return entrySeperatorSize;
  1226. }
  1227. //! returns the color of the entry seperator
  1228. int DrawableList::getEntrySeperatorColor() const
  1229. {
  1230. return entrySeperatorColor;
  1231. }