SelectionBox.cpp 69 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102
  1. #include "SelectionBox.h"
  2. #include "AlphaField.h"
  3. #include "Border.h"
  4. #include "Button.h"
  5. #include "Font.h"
  6. #include "Image.h"
  7. #include "KeyboardEvent.h"
  8. #include "MouseEvent.h"
  9. #include "Scroll.h"
  10. #include "Text.h"
  11. #include "TextField.h"
  12. #include "ToolTip.h"
  13. using namespace Framework;
  14. // Contents of the SelectionBox class from SelectionBox.h
  15. // Constructor
  16. SelectionBox::SelectionBox()
  17. : DrawableBackground(),
  18. textRd(0),
  19. msStyle(0),
  20. members(new RCArray<TextField>()),
  21. ausfahren(new Button()),
  22. selBorder(new LBorder()),
  23. selBgF(0xFF000000),
  24. selBgB(0),
  25. selAf(new AlphaField()),
  26. msSelBorder(0),
  27. msSelBgF(0),
  28. msSelBgB(0),
  29. msSelAf(0),
  30. mouseBorder(new LBorder()),
  31. mouseBgF(0xFF000000),
  32. mouseBgB(0),
  33. mouseAf(new AlphaField()),
  34. msMouseBorder(0),
  35. msMouseBgF(0),
  36. msMouseBgB(0),
  37. msMouseAf(0),
  38. anzahl(0),
  39. selection(0),
  40. ausgeklappt(0),
  41. ausklappHeight(0),
  42. ausklapMaxHeight(200),
  43. entryHeight(15),
  44. tickval(0),
  45. mouseEntry(0),
  46. scrollAnzeigen(0),
  47. eAkP(0),
  48. eAk(0)
  49. {
  50. vertikalScrollBar = new VScrollBar();
  51. style = Style::Normal;
  52. border = new LBorder();
  53. border->setColor(0xFFFFFFFF);
  54. border->setBorderWidth(1);
  55. ausfahren->setStyle(Button::Style::Visible | Button::Style::Allowed
  56. | Button::Style::ClickBuffer);
  57. ausfahren->setKBColor(0xA0000000);
  58. ausfahren->setKBStrength(10);
  59. ausfahren->setSize(18, 18);
  60. ausfahren->setFontColor(0xFFFFFFFF);
  61. ausfahren->setText("\\/");
  62. selBorder->setColor(0xFF00FF00);
  63. selBorder->setBorderWidth(1);
  64. selAf->setColor(0xA000FF00);
  65. selAf->setStrength(7);
  66. mouseBorder->setColor(0xFF00FF00);
  67. mouseBorder->setBorderWidth(1);
  68. mouseAf->setColor(0x5000FF00);
  69. mouseAf->setStrength(7);
  70. gr.x = 20;
  71. gr.y = 20;
  72. }
  73. // Destructor
  74. SelectionBox::~SelectionBox()
  75. {
  76. if (textRd) textRd->release();
  77. if (msStyle) msStyle->release();
  78. if (members) members->release();
  79. if (ausfahren) ausfahren->release();
  80. if (selBorder) selBorder->release();
  81. if (selBgB) selBgB->release();
  82. if (selAf) selAf->release();
  83. if (msSelBorder) msSelBorder->release();
  84. if (msSelAf) msSelAf->release();
  85. if (msSelBgB) msSelBgB->release();
  86. if (msSelBgF) msSelBgF->release();
  87. if (mouseBorder) mouseBorder->release();
  88. if (mouseAf) mouseAf->release();
  89. if (mouseBgB) mouseBgB->release();
  90. if (msMouseBorder) msMouseBorder->release();
  91. if (msMouseAf) msMouseAf->release();
  92. if (msMouseBgB) msMouseBgB->release();
  93. if (msMouseBgF) msMouseBgF->release();
  94. }
  95. void SelectionBox::doMouseEvent(MouseEvent& me, bool userRet) // mouse events
  96. {
  97. if (hasStyleNot(Style::Allowed) || hasStyleNot(Style::Focus)
  98. || me.processed)
  99. {
  100. ausgeklappt = 0;
  101. me.processed = 1;
  102. return;
  103. }
  104. if (!userRet) return;
  105. mouseEntry = -1;
  106. bool insideParent = me.insideParent;
  107. me.insideParent = me.mx >= 0 && me.mx < gr.x && me.my >= 0
  108. && me.my < gr.y + ausklappHeight;
  109. bool vera = me.processed;
  110. if (ausfahren)
  111. {
  112. int tmpMx = me.mx;
  113. int tmpMy = me.my;
  114. if (me.mx >= 0 && me.my >= 0 && me.mx < gr.x && me.my < gr.y)
  115. me.mx = ausfahren->getX(), me.my = ausfahren->getY() + 1;
  116. ausfahren->doPublicMouseEvent(me);
  117. me.mx = tmpMx, me.my = tmpMy;
  118. }
  119. if (me.processed && !vera && me.id == ME_RLeft)
  120. {
  121. ausgeklappt = !ausgeklappt;
  122. if (ausgeklappt) mouseEntry = selection;
  123. if (scrollAnzeigen) scrollToEntry(mouseEntry);
  124. }
  125. if (hasStyle(Style::VScroll) && vertikalScrollBar && ausgeklappt
  126. && scrollAnzeigen)
  127. {
  128. int rbr = 0;
  129. if (border && hasStyle(Style::Border)) rbr = border->getRWidth();
  130. if ((me.mx > gr.x - 15 - rbr && me.my > gr.y) || me.id == ME_UScroll
  131. || me.id == ME_DScroll)
  132. {
  133. vertikalScrollBar->doMouseMessage(gr.x - rbr - 15,
  134. gr.y,
  135. 15,
  136. vertikalScrollBar->getScrollData()->anzeige,
  137. me);
  138. me.processed = 1;
  139. }
  140. }
  141. if (!me.processed)
  142. {
  143. int eintr = -1;
  144. int tmp = me.my - gr.y
  145. + (vertikalScrollBar ? vertikalScrollBar->getScroll() : 0);
  146. if (hasStyle(Style::MultiStyled))
  147. {
  148. for (int i = 0; i < anzahl; ++i)
  149. {
  150. if (tmp > 0
  151. && tmp < (members->z(i) ? members->z(i)->getHeight() : 0))
  152. {
  153. eintr = i;
  154. break;
  155. }
  156. tmp -= members->z(i) ? members->z(i)->getHeight() : 0;
  157. }
  158. }
  159. else
  160. {
  161. for (int i = 0; i < anzahl; ++i)
  162. {
  163. if (tmp > 0 && tmp < entryHeight)
  164. {
  165. eintr = i;
  166. break;
  167. }
  168. tmp -= entryHeight;
  169. }
  170. }
  171. if (ausgeklappt && me.mx > 0 && me.mx < gr.x && me.my > gr.y
  172. && me.my < gr.y + ausklappHeight)
  173. {
  174. if (eintr >= 0)
  175. {
  176. if (me.id == ME_RLeft)
  177. {
  178. if (selection != eintr) rend = 1;
  179. selection = eintr;
  180. if (eAk) eAk(eAkP, this, 0, selection);
  181. }
  182. if (mouseEntry != eintr) rend = 1;
  183. mouseEntry = eintr;
  184. }
  185. }
  186. }
  187. me.processed = 1;
  188. me.insideParent = insideParent;
  189. }
  190. // non-constant
  191. void SelectionBox::setEventParam(void* p) // set event parameter
  192. {
  193. eAkP = p;
  194. }
  195. void SelectionBox::setEventAktion(
  196. std::function<void(void*, SelectionBox*, int, int)>
  197. event) // set event action
  198. {
  199. this->eAk = event;
  200. }
  201. void SelectionBox::setFontZ(Font* font) // set font
  202. {
  203. if (!this->textRd)
  204. textRd = new TextRenderer(font);
  205. else
  206. textRd->setFontZ(font);
  207. ausfahren->setFontZ(dynamic_cast<Font*>(font->getThis()));
  208. rend = 1;
  209. }
  210. void SelectionBox::setTextRendererZ(TextRenderer* textRd)
  211. {
  212. if (this->textRd) this->textRd->release();
  213. this->textRd = textRd;
  214. }
  215. void SelectionBox::addEntry(const char* txt) // add entry
  216. {
  217. TextField* tf = new TextField();
  218. if (textRd) tf->setFontZ(textRd->getFont());
  219. tf->addStyle(TextField::Style::Visible | TextField::Style::Center
  220. | TextField::Style::Border);
  221. tf->setText(txt);
  222. tf->setFontColor(0xFFFFFFFF);
  223. tf->setBorderColor(0xFFFFFFFF);
  224. tf->setSize(0, entryHeight);
  225. members->add(tf, anzahl);
  226. ++anzahl;
  227. rend = 1;
  228. }
  229. void SelectionBox::addEntry(Text* txt)
  230. {
  231. TextField* tf = new TextField();
  232. if (textRd) tf->setFontZ(textRd->getFont());
  233. tf->addStyle(TextField::Style::Visible | TextField::Style::Center
  234. | TextField::Style::Border);
  235. tf->setText(txt);
  236. tf->setFontColor(0xFFFFFFFF);
  237. tf->setBorderColor(0xFFFFFFFF);
  238. tf->setSize(0, entryHeight);
  239. members->add(tf, anzahl);
  240. ++anzahl;
  241. rend = 1;
  242. }
  243. void SelectionBox::addEntryZ(TextField* txt)
  244. {
  245. members->add(txt, anzahl);
  246. ++anzahl;
  247. rend = 1;
  248. }
  249. void SelectionBox::setEntry(int i, const char* txt) // set entry text
  250. {
  251. if (members->z(i)) members->z(i)->setText(txt);
  252. rend = 1;
  253. }
  254. void SelectionBox::setEntry(int i, Text* txt)
  255. {
  256. if (members->z(i))
  257. members->z(i)->setText(txt);
  258. else
  259. txt->release();
  260. rend = 1;
  261. }
  262. void SelectionBox::setEntryZ(int i, TextField* txt)
  263. {
  264. if (i < anzahl)
  265. members->set(txt, i);
  266. else
  267. txt->release();
  268. rend = 1;
  269. }
  270. void SelectionBox::removeEntry(int i) // remove entry
  271. {
  272. if (i < anzahl)
  273. {
  274. members->remove(i);
  275. if (msStyle) msStyle->remove(i);
  276. if (msSelBorder) msSelBorder->remove(i);
  277. if (msSelBgF) msSelBgF->remove(i);
  278. if (msSelBgB) msSelBgB->remove(i);
  279. if (msSelAf) msSelAf->remove(i);
  280. if (msMouseBorder) msMouseBorder->remove(i);
  281. if (msMouseBgF) msMouseBgF->remove(i);
  282. if (msMouseBgB) msMouseBgB->remove(i);
  283. if (msMouseAf) msMouseAf->remove(i);
  284. if (selection > i) --selection;
  285. if (mouseEntry > i) --mouseEntry;
  286. --anzahl;
  287. rend = 1;
  288. }
  289. }
  290. void SelectionBox::setDropDownButtonZ(Button* ausK) // set expand button
  291. {
  292. if (ausfahren) ausfahren->release();
  293. ausfahren = ausK;
  294. rend = 1;
  295. }
  296. void SelectionBox::setEntryBorderZ(int i, Border* border) // set entry border
  297. {
  298. if (members->z(i))
  299. members->z(i)->setBorderZ(border);
  300. else
  301. border->release();
  302. rend = 1;
  303. }
  304. void SelectionBox::setEntryBorderColor(int i, int f) // set entry border color
  305. {
  306. if (members->z(i)) members->z(i)->setBorderColor(f);
  307. rend = 1;
  308. }
  309. void SelectionBox::setEntryBorderWidth(int i, int rbr) // set entry border width
  310. {
  311. if (members->z(i)) members->z(i)->setBorderWidth(rbr);
  312. rend = 1;
  313. }
  314. void SelectionBox::setEntryBackgroundColor(
  315. int i, int f) // set entry background color
  316. {
  317. if (members->z(i)) members->z(i)->setBackgroundColor(f);
  318. rend = 1;
  319. }
  320. void SelectionBox::setEntryBackgroundImageZ(
  321. int i, Image* bgB) // set entry background image
  322. {
  323. if (members->z(i))
  324. members->z(i)->setBackgroundImageZ(bgB);
  325. else
  326. bgB->release();
  327. rend = 1;
  328. }
  329. void SelectionBox::setEntryBackgroundImage(int i, Image* bgB)
  330. {
  331. if (members->z(i))
  332. members->z(i)->setBackgroundImage(bgB);
  333. else
  334. bgB->release();
  335. rend = 1;
  336. }
  337. void SelectionBox::setEntryAlphaFieldZ(
  338. int i, AlphaField* af) // set entry AlphaField
  339. {
  340. if (members->z(i)) members->z(i)->setAlphaFieldZ(af);
  341. rend = 1;
  342. }
  343. void SelectionBox::setEntryAlphaFieldColor(
  344. int i, int afF) // set entry AlphaField color
  345. {
  346. if (members->z(i)) members->z(i)->setAlphaFieldColor(afF);
  347. rend = 1;
  348. }
  349. void SelectionBox::setEntryAlphaFieldStrength(
  350. int i, int afSt) // set entry AlphaField strength
  351. {
  352. if (members->z(i)) members->z(i)->setAlphaFieldStrength(afSt);
  353. rend = 1;
  354. }
  355. void SelectionBox::setSelBorderZ(Border* border) // set selection border
  356. {
  357. if (selBorder) selBorder->release();
  358. selBorder = border;
  359. rend = 1;
  360. }
  361. void SelectionBox::setSelBorderColor(int f) // set selection border color
  362. {
  363. if (!selBorder) selBorder = new LBorder();
  364. selBorder->setColor(f);
  365. rend = 1;
  366. }
  367. void SelectionBox::setSelBorderWidth(int rbr) // set selection border width
  368. {
  369. if (!selBorder) selBorder = new LBorder();
  370. selBorder->setBorderWidth(rbr);
  371. rend = 1;
  372. }
  373. void SelectionBox::setSelBackgroundColor(
  374. int f) // set selection background color
  375. {
  376. selBgF = f;
  377. rend = 1;
  378. }
  379. void SelectionBox::setSelBackgroundImageZ(
  380. Image* bgB) // set selection background image
  381. {
  382. if (selBgB) selBgB->release();
  383. selBgB = bgB;
  384. rend = 1;
  385. }
  386. void SelectionBox::setSelBackgroundImage(Image* bgB)
  387. {
  388. if (!selBgB) selBgB = new Image();
  389. selBgB->newImage(bgB->getWidth(), bgB->getHeight(), 0);
  390. selBgB->drawImage(0, 0, bgB->getWidth(), bgB->getHeight(), *bgB);
  391. bgB->release();
  392. rend = 1;
  393. }
  394. void SelectionBox::setSelAlphaFieldZ(AlphaField* af) // set selection AlphaField
  395. {
  396. if (selAf) selAf->release();
  397. selAf = af;
  398. rend = 1;
  399. }
  400. void SelectionBox::setSelAlphaFieldColor(
  401. int afF) // set selection AlphaField color
  402. {
  403. if (!selAf) selAf = new AlphaField();
  404. selAf->setColor(afF);
  405. rend = 1;
  406. }
  407. void SelectionBox::setSelAlphaFieldStrength(
  408. int afSt) // set selection AlphaField strength
  409. {
  410. if (!selAf) selAf = new AlphaField();
  411. selAf->setStrength(afSt);
  412. rend = 1;
  413. }
  414. void SelectionBox::setMsSelBorderZ(
  415. int i, Border* border) // set multistyle selection border
  416. {
  417. if (hasStyleNot(Style::MultiStyled) || i >= anzahl)
  418. {
  419. border->release();
  420. return;
  421. }
  422. if (!msSelBorder) msSelBorder = new RCArray<Border>();
  423. msSelBorder->set(border, i);
  424. rend = 1;
  425. }
  426. void SelectionBox::setMsSelBorderColor(
  427. int i, int f) // set multistyle selection border color
  428. {
  429. if (hasStyleNot(Style::MultiStyled) || i >= anzahl) return;
  430. if (!msSelBorder) msSelBorder = new RCArray<Border>();
  431. if (!msSelBorder->z(i)) msSelBorder->set(new LBorder(), i);
  432. msSelBorder->z(i)->setColor(f);
  433. rend = 1;
  434. }
  435. void SelectionBox::setMsSelBorderWidth(
  436. int i, int rbr) // set multistyle selection width
  437. {
  438. if (hasStyleNot(Style::MultiStyled) || i >= anzahl) return;
  439. if (!msSelBorder) msSelBorder = new RCArray<Border>();
  440. if (!msSelBorder->z(i)) msSelBorder->set(new LBorder(), i);
  441. msSelBorder->z(i)->setBorderWidth(rbr);
  442. rend = 1;
  443. }
  444. void SelectionBox::setMsSelBackgroundColor(
  445. int i, int f) // set multistyle selection background color
  446. {
  447. if (hasStyleNot(Style::MultiStyled) || i >= anzahl) return;
  448. if (!msSelBgF) msSelBgF = new Array<int>();
  449. msSelBgF->set(f, i);
  450. rend = 1;
  451. }
  452. void SelectionBox::setMsSelBackgroundImageZ(
  453. int i, Image* bgB) // set multistyle selection background image
  454. {
  455. if (hasStyleNot(Style::MultiStyled) || i >= anzahl)
  456. {
  457. bgB->release();
  458. return;
  459. }
  460. if (!msSelBgB) msSelBgB = new RCArray<Image>();
  461. msSelBgB->set(bgB, i);
  462. rend = 1;
  463. }
  464. void SelectionBox::setMsSelBackgroundImage(int i, Image* bgB)
  465. {
  466. if (hasStyleNot(Style::MultiStyled) || i >= anzahl)
  467. {
  468. bgB->release();
  469. return;
  470. }
  471. if (!msSelBgB) msSelBgB = new RCArray<Image>();
  472. if (!msSelBgB->z(i))
  473. {
  474. Image* z = new Image;
  475. z->newImage(bgB->getWidth(), bgB->getHeight(), 0);
  476. z->drawImage(0, 0, bgB->getWidth(), bgB->getHeight(), *bgB);
  477. msSelBgB->set(z, i);
  478. }
  479. else
  480. {
  481. msSelBgB->z(i)->newImage(bgB->getWidth(), bgB->getHeight(), 0);
  482. msSelBgB->z(i)->drawImage(
  483. 0, 0, bgB->getWidth(), bgB->getHeight(), *bgB);
  484. }
  485. bgB->release();
  486. rend = 1;
  487. }
  488. void SelectionBox::setMsSelAlphaFieldZ(
  489. int i, AlphaField* af) // set multistyle selection AlphaField
  490. {
  491. if (hasStyleNot(Style::MultiStyled) || i >= anzahl)
  492. {
  493. af->release();
  494. return;
  495. }
  496. if (!msSelAf) msSelAf = new RCArray<AlphaField>();
  497. msSelAf->set(af, i);
  498. rend = 1;
  499. }
  500. void SelectionBox::setMsSelAlphaFieldColor(
  501. int i, int afF) // set multistyle selection AlphaField color
  502. {
  503. if (hasStyleNot(Style::MultiStyled) || i >= anzahl) return;
  504. if (!msSelAf) msSelAf = new RCArray<AlphaField>();
  505. if (!msSelAf->z(i)) msSelAf->set(new AlphaField(), i);
  506. msSelAf->z(i)->setColor(afF);
  507. rend = 1;
  508. }
  509. void SelectionBox::setMsSelAlphaFieldStrength(
  510. int i, int afSt) // set multistyle selection AlphaField strength
  511. {
  512. if (hasStyleNot(Style::MultiStyled) || i >= anzahl) return;
  513. if (!msSelAf) msSelAf = new RCArray<AlphaField>();
  514. if (!msSelAf->z(i)) msSelAf->set(new AlphaField(), i);
  515. msSelAf->z(i)->setStrength(afSt);
  516. rend = 1;
  517. }
  518. void SelectionBox::setMouseBorderZ(Border* border) // set mouse border
  519. {
  520. if (mouseBorder) mouseBorder->release();
  521. mouseBorder = border;
  522. rend = 1;
  523. }
  524. void SelectionBox::setMouseBorderColor(int f) // set mouse border color
  525. {
  526. if (!mouseBorder) mouseBorder = new LBorder();
  527. mouseBorder->setColor(f);
  528. rend = 1;
  529. }
  530. void SelectionBox::setMouseBorderWidth(int rbr) // set mouse border width
  531. {
  532. if (!mouseBorder) mouseBorder = new LBorder();
  533. mouseBorder->setBorderWidth(rbr);
  534. rend = 1;
  535. }
  536. void SelectionBox::setMouseBackgroundColor(int f) // set mouse background color
  537. {
  538. mouseBgF = f;
  539. rend = 1;
  540. }
  541. void SelectionBox::setMouseBackgroundImageZ(
  542. Image* bgB) // set mouse background image
  543. {
  544. if (mouseBgB) mouseBgB->release();
  545. mouseBgB = bgB;
  546. rend = 1;
  547. }
  548. void SelectionBox::setMouseBackgroundImage(Image* bgB)
  549. {
  550. if (!mouseBgB) mouseBgB = new Image();
  551. mouseBgB->newImage(bgB->getWidth(), bgB->getHeight(), 0);
  552. mouseBgB->drawImage(0, 0, bgB->getWidth(), bgB->getHeight(), *bgB);
  553. bgB->release();
  554. rend = 1;
  555. }
  556. void SelectionBox::setMouseAlphaFieldZ(AlphaField* af) // set mouse AlphaField
  557. {
  558. if (mouseAf) mouseAf->release();
  559. mouseAf = af;
  560. rend = 1;
  561. }
  562. void SelectionBox::setMouseAlphaFieldColor(
  563. int afF) // set mouse AlphaField color
  564. {
  565. if (!mouseAf) mouseAf = new AlphaField();
  566. mouseAf->setColor(afF);
  567. rend = 1;
  568. }
  569. void SelectionBox::setMouseAlphaFieldStrength(
  570. int afSt) // set mouse AlphaField strength
  571. {
  572. if (!mouseAf) mouseAf = new AlphaField();
  573. mouseAf->setStrength(afSt);
  574. rend = 1;
  575. }
  576. void SelectionBox::setMsMouseBorderZ(
  577. int i, Border* border) // set multistyle mouse border
  578. {
  579. if (hasStyleNot(Style::MultiStyled) || i >= anzahl)
  580. {
  581. border->release();
  582. return;
  583. }
  584. if (!msMouseBorder) msMouseBorder = new RCArray<Border>();
  585. msMouseBorder->set(border, i);
  586. rend = 1;
  587. }
  588. void SelectionBox::setMsMouseBorderColor(
  589. int i, int f) // set multistyle mouse border color
  590. {
  591. if (hasStyleNot(Style::MultiStyled) || i >= anzahl) return;
  592. if (!msMouseBorder) msMouseBorder = new RCArray<Border>();
  593. if (!msMouseBorder->z(i)) msMouseBorder->set(new LBorder(), i);
  594. msMouseBorder->z(i)->setColor(f);
  595. rend = 1;
  596. }
  597. void SelectionBox::setMsMouseBorderWidth(
  598. int i, int rbr) // set multistyle mouse border width
  599. {
  600. if (hasStyleNot(Style::MultiStyled) || i >= anzahl) return;
  601. if (!msMouseBorder) msMouseBorder = new RCArray<Border>();
  602. if (!msMouseBorder->z(i)) msMouseBorder->set(new LBorder(), i);
  603. msMouseBorder->z(i)->setBorderWidth(rbr);
  604. rend = 1;
  605. }
  606. void SelectionBox::setMsMouseBackgroundColor(
  607. int i, int f) // set multistyle mouse background color
  608. {
  609. if (hasStyleNot(Style::MultiStyled) || i >= anzahl) return;
  610. if (!msMouseBgF) msMouseBgF = new Array<int>();
  611. msMouseBgF->set(f, i);
  612. rend = 1;
  613. }
  614. void SelectionBox::setMsMouseBackgroundImageZ(
  615. int i, Image* bgB) // set multistyle mouse background image
  616. {
  617. if (hasStyleNot(Style::MultiStyled) || i >= anzahl)
  618. {
  619. bgB->release();
  620. return;
  621. }
  622. if (!msMouseBgB) msMouseBgB = new RCArray<Image>();
  623. msMouseBgB->set(bgB, i);
  624. rend = 1;
  625. }
  626. void SelectionBox::setMsMouseBackgroundImage(int i, Image* bgB)
  627. {
  628. if (hasStyleNot(Style::MultiStyled) || i >= anzahl)
  629. {
  630. bgB->release();
  631. return;
  632. }
  633. if (!msMouseBgB) msMouseBgB = new RCArray<Image>();
  634. if (!msMouseBgB->z(i))
  635. {
  636. Image* z = new Image;
  637. z->newImage(bgB->getWidth(), bgB->getHeight(), 0);
  638. z->drawImage(0, 0, bgB->getWidth(), bgB->getHeight(), *bgB);
  639. msMouseBgB->set(z, i);
  640. }
  641. else
  642. {
  643. msMouseBgB->z(i)->newImage(bgB->getWidth(), bgB->getHeight(), 0);
  644. msMouseBgB->z(i)->drawImage(
  645. 0, 0, bgB->getWidth(), bgB->getHeight(), *bgB);
  646. }
  647. bgB->release();
  648. rend = 1;
  649. }
  650. void SelectionBox::setMsMouseAlphaFieldZ(
  651. int i, AlphaField* af) // set multistyle mouse AlphaField
  652. {
  653. if (hasStyleNot(Style::MultiStyled) || i >= anzahl)
  654. {
  655. af->release();
  656. return;
  657. }
  658. if (!msMouseAf) msMouseAf = new RCArray<AlphaField>();
  659. msMouseAf->set(af, i);
  660. rend = 1;
  661. }
  662. void SelectionBox::setMsMouseAlphaFieldColor(
  663. int i, int afF) // set multistyle mouse AlphaField color
  664. {
  665. if (hasStyleNot(Style::MultiStyled) || i >= anzahl) return;
  666. if (!msMouseAf) msMouseAf = new RCArray<AlphaField>();
  667. if (!msMouseAf->z(i)) msMouseAf->set(new AlphaField(), i);
  668. msMouseAf->z(i)->setColor(afF);
  669. rend = 1;
  670. }
  671. void SelectionBox::setMsMouseAlphaFieldStrength(
  672. int i, int afSt) // set multistyle mouse AlphaField strength
  673. {
  674. if (hasStyleNot(Style::MultiStyled) || i >= anzahl) return;
  675. if (!msMouseAf) msMouseAf = new RCArray<AlphaField>();
  676. if (!msMouseAf->z(i)) msMouseAf->set(new AlphaField(), i);
  677. msMouseAf->z(i)->setStrength(afSt);
  678. rend = 1;
  679. }
  680. void SelectionBox::setSelection(int i) // select entry
  681. {
  682. if (i < anzahl && i != selection)
  683. {
  684. selection = i;
  685. if (eAk) eAk(eAkP, this, 0, selection);
  686. rend = 1;
  687. }
  688. }
  689. void SelectionBox::expand() // expand list
  690. {
  691. ausgeklappt = 1;
  692. }
  693. void SelectionBox::collapse() // collapse list
  694. {
  695. ausgeklappt = 0;
  696. }
  697. void SelectionBox::scrollToEntry(int i) // scroll list
  698. {
  699. if (hasStyle(Style::VScroll) && vertikalScrollBar && i < anzahl)
  700. {
  701. int scrollPos = 0;
  702. if (hasStyle(Style::MultiStyled))
  703. {
  704. for (int j = 0; j < i; ++j)
  705. scrollPos += members->z(j) ? members->z(j)->getHeight() : 0;
  706. }
  707. else
  708. scrollPos += i * entryHeight;
  709. vertikalScrollBar->scroll(scrollPos);
  710. rend = 1;
  711. }
  712. }
  713. void SelectionBox::setMaxAuskappHeight(
  714. int maxHeight) // height of the list when expanded
  715. {
  716. ausklapMaxHeight = maxHeight;
  717. }
  718. void SelectionBox::setEntryHeight(int height) // sets the height of the entries
  719. {
  720. entryHeight = height;
  721. }
  722. void SelectionBox::addMsStyle(int i, __int64 abStyle) // add multistyle style
  723. {
  724. if (hasStyleNot(Style::MultiStyled) || i >= anzahl) return;
  725. if (!msStyle) msStyle = new Array<__int64>();
  726. msStyle->set(msStyle->get(i) | abStyle, i);
  727. rend = 1;
  728. }
  729. void SelectionBox::setMsStyle(
  730. int i, __int64 abStyle, bool add) // set multistyle style
  731. {
  732. if (hasStyleNot(Style::MultiStyled) || i >= anzahl) return;
  733. if (!msStyle) msStyle = new Array<__int64>();
  734. if (add)
  735. msStyle->set(msStyle->get(i) | abStyle, i);
  736. else
  737. msStyle->set(msStyle->get(i) & ~abStyle, i);
  738. rend = 1;
  739. }
  740. void SelectionBox::setMsStyle(int i, __int64 abStyle)
  741. {
  742. if (hasStyleNot(Style::MultiStyled) || i >= anzahl) return;
  743. if (!msStyle) msStyle = new Array<__int64>();
  744. msStyle->set(abStyle, i);
  745. rend = 1;
  746. }
  747. void SelectionBox::removeMsStyle(
  748. int i, __int64 abStyle) // remove multistyle style
  749. {
  750. if (hasStyleNot(Style::MultiStyled) || i >= anzahl) return;
  751. if (!msStyle) msStyle = new Array<__int64>();
  752. msStyle->set(msStyle->get(i) & ~abStyle, i);
  753. rend = 1;
  754. }
  755. bool SelectionBox::tick(double tickVal) // tick
  756. {
  757. if (ausgeklappt && ausfahren && !ausfahren->zText()->isEqual("/\\"))
  758. {
  759. ausfahren->setText("/\\");
  760. rend = 1;
  761. }
  762. else if (!ausgeklappt && ausfahren && !ausfahren->zText()->isEqual("\\/"))
  763. {
  764. ausfahren->setText("\\/");
  765. rend = 1;
  766. }
  767. if (hasStyleNot(Style::Visible) || hasStyleNot(Style::Allowed))
  768. ausgeklappt = 0;
  769. rend |= ausfahren->tick(tickVal);
  770. this->tickval += tickVal * 300;
  771. int val = (int)this->tickval;
  772. if (val < 1) return DrawableBackground::tick(tickVal);
  773. this->tickval -= val;
  774. int maxHeight = border ? border->getRWidth() : 0;
  775. if (hasStyleNot(Style::MultiStyled))
  776. maxHeight += anzahl * entryHeight;
  777. else
  778. for (int i = 0; i < anzahl; ++i)
  779. maxHeight += members->z(i) ? members->z(i)->getHeight() : 0;
  780. if (maxHeight > ausklapMaxHeight)
  781. {
  782. if (hasStyle(Style::VScroll) && vertikalScrollBar)
  783. {
  784. scrollAnzeigen = 1;
  785. vertikalScrollBar->update(maxHeight, ausklapMaxHeight);
  786. }
  787. maxHeight = ausklapMaxHeight;
  788. }
  789. else
  790. scrollAnzeigen = 0;
  791. if (ausgeklappt)
  792. {
  793. if (ausklappHeight < maxHeight)
  794. {
  795. ausklappHeight += val;
  796. if (ausklappHeight > maxHeight) ausklappHeight = maxHeight;
  797. rend = 1;
  798. }
  799. }
  800. else
  801. {
  802. if (ausklappHeight > 0)
  803. {
  804. ausklappHeight -= val;
  805. if (ausklappHeight < 0) ausklappHeight = 0;
  806. rend = 1;
  807. }
  808. }
  809. for (int i = 0; i < anzahl; ++i)
  810. {
  811. if (i != selection)
  812. rend |= members->z(i)->tick(tickVal);
  813. else
  814. members->z(i)->tick(tickVal);
  815. }
  816. return DrawableBackground::tick(tickVal);
  817. }
  818. void SelectionBox::doKeyboardEvent(KeyboardEvent& te) // Keyboard
  819. {
  820. if (te.processed || hasStyleNot(Style::Focus)
  821. || hasStyleNot(Style::Allowed))
  822. return;
  823. if (te.id == TE_Release)
  824. {
  825. switch (te.virtualKey)
  826. {
  827. case T_Oben:
  828. if (selection > 0)
  829. --selection;
  830. else
  831. selection = anzahl - 1;
  832. if (eAk) eAk(eAkP, this, 0, selection);
  833. scrollToEntry(selection);
  834. rend = 1;
  835. break;
  836. case T_Unten:
  837. if (selection < anzahl - 1)
  838. ++selection;
  839. else
  840. selection = 0;
  841. if (eAk) eAk(eAkP, this, 0, selection);
  842. scrollToEntry(selection);
  843. rend = 1;
  844. break;
  845. }
  846. }
  847. if (te.processed && nTak) te.processed = nTak(ntakParam, this, te);
  848. }
  849. void SelectionBox::render(Image& zRObj) // renders into zRObj
  850. {
  851. if (hasStyle(Style::Visible))
  852. {
  853. rwLock.lockRead();
  854. int br = gr.x;
  855. int hi = gr.y + ausklappHeight;
  856. if ((ausklappHeight
  857. && !zRObj.setDrawOptionsErzwingen(pos.x, pos.y, br, hi))
  858. || (!ausklappHeight && !zRObj.setDrawOptions(pos.x, pos.y, br, hi)))
  859. {
  860. rwLock.unlockRead();
  861. return;
  862. }
  863. int rbr = 0;
  864. if (hasStyle(Style::Border) && border) // Draw border
  865. {
  866. border->setSize(br, hi);
  867. border->render(zRObj);
  868. rbr = border->getRWidth();
  869. }
  870. if ((ausklappHeight
  871. && !zRObj.setDrawOptionsErzwingen(
  872. rbr, rbr, br - rbr * 2, hi - rbr * 2))
  873. || (!ausklappHeight
  874. && !zRObj.setDrawOptions(rbr, rbr, br - rbr * 2, hi - rbr * 2)))
  875. {
  876. zRObj.releaseDrawOptions();
  877. rwLock.unlockRead();
  878. return;
  879. }
  880. if (hasStyle(Style::Background))
  881. {
  882. if (hasStyle(Style::BAlpha))
  883. zRObj.alphaRegion(0, 0, br, hi, backgroundColor);
  884. else
  885. zRObj.fillRegion(0, 0, br, hi, backgroundColor);
  886. if (hasStyle(Style::BImage) && backgroundImage)
  887. {
  888. if (hasStyle(Style::BAlpha))
  889. zRObj.alphaImage(0, 0, br, hi, *backgroundImage);
  890. else
  891. zRObj.drawImage(0, 0, br, hi, *backgroundImage);
  892. }
  893. }
  894. if (hasStyle(Style::Buffered) && backgroundFeld)
  895. {
  896. backgroundFeld->setSize(br - rbr * 2, hi - rbr * 2);
  897. backgroundFeld->render(zRObj);
  898. }
  899. if (ausfahren) // Draw expand button
  900. {
  901. ausfahren->setSize(gr.y - rbr * 2, gr.y - rbr * 2);
  902. ausfahren->setPosition(gr.x - rbr - ausfahren->getWidth(), rbr);
  903. ausfahren->render(zRObj);
  904. }
  905. if (members) // Draw selected text field
  906. {
  907. if (selection < 0)
  908. {
  909. selection = 0;
  910. if (eAk) eAk(eAkP, this, 0, selection);
  911. }
  912. if (selection >= anzahl)
  913. {
  914. selection = anzahl - 1;
  915. if (eAk) eAk(eAkP, this, 0, selection);
  916. }
  917. TextField* tf = selection >= 0 ? members->z(selection) : 0;
  918. if (tf)
  919. {
  920. AlphaField* tmpBuffer = 0;
  921. bool tmpB = 0;
  922. int tmpHColor = 0;
  923. bool tmpH = 0;
  924. Image* tmpHImage = 0;
  925. bool tmpHB = 0;
  926. bool tmpHAlpha = 0;
  927. Border* tmpBorder = 0;
  928. bool tmpR = 0;
  929. if (hasStyleNot(Style::MultiStyled) || !msStyle)
  930. {
  931. if (hasStyle(Style::SelectionBuffer))
  932. {
  933. tmpBuffer = tf->getAlphaField();
  934. tf->setAlphaFieldZ(
  935. dynamic_cast<AlphaField*>(selAf->getThis()));
  936. tmpB = tf->hasStyle(TextField::Style::Buffered);
  937. tf->setStyle(TextField::Style::Buffered,
  938. hasStyle(Style::SelectionBuffer));
  939. }
  940. if (hasStyle(Style::SelectionBackground))
  941. {
  942. tmpH = tf->hasStyle(TextField::Style::Background);
  943. tmpHColor = tf->getBackgroundColor();
  944. tf->setBackgroundColor(selBgF);
  945. tf->setStyle(TextField::Style::Background,
  946. hasStyle(Style::Background));
  947. if (hasStyle(Style::SelectionHImage))
  948. {
  949. tmpHImage = tf->getBackgroundImage();
  950. tf->setBackgroundImageZ(
  951. dynamic_cast<Image*>(selBgB->getThis()));
  952. tmpHB = tf->hasStyle(TextField::Style::BImage);
  953. tf->setStyle(TextField::Style::BImage,
  954. hasStyle(Style::BImage));
  955. }
  956. if (hasStyle(Style::SelectionHAlpha))
  957. {
  958. tmpHAlpha = tf->hasStyle(TextField::Style::BAlpha);
  959. tf->setStyle(TextField::Style::BAlpha,
  960. hasStyle(Style::SelectionHAlpha));
  961. }
  962. }
  963. if (hasStyle(Style::SelectionBorder))
  964. {
  965. tmpBorder = tf->getBorder();
  966. tf->setBorderZ(
  967. dynamic_cast<Border*>(selBorder->getThis()));
  968. tmpR = tf->hasStyle(TextField::Style::Border);
  969. tf->setStyle(TextField::Style::Border,
  970. hasStyle(Style::SelectionBorder));
  971. }
  972. }
  973. else
  974. {
  975. if (hasMsStyle(selection, Style::SelectionBuffer)
  976. && msSelAf)
  977. {
  978. tmpBuffer = tf->getAlphaField();
  979. tf->setAlphaFieldZ(msSelAf->get(selection));
  980. tmpB = tf->hasStyle(TextField::Style::Buffered);
  981. tf->setStyle(TextField::Style::Buffered,
  982. hasMsStyle(selection, Style::SelectionBuffer));
  983. }
  984. if (hasMsStyle(selection, Style::SelectionBackground))
  985. {
  986. tmpH = tf->hasStyle(Style::Background);
  987. tf->setStyle(TextField::Style::Background,
  988. hasMsStyle(selection, Style::SelectionBackground));
  989. if (msSelBgF && msSelBgF->has(selection))
  990. {
  991. tmpHColor = tf->getBackgroundColor();
  992. tf->setBackgroundColor(msSelBgF->get(selection));
  993. }
  994. if (hasMsStyle(selection, Style::SelectionHImage)
  995. && msSelBgB)
  996. {
  997. tmpHImage = tf->getBackgroundImage();
  998. tf->setBackgroundImageZ(msSelBgB->get(selection));
  999. tmpHB = tf->hasStyle(TextField::Style::BImage);
  1000. tf->setStyle(TextField::Style::BImage,
  1001. hasMsStyle(selection, Style::BImage));
  1002. }
  1003. if (hasMsStyle(selection, Style::SelectionHAlpha))
  1004. {
  1005. tmpHAlpha = tf->hasStyle(TextField::Style::BAlpha);
  1006. tf->setStyle(TextField::Style::BAlpha,
  1007. hasMsStyle(selection, Style::SelectionHAlpha));
  1008. }
  1009. }
  1010. if (hasMsStyle(selection, Style::SelectionBorder)
  1011. && msSelBorder)
  1012. {
  1013. tmpBorder = tf->getBorder();
  1014. tf->setBorderZ(msSelBorder->get(selection));
  1015. tmpR = tf->hasStyle(TextField::Style::Border);
  1016. tf->setStyle(TextField::Style::Border,
  1017. hasMsStyle(selection, Style::SelectionBorder));
  1018. }
  1019. }
  1020. int tmpHi = tf->getHeight();
  1021. tf->setPosition(0, 0);
  1022. tf->setSize(
  1023. gr.x - rbr * 2 - (ausfahren ? ausfahren->getWidth() : 0),
  1024. gr.y - rbr * 2);
  1025. tf->render(zRObj);
  1026. tf->setSize(tf->getWidth(), tmpHi);
  1027. if (hasStyleNot(Style::MultiStyled) || !msStyle)
  1028. {
  1029. if (hasStyle(Style::SelectionBuffer))
  1030. {
  1031. tf->setAlphaFieldZ(tmpBuffer);
  1032. tf->setStyle(TextField::Style::Buffered, tmpB);
  1033. }
  1034. if (hasStyle(Style::SelectionBackground))
  1035. {
  1036. tf->setBackgroundColor(tmpHColor);
  1037. tf->setStyle(TextField::Style::Background, tmpH);
  1038. if (hasStyle(Style::SelectionHImage))
  1039. {
  1040. tf->setBackgroundImageZ(tmpHImage);
  1041. tf->setStyle(TextField::Style::BImage, tmpHB);
  1042. }
  1043. if (hasStyle(Style::SelectionHAlpha))
  1044. tf->setStyle(TextField::Style::BAlpha, tmpHAlpha);
  1045. }
  1046. if (hasStyle(Style::SelectionBorder))
  1047. {
  1048. tf->setBorderZ(tmpBorder);
  1049. tf->setStyle(TextField::Style::Border, tmpR);
  1050. }
  1051. }
  1052. else
  1053. {
  1054. if (hasMsStyle(selection, Style::SelectionBuffer)
  1055. && msSelAf)
  1056. {
  1057. tf->setAlphaFieldZ(tmpBuffer);
  1058. tf->setStyle(TextField::Style::Buffered, tmpB);
  1059. }
  1060. if (hasMsStyle(selection, Style::SelectionBackground))
  1061. {
  1062. tf->setStyle(TextField::Style::Background, tmpH);
  1063. if (msSelBgF && msSelBgF->has(selection))
  1064. tf->setBackgroundColor(tmpHColor);
  1065. if (hasMsStyle(selection, Style::SelectionHImage)
  1066. && msSelBgB)
  1067. {
  1068. tf->setBackgroundImageZ(tmpHImage);
  1069. tf->setStyle(TextField::Style::BImage, tmpHB);
  1070. }
  1071. if (hasMsStyle(selection, Style::SelectionHAlpha))
  1072. tf->setStyle(TextField::Style::BAlpha, tmpHAlpha);
  1073. }
  1074. if (hasMsStyle(selection, Style::SelectionBorder)
  1075. && msSelBorder)
  1076. {
  1077. tf->setBorderZ(tmpBorder);
  1078. tf->setStyle(TextField::Style::Border, tmpR);
  1079. }
  1080. }
  1081. }
  1082. }
  1083. bool vsb
  1084. = hasStyle(Style::VScroll) && vertikalScrollBar; // Draw scroll bar
  1085. if (selection >= anzahl)
  1086. {
  1087. selection = 0;
  1088. if (eAk) eAk(eAkP, this, 0, selection);
  1089. }
  1090. if (members)
  1091. {
  1092. if (vsb && ausklappHeight)
  1093. {
  1094. br -= 15;
  1095. vertikalScrollBar->getScrollData()->anzeige
  1096. = ausklappHeight - rbr;
  1097. vertikalScrollBar->render(
  1098. br - rbr, gr.y, 15, ausklappHeight - rbr, zRObj);
  1099. }
  1100. if ((ausklappHeight
  1101. && !zRObj.setDrawOptionsErzwingen(
  1102. 0, gr.y, br - rbr, hi - rbr - gr.y))
  1103. || (!ausklappHeight
  1104. && !zRObj.setDrawOptions(
  1105. 0, gr.y, br - rbr, hi - rbr - gr.y)))
  1106. {
  1107. zRObj.releaseDrawOptions();
  1108. zRObj.releaseDrawOptions();
  1109. rwLock.unlockRead();
  1110. return;
  1111. }
  1112. int maxHeight = 0;
  1113. int dy = 0;
  1114. if (vsb) dy -= vertikalScrollBar->getScroll();
  1115. int mdy = hi - rbr;
  1116. anzahl = members->getEntryCount();
  1117. for (int i = 0; i < anzahl; ++i)
  1118. {
  1119. TextField* tf = members->z(i);
  1120. if (dy >= mdy && !vsb) break;
  1121. tf->setPosition(0, dy);
  1122. tf->setSize(br - rbr * 2, tf->getHeight());
  1123. maxHeight += tf->getHeight();
  1124. bool selected = selection == i;
  1125. AlphaField* tmpBuffer = 0;
  1126. bool tmpB = 0;
  1127. int tmpHColor = 0;
  1128. bool tmpH = 0;
  1129. Image* tmpHImage = 0;
  1130. bool tmpHB = 0;
  1131. bool tmpHAlpha = 0;
  1132. Border* tmpBorder = 0;
  1133. bool tmpR = 0;
  1134. if (selected)
  1135. {
  1136. if (hasStyleNot(Style::MultiStyled) || !msStyle)
  1137. {
  1138. if (hasStyle(Style::SelectionBuffer))
  1139. {
  1140. tmpBuffer = tf->getAlphaField();
  1141. tf->setAlphaFieldZ(
  1142. dynamic_cast<AlphaField*>(selAf->getThis()));
  1143. tmpB = tf->hasStyle(TextField::Style::Buffered);
  1144. tf->setStyle(TextField::Style::Buffered,
  1145. hasStyle(Style::SelectionBuffer));
  1146. }
  1147. if (hasStyle(Style::SelectionBackground))
  1148. {
  1149. tmpH = tf->hasStyle(TextField::Style::Background);
  1150. tmpHColor = tf->getBackgroundColor();
  1151. tf->setBackgroundColor(selBgF);
  1152. tf->setStyle(TextField::Style::Background,
  1153. hasStyle(Style::Background));
  1154. if (hasStyle(Style::SelectionHImage))
  1155. {
  1156. tmpHImage = tf->getBackgroundImage();
  1157. tf->setBackgroundImageZ(
  1158. dynamic_cast<Image*>(selBgB->getThis()));
  1159. tmpHB = tf->hasStyle(TextField::Style::BImage);
  1160. tf->setStyle(TextField::Style::BImage,
  1161. hasStyle(Style::BImage));
  1162. }
  1163. if (hasStyle(Style::SelectionHAlpha))
  1164. {
  1165. tmpHAlpha
  1166. = tf->hasStyle(TextField::Style::BAlpha);
  1167. tf->setStyle(TextField::Style::BAlpha,
  1168. hasStyle(Style::SelectionHAlpha));
  1169. }
  1170. }
  1171. if (hasStyle(Style::SelectionBorder))
  1172. {
  1173. tmpBorder = tf->getBorder();
  1174. tf->setBorderZ(
  1175. dynamic_cast<Border*>(selBorder->getThis()));
  1176. tmpR = tf->hasStyle(TextField::Style::Border);
  1177. tf->setStyle(TextField::Style::Border,
  1178. hasStyle(Style::SelectionBorder));
  1179. }
  1180. }
  1181. else
  1182. {
  1183. if (hasMsStyle(i, Style::SelectionBuffer) && msSelAf)
  1184. {
  1185. tmpBuffer = tf->getAlphaField();
  1186. tf->setAlphaFieldZ(msSelAf->get(i));
  1187. tmpB = tf->hasStyle(TextField::Style::Buffered);
  1188. tf->setStyle(TextField::Style::Buffered,
  1189. hasMsStyle(i, Style::SelectionBuffer));
  1190. }
  1191. if (hasMsStyle(i, Style::SelectionBackground))
  1192. {
  1193. tmpH = tf->hasStyle(Style::Background);
  1194. tf->setStyle(TextField::Style::Background,
  1195. hasMsStyle(i, Style::SelectionBackground));
  1196. if (msSelBgF && msSelBgF->has(i))
  1197. {
  1198. tmpHColor = tf->getBackgroundColor();
  1199. tf->setBackgroundColor(msSelBgF->get(i));
  1200. }
  1201. if (hasMsStyle(i, Style::SelectionHImage)
  1202. && msSelBgB)
  1203. {
  1204. tmpHImage = tf->getBackgroundImage();
  1205. tf->setBackgroundImageZ(msSelBgB->get(i));
  1206. tmpHB = tf->hasStyle(TextField::Style::BImage);
  1207. tf->setStyle(TextField::Style::BImage,
  1208. hasMsStyle(i, Style::BImage));
  1209. }
  1210. if (hasMsStyle(i, Style::SelectionHAlpha))
  1211. {
  1212. tmpHAlpha
  1213. = tf->hasStyle(TextField::Style::BAlpha);
  1214. tf->setStyle(TextField::Style::BAlpha,
  1215. hasMsStyle(i, Style::SelectionHAlpha));
  1216. }
  1217. }
  1218. if (hasMsStyle(i, Style::SelectionBorder)
  1219. && msSelBorder)
  1220. {
  1221. tmpBorder = tf->getBorder();
  1222. tf->setBorderZ(msSelBorder->get(i));
  1223. tmpR = tf->hasStyle(TextField::Style::Border);
  1224. tf->setStyle(TextField::Style::Border,
  1225. hasMsStyle(i, Style::SelectionBorder));
  1226. }
  1227. }
  1228. }
  1229. else if (mouseEntry == i)
  1230. {
  1231. if (hasStyleNot(Style::MultiStyled) || !msStyle)
  1232. {
  1233. if (hasStyle(Style::MouseBuffer))
  1234. {
  1235. tmpBuffer = tf->getAlphaField();
  1236. tf->setAlphaFieldZ(
  1237. dynamic_cast<AlphaField*>(mouseAf->getThis()));
  1238. tmpB = tf->hasStyle(TextField::Style::Buffered);
  1239. tf->setStyle(TextField::Style::Buffered,
  1240. hasStyle(Style::MouseBuffer));
  1241. }
  1242. if (hasStyle(Style::MouseBackground))
  1243. {
  1244. tmpH = tf->hasStyle(TextField::Style::Background);
  1245. tmpHColor = tf->getBackgroundColor();
  1246. tf->setBackgroundColor(mouseBgF);
  1247. tf->setStyle(TextField::Style::Background,
  1248. hasStyle(Style::Background));
  1249. if (hasStyle(Style::MouseHImage))
  1250. {
  1251. tmpHImage = tf->getBackgroundImage();
  1252. tf->setBackgroundImageZ(
  1253. dynamic_cast<Image*>(mouseBgB->getThis()));
  1254. tmpHB = tf->hasStyle(TextField::Style::BImage);
  1255. tf->setStyle(TextField::Style::BImage,
  1256. hasStyle(Style::BImage));
  1257. }
  1258. if (hasStyle(Style::MouseHAlpha))
  1259. {
  1260. tmpHAlpha
  1261. = tf->hasStyle(TextField::Style::BAlpha);
  1262. tf->setStyle(TextField::Style::BAlpha,
  1263. hasStyle(Style::MouseHAlpha));
  1264. }
  1265. }
  1266. if (hasStyle(Style::MouseBorder))
  1267. {
  1268. tmpBorder = tf->getBorder();
  1269. tf->setBorderZ(
  1270. dynamic_cast<Border*>(mouseBorder->getThis()));
  1271. tmpR = tf->hasStyle(TextField::Style::Border);
  1272. tf->setStyle(TextField::Style::Border,
  1273. hasStyle(Style::MouseBorder));
  1274. }
  1275. }
  1276. else
  1277. {
  1278. if (hasMsStyle(i, Style::MouseBuffer) && msSelAf)
  1279. {
  1280. tmpBuffer = tf->getAlphaField();
  1281. tf->setAlphaFieldZ(msMouseAf->get(i));
  1282. tmpB = tf->hasStyle(TextField::Style::Buffered);
  1283. tf->setStyle(TextField::Style::Buffered,
  1284. hasMsStyle(i, Style::MouseBuffer));
  1285. }
  1286. if (hasMsStyle(i, Style::MouseBackground))
  1287. {
  1288. tmpH = tf->hasStyle(Style::Background);
  1289. tf->setStyle(TextField::Style::Background,
  1290. hasMsStyle(i, Style::MouseBackground));
  1291. if (msMouseBgF && msMouseBgF->has(i))
  1292. {
  1293. tmpHColor = tf->getBackgroundColor();
  1294. tf->setBackgroundColor(msMouseBgF->get(i));
  1295. }
  1296. if (hasMsStyle(i, Style::MouseHImage) && msMouseBgB)
  1297. {
  1298. tmpHImage = tf->getBackgroundImage();
  1299. tf->setBackgroundImageZ(msMouseBgB->get(i));
  1300. tmpHB = tf->hasStyle(TextField::Style::BImage);
  1301. tf->setStyle(TextField::Style::BImage,
  1302. hasMsStyle(i, Style::BImage));
  1303. }
  1304. if (hasMsStyle(i, Style::MouseHAlpha))
  1305. {
  1306. tmpHAlpha
  1307. = tf->hasStyle(TextField::Style::BAlpha);
  1308. tf->setStyle(TextField::Style::BAlpha,
  1309. hasMsStyle(i, Style::MouseHAlpha));
  1310. }
  1311. }
  1312. if (hasMsStyle(i, Style::MouseBorder) && msMouseBorder)
  1313. {
  1314. tmpBorder = tf->getBorder();
  1315. tf->setBorderZ(msMouseBorder->get(i));
  1316. tmpR = tf->hasStyle(TextField::Style::Border);
  1317. tf->setStyle(TextField::Style::Border,
  1318. hasMsStyle(i, Style::MouseBorder));
  1319. }
  1320. }
  1321. }
  1322. tf->render(zRObj);
  1323. if (selected)
  1324. {
  1325. if (hasStyleNot(Style::MultiStyled) || !msStyle)
  1326. {
  1327. if (hasStyle(Style::SelectionBuffer))
  1328. {
  1329. tf->setAlphaFieldZ(tmpBuffer);
  1330. tf->setStyle(TextField::Style::Buffered, tmpB);
  1331. }
  1332. if (hasStyle(Style::SelectionBackground))
  1333. {
  1334. tf->setBackgroundColor(tmpHColor);
  1335. tf->setStyle(TextField::Style::Background, tmpH);
  1336. if (hasStyle(Style::SelectionHImage))
  1337. {
  1338. tf->setBackgroundImageZ(tmpHImage);
  1339. tf->setStyle(TextField::Style::BImage, tmpHB);
  1340. }
  1341. if (hasStyle(Style::SelectionHAlpha))
  1342. tf->setStyle(
  1343. TextField::Style::BAlpha, tmpHAlpha);
  1344. }
  1345. if (hasStyle(Style::SelectionBorder))
  1346. {
  1347. tf->setBorderZ(tmpBorder);
  1348. tf->setStyle(TextField::Style::Border, tmpR);
  1349. }
  1350. }
  1351. else
  1352. {
  1353. if (hasMsStyle(i, Style::SelectionBuffer) && msSelAf)
  1354. {
  1355. tf->setAlphaFieldZ(tmpBuffer);
  1356. tf->setStyle(TextField::Style::Buffered, tmpB);
  1357. }
  1358. if (hasMsStyle(i, Style::SelectionBackground))
  1359. {
  1360. tf->setStyle(TextField::Style::Background, tmpH);
  1361. if (msSelBgF && msSelBgF->has(i))
  1362. tf->setBackgroundColor(tmpHColor);
  1363. if (hasMsStyle(i, Style::SelectionHImage)
  1364. && msSelBgB)
  1365. {
  1366. tf->setBackgroundImageZ(tmpHImage);
  1367. tf->setStyle(TextField::Style::BImage, tmpHB);
  1368. }
  1369. if (hasMsStyle(i, Style::SelectionHAlpha))
  1370. tf->setStyle(
  1371. TextField::Style::BAlpha, tmpHAlpha);
  1372. }
  1373. if (hasMsStyle(i, Style::SelectionBorder)
  1374. && msSelBorder)
  1375. {
  1376. tf->setBorderZ(tmpBorder);
  1377. tf->setStyle(TextField::Style::Border, tmpR);
  1378. }
  1379. }
  1380. }
  1381. else if (mouseEntry == i)
  1382. {
  1383. if (hasStyleNot(Style::MultiStyled) || !msStyle)
  1384. {
  1385. if (hasStyle(Style::MouseBuffer))
  1386. {
  1387. tf->setAlphaFieldZ(tmpBuffer);
  1388. tf->setStyle(TextField::Style::Buffered, tmpB);
  1389. }
  1390. if (hasStyle(Style::MouseBackground))
  1391. {
  1392. tf->setBackgroundColor(tmpHColor);
  1393. tf->setStyle(TextField::Style::Background, tmpH);
  1394. if (hasStyle(Style::MouseHImage))
  1395. {
  1396. tf->setBackgroundImageZ(tmpHImage);
  1397. tf->setStyle(TextField::Style::BImage, tmpHB);
  1398. }
  1399. if (hasStyle(Style::MouseHAlpha))
  1400. tf->setStyle(
  1401. TextField::Style::BAlpha, tmpHAlpha);
  1402. }
  1403. if (hasStyle(Style::MouseBorder))
  1404. {
  1405. tf->setBorderZ(tmpBorder);
  1406. tf->setStyle(TextField::Style::Border, tmpR);
  1407. }
  1408. }
  1409. else
  1410. {
  1411. if (hasMsStyle(i, Style::MouseBuffer) && msSelAf)
  1412. {
  1413. tf->setAlphaFieldZ(tmpBuffer);
  1414. tf->setStyle(TextField::Style::Buffered, tmpB);
  1415. }
  1416. if (hasMsStyle(i, Style::MouseBackground))
  1417. {
  1418. tf->setStyle(TextField::Style::Background, tmpH);
  1419. if (msSelBgF && msSelBgF->has(i))
  1420. tf->setBackgroundColor(tmpHColor);
  1421. if (hasMsStyle(i, Style::MouseHImage) && msSelBgB)
  1422. {
  1423. tf->setBackgroundImageZ(tmpHImage);
  1424. tf->setStyle(TextField::Style::BImage, tmpHB);
  1425. }
  1426. if (hasMsStyle(i, Style::MouseHAlpha))
  1427. tf->setStyle(
  1428. TextField::Style::BAlpha, tmpHAlpha);
  1429. }
  1430. if (hasMsStyle(i, Style::MouseBorder) && msSelBorder)
  1431. {
  1432. tf->setBorderZ(tmpBorder);
  1433. tf->setStyle(TextField::Style::Border, tmpR);
  1434. }
  1435. }
  1436. }
  1437. dy += tf->getHeight();
  1438. }
  1439. if (vertikalScrollBar)
  1440. vertikalScrollBar->getScrollData()->max = maxHeight;
  1441. zRObj.releaseDrawOptions();
  1442. }
  1443. zRObj.releaseDrawOptions();
  1444. zRObj.releaseDrawOptions();
  1445. rwLock.unlockRead();
  1446. }
  1447. }
  1448. // constant
  1449. int SelectionBox::getEntryPos(
  1450. const char* txt) const // returns the entry position
  1451. {
  1452. for (int i = 0; i < anzahl; ++i)
  1453. if (members->z(i) && members->z(i)->zText()->isEqual(txt)) return i;
  1454. return -1;
  1455. }
  1456. int SelectionBox::getEntryPos(Text* txt) const
  1457. {
  1458. for (int i = 0; i < anzahl; ++i)
  1459. {
  1460. if (members->z(i) && members->z(i)->zText()->isEqual(txt->getText()))
  1461. {
  1462. txt->release();
  1463. return i;
  1464. }
  1465. }
  1466. txt->release();
  1467. return -1;
  1468. }
  1469. Text* SelectionBox::getEntryText(int i) const // returns the entry text
  1470. {
  1471. if (i >= anzahl) return 0;
  1472. return members->z(i) ? members->z(i)->getText() : 0;
  1473. }
  1474. Text* SelectionBox::zEntryText(int i) const
  1475. {
  1476. if (i >= anzahl) return 0;
  1477. return members->z(i) ? members->z(i)->zText() : 0;
  1478. }
  1479. TextField* SelectionBox::getEntry(int i) const // returns the entry
  1480. {
  1481. if (i >= anzahl) return 0;
  1482. return members->get(i);
  1483. }
  1484. TextField* SelectionBox::zEntry(int i) const
  1485. {
  1486. if (i >= anzahl) return 0;
  1487. return members->z(i);
  1488. }
  1489. int SelectionBox::getSelection()
  1490. const // returns the position of the selected entry
  1491. {
  1492. return selection;
  1493. }
  1494. int SelectionBox::getEntryCount() const // returns the number of entries
  1495. {
  1496. return anzahl;
  1497. }
  1498. bool SelectionBox::isExpanded() const // checks if the list is expanded
  1499. {
  1500. return ausgeklappt;
  1501. }
  1502. int SelectionBox::getMaxHeight() const // returns the maximum list height
  1503. {
  1504. if (!hasStyle(Style::MaxHeight)) return 0;
  1505. return ausklapMaxHeight;
  1506. }
  1507. int SelectionBox::getEntryHeight() const // returns the height of the entries
  1508. {
  1509. return entryHeight;
  1510. }
  1511. Button*
  1512. SelectionBox::getDropDownButton() const // returns the expand/collapse button
  1513. {
  1514. if (hasStyle(Style::MultiStyled)) return 0;
  1515. return ausfahren ? dynamic_cast<Button*>(ausfahren->getThis()) : 0;
  1516. }
  1517. Button* SelectionBox::zDropDownButton() const
  1518. {
  1519. if (hasStyle(Style::MultiStyled)) return 0;
  1520. return ausfahren;
  1521. }
  1522. Border* SelectionBox::getEntryBorder(int i) const // returns the entry border
  1523. {
  1524. if (!hasStyle(Style::MultiStyled)) return 0;
  1525. if (!members->z(i)) return 0;
  1526. return members->z(i)->getBorder();
  1527. }
  1528. Border* SelectionBox::zEntryBorder(int i) const
  1529. {
  1530. if (!hasStyle(Style::MultiStyled)) return 0;
  1531. if (!members->z(i)) return 0;
  1532. return members->z(i)->zBorder();
  1533. }
  1534. int SelectionBox::getEntryBorderColor(
  1535. int i) const // returns the entry border color
  1536. {
  1537. if (!hasStyle(Style::MultiStyled)) return 0;
  1538. if (!members->z(i)) return 0;
  1539. return members->z(i)->getBorderColor();
  1540. }
  1541. int SelectionBox::getEntryBorderWidth(
  1542. int i) const // returns the entry border width
  1543. {
  1544. if (!hasStyle(Style::MultiStyled)) return 0;
  1545. if (!members->z(i)) return 0;
  1546. return members->z(i)->getBorderWidth();
  1547. }
  1548. AlphaField* SelectionBox::getEntryAlphaField(
  1549. int i) const // returns the entry AlphaField
  1550. {
  1551. if (!hasStyle(Style::MultiStyled)) return 0;
  1552. if (!members->z(i)) return 0;
  1553. return members->z(i)->getAlphaField();
  1554. }
  1555. AlphaField* SelectionBox::zEntryAlphaField(int i) const
  1556. {
  1557. if (!hasStyle(Style::MultiStyled)) return 0;
  1558. if (!members->z(i)) return 0;
  1559. return members->z(i)->zAlphaField();
  1560. }
  1561. int SelectionBox::getEntryAlphaFieldColor(
  1562. int i) const // returns the entry AlphaField color
  1563. {
  1564. if (!hasStyle(Style::MultiStyled)) return 0;
  1565. if (!members->z(i)) return 0;
  1566. return members->z(i)->getAlphaFieldColor();
  1567. }
  1568. int SelectionBox::getEntryAlphaFieldStrength(
  1569. int i) const // returns the entry AlphaField strength
  1570. {
  1571. if (!hasStyle(Style::MultiStyled)) return 0;
  1572. if (!members->z(i)) return 0;
  1573. return members->z(i)->getAlphaFieldStrength();
  1574. }
  1575. int SelectionBox::getEntryBackgroundColor(
  1576. int i) const // returns the entry background color
  1577. {
  1578. if (!hasStyle(Style::MultiStyled)) return 0;
  1579. if (!members->z(i)) return 0;
  1580. return members->z(i)->getBackgroundColor();
  1581. }
  1582. Image* SelectionBox::getEntryBackgroundImage(
  1583. int i) const // returns the entry background image
  1584. {
  1585. if (!hasStyle(Style::MultiStyled)) return 0;
  1586. if (!members->z(i)) return 0;
  1587. return members->z(i)->getBackgroundImage();
  1588. }
  1589. Image* SelectionBox::zEntryBackgroundImage(int i) const
  1590. {
  1591. if (!hasStyle(Style::MultiStyled)) return 0;
  1592. if (!members->z(i)) return 0;
  1593. return members->z(i)->zBackgroundImage();
  1594. }
  1595. Border* SelectionBox::getSelBorder() const // returns the selection border
  1596. {
  1597. if (hasStyle(Style::MultiStyled)) return 0;
  1598. return selBorder ? dynamic_cast<Border*>(selBorder->getThis()) : 0;
  1599. }
  1600. Border* SelectionBox::zSelBorder() const
  1601. {
  1602. if (hasStyle(Style::MultiStyled)) return 0;
  1603. return selBorder;
  1604. }
  1605. int SelectionBox::getSelBorderColor()
  1606. const // returns the selection border color
  1607. {
  1608. if (hasStyle(Style::MultiStyled)) return 0;
  1609. return selBorder ? selBorder->getColor() : 0;
  1610. }
  1611. int SelectionBox::getSelBorderWidth()
  1612. const // returns the selection border width
  1613. {
  1614. if (hasStyle(Style::MultiStyled)) return 0;
  1615. return selBorder ? selBorder->getRWidth() : 0;
  1616. }
  1617. AlphaField*
  1618. SelectionBox::getSelAlphaField() const // returns the selection AlphaField
  1619. {
  1620. if (hasStyle(Style::MultiStyled)) return 0;
  1621. return selAf ? dynamic_cast<AlphaField*>(selAf->getThis()) : 0;
  1622. }
  1623. AlphaField* SelectionBox::zSelAlphaField() const
  1624. {
  1625. if (hasStyle(Style::MultiStyled)) return 0;
  1626. return selAf;
  1627. }
  1628. int SelectionBox::getSelAlphaFieldColor()
  1629. const // returns the selection AlphaField color
  1630. {
  1631. if (hasStyle(Style::MultiStyled)) return 0;
  1632. return selAf ? selAf->getColor() : 0;
  1633. }
  1634. int SelectionBox::getSelAlphaFieldStrength()
  1635. const // returns the selection AlphaField strength
  1636. {
  1637. if (hasStyle(Style::MultiStyled)) return 0;
  1638. return selAf ? selAf->getStrength() : 0;
  1639. }
  1640. int SelectionBox::getSelBackgroundColor()
  1641. const // returns the selection background color
  1642. {
  1643. if (hasStyle(Style::MultiStyled)) return 0;
  1644. return selBgF;
  1645. }
  1646. Image* SelectionBox::getSelBackgroundImage()
  1647. const // returns the selection background image
  1648. {
  1649. if (hasStyle(Style::MultiStyled)) return 0;
  1650. return selBgB ? dynamic_cast<Image*>(selBgB->getThis()) : 0;
  1651. }
  1652. Image* SelectionBox::zSelBackgroundImage() const
  1653. {
  1654. if (hasStyle(Style::MultiStyled)) return 0;
  1655. return selBgB;
  1656. }
  1657. Border* SelectionBox::getMsSelBorder(
  1658. int i) const // returns the multistyle selection border
  1659. {
  1660. if (!hasStyle(Style::MultiStyled)) return 0;
  1661. if (!msSelBorder) return 0;
  1662. return msSelBorder->z(i)
  1663. ? dynamic_cast<Border*>(msSelBorder->z(i)->getThis())
  1664. : 0;
  1665. }
  1666. Border* SelectionBox::zMsSelBorder(int i) const
  1667. {
  1668. if (!hasStyle(Style::MultiStyled)) return 0;
  1669. if (!msSelBorder) return 0;
  1670. return msSelBorder->z(i);
  1671. }
  1672. int SelectionBox::getMsSelBorderColor(
  1673. int i) const // returns the multistyle selection border color
  1674. {
  1675. if (!hasStyle(Style::MultiStyled)) return 0;
  1676. if (!msSelBorder) return 0;
  1677. return msSelBorder->z(i) ? msSelBorder->z(i)->getColor() : 0;
  1678. }
  1679. int SelectionBox::getMsSelBorderWidth(
  1680. int i) const // returns the multistyle selection border width
  1681. {
  1682. if (!hasStyle(Style::MultiStyled)) return 0;
  1683. if (!msSelBorder) return 0;
  1684. return msSelBorder->z(i) ? msSelBorder->z(i)->getRWidth() : 0;
  1685. }
  1686. AlphaField* SelectionBox::getMsSelAlphaField(
  1687. int i) const // returns the multistyle selection AlphaField
  1688. {
  1689. if (!hasStyle(Style::MultiStyled)) return 0;
  1690. if (!msSelAf) return 0;
  1691. return msSelAf->z(i) ? dynamic_cast<AlphaField*>(msSelAf->z(i)->getThis())
  1692. : 0;
  1693. }
  1694. AlphaField* SelectionBox::zMsSelAlphaField(int i) const
  1695. {
  1696. if (!hasStyle(Style::MultiStyled)) return 0;
  1697. if (!msSelAf) return 0;
  1698. return msSelAf->z(i);
  1699. }
  1700. int SelectionBox::getMsSelAlphaFieldColor(
  1701. int i) const // returns the multistyle selection AlphaField color
  1702. {
  1703. if (!hasStyle(Style::MultiStyled)) return 0;
  1704. if (!msSelAf) return 0;
  1705. return msSelAf->z(i) ? msSelAf->z(i)->getColor() : 0;
  1706. }
  1707. int SelectionBox::getMsSelAlphaFieldStrength(
  1708. int i) const // returns the multistyle selection AlphaField strength
  1709. {
  1710. if (!hasStyle(Style::MultiStyled)) return 0;
  1711. if (!msSelAf) return 0;
  1712. return msSelAf->z(i) ? msSelAf->z(i)->getStrength() : 0;
  1713. }
  1714. int SelectionBox::getMsSelBackgroundColor(
  1715. int i) const // returns the multistyle selection background color
  1716. {
  1717. if (!hasStyle(Style::MultiStyled)) return 0;
  1718. if (!msSelBgF || !msSelBgF->has(i)) return 0;
  1719. return msSelBgF->get(i);
  1720. }
  1721. Image* SelectionBox::getMsSelBackgroundImage(
  1722. int i) const // returns the multistyle selection background image
  1723. {
  1724. if (!hasStyle(Style::MultiStyled)) return 0;
  1725. if (!msSelBgB) return 0;
  1726. return msSelBgB->get(i);
  1727. }
  1728. Image* SelectionBox::zMsSelBackgroundImage(int i) const
  1729. {
  1730. if (!hasStyle(Style::MultiStyled)) return 0;
  1731. if (!msSelBgB) return 0;
  1732. return msSelBgB->z(i);
  1733. }
  1734. Border* SelectionBox::getMouseBorder() const // returns the mouse border
  1735. {
  1736. if (hasStyle(Style::MultiStyled)) return 0;
  1737. return mouseBorder ? dynamic_cast<Border*>(mouseBorder->getThis()) : 0;
  1738. }
  1739. Border* SelectionBox::zMouseBorder() const
  1740. {
  1741. if (hasStyle(Style::MultiStyled)) return 0;
  1742. return mouseBorder;
  1743. }
  1744. int SelectionBox::getMouseBorderColor() const // returns the mouse border color
  1745. {
  1746. if (hasStyle(Style::MultiStyled)) return 0;
  1747. return mouseBorder ? mouseBorder->getColor() : 0;
  1748. }
  1749. int SelectionBox::getMouseBorderWidth() const // returns the mouse border width
  1750. {
  1751. if (hasStyle(Style::MultiStyled)) return 0;
  1752. return mouseBorder ? mouseBorder->getRWidth() : 0;
  1753. }
  1754. AlphaField*
  1755. SelectionBox::getMouseAlphaField() const // returns the mouse AlphaField
  1756. {
  1757. if (hasStyle(Style::MultiStyled)) return 0;
  1758. return mouseAf ? dynamic_cast<AlphaField*>(mouseAf->getThis()) : 0;
  1759. }
  1760. AlphaField* SelectionBox::zMouseAlphaField() const
  1761. {
  1762. if (hasStyle(Style::MultiStyled)) return 0;
  1763. return mouseAf;
  1764. }
  1765. int SelectionBox::getMouseAlphaFieldColor()
  1766. const // returns the mouse AlphaField color
  1767. {
  1768. if (hasStyle(Style::MultiStyled)) return 0;
  1769. return mouseAf ? mouseAf->getColor() : 0;
  1770. }
  1771. int SelectionBox::getMouseAlphaFieldStrength()
  1772. const // returns the mouse AlphaField strength
  1773. {
  1774. if (hasStyle(Style::MultiStyled)) return 0;
  1775. return mouseAf ? mouseAf->getStrength() : 0;
  1776. }
  1777. int SelectionBox::getMouseBackgroundColor()
  1778. const // returns the mouse background color
  1779. {
  1780. if (hasStyle(Style::MultiStyled)) return 0;
  1781. return mouseBgF;
  1782. }
  1783. Image* SelectionBox::getMouseBackgroundImage()
  1784. const // returns the mouse background image
  1785. {
  1786. if (hasStyle(Style::MultiStyled)) return 0;
  1787. return mouseBgB ? dynamic_cast<Image*>(mouseBgB->getThis()) : 0;
  1788. }
  1789. Image* SelectionBox::zMouseBackgroundImage() const
  1790. {
  1791. if (hasStyle(Style::MultiStyled)) return 0;
  1792. return mouseBgB;
  1793. }
  1794. Border* SelectionBox::getMsMouseBorder(
  1795. int i) const // returns the multistyle mouse border
  1796. {
  1797. if (!hasStyle(Style::MultiStyled)) return 0;
  1798. if (!msMouseBorder) return 0;
  1799. return msMouseBorder->get(i);
  1800. }
  1801. Border* SelectionBox::zMsMouseBorder(int i) const
  1802. {
  1803. if (!hasStyle(Style::MultiStyled)) return 0;
  1804. if (!msMouseBorder) return 0;
  1805. return msMouseBorder->z(i);
  1806. }
  1807. int SelectionBox::getMsMouseBorderColor(
  1808. int i) const // returns the multistyle mouse border color
  1809. {
  1810. if (!hasStyle(Style::MultiStyled)) return 0;
  1811. if (!msMouseBorder) return 0;
  1812. return msMouseBorder->z(i) ? msMouseBorder->z(i)->getColor() : 0;
  1813. }
  1814. int SelectionBox::getMsMouseBorderWidth(
  1815. int i) const // returns the multistyle mouse border width
  1816. {
  1817. if (!hasStyle(Style::MultiStyled)) return 0;
  1818. if (!msMouseBorder) return 0;
  1819. return msMouseBorder->z(i) ? msMouseBorder->z(i)->getRWidth() : 0;
  1820. }
  1821. AlphaField* SelectionBox::getMsMouseAlphaField(
  1822. int i) const // returns the multistyle mouse AlphaField
  1823. {
  1824. if (!hasStyle(Style::MultiStyled)) return 0;
  1825. if (!msMouseAf) return 0;
  1826. return msMouseAf->get(i);
  1827. }
  1828. AlphaField* SelectionBox::zMsMouseAlphaField(int i) const
  1829. {
  1830. if (!hasStyle(Style::MultiStyled)) return 0;
  1831. if (!msMouseAf) return 0;
  1832. return msMouseAf->z(i);
  1833. }
  1834. int SelectionBox::getMsMouseAlphaFieldColor(
  1835. int i) const // returns the multistyle mouse AlphaField color
  1836. {
  1837. if (!hasStyle(Style::MultiStyled)) return 0;
  1838. if (!msMouseAf) return 0;
  1839. return msMouseAf->z(i) ? msMouseAf->z(i)->getColor() : 0;
  1840. }
  1841. int SelectionBox::getMsMouseAlphaFieldStrength(
  1842. int i) const // returns the multistyle mouse AlphaField strength
  1843. {
  1844. if (!hasStyle(Style::MultiStyled)) return 0;
  1845. if (!msMouseAf) return 0;
  1846. return msMouseAf->z(i) ? msMouseAf->z(i)->getStrength() : 0;
  1847. }
  1848. int SelectionBox::getMsMouseBackgroundColor(
  1849. int i) const // returns the multistyle mouse background color
  1850. {
  1851. if (!hasStyle(Style::MultiStyled)) return 0;
  1852. if (!msMouseBgF || !msMouseBgF->has(i)) return 0;
  1853. return msMouseBgF->get(i);
  1854. }
  1855. Image* SelectionBox::getMsMouseBackgroundImage(
  1856. int i) const // returns the multistyle mouse background image
  1857. {
  1858. if (!hasStyle(Style::MultiStyled)) return 0;
  1859. if (!msMouseBgB) return 0;
  1860. return msMouseBgB->get(i);
  1861. }
  1862. Image* SelectionBox::zMsMouseBackgroundImage(int i) const
  1863. {
  1864. if (!hasStyle(Style::MultiStyled)) return 0;
  1865. if (!msMouseBgB) return 0;
  1866. return msMouseBgB->z(i);
  1867. }
  1868. // Checks if a point is inside this object
  1869. // x: the x coordinate of the point
  1870. // y: the y coordinate of the point
  1871. // return: 1 if the point is inside, 0 otherwise
  1872. bool SelectionBox::isPointInside(int x, int y) const
  1873. {
  1874. return x >= pos.x && x < pos.x + gr.x && y >= pos.y
  1875. && y < pos.y + gr.y + ausklappHeight;
  1876. }
  1877. bool SelectionBox::hasMsStyle(
  1878. int i, __int64 abStyle) const // checks if multistyle style is present
  1879. {
  1880. if ((style | Style::MultiStyled) != style || !msStyle || !msStyle->has(i))
  1881. return 0;
  1882. return (msStyle->get(i) | abStyle) == msStyle->get(i);
  1883. }
  1884. bool SelectionBox::hasMsStyleNot(
  1885. int i, __int64 abStyle) const // checks if multistyle style is not present
  1886. {
  1887. if ((style | Style::MultiStyled) != style || !msStyle || !msStyle->has(i))
  1888. return 1;
  1889. return (msStyle->get(i) | abStyle) != msStyle->get(i);
  1890. }
  1891. Drawable* SelectionBox::duplicate() const // Creates a copy of the drawing
  1892. {
  1893. SelectionBox* obj = new SelectionBox();
  1894. obj->setPosition(pos);
  1895. obj->setSize(gr);
  1896. obj->setMouseEventParameter(makParam);
  1897. obj->setKeyboardEventParameter(takParam);
  1898. obj->setMouseEvent(mak);
  1899. obj->setKeyboardEvent(tak);
  1900. if (toolTip) obj->setToolTipZ((ToolTip*)toolTip->duplicate());
  1901. obj->setStyle(style);
  1902. if (textRd)
  1903. obj->setTextRendererZ(dynamic_cast<TextRenderer*>(textRd->getThis()));
  1904. if (border) obj->setBorderZ((Border*)border->duplicate());
  1905. if (ausfahren) obj->setDropDownButtonZ((Button*)ausfahren->duplicate());
  1906. obj->setBackgroundColor(backgroundColor);
  1907. if (backgroundImage)
  1908. obj->setBackgroundImage(
  1909. dynamic_cast<Image*>(backgroundImage->getThis()));
  1910. if (backgroundFeld)
  1911. obj->setAlphaFieldZ((AlphaField*)backgroundFeld->duplicate());
  1912. if (selBorder) obj->setSelBorderZ((Border*)selBorder->duplicate());
  1913. obj->setSelBackgroundColor(selBgF);
  1914. if (selBgB)
  1915. obj->setSelBackgroundImage(dynamic_cast<Image*>(selBgB->getThis()));
  1916. if (selAf) obj->setSelAlphaFieldZ((AlphaField*)selAf->duplicate());
  1917. if (mouseBorder) obj->setMouseBorderZ((Border*)mouseBorder->duplicate());
  1918. obj->setMouseBackgroundColor(mouseBgF);
  1919. if (mouseBgB)
  1920. obj->setMouseBackgroundImage(dynamic_cast<Image*>(mouseBgB->getThis()));
  1921. if (mouseAf) obj->setMouseAlphaFieldZ((AlphaField*)mouseAf->duplicate());
  1922. obj->setMaxAuskappHeight(ausklapMaxHeight);
  1923. obj->setEntryHeight(entryHeight);
  1924. for (int i = 0; i < anzahl; ++i)
  1925. {
  1926. if (members->z(i))
  1927. {
  1928. obj->addEntry("a");
  1929. obj->setEntryZ(i, (TextField*)members->z(i)->duplicate());
  1930. if (msStyle && msStyle->has(i)) obj->setMsStyle(i, msStyle->get(i));
  1931. if (msSelBorder && msSelBorder->z(i))
  1932. obj->setMsSelBorderZ(
  1933. i, (Border*)msSelBorder->z(i)->duplicate());
  1934. if (msSelBgF && msSelBgF->has(i))
  1935. obj->setMsSelBackgroundColor(i, msSelBgF->get(i));
  1936. if (msSelBgB && msSelBgB->z(i))
  1937. obj->setMsSelBackgroundImage(i, msSelBgB->get(i));
  1938. if (msSelAf && msSelAf->z(i))
  1939. obj->setMsSelAlphaFieldZ(
  1940. i, (AlphaField*)msSelAf->z(i)->duplicate());
  1941. if (msMouseBorder && msMouseBorder->z(i))
  1942. obj->setMsMouseBorderZ(
  1943. i, (Border*)msMouseBorder->z(i)->duplicate());
  1944. if (msMouseBgF && msMouseBgF->has(i))
  1945. obj->setMsMouseBackgroundColor(i, msMouseBgF->get(i));
  1946. if (msMouseBgB && msMouseBgB->z(i))
  1947. obj->setMsMouseBackgroundImage(i, msMouseBgB->get(i));
  1948. if (msMouseAf && msMouseAf->z(i))
  1949. obj->setMsMouseAlphaFieldZ(
  1950. i, (AlphaField*)msMouseAf->z(i)->duplicate());
  1951. }
  1952. }
  1953. obj->setAlphaFieldColor(selection);
  1954. return obj;
  1955. }