Table.cpp 46 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643
  1. #include "Table.h"
  2. #include "AlphaField.h"
  3. #include "Border.h"
  4. #include "Image.h"
  5. #include "KeyboardEvent.h"
  6. #include "MouseEvent.h"
  7. #include "Scroll.h"
  8. #include "Text.h"
  9. #include "ToolTip.h"
  10. using namespace Framework;
  11. // Contents of the ObjTable class from Table.h
  12. // Constructor
  13. ObjTable::ObjTable()
  14. : DrawableBackground(),
  15. members(new RCArray<RCArray<Drawable>>()),
  16. spaltenNamen(new RCArray<Text>()),
  17. zeilenNamen(new RCArray<Text>()),
  18. columnWidth(new Array<int>()),
  19. zeilenHeight(new Array<int>()),
  20. minSpaltenWidth(new Array<int>()),
  21. maxSpaltenWidth(new Array<int>()),
  22. minZeilenHeight(new Array<int>()),
  23. maxZeilenHeight(new Array<int>()),
  24. spaltenAnzahl(0),
  25. zeilenAnzahl(0),
  26. klickSpalte(-1),
  27. klickZeile(-1),
  28. mSpalte(-1),
  29. mZeile(-1),
  30. mx(0),
  31. my(0),
  32. selected(-1, -1),
  33. rasterColor(0xFF000000),
  34. gridWidth(1),
  35. aRam(0),
  36. aAf(0),
  37. msaRam(new RCArray<RCArray<Border>>()),
  38. msaAf(new RCArray<RCArray<AlphaField>>()),
  39. styles(new RCArray<Array<__int64>>())
  40. {
  41. style = Style::MEIgnoreInside | Style::MEIgnoreParentInside
  42. | Style::MEIgnoreVisible | Style::MEIgnoreProcessed;
  43. }
  44. // Destructor
  45. ObjTable::~ObjTable()
  46. {
  47. if (members) members->release();
  48. if (spaltenNamen) spaltenNamen->release();
  49. if (zeilenNamen) zeilenNamen->release();
  50. if (columnWidth) columnWidth->release();
  51. if (zeilenHeight) zeilenHeight->release();
  52. if (minSpaltenWidth) minSpaltenWidth->release();
  53. if (maxSpaltenWidth) maxSpaltenWidth->release();
  54. if (minZeilenHeight) minZeilenHeight->release();
  55. if (maxZeilenHeight) maxZeilenHeight->release();
  56. if (aRam) aRam->release();
  57. if (aAf) aAf->release();
  58. if (msaRam) msaRam->release();
  59. if (msaAf) msaAf->release();
  60. if (styles) styles->release();
  61. }
  62. void ObjTable::doMouseEvent(
  63. MouseEvent& me, bool userRet) // processes mouse events
  64. {
  65. if (!hasStyle(Style::Visible) || !me.insideParent || me.processed
  66. || me.mx < 0 || me.my < 0 || me.mx >= gr.x || me.my >= gr.y || !userRet)
  67. {
  68. if (me.id == ME_PLeft)
  69. {
  70. klickSpalte = -1;
  71. klickZeile = -1;
  72. }
  73. bool processed = me.processed;
  74. me.processed |= hasStyleNot(Style::Visible);
  75. bool insideParent = me.insideParent;
  76. me.insideParent = 0;
  77. int rbr = 0;
  78. if (hasStyle(Style::Border) && border) rbr = border->getRWidth();
  79. me.mx -= rbr;
  80. me.my -= rbr;
  81. if (hasStyle(Style::VScroll) && vertikalScrollBar)
  82. me.my += vertikalScrollBar->getScroll();
  83. if (hasStyle(Style::HScroll) && horizontalScrollBar)
  84. me.mx += horizontalScrollBar->getScroll();
  85. if (me.id != ME_Enter && me.id != ME_Leaves)
  86. {
  87. for (int i = 0; i < zeilenAnzahl; ++i)
  88. {
  89. for (int j = 0; j < spaltenAnzahl; ++j)
  90. {
  91. Drawable* obj = zDrawable(j, i);
  92. if (obj) obj->doPublicMouseEvent(me);
  93. }
  94. }
  95. }
  96. me.mx += rbr;
  97. me.my += rbr;
  98. if (hasStyle(Style::VScroll) && vertikalScrollBar)
  99. me.my -= vertikalScrollBar->getScroll();
  100. if (hasStyle(Style::HScroll) && horizontalScrollBar)
  101. me.mx -= horizontalScrollBar->getScroll();
  102. me.insideParent = insideParent;
  103. if (hasStyleNot(Style::Visible)) me.processed = processed;
  104. return;
  105. }
  106. int tmx = me.mx;
  107. int tmy = me.my;
  108. bool aufScroll = 0;
  109. if (vertikalScrollBar && hasStyle(Style::VScroll)
  110. && me.mx > pos.x + gr.x - 15)
  111. aufScroll = 1;
  112. if (horizontalScrollBar && hasStyle(Style::HScroll)
  113. && me.my > pos.y + gr.y - 15)
  114. aufScroll = 1;
  115. me.mx -= ((horizontalScrollBar && hasStyle(Style::HScroll))
  116. ? horizontalScrollBar->getScroll()
  117. : 0);
  118. me.my -= ((vertikalScrollBar && hasStyle(Style::VScroll))
  119. ? vertikalScrollBar->getScroll()
  120. : 0);
  121. rwLock.lockRead();
  122. if (!me.processed && !aufScroll)
  123. {
  124. double ox = getMouseColumn(
  125. me.mx
  126. + ((horizontalScrollBar && hasStyle(Style::HScroll))
  127. ? horizontalScrollBar->getScroll()
  128. : 0));
  129. double oy
  130. = getMouseRow(me.my
  131. + ((vertikalScrollBar && hasStyle(Style::VScroll))
  132. ? vertikalScrollBar->getScroll()
  133. : 0));
  134. if (me.id == ME_RLeft)
  135. {
  136. klickSpalte = -1;
  137. klickZeile = -1;
  138. mSpalte = -1, mZeile = -1;
  139. }
  140. if ((hasStyle(Style::ColumnWidthChangeable)
  141. || hasStyle(Style::RowHeightChangeable))
  142. && klickSpalte < 0 && klickZeile < 0)
  143. {
  144. if (hasStyle(Style::ColumnWidthChangeable))
  145. {
  146. if (me.id == ME_PLeft && ox != (int)ox)
  147. {
  148. mSpalte = ox;
  149. mx = me.mx;
  150. rend = 1;
  151. }
  152. if (mSpalte > -1)
  153. {
  154. int br = getColumnWidth((int)mSpalte) + (me.mx - mx);
  155. if (hasStyle(Style::ColumnWidthMax)
  156. && br > getMaxColumnWidth((int)mSpalte))
  157. br = getMaxColumnWidth((int)mSpalte);
  158. if (hasStyle(Style::ColumnWidthMin)
  159. && br < getMinColumnWidth((int)mSpalte))
  160. br = getMinColumnWidth((int)mSpalte);
  161. setColumnWidth((int)mSpalte, br);
  162. mx = me.mx;
  163. rend = 1;
  164. }
  165. }
  166. if (hasStyle(Style::RowHeightChangeable))
  167. {
  168. if (me.id == ME_PLeft && oy != (int)oy)
  169. {
  170. mZeile = oy;
  171. my = me.my;
  172. rend = 1;
  173. }
  174. if (mZeile > -1)
  175. {
  176. int hi = getRowHeight((int)mZeile) + (me.my - my);
  177. if (hasStyle(Style::RowHeightMax)
  178. && hi > getMaxRowHeight((int)mZeile))
  179. hi = getMaxRowHeight((int)mZeile);
  180. if (hasStyle(Style::RowHeightMin)
  181. && hi < getMinRowHeight((int)mZeile))
  182. hi = getMinRowHeight((int)mZeile);
  183. setRowHeight((int)mZeile, hi);
  184. my = me.my;
  185. rend = 1;
  186. }
  187. }
  188. }
  189. if (hasStyle(Style::ColumnsMovable) && ox == (int)ox && mSpalte == -1
  190. && mZeile == -1)
  191. {
  192. if (klickSpalte >= 0 && klickSpalte < spaltenAnzahl
  193. && klickSpalte != ox && !oy && ox >= 0)
  194. {
  195. setColumnPosition(klickSpalte, (int)ox);
  196. klickSpalte = (int)ox;
  197. rend = 1;
  198. }
  199. if (me.id == ME_PLeft)
  200. {
  201. if (!oy && klickSpalte < 0)
  202. {
  203. klickSpalte = (int)ox;
  204. rend = 1;
  205. }
  206. }
  207. }
  208. if (hasStyle(Style::RowsMovable) && oy == (int)oy && mSpalte == -1
  209. && mZeile == -1)
  210. {
  211. if (klickZeile >= 0 && klickZeile < zeilenAnzahl && klickZeile != oy
  212. && !ox && oy >= 0)
  213. {
  214. setRowPosition(klickZeile, (int)oy);
  215. klickZeile = (int)oy;
  216. rend = 1;
  217. }
  218. if (me.id == ME_PLeft)
  219. {
  220. if (!ox && klickZeile < 0)
  221. {
  222. klickZeile = (int)oy;
  223. rend = 1;
  224. }
  225. }
  226. }
  227. }
  228. me.mx += (horizontalScrollBar && hasStyle(Style::HScroll))
  229. ? horizontalScrollBar->getScroll()
  230. : 0;
  231. me.my += (vertikalScrollBar && hasStyle(Style::VScroll))
  232. ? vertikalScrollBar->getScroll()
  233. : 0;
  234. bool vs = hasStyle(Style::VScroll) && vertikalScrollBar;
  235. bool hs = hasStyle(Style::HScroll) && horizontalScrollBar;
  236. int rbr = border ? border->getRWidth() : 0;
  237. if (vs)
  238. {
  239. if (hs)
  240. horizontalScrollBar->doMouseMessage(
  241. rbr, gr.y - 15 - rbr, gr.x - 15 - rbr * 2, 15, me);
  242. vertikalScrollBar->doMouseMessage(
  243. gr.x - 15 - rbr, rbr, 15, gr.y - rbr * 2, me);
  244. }
  245. else if (hs)
  246. horizontalScrollBar->doMouseMessage(
  247. rbr, gr.y - 15 - rbr, gr.x - rbr * 2, 15, me);
  248. if (aufScroll) me.processed = 1;
  249. if (me.id != ME_Enter && me.id != ME_Leaves)
  250. {
  251. for (int i = 0; i < zeilenAnzahl; ++i)
  252. {
  253. for (int j = 0; j < spaltenAnzahl; ++j)
  254. {
  255. bool b = me.processed;
  256. Drawable* obj = zDrawable(j, i);
  257. if (obj) obj->doPublicMouseEvent(me);
  258. if (!b && me.processed && me.id == ME_PLeft)
  259. selected = Point(j, i);
  260. }
  261. }
  262. }
  263. rwLock.unlockRead();
  264. me.processed = 1;
  265. me.mx = tmx;
  266. me.my = tmy;
  267. }
  268. // non-constant
  269. void ObjTable::addColumn(const char* name) // add column
  270. {
  271. addColumn(spaltenAnzahl, name);
  272. }
  273. void ObjTable::addColumn(Text* name)
  274. {
  275. addColumn(spaltenAnzahl, name);
  276. }
  277. void ObjTable::addColumn(int sNum, const char* name) // insert column at sNum
  278. {
  279. if (sNum > spaltenAnzahl) return;
  280. rwLock.lockWrite();
  281. members->add(new RCArray<Drawable>(), sNum);
  282. spaltenNamen->add(new Text(name), sNum);
  283. columnWidth->add(100, sNum);
  284. minSpaltenWidth->add(0, sNum);
  285. maxSpaltenWidth->add(300, sNum);
  286. msaRam->add(new RCArray<Border>(), sNum);
  287. msaAf->add(new RCArray<AlphaField>(), sNum);
  288. styles->add(new Array<__int64>(), sNum);
  289. for (int i = 0; i < zeilenAnzahl; i++)
  290. {
  291. members->z(sNum)->add(0);
  292. msaRam->z(sNum)->add(0);
  293. msaAf->z(sNum)->add(0);
  294. styles->z(sNum)->add(0);
  295. }
  296. ++spaltenAnzahl;
  297. rend = 1;
  298. rwLock.unlockWrite();
  299. }
  300. void ObjTable::addColumn(int sNum, Text* name)
  301. {
  302. addColumn(sNum, name->getText());
  303. name->release();
  304. }
  305. void ObjTable::addRow(const char* name) // add row
  306. {
  307. addRow(zeilenAnzahl, name);
  308. }
  309. void ObjTable::addRow(Text* name)
  310. {
  311. addRow(zeilenAnzahl, name);
  312. }
  313. void ObjTable::addRow(int zNum, const char* name) // insert row at zNum
  314. {
  315. if (zNum > zeilenAnzahl) return;
  316. rwLock.lockWrite();
  317. zeilenNamen->add(new Text(name), zNum);
  318. zeilenHeight->add(20, zNum);
  319. minZeilenHeight->add(0, zNum);
  320. maxZeilenHeight->add(100, zNum);
  321. for (int i = 0; i < spaltenAnzahl; ++i)
  322. {
  323. if (members->z(i)) members->z(i)->add(0, zNum);
  324. if (msaRam->z(i)) msaRam->z(i)->add(0, zNum);
  325. if (msaAf->z(i)) msaAf->z(i)->add(0, zNum);
  326. if (styles->z(i)) styles->z(i)->add(0, zNum);
  327. }
  328. ++zeilenAnzahl;
  329. rend = 1;
  330. rwLock.unlockWrite();
  331. }
  332. void ObjTable::addRow(int zNum, Text* name)
  333. {
  334. addRow(zNum, name->getText());
  335. name->release();
  336. }
  337. void ObjTable::removeColumn(int sNum) // delete column
  338. {
  339. if (sNum >= spaltenAnzahl) return;
  340. rwLock.lockWrite();
  341. members->remove(sNum);
  342. spaltenNamen->remove(sNum);
  343. columnWidth->remove(sNum);
  344. minSpaltenWidth->remove(sNum);
  345. maxSpaltenWidth->remove(sNum);
  346. if (msaRam->z(sNum)) msaRam->z(sNum)->release();
  347. msaRam->remove(sNum);
  348. if (msaAf->z(sNum)) msaAf->z(sNum)->release();
  349. msaAf->remove(sNum);
  350. styles->remove(sNum);
  351. --spaltenAnzahl;
  352. rend = 1;
  353. rwLock.unlockWrite();
  354. }
  355. void ObjTable::removeColumn(const char* name)
  356. {
  357. removeColumn(getColumnNumber(name));
  358. }
  359. void ObjTable::removeColumn(Text* name)
  360. {
  361. removeColumn(getColumnNumber(name));
  362. }
  363. void ObjTable::removeRow(int zNum) // delete row
  364. {
  365. if (zNum >= zeilenAnzahl) return;
  366. rwLock.lockWrite();
  367. zeilenNamen->remove(zNum);
  368. zeilenHeight->remove(zNum);
  369. minZeilenHeight->remove(zNum);
  370. maxZeilenHeight->remove(zNum);
  371. for (int i = 0; i < spaltenAnzahl; ++i)
  372. {
  373. if (members->z(i)) members->z(i)->remove(zNum);
  374. if (msaRam->z(i)) msaRam->z(i)->remove(zNum);
  375. if (msaAf->z(i)) msaAf->z(i)->remove(zNum);
  376. if (styles->z(i)) styles->z(i)->remove(zNum);
  377. }
  378. --zeilenAnzahl;
  379. rend = 1;
  380. rwLock.unlockWrite();
  381. }
  382. void ObjTable::removeRow(const char* name)
  383. {
  384. removeRow(getRowNumber(name));
  385. }
  386. void ObjTable::removeRow(Text* name)
  387. {
  388. removeRow(getRowNumber(name));
  389. }
  390. void ObjTable::setColumnPosition(
  391. const char* name, int pos) // sets the position of a column
  392. {
  393. setColumnPosition(getColumnNumber(name), pos);
  394. }
  395. void ObjTable::setColumnPosition(Text* name, int pos)
  396. {
  397. setColumnPosition(getColumnNumber(name), pos);
  398. }
  399. void ObjTable::setColumnPosition(int sNum, int pos)
  400. {
  401. if (sNum >= spaltenAnzahl || pos >= spaltenAnzahl || sNum == pos) return;
  402. int delPos = sNum;
  403. int insertPos = pos;
  404. if (pos < sNum)
  405. ++delPos;
  406. else
  407. ++insertPos;
  408. rwLock.lockWrite();
  409. members->add(members->get(sNum), insertPos);
  410. members->remove(delPos);
  411. spaltenNamen->add(spaltenNamen->get(sNum), insertPos);
  412. spaltenNamen->remove(delPos);
  413. columnWidth->add(
  414. columnWidth->has(sNum) ? columnWidth->get(sNum) : 0, insertPos);
  415. columnWidth->remove(delPos);
  416. minSpaltenWidth->add(
  417. minSpaltenWidth->has(sNum) ? minSpaltenWidth->get(sNum) : 0, insertPos);
  418. minSpaltenWidth->remove(delPos);
  419. msaRam->add(msaRam->z(sNum), insertPos);
  420. msaRam->remove(delPos);
  421. msaAf->add(msaAf->z(sNum), insertPos);
  422. msaAf->remove(delPos);
  423. styles->add(styles->get(sNum), insertPos);
  424. styles->remove(delPos);
  425. rend = 1;
  426. rwLock.unlockWrite();
  427. }
  428. void ObjTable::setRowPosition(
  429. const char* name, int pos) // sets the row position
  430. {
  431. setRowPosition(getRowNumber(name), pos);
  432. }
  433. void ObjTable::setRowPosition(Text* name, int pos)
  434. {
  435. setRowPosition(getRowNumber(name), pos);
  436. }
  437. void ObjTable::setRowPosition(int zNum, int pos)
  438. {
  439. if (zNum >= zeilenAnzahl || pos >= zeilenAnzahl || pos == zNum) return;
  440. int delPos = zNum;
  441. int insertPos = pos;
  442. if (pos < zNum)
  443. ++delPos;
  444. else
  445. ++insertPos;
  446. rwLock.lockWrite();
  447. zeilenNamen->add(zeilenNamen->get(zNum), insertPos);
  448. zeilenNamen->remove(delPos);
  449. zeilenHeight->add(
  450. zeilenHeight->has(zNum) ? zeilenHeight->get(zNum) : 0, insertPos);
  451. zeilenHeight->remove(delPos);
  452. minZeilenHeight->add(
  453. minZeilenHeight->has(zNum) ? minZeilenHeight->get(zNum) : 0, insertPos);
  454. minZeilenHeight->remove(delPos);
  455. maxZeilenHeight->add(
  456. maxZeilenHeight->has(zNum) ? maxZeilenHeight->get(zNum) : 0, insertPos);
  457. maxZeilenHeight->remove(delPos);
  458. for (int i = 0; i < spaltenAnzahl; ++i)
  459. {
  460. if (members->z(i))
  461. {
  462. members->z(i)->add(
  463. members->z(i)->has(zNum) ? members->z(i)->get(zNum) : 0,
  464. insertPos);
  465. members->z(i)->remove(delPos);
  466. }
  467. if (msaRam->z(i))
  468. {
  469. msaRam->z(i)->add(
  470. msaRam->z(i)->z(zNum) ? msaRam->z(i)->get(zNum) : 0, insertPos);
  471. msaRam->z(i)->remove(delPos);
  472. }
  473. if (msaAf->z(i))
  474. {
  475. msaAf->z(i)->add(
  476. msaAf->z(i)->z(zNum) ? msaAf->z(i)->get(zNum) : 0, insertPos);
  477. msaAf->z(i)->remove(delPos);
  478. }
  479. if (styles->z(i))
  480. {
  481. styles->z(i)->add(
  482. styles->z(i)->has(zNum) ? styles->z(i)->get(zNum) : 0,
  483. insertPos);
  484. styles->z(i)->remove(delPos);
  485. }
  486. }
  487. rend = 1;
  488. rwLock.unlockWrite();
  489. }
  490. void ObjTable::setDrawableZ(int sNum, int zNum, Drawable* obj) // sets a drawing
  491. {
  492. if (sNum >= spaltenAnzahl || zNum >= zeilenAnzahl) return;
  493. rwLock.lockWrite();
  494. if (!members->z(sNum)) members->set(new RCArray<Drawable>(), sNum);
  495. while (members->z(sNum)->getEntryCount() <= zNum)
  496. members->z(sNum)->add(0);
  497. members->z(sNum)->set(obj, zNum);
  498. if (columnWidth->has(sNum))
  499. {
  500. obj->setWidth(columnWidth->get(sNum));
  501. }
  502. if (zeilenHeight->has(zNum))
  503. {
  504. obj->setHeight(zeilenHeight->get(zNum));
  505. }
  506. rend = 1;
  507. rwLock.unlockWrite();
  508. }
  509. void ObjTable::setDrawableZ(
  510. const char* spaltenName, const char* zeilenName, Drawable* zDrawable)
  511. {
  512. setDrawableZ(
  513. getColumnNumber(spaltenName), getRowNumber(zeilenName), zDrawable);
  514. }
  515. void ObjTable::setDrawableZ(
  516. Text* spaltenName, Text* zeilenName, Drawable* zDrawable)
  517. {
  518. setDrawableZ(
  519. getColumnNumber(spaltenName), getRowNumber(zeilenName), zDrawable);
  520. }
  521. void ObjTable::setColumnWidth(int sNum, int br) // sets the column width
  522. {
  523. if (sNum >= spaltenAnzahl) return;
  524. rwLock.lockWrite();
  525. columnWidth->set(br, sNum);
  526. rend = 1;
  527. rwLock.unlockWrite();
  528. }
  529. void ObjTable::setColumnWidth(const char* name, int br)
  530. {
  531. setColumnWidth(getColumnNumber(name), br);
  532. }
  533. void ObjTable::setColumnWidth(Text* name, int br)
  534. {
  535. setColumnWidth(getColumnNumber(name), br);
  536. }
  537. void ObjTable::setRowHeight(int zNum, int hi) // sets the row height
  538. {
  539. if (zNum >= zeilenAnzahl) return;
  540. rwLock.lockWrite();
  541. zeilenHeight->set(hi, zNum);
  542. rend = 1;
  543. rwLock.unlockWrite();
  544. }
  545. void ObjTable::setRowHeight(const char* name, int hi)
  546. {
  547. setRowHeight(getRowNumber(name), hi);
  548. }
  549. void ObjTable::setRowHeight(Text* name, int hi)
  550. {
  551. setRowHeight(getRowNumber(name), hi);
  552. }
  553. void ObjTable::setMinColumnWidth(
  554. int sNum, int minBr) // sets the minimum column width
  555. {
  556. if (sNum >= spaltenAnzahl) return;
  557. rwLock.lockWrite();
  558. minSpaltenWidth->set(minBr, sNum);
  559. rend = 1;
  560. rwLock.unlockWrite();
  561. }
  562. void ObjTable::setMinColumnWidth(const char* name, int minBr)
  563. {
  564. setMinColumnWidth(getColumnNumber(name), minBr);
  565. }
  566. void ObjTable::setMinColumnWidth(Text* name, int minBr)
  567. {
  568. setMinColumnWidth(getColumnNumber(name), minBr);
  569. }
  570. void ObjTable::setMaxColumnWidth(
  571. int sNum, int maxBr) // sets the maximum column width
  572. {
  573. if (sNum >= spaltenAnzahl) return;
  574. rwLock.lockWrite();
  575. maxSpaltenWidth->set(maxBr, sNum);
  576. rend = 1;
  577. rwLock.unlockWrite();
  578. }
  579. void ObjTable::setMaxColumnWidth(const char* name, int maxBr)
  580. {
  581. setMaxColumnWidth(getColumnNumber(name), maxBr);
  582. }
  583. void ObjTable::setMaxColumnWidth(Text* name, int maxBr)
  584. {
  585. setMaxColumnWidth(getColumnNumber(name), maxBr);
  586. }
  587. void ObjTable::setMinRowHeight(
  588. int zNum, int minHi) // sets the minimum row height
  589. {
  590. if (zNum >= zeilenAnzahl) return;
  591. rwLock.lockWrite();
  592. minZeilenHeight->set(minHi, zNum);
  593. rend = 1;
  594. rwLock.unlockWrite();
  595. }
  596. void ObjTable::setMinRowHeight(const char* name, int minHi)
  597. {
  598. setMinRowHeight(getRowNumber(name), minHi);
  599. }
  600. void ObjTable::setMinRowHeight(Text* name, int minHi)
  601. {
  602. setMinRowHeight(getRowNumber(name), minHi);
  603. }
  604. void ObjTable::setMaxRowHeight(
  605. int zNum, int maxHi) // sets the maximum row height
  606. {
  607. if (zNum >= zeilenAnzahl) return;
  608. rwLock.lockWrite();
  609. maxZeilenHeight->set(maxHi, zNum);
  610. rend = 1;
  611. rwLock.unlockWrite();
  612. }
  613. void ObjTable::setMaxRowHeight(const char* name, int maxHi)
  614. {
  615. setMaxRowHeight(getRowHeight(name), maxHi);
  616. }
  617. void ObjTable::setMaxRowHeight(Text* name, int maxHi)
  618. {
  619. setMaxRowHeight(getRowHeight(name), maxHi);
  620. }
  621. void ObjTable::setSelection(
  622. int sNum, int zNum) // selects the corresponding field
  623. {
  624. if (sNum >= spaltenAnzahl || zNum >= zeilenAnzahl) return;
  625. rwLock.lockWrite();
  626. selected.x = sNum;
  627. selected.y = zNum;
  628. rend = 1;
  629. rwLock.unlockWrite();
  630. }
  631. void ObjTable::setSelection(const char* spaltenName, const char* zeilenName)
  632. {
  633. setSelection(getColumnNumber(spaltenName), getRowNumber(zeilenName));
  634. }
  635. void ObjTable::setSelection(Text* spaltenName, Text* zeilenName)
  636. {
  637. setSelection(getColumnNumber(spaltenName), getRowNumber(zeilenName));
  638. }
  639. void ObjTable::setGridColor(int f) // sets the grid color
  640. {
  641. rasterColor = f;
  642. rend = 1;
  643. }
  644. void ObjTable::setGridWidth(int br) // sets the width of the grid
  645. {
  646. gridWidth = br;
  647. rend = 1;
  648. }
  649. void ObjTable::setABorderZ(Border* ram) // sets the selection border
  650. {
  651. if (aRam) aRam->release();
  652. aRam = ram;
  653. rend = 1;
  654. }
  655. void ObjTable::setARColor(int f) // sets the selection border color
  656. {
  657. if (!aRam) aRam = new LBorder();
  658. aRam->setColor(f);
  659. rend = 1;
  660. }
  661. void ObjTable::setARWidth(int br) // sets the selection border width
  662. {
  663. if (!aRam) aRam = new LBorder();
  664. aRam->setBorderWidth(br);
  665. rend = 1;
  666. }
  667. void ObjTable::setAAlphaFieldZ(AlphaField* af) // sets the selection AlphaField
  668. {
  669. if (aAf) aAf->release();
  670. aAf = af;
  671. rend = 1;
  672. }
  673. void ObjTable::setAAfColor(int f) // sets the color of the selection AlphaField
  674. {
  675. if (!aAf) aAf = new AlphaField();
  676. aAf->setColor(f);
  677. rend = 1;
  678. }
  679. void ObjTable::setAAfStrength(
  680. int st) // sets the strength of the selection AlphaField
  681. {
  682. if (!aAf) aAf = new AlphaField();
  683. aAf->setStrength(st);
  684. rend = 1;
  685. }
  686. void ObjTable::setABorderZ(
  687. int sNum, int zNum, Border* ram) // sets the selection border
  688. {
  689. if (msaRam->z(sNum)) msaRam->z(sNum)->set(ram, zNum);
  690. rend = 1;
  691. }
  692. void ObjTable::setABorderZ(
  693. const char* spaltenName, const char* zeilenName, Border* ram)
  694. {
  695. setABorderZ(getColumnNumber(spaltenName), getRowNumber(zeilenName), ram);
  696. }
  697. void ObjTable::setABorderZ(Text* spaltenName, Text* zeilenName, Border* ram)
  698. {
  699. setABorderZ(getColumnNumber(spaltenName), getRowNumber(zeilenName), ram);
  700. }
  701. void ObjTable::setARColor(
  702. int sNum, int zNum, int f) // sets the selection border color
  703. {
  704. if (msaRam->z(sNum))
  705. {
  706. Border* tmp = msaRam->z(sNum)->z(zNum);
  707. if (!tmp)
  708. {
  709. tmp = new LBorder();
  710. msaRam->z(sNum)->set(tmp, zNum);
  711. }
  712. tmp->setColor(f);
  713. rend = 1;
  714. }
  715. }
  716. void ObjTable::setARColor(
  717. const char* spaltenName, const char* zeilenName, int f)
  718. {
  719. setARColor(getColumnNumber(spaltenName), getRowNumber(zeilenName), f);
  720. }
  721. void ObjTable::setARColor(Text* spaltenName, Text* zeilenName, int f)
  722. {
  723. setARColor(getColumnNumber(spaltenName), getRowNumber(zeilenName), f);
  724. }
  725. void ObjTable::setARWidth(
  726. int sNum, int zNum, int br) // sets the selection border width
  727. {
  728. if (msaRam->z(sNum))
  729. {
  730. Border* tmp = msaRam->z(sNum)->z(zNum);
  731. if (!tmp)
  732. {
  733. tmp = new LBorder();
  734. msaRam->z(sNum)->set(tmp, zNum);
  735. }
  736. tmp->setBorderWidth(br);
  737. rend = 1;
  738. }
  739. }
  740. void ObjTable::setARWidth(
  741. const char* spaltenName, const char* zeilenName, int br)
  742. {
  743. setARWidth(getColumnNumber(spaltenName), getRowNumber(zeilenName), br);
  744. }
  745. void ObjTable::setARWidth(Text* spaltenName, Text* zeilenName, int br)
  746. {
  747. setARWidth(getColumnNumber(spaltenName), getRowNumber(zeilenName), br);
  748. }
  749. void ObjTable::setAAlphaFieldZ(
  750. int sNum, int zNum, AlphaField* af) // sets the selection AlphaField
  751. {
  752. if (msaAf->z(sNum)) msaAf->z(sNum)->set(af, zNum);
  753. rend = 1;
  754. }
  755. void ObjTable::setAAlphaFieldZ(
  756. const char* spaltenName, const char* zeilenName, AlphaField* af)
  757. {
  758. setAAlphaFieldZ(getColumnNumber(spaltenName), getRowNumber(zeilenName), af);
  759. }
  760. void ObjTable::setAAlphaFieldZ(
  761. Text* spaltenName, Text* zeilenName, AlphaField* af)
  762. {
  763. setAAlphaFieldZ(getColumnNumber(spaltenName), getRowNumber(zeilenName), af);
  764. }
  765. void ObjTable::setAAfColor(
  766. int sNum, int zNum, int f) // sets the color of the selection AlphaField
  767. {
  768. if (msaAf->z(sNum))
  769. {
  770. AlphaField* tmp = msaAf->z(sNum)->z(zNum);
  771. if (!tmp)
  772. {
  773. tmp = new AlphaField();
  774. msaAf->z(sNum)->set(tmp, zNum);
  775. }
  776. tmp->setColor(f);
  777. rend = 1;
  778. }
  779. }
  780. void ObjTable::setAAfColor(
  781. const char* spaltenName, const char* zeilenName, int f)
  782. {
  783. setAAfColor(getColumnNumber(spaltenName), getRowNumber(zeilenName), f);
  784. }
  785. void ObjTable::setAAfColor(Text* spaltenName, Text* zeilenName, int f)
  786. {
  787. setAAfColor(getColumnNumber(spaltenName), getRowNumber(zeilenName), f);
  788. }
  789. void ObjTable::setAAfStrength(
  790. int sNum, int zNum, int st) // sets the strength of the selection AlphaField
  791. {
  792. if (msaAf->z(sNum))
  793. {
  794. AlphaField* tmp = msaAf->z(sNum)->z(zNum);
  795. if (!tmp)
  796. {
  797. tmp = new AlphaField();
  798. msaAf->z(sNum)->set(tmp, zNum);
  799. }
  800. tmp->setStrength(st);
  801. rend = 1;
  802. }
  803. }
  804. void ObjTable::setAAfStrength(
  805. const char* spaltenName, const char* zeilenName, int st)
  806. {
  807. setAAfStrength(getColumnNumber(spaltenName), getRowNumber(zeilenName), st);
  808. }
  809. void ObjTable::setAAfStrength(Text* spaltenName, Text* zeilenName, int st)
  810. {
  811. setAAfStrength(getColumnNumber(spaltenName), getRowNumber(zeilenName), st);
  812. }
  813. void ObjTable::addMsStyle(
  814. int sNum, int zNum, __int64 style) // sets the style when Multistyled
  815. {
  816. if (sNum >= spaltenAnzahl || zNum >= zeilenAnzahl) return;
  817. if (styles->z(sNum))
  818. styles->z(sNum)->set(
  819. (styles->z(sNum)->has(zNum) ? styles->z(sNum)->get(zNum) : 0)
  820. | style,
  821. zNum);
  822. rend = 1;
  823. }
  824. void ObjTable::addMsStyle(
  825. const char* spaltenName, const char* zeilenName, __int64 style)
  826. {
  827. addMsStyle(getColumnNumber(spaltenName), getRowNumber(zeilenName), style);
  828. }
  829. void ObjTable::addMsStyle(Text* spaltenName, Text* zeilenName, __int64 style)
  830. {
  831. addMsStyle(getColumnNumber(spaltenName), getRowNumber(zeilenName), style);
  832. }
  833. void ObjTable::setMsStyle(int sNum, int zNum, __int64 style)
  834. {
  835. if (sNum >= spaltenAnzahl || zNum >= zeilenAnzahl) return;
  836. if (styles->z(sNum)) styles->z(sNum)->set(style, zNum);
  837. rend = 1;
  838. }
  839. void ObjTable::setMsStyle(
  840. const char* spaltenName, const char* zeilenName, __int64 style)
  841. {
  842. setMsStyle(getColumnNumber(spaltenName), getRowNumber(zeilenName), style);
  843. }
  844. void ObjTable::setMsStyle(Text* spaltenName, Text* zeilenName, __int64 style)
  845. {
  846. setMsStyle(getColumnNumber(spaltenName), getRowNumber(zeilenName), style);
  847. }
  848. void ObjTable::setMsStyle(int sNum, int zNum, __int64 style, bool add_remove)
  849. {
  850. if (sNum >= spaltenAnzahl || zNum >= zeilenAnzahl) return;
  851. if (styles->z(sNum))
  852. {
  853. if (add_remove)
  854. styles->z(sNum)->set(
  855. (styles->z(sNum)->has(zNum) ? styles->z(sNum)->get(zNum) : 0)
  856. | style,
  857. zNum);
  858. else
  859. styles->z(sNum)->set(
  860. (styles->z(sNum)->has(zNum) ? styles->z(sNum)->get(zNum) : 0)
  861. & (~style),
  862. zNum);
  863. rend = 1;
  864. }
  865. }
  866. void ObjTable::setMsStyle(const char* spaltenName,
  867. const char* zeilenName,
  868. __int64 style,
  869. bool add_remove)
  870. {
  871. setMsStyle(getColumnNumber(spaltenName),
  872. getRowNumber(zeilenName),
  873. style,
  874. add_remove);
  875. }
  876. void ObjTable::setMsStyle(
  877. Text* spaltenName, Text* zeilenName, __int64 style, bool add_remove)
  878. {
  879. setMsStyle(getColumnNumber(spaltenName),
  880. getRowNumber(zeilenName),
  881. style,
  882. add_remove);
  883. }
  884. void ObjTable::removeMsStyle(int sNum, int zNum, __int64 style)
  885. {
  886. if (sNum >= spaltenAnzahl || zNum >= zeilenAnzahl) return;
  887. if (styles->z(sNum))
  888. styles->z(sNum)->set(
  889. (styles->z(sNum)->has(zNum) ? styles->z(sNum)->get(zNum) : 0)
  890. & (~style),
  891. zNum);
  892. rend = 1;
  893. }
  894. void ObjTable::removeMsStyle(
  895. const char* spaltenName, const char* zeilenName, __int64 style)
  896. {
  897. removeMsStyle(
  898. getColumnNumber(spaltenName), getRowNumber(zeilenName), style);
  899. }
  900. void ObjTable::removeMsStyle(Text* spaltenName, Text* zeilenName, __int64 style)
  901. {
  902. removeMsStyle(
  903. getColumnNumber(spaltenName), getRowNumber(zeilenName), style);
  904. }
  905. bool ObjTable::tick(double tickVal) // tick Message
  906. {
  907. rwLock.lockRead();
  908. for (int i = 0; i < zeilenAnzahl; ++i)
  909. {
  910. for (int j = 0; j < spaltenAnzahl; ++j)
  911. {
  912. Drawable* obj = zDrawable(j, i);
  913. if (obj) rend |= obj->tick(tickVal);
  914. }
  915. }
  916. rwLock.unlockRead();
  917. return DrawableBackground::tick(tickVal);
  918. }
  919. void ObjTable::doKeyboardEvent(KeyboardEvent& te)
  920. {
  921. bool ntakc = !te.processed;
  922. if (hasStyleNot(Style::Focus) || hasStyleNot(Style::Allowed)
  923. || hasStyleNot(Style::Visible))
  924. return;
  925. if (tak && (te.processed || tak(takParam, this, te)))
  926. {
  927. rwLock.lockRead();
  928. if (zDrawable(selected.x, selected.y))
  929. {
  930. zDrawable(selected.x, selected.y)->doKeyboardEvent(te);
  931. if (!te.processed && te.id == TE_Press)
  932. {
  933. if (te.virtualKey == T_Oben)
  934. {
  935. --(selected.y);
  936. rend = 1;
  937. }
  938. if (te.virtualKey == T_Unten)
  939. {
  940. ++(selected.y);
  941. rend = 1;
  942. }
  943. if (te.virtualKey == T_Links)
  944. {
  945. --(selected.x);
  946. rend = 1;
  947. }
  948. if (te.virtualKey == T_Rechts)
  949. {
  950. ++(selected.x);
  951. rend = 1;
  952. }
  953. }
  954. }
  955. rwLock.unlockRead();
  956. }
  957. te.processed = 1;
  958. if (ntakc && te.processed && nTak) te.processed = nTak(ntakParam, this, te);
  959. }
  960. void ObjTable::render(Image& zRObj) // renders the table into zRObj
  961. {
  962. if (hasStyleNot(Style::Visible)) return;
  963. DrawableBackground::render(zRObj);
  964. rwLock.lockRead();
  965. if (!zRObj.setDrawOptions(innenPosition, innenSize))
  966. {
  967. rwLock.unlockRead();
  968. return;
  969. }
  970. int xPos = 0;
  971. if (horizontalScrollBar && hasStyle(Style::HScroll))
  972. xPos -= horizontalScrollBar->getScroll();
  973. for (int s = 0; s < spaltenAnzahl; ++s)
  974. {
  975. int sBr = columnWidth->has(s) ? columnWidth->get(s) : 0;
  976. int yPos = 0;
  977. if (vertikalScrollBar && hasStyle(Style::VScroll))
  978. yPos -= vertikalScrollBar->getScroll();
  979. RCArray<Drawable>* tmp_zDrawables = members->z(s);
  980. if (!tmp_zDrawables) continue;
  981. for (int z = 0; z < zeilenAnzahl && tmp_zDrawables; ++z)
  982. {
  983. int zHi = zeilenHeight->has(z) ? zeilenHeight->get(z) : 0;
  984. if (hasStyle(Style::Raster)) yPos += gridWidth;
  985. yPos += zHi;
  986. if (z == zeilenAnzahl - 1 && vertikalScrollBar
  987. && hasStyle(Style::VScroll))
  988. vertikalScrollBar->getScrollData()->max
  989. = yPos + vertikalScrollBar->getScroll();
  990. }
  991. for (int z = zeilenAnzahl - 1; z >= 0 && tmp_zDrawables; z--)
  992. {
  993. int zHi = zeilenHeight->has(z) ? zeilenHeight->get(z) : 0;
  994. yPos -= zHi;
  995. if (hasStyle(Style::Raster))
  996. {
  997. yPos -= gridWidth;
  998. for (int i = 0; i < gridWidth; i++)
  999. zRObj.drawLineHAlpha(
  1000. xPos, yPos + zHi + i, sBr, rasterColor);
  1001. }
  1002. Drawable* obj = tmp_zDrawables->has(z) ? tmp_zDrawables->z(z) : 0;
  1003. if (obj)
  1004. {
  1005. obj->setPosition(xPos, yPos);
  1006. obj->setSize(sBr, zHi);
  1007. obj->render(zRObj);
  1008. if (selected.x == s && selected.y == z)
  1009. {
  1010. Border* tmp_aRam = aRam;
  1011. AlphaField* tmp_aAf = aAf;
  1012. bool aRamB = hasStyle(Style::SelectionBorder) && tmp_aRam;
  1013. bool aAfB = hasStyle(Style::SelectionBuffer) && tmp_aAf;
  1014. if (hasStyle(Style::SelectionMultistyled))
  1015. {
  1016. tmp_aRam = getABorder(s, z);
  1017. tmp_aAf = getAAlphaField(s, z);
  1018. aRamB = hasMsStyle(s, z, Style::SelectionBorder)
  1019. && tmp_aRam;
  1020. aAfB = hasMsStyle(s, z, Style::SelectionBuffer)
  1021. && tmp_aAf;
  1022. }
  1023. int aRbr = 0;
  1024. if (aRamB)
  1025. {
  1026. tmp_aRam->setPosition(xPos, yPos);
  1027. tmp_aRam->setSize(sBr, zHi);
  1028. tmp_aRam->render(zRObj);
  1029. aRbr = tmp_aRam->getRWidth();
  1030. }
  1031. if (aAfB)
  1032. {
  1033. tmp_aAf->setPosition(aRbr + xPos, aRbr + yPos);
  1034. tmp_aAf->setSize(sBr - aRbr * 2, zHi - aRbr * 2);
  1035. tmp_aAf->render(zRObj);
  1036. }
  1037. }
  1038. }
  1039. }
  1040. if (hasStyle(Style::Raster))
  1041. {
  1042. for (int i = 0; i < gridWidth; i++)
  1043. zRObj.drawLineVAlpha(
  1044. xPos + sBr + i, 0, innenSize.y, rasterColor);
  1045. xPos += gridWidth;
  1046. }
  1047. xPos += sBr;
  1048. }
  1049. if (horizontalScrollBar && hasStyle(Style::HScroll))
  1050. horizontalScrollBar->getScrollData()->max
  1051. = xPos + horizontalScrollBar->getScroll();
  1052. zRObj.releaseDrawOptions();
  1053. rwLock.unlockRead();
  1054. }
  1055. // constant
  1056. int ObjTable::getColumnCount() const // returns the number of columns
  1057. {
  1058. return spaltenAnzahl;
  1059. }
  1060. int ObjTable::getRowCount() const // returns the number of rows
  1061. {
  1062. return zeilenAnzahl;
  1063. }
  1064. int ObjTable::getColumnNumber(
  1065. const char* name) const // returns the index of the column with the name
  1066. {
  1067. for (int i = 0; i < spaltenAnzahl; ++i)
  1068. {
  1069. if (spaltenNamen->z(i)->isEqual(name)) return i;
  1070. }
  1071. return -1;
  1072. }
  1073. int ObjTable::getColumnNumber(Text* name) const
  1074. {
  1075. int ret = getColumnNumber(name->getText());
  1076. name->release();
  1077. return ret;
  1078. }
  1079. Text* ObjTable::getColumnName(
  1080. int num) const // returns the name of the column with index num
  1081. {
  1082. return spaltenNamen->get(num);
  1083. }
  1084. Text* ObjTable::zColumnName(int num) const
  1085. {
  1086. return spaltenNamen->z(num);
  1087. }
  1088. int ObjTable::getRowNumber(
  1089. const char* name) const // returns the index of the row with the name
  1090. {
  1091. for (int i = 0; i < zeilenAnzahl; ++i)
  1092. {
  1093. if (zeilenNamen->z(i)->isEqual(name)) return i;
  1094. }
  1095. return -1;
  1096. }
  1097. int ObjTable::getRowNumber(Text* name) const
  1098. {
  1099. int ret = getRowNumber(name->getText());
  1100. name->release();
  1101. return ret;
  1102. }
  1103. Text* ObjTable::getRowName(
  1104. int num) const // returns the name of the row with index num
  1105. {
  1106. return zeilenNamen->get(num);
  1107. }
  1108. Text* ObjTable::zRowName(int num) const
  1109. {
  1110. return zeilenNamen->z(num);
  1111. }
  1112. Point ObjTable::getDrawablePosition(
  1113. Drawable* zObj) const // returns the position of a drawing
  1114. {
  1115. for (int x = 0; x < spaltenAnzahl; ++x)
  1116. {
  1117. for (int y = 0; y < zeilenAnzahl; ++y)
  1118. {
  1119. if (zDrawable(x, y) == zObj) return Point(x, y);
  1120. }
  1121. }
  1122. return Point(-1, -1);
  1123. }
  1124. Drawable* ObjTable::zDrawable(
  1125. int sNum, int zNum) const // returns the drawing at the position
  1126. {
  1127. if (sNum < 0 || zNum < 0 || sNum >= spaltenAnzahl || zNum >= zeilenAnzahl)
  1128. return 0;
  1129. if (!members->z(sNum)) return 0;
  1130. RCArray<Drawable>* tmp = members->z(sNum);
  1131. if (!tmp->has(zNum)) return 0;
  1132. return tmp ? tmp->z(zNum) : 0;
  1133. }
  1134. Drawable* ObjTable::zDrawable(
  1135. const char* spaltenName, const char* zeilenName) const
  1136. {
  1137. return zDrawable(getColumnNumber(spaltenName), getRowNumber(zeilenName));
  1138. }
  1139. Drawable* ObjTable::zDrawable(Text* spaltenName, Text* zeilenName) const
  1140. {
  1141. return zDrawable(getColumnNumber(spaltenName), getRowNumber(zeilenName));
  1142. }
  1143. Drawable* ObjTable::getDrawable(
  1144. int sNum, int zNum) const // returns the drawing at the position
  1145. {
  1146. if (!members->z(sNum)) return 0;
  1147. RCArray<Drawable>* tmp = members->z(sNum);
  1148. if (!tmp->has(zNum)) return 0;
  1149. return tmp ? tmp->get(zNum) : 0;
  1150. }
  1151. Drawable* ObjTable::getDrawable(
  1152. const char* spaltenName, const char* zeilenName) const
  1153. {
  1154. return getDrawable(getColumnNumber(spaltenName), getRowNumber(zeilenName));
  1155. }
  1156. Drawable* ObjTable::getDrawable(Text* spaltenName, Text* zeilenName) const
  1157. {
  1158. return getDrawable(getColumnNumber(spaltenName), getRowNumber(zeilenName));
  1159. }
  1160. int ObjTable::getColumnWidth(int num) const // returns the width of the column
  1161. {
  1162. return columnWidth->get(num);
  1163. }
  1164. int ObjTable::getColumnWidth(const char* name) const
  1165. {
  1166. return getColumnWidth(getColumnNumber(name));
  1167. }
  1168. int ObjTable::getColumnWidth(Text* name) const
  1169. {
  1170. return getColumnWidth(getColumnNumber(name));
  1171. }
  1172. int ObjTable::getRowHeight(int num) const // returns the height of the row
  1173. {
  1174. return zeilenHeight->get(num);
  1175. }
  1176. int ObjTable::getRowHeight(const char* name) const
  1177. {
  1178. return getRowHeight(getRowNumber(name));
  1179. }
  1180. int ObjTable::getRowHeight(Text* name) const
  1181. {
  1182. return getRowHeight(getRowNumber(name));
  1183. }
  1184. int ObjTable::getMinColumnWidth(
  1185. int num) const // returns the minimum column width
  1186. {
  1187. return minSpaltenWidth->get(num);
  1188. }
  1189. int ObjTable::getMinColumnWidth(const char* name) const
  1190. {
  1191. return getMinColumnWidth(getColumnNumber(name));
  1192. }
  1193. int ObjTable::getMinColumnWidth(Text* name) const
  1194. {
  1195. return getMinColumnWidth(getColumnNumber(name));
  1196. }
  1197. int ObjTable::getMaxColumnWidth(
  1198. int num) const // returns the maximum column width
  1199. {
  1200. return maxSpaltenWidth->get(num);
  1201. }
  1202. int ObjTable::getMaxColumnWidth(const char* name) const
  1203. {
  1204. return getMaxColumnWidth(getColumnNumber(name));
  1205. }
  1206. int ObjTable::getMaxColumnWidth(Text* name) const
  1207. {
  1208. return getMaxColumnWidth(getColumnNumber(name));
  1209. }
  1210. int ObjTable::getMinRowHeight(int num) const // returns the minimum row height
  1211. {
  1212. return minZeilenHeight->get(num);
  1213. }
  1214. int ObjTable::getMinRowHeight(const char* name) const
  1215. {
  1216. return getMinRowHeight(getRowNumber(name));
  1217. }
  1218. int ObjTable::getMinRowHeight(Text* name) const
  1219. {
  1220. return getMinRowHeight(getRowNumber(name));
  1221. }
  1222. int ObjTable::getMaxRowHeight(int num) const // returns the maximum row height
  1223. {
  1224. return maxZeilenHeight->get(num);
  1225. }
  1226. int ObjTable::getMaxRowHeight(const char* name) const
  1227. {
  1228. return getMaxRowHeight(getRowNumber(name));
  1229. }
  1230. int ObjTable::getMaxRowHeight(Text* name) const
  1231. {
  1232. return getMaxRowHeight(getRowNumber(name));
  1233. }
  1234. double ObjTable::getMouseColumn(
  1235. int mx) const // determines the column under the mouse
  1236. {
  1237. if (mx >= gr.x) return -1;
  1238. int hsBeg = (horizontalScrollBar && hasStyle(Style::HScroll))
  1239. ? horizontalScrollBar->getScroll()
  1240. : 0;
  1241. mx += hsBeg;
  1242. if (mx < 0) return -1;
  1243. int xx = border ? border->getRWidth() : 0;
  1244. for (int i = 0; i < spaltenAnzahl; ++i)
  1245. {
  1246. xx += columnWidth->get(i);
  1247. if (mx < xx - 5) return i;
  1248. if (mx < xx + 5) return i + 0.5;
  1249. xx += gridWidth;
  1250. }
  1251. return -1;
  1252. }
  1253. Text* ObjTable::getMouseColumnnName(int mx) const
  1254. {
  1255. double tmp = getMouseColumn(mx);
  1256. if (tmp != (int)tmp) return 0;
  1257. return getColumnName((int)tmp);
  1258. }
  1259. Text* ObjTable::zMouseColumnName(int mx) const
  1260. {
  1261. double tmp = getMouseColumn(mx);
  1262. if (tmp != (int)tmp) return 0;
  1263. return zColumnName((int)tmp);
  1264. }
  1265. double ObjTable::getMouseRow(int my) const // calculates the row under the mouse
  1266. {
  1267. if (my >= gr.y) return -1;
  1268. if (my < 0) return -1;
  1269. int vsBeg = vertikalScrollBar && hasStyle(Style::VScroll)
  1270. ? vertikalScrollBar->getScroll()
  1271. : 0;
  1272. my += vsBeg;
  1273. int yy = border ? border->getRWidth() : 0;
  1274. for (int i = 0; i < zeilenAnzahl; ++i)
  1275. {
  1276. yy += zeilenHeight->get(i);
  1277. if (my < yy - 5) return i;
  1278. if (my < yy + 5) return i + 0.5;
  1279. yy += gridWidth;
  1280. }
  1281. return -1;
  1282. }
  1283. Text* ObjTable::getMouseRownName(int my) const
  1284. {
  1285. double tmp = getMouseRow(my);
  1286. if (tmp != (int)tmp) return 0;
  1287. return getRowName((int)tmp);
  1288. }
  1289. Text* ObjTable::zMouseRowName(int my) const
  1290. {
  1291. double tmp = getMouseRow(my);
  1292. if (tmp != (int)tmp) return 0;
  1293. return zRowName((int)tmp);
  1294. }
  1295. const Point&
  1296. ObjTable::getSelahlPosition() const // returns the selection position
  1297. {
  1298. return selected;
  1299. }
  1300. int ObjTable::getGridColor() const // returns the color of the grid
  1301. {
  1302. return rasterColor;
  1303. }
  1304. int ObjTable::getGridWidth() const // returns the width of the grid
  1305. {
  1306. return gridWidth;
  1307. }
  1308. Border* ObjTable::getABorder() const // returns the selection border
  1309. {
  1310. return aRam ? dynamic_cast<Border*>(aRam->getThis()) : 0;
  1311. }
  1312. Border* ObjTable::zABorder() const
  1313. {
  1314. return aRam;
  1315. }
  1316. AlphaField* ObjTable::getAAlphaField() const // returns the selection AlphaField
  1317. {
  1318. return aAf ? dynamic_cast<AlphaField*>(aAf->getThis()) : 0;
  1319. }
  1320. AlphaField* ObjTable::zAAlphaField() const
  1321. {
  1322. return aAf;
  1323. }
  1324. Border* ObjTable::getABorder(
  1325. int sNum, int zNum) const // returns the selection border
  1326. {
  1327. RCArray<Border>* tmp = msaRam->z(sNum);
  1328. return tmp ? tmp->get(zNum) : 0;
  1329. }
  1330. Border* ObjTable::zABorder(int sNum, int zNum) const
  1331. {
  1332. RCArray<Border>* tmp = msaRam->z(sNum);
  1333. return tmp ? tmp->z(zNum) : 0;
  1334. }
  1335. AlphaField* ObjTable::getAAlphaField(
  1336. int sNum, int zNum) const // returns the selection AlphaField
  1337. {
  1338. RCArray<AlphaField>* tmp = msaAf->z(sNum);
  1339. return tmp ? tmp->get(zNum) : 0;
  1340. }
  1341. AlphaField* ObjTable::zAAlphaField(int sNum, int zNum) const
  1342. {
  1343. return msaAf->z(sNum) ? msaAf->z(sNum)->z(zNum) : 0;
  1344. }
  1345. Border* ObjTable::getABorder(const char* spaltenName,
  1346. const char* zeilenName) const // returns the selection border
  1347. {
  1348. return getABorder(getColumnNumber(spaltenName), getRowNumber(zeilenName));
  1349. }
  1350. Border* ObjTable::zABorder(
  1351. const char* spaltenName, const char* zeilenName) const
  1352. {
  1353. return zABorder(getColumnNumber(spaltenName), getRowNumber(zeilenName));
  1354. }
  1355. AlphaField* ObjTable::getAAlphaField(const char* spaltenName,
  1356. const char* zeilenName) const // returns the selection AlphaField
  1357. {
  1358. return getAAlphaField(
  1359. getColumnNumber(spaltenName), getRowNumber(zeilenName));
  1360. }
  1361. AlphaField* ObjTable::zAAlphaField(
  1362. const char* spaltenName, const char* zeilenName) const
  1363. {
  1364. return zAAlphaField(getColumnNumber(spaltenName), getRowNumber(zeilenName));
  1365. }
  1366. Border* ObjTable::getABorder(
  1367. Text* spaltenName, Text* zeilenName) const // returns the selection border
  1368. {
  1369. return getABorder(getColumnNumber(spaltenName), getRowNumber(zeilenName));
  1370. }
  1371. Border* ObjTable::zABorder(Text* spaltenName, Text* zeilenName) const
  1372. {
  1373. return zABorder(getColumnNumber(spaltenName), getRowNumber(zeilenName));
  1374. }
  1375. AlphaField* ObjTable::getAAlphaField(Text* spaltenName,
  1376. Text* zeilenName) const // returns the selection AlphaField
  1377. {
  1378. return getAAlphaField(
  1379. getColumnNumber(spaltenName), getRowNumber(zeilenName));
  1380. }
  1381. AlphaField* ObjTable::zAAlphaField(Text* spaltenName, Text* zeilenName) const
  1382. {
  1383. return zAAlphaField(getColumnNumber(spaltenName), getRowNumber(zeilenName));
  1384. }
  1385. bool ObjTable::hasMsStyle(
  1386. int sNum, int zNum, __int64 style) const // checks if style is present
  1387. {
  1388. __int64 s = styles->z(sNum) && styles->z(sNum)->has(zNum)
  1389. ? styles->z(sNum)->get(zNum)
  1390. : 0;
  1391. return (s | style) == s;
  1392. }
  1393. bool ObjTable::hasMsStyleNot(int sNum,
  1394. int zNum,
  1395. __int64 style) const // checks if style is not present
  1396. {
  1397. __int64 s = styles->z(sNum) && styles->z(sNum)->has(zNum)
  1398. ? styles->z(sNum)->get(zNum)
  1399. : 0;
  1400. return (s | style) != s;
  1401. }
  1402. bool ObjTable::hasMsStyle(const char* spaltenName,
  1403. const char* zeilenName,
  1404. __int64 style) const // checks if style is present
  1405. {
  1406. return hasMsStyle(
  1407. getColumnNumber(spaltenName), getRowNumber(zeilenName), style);
  1408. }
  1409. bool ObjTable::hasMsStyleNot(const char* spaltenName,
  1410. const char* zeilenName,
  1411. __int64 style) const // checks if style is not present
  1412. {
  1413. return hasMsStyleNot(
  1414. getColumnNumber(spaltenName), getRowNumber(zeilenName), style);
  1415. }
  1416. bool ObjTable::hasMsStyle(Text* spaltenName,
  1417. Text* zeilenName,
  1418. __int64 style) const // checks if style is present
  1419. {
  1420. return hasMsStyle(
  1421. getColumnNumber(spaltenName), getRowNumber(zeilenName), style);
  1422. }
  1423. bool ObjTable::hasMsStyleNot(Text* spaltenName,
  1424. Text* zeilenName,
  1425. __int64 style) const // checks if style is not present
  1426. {
  1427. return hasMsStyleNot(
  1428. getColumnNumber(spaltenName), getRowNumber(zeilenName), style);
  1429. }
  1430. Drawable* ObjTable::duplicate() const // Creates a copy of the table
  1431. {
  1432. ObjTable* obj = new ObjTable();
  1433. obj->setPosition(pos);
  1434. obj->setSize(gr);
  1435. obj->setMouseEventParameter(makParam);
  1436. obj->setKeyboardEventParameter(takParam);
  1437. obj->setMouseEvent(mak);
  1438. obj->setKeyboardEvent(tak);
  1439. if (toolTip) obj->setToolTipZ((ToolTip*)toolTip->duplicate());
  1440. obj->setStyle(style);
  1441. if (border) obj->setBorderZ((Border*)border->duplicate());
  1442. obj->setBackgroundColor(backgroundColor);
  1443. if (backgroundImage)
  1444. obj->setBackgroundImage(
  1445. dynamic_cast<Image*>(backgroundImage->getThis()));
  1446. if (backgroundFeld)
  1447. obj->setAlphaFieldZ((AlphaField*)backgroundFeld->duplicate());
  1448. obj->setGridColor(rasterColor);
  1449. obj->setGridWidth(gridWidth);
  1450. if (aRam) obj->setABorderZ((Border*)aRam->duplicate());
  1451. if (aAf) obj->setAAlphaFieldZ((AlphaField*)aAf->duplicate());
  1452. for (int s = 0; s < spaltenAnzahl; ++s)
  1453. {
  1454. obj->addColumn(spaltenNamen->get(s));
  1455. if (columnWidth->has(s)) obj->setColumnWidth(s, columnWidth->get(s));
  1456. if (minSpaltenWidth->has(s))
  1457. obj->setMinColumnWidth(s, minSpaltenWidth->get(s));
  1458. if (maxSpaltenWidth->has(s))
  1459. obj->setMaxColumnWidth(s, maxSpaltenWidth->get(s));
  1460. for (int z = 0; z < zeilenAnzahl; ++z)
  1461. {
  1462. if (!s)
  1463. {
  1464. obj->addRow(zeilenNamen->get(z));
  1465. if (zeilenHeight->has(z))
  1466. obj->setRowHeight(z, zeilenHeight->get(z));
  1467. if (minZeilenHeight->has(z))
  1468. obj->setMinRowHeight(z, minZeilenHeight->get(z));
  1469. if (maxZeilenHeight->has(z))
  1470. obj->setMaxRowHeight(z, maxZeilenHeight->get(z));
  1471. }
  1472. if (members->z(s) && members->z(s)->has(z))
  1473. obj->setDrawableZ(s, z, members->z(s)->get(z));
  1474. if (styles->z(s) && styles->z(s)->has(z))
  1475. obj->setMsStyle(s, z, styles->z(s)->get(z));
  1476. if (msaRam->z(s) && msaRam->z(s)->z(z))
  1477. obj->setABorderZ(
  1478. s, z, (Border*)msaRam->z(s)->z(z)->duplicate());
  1479. if (msaAf->z(s) && msaAf->z(s)->z(z))
  1480. obj->setAAlphaFieldZ(
  1481. s, z, (AlphaField*)msaAf->z(s)->z(z)->duplicate());
  1482. }
  1483. }
  1484. obj->setSelection(selected.x, selected.y);
  1485. return obj;
  1486. }