Liste.cpp 32 KB

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