Liste.cpp 32 KB

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