TextFeld.cpp 57 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793
  1. #include "TextFeld.h"
  2. #include "Schrift.h"
  3. #include "Text.h"
  4. #include "AlphaFeld.h"
  5. #include "Rahmen.h"
  6. #include "Bild.h"
  7. #include "TastaturEreignis.h"
  8. #include "MausEreignis.h"
  9. #include "Fenster.h"
  10. #include "Scroll.h"
  11. #include <math.h>
  12. #include "Globals.h"
  13. #include "ToolTip.h"
  14. #include "Scroll.h"
  15. using namespace Framework;
  16. bool TextFeld::TextStyle::operator==( const TextStyle &rhs )
  17. {
  18. return fontSize == rhs.fontSize && fontColor == rhs.fontColor &&
  19. selectedColor == rhs.selectedColor && selectedBackcroundColor == rhs.selectedBackcroundColor &&
  20. underlined == rhs.underlined && selected == rhs.selected && interactParam == rhs.interactParam && rendererIndex == rhs.rendererIndex;
  21. }
  22. TextFeld::TextStyleManager::TextStyleManager()
  23. : renderer( new RCArray< TextRenderer >() ),
  24. index( 0 ),
  25. styleIndex( 0 ),
  26. text( 0 ),
  27. ref( 1 )
  28. {
  29. current.beginIndex = 0;
  30. current.fontColor = 0xFFFFFFFF;
  31. current.fontSize = 12;
  32. current.selected = 0;
  33. current.selectedColor = 0xFFFFFFFF;
  34. current.selectedBackcroundColor = 0xFF0000FF;
  35. current.underlined = 0;
  36. current.interactParam = 0;
  37. current.rendererIndex = 0;
  38. textStyle.add( current );
  39. }
  40. TextFeld::TextStyleManager::~TextStyleManager()
  41. {
  42. if( renderer )
  43. renderer->release();
  44. if( text )
  45. text->release();
  46. }
  47. // Setzt den Style eines Textabschnittes
  48. // begin: die startposition des Abschnittes
  49. // end: die endposition des Abschnittes (nicht enthalten)
  50. void TextFeld::TextStyleManager::setTextStyle( int begin, int end, TextFeld::TextStyle style )
  51. {
  52. if( begin < 0 || begin > end || begin > text->getLength() )
  53. return;
  54. int sc = textStyle.getEintragAnzahl();
  55. int index = -1;
  56. TextStyle s = textStyle.get( 0 );
  57. // suche bis zur richtigen stelle im stylearray
  58. for( int i = 0; i < sc; i++ )
  59. {
  60. if( textStyle.get( i ).beginIndex >= begin )
  61. {
  62. index = i;
  63. if( textStyle.get( i ).beginIndex > begin )
  64. s = textStyle.get( i - 1 );
  65. else
  66. {
  67. s = textStyle.get( i );
  68. textStyle.remove( i );
  69. sc--;
  70. }
  71. break;
  72. }
  73. }
  74. style.beginIndex = begin;
  75. s.beginIndex = end;
  76. if( index < 0 )
  77. { // hinten an styles anfügen
  78. textStyle.add( style );
  79. textStyle.add( s );
  80. }
  81. else
  82. { // in die mitte des style arrays einfügen
  83. textStyle.add( style, index );
  84. for( int i = index + 1; i < sc + 1; i++ )
  85. { // styles entfernen die überschrieben wurden
  86. if( textStyle.get( i ).beginIndex <= end && textStyle.get( i ).beginIndex > begin )
  87. {
  88. s = textStyle.get( i );
  89. textStyle.remove( i );
  90. i--;
  91. sc--;
  92. }
  93. }
  94. s.beginIndex = end;
  95. textStyle.add( s, index + 1 );
  96. }
  97. cleanupStyles();
  98. }
  99. // Entfernt einen Textabschnitt
  100. // begin: der index des ersten betroffenen zeichens
  101. // end: der index des ersten zeichens nach dem abschnitt
  102. void TextFeld::TextStyleManager::removeText( int begin, int end )
  103. {
  104. int sc = textStyle.getEintragAnzahl();
  105. for( int i = 1; i < sc; i++ )
  106. {
  107. TextStyle s = textStyle.get( i );
  108. if( s.beginIndex >= begin && s.beginIndex < end )
  109. {
  110. textStyle.remove( i );
  111. i--;
  112. sc--;
  113. }
  114. if( s.beginIndex >= end )
  115. {
  116. s.beginIndex -= end - begin;
  117. textStyle.set( s, i );
  118. }
  119. }
  120. text->remove( begin, end );
  121. cleanupStyles();
  122. }
  123. // Fügt ein Text an einer bestimmten Position ein
  124. // pos: die position des neuen Textausschnitts
  125. // text: der neue Text
  126. void TextFeld::TextStyleManager::insertText( int pos, const char *text )
  127. {
  128. int len = textLength( text );
  129. this->text->insert( pos, text );
  130. int sc = textStyle.getEintragAnzahl();
  131. for( int i = 0; i < sc; i++ )
  132. {
  133. TextStyle s = textStyle.get( i );
  134. if( s.beginIndex > pos )
  135. {
  136. s.beginIndex += len;
  137. textStyle.set( s, i );
  138. }
  139. }
  140. cleanupStyles();
  141. }
  142. // Entfernt nicht benötiegte gleiche styles
  143. void TextFeld::TextStyleManager::cleanupStyles()
  144. {
  145. int sc = textStyle.getEintragAnzahl();
  146. TextStyle last = textStyle.get( 0 );
  147. for( int i = 1; i < sc; i++ )
  148. {
  149. if( textStyle.get( i ).beginIndex == last.beginIndex )
  150. {
  151. last = textStyle.get( i );
  152. textStyle.remove( i - 1 );
  153. i--;
  154. sc--;
  155. continue;
  156. }
  157. if( textStyle.get( i ) == last || ( text && textStyle.get( i ).beginIndex > text->getLength() ) )
  158. {
  159. textStyle.remove( i );
  160. i--;
  161. sc--;
  162. }
  163. else
  164. last = textStyle.get( i );
  165. }
  166. }
  167. // gibt eine referenz auf das style objekt zurück
  168. TextFeld::TextStyle &TextFeld::TextStyleManager::currentStyle()
  169. {
  170. return current;
  171. }
  172. // gibt den aktuellen text renderer zurück
  173. TextRenderer *TextFeld::TextStyleManager::zCurrentRenderer()
  174. {
  175. TextRenderer *tr = renderer->z( current.rendererIndex );
  176. if( !tr )
  177. tr = renderer->z( 0 );
  178. if( tr )
  179. tr->setSchriftSize( current.fontSize );
  180. return tr;
  181. }
  182. // ändert den inhalt des style objektes auf den style des nächsten zeichens
  183. bool TextFeld::TextStyleManager::nextStyle()
  184. {
  185. index++;
  186. if( textStyle.getEintragAnzahl() > styleIndex + 1 && index >= textStyle.get( styleIndex + 1 ).beginIndex )
  187. current = textStyle.get( styleIndex++ + 1 );
  188. return text && index < text->getLength();
  189. }
  190. // ändert den inhalt des style objektes auf den style des angegebenen zeichens
  191. // index: der Index des Zeichens zu dem gesprungen werden soll
  192. // gibt 0 zurück falls es das zeichen nicht gibt
  193. bool TextFeld::TextStyleManager::stepTo( int index )
  194. {
  195. this->index = index;
  196. current = getTextStyle( index );
  197. return text && index < text->getLength();
  198. }
  199. // ändert den inhalt des style objektes auf den style des ersten zeichens
  200. void TextFeld::TextStyleManager::resetIteration()
  201. {
  202. index = 0;
  203. styleIndex = 0;
  204. current = textStyle.get( 0 );
  205. }
  206. // Gibt den Style eines bestimmten zeichens zurück
  207. // index: Der index des Zeichensf
  208. TextFeld::TextStyle TextFeld::TextStyleManager::getTextStyle( int index ) const
  209. {
  210. TextStyle last = textStyle.get( 0 );
  211. int ind = 0;
  212. for( auto i = textStyle.getIterator(); i && ind <= index; ind++ )
  213. {
  214. if( i._.beginIndex <= ind )
  215. {
  216. last = i;
  217. i++;
  218. }
  219. }
  220. return last;
  221. }
  222. // Erhöht den Reference Counting Zähler.
  223. // return: this.
  224. TextFeld::TextStyleManager *TextFeld::TextStyleManager::getThis()
  225. {
  226. ref++;
  227. return this;
  228. }
  229. // Verringert den Reference Counting Zähler. Wenn der Zähler 0 erreicht, wird das Zeichnung automatisch gelöscht.
  230. // return: 0.
  231. TextFeld::TextStyleManager *TextFeld::TextStyleManager::release()
  232. {
  233. if( !--ref )
  234. delete this;
  235. return 0;
  236. }
  237. // Inhalt der TextFeld Klasse aus TextFeld.h
  238. // Konstruktor
  239. TextFeld::TextFeld()
  240. : ZeichnungHintergrund(),
  241. tm( new TextStyleManager() ),
  242. showChar( 0 ),
  243. cpos( 0 ),
  244. tickVal( 0 ),
  245. mausKlick( 0 )
  246. {
  247. charEvent = 0;
  248. horizontalScrollBar = new HScrollBar();
  249. vertikalScrollBar = new VScrollBar();
  250. this->setMausEreignis( _ret1ME );
  251. this->setTastaturEreignis( _ret1TE );
  252. }
  253. // Destruktor
  254. TextFeld::~TextFeld()
  255. {
  256. tm->release();
  257. }
  258. int TextFeld::getTextHeight() const
  259. {
  260. tm->resetIteration();
  261. int th = 0;
  262. int len = tm->text->getLength();
  263. char *text = tm->text->getText();
  264. int max = 0;
  265. int abstand = 0;
  266. for( int i = 0; i < len; i++ )
  267. {
  268. if( text[ i ] == '\n' )
  269. {
  270. th += max + abstand;
  271. abstand = 0;
  272. max = 0;
  273. tm->nextStyle();
  274. continue;
  275. }
  276. TextRenderer *r = tm->zCurrentRenderer();
  277. if( r )
  278. {
  279. int tmp = r->getZeilenHeight();
  280. max = max >= tmp ? max : tmp;
  281. if( max == tmp )
  282. abstand = r->getZeichenAbstand();
  283. }
  284. tm->nextStyle();
  285. }
  286. if( max > 0 )
  287. th += max;
  288. return th;
  289. }
  290. int TextFeld::getTextWidth() const
  291. {
  292. tm->resetIteration();
  293. int maxBr = 0;
  294. int len = tm->text->getLength();
  295. char *text = tm->text->getText();
  296. int lineBr = 0;
  297. char buff[] = { 0,0 };
  298. for( int i = 0; i < len; i++ )
  299. {
  300. buff[ 0 ] = text[ i ];
  301. if( text[ i ] == '\n' )
  302. {
  303. maxBr = maxBr >= lineBr ? maxBr : lineBr;
  304. lineBr = 0;
  305. tm->nextStyle();
  306. continue;
  307. }
  308. TextRenderer *r = tm->zCurrentRenderer();
  309. if( r )
  310. lineBr += r->getTextBreite( buff );
  311. tm->nextStyle();
  312. }
  313. if( lineBr > 0 )
  314. maxBr = maxBr >= lineBr ? maxBr : lineBr;
  315. return maxBr;
  316. }
  317. // charEvent: eine funktion die aufgerufen wird, wenn sich die maus auf einem bestimmten zeichen befindet und der interactParam im style != 0 ist
  318. // aufruf: charEvent( charIndex, interactParam, mausEreignis );
  319. void TextFeld::setCharEvent( std::function< void( int, int, MausEreignis me ) > charEvent )
  320. {
  321. this->charEvent = charEvent;
  322. }
  323. void TextFeld::setText( Text * txt ) // setzt den angezeigten Text
  324. {
  325. lockZeichnung();
  326. if( !tm->text )
  327. tm->text = new Text();
  328. tm->text->setText( txt );
  329. if( hatStyle( Style::VScroll ) )
  330. updateVScroll();
  331. if( hatStyle( Style::HScroll ) )
  332. updateHScroll();
  333. unlockZeichnung();
  334. rend = 1;
  335. }
  336. void TextFeld::setTextZ( Text * txt ) // setzt einen Zeiger zum angezeigten Text
  337. {
  338. lockZeichnung();
  339. if( tm->text )
  340. tm->text->release();
  341. tm->text = txt;
  342. if( hatStyle( Style::VScroll ) )
  343. updateVScroll();
  344. if( hatStyle( Style::HScroll ) )
  345. updateHScroll();
  346. rend = 1;
  347. unlockZeichnung();
  348. }
  349. void TextFeld::setText( const char *txt ) // setzt den angezeigten Text
  350. {
  351. lockZeichnung();
  352. if( !tm->text )
  353. tm->text = new Text();
  354. tm->text->setText( txt );
  355. if( hatStyle( Style::VScroll ) )
  356. updateVScroll();
  357. if( hatStyle( Style::HScroll ) )
  358. updateHScroll();
  359. rend = 1;
  360. unlockZeichnung();
  361. }
  362. // setzt den Text mit styles
  363. // txt: der Text
  364. // format: \x1: aktiviert unterschtrich
  365. // \x2\xY: setzt die schriftgröße auf y für den folgenden text
  366. // \x3\xA\xR\xG\xB: setzt die schriftfarbe auf ARGB
  367. // \x4\xA\xR\xG\xB: setzt die farbe des ausgewählten textes
  368. // \x5\xA\xR\xG\xB: setzt die hintergrundfarbe des ausgewählten textes
  369. // \x6\xY: setzt text renderer index auf y
  370. // \x7: deaktiviert unterschtrich
  371. // \x8\xA\xB\xC\xD: set interact param to ABCD
  372. void TextFeld::setFormattedText( const char *txt )
  373. {
  374. lockZeichnung();
  375. if( !tm->text )
  376. tm->text = new Text();
  377. tm->textStyle.leeren();
  378. TextStyle current;
  379. current.beginIndex = 0;
  380. current.fontColor = 0xFFFFFFFF;
  381. current.fontSize = 12;
  382. current.selected = 0;
  383. current.selectedColor = 0xFFFFFFFF;
  384. current.selectedBackcroundColor = 0xFF0000FF;
  385. current.underlined = 0;
  386. current.interactParam = 0;
  387. current.rendererIndex = 0;
  388. tm->textStyle.add( current );
  389. Text result = "";
  390. for( int i = 0; 1; i++ )
  391. {
  392. bool br = 0;
  393. current.beginIndex = result.getLength();
  394. switch( txt[ i ] )
  395. {
  396. case 0:
  397. br = 1;
  398. break;
  399. case 1:
  400. current.underlined = 1;
  401. tm->textStyle.add( current );
  402. break;
  403. case 2:
  404. current.fontSize = (unsigned char)txt[ ++i ];
  405. tm->textStyle.add( current );
  406. break;
  407. case 3:
  408. current.fontColor = 0;
  409. current.fontColor |= (unsigned char)txt[ ++i ] << 24;
  410. current.fontColor |= (unsigned char)txt[ ++i ] << 16;
  411. current.fontColor |= (unsigned char)txt[ ++i ] << 8;
  412. current.fontColor |= (unsigned char)txt[ ++i ];
  413. tm->textStyle.add( current );
  414. break;
  415. case 4:
  416. current.selectedColor = 0;
  417. current.selectedColor |= (unsigned char)txt[ ++i ] << 24;
  418. current.selectedColor |= (unsigned char)txt[ ++i ] << 16;
  419. current.selectedColor |= (unsigned char)txt[ ++i ] << 8;
  420. current.selectedColor |= (unsigned char)txt[ ++i ];
  421. tm->textStyle.add( current );
  422. break;
  423. case 5:
  424. current.selectedBackcroundColor = 0;
  425. current.selectedBackcroundColor |= (unsigned char)txt[ ++i ] << 24;
  426. current.selectedBackcroundColor |= (unsigned char)txt[ ++i ] << 16;
  427. current.selectedBackcroundColor |= (unsigned char)txt[ ++i ] << 8;
  428. current.selectedBackcroundColor |= (unsigned char)txt[ ++i ];
  429. tm->textStyle.add( current );
  430. break;
  431. case 6:
  432. current.rendererIndex = (unsigned char)txt[ ++i ];
  433. tm->textStyle.add( current );
  434. break;
  435. case 7:
  436. current.underlined = 0;
  437. tm->textStyle.add( current );
  438. break;
  439. case 8:
  440. current.interactParam = 0;
  441. current.interactParam |= (unsigned char)txt[ ++i ] << 24;
  442. current.interactParam |= (unsigned char)txt[ ++i ] << 16;
  443. current.interactParam |= (unsigned char)txt[ ++i ] << 8;
  444. current.interactParam |= (unsigned char)txt[ ++i ];
  445. tm->textStyle.add( current );
  446. break;
  447. default:
  448. result.append( txt[ i ] );
  449. }
  450. if( br )
  451. break;
  452. }
  453. tm->text->setText( result );
  454. tm->cleanupStyles();
  455. if( hatStyle( Style::VScroll ) )
  456. updateVScroll();
  457. if( hatStyle( Style::HScroll ) )
  458. updateHScroll();
  459. rend = 1;
  460. unlockZeichnung();
  461. }
  462. // fügt zeilenumbrüche so ein, dass der text nicht die breite des textfeldes überschreitet
  463. void TextFeld::addLineBreaks()
  464. {
  465. if( !tm->text )
  466. return;
  467. int lastPos = -1;
  468. int lastPos2 = -1;
  469. int x = 0;
  470. const char *txt = tm->text->getText();
  471. Text result = "";
  472. int len = tm->text->getLength();
  473. lockZeichnung();
  474. tm->resetIteration();
  475. TextStyle last = tm->currentStyle();
  476. for( int i = 0; i < len; ++i )
  477. {
  478. if( txt[ i ] == ' ' )
  479. {
  480. lastPos = i;
  481. lastPos2 = result.getLength();
  482. x += tm->zCurrentRenderer()->getTextBreite( " " );
  483. result += " ";
  484. continue;
  485. }
  486. if( txt[ i ] == '\t' )
  487. {
  488. lastPos = i;
  489. lastPos2 = result.getLength();
  490. x += tm->zCurrentRenderer()->getTextBreite( "\t" );
  491. result += "\t";
  492. continue;
  493. }
  494. if( txt[ i ] == '\n' )
  495. {
  496. x = 0;
  497. lastPos = -1;
  498. lastPos2 = -1;
  499. result += "\n";
  500. continue;
  501. }
  502. char buff[ 2 ] = { txt[ i ], 0 };
  503. x += tm->zCurrentRenderer()->getTextBreite( buff );
  504. result += buff;
  505. if( x > getBreite() && lastPos > -1 )
  506. {
  507. result.remove( lastPos2, result.getLength() );
  508. result += "\n";
  509. x = 0;
  510. i = lastPos;
  511. lastPos = -1;
  512. lastPos2 = -1;
  513. tm->stepTo( lastPos );
  514. last = tm->currentStyle();
  515. }
  516. tm->nextStyle();
  517. if( last.fontSize != tm->current.fontSize )
  518. {
  519. char tmp[ 3 ] = { 2, (char)tm->current.fontSize, 0 };
  520. result += tmp;
  521. last.fontSize = tm->current.fontSize;
  522. }
  523. if( last.fontColor != tm->current.fontColor )
  524. {
  525. char tmp[ 6 ] = { 3, (char)((tm->current.fontColor >> 24) & 0xFF),
  526. (char)( ( tm->current.fontColor >> 16 ) & 0xFF ),
  527. (char)( ( tm->current.fontColor >> 8 ) & 0xFF ),
  528. (char)( tm->current.fontColor & 0xFF ), 0 };
  529. result += tmp;
  530. last.fontColor = tm->current.fontColor;
  531. }
  532. if( last.selectedColor != tm->current.selectedColor )
  533. {
  534. char tmp[ 6 ] = { 4, (char)( ( tm->current.selectedColor >> 24 ) & 0xFF ),
  535. (char)( ( tm->current.selectedColor >> 16 ) & 0xFF ),
  536. (char)( ( tm->current.selectedColor >> 8 ) & 0xFF ),
  537. (char)( tm->current.selectedColor & 0xFF ), 0 };
  538. result += tmp;
  539. last.selectedColor = tm->current.selectedColor;
  540. }
  541. if( last.selectedBackcroundColor != tm->current.selectedBackcroundColor )
  542. {
  543. char tmp[ 6 ] = { 5, (char)( ( tm->current.selectedBackcroundColor >> 24 ) & 0xFF ),
  544. (char)( ( tm->current.selectedBackcroundColor >> 16 ) & 0xFF ),
  545. (char)( ( tm->current.selectedBackcroundColor >> 8 ) & 0xFF ),
  546. (char)( tm->current.selectedBackcroundColor & 0xFF ), 0 };
  547. result += tmp;
  548. last.selectedBackcroundColor = tm->current.selectedBackcroundColor;
  549. }
  550. if( last.underlined != tm->current.underlined )
  551. {
  552. char tmp[ 2 ] = { tm->current.underlined ? 1 : 7, 0 };
  553. result += tmp;
  554. last.underlined = tm->current.underlined;
  555. }
  556. if( last.interactParam != tm->current.interactParam )
  557. {
  558. char tmp[ 6 ] = { 8, (char)( ( tm->current.interactParam >> 24 ) & 0xFF ),
  559. (char)( ( tm->current.interactParam >> 16 ) & 0xFF ),
  560. (char)( ( tm->current.interactParam >> 8 ) & 0xFF ),
  561. (char)( tm->current.interactParam & 0xFF ), 0 };
  562. result += tmp;
  563. last.interactParam = tm->current.interactParam;
  564. }
  565. if( last.rendererIndex != tm->current.rendererIndex )
  566. {
  567. char tmp[ 3 ] = { 6, (char)tm->current.rendererIndex, 0 };
  568. result += tmp;
  569. last.rendererIndex = tm->current.rendererIndex;
  570. }
  571. }
  572. unlockZeichnung();
  573. setFormattedText( result );
  574. }
  575. // Setzt den Style eines Textabschnittes
  576. // begin: die startposition des Abschnittes
  577. // end: die endposition des Abschnittes (nicht enthalten)
  578. void TextFeld::setTextStyle( int begin, int end, TextStyle style )
  579. {
  580. tm->setTextStyle( begin, end, style );
  581. }
  582. void TextFeld::addZeile( const char *zeile ) // fügt Zeile An
  583. {
  584. if( tm->text )
  585. {
  586. Text *txt = new Text( zeile );
  587. if( zeile[ txt->getLength() - 1 ] != '\n' )
  588. txt->append( "\n" );
  589. TextRenderer * r = tm->renderer->z( 0 );
  590. if( tm->textStyle.get( tm->textStyle.getEintragAnzahl() - 1 ).rendererIndex < tm->renderer->getEintragAnzahl() )
  591. r = tm->renderer->z( tm->textStyle.get( tm->textStyle.getEintragAnzahl() - 1 ).rendererIndex );
  592. if( r )
  593. {
  594. bool vs = vertikalScrollBar && hatStyle( Style::VScroll );
  595. int rbr = ( rahmen && hatStyle( Style::Rahmen ) ) ? rahmen->getRBreite() : 0;
  596. r->setSchriftSize( tm->textStyle.get( tm->textStyle.getEintragAnzahl() - 1 ).fontSize );
  597. r->textFormatieren( txt, gr.x - ( (int)vs * 15 ) - rbr * 2 );
  598. }
  599. lockZeichnung();
  600. tm->text->append( txt->getText() );
  601. unlockZeichnung();
  602. txt->release();
  603. if( hatStyle( Style::VScroll ) )
  604. updateVScroll();
  605. if( hatStyle( Style::HScroll ) )
  606. updateHScroll();
  607. rend = 1;
  608. }
  609. }
  610. // Fügt eine Zeile an den Text an
  611. // zeile: Die neue Zeile
  612. // color: Die Farbe der Zeile
  613. void TextFeld::addZeile( const char *zeile, int color )
  614. {
  615. if( tm->text )
  616. {
  617. Text *txt = new Text( zeile );
  618. if( zeile[ txt->getLength() - 1 ] != '\n' )
  619. txt->append( "\n" );
  620. TextRenderer * r = tm->renderer->z( 0 );
  621. if( tm->textStyle.get( tm->textStyle.getEintragAnzahl() - 1 ).rendererIndex < tm->renderer->getEintragAnzahl() )
  622. r = tm->renderer->z( tm->textStyle.get( tm->textStyle.getEintragAnzahl() - 1 ).rendererIndex );
  623. if( r )
  624. {
  625. bool vs = vertikalScrollBar && hatStyle( Style::VScroll );
  626. int rbr = ( rahmen && hatStyle( Style::Rahmen ) ) ? rahmen->getRBreite() : 0;
  627. r->setSchriftSize( tm->textStyle.get( tm->textStyle.getEintragAnzahl() - 1 ).fontSize );
  628. r->textFormatieren( txt, gr.x - ( (int)vs * 15 ) - rbr * 2 );
  629. }
  630. lockZeichnung();
  631. tm->text->append( txt->getText() );
  632. setSchriftFarbe( tm->text->getLength() - txt->getLength(), tm->text->getLength(), color );
  633. unlockZeichnung();
  634. txt->release();
  635. if( hatStyle( Style::VScroll ) )
  636. updateVScroll();
  637. if( hatStyle( Style::HScroll ) )
  638. updateHScroll();
  639. rend = 1;
  640. }
  641. }
  642. // Deselectiert alle textabschnitte
  643. void TextFeld::deselectAuswahl()
  644. {
  645. for( int i = 0; i < tm->textStyle.getEintragAnzahl(); i++ )
  646. {
  647. TextStyle s = tm->textStyle.get( i );
  648. if( s.selected )
  649. {
  650. s.selected = 0;
  651. tm->textStyle.set( s, i );
  652. }
  653. }
  654. tm->cleanupStyles();
  655. }
  656. void TextFeld::setAuswahl( int pos1, int pos2 ) // setzt den Ausgewählten Text
  657. {
  658. deselectAuswahl();
  659. TextStyle s = tm->getTextStyle( pos1 );
  660. s.selected = 1;
  661. tm->setTextStyle( pos1, pos2, s );
  662. }
  663. void TextFeld::setAuswahl( Punkt & auswahl )
  664. {
  665. deselectAuswahl();
  666. TextStyle s = tm->getTextStyle( auswahl.x );
  667. s.selected = 1;
  668. tm->setTextStyle( auswahl.x, auswahl.y, s );
  669. rend = 1;
  670. }
  671. void TextFeld::addAuswahl( int pos1, int pos2 )
  672. {
  673. TextStyle s = tm->getTextStyle( pos1 );
  674. s.selected = 1;
  675. tm->setTextStyle( pos1, pos2, s );
  676. }
  677. void TextFeld::addAuswahl( Punkt & auswahl )
  678. {
  679. TextStyle s = tm->getTextStyle( auswahl.x );
  680. s.selected = 1;
  681. tm->setTextStyle( auswahl.x, auswahl.y, s );
  682. rend = 1;
  683. }
  684. // Setzt den ausgewählten textabschnitt fest
  685. // begin: Die Cursorposition im Text
  686. // end: Die Position im Text, bis zu der der Text eingefärbt werden soll
  687. void TextFeld::invertAuswahl( int begin, int end )
  688. {
  689. for( int i = begin; i < end; i++ )
  690. {
  691. TextStyle s = tm->getTextStyle( i );
  692. s.selected = !s.selected;
  693. tm->setTextStyle( i, i + 1, s );
  694. rend = 1;
  695. }
  696. }
  697. // ersetzt alle ausgewählten Textabschnitte mit einem text
  698. // text: der neue Text
  699. void TextFeld::replaceAuswahl( const char *text )
  700. {
  701. tm->cleanupStyles();
  702. int sa = tm->textStyle.getEintragAnzahl();
  703. int last = tm->text->getLength();
  704. int si = 0;
  705. for( int i = sa - 1; i >= 0; i-- )
  706. {
  707. TextStyle s = tm->textStyle.get( i );
  708. si = i;
  709. if( s.selected )
  710. {
  711. if( ( i > 0 && !tm->textStyle.get( i - 1 ).selected ) || i == 0 )
  712. {
  713. s.selected = false;
  714. tm->textStyle.set( s, si );
  715. tm->removeText( s.beginIndex, last );
  716. tm->insertText( s.beginIndex, text );
  717. }
  718. }
  719. else
  720. last = s.beginIndex;
  721. }
  722. }
  723. void TextFeld::setTextRendererZ( TextRenderer * textRd )
  724. {
  725. if( tm->renderer )
  726. tm->renderer->leeren();
  727. else
  728. tm->renderer = new RCArray< TextRenderer >();
  729. tm->renderer->add( textRd );
  730. rend = 1;
  731. }
  732. // Fügt einen TextRenderer hinzu
  733. // textRd: Der Textrenderer
  734. void TextFeld::addTextRendererZ( TextRenderer * textRd )
  735. {
  736. if( !tm->renderer )
  737. tm->renderer = new RCArray< TextRenderer >();
  738. tm->renderer->add( textRd );
  739. }
  740. // Setzt die verwendeten TextRenderer
  741. // textRd: Die Textrenderer
  742. void TextFeld::setTextRendererZ( RCArray< TextRenderer > * textRd )
  743. {
  744. if( tm->renderer )
  745. tm->renderer->release();
  746. tm->renderer = textRd;
  747. }
  748. void TextFeld::setSchriftZ( Schrift * schrift ) // setzt einen Zeiger zur Schrift
  749. {
  750. if( !tm->renderer )
  751. tm->renderer = new RCArray< TextRenderer >();
  752. if( !tm->renderer->getEintragAnzahl() )
  753. tm->renderer->add( new TextRenderer( schrift ) );
  754. else
  755. tm->renderer->z( 0 )->setSchriftZ( schrift );
  756. rend = 1;
  757. }
  758. // Setzt einen Zeiger zur Schrift
  759. // rendererIndex: Der Index des Renderers dessen Schrift gesetzt werden soll
  760. // schrift: Die Schrift, die zum Textzeichnen verwendet werden soll.
  761. void TextFeld::setSchriftZ( int rendererIndex, Schrift * schrift )
  762. {
  763. if( !tm->renderer )
  764. tm->renderer = new RCArray< TextRenderer >();
  765. if( tm->renderer->getEintragAnzahl() <= rendererIndex )
  766. tm->renderer->add( new TextRenderer( schrift ), rendererIndex );
  767. else
  768. tm->renderer->z( rendererIndex )->setSchriftZ( schrift );
  769. }
  770. void TextFeld::setSchriftSize( unsigned char gr ) // setzt die Schriftgröße
  771. {
  772. TextStyle s = tm->textStyle.get( 0 );
  773. s.fontSize = gr;
  774. tm->textStyle.set( s, 0 );
  775. rend = 1;
  776. }
  777. // Setzt die Schriftgröße (Standart: 12)
  778. // begin: Der Index des ersten betroffenen Zeichens
  779. // end: Der Index des ersten nicht betroffenen Zeichens
  780. // gr: Die Schriftgröße, die zum Textzeichnen verwendet werden soll
  781. void TextFeld::setSchriftSize( int begin, int end, unsigned char gr )
  782. {
  783. TextStyle s = tm->getTextStyle( begin );
  784. s.fontSize = gr;
  785. tm->setTextStyle( begin, end, s );
  786. rend = 1;
  787. }
  788. void TextFeld::setSchriftFarbe( int fc ) // setzt die Schrift Farbe
  789. {
  790. TextStyle s = tm->textStyle.get( 0 );
  791. s.fontColor = fc;
  792. tm->textStyle.set( s, 0 );
  793. rend = 1;
  794. }
  795. // Setzt die Schrift Farbe
  796. // begin: Der Index des ersten betroffenen Zeichens
  797. // end: Der Index des ersten nicht betroffenen Zeichens
  798. // fc: Die Farbe, die zum Textzeichnen verwendet werden soll
  799. void TextFeld::setSchriftFarbe( int begin, int end, int fc )
  800. {
  801. TextStyle s = tm->getTextStyle( begin );
  802. s.fontColor = fc;
  803. tm->setTextStyle( begin, end, s );
  804. rend = 1;
  805. }
  806. void TextFeld::setSchowChar( unsigned char c ) // bei Passwortfeld *
  807. {
  808. showChar = c;
  809. rend = 1;
  810. }
  811. void TextFeld::setVScrollZuZeile( int zeile ) // scrollt zur Zeile
  812. {
  813. if( vertikalScrollBar && tm->renderer && tm->renderer->getEintragAnzahl() && tm->text && hatStyle( Style::Mehrzeilig ) )
  814. {
  815. lockZeichnung();
  816. tm->resetIteration();
  817. int len = tm->text->getLength();
  818. int y = 0;
  819. int lnum = 0;
  820. char *text = tm->text->getText();
  821. int max = 0;
  822. for( int i = 0; i < len && lnum < zeile; i++ )
  823. {
  824. if( text[ i ] == '\n' )
  825. {
  826. lnum++;
  827. y += max;
  828. max = 0;
  829. tm->nextStyle();
  830. continue;
  831. }
  832. TextRenderer *r = tm->zCurrentRenderer();
  833. if( r )
  834. {
  835. int tmp = r->getZeilenabstand() + r->getZeilenHeight();
  836. max = max >= tmp ? max : tmp;
  837. }
  838. tm->nextStyle();
  839. }
  840. unlockZeichnung();
  841. vertikalScrollBar->scroll( y );
  842. rend = 1;
  843. }
  844. }
  845. void TextFeld::updateVScroll( int pos ) // scrollt nach unten
  846. {
  847. if( pos == -1 )
  848. pos = cpos;
  849. if( vertikalScrollBar )
  850. {
  851. int sPos = 0;
  852. int hi = 0;
  853. int sPosZH = 0;
  854. if( tm->text && tm->renderer )
  855. {
  856. if( hatStyleNicht( Style::Mehrzeilig ) )
  857. tm->text->remove( '\n' );
  858. hi = gr.y;
  859. if( hatStyle( Style::Rahmen ) && rahmen )
  860. hi -= rahmen->getRBreite() * 2;
  861. if( hatStyle( Style::HScroll ) && horizontalScrollBar )
  862. hi -= 15;
  863. int th = 0;
  864. lockZeichnung();
  865. tm->resetIteration();
  866. int len = tm->text->getLength();
  867. char *text = tm->text->getText();
  868. int max = 0;
  869. int lastMax = 0;
  870. for( int i = 0; i < len; i++ )
  871. {
  872. if( text[ i ] == '\n' )
  873. {
  874. if( i <= pos )
  875. {
  876. sPos += max;
  877. sPosZH = max;
  878. }
  879. th += max;
  880. lastMax = max;
  881. max = 0;
  882. tm->nextStyle();
  883. continue;
  884. }
  885. TextRenderer *r = tm->zCurrentRenderer();
  886. if( r )
  887. {
  888. int tmp = r->getZeilenabstand() + r->getZeilenHeight();
  889. max = max >= tmp ? max : tmp;
  890. }
  891. tm->nextStyle();
  892. }
  893. if( max != lastMax && max > 0 )
  894. {
  895. th += max;
  896. lastMax = max;
  897. }
  898. th += lastMax;
  899. unlockZeichnung();
  900. vertikalScrollBar->update( th, hi );
  901. }
  902. if( sPos - sPosZH < vertikalScrollBar->getScroll() )
  903. vertikalScrollBar->scroll( sPos - sPosZH );
  904. if( sPos + sPosZH > vertikalScrollBar->getScroll() + vertikalScrollBar->getScrollData()->anzeige )
  905. vertikalScrollBar->scroll( sPos + sPosZH * 2 - hi );
  906. rend = 1;
  907. }
  908. }
  909. void TextFeld::updateHScroll( int pos ) // scrollt zur Curser Position
  910. {
  911. if( pos == -1 )
  912. pos = cpos;
  913. lockZeichnung();
  914. if( horizontalScrollBar && tm->text && tm->renderer )
  915. {
  916. if( hatStyleNicht( Style::Mehrzeilig ) )
  917. tm->text->remove( '\n' );
  918. int br = gr.x;
  919. if( hatStyle( Style::Rahmen ) && rahmen )
  920. br -= rahmen->getRBreite() * 2;
  921. if( hatStyle( Style::VScroll ) && vertikalScrollBar )
  922. br -= 15;
  923. tm->resetIteration();
  924. int maxBr = 0;
  925. int len = tm->text->getLength();
  926. char *text = tm->text->getText();
  927. int lineBr = 0;
  928. char buff[] = { 0,0 };
  929. int cbr = 0;
  930. for( int i = 0; i < len; i++ )
  931. {
  932. buff[ 0 ] = text[ i ];
  933. if( text[ i ] == '\n' )
  934. {
  935. maxBr = maxBr >= lineBr ? maxBr : lineBr;
  936. lineBr = 0;
  937. tm->nextStyle();
  938. continue;
  939. }
  940. TextRenderer *r = tm->zCurrentRenderer();
  941. if( r )
  942. {
  943. lineBr += r->getTextBreite( buff );
  944. if( i <= pos )
  945. cbr = lineBr;
  946. }
  947. tm->nextStyle();
  948. }
  949. maxBr = maxBr >= lineBr ? maxBr : lineBr;
  950. horizontalScrollBar->update( maxBr, br );
  951. if( cbr > horizontalScrollBar->getScroll() + horizontalScrollBar->getScrollData()->anzeige )
  952. horizontalScrollBar->scroll( cbr - br );
  953. if( cbr < horizontalScrollBar->getScroll() )
  954. horizontalScrollBar->scroll( cbr );
  955. }
  956. unlockZeichnung();
  957. }
  958. // Gibt die breite in pixeln zurück, die benötigt wird um den aktuellen text mit den aktuellen styles voll anzuzeigen
  959. int TextFeld::getNeededWidth()
  960. {
  961. int maxBr = 0;
  962. lockZeichnung();
  963. if( tm->text && tm->renderer )
  964. maxBr = getTextWidth();
  965. unlockZeichnung();
  966. return maxBr;
  967. }
  968. // Gibt die höhe in pixeln zurück, die benötigt wird um den aktuellen text mit den aktuellen styles voll anzuzeigen
  969. int TextFeld::getNeededHeight()
  970. {
  971. int th = 0;
  972. lockZeichnung();
  973. if( tm->text && tm->renderer )
  974. th = getTextHeight();
  975. unlockZeichnung();
  976. return th;
  977. }
  978. bool TextFeld::tick( double tickval ) // tick
  979. {
  980. if( hatStyle( Style::Fokus ) )
  981. {
  982. if( tickVal < 0.5 && tickVal + tickval >= 0.5 )
  983. rend = 1;
  984. if( tickVal >= 0.5 && tickVal + tickval >= 1 )
  985. rend = 1;
  986. tickVal += tickval;
  987. if( tickVal >= 1 )
  988. tickVal -= 1;
  989. }
  990. return ZeichnungHintergrund::tick( tickval );
  991. }
  992. void TextFeld::doMausEreignis( MausEreignis & me ) // Maus Ereignis
  993. {
  994. bool nmakc = !me.verarbeitet;
  995. if( hatStyleNicht( Style::Erlaubt ) || hatStyleNicht( Style::Sichtbar ) )
  996. {
  997. if( toolTip )
  998. toolTip->setMausIn( 0 );
  999. me.mx -= pos.x, me.my -= pos.y;
  1000. int rbr = 0;
  1001. if( rahmen )
  1002. rbr = rahmen->getRBreite();
  1003. if( ( ( vertikalScrollBar && hatStyle( Style::VScroll ) ) ||
  1004. ( horizontalScrollBar && hatStyle( Style::HScroll ) ) ) &&
  1005. me.mx > rbr && me.mx < gr.x - rbr &&
  1006. me.my > rbr && me.my < gr.y - rbr )
  1007. {
  1008. vertikalScrollBar->doMausMessage( gr.x - rbr - 15, rbr, 15, gr.y - rbr * 2, me );
  1009. horizontalScrollBar->doMausMessage( rbr, gr.y - rbr * 2 - 15, gr.x - rbr * 2 - ( ( vertikalScrollBar && hatStyle( Style::VScroll ) ) ? 15 : 0 ), 15, me );
  1010. me.verarbeitet = 1;
  1011. }
  1012. me.mx += pos.x, me.my += pos.y;
  1013. mausKlick = 0;
  1014. return;
  1015. }
  1016. bool removeFokus = 0;
  1017. if( me.verarbeitet || !( me.mx >= pos.x && me.mx <= pos.x + gr.x && me.my >= pos.y && me.my <= pos.y + gr.y ) )
  1018. {
  1019. if( mausIn )
  1020. {
  1021. mausIn = 0;
  1022. if( toolTip )
  1023. toolTip->setMausIn( 0 );
  1024. MausEreignis me2;
  1025. me2.id = ME_Leaves;
  1026. me2.mx = me.mx;
  1027. me2.my = me.my;
  1028. me2.verarbeitet = 0;
  1029. doMausEreignis( me2 );
  1030. return;
  1031. }
  1032. removeFokus = 1;
  1033. }
  1034. 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 )
  1035. {
  1036. if( removeFokus && me.id == ME_RLinks )
  1037. {
  1038. me.mx -= pos.x, me.my -= pos.y;
  1039. if( hatStyle( Style::Fokus ) && mak && ( me.verarbeitet || mak( makParam, this, me ) ) )
  1040. removeStyle( Style::Fokus );
  1041. if( nmakc && me.verarbeitet && nMak )
  1042. me.verarbeitet = nMak( nmakParam, this, me );
  1043. me.mx += pos.x, me.my += pos.y;
  1044. }
  1045. if( toolTip )
  1046. toolTip->setMausIn( 0 );
  1047. return;
  1048. }
  1049. if( !mausIn && me.id != ME_Leaves )
  1050. {
  1051. mausIn = 1;
  1052. if( toolTip )
  1053. toolTip->setMausIn( 1 );
  1054. MausEreignis me2;
  1055. me2.id = ME_Betritt;
  1056. me2.mx = me.mx;
  1057. me2.my = me.my;
  1058. me2.verarbeitet = 0;
  1059. doMausEreignis( me2 );
  1060. }
  1061. me.mx -= pos.x, me.my -= pos.y;
  1062. if( mak && ( me.verarbeitet || mak( makParam, this, me ) ) )
  1063. {
  1064. if( removeFokus && me.id == ME_RLinks )
  1065. removeStyle( Style::Fokus );
  1066. if( !me.verarbeitet )
  1067. {
  1068. if( hatStyleNicht( Style::Fokus ) )
  1069. {
  1070. mausKlick = 0;
  1071. if( me.id == Framework::ME_PLinks )
  1072. addStyle( Style::Fokus );
  1073. }
  1074. int rbr = 0;
  1075. if( rahmen )
  1076. rbr = rahmen->getRBreite();
  1077. if( vertikalScrollBar && hatStyle( Style::VScroll ) )
  1078. {
  1079. if( vertikalScrollBar->doMausMessage( gr.x - rbr - 15, rbr, 15, gr.y - rbr * 2, me ) )
  1080. {
  1081. if( nmakc && me.verarbeitet && nMak )
  1082. me.verarbeitet = nMak( nmakParam, this, me );
  1083. me.mx += pos.x, me.my += pos.y;
  1084. return;
  1085. }
  1086. }
  1087. if( horizontalScrollBar && hatStyle( Style::HScroll ) )
  1088. {
  1089. if( horizontalScrollBar->doMausMessage( rbr, gr.y - rbr - 15, gr.x - rbr * 2 - ( ( vertikalScrollBar && hatStyle( Style::VScroll ) ) ? 15 : 0 ), 15, me ) )
  1090. {
  1091. if( nmakc && me.verarbeitet && nMak )
  1092. me.verarbeitet = nMak( nmakParam, this, me );
  1093. me.mx += pos.x, me.my += pos.y;
  1094. return;
  1095. }
  1096. }
  1097. bool shift = TastenStand[ T_Shift ];
  1098. bool strg = TastenStand[ T_Strg ];
  1099. int tbr = getTextWidth();
  1100. int thi = getTextHeight();
  1101. int scrollHi = ( vertikalScrollBar && hatStyle( Style::VScroll ) ) ? vertikalScrollBar->getScroll() : 0;
  1102. int scrollBr = ( horizontalScrollBar && hatStyle( Style::HScroll ) ) ? horizontalScrollBar->getScroll() : 0;
  1103. int xxx = me.mx - rbr + scrollBr;
  1104. int yyy = me.my - rbr + scrollHi;
  1105. int mausChar = getTextIndexAt( xxx, yyy );
  1106. int scrollBreite = ( vertikalScrollBar && hatStyle( Style::VScroll ) ) * 15;
  1107. int scrollHeight = ( horizontalScrollBar && hatStyle( Style::HScroll ) ) * 15;
  1108. if( hatStyle( Style::HCenter ) )
  1109. xxx -= ( ( ( gr.x - scrollBreite ) / 2 ) - tbr / 2 ) - rbr;
  1110. if( hatStyle( Style::VCenter ) && hatStyleNicht( Style::VScroll ) )
  1111. yyy -= ( ( ( gr.y - scrollHeight ) / 2 ) - thi / 2 ) - rbr;
  1112. if( mausChar >= 0 )
  1113. {
  1114. TextStyle s = tm->getTextStyle( mausChar );
  1115. if( charEvent )
  1116. charEvent( mausChar, s.interactParam, me );
  1117. }
  1118. if( me.mx < gr.x - rbr - 15 )
  1119. {
  1120. if( tm->renderer )
  1121. {
  1122. int ncpos = getCurserPosAt( xxx, yyy );
  1123. if( me.id == Framework::ME_PLinks )
  1124. {
  1125. if( ncpos != -1 )
  1126. {
  1127. if( shift && cpos != ncpos )
  1128. addAuswahl( MIN( cpos, ncpos ), MAX( cpos, ncpos ) );
  1129. else if( !shift && !mausKlick && !strg )
  1130. deselectAuswahl();
  1131. cpos = ncpos;
  1132. rend = 1;
  1133. if( vertikalScrollBar && hatStyle( Style::VScroll ) )
  1134. updateVScroll();
  1135. if( horizontalScrollBar && hatStyle( Style::HScroll ) )
  1136. updateHScroll();
  1137. }
  1138. mausKlick = 1;
  1139. }
  1140. if( me.id == ME_Bewegung && mausKlick )
  1141. {
  1142. if( ncpos != -1 )
  1143. {
  1144. rend = 1;
  1145. if( cpos != ncpos )
  1146. invertAuswahl( MIN( cpos, ncpos ), MAX( cpos, ncpos ) );
  1147. cpos = ncpos;
  1148. if( vertikalScrollBar && hatStyle( Style::VScroll ) )
  1149. updateVScroll( cpos );
  1150. if( horizontalScrollBar && hatStyle( Style::HScroll ) )
  1151. updateHScroll( cpos );
  1152. }
  1153. }
  1154. if( me.id == ME_RLinks )
  1155. {
  1156. if( ncpos != -1 )
  1157. {
  1158. rend = 1;
  1159. if( cpos != ncpos )
  1160. invertAuswahl( MIN( cpos, ncpos ), MAX( cpos, ncpos ) );
  1161. cpos = ncpos;
  1162. if( vertikalScrollBar && hatStyle( Style::VScroll ) )
  1163. updateVScroll( cpos );
  1164. if( horizontalScrollBar && hatStyle( Style::HScroll ) )
  1165. updateHScroll( cpos );
  1166. }
  1167. mausKlick = 0;
  1168. }
  1169. }
  1170. }
  1171. }
  1172. me.verarbeitet = 1;
  1173. }
  1174. if( nmakc && me.verarbeitet && nMak )
  1175. me.verarbeitet = nMak( nmakParam, this, me );
  1176. me.mx += pos.x, me.my += pos.y;
  1177. }
  1178. void TextFeld::doTastaturEreignis( TastaturEreignis & te )
  1179. {
  1180. bool ntakc = !te.verarbeitet;
  1181. if( te.verarbeitet || hatStyleNicht( Style::Fokus ) )
  1182. return;
  1183. if( !tak )
  1184. return;
  1185. ++ref;
  1186. if( tak( takParam, this, te ) )
  1187. {
  1188. if( hatStyleNicht( Style::Erlaubt ) )
  1189. {
  1190. --ref;
  1191. if( !ref )
  1192. delete this;
  1193. return;
  1194. }
  1195. if( te.id == TE_Press )
  1196. {
  1197. bool shift = TastenStand[ T_Shift ];
  1198. bool strg = TastenStand[ T_Strg ];
  1199. switch( te.taste )
  1200. {
  1201. case T_Entf:
  1202. if( !tm->getTextStyle( cpos ).selected )
  1203. tm->removeText( cpos, cpos + 1 );
  1204. else
  1205. {
  1206. cpos = tm->getTextStyle( cpos ).beginIndex;
  1207. while( cpos > 0 && tm->getTextStyle( cpos - 1 ).selected )
  1208. cpos = tm->getTextStyle( cpos - 1 ).beginIndex;
  1209. }
  1210. replaceAuswahl( "" );
  1211. deselectAuswahl();
  1212. rend = 1;
  1213. break;
  1214. case T_BackSpace:
  1215. if( !tm->getTextStyle( cpos ).selected )
  1216. {
  1217. tm->removeText( cpos - 1, cpos );
  1218. cpos--;
  1219. }
  1220. else
  1221. {
  1222. cpos = tm->getTextStyle( cpos ).beginIndex;
  1223. while( cpos > 0 && tm->getTextStyle( cpos - 1 ).selected )
  1224. cpos = tm->getTextStyle( cpos - 1 ).beginIndex;
  1225. }
  1226. replaceAuswahl( "" );
  1227. deselectAuswahl();
  1228. rend = 1;
  1229. break;
  1230. case T_Enter:
  1231. if( !tm->getTextStyle( cpos ).selected )
  1232. tm->insertText( cpos, "\n" );
  1233. else
  1234. {
  1235. cpos = tm->getTextStyle( cpos ).beginIndex;
  1236. while( cpos > 0 && tm->getTextStyle( cpos - 1 ).selected )
  1237. cpos = tm->getTextStyle( cpos - 1 ).beginIndex;
  1238. }
  1239. replaceAuswahl( "\n" );
  1240. ++cpos;
  1241. rend = 1;
  1242. break;
  1243. case T_Links:
  1244. if( shift )
  1245. {
  1246. if( strg )
  1247. {
  1248. int tmp = tm->text->getLKick( cpos );
  1249. invertAuswahl( tmp, cpos );
  1250. cpos = tmp;
  1251. }
  1252. else
  1253. {
  1254. invertAuswahl( cpos - 1, cpos );
  1255. --cpos;
  1256. }
  1257. }
  1258. else
  1259. {
  1260. if( strg )
  1261. cpos = tm->text->getLKick( cpos );
  1262. else
  1263. --cpos;
  1264. deselectAuswahl();
  1265. }
  1266. rend = 1;
  1267. break;
  1268. case T_Oben:
  1269. {
  1270. int tmp = tm->text->getOKick( cpos );
  1271. invertAuswahl( tmp, cpos );
  1272. cpos = tmp;
  1273. if( !shift )
  1274. deselectAuswahl();
  1275. rend = 1;
  1276. break;
  1277. }
  1278. case T_Rechts:
  1279. if( shift )
  1280. {
  1281. if( strg )
  1282. {
  1283. int tmp = tm->text->getRKick( cpos );
  1284. invertAuswahl( cpos, tmp );
  1285. cpos = tmp;
  1286. }
  1287. else
  1288. {
  1289. invertAuswahl( cpos, cpos + 1 );
  1290. ++cpos;
  1291. }
  1292. }
  1293. else
  1294. {
  1295. if( strg )
  1296. cpos = tm->text->getRKick( cpos );
  1297. else
  1298. ++cpos;
  1299. deselectAuswahl();
  1300. }
  1301. rend = 1;
  1302. break;
  1303. case T_Unten:
  1304. {
  1305. int tmp = tm->text->getUKick( cpos );
  1306. invertAuswahl( cpos, tmp );
  1307. cpos = tmp;
  1308. if( !shift )
  1309. deselectAuswahl();
  1310. rend = 1;
  1311. break;
  1312. }
  1313. default:
  1314. if( strg && te.id == TE_Press )
  1315. {
  1316. if( te.taste == 'c' || te.taste == 'C' )
  1317. {
  1318. int sa = tm->textStyle.getEintragAnzahl();
  1319. int length = 0;
  1320. for( int i = 0; i < sa; i++ )
  1321. {
  1322. TextStyle s = tm->textStyle.get( i );
  1323. if( s.selected )
  1324. {
  1325. int max = tm->text->getLength();
  1326. if( i < sa - 1 )
  1327. max = tm->textStyle.get( i + 1 ).beginIndex;
  1328. length += max - s.beginIndex;
  1329. }
  1330. }
  1331. if( length )
  1332. {
  1333. char *txt = new char[ length + 1 ];
  1334. txt[ length ] = 0;
  1335. int index = 0;
  1336. for( int i = 0; i < sa; i++ )
  1337. {
  1338. TextStyle s = tm->textStyle.get( i );
  1339. if( s.selected )
  1340. {
  1341. int max = tm->text->getLength();
  1342. if( i < sa - 1 )
  1343. max = tm->textStyle.get( i + 1 ).beginIndex;
  1344. memcpy( txt + index, tm->text->getText() + s.beginIndex, max - s.beginIndex );
  1345. index += max - s.beginIndex;
  1346. }
  1347. }
  1348. TextKopieren( txt );
  1349. delete[] txt;
  1350. }
  1351. else
  1352. TextKopieren( tm->text->getText() );
  1353. }
  1354. if( te.taste == 'v' || te.taste == 'V' )
  1355. {
  1356. char *txt = TextInsert();
  1357. if( !tm->getTextStyle( cpos ).selected )
  1358. tm->insertText( cpos, txt );
  1359. else
  1360. {
  1361. cpos = tm->getTextStyle( cpos ).beginIndex;
  1362. while( cpos > 0 && tm->getTextStyle( cpos - 1 ).selected )
  1363. cpos = tm->getTextStyle( cpos - 1 ).beginIndex;
  1364. }
  1365. replaceAuswahl( txt );
  1366. cpos += textLength( txt );
  1367. rend = 1;
  1368. }
  1369. break;
  1370. }
  1371. if( istSchreibbar( te.taste ) )
  1372. {
  1373. char buff[] = { (char)te.taste, 0 };
  1374. if( !tm->getTextStyle( cpos ).selected )
  1375. tm->insertText( cpos, buff );
  1376. else
  1377. {
  1378. cpos = tm->getTextStyle( cpos ).beginIndex;
  1379. while( cpos > 0 && tm->getTextStyle( cpos - 1 ).selected )
  1380. cpos = tm->getTextStyle( cpos - 1 ).beginIndex;
  1381. }
  1382. replaceAuswahl( buff );
  1383. ++cpos;
  1384. rend = 1;
  1385. }
  1386. break;
  1387. }
  1388. }
  1389. if( cpos < 0 )
  1390. cpos = 0;
  1391. if( cpos > tm->text->getLength() )
  1392. cpos = tm->text->getLength();
  1393. if( hatStyle( Style::VScroll ) )
  1394. updateVScroll( cpos );
  1395. if( hatStyle( Style::HScroll ) )
  1396. updateHScroll( cpos );
  1397. te.verarbeitet = 1;
  1398. }
  1399. --ref;
  1400. if( ntakc && te.verarbeitet && nTak )
  1401. te.verarbeitet = nTak( ntakParam, this, te );
  1402. if( !ref )
  1403. delete this;
  1404. }
  1405. void TextFeld::render( Bild & zRObj ) // zeichenet nach zRObj
  1406. {
  1407. if( hatStyleNicht( Style::Sichtbar ) )
  1408. return;
  1409. ZeichnungHintergrund::render( zRObj );
  1410. if( !tm->text || !tm->renderer )
  1411. return;
  1412. lockZeichnung();
  1413. if( !zRObj.setDrawOptions( innenPosition, innenSize ) )
  1414. {
  1415. unlockZeichnung();
  1416. return;
  1417. }
  1418. if( hatStyleNicht( Style::Mehrzeilig ) )
  1419. tm->text->remove( '\n' );
  1420. int tbr = getTextWidth();
  1421. int thi = getTextHeight();
  1422. int xxx = 0;
  1423. int yyy = 0;
  1424. int breite = innenSize.x;
  1425. int height = innenSize.y;
  1426. bool hs = horizontalScrollBar && hatStyle( Style::HScroll );
  1427. bool vs = vertikalScrollBar && hatStyle( Style::VScroll );
  1428. if( vs )
  1429. yyy -= vertikalScrollBar->getScroll();
  1430. if( hs )
  1431. xxx -= horizontalScrollBar->getScroll();
  1432. if( hatStyle( Style::HCenter ) && !hs )
  1433. xxx = ( breite / 2 ) - tbr / 2;
  1434. if( hatStyle( Style::VCenter ) && !vs )
  1435. yyy = ( height / 2 ) - thi / 2;
  1436. int x = xxx;
  1437. int y = yyy;
  1438. int len = tm->text->getLength();
  1439. char *text = tm->text->getText();
  1440. lockZeichnung();
  1441. tm->resetIteration();
  1442. TextStyle & style = tm->currentStyle();
  1443. int maxLH = 0;
  1444. for( int i = 0; i <= len; i++ )
  1445. {
  1446. int oldX = x;
  1447. if( i < len &&tm->zCurrentRenderer() )
  1448. tm->zCurrentRenderer()->renderChar( x, y, istSchreibbar( showChar ) ? showChar : text[ i ], zRObj, style.selected ? style.selectedColor : style.fontColor, style.underlined, style.selected, style.selectedBackcroundColor );
  1449. if( i == cpos && tickVal <= 0.5 && hatStyle( Style::Fokus ) && hatStyle( Style::Erlaubt ) )
  1450. zRObj.drawLinieV( oldX, y, tm->zCurrentRenderer()->getZeilenHeight(), 0xFFFF5555 );
  1451. if( tm->zCurrentRenderer() )
  1452. {
  1453. int tmp = tm->zCurrentRenderer()->getZeilenHeight() + tm->zCurrentRenderer()->getZeilenAbstand();
  1454. maxLH = tmp > maxLH ? tmp : maxLH;
  1455. }
  1456. if( i < len && text[ i ] == '\n' )
  1457. {
  1458. x = xxx;
  1459. y += maxLH;
  1460. }
  1461. tm->nextStyle();
  1462. }
  1463. unlockZeichnung();
  1464. zRObj.releaseDrawOptions();
  1465. unlockZeichnung();
  1466. }
  1467. // Konstant
  1468. Text *TextFeld::getText() const // gibt vom Text zurück
  1469. {
  1470. if( !tm->text )
  1471. return 0;
  1472. return tm->text->getThis();
  1473. }
  1474. Text *TextFeld::zText() const // gibt den Text zurück
  1475. {
  1476. return tm->text;
  1477. }
  1478. Schrift *TextFeld::getSchrift() const// gint getThis der Schrift Zurück
  1479. {
  1480. tm->resetIteration();
  1481. return tm->zCurrentRenderer() ? tm->zCurrentRenderer()->getSchrift() : 0;
  1482. }
  1483. Schrift *TextFeld::zSchrift() const// gibt die Schrift zurück
  1484. {
  1485. tm->resetIteration();
  1486. return tm->zCurrentRenderer() ? tm->zCurrentRenderer()->zSchrift() : 0;
  1487. }
  1488. // Gibt die Schrift zurück.
  1489. // rendererIndex: Der Index des Renderers dessen Schrift zurückgegeben werden soll
  1490. // return: 0, falls die Schrift nicht gesetzt wurde
  1491. Schrift *TextFeld::getSchrift( int rendererIndex ) const
  1492. {
  1493. if( tm->renderer && tm->renderer->z( rendererIndex ) )
  1494. return tm->renderer->z( rendererIndex )->getSchrift();
  1495. return 0;
  1496. }
  1497. // Gibt die Schrift ohne erhöhten Reference Counter zurük
  1498. // rendererIndex: Der Index des Renderers dessen Schrift zurückgegeben werden soll
  1499. // return: 0, falls die Schrift nicht gesetzt wurde
  1500. Schrift *TextFeld::zSchrift( int rendererIndex ) const
  1501. {
  1502. if( tm->renderer && tm->renderer->z( rendererIndex ) )
  1503. return tm->renderer->z( rendererIndex )->zSchrift();
  1504. return 0;
  1505. }
  1506. TextRenderer *TextFeld::getTextRenderer() const
  1507. {
  1508. tm->resetIteration();
  1509. return tm->zCurrentRenderer()->getThis();
  1510. }
  1511. TextRenderer *TextFeld::zTextRenderer() const
  1512. {
  1513. tm->resetIteration();
  1514. return tm->zCurrentRenderer();
  1515. }
  1516. // Gibt den TextRenderer zurück.
  1517. // index: Der Index des Renderers der zurückgegeben werden soll
  1518. // return: 0, falls der TextRenderer nicht gesetzt wurde
  1519. TextRenderer *TextFeld::getTextRenderer( int index ) const
  1520. {
  1521. if( tm->renderer && tm->renderer->z( index ) )
  1522. return tm->renderer->get( index );
  1523. return 0;
  1524. }
  1525. // Gibt dien TextRenderer ohne erhöhten Reference Counter zurük
  1526. // index: Der Index des Renderers der zurückgegeben werden soll
  1527. // return: 0, falls der TextRenderer nicht gesetzt wurde
  1528. TextRenderer *TextFeld::zTextRenderer( int index ) const
  1529. {
  1530. if( tm->renderer && tm->renderer->z( index ) )
  1531. return tm->renderer->z( index );
  1532. return 0;
  1533. }
  1534. unsigned char TextFeld::getSchriftSize() const // gibt die Schriftgröße zurück
  1535. {
  1536. tm->resetIteration();
  1537. return tm->current.fontSize;
  1538. }
  1539. // Gibt die Schriftgröße zurück
  1540. // index: Der Index des Zeichens
  1541. unsigned char TextFeld::getSchriftSize( int index ) const
  1542. {
  1543. tm->resetIteration();
  1544. return tm->current.fontSize;
  1545. }
  1546. int TextFeld::getSchriftFarbe() const// gibt getThis der Schriftfarbe zurück
  1547. {
  1548. tm->resetIteration();
  1549. return tm->current.fontColor;
  1550. }
  1551. // Gibt die Schriftfarbe im A8R8G8B8 Format zurück
  1552. // index: Der Index des Zeichens
  1553. int TextFeld::getSchriftFarbe( int index ) const
  1554. {
  1555. return tm->getTextStyle( index ).fontColor;
  1556. }
  1557. unsigned char TextFeld::getShowChar() const // gibt den Anzeige Char zurück
  1558. {
  1559. return showChar;
  1560. }
  1561. int TextFeld::getCursorPos() const
  1562. {
  1563. return cpos;
  1564. }
  1565. // Gibt 1 zurück wenn das Zeichen ausgewählt ist
  1566. // index: Der Index des Zeichens
  1567. bool TextFeld::isCharSelected( int index ) const
  1568. {
  1569. return tm->getTextStyle( index ).selected;
  1570. }
  1571. // Gibt den Index des Zeichens zurück, das sich unter der Maus befindet
  1572. // mx: die x position der maus relativ zur position des textfeldes
  1573. // my: die y position der maus relativ zut position des textfeldes
  1574. // return: -1, falls sich an der Position kein zeichen befindet
  1575. int TextFeld::getTextIndexAt( int mx, int my ) const
  1576. {
  1577. int tbr = getTextWidth();
  1578. int thi = getTextHeight();
  1579. int xxx = 0;
  1580. int yyy = 0;
  1581. int breite = innenSize.x;
  1582. int height = innenSize.y;
  1583. bool hs = horizontalScrollBar && hatStyle( Style::HScroll );
  1584. bool vs = vertikalScrollBar && hatStyle( Style::VScroll );
  1585. if( vs )
  1586. yyy -= vertikalScrollBar->getScroll();
  1587. if( hs )
  1588. xxx -= horizontalScrollBar->getScroll();
  1589. if( hatStyle( Style::HCenter ) && !hs )
  1590. xxx = ( breite / 2 ) - tbr / 2;
  1591. if( hatStyle( Style::VCenter ) && !vs )
  1592. yyy = ( height / 2 ) - thi / 2;
  1593. int x = xxx;
  1594. int y = yyy;
  1595. int len = tm->text->getLength();
  1596. char *text = tm->text->getText();
  1597. tm->resetIteration();
  1598. int maxLH = 0;
  1599. for( int i = 0; i < len; i++ )
  1600. {
  1601. int tmpx = tm->zCurrentRenderer()->getCharWidth( istSchreibbar( showChar ) ? showChar : text[ i ] );
  1602. int tmpy = tm->zCurrentRenderer()->getZeilenHeight();
  1603. if( mx >= x && mx < x + tmpx && my >= y && my < maxLH + tmpy )
  1604. return i;
  1605. if( mx < x + tmpx && my < maxLH + tmpy )
  1606. return -1;
  1607. x += tmpx + tm->zCurrentRenderer()->getZeichenAbstand();
  1608. tmpy += tm->zCurrentRenderer()->getZeilenAbstand();
  1609. maxLH = tmpy > maxLH ? tmpy : maxLH;
  1610. if( text[ i ] == '\n' )
  1611. {
  1612. x = xxx;
  1613. y += maxLH;
  1614. }
  1615. tm->nextStyle();
  1616. }
  1617. return -1;
  1618. }
  1619. // Gibt den Index des Zeichens zurück, vor dem der curser gesetzt wird, wenn mit der maus geklickt wird
  1620. // mx: die x position der maus relativ zur position des textfeldes
  1621. // my: die y position der maus relativ zut position des textfeldes
  1622. int TextFeld::getCurserPosAt( int mx, int my ) const
  1623. {
  1624. int tbr = getTextWidth();
  1625. int thi = getTextHeight();
  1626. int xxx = 0;
  1627. int yyy = 0;
  1628. int breite = innenSize.x;
  1629. int height = innenSize.y;
  1630. bool hs = horizontalScrollBar && hatStyle( Style::HScroll );
  1631. bool vs = vertikalScrollBar && hatStyle( Style::VScroll );
  1632. if( vs )
  1633. yyy -= vertikalScrollBar->getScroll();
  1634. if( hs )
  1635. xxx -= horizontalScrollBar->getScroll();
  1636. if( hatStyle( Style::HCenter ) && !hs )
  1637. xxx = ( breite / 2 ) - tbr / 2;
  1638. if( hatStyle( Style::VCenter ) && !vs )
  1639. yyy = ( height / 2 ) - thi / 2;
  1640. int x = xxx;
  1641. int y = yyy;
  1642. int len = tm->text->getLength();
  1643. char *text = tm->text->getText();
  1644. tm->resetIteration();
  1645. int maxLH = 0;
  1646. for( int i = 0; i < len; i++ )
  1647. {
  1648. int tmpx = tm->zCurrentRenderer()->getCharWidth( istSchreibbar( showChar ) ? showChar : text[ i ] );
  1649. int tmpy = tm->zCurrentRenderer()->getZeilenHeight() + tm->zCurrentRenderer()->getZeilenAbstand();
  1650. if( mx < x + tmpx / 2 && my < y + tmpy - tm->zCurrentRenderer()->getZeilenAbstand() / 2 )
  1651. return i;
  1652. x += tmpx + tm->zCurrentRenderer()->getZeichenAbstand();
  1653. maxLH = tmpy > maxLH ? tmpy : maxLH;
  1654. if( text[ i ] == '\n' )
  1655. {
  1656. if( my >= y - tm->zCurrentRenderer()->getZeilenAbstand() / 2 && my < y + maxLH - tm->zCurrentRenderer()->getZeilenAbstand() / 2 )
  1657. return i;
  1658. x = xxx;
  1659. y += maxLH;
  1660. }
  1661. tm->nextStyle();
  1662. }
  1663. return tm->text->getLength();
  1664. }
  1665. // Gibt den Style eines bestimmten zeichens zurück
  1666. // index: Der index des Zeichensf
  1667. TextFeld::TextStyle TextFeld::getTextStyle( int index ) const
  1668. {
  1669. return tm->getTextStyle( index );
  1670. }
  1671. Zeichnung *TextFeld::dublizieren() const // Erzeugt eine Kopie des Zeichnungs
  1672. {
  1673. TextFeld *obj = new TextFeld();
  1674. obj->setPosition( pos );
  1675. obj->setSize( gr );
  1676. obj->setMausEreignisParameter( makParam );
  1677. obj->setTastaturEreignisParameter( takParam );
  1678. obj->setMausEreignis( mak );
  1679. obj->setTastaturEreignis( tak );
  1680. if( toolTip )
  1681. obj->setToolTipZ( (ToolTip *)toolTip->dublizieren() );
  1682. obj->setStyle( style );
  1683. obj->tm->renderer->release();
  1684. obj->tm->renderer = tm->renderer->getThis();
  1685. obj->tm->textStyle.leeren();
  1686. for( auto i = tm->textStyle.getIterator(); i; i++ )
  1687. obj->tm->textStyle.add( i._ );
  1688. obj->tm->index = tm->index;
  1689. obj->tm->styleIndex = tm->styleIndex;
  1690. obj->tm->current = tm->current;
  1691. if( tm->text )
  1692. obj->setText( tm->text->getText() );
  1693. obj->setHintergrundFarbe( hintergrundFarbe );
  1694. if( hintergrundFeld )
  1695. obj->setAlphaFeldZ( (AlphaFeld *)hintergrundFeld->dublizieren() );
  1696. if( rahmen )
  1697. obj->setRahmenZ( (Rahmen *)rahmen->dublizieren() );
  1698. if( hintergrundBild )
  1699. obj->setHintergrundBild( hintergrundBild->getThis() );
  1700. if( vertikalScrollBar )
  1701. {
  1702. obj->setVertikalKlickScroll( vertikalScrollBar->getKlickScroll() );
  1703. obj->setVertikalScrollPos( vertikalScrollBar->getScroll() );
  1704. obj->setVertikalScrollFarbe( vertikalScrollBar->getFarbe(), vertikalScrollBar->getBgFarbe() );
  1705. }
  1706. if( horizontalScrollBar )
  1707. {
  1708. obj->setHorizontalKlickScroll( horizontalScrollBar->getKlickScroll() );
  1709. obj->setHorizontalScrollPos( horizontalScrollBar->getScroll() );
  1710. obj->setHorizontalScrollFarbe( horizontalScrollBar->getFarbe(), horizontalScrollBar->getBgFarbe() );
  1711. }
  1712. obj->setSchowChar( showChar );
  1713. return obj;
  1714. }